]> git.mxchange.org Git - simple-upload.git/blobdiff - index.php
Opps, wrong language according to https://validator.w3.org
[simple-upload.git] / index.php
index 4f33d3e7cbef5948f7b3ea2edfedc058d010c87f..edbeaff746352cec21a4a3da24a9cbabc5c8f043 100644 (file)
--- a/index.php
+++ b/index.php
 
                // Files that will be ignored
                'ignores' => array('.', '..', 'LICENSE', 'README.md'),
+
+               // Language code
+               'lang' => 'en',
+
+               // 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');
 
                // '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']))
        }
 
        // Format file size
-       function FormatSize ($bytes) {
+       function formatSize ($bytes) {
                $units = array('B', 'KB', 'MB', 'GB', 'TB');
 
                $bytes = max($bytes, 0);
        }
 
        // Rotating a two-dimensional array
-       function DiverseArray ($vector) {
+       function diverseArray ($vector) {
                $result = array();
                foreach ($vector as $key1 => $value1)
                        foreach ($value1 as $key2 => $value2)
        }
 
        // Handling file upload
-       function UploadFile ($file_data) {
+       function uploadFile ($file_data) {
                global $settings;
                global $data;
                global $_SESSION;
                        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']));
        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;
        }
 
        }
 
        // 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)))
                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']);
 ?>
-<html lang="en-GB">
+<!DOCTYPE html>
+<html lang="<?=$settings['lang']?>" dir="<?=$settings['lang_dir']?>">
        <head>
-               <meta charset="utf-8">
+               <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+               <meta http-equiv="Content-Script-Type" content="text/javascript">
+               <meta name="robots" content="noindex">
+               <meta name="referrer" content="origin-when-crossorigin">
                <title><?=$settings['title']?></title>
                <style media="screen">
+               <!--
                        body {
                                background: #111;
                                margin: 0;
                                        opacity: 0.8;
                                }
                        }
+               //-->
                </style>
        </head>
        <body>
                                                $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);
                        </ul>
                <?php } ?>
                <a href="https://github.com/muchweb/simple-php-upload"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
-               <script charset="utf-8">
+               <script type="text/javascript">
+               <!--
                        var target_form = document.getElementById('simpleupload-form'),
                                target_ul = document.getElementById('simpleupload-ul'),
                                target_input = document.getElementById('simpleupload-input');
                                AddFileLi('Uploading...', '');
                                target_form.submit();
                        };
+               //-->
                </script>
        </body>
 </html>