-
Notifications
You must be signed in to change notification settings - Fork 15
/
wmzz_post_cron.php
executable file
·126 lines (123 loc) · 4.56 KB
/
wmzz_post_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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
if (!defined('SYSTEM_ROOT')) { die('Insufficient Permissions'); }
function wmzz_post_send($uid, $tid, $pid, $water = 'StusGame Tieba Cloud Sign Plugin "wmzz_post"', $device = 4) {
if (empty($uid) || empty($tid) || empty($pid)) {
return array(
'status' => '1',
'msg' => ''
);
}
$ck = misc::GetCookie($pid);
$xs = wmzz_post_gettie($tid,$ck);
$x = array(
'BDUSS' => $ck,
'_client_id' => 'wappc_136' . rand_int(10) . '_' . rand_int(3),
'_client_type' => $device,
'_client_version' => '5.0.0',
'_phone_imei' => md5(rand_int(16)),
'anonymous' => '0',
'content' => $water,
'fid' => $xs['fid'],
'kw' => $xs['word'],
'net_type' => '3',
'tbs' => $xs['tbs'],
'tid' => $tid,
'title' => ''
);
$y = '';
foreach ( $x as $key => $value ) {
$y .= $key . '=' . $value;
}
$x['sign'] = strtoupper(md5($y.'tiebaclient!!!'));
$c = new wcurl('http://c.tieba.baidu.com/c/c/post/add',array('Content-Type: application/x-www-form-urlencoded'));
/* //Note:普通的
$x = wmzz_post_gettie($tid,$ck);
$c = new wcurl('http://tieba.baidu.com'.$x['__formurl']);
unset($x['__formurl']);
$x['co'] = $water;
*/
$c->addcookie('BDUSS='.$ck);
$return = json_decode($c->post($x),true);
$c->close();
if (!empty($return['error_code']) && $return['error_code'] != '1') {
return array(
'status' => $return['error_code'],
'msg' => $return['error_msg']
);
} else {
return array(
'status' => '1',
'msg' => ''
);
}
}
function wmzz_post_gettie($tid, $ck) {
$c = new wcurl('http://tieba.baidu.com/mo/m?kz='.$tid ,array('User-Agent: Chinese Fucking Phone'));
$c->addcookie('BDUSS='.$ck);
$t = $c->exec();
preg_match('/<form action=\"(.*?)\" method=\"post\">/', $t , $formurl);
preg_match('/<input type=\"hidden\" name=\"ti\" value=\"(.*?)\"\/>/', $t, $ti);
preg_match('/<input type=\"hidden\" name=\"src\" value=\"(.*?)\"\/>/', $t, $src);
preg_match('/<input type=\"hidden\" name=\"word\" value=\"(.*?)\"\/>/', $t, $word);
preg_match('/<input type=\"hidden\" name=\"tbs\" value=\"(.*?)\"\/>/', $t, $tbs);
preg_match('/<input type=\"hidden\" name=\"fid\" value=\"(.*?)\"\/>/', $t, $fid);
preg_match('/<input type=\"hidden\" name=\"z\" value=\"(.*?)\"\/>/', $t, $z);
preg_match('/<input type=\"hidden\" name=\"floor\" value=\"(.*?)\"\/>/', $t, $floor);
return array(
'__formurl' => $formurl[1],
'co' => '',
'ti' => $ti[1],
'src' => $src[1],
'word' => $word[1],
'tbs' => $tbs[1],
'ifpost' => '1',
'ifposta' => '0',
'post_info' => '0',
'tn' => 'baiduWiseSubmit',
'fid' => $fid[1],
'verify' => '',
'verify_2' => '',
'pinf' => '1_2_0',
'pic_info' => '',
'z' => $z[1],
'last' => '0',
'pn' => '0',
'r' => '0',
'see_lz' => '0',
'no_post_pic' => '0',
'floor' => $floor[1],
'sub1' => '回贴'
);
}
function cron_wmzz_post() {
global $m;
$set = unserialize(option::get('plugin_wmzz_post'));
$today = date("Y-m-d");
//准备:扫描wmzz_post表中lastdo不是今天的,然后更新wmzz_post_data表的remain
$sy = $m->query("SELECT * FROM `".DB_PREFIX."wmzz_post` WHERE `lastdo` != '{$today}';");
while ($sx = $m->fetch_array($sy)) {
$m->query('UPDATE `'.DB_NAME.'`.`'.DB_PREFIX.'wmzz_post_data` SET `remain` = \''.$sx['num'].'\' WHERE `uid` = '.$sx['uid']);
$m->query('UPDATE `'.DB_NAME.'`.`'.DB_PREFIX.'wmzz_post` SET `lastdo` = \''.$today.'\' WHERE `uid` = '.$sx['uid']);
}
//开始:计划任务
$count = $m->once_fetch_array("SELECT COUNT(*) AS `c` FROM `".DB_PREFIX."wmzz_post_data` WHERE `remain` > '0' LIMIT {$set['rem']};");
if ($count['c'] == $set['rem']) {
$y = rand_row(DB_PREFIX.'wmzz_post_data','id', $set['rem'] ,"`remain` > '0'");
} else {
$y = rand_row(DB_PREFIX.'wmzz_post_data','id', $count['c'] ,"`remain` > '0'");
}
//如果只有一条记录的兼容方案
if (isset($y['url'])) {
$y = array(0 => $y);
}
foreach ($y as $x) {
if (!empty($x['pid']) && !empty($x['uid'])) {
$u = $m->once_fetch_array("SELECT * FROM `".DB_PREFIX."wmzz_post` WHERE `uid` = '{$x['uid']}'");
$cont = unserialize($u['cont']);
$remain = $x['remain'] - 1 ;
$res = wmzz_post_send($x['uid'] , $x['url'] , $x['pid'] , rand_array($cont) , $set['device']);
$m->query('UPDATE `'.DB_NAME.'`.`'.DB_PREFIX.'wmzz_post_data` SET `remain` = \'' . $remain . '\',`status` = \''.$res['status'].'\',`msg` = \''.$res['msg'].'\' WHERE `url` = \''.$x['url'].'\' AND `uid` = '.$x['uid']);
sleep($set['sleep']);
}
}
}