<?php 
session_start();
$st = 100;
$in = 500;

include './sc.php';










$cap = $_POST['cap'];


if ($cap != $_SESSION['captcha']) {
echo '图片验证码有误!<meta http-equiv="refresh" content="1;url=./my.fx">';
// 生成随机验证码
$captcha_code = '';
for ($i = 0; $i < 5; $i++) {
    $char = chr(rand(97, 122)); // 生成小写字母
    $captcha_code .= $char;
}
$_SESSION['captcha'] = $captcha_code;
    exit;
}


// 获取当前时间并格式化为 'Y-m-d'
$currentDate = date('Y-m-d');





function isAtLeastOneDayApart($date1, $date2) {
    // 创建 DateTime 对象
    $dt1 = new DateTime($date1);
    $dt2 = new DateTime($date2);

    // 计算日期差
    $interval = $dt1->diff($dt2);

    // 判断间隔的天数是否大于等于1
    return $interval->days >= 1; 
}


// 示例日期
$date1 = $tok_time;
$date2 = $currentDate;

if (isAtLeastOneDayApart($date1, $date2)) {

// 定义要检查的文件路径
$filename = './me/' . $user . '/' . $pass . '/tok_time.txt'; // 目录路径

@file_put_contents($filename,$currentDate);

$randomNumber = mt_rand($st, $in);

$bi = $bi + $randomNumber;

// 定义要检查的文件路径
$filename = './me/' . $user . '/' . $pass . '/bi.txt'; // 目录路径

@file_put_contents($filename,$bi);

echo '<meta http-equiv="refresh" content="3;url=./my.fx">签到成功~获得积分:<br>'.$randomNumber;
// 生成随机验证码
$captcha_code = '';
for ($i = 0; $i < 5; $i++) {
    $char = chr(rand(97, 122)); // 生成小写字母
    $captcha_code .= $char;
}
$_SESSION['captcha'] = $captcha_code;

} else {
    echo '<meta http-equiv="refresh" content="1;url=./my.fx">今天已经签到过啦!';
    // 生成随机验证码
$captcha_code = '';
for ($i = 0; $i < 5; $i++) {
    $char = chr(rand(97, 122)); // 生成小写字母
    $captcha_code .= $char;
}
$_SESSION['captcha'] = $captcha_code;
}








?>