Skip to content

Commit 54bb696

Browse files
author
danh
committed
Fixed 'download as a zip file' which was broken after the page rearrangement.
git-svn-id: http://svn.resourcespace.org/svn/resourcespace@461 c08608d7-6e46-0410-86ca-f2a6f1370df5
1 parent 6bf9a6c commit 54bb696

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

upload/.gitignore fpdf/.gitignore

File renamed without changes.

fpdf/font/.gitignore

Whitespace-only changes.

licenses/.gitignore

Whitespace-only changes.

pages/collection_download.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@
4848
# Only download resources with proper access level
4949
if ($access==0)
5050
{
51-
$p=get_resource_path($ref,$size,false,$result[$n]["file_extension"]);
51+
$p=dirname(__FILE__) . "/../" . get_resource_path($ref,$size,false,$result[$n]["file_extension"]);
5252
if (!file_exists($p))
5353
{
5454
# If the file doesn't exist for this size, then the original file must be in the requested size.
5555
# Try again with the size omitted to get the original.
56-
$p=get_resource_path($ref,"",false,$result[$n]["file_extension"]);
56+
$p=dirname(__FILE__) . "/../" . get_resource_path($ref,"",false,$result[$n]["file_extension"]);
5757
}
5858
if (file_exists($p))
5959
{
6060
# when writing metadata, we take an extra security measure by copying the files to filestore/tmp
6161

6262
$tmpfile=write_metadata($p,$ref);
63-
if($tmpfile!="" && file_exists($tmpfile)){$p=$tmpfile;}
63+
if($tmpfile!==false && file_exists($tmpfile)){$p=$tmpfile;}
6464

6565

6666
# if the tmpfile is made, from here on we are working with that.
@@ -69,7 +69,7 @@
6969
# If using original filenames when downloading, copy the file to new location so the name is included.
7070
if ($original_filenames_when_downloading)
7171
{
72-
if(!is_dir("filestore/tmp")){mkdir("filestore/tmp",0777);}
72+
if(!is_dir(dirname(__FILE__) . "/../filestore/tmp")){mkdir(dirname(__FILE__) . "/../filestore/tmp",0777);}
7373
# Retrieve the original file name (strip the path if it's present due to staticsync.php)
7474
$filename=get_resource_data($ref);
7575
# Prepend file name with resource ID to prevent collisions
@@ -85,7 +85,7 @@
8585
$fs=explode("/",$filename);$filename=$fs[count($fs)-1];
8686

8787
# Copy to a new location
88-
$newpath="filestore/tmp/" . $filename;
88+
$newpath=dirname(__FILE__) . "/../filestore/tmp/" . $filename;
8989
copy($p,$newpath);
9090

9191
# Add the temporary file to the post-zip deletion list.
@@ -118,7 +118,7 @@
118118

119119
# build an array of paths so we can clean up any exiftool-modified files.
120120

121-
if($tmpfile!="" && file_exists($tmpfile)){$deletion_array[]=$tmpfile;}
121+
if($tmpfile!==false && file_exists($tmpfile)){$deletion_array[]=$tmpfile;}
122122
daily_stat("Resource download",$ref);
123123
resource_log($ref,'d',0);
124124
}
@@ -128,7 +128,7 @@
128128

129129
# write text file, add to zip, and schedule for deletion
130130
if (($zipped_collection_textfile==true)&&($includetext=="true")){
131-
$textfile = "filestore/tmp/".$collection."-".$collectiondata['name'].$sizetext.".txt";
131+
$textfile = dirname(__FILE__) . "/../filestore/tmp/".$collection."-".$collectiondata['name'].$sizetext.".txt";
132132
$fh = fopen($textfile, 'w') or die("can't open file");
133133
fwrite($fh, $text);
134134
fclose($fh);
@@ -138,21 +138,21 @@
138138
}
139139

140140
# Create and send the zipfile
141-
if(!is_dir("filestore/tmp")){mkdir("filestore/tmp",0777);}
141+
if(!is_dir(dirname(__FILE__) . "/../filestore/tmp")){mkdir(dirname(__FILE__) . "/../filestore/tmp",0777);}
142142

143143
$file="collection_" . $collection . "_" . $size . ".zip";
144-
exec("$zipcommand filestore/tmp/" . $file . $path);
145-
$filesize=filesize("filestore/tmp/" . $file);
144+
exec("$zipcommand " . dirname(__FILE__) . "/../filestore/tmp/" . $file . $path);
145+
$filesize=filesize(dirname(__FILE__) . "/../filestore/tmp/" . $file);
146146

147147
header("Content-Disposition: attachment; filename=" . $file);
148148
header("Content-Type: application/zip");
149149
header("Content-Length: " . $filesize);
150150

151151
set_time_limit(0);
152-
echo file_get_contents("filestore/tmp/" . $file);
152+
echo file_get_contents(dirname(__FILE__) . "/../filestore/tmp/" . $file);
153153

154-
unlink("filestore/tmp/" . $file);
155-
foreach($deletion_array as $tmpfile){delete_exif_tmpfile($tmpfile);}
154+
unlink(dirname(__FILE__) . "/../filestore/tmp/" . $file);
155+
foreach($deletion_array as $tmpfile) {delete_exif_tmpfile($tmpfile);}
156156
exit();
157157
}
158158
include "../include/header.php";

0 commit comments

Comments
 (0)