-
Notifications
You must be signed in to change notification settings - Fork 10
/
cron.php
82 lines (78 loc) · 2.24 KB
/
cron.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
require_once('./Application/core.php');
error_reporting(0);
set_time_limit(0);
$DB = new DB();
$DB->init();
updatesum($DB);
runlike($DB);
updatecur($DB);
function testsid($qq,$sid){
$url = "http://ish.z.qq.com/infocenter_v2.jsp?B_UID=".$qq."&sid=".$sid."&g_ut=1";
$page = url_fetch($url);
if( strpos($page ,"赞")){
return true;
}else{
return false;
}
}
function updatecur($DB){
$status = getStatus($DB);
$current = $status['cur'] + 1;
if($current > $status['sum']){
$DB->Cron("cur",0);
}else{
$DB->Cron("cur",$current);
}
echo "ok";
}
function getStatus($DB){
$cronstatus = $DB->Query("tl_cron","id","1");
return $cronstatus;
}
function updatesum($DB){
$qShowStatus = "SHOW TABLE STATUS LIKE 'tl_user'";
$result = mysql_fetch_assoc(mysql_query($qShowStatus));
$sum = $result['Auto_increment'];
$DB->Cron("sum",$sum);
}
function runlike($DB){
$cookie = "";
$status = getStatus($DB);
$uid = $status['cur'];
$user = $DB->Query("tl_sid","uid",$uid);
$qq= $user['qq'];
$sid = $user['sid'];
$re = '/href="(http:\\/\\/blog[0-9]*?.z.qq.com\\/like.*?)">赞/';
$url = "http://ish.z.qq.com/infocenter_v2.jsp?B_UID=".$qq."&sid=".$sid."&g_ut=1";
$page = url_fetch($url);
preg_match_all($re, $page, $matches);
$ia = count($matches[1]);
for($i = 0 ; $i < $ia ; $i++){
sleep(5);
$cookie2 = like_click($matches[1][$i],$url,$cookie);
if(!empty($cookie2)){ $cookie = $cookie2 ;}
}
echo "ok";
}
function like_click($url,$referer=NULL,$cookie){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,html_entity_decode($url));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 820)");
curl_setopt($ch, CURLOPT_HEADER, TRUE); //表示需要response header
curl_setopt($ch, CURLOPT_NOBODY, FALSE); //表示需要response body
$header = array ();
$header [] = 'Accept-Language: zh-cn';
$header [] = 'Pragma: no-cache';
$header [] = 'Referer: '.$referer;
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE,$cookie);
$page = curl_exec($ch);
curl_close($ch);
$re = "/Set-Cookie: (.*?);/";
preg_match($re, $page, $matches);
echo $page;
return $matches[1];
}
?>