-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendsms.php
131 lines (99 loc) · 3.45 KB
/
sendsms.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
121
122
123
124
125
126
127
128
129
130
131
<?php
/*
Author: Ewere Diagboya
Company: Wicee Solutions
Description: This API is built on three major SMS APIs in Nigera:
SMSLIVE - smslive247.com
KullSMS - kullsms.com
Xwireless - xwireless.net
You are free to edit the code and use your own SMS API as you choose
For Complaints or Comments
Phone: 08066194746
Email: [email protected]
*/
// Connect to the Database - create your own database connection
mysql_connect("localhost","root","");
mysql_select_db("smsdb");
/*
Send Code
Get Parameters from URL Sent and Insert into the DB
No validation is really required
Just few to parse the correct information to the DB
Email, Password
*/
// Constant Definitions
define("ADEMAIL",$ad_email,true);
define("SUBAC",$sbact,true);
define("SUBPWD",$sbpwd,true);
define("SMSURL",$surl,true);
// Function to Send SMS
function sendsms ($email, $pwd, $nos, $from, $msg)
{
// Login user before trying to send SMS and balance
$sql = "SELECT * FROM members WHERE (email='$email' OR phone='$email') AND password=md5('$pwd')";
$runq = mysql_query($sql);
$rec = mysql_fetch_array($runq);
$tl = mysql_num_rows($runq);
$balance = $rec[bal];
if(!$runq)
{
echo "Server Error";
}
else
{
if ($tl == 1) {
// LOGIN SUCCESS
////////////////////////////////////////////
$splitnos = substr($nos,0,-1);
$splnos = explode(",", $splitnos);
$totalnos = count($splnos);
foreach ($splnos as $recs) // Sending Loop
{
if ($balance > 0) // If balance is greater than 0 then user can send
{
// Send to Database
$sqlq = "INSERT INTO msgs (`id` , `email` , `sender` , `to` , `msg` , `dnt`) VALUES (NULL , '$email', '$from', '$recs',
'$msg', NOW( ))";
$runq = mysql_query($sqlq) or die("Server Error");
// Update balance by deducting from original
$sqlupd = "update members set bal=bal-1 where email='$email'";
$runupd = mysql_query($sqlupd) or die("Server Error");
$i++; // Increment Counter
// Kull API
$kemail = "your-kull-sms-email";
$kpwd = "your-kullsms-password";
$recss = "234" . substr($recs, 1);
// Send SMS through KULLSMS API
// $s_sms = file('http:https://sms.kullsms.com/customer/bulksms/[email protected]&password=kullsmspwd&message='. urlencode($msg) . '&sender=' . $from .
'&mobiles=' . $recss );
// Send SMS through SMSLive
$ssms = file('http:https://www.smslive247.com/http/index.aspx?cmd=sendquickmsg&owneremail=' . ADEMAIL . '&subacct=' . SUBAC . '&subacctpwd='
. SUBPWD . '&message=' . rawurlencode($msg) . '&sender=' . rawurldecode($from) . '&sendto=' . rawurlencode($recs) . '&msgtype=0');
// Send SMS through Xwireless
$xusername = "your-username";
$xpassword = "your-password";
// $se_sms = file('http:https://smsc.xwireless.net/API/WebSMS/Http/v1.0a/index.php?username='. $xusername .'&password='. $xpassword .'&sender=' . rawurldecode($from) .
'&to=' . rawurlencode($recs) .'&message=' . rawurlencode($msg) . '&international=1&reqid=1&format={json|text}&route_id=<route+id>&sendondate=04-09-2012T03:16:11');
// Give return
//echo "<p>$i</p>";
if ($i == $totalnos)
{
// Update balance
$sqlupd = "update members set bal=bal+1 where email='$email'";
$runupd = mysql_query($sqlupd) or die("Server Error");
echo "OK: " . $s_sms[0];
}
}
else // If balance is equal to or greater than 0
{
echo "ER";
break;
}
} // Sending Loop
}
else {
echo "0"; // Login Failure
}
}
}
?>