写的一个自动生成计划的脚本

<?

date_default_timezone_set("Etc/GMT+8");
$mysql_server_name='localhost';
$mysql_username='root';
$mysql_password='root';
$mysql_database='cpjh';
@$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password) or die("error connecting") ;
mysql_query("set names 'utf8'");
mysql_select_db($mysql_database);
session_start();
function getRandomStr1($len){
    $tmp=array();

    while(count($tmp)<$len){
        $tmp[]=mt_rand(0,9);
        $tmp=array_unique($tmp);
    }
    $str = implode(",", $tmp);
    return $str;

}

$url1 = 'http://sxcpjihua.com/lottery/data.do?name=WFC';

function curlGet($url){
    $cookie_file = dirname(__FILE__)."/cookie.txt";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}

$wfc = curlGet($url1);
$wfc_arr = json_decode($wfc);
$wfc_haoMa = $wfc_arr[0]->haoMa;
$wfc_qiHao = $wfc_arr[0]->qiHao;

$room=substr($wfc_qiHao,-7);
$yer = substr($wfc_qiHao,0,4);
switch($room) {
    case "0131228":
        $qh = $yer.'0201001';
        break;
    case "0228228":
        $qh = $yer.'0301001';
        break;
    case "0331228":
        $qh = $yer.'0401001';
        break;
    case "0430228":
        $qh = $yer.'0501001';
        break;
    case "0531228":
        $qh = $yer.'0601001';
        break;
    case "0630228":
        $qh = $yer.'0701001';
        break;
    case "0731228":
        $qh = $yer.'0801001';
        break;
    case "0831228":
        $qh = $yer.'0901001';
        break;
    case "0930228":
        $qh = $yer.'1001001';
        break;
    case "1031228":
        $qh = $yer.'1101001';
        break;
    case "1130228":
        $qh = $yer.'1201001';
        break;
    case "1231228":
        $yer = $yer+1;
        $qh = $yer.'0101001';
        break;
    default:
        $str=substr($wfc_qiHao,-3);
        if($str=='288'){
            $str1 = substr($wfc_qiHao,0,8)+1;
            $qh = $str1.'001';
        }else{
            $qh = $wfc_qiHao+1;
        }
        break;
}

$sql = "select * FROM wfc where flag=0";
@$rs=mysql_query($sql);

if($_SESSION['qiHao']==$wfc_qiHao){
    while($vr = mysql_fetch_array($rs)){

        if($vr["ma"]=="7码"){
            $str = getRandomStr1(7);
        }elseif ($vr["ma"]=="6码"){
            $str = getRandomStr1(6);
        }elseif ($vr["ma"]=="5码"){
            $str = getRandomStr1(5);
        }elseif ($vr["ma"]=="4码"){
            $str = getRandomStr1(4);
        }elseif ($vr["ma"]=="3码"){
            $str = getRandomStr1(3);
        }else{
            $str = getRandomStr1(1);
        }
        $id = $vr["id"];

        $sql1 = "insert into sxwfc_plan (plan,wid,qi) values ('$str',$id,$qh)";

        mysql_query($sql1);
    }
    $_SESSION['qiHao'] = $qh;
    $sql2 = "update sxwfc_plan set qs='$wfc_haoMa' where qi='$wfc_qiHao'";
    mysql_query($sql2);
    $fp = fopen("test.txt", "a+");
    fwrite($fp, date("Y-m-d H:i:s") . "执行成功!\r\n");
    fclose($fp);
}


?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

</body>
</html>
<script>setTimeout("location=location; ", 1000*100); </script>

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值