// Website title
'title' => 'strace.club',
+ // Description for this website
+ 'description' => '',
+
// Base path (auto-detection)
'base_path' => dirname(__FILE__) . DIRECTORY_SEPARATOR,
// Random file name letters
'random_name_alphabet' => 'qazwsxedcrfvtgbyhnujmikolp1234567890',
+ // Add original name (but cleaned) to file name if random file name feature is enabled?
+ 'suffix_original_name' => false,
+
// Display debugging information
'debug' => false,
- // Complete URL to your directory (including tracing slash)
- 'url' => 'http://strace.club/',
+ // Complete URL to your directory (including tracing slash, leave for auto-detection)
+ 'url' => detectServerUrl(),
// Amount of seconds that each file should be stored for (0 for no limit)
// Default 30 days
$data = array();
// Name of this file
- $data['scriptname'] = $settings['url'] . '/' . pathinfo(__FILE__, PATHINFO_BASENAME);
+ $data['scriptname'] = $settings['url'] . pathinfo(__FILE__, PATHINFO_BASENAME);
// Adding current script name to ignore list
$data['ignores'] = $settings['ignores'];
$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'][mt_rand(0, strlen($settings['random_name_alphabet']) - 1)];
+ if ($settings['suffix_original_name'])
+ $file_data['target_file_name'] .= '_' . preg_replace('/[^0-9a-zA-Z_-]/', '', pathinfo($file_data['uploaded_file_name'], PATHINFO_BASENAME));
if ($settings['random_name_keep_type'])
$file_data['target_file_name'] .= '.' . pathinfo($file_data['uploaded_file_name'], PATHINFO_EXTENSION);
} while (isReadableFile($file_data['target_file_name']));
global $data;
if (in_array(substr($file, 1), $_SESSION['upload_user_files']) || in_array($file, $_SESSION['upload_user_files'])) {
- $fqfn = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
- if (!in_array($file, $data['ignores']) && isReadableFile($fqfn)) {
+ $sourceFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . $file;
+ if (!in_array($file, $data['ignores']) && isReadableFile($sourceFile)) {
if (substr($file, 0, 1) === '.') {
- rename($fqfn, substr($fqfn, 1));
- echo 'File has been made visible';
+ $targetFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . substr($file, 1);
+ $successMessage = 'File has been made public';
+ $failedMessage = 'File has NOT been made public';
} else {
- rename($fqfn, $data['uploaddir'] . DIRECTORY_SEPARATOR . '.' . $file);
- echo 'File has been hidden';
+ $targetFile = $data['uploaddir'] . DIRECTORY_SEPARATOR . '.' . $file;
+ $successMessage = 'File has been hidden';
+ $failedMessage = 'File has NOT been hidden';
+ }
+ if (rename($sourceFile, $targetFile)) {
+ echo $successMessage;
+ } else {
+ echo $failedMessage;
}
exit;
}
return (is_file($file) && is_readable($file));
}
+ // Detects full URL of installation
+ function detectServerUrl () {
+ // Is "cache" there?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Default protocol is HTTP
+ $protocol = 'http';
+
+ // Is SSL given?
+ if (((isset($_SERVER['HTTPS'])) && (strtolower($_SERVER['HTTPS']) == 'on')) || ((isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) && (strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'))) {
+ // Protocol is HTTPS
+ $protocol = 'https';
+ } // END - if
+
+ // Construct full URL
+ $GLOBALS[__FUNCTION__] = str_replace("\\", '', sprintf('%s://%s%s/', $protocol, $_SERVER['SERVER_NAME'], dirname($_SERVER['SCRIPT_NAME'])));
+ } // END - if
+
+ // Return cached value
+ return $GLOBALS[__FUNCTION__];
+ }
+
// Files are being POSEed. Uploading them one by one.
if (isset($_FILES['file'])) {
header('Content-type: text/plain');
</head>
<body>
<h1><?=$settings['title']?></h1>
+ <p><?=$settings['description']?></p>
<form action="<?= $data['scriptname'] ?>" method="post" enctype="multipart/form-data" class="dropzone" id="simpleupload-form">
Maximum upload size: <?php echo $data['max_upload_size']; ?><br />
<input type="file" name="file[]" id="simpleupload-input" />