View difference between Paste ID: t5ppf7Jf and JcaLuRCj
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
/* 
4
5
 *    PHP vB 3.8.x remote utils
6
7
 *         Written by bool_
8
9
 * ps. used some guys script for the login func
10
11
 * currently can; login, post threads,
12
13
 * shout to infernoshout, and reply to threads.
14
15
 */
16
17
class vBulletin {
18
19
    protected $site, $ch;
20
21
	
22
23
	public function __construct($i_site, $cookies_file) {
24
25
	    $this->site = $i_site;
26
27
		$this->ch = curl_init();
28
29
        curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
30
31
        curl_setopt($this->ch, CURLOPT_TIMEOUT, '50'); 
32
33
        curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1); 
34
35
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); 
36
37
        curl_setopt($this->ch, CURLOPT_REFERER, $this->site);
38
39
        curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookies_file);
40
41
        curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookies_file);
42
43
	}
44
45
	
46
47
	public function vB_post_reply($thread, $topic, $message) {
48
49
	    curl_setopt($this->ch, CURLOPT_URL, $this->site . 'newreply.php?do=newreply&noquote=1&t=' . $thread);
50
51
        curl_setopt($this->ch, CURLOPT_POST, 0);
52
53
        $buffer = curl_exec($this->ch);
54
55
        $sectoken = '';
56
57
        $posthash = '';
58
59
        $posttime = '';
60
61
        $userid = '';
62
63
        preg_match('#<input type="hidden" name="securitytoken" value="(.+?)" />(.+?)#', $buffer, $sectoken);
64
65
        preg_match('#<input type="hidden" name="posthash" value="(.+?)" />(.+?)#', $buffer, $posthash);
66
67
        preg_match('#<input type="hidden" name="poststarttime" value="(.+?)" />(.+?)#', $buffer, $posttime);
68
69
        preg_match('#<input type="hidden" name="loggedinuser" value="(.+?)" />(.+?)#', $buffer, $userid);
70
71
	    if(!$sectoken[1] or !$posthash[1] or !$posttime[1] or !$userid[1]) {
72
73
	        $this->vB_post_reply($thread, $topic, $message); // try to get info again.
74
75
    	}
76
77
        $data = 'do=postreply&title=' . urlencode($topic) . '&message=' . urlencode($message) . '&wysiwyg=0&iconid=0&securitytoken='
78
79
        . $sectoken[1] . '&specifiedpost=0&sbutton=Submit+Reply&parseurl=1&emailupdate=9999&polloptions=4&f=' . $cat . '&posthash=' . $posthash[1] .
80
81
        '&poststarttime=' . $posttime[1] . '&loggedinuser=' . $userid[1] . '&t=' . $thread;
82
83
        curl_setopt($this->ch, CURLOPT_URL, $this->site . 'newreply.php?do=postreply&t=' . $cat);
84
85
        curl_setopt($this->ch, CURLOPT_POST, 1); 
86
87
        curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data); 
88
89
        $buffer = curl_exec($this->ch);
90
91
        if(stristr($buffer, 'you do not have permission to access this page')) {
92
93
	        return false;
94
95
        } elseif(stristr($buffer, 'Please try again in ')) {
96
97
    	    return false;
98
99
        } else {
100
101
    	    return true;
102
103
        }
104
105
	}
106
107
	
108
109
	public function vB_post_thread($cat, $topic, $message) {
110
111
	    curl_setopt($this->ch, CURLOPT_URL, $this->site . 'newthread.php?do=newthread&f=' . $cat);
112
113
        curl_setopt($this->ch, CURLOPT_POST, 0);
114
115
        $buffer = curl_exec($this->ch);
116
117
        $sectoken = '';
118
119
        $posthash = '';
120
121
        $posttime = '';
122
123
        $userid = '';
124
125
        preg_match('#<input type="hidden" name="securitytoken" value="(.+?)" />(.+?)#', $buffer, $sectoken);
126
127
        preg_match('#<input type="hidden" name="posthash" value="(.+?)" />(.+?)#', $buffer, $posthash);
128
129
        preg_match('#<input type="hidden" name="poststarttime" value="(.+?)" />(.+?)#', $buffer, $posttime);
130
131
        preg_match('#<input type="hidden" name="loggedinuser" value="(.+?)" />(.+?)#', $buffer, $userid);
132
133
	    if(!$sectoken[1] or !$posthash[1] or !$posttime[1] or !$userid[1]) {
134
135
	        $this->vB_post_thread($cat, $topic, $message); // try to get info again.
136
137
    	}
138
139
        $data = 'do=postthread&subject=' . urlencode($topic) . '&message=' . urlencode($message) . '&wysiwyg=0&iconid=0&securitytoken='
140
141
        . $sectoken[1] . '&sbutton=Submit+New+Thread&parseurl=1&emailupdate=9999&polloptions=4&f=' . $cat . '&posthash=' . $posthash[1] .
142
143
        '&poststarttime=' . $posttime[1] . '&loggedinuser=' . $userid[1];
144
145
        curl_setopt($this->ch, CURLOPT_URL, $this->site . 'newthread.php?do=postthread&f=' . $cat);
146
147
        curl_setopt($this->ch, CURLOPT_POST, 1); 
148
149
        curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data); 
150
151
        $buffer = curl_exec($this->ch);
152
153
        if(stristr($buffer, 'you do not have permission to access this page')) {
154
155
	        return false;
156
157
        } elseif(stristr($buffer, 'Please try again in ')) {
158
159
    	    return false;
160
161
        } else {
162
163
    	    return true;
164
165
        }
166
167
	}
168
169
	
170
171
    function vB_login($user, $pass) {
172
173
        $md5Pass = md5($pass); 
174
175
        $data = "do=login&vb_login_username=$user&securitytoken=guest&vb_login_md5password_utf=$md5Pass&vb_login_md5password=$md5Pass"; 
176
177
        curl_setopt($this->ch, CURLOPT_URL, $this->site . 'login.php?do=login');
178
179
        curl_setopt($this->ch, CURLOPT_POST, 1); 
180
181
        curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data); 
182
183
        $buffer = curl_exec($this->ch); 
184
185
        $pos = strpos($buffer, "Thank you for logging in,"); 
186
187
        if($pos === false) { 
188
189
            return 0; 
190
191
        } else { 
192
193
            return 1; 
194
195
        } 
196
197
    } 
198
199
200
201
    function vB_inferno_shout($message) {
202
203
        $data = "do=shout&message=$message"; 
204
205
        curl_setopt($this->ch, CURLOPT_URL, $this->site . 'infernoshout.php?do=shout');
206
207
        curl_setopt($this->ch, CURLOPT_POST, 1); 
208
209
        curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data); 
210
211
        $buffer = curl_exec($this->ch); 
212
213
        $pos = strpos($buffer, "completed"); 
214
215
        if($pos === false) { 
216
217
            return 0; 
218
219
        } else { 
220
221
            return 1; 
222
223
        } 
224
225
    } 	
226
227
}
228
229
230
231
$test = new vBulletin('avbulletinsitewithtrailingslash', 'cookies.txt');
232
233
if($test->vB_login('Anthony', 'fuktitsshit')) {
234
235
    echo 'logged in!';
236
237
} else {
238
239
    echo ' couldnt log in????';
240
241
}
242
243
if($test->vB_inferno_shout('so whats going on here m8?')) {
244
245
    echo ' shouted!';
246
247
}
248
249
250
251
if($test->vB_post_thread(26, 'the cool cat game', 'ur playing it and you dun even know.')) {
252
253
    echo ' thread posted!';
254
255
}
256
257
258
259
if($test->vB_post_reply(133, 'usuk', 'satellite is whats up dark themes fail.')) {
260
261
    echo ' reply posted!';
262
263
}
264
265
?>