|
48 | 48 | # Only download resources with proper access level
|
49 | 49 | if ($access==0)
|
50 | 50 | {
|
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"]); |
52 | 52 | if (!file_exists($p))
|
53 | 53 | {
|
54 | 54 | # If the file doesn't exist for this size, then the original file must be in the requested size.
|
55 | 55 | # 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"]); |
57 | 57 | }
|
58 | 58 | if (file_exists($p))
|
59 | 59 | {
|
60 | 60 | # when writing metadata, we take an extra security measure by copying the files to filestore/tmp
|
61 | 61 |
|
62 | 62 | $tmpfile=write_metadata($p,$ref);
|
63 |
| - if($tmpfile!="" && file_exists($tmpfile)){$p=$tmpfile;} |
| 63 | + if($tmpfile!==false && file_exists($tmpfile)){$p=$tmpfile;} |
64 | 64 |
|
65 | 65 |
|
66 | 66 | # if the tmpfile is made, from here on we are working with that.
|
|
69 | 69 | # If using original filenames when downloading, copy the file to new location so the name is included.
|
70 | 70 | if ($original_filenames_when_downloading)
|
71 | 71 | {
|
72 |
| - if(!is_dir("filestore/tmp")){mkdir("filestore/tmp",0777);} |
| 72 | + if(!is_dir(dirname(__FILE__) . "/../filestore/tmp")){mkdir(dirname(__FILE__) . "/../filestore/tmp",0777);} |
73 | 73 | # Retrieve the original file name (strip the path if it's present due to staticsync.php)
|
74 | 74 | $filename=get_resource_data($ref);
|
75 | 75 | # Prepend file name with resource ID to prevent collisions
|
|
85 | 85 | $fs=explode("/",$filename);$filename=$fs[count($fs)-1];
|
86 | 86 |
|
87 | 87 | # Copy to a new location
|
88 |
| - $newpath="filestore/tmp/" . $filename; |
| 88 | + $newpath=dirname(__FILE__) . "/../filestore/tmp/" . $filename; |
89 | 89 | copy($p,$newpath);
|
90 | 90 |
|
91 | 91 | # Add the temporary file to the post-zip deletion list.
|
|
118 | 118 |
|
119 | 119 | # build an array of paths so we can clean up any exiftool-modified files.
|
120 | 120 |
|
121 |
| - if($tmpfile!="" && file_exists($tmpfile)){$deletion_array[]=$tmpfile;} |
| 121 | + if($tmpfile!==false && file_exists($tmpfile)){$deletion_array[]=$tmpfile;} |
122 | 122 | daily_stat("Resource download",$ref);
|
123 | 123 | resource_log($ref,'d',0);
|
124 | 124 | }
|
|
128 | 128 |
|
129 | 129 | # write text file, add to zip, and schedule for deletion
|
130 | 130 | 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"; |
132 | 132 | $fh = fopen($textfile, 'w') or die("can't open file");
|
133 | 133 | fwrite($fh, $text);
|
134 | 134 | fclose($fh);
|
|
138 | 138 | }
|
139 | 139 |
|
140 | 140 | # 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);} |
142 | 142 |
|
143 | 143 | $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); |
146 | 146 |
|
147 | 147 | header("Content-Disposition: attachment; filename=" . $file);
|
148 | 148 | header("Content-Type: application/zip");
|
149 | 149 | header("Content-Length: " . $filesize);
|
150 | 150 |
|
151 | 151 | set_time_limit(0);
|
152 |
| - echo file_get_contents("filestore/tmp/" . $file); |
| 152 | + echo file_get_contents(dirname(__FILE__) . "/../filestore/tmp/" . $file); |
153 | 153 |
|
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);} |
156 | 156 | exit();
|
157 | 157 | }
|
158 | 158 | include "../include/header.php";
|
|
0 commit comments