X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=index.php;h=7d866367d72263ab54ada5cac935827f642e0ad2;hb=4376a1aa26c2698a777cbd86ef3d421f0248f39e;hp=4f33d3e7cbef5948f7b3ea2edfedc058d010c87f;hpb=9c50e9818959b534c23a3077ede8e609882a7ed5;p=simple-upload.git diff --git a/index.php b/index.php index 4f33d3e..7d86636 100644 --- a/index.php +++ b/index.php @@ -62,9 +62,21 @@ // Files that will be ignored 'ignores' => array('.', '..', 'LICENSE', 'README.md'), + + // Language code + 'lang' => 'en_GB', + + // Language direction + 'lang_dir' => 'ltr', ); // =============={ Configuration End }============== + // Is the local config file there? + if (file_exists('config-local.php')) { + // Load it then + include('config-local.php'); + } + // Enabling error reporting if ($settings['debug']) { error_reporting(E_ALL); @@ -82,7 +94,7 @@ $data['ignores'][] = $data['scriptname']; // Use canonized path - $data['uploaddir'] = realpath($settings['uploaddir']); + $data['uploaddir'] = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . $settings['uploaddir']); // Maximum upload size, set by system $data['max_upload_size'] = ini_get('upload_max_filesize'); @@ -94,7 +106,7 @@ // 'User ID' if (!isset($_SESSION['upload_user_id'])) - $_SESSION['upload_user_id'] = rand(100000, 999999); + $_SESSION['upload_user_id'] = mt_rand(100000, 999999); // List of filenames that were uploaded by this user if (!isset($_SESSION['upload_user_files'])) @@ -124,7 +136,7 @@ } // Format file size - function FormatSize ($bytes) { + function formatSize ($bytes) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); @@ -137,7 +149,7 @@ } // Rotating a two-dimensional array - function DiverseArray ($vector) { + function diverseArray ($vector) { $result = array(); foreach ($vector as $key1 => $value1) foreach ($value1 as $key2 => $value2) @@ -146,7 +158,7 @@ } // Handling file upload - function UploadFile ($file_data) { + function uploadFile ($file_data) { global $settings; global $data; global $_SESSION; @@ -159,7 +171,7 @@ do { $file_data['target_file_name'] = ''; while (strlen($file_data['target_file_name']) < $settings['random_name_len']) - $file_data['target_file_name'] .= $settings['random_name_alphabet'][rand(0, strlen($settings['random_name_alphabet']) - 1)]; + $file_data['target_file_name'] .= $settings['random_name_alphabet'][mt_rand(0, strlen($settings['random_name_alphabet']) - 1)]; if ($settings['random_name_keep_type']) $file_data['target_file_name'] .= '.' . pathinfo($file_data['uploaded_file_name'], PATHINFO_EXTENSION); } while (file_exists($file_data['target_file_name'])); @@ -187,11 +199,11 @@ if (isset($_FILES['file'])) { header('Content-type: text/plain'); if (is_array($_FILES['file'])) { - $file_array = DiverseArray($_FILES['file']); + $file_array = diverseArray($_FILES['file']); foreach ($file_array as $file_data) - UploadFile($file_data); + uploadFile($file_data); } else - UploadFile($_FILES['file']); + uploadFile($_FILES['file']); exit; } @@ -222,7 +234,7 @@ } // List files in a given directory, excluding certain files - function ListFiles ($dir, $exclude) { + function listFiles ($dir, $exclude) { $file_array = array(); $dh = opendir($dir); while (false !== ($filename = readdir($dh))) @@ -233,21 +245,25 @@ return $file_array; } - $file_array = ListFiles($settings['uploaddir'], $data['ignores']); + $file_array = listFiles($settings['uploaddir'], $data['ignores']); // Removing old files foreach ($file_array as $file) if ($settings['time_limit'] < time() - filemtime($file)) unlink($file); - $file_array = ListFiles($settings['uploaddir'], $data['ignores']); - + $file_array = listFiles($settings['uploaddir'], $data['ignores']); ?> - + + - + + + + <?=$settings['title']?> @@ -365,7 +382,7 @@ $file_private = $filename[0] === '.'; if ($settings['listfiles_size']) - $file_info[] = FormatSize(filesize($filename)); + $file_info[] = formatSize(filesize($filename)); if ($settings['listfiles_size']) $file_info[] = date($settings['listfiles_date_format'], $mtime);