<?php
function generate_uuid() {
    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        mt_rand(0, 0xffff), mt_rand(0, 0xffff),
        mt_rand(0, 0xffff),
        mt_rand(0, 0x0fff) | 0x4000,
        mt_rand(0, 0x3fff) | 0x8000,
        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
    );
}


if (isset($_FILES['file'])) {
    $file_content = file_get_contents($_FILES["file"]["tmp_name"]);
    if (preg_match('/^[^0-9A-Za-z]+$/', $file_content)) {
        $ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
        $uuid = generate_uuid();

        move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $uuid . "." . $ext );
        echo "업로드 완료: uploads/" . $uuid . "." . $ext;
    } else {
        echo "no hack~~";
    }
}
highlight_file(__FILE__)
?>