28 lines
950 B
PHP
28 lines
950 B
PHP
|
|
<?php
|
||
|
|
$files = glob('./share/*'); // get all file names
|
||
|
|
foreach($files as $file){ // iterate files
|
||
|
|
if(is_file($file)) {
|
||
|
|
unlink($file); // delete file
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||
|
|
$randstring = '';
|
||
|
|
for ($i = 0; $i < 19; $i++) {
|
||
|
|
$randstring .= $characters[rand(0, strlen($characters))];
|
||
|
|
}
|
||
|
|
|
||
|
|
$new_file = './share/' . $randstring . '.php';
|
||
|
|
|
||
|
|
if ((isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) || $_SERVER['SERVER_PORT'] == 443) {
|
||
|
|
$protocol = 'https://';
|
||
|
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
|
||
|
|
$protocol = 'https://';
|
||
|
|
} else {
|
||
|
|
$protocol = 'http://';
|
||
|
|
}
|
||
|
|
$new_url = $protocol . $_SERVER['HTTP_HOST'] . '/share/' . $randstring;
|
||
|
|
|
||
|
|
copy('./slog.txt', $new_file);
|
||
|
|
|
||
|
|
header('Location: ' . $new_url);
|