· 9 years ago · Jan 23, 2017, 03:02 PM
1<?php
2 /*
3 CREATE TABLE IF NOT EXISTS `by133312` (
4 `id` int(11) NOT NULL AUTO_INCREMENT,
5 `owner_id` text COLLATE utf8_unicode_ci NOT NULL,
6 `post_id` text COLLATE utf8_unicode_ci NOT NULL,
7 `time` text COLLATE utf8_unicode_ci NOT NULL,
8 PRIMARY KEY (`id`)
9 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
10 */
11 set_time_limit(0);
12 ignore_user_abort(1);
13
14 // ПОДКЛЮЧЕÐИЕ К БÐЗЕ ДÐÐÐЫХ
15 $mysqli = new mysqli("localhost", "логин", "пароль", "логин") or die("Error");
16 $mysqli->query("SET NAMES 'utf8'");
17
18 // ACCESS_TOKEN ПОЛУЧÐЕМ ЕГО ТУТ: http://offpage.xyz/API/token.check.php
19 $access_token = "токен";
20
21 // Ð’ÐШИ ФОТОГРÐФИИ
22 $attachments = array("photo328560438_427462913", "photo328560438_427462928", "photo328560438_427462997"); // https://vk.com/id328560438
23
24 // КЛЮЧ ОТ РУКÐПЧИ
25 $key = "Рукапча";
26
27 /*
28 ===============================
29 ТУТ ÐЕЧЕГО ÐЕ ТРОГÐТЬ!!!
30 СКРИПТ ÐÐЧИÐÐЕТ Ð ÐБОТÐТЬ
31 ===============================
32 */
33
34 $group_ids = array("spottsila", "go2friends", "club39130136", "dobav_menya_esli_xochesh", "dvd_2", "frend_rusfans", "club39673900", "ss_pr", "iron_like");
35 if(!$key) die("ÐВТОРИЗУЙТЕСЬ Ð’ РУКÐПЧЕ!!!");
36 for($i = 0; $i < count($group_ids); $i++) {
37 if($group_ids[$i])
38 $getById = by("groups.getById", array("fields" => "can_post,is_closed", "group_ids" => $group_ids[$i], "access_token" => $access_token));
39 if($getById[0]["can_post"] == 1 and $getById[0]["is_closed"] == 0) {
40 $post = by("wall.post", array("owner_id" => -$getById[0]["gid"], "attachments" => $attachments[rand(0, count($attachments))], "access_token" => $access_token));
41 if($post["error_code"] == 14) {
42 download($post["captcha_img"]);
43 $captcha_key = recognize(dirname(__FILE__)."/captcha.png", $key, false, "rucaptcha.com");
44 $post = by("wall.post", array("captcha_sid" => $post["captcha_sid"], "captcha_key" => $captcha_key, "owner_id" => -$getById[0]["gid"], "attachments" => $attachments[rand(0, count($attachments))], "access_token" => $access_token));
45 }
46
47 if($post["post_id"]) {
48 $mysqli->query("
49 INSERT INTO
50 `by133312`(
51 `owner_id`,
52 `post_id`,
53 `time`
54 )
55 VALUES(
56 '".$getById[0]["gid"]."',
57 '".$post["post_id"]."',
58 '".date("H:i", strtotime("+3 min"))."'
59 );
60 ");
61 }
62 }
63 sleep(1);
64 }
65
66 $id = $mysqli->query("SELECT * FROM `by133312`")->fetch_assoc();
67 if($id["time"] == date("H:i")) {
68 $delete = by("wall.delete", array("owner_id" => -$id["owner_id"], "post_id" => $id["post_id"], "access_token" => $access_token));
69 if($delete == 1) {
70 $mysqli->query("DELETE FROM `by133312` WHERE `id` = '".$id["id"]."';");
71 }
72 }
73
74 function download($picture) {
75 $pic = curl_init($picture);
76 $file = fopen("captcha.png", "wb");
77 curl_setopt($pic, CURLOPT_FILE, $file);
78 curl_setopt($pic, CURLOPT_HEADER, 0);
79 curl_exec($pic);
80 curl_close($pic);
81 fclose($file);
82 }
83
84 function by($method, $post = false) {
85 $ch = curl_init("https://api.vk.com/method/".$method);
86 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
87 curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
88 curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
89 if($post) {
90 curl_setopt($ch, CURLOPT_POST, 1);
91 curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
92 }
93 $response = curl_exec($ch);
94 curl_close($ch);
95 $json = json_decode($response, true);
96 if($json["error"]["error_msg"]) {
97 return $json["error"];
98 } else {
99 return $json["response"];
100 }
101 }
102
103 function recognize(
104 $filename,
105 $apikey,
106 $is_verbose = true,
107 $domain="rucaptcha.com",
108 $rtimeout = 5,
109 $mtimeout = 120,
110 $is_phrase = 0,
111 $is_regsense = 0,
112 $is_numeric = 0,
113 $min_len = 0,
114 $max_len = 0,
115 $language = 0
116 )
117 {
118 if (!file_exists($filename))
119 {
120 if ($is_verbose) echo "file $filename not found\n";
121 return false;
122 }
123 $postdata = array(
124 'method' => 'post',
125 'key' => $apikey,
126 'file' => '@'.$filename,
127 'phrase' => $is_phrase,
128 'regsense' => $is_regsense,
129 'numeric' => $is_numeric,
130 'min_len' => $min_len,
131 'max_len' => $max_len,
132 'language' => $language
133
134 );
135 $ch = curl_init();
136 curl_setopt($ch, CURLOPT_URL, "http://$domain/in.php");
137 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
138 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
139 curl_setopt($ch, CURLOPT_POST, 1);
140 curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
141 $result = curl_exec($ch);
142 if (curl_errno($ch))
143 {
144 if ($is_verbose) echo "CURL returned error: ".curl_error($ch)."\n";
145 return false;
146 }
147 curl_close($ch);
148 if (strpos($result, "ERROR")!==false)
149 {
150 if ($is_verbose) echo "server returned error: $result\n";
151 return false;
152 }
153 else
154 {
155 $ex = explode("|", $result);
156 $captcha_id = $ex[1];
157 if ($is_verbose) echo "captcha sent, got captcha ID $captcha_id\n";
158 $waittime = 0;
159 if ($is_verbose) echo "waiting for $rtimeout seconds\n";
160 sleep($rtimeout);
161 while(true)
162 {
163 $result = file_get_contents("http://$domain/res.php?key=".$apikey.'&action=get&id='.$captcha_id);
164 if (strpos($result, 'ERROR')!==false)
165 {
166 if ($is_verbose) echo "server returned error: $result\n";
167 return false;
168 }
169 if ($result=="CAPCHA_NOT_READY")
170 {
171 if ($is_verbose) echo "captcha is not ready yet\n";
172 $waittime += $rtimeout;
173 if ($waittime>$mtimeout)
174 {
175 if ($is_verbose) echo "timelimit ($mtimeout) hit\n";
176 break;
177 }
178 if ($is_verbose) echo "waiting for $rtimeout seconds\n";
179 sleep($rtimeout);
180 }
181 else
182 {
183 $ex = explode('|', $result);
184 if (trim($ex[0])=='OK') return trim($ex[1]);
185 }
186 }
187
188 return false;
189 }
190 }
191?>