This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmybb.class.php
68 lines (55 loc) · 2.39 KB
/
mybb.class.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
<?php
/*
MyBB Class
Copyright (C) 2013 Ramadhan Amizudin <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class MyBB {
var $xpm_key, $xpm_user;
var $username, $password, $post_key, $host;
var $login_post = 'username=%s&password=%s&remember=yes&submit=Login&action=do_login&url=';
var $send_pm = 'my_post_key=#post_key#&to=#to#&bcc=&subject=#subject#&icon=-1&message_new=#body#&message=#body#&options[signature]=1&options[savecopy]=1&options[readreceipt]=1&action=do_send&pmid=&do=&submit=Send+Message';
function __construct($host) {
$this->host = $host;
}
function Login($username = '', $password = '') {
$data = HTTPRequest($this->host . '/member.php', true, sprintf($this->login_post, $username, $password));
if(preg_match("/You have entered an invalid/i", $data)) {
return false;
} else {
// $data = HTTPRequest($this->host); // tbd lepas login dia redirect ke 404 page -_-
$this->GetPostKey($data);
if ( stripos($this->host, 'tbd.my') !== false ) {
$this->getXPMKey($data);
}
}
}
function SendPM($to, $subject, $message) {
$crafted = str_replace("#post_key#", $this->post_key, $this->send_pm);
$crafted = str_replace("#to#", $to, $crafted);
$crafted = str_replace("#subject#", $subject, $crafted);
$crafted = str_replace("#body#", $message, $crafted);
HTTPRequest($this->host . '/private.php', true, $crafted);
}
function GetPostKey($response) {
preg_match_all("/var\ my_post_key\ =\ \"(.+?)\"\;/", $response, $post_key);
$this->post_key = $post_key[1][0];
}
function getXPMKey($response) {
// print $response;
preg_match_all("/var\ xpm_key\ =\ \"(.+?)\"\;/", $response, $key);
preg_match_all("/var\ xpm_user\ =\ \"(.+?)\"\;/", $response, $user);
$this->xpm_key = $key[1][0];
$this->xpm_user = $user[1][0];
}
}
?>