-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhile.php
executable file
·54 lines (45 loc) · 1.33 KB
/
while.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
$dbh = mysql_connect("127.0.0.1:3306","root","root");
if(!$dbh){die("error");}
mysql_select_db("cj", $dbh);
$q = "select * from user";
///$sql = sprintf("select count(*) from %s", DB_TABLENAME);
ignore_user_abort();
set_time_limit(0);
$interval=2;
function judgeEqual($key1,$key2){
if(array_diff($key1,$key2) || array_diff($key2,$key1)){
return true;
}else{
return false;
}
}
do{
$rs = mysql_query($q, $dbh);
//var_dump($rs);
while( $row = mysql_fetch_array($rs) ){
$json_mysql = $row['cj_data'];
$arr_mysql = json_decode($json_mysql,true)["score"];
//var_dump($arr_mysql);
$userid=$row['user_id'];
$password=$row['pass'];
$json_server = file_get_contents('http://cj.ldustu.com/api/score?userid=20123116743&password=021995&from=message&appid=10002&secret=message@ldsn');
$arr_server = json_decode($json_server,true)["score"];
//var_dump($status);
//var_dump($arr_server);
for($i=0;$i<sizeof($arr_server);$i++){
$status = judgeEqual($arr_mysql[$i],$arr_server[$i]);
if($status == true){
$message = "学科:".$arr_mysql[$i]['kcm']."由:".$arr_mysql[$i]['cj']." 更新到:" . $arr_server[$i]['cj'].'<br />';
$fp = fopen('text3.txt','a');
fwrite($fp,$message);
fclose($fp);
}
}
//foreach ($arr_server as $value) {
//print_r($value);
// }
}
sleep($interval);
}while(true);
?>