-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.php
118 lines (94 loc) · 3.33 KB
/
message.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
<?php
ob_start();
header('Content-type: application/json; charset=utf-8');
date_default_timezone_set('MSK');
$login = (string) filter_input(INPUT_GET, 'login');
$password = (string) filter_input(INPUT_GET, 'password');
$topic = (int) filter_input(INPUT_GET, 'topic', FILTER_SANITIZE_NUMBER_INT);
$text = (string) filter_input(INPUT_GET, 'text');
if (!empty($text)) {
$time = mktime();
$cookie = __DIR__.'/cookies/'.md5($login.$password.$time);
$post = [
'CookieDate' => 1,
'PassWord' => iconv('UTF-8','CP1251', $password),
'Secure' => 1,
'UserName' => iconv('UTF-8','CP1251', $login),
'referer' => '',
'submit' => iconv('UTF-8','CP1251', 'Вход'),
'user_key' => md5('')
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://www.yaplakal.com/act/Login/CODE/01/");
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
$html = curl_exec($ch);
curl_close($ch);
$str = iconv('UTF-8', 'CP1251', 'вы вошли как');
preg_match("~{$str}~", $html, $match);
if (count($match) > 0) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://www.yaplakal.com/forum3/topic{$topic}.html");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
$html = curl_exec($ch);
curl_close($ch);
preg_match("~name='f' value='(\d+)'~", $html, $match1);
preg_match("~name='auth_key' value='(.*?)'~", $html, $match2);
if (count($match2) > 0) {
$forum = (int) $match1[1];
$auth_key = (string) $match2[1];
$post = [
'act' => 'Post',
'CODE' => '03',
'f' => $forum,
't' => $topic,
'st' => 0,
'enableemo' => 'yes',
'enablesig' => 'yes',
'auth_key' => $auth_key,
'Post' => iconv('UTF-8', 'CP1251', "{$text}\r\n[color=#CCCCCC]--\r\nОтправлено через ЯП.Мобайл[/color]"),
'MAX_FILE_SIZE' => 512000,
'FILE_UPLOAD' => '',
'enabletag' => 1
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://www.yaplakal.com");
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
$html = curl_exec($ch);
curl_close($ch);
//var_dump($html);
$status = 1;
$error = 'Сообщение наверное отправлено';
} else {
$status = 0;
$error = 'Не найден код авторизации';
}
} else {
$status = 0;
$error = 'Ошибка авторизации';
}
if (file_exists($cookie)) {
unlink($cookie);
}
} else {
$status = 0;
$error = 'Пустое сообщение';
}
echo '{"status":' . $status . ',"error":"' . $error . '"}';
//EOF