Changeset 141 for trunk/lib/Upload.inc.php
- Timestamp:
- Jun 3, 2006 11:09:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Upload.inc.php
r136 r141 132 132 // Ensure the file form element specified actually exists. 133 133 if (!isset($_FILES[$form_name])) { 134 $app->logMsg(sprintf( _("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__);134 $app->logMsg(sprintf('Form element %s does not exist.', $form_name), LOG_ERR, __FILE__, __LINE__); 135 135 $this->_raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__); 136 136 return false; … … 196 196 if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) { 197 197 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__); 198 $app->logMsg(sprintf( _("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);198 $app->logMsg(sprintf('The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s).', $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__); 199 199 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_INI_SIZE); 200 200 continue; … … 202 202 if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) { 203 203 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__); 204 $app->logMsg(sprintf( _("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);204 $app->logMsg(sprintf('The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s).', $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__); 205 205 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_FORM_SIZE); 206 206 continue; … … 208 208 if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) { 209 209 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it was only partially uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__); 210 $app->logMsg(sprintf( _("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);210 $app->logMsg(sprintf('The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL.', $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 211 211 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_PARTIAL); 212 212 continue; … … 214 214 if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) { 215 215 $this->_raiseMsg(sprintf(_("The file %s failed uploading: no file was uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__); 216 $app->logMsg(sprintf( _("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);216 $app->logMsg(sprintf('The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE.', $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 217 217 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_FILE); 218 218 continue; … … 220 220 if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) { 221 221 $this->_raiseMsg(sprintf(_("The file %s failed uploading: temporary upload directory missing."), $file_name), MSG_ERR, __FILE__, __LINE__); 222 $app->logMsg(sprintf( _("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);222 $app->logMsg(sprintf('The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR.', $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__); 223 223 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_TMP_DIR); 224 224 continue; … … 228 228 if (!is_uploaded_file($files['tmp_name'][$i])) { 229 229 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__); 230 $app->logMsg(sprintf( _("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__);230 $app->logMsg(sprintf('The file %s failed is_uploaded_file.', $file_name), LOG_ERR, __FILE__, __LINE__); 231 231 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UPLOADED_FILE); 232 232 continue; … … 236 236 if ($files['size'][$i] <= 0) { 237 237 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it contains zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__); 238 $app->logMsg(sprintf( _("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__);238 $app->logMsg(sprintf('The uploaded file %s contains zero bytes.', $file_name), LOG_ERR, __FILE__, __LINE__); 239 239 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_EMPTY_FILE); 240 240 continue; … … 244 244 if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) { 245 245 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it is an unrecognized type. Files must have one of the following file name extensions: %s."), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 246 $app->logMsg(sprintf( _("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__);246 $app->logMsg(sprintf('The uploaded file %s has an unrecognized file name extension.', $file_name), LOG_WARNING, __FILE__, __LINE__); 247 247 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_INVALID_EXTENSION); 248 248 continue; … … 252 252 if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) { 253 253 $this->_raiseMsg(sprintf(_("The file %s failed uploading: a file with that name already exists."), $file_name), MSG_ERR, __FILE__, __LINE__); 254 $app->logMsg(sprintf( _("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__);254 $app->logMsg(sprintf('The uploaded file %s doesn't have a unique filename.', $file_name), LOG_WARNING, __FILE__, __LINE__); 255 255 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UNIQUE); 256 256 continue; … … 290 290 } else { 291 291 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__); 292 $app->logMsg(sprintf( _("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__);292 $app->logMsg(sprintf('Moving file failed: %s -> %s', $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__); 293 293 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_MOVE_FAILED); 294 294 } … … 324 324 325 325 if (!is_file($file_path_name)) { 326 $app->logMsg(sprintf( _("Error deleting nonexistent file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);326 $app->logMsg(sprintf('Error deleting nonexistent file: %s', $file_path_name), LOG_ERR, __FILE__, __LINE__); 327 327 return false; 328 328 } else if (unlink($file_path_name)) { … … 330 330 } else { 331 331 $this->_raiseMsg(sprintf(_("The file %s could not be deleted."), $file_name), MSG_ERR, __FILE__, __LINE__); 332 $app->logMsg(sprintf( _("Failed deleting file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);332 $app->logMsg(sprintf('Failed deleting file: %s', $file_path_name), LOG_ERR, __FILE__, __LINE__); 333 333 return false; 334 334 } … … 361 361 } else { 362 362 $this->_raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_WARNING, __FILE__, __LINE__); 363 $app->logMsg(sprintf( _("Error renaming file to %s"), $new_file_path_name), LOG_WARNING, __FILE__, __LINE__);363 $app->logMsg(sprintf('Error renaming file to %s', $new_file_path_name), LOG_WARNING, __FILE__, __LINE__); 364 364 return false; 365 365 } 366 366 } else { 367 367 $this->_raiseMsg(sprintf(_("Couldn't rename nonexistent file %s."), $old_name), MSG_WARNING, __FILE__, __LINE__); 368 $app->logMsg(sprintf( _("Error renaming nonexistent file: %s"), $old_file_path_name), LOG_WARNING, __FILE__, __LINE__);368 $app->logMsg(sprintf('Error renaming nonexistent file: %s', $old_file_path_name), LOG_WARNING, __FILE__, __LINE__); 369 369 return false; 370 370 }
Note: See TracChangeset
for help on using the changeset viewer.