HEX
Server: Apache/2.4.37 (CentOS Stream) OpenSSL/1.1.1k
System: Linux ysnet.com.tw 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User: test (521)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //proc/thread-self/cwd/captcha.php
<?php
// 開啟 session
session_start();

// 設定驗證碼內容(生成 5 位數字)
$captcha_code = '';
for ($i = 0; $i < 5; $i++) {
    $captcha_code .= rand(0, 9);
}

// 將驗證碼存入 session
$_SESSION['captcha'] = $captcha_code;

// 創建圖片
$image = imagecreate(120, 40); // 寬 120px,高 40px

// 設置顏色
$background_color = imagecolorallocate($image, 255, 255, 255); // 白色背景
$text_color = imagecolorallocate($image, 0, 0, 0);             // 黑色文字
$line_color = imagecolorallocate($image, 64, 64, 64);          // 灰色線條

// 添加隨機干擾線
for ($i = 0; $i < 5; $i++) {
    imageline($image, rand(0, 120), rand(0, 40), rand(0, 120), rand(0, 40), $line_color);
}

// 添加驗證碼文字
imagestring($image, 5, 30, 10, $captcha_code, $text_color);

// 設置輸出格式為 PNG
header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
?>