Rev 1266 | Rev 1279 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1266 | Rev 1267 | ||
---|---|---|---|
Line 204... | Line 204... | ||
204 | $uploadfile = $uploaddir . DIRECTORY_SEPARATOR . basename($req_filename); |
204 | $uploadfile = $uploaddir . DIRECTORY_SEPARATOR . basename($req_filename); |
205 | 205 | ||
206 | if (!file_exists($uploadfile)) throw new OIDplusException(_L('File does not exist')); |
206 | if (!file_exists($uploadfile)) throw new OIDplusException(_L('File does not exist')); |
207 | @unlink($uploadfile); |
207 | @unlink($uploadfile); |
208 | if (file_exists($uploadfile)) { |
208 | if (file_exists($uploadfile)) { |
209 | OIDplus::logger()->log("[ERR]OID(%1)+[ERR]A!", "Attachment file '%2' could not be deleted from object '%1' (problem with permissions?)", $id, basename($uploadfile)); |
209 | OIDplus::logger()->log("V2:[ERR]OID(%1)+[ERR]A", "Attachment file '%2' could not be deleted from object '%1' (problem with permissions?)", $id, basename($uploadfile)); |
210 | $msg = _L('Attachment file "%1" could not be deleted from object "%2" (problem with permissions?)',basename($uploadfile),$id); |
210 | $msg = _L('Attachment file "%1" could not be deleted from object "%2" (problem with permissions?)',basename($uploadfile),$id); |
211 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
211 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
212 | throw new OIDplusException($msg); |
212 | throw new OIDplusException($msg); |
213 | } else { |
213 | } else { |
214 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
214 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
Line 217... | Line 217... | ||
217 | // If it was the last file, delete the empty directory |
217 | // If it was the last file, delete the empty directory |
218 | $ary = @glob($uploaddir . DIRECTORY_SEPARATOR . '*'); |
218 | $ary = @glob($uploaddir . DIRECTORY_SEPARATOR . '*'); |
219 | if (is_array($ary) && (count($ary) == 0)) @rmdir($uploaddir); |
219 | if (is_array($ary) && (count($ary) == 0)) @rmdir($uploaddir); |
220 | } |
220 | } |
221 | 221 | ||
222 | OIDplus::logger()->log("[OK]OID(%1)+[?INFO/!OK]OIDRA(%1)?/[?INFO/!OK]A?", "Deleted attachment '%2' from object '%1'", $id, basename($uploadfile)); |
222 | OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Deleted attachment '%2' from object '%1'", $id, basename($uploadfile)); |
223 | 223 | ||
224 | return array("status" => 0); |
224 | return array("status" => 0); |
225 | 225 | ||
226 | } else if ($actionID == 'uploadAttachment') { |
226 | } else if ($actionID == 'uploadAttachment') { |
227 | _CheckParamExists($params, 'id'); |
227 | _CheckParamExists($params, 'id'); |
Line 283... | Line 283... | ||
283 | $uploadfile = $uploaddir . DIRECTORY_SEPARATOR . basename($req_filename); |
283 | $uploadfile = $uploaddir . DIRECTORY_SEPARATOR . basename($req_filename); |
284 | 284 | ||
285 | if (!is_dir($uploaddir)) { |
285 | if (!is_dir($uploaddir)) { |
286 | @mkdir($uploaddir, 0777, true); |
286 | @mkdir($uploaddir, 0777, true); |
287 | if (!is_dir($uploaddir)) { |
287 | if (!is_dir($uploaddir)) { |
288 | OIDplus::logger()->log("[ERR]OID(%1)+[ERR]A!", "Upload attachment '%2' to object '%1' failed: Cannot create directory '%3' (problem with permissions?)", $id, basename($uploadfile), basename($uploaddir)); |
288 | OIDplus::logger()->log("V2:[ERR]OID(%1)+[ERR]A", "Upload attachment '%2' to object '%1' failed: Cannot create directory '%3' (problem with permissions?)", $id, basename($uploadfile), basename($uploaddir)); |
289 | $msg = _L('Upload attachment "%1" to object "%2" failed',basename($uploadfile),$id).': '._L('Cannot create directory "%1" (problem with permissions?)',basename($uploaddir)); |
289 | $msg = _L('Upload attachment "%1" to object "%2" failed',basename($uploadfile),$id).': '._L('Cannot create directory "%1" (problem with permissions?)',basename($uploaddir)); |
290 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
290 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
291 | throw new OIDplusException($msg); |
291 | throw new OIDplusException($msg); |
292 | } else { |
292 | } else { |
293 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
293 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
294 | } |
294 | } |
295 | } |
295 | } |
296 | } |
296 | } |
297 | 297 | ||
298 | if (!@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { |
298 | if (!@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { |
299 | OIDplus::logger()->log("[ERR]OID(%1)+[ERR]A!", "Upload attachment '%2' to object '%1' failed: Cannot move uploaded file into directory (problem with permissions?)", $id, basename($uploadfile)); |
299 | OIDplus::logger()->log("V2:[ERR]OID(%1)+[ERR]A", "Upload attachment '%2' to object '%1' failed: Cannot move uploaded file into directory (problem with permissions?)", $id, basename($uploadfile)); |
300 | $msg = _L('Upload attachment "%1" to object "%2" failed',basename($uploadfile),$id).': '._L('Cannot move uploaded file into directory (problem with permissions?)'); |
300 | $msg = _L('Upload attachment "%1" to object "%2" failed',basename($uploadfile),$id).': '._L('Cannot move uploaded file into directory (problem with permissions?)'); |
301 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
301 | if (OIDplus::authUtils()->isAdminLoggedIn()) { |
302 | throw new OIDplusException($msg); |
302 | throw new OIDplusException($msg); |
303 | } else { |
303 | } else { |
304 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
304 | throw new OIDplusException($msg.'. '._L('Please contact the system administrator.')); |
305 | } |
305 | } |
306 | } |
306 | } |
307 | 307 | ||
308 | OIDplus::logger()->log("[OK]OID(%1)+[?INFO/!OK]OIDRA(%1)?/[?INFO/!OK]A?", "Uploaded attachment '%2' to object '%1'", $id, basename($uploadfile)); |
308 | OIDplus::logger()->log("V2:[OK]OID(%1)+[OK/INFO]OIDRA(%1)+[OK/INFO]A", "Uploaded attachment '%2' to object '%1'", $id, basename($uploadfile)); |
309 | 309 | ||
310 | return array("status" => 0); |
310 | return array("status" => 0); |
311 | } else { |
311 | } else { |
312 | return parent::action($actionID, $params); |
312 | return parent::action($actionID, $params); |
313 | } |
313 | } |
Line 512... | Line 512... | ||
512 | if ($uploaddir != '') { |
512 | if ($uploaddir != '') { |
513 | $ary = @glob($uploaddir . DIRECTORY_SEPARATOR . '*'); |
513 | $ary = @glob($uploaddir . DIRECTORY_SEPARATOR . '*'); |
514 | if ($ary) foreach ($ary as $a) @unlink($a); |
514 | if ($ary) foreach ($ary as $a) @unlink($a); |
515 | @rmdir($uploaddir); |
515 | @rmdir($uploaddir); |
516 | if (is_dir($uploaddir)) { |
516 | if (is_dir($uploaddir)) { |
517 | OIDplus::logger()->log("[WARN]OID(%1)+[WARN]A!", "Attachment directory '%2' could not be deleted during the deletion of the OID", $id, $uploaddir); |
517 | OIDplus::logger()->log("V2:[WARN]OID(%1)+[WARN]A", "Attachment directory '%2' could not be deleted during the deletion of the OID", $id, $uploaddir); |
518 | } |
518 | } |
519 | } |
519 | } |
520 | } |
520 | } |
521 | 521 | ||
522 | /** |
522 | /** |