00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 include_once 'config/const.Paths.php';
00026 include_once 'config/const.Options.php';
00027 include_once 'global.php';
00028
00029
00030 set_locale();
00031
00032
00033
00034
00035 $upload_source = $_POST['upload_source'];
00036 include_once "upload/$upload_source.php";
00037
00038
00039 upload_files();
00040
00041
00042 include_once 'upload/upload_message.html';
00043
00044 exit;
00045
00046
00047
00049 function set_locale()
00050 {
00051 $app_name = basename(dirname(dirname(__FILE__)));
00052 $domain = $app_name;
00053 if (LNG != UNDEFINED) setlocale(LC_MESSAGES, LNG);
00054 if (CODESET != UNDEFINED) bind_textdomain_codeset($domain, CODESET);
00055 bindtextdomain($domain, 'l10n/');
00056 textdomain($domain);
00057 }
00058
00060 function T_($msgid)
00061 {
00062 return gettext($msgid);
00063 }
00070 function check_upload_status($file)
00071 {
00072 $error = $_FILES[$file]['error'];
00073 switch ($error)
00074 {
00075 case UPLOAD_ERR_INI_SIZE:
00076 $msg = T_("File 'v_fname' exceeds the upload_max_filesize directive in php.ini.");
00077 break;
00078
00079 case UPLOAD_ERR_FORM_SIZE:
00080 $msg = T_("File 'v_fname' exceeds the MAX_FILE_SIZE directive that was specified in the html form.");
00081 break;
00082
00083 case UPLOAD_ERR_PARTIAL:
00084 $msg = T_("File 'v_fname' was only partially uploaded. Please try again.");
00085 break;
00086
00087 case UPLOAD_ERR_NO_FILE:
00088 $msg = T_("No file was uploaded. Please try again.");
00089 break;
00090
00091 default:
00092 case UPLOAD_ERR_OK:
00093 $msg = '';
00094 break;
00095 }
00096
00097 $fname = $_FILES[$file]['name'];
00098 $fname = basename($fname);
00099 $msg = str_replace('v_fname', $fname, $msg);
00100
00101 return $msg;
00102 }
00103
00109 function move_file($tmp_file, $dest_file)
00110 {
00111
00112 if (!is_uploaded_file($tmp_file))
00113 $msg = T_("File 'v_fname' not uploaded, there is some error.");
00114
00115
00116 chmod($tmp_file, 0644);
00117 $dest_dir = dirname($dest_file);
00118 shell("mkdir -p $dest_dir");
00119 shell("cp $tmp_file $dest_file");
00120 unlink($tmp_file);
00121
00122
00123 if (file_exists($dest_file))
00124 $msg = T_("File 'v_fname' uploaded successfully.");
00125 else
00126 $msg = T_("File 'v_fname' is not uploaded for some reasons.");
00127
00128 $msg = str_replace('v_fname', basename($dest_file), $msg);
00129 return $msg;
00130 }
00131 ?>