@ 2014-05-21T08:35:00Z <?php
/**
* upload.php
*
* Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
#!! IMPORTANT:
#!! this file is just an example, it doesn't incorporate any security checks and
#!! is not recommended to be used in production environment as it is. Be sure to
#!! revise it and customize to your needs.
// Make sure file is not cached (as it happens for example on iOS devices)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
/*
// Support CORS
header("Access-Control-Allow-Origin: *");
// other CORS headers if any...
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
exit; // finish preflight CORS requests here
}
*/
// 5 minutes execution time
@set_time_limit(5 * 60);
// Uncomment this one to fake upload time
// usleep(5000);
// Settings
//$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'uploads';
$cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds
// Create target dir
if (!file_exists($targetDir)) {
@mkdir($targetDir);
}
// Get a file name
if (isset($_REQUEST["name"])) {
$fileName = $_REQUEST["name"];
} elseif (!empty($_FILES)) {
$fileName = $_FILES["file"]["name"];
} else {
$fileName = uniqid("file_");
}
public static function normalizeString ($str = '')
{
$str = strip_tags($str);
$str = preg_replace('/[\r\n\t ]+/', ' ', $str);
$str = preg_replace('/[\"\*\/\:\<\>\?\'\|]+/', ' ', $str);
$str = strtolower($str);
$str = html_entity_decode( $str, ENT_QUOTES, "utf-8" );
$str = htmlentities($str, ENT_QUOTES, "utf-8");
$str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
$str = str_replace(' ', '-', $str);
$str = rawurlencode($str);
$str = str_replace('%', '-', $str);
return $str;
}
$filename = normalizeString($filename)
$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
// Chunking might be enabled
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
// Remove old temp files
if ($cleanupTargetDir) {
if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}
while (($file = readdir($dir)) !== false) {
$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
// If temp file is current file proceed to the next
if ($tmpfilePath == "{$filePath}.part") {
continue;
}
// Remove temp file if it is older than the max age and is not the current file
if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
@unlink($tmpfilePath);
}
}
closedir($dir);
}
// Open temp file
if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
if (!empty($_FILES)) {
if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
}
// Read binary input stream and append it to temp file
if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
} else {
if (!$in = @fopen("php://input", "rb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
}
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
@fclose($out);
@fclose($in);
// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
}
// Return Success JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.2 0.007 0.057 17.75 7.0.1 0.010 0.073 17.75 7.0.0 0.007 0.077 17.72 5.6.17 0.007 0.043 18.25 5.6.16 0.010 0.053 18.29 5.6.15 0.010 0.070 18.22 5.6.14 0.003 0.043 18.23 5.6.13 0.020 0.047 18.21 5.6.12 0.007 0.087 18.28 5.6.11 0.017 0.077 18.22 5.6.10 0.010 0.077 18.14 5.6.9 0.013 0.070 18.17 5.6.8 0.017 0.067 17.50 5.6.7 0.013 0.070 17.56 5.6.6 0.017 0.053 17.60 5.6.5 0.010 0.050 17.53 5.6.4 0.003 0.057 17.54 5.6.3 0.007 0.043 17.51 5.6.2 0.000 0.040 17.51 5.6.1 0.007 0.073 17.62 5.6.0 0.003 0.060 17.59 5.5.31 0.003 0.040 17.95 5.5.30 0.007 0.047 18.03 5.5.29 0.010 0.043 18.05 5.5.28 0.010 0.077 18.07 5.5.27 0.010 0.083 17.94 5.5.26 0.003 0.080 17.94 5.5.25 0.007 0.053 17.86 5.5.24 0.013 0.057 17.34 5.5.23 0.003 0.063 17.36 5.5.22 0.013 0.073 17.33 5.5.21 0.000 0.090 17.41 5.5.20 0.003 0.080 17.31 5.5.19 0.007 0.033 17.32 5.5.18 0.007 0.077 17.33 5.5.16 0.020 0.063 17.33 5.5.15 0.003 0.043 17.39 5.5.14 0.010 0.070 17.35 5.5.13 0.007 0.037 17.43 5.5.12 0.003 0.080 17.30 5.5.11 0.007 0.080 17.29 5.5.10 0.007 0.073 17.21 5.5.9 0.007 0.050 17.33 5.5.8 0.003 0.080 17.20 5.5.7 0.017 0.073 17.20 5.5.6 0.000 0.070 17.23 5.5.5 0.007 0.050 17.16 5.5.4 0.010 0.077 17.33 5.5.3 0.010 0.073 17.31 5.5.2 0.003 0.067 17.19 5.5.1 0.007 0.073 17.32 5.5.0 0.007 0.080 17.18 5.4.45 0.013 0.063 19.36 5.4.44 0.017 0.073 19.36 5.4.43 0.013 0.050 19.35 5.4.42 0.003 0.080 19.36 5.4.41 0.003 0.077 19.33 5.4.40 0.010 0.047 19.05 5.4.39 0.007 0.083 19.02 5.4.38 0.010 0.063 19.03 5.4.37 0.007 0.073 19.17 5.4.36 0.000 0.050 19.05 5.4.35 0.007 0.043 19.00 5.4.34 0.003 0.043 19.05 5.4.32 0.007 0.070 19.03 5.4.31 0.007 0.040 18.99 5.4.30 0.007 0.077 18.95 5.4.29 0.003 0.047 19.09 5.4.28 0.010 0.060 19.12 5.4.27 0.010 0.070 19.05 5.4.26 0.007 0.080 19.04 5.4.25 0.010 0.070 18.97 5.4.24 0.010 0.057 19.04 5.4.23 0.003 0.080 18.96 5.4.22 0.017 0.067 19.03 5.4.21 0.007 0.047 19.00 5.4.20 0.003 0.043 19.26 5.4.19 0.003 0.070 19.02 5.4.18 0.013 0.070 19.00 5.4.17 0.007 0.037 19.10 5.4.16 0.007 0.077 18.86 5.4.15 0.007 0.080 19.03 5.4.14 0.003 0.080 16.39 5.4.13 0.007 0.043 16.41 5.4.12 0.010 0.040 16.34 5.4.11 0.007 0.060 16.41 5.4.10 0.010 0.050 16.38 5.4.9 0.000 0.043 16.39 5.4.8 0.010 0.067 16.47 5.4.7 0.013 0.033 16.53 5.4.6 0.010 0.033 16.21 5.4.5 0.003 0.057 16.36 5.4.4 0.017 0.053 16.45 5.4.3 0.010 0.067 16.40 5.4.2 0.013 0.063 16.40 5.4.1 0.007 0.033 16.40 5.4.0 0.013 0.037 15.83 5.3.29 0.010 0.060 14.67 5.3.28 0.020 0.063 14.58 5.3.27 0.000 0.057 14.39 5.3.26 0.003 0.063 14.61 5.3.25 0.003 0.077 14.56 5.3.24 0.003 0.053 14.58 5.3.23 0.007 0.077 14.52 5.3.22 0.007 0.077 14.53 5.3.21 0.007 0.060 14.50 5.3.20 0.007 0.080 14.55 5.3.19 0.003 0.043 14.35 5.3.18 0.010 0.070 14.40 5.3.17 0.003 0.073 14.65 5.3.16 0.010 0.070 14.45 5.3.15 0.003 0.047 14.56 5.3.14 0.003 0.080 14.53 5.3.13 0.000 0.053 14.52 5.3.12 0.007 0.037 14.51 5.3.11 0.003 0.037 14.37 5.3.10 0.003 0.067 14.00 5.3.9 0.003 0.047 13.96 5.3.8 0.003 0.057 13.95 5.3.7 0.007 0.053 13.97 5.3.6 0.000 0.043 13.77 5.3.5 0.007 0.077 13.94 5.3.4 0.003 0.083 14.03 5.3.3 0.007 0.070 13.88 5.3.2 0.003 0.070 13.67 5.3.1 0.013 0.037 13.62 5.3.0 0.003 0.073 13.59
preferences:dark mode live preview
143.32 ms | 1394 KiB | 7 Q