-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.sms.php
120 lines (97 loc) · 2.97 KB
/
class.sms.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
<?php
include_once "cprint.php";
class sms
{
var $username,$password;
var $curl,$server,$data;
public function __construct()
{
$this->curl=new cURL();
//$this->curl->setProxy("");
$this->data=array();
}
public function setGateway($serverName)
{
switch($serverName)
{
case 'way2sms':
$this->server='way2sms';
break;
default :
print "Currently only Way2sms is supported";
break;
}
}
public function login($username,$password)
{
$server=$this->server;
return(call_user_func(array($this,"login_$server"),$username,$password));
}
public function send($number,$msg)
{
$server=$this->server;
return(call_user_func(array($this,"send_$server"),$number,$msg));
}
private function login_way2sms($username,$password)
{
$html=($this->curl->post("http://www.way2sms.com","1=1"));
if (!preg_match("/Location:(.*)\n/",$html,$matches)) {
print("Error getting domain");
cprint($html);
return(0);
}
$domain=trim($matches[1]);
$this->data['domain']=$domain;
cprint("Domain:$domain");
$html= $this->curl->post(
"${domain}Login1.action",
"username=$username&password=$password&Submit=Sign+in"
);
if (!preg_match('/<h3>Welcome to Way2SMS<.h3>/',$html)) {
print("Error Logging In");
print($html);
return(0);
}
print("Logged In Successfully");
if (!preg_match("/Location:(.*)[?]id=(.*)\n/",$html,$matches)) {
print("Error getting location & token");
cprint($html);
return(0);
}
$referer=trim($matches[1]);
$token=trim($matches[2]);
$this->data['referer']=$referer;
$this->data['token']=$token;
cprint("Referer:$referer");
cprint("Token:$token");
return(1);
}
private function send_way2sms($number,$msg)
{
$domain=$this->data['domain'];
print("Msg:$msg");
$token=$this->data['token'];
$html=$this->curl->post(
"{$domain}main.action?section=s",
"vfType=register_verify&Token=${token}",
$this->data['referer']
);
$msg=urlencode($msg);
$html=$this->curl->post(
"{$domain}smstoss.action",
"ssaction=ss&Token=${token}&mobile=$number&message=$msg"
);
if (!preg_match('/Message has been submitted successfully/',$html)) {
print("Error in sending sms");
print($html);
return(0);
}
else {
echo "<script type=\"text/javascript\">alert('SMS Successfully sended');</script>";
print("sms sended sucessfully");
print("Logged In Successfully");
return(1);
}
}
}
?>