forked from hsrai/GNDEC-SMS-Service
-
Notifications
You must be signed in to change notification settings - Fork 2
/
insert.php
executable file
·205 lines (172 loc) · 6.06 KB
/
insert.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
/*************************************************************
* THE ADDRESS BOOK : version 1.04d
*
*************************************************************
*
* list.php
* Lists address book entries. This is the main page.
*
*************************************************************/
// ** GET CONFIGURATION DATA **
require_once('constants.inc');
require_once(FILE_FUNCTIONS);
require_once(FILE_CLASS_OPTIONS);
require_once(FILE_CLASS_CONTACTLIST);
require_once(FILE_CLASSES);
session_start();
$by = $_SESSION['username'];
// ** OPEN CONNECTION TO THE DATABASE **
$db_link = openDatabase($db_hostname, $db_username, $db_password, $db_name);
// ** CHECK FOR LOGIN **
checkForLogin();
// ** RETRIEVE OPTIONS THAT PERTAIN TO THIS PAGE **
$options = new Options();
// ** END INITIALIZATION *******************************************************
// CREATE THE LIST.
$list = &new ContactList();
// THIS PAGE TAKES SEVERAL GET VARIABLES
// ie. list.php?group_id=6&page=2&letter=c&limit=20
if ($_GET['groupid']) $list->group_id = $_GET['groupid'];
if ($_GET['page']) $list->current_page = $_GET['page'];
if (isset($_GET['letter'])) $list->current_letter = $_GET['letter'];
if (isset($_GET['limit'])) $list->max_entries = $_GET['limit'];
// Set group name (group_id defaults to 0 if not provided)
$list->group_name();
// ** RETRIEVE CONTACT LIST BY GROUP **
$r_contact = $list->retrieve($_SESSION['username']);
$sms_time = date("F j, Y, g:i a");
//echo $sms_time;
?>
<HTML>
<HEAD>
<TITLE><?php echo "$lang[TITLE_TAB] - $lang[TITLE_LIST]"?></TITLE>
<LINK REL="stylesheet" HREF="styles.css" TYPE="text/css">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="-1">
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['CHARSET']?>">
</HEAD>
<BODY onLoad="document.goToEntry.goTo.focus();">
<A NAME="top"></A>
<P>
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=570>
<TR><TD><IMG SRC="images/title.png" WIDTH=570 HEIGHT=90 ALT="" BORDER=0></TD></TR>
<TR>
<TD>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=570>
<TR VALIGN="top">
<TD WIDTH=285 CLASS="data">
<?php
// PRINT WELCOME MESSAGE
if ($options->msgWelcome != "") {
echo("<B>$options->msgWelcome</B>\n");
}
// PRINT SITE LANGUAGE [disabled for release]
// if($options->global_options[language] != $options->user_options[language]) echo "<br>".$lang[WELCOME_SITE_LANG].": ".$options->global_options[language];
// if($options->global_options[language] != $options->user_options[language] AND isset($options->user_options[language])) echo "<br>".$lang[WELCOME_UR_LANG].": ".$options->user_options[language];
// PRINT LOGGED IN USER
if (($_SESSION['username'] == "@auth_off") || ($_SESSION['usertype'] == "guest")) {
?>
<BR><?php echo $lang[MSG_LOGIN_NOT]. '<a href=" '.FILE_INDEX.'?mode=login"> '.$lang[WELCOME_LOGIN].'</a>' ?>
<?php
} else {
?>
<BR><?php echo $lang[WELCOME_CURRENT_LOGIN].' <b>'.$_SESSION['username'].'</b>'?>
<?php
if ($_SESSION['usertype'] == "admin") {
echo('<BR>'.$lang[WELCOME_ADMIN_ACCESS]);
}
if ($_SESSION['usertype'] == "user") {
echo('<BR>'.$lang[WELCOME_USER_ACCESS]);
}
echo '<br><a href=" '.FILE_INDEX.'?mode=logout"> '.$lang[WELCOME_LOGOUT].'</a>';
}
?>
<?php
// $sql2 = "SELECT firstname FROM contact";
// $result = mysql_query($sql2);
//while ($num = mysql_fetch_array($result))
// {
// echo $num['firstname'];
// echo "<br />";
// }
?>
<BR><BR><BR>
</TD>
<html>
<head>
<title>Thanks</title>
<link type="text/css" rel="stylesheet" href="../style.css" />
</head>
<body bgcolor="#CBD5E9">
<p><h2>Thanks for using SMS Service.</h2></p>
<?php
$con = mysql_connect($db_hostname,$db_username,$db_password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("adbook", $con);
if(isset($_POST['schedule'])) {
echo "<h3>SMS Scheduled Successfully</h3>";
$event_name = date("FjYgia")."_".$_SESSION['username'];
$mobile = explode(",",$_POST['mobile']);
mysql_query("SET GLOBAL event_scheduler=1") or die(mysql_error());
$i=0;
foreach($mobile as $mobi) {
mysql_query("CREATE EVENT ".$event_name.$i." ON SCHEDULE AT '".$_POST['datetime']."' DO INSERT INTO adbook.send_sms(sender,receiver,msgdata) VALUES ('".$by."','".$mobi."','".$_POST['msgdata']."')") or die(mysql_error());
$i +=1;
}
}
else {
echo "<h3>SMS sent to the following Persons:</h3>";
$msgdata = mysql_real_escape_string($_POST[msgdata]);
$numbers=explode(",",str_replace("-","",$_POST[receiver]));
$count=0;
foreach ($numbers as $number)
{
if($number == '')
continue;
$sql="INSERT INTO send_sms (sender, receiver, msgdata)
VALUES
('".$_SESSION['username']."','$number','$msgdata')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$count++;
$resulth = mysql_query($sql2 = "SELECT id FROM address WHERE phone1='".$number."'");
if(mysql_num_rows($resulth)!=0)
{
$shname = mysql_fetch_array($resulth);
$hresulth = mysql_query($sql3 = "SELECT firstname, middlename, lastname FROM contact WHERE id='".$shname[0]."'");
$shnames = mysql_fetch_array($hresulth);
$rep_name = $shname[middlename]. " " .$shnames[firstname]. " " .$shnames[lastname];
mysql_query("INSERT INTO report (receiver,mobile,msgdata,sender,time)
VALUES ('".$rep_name."','".$number."','".$msgdata."','".$by."','".$sms_time."')");
echo $shnames[firstname]. " " .$shnames[middlename]. " " .$shnames[lastname] . "<br />";
}
else
{
echo $number. "<br />";
mysql_query("INSERT INTO report (receiver,mobile,msgdata,sender,time)
VALUES ('NA','".$number."','".$msgdata."','".$by."','".$sms_time."')");
}
}
mysql_close($con);
echo "<br><h3>Total Number of Recipients : ".$count."</h3>";
}
?>
<br>
<table>
<tr>
<td><form action="list.php" method="post">
<input type="image" src="images/addressbook.png" />
</form></td>
<td><form action="sendsms.php" method="post">
<input type="image" src="images/send_more.png" />
</form></td>
</body>
</html>