Warning: You do not have the PHP ZIP extension installed.
Please install the PHP-zip extension before moving forward
';
22 | }
23 |
24 | echo '
php.ini specifies your server\'s maximum upload filesize as: '.min(ini_get('post_max_size'), ini_get('upload_max_filesize')).'
To change this, edit the value of upload_max_filesize(currently '.ini_get('upload_max_filesize').') in your php.ini The value of post_max_size(currently '.ini_get('post_max_size').') must always be larger than upload_max_filesize
';
25 |
26 | echo '
php.ini specifies that your server can permit uploads of up to '.ini_get('max_file_uploads').' files in one request
To change this, edit the value of max_file_uploads in your php.ini
130 |
131 |
132 |
--------------------------------------------------------------------------------
/simplefs-cron.php:
--------------------------------------------------------------------------------
1 | 0)) {
25 | // If the user doesn't have "auto-delete files" enabled, there's nothing to be done here
26 | $i = $i + 1;
27 | continue; // Jump to the next user
28 | }
29 | // Otherwise, carry on and delete old files
30 |
31 | $cutoff_point = ($currentTime - $delete_after_time);
32 |
33 | // Get list of files older than the cutoff point
34 | $FileIDs = contactDB("SELECT fileid FROM files WHERE fileowner=$user_id AND filedate <= $cutoff_point;", 0);
35 |
36 | // Delete files in that list
37 | foreach ($FileIDs as $file) {
38 |
39 | // Get file path
40 | $file_path = contactDB("SELECT filepath FROM files WHERE fileid=$file;", 0);
41 | $file_path = $file_path[0];
42 |
43 | unlink($file_path); // Delete file
44 |
45 | $dbChange = contactDB("DELETE FROM files WHERE fileid=$file;", 0); // Update database
46 | }
47 |
48 | $i = $i + 1;
49 | }
--------------------------------------------------------------------------------
/upload.php:
--------------------------------------------------------------------------------
1 | 1) {
23 | $target_file = $target_dir . "SimpleFS_User$currentUser " . date('Y-m-d H_i_s') . ".zip";
24 | } else {
25 | $target_file = $target_dir . basename($_FILES["upfile"]["name"][0]);
26 | }
27 |
28 | $uploadOk = true;
29 | $fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
30 |
31 |
32 | if (file_exists($target_file)) {
33 | echo "
Error: file already exists
";
34 | $uploadOk = false;
35 | }
36 |
37 | /* *************************** */
38 | /* Disallow risky file formats */
39 | /* This section is commented out by default. If for some reason you can't protect direct access to the files/ directory, it may be a good idea to uncomment the following code */
40 | /* However, SimpleFS comes with basic .htaccess files which should do the job for most users (assuming you're running Apache)
41 | /* ************************** */
42 |
43 | /*
44 | if($fileType == "php" || $fileType == "htm" || $fileType == "html" || $fileType == "phtml" || $fileType == "asp" || $fileType == "aspx" || $fileType == "axd" || $fileType == "asx" || $fileType == "asmx" || $fileType == "ashx" || $fileType == "cfm" || $fileType == "xhtml" || $fileType == "jhtml" || $fileType == "pl" || $fileType == "php4" || $fileType == "php3" || $fileType == "php5" || $fileType == "php6" || $fileType == "php7" || $fileType == "rhtml" || $fileType == "shtml") {
45 | die("Error: File type disallowed by security measure.");
46 | $uploadOk = 0;
47 | }
48 | */
49 |
50 | /* End of the aforementioned security section */
51 | /* **************************************************** */
52 |
53 | // TODO: Replace "sanitization" with prepared statements
54 |
55 | if (strpos($target_file, "'") !== false || strpos($target_file, '"') !== false) {
56 | echo "
Error: Cannot upload files with apostrophes or quote-marks
";
57 | $uploadOk = false;
58 | }
59 |
60 | /* Getting a list of all file IDs */
61 |
62 | $fileListId = contactDB("SELECT * FROM files;", 0);
63 |
64 | if ($uploadOk == false) {
65 | echo "
Error: file was not uploaded
";
66 | } else {
67 |
68 | // If the user is uploading multiple files, we'll ZIP them
69 | if (count($_FILES["upfile"]["name"]) > 1) {
70 | $zip_archive = new ZipArchive;
71 | $zip_archive->open($target_file, ZipArchive::CREATE);
72 |
73 | foreach ($_FILES["upfile"]["tmp_name"] as $key=>$tmp_file_name) {
74 | $zip_archive->addFile($tmp_file_name, basename($_FILES["upfile"]["name"][$key]));
75 | }
76 |
77 | $file_upload_complete = $zip_archive->close();
78 | } else {
79 | $file_upload_complete = move_uploaded_file($_FILES["upfile"]["tmp_name"][0], $target_file);
80 | }
81 |
82 | if ($file_upload_complete) {
83 |
84 | $newFileId = rand(10000, 99999);
85 | while (in_array($newFileId, $fileListId)) {
86 | $newFileId = rand(10000, 99999);
87 | }
88 |
89 |
90 | /* Write entry to DB */
91 |
92 | $current_date = time();
93 |
94 | $publish = contactDB("INSERT INTO files (fileid, filepath, fileowner, filedate)
95 | VALUES ($newFileId, '$target_file', $currentUser, $current_date);", 0);
96 |
97 | /* Tell the user all is well */
98 |
99 | echo "
Uploaded!
";
100 |
101 | /* Provide the download link */
102 |
103 | $download_link = get_download_link($newFileId);
104 |
105 | // Javascript is used for the "copy to clipboard" button
106 | echo "";
123 | // Display the link
124 | // If we're over SSL or on localhost, display a "copy to clipboard" button
125 | // (The browser navigator.clipboard API is only available over SSL or localhost)
126 | // (This is the answer to the GH bug report #7)
127 | echo "