forked from Innoz-Technologies/SMSGyan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
celebrity.php
132 lines (108 loc) · 4.14 KB
/
celebrity.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
<?php
apc_fetch("celebrityName", $success);
if (!$success) {
echo "<h1>Connceting</h1>";
mysql_close();
include 'lib/configdb2.php';
}
require_once 'binary_search.php';
echo "<h4>CITY SEARCH</h4>";
$tree = new BinarySearch('celebrityName', 'msisdn', 1);
$btime = microtime(true);
echo $c_number = $tree->search($number, 1);
if (!$success) {
mysql_close();
include 'lib/appconfigdb.php';
}
if (!empty($c_number)) {
mysql_close();
include 'lib/configdb2.php';
$query = "select * from celebrityName where msisdn='$c_number'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
$celebrityName = $row["name"];
$celebrityID = $row["id"];
$q = "INSERT INTO celebrityTweets(`celebrityID`,`tweets`) VALUES($celebrityID,'" . mysql_real_escape_string($query_in) . "')";
if (mysql_query($q)) {
echo "<br>Record Insertd";
}
}
$total_return = "successfully posted";
$isReturn = 0;
mysql_close();
include 'lib/appconfigdb.php';
} elseif (preg_match("~__celebrity__(.+)__(.+)__(.+)__~is", $req, $match)) {
mysql_close();
include 'lib/configdb2.php';
$celebrityID = $match[1];
$type = $match[2];
$celebrityName = $match[3];
if ($type == "list") {
$cbTime = date("Y-m-d H:i:s");
} else {
$cbTime = $type;
}
echo $q = "select * from celebrityTweets where celebrityID=" . $celebrityID . " and `timestamp`< '$cbTime' order by `timestamp` desc limit 2";
$result1 = mysql_query($q);
if (mysql_num_rows($result1)) {
$row1 = mysql_fetch_array($result1);
$total_return = $celebrityName . " : " . $row1["tweets"];
if (mysql_num_rows($result1) > 1) {
$options_list[] = "Previous";
$list[] = array("content" => "__celebrity__" . $row1["celebrityID"] . "__" . $row1["timestamp"] . "__" . $celebrityName . "__");
}
}
if (empty($total_return)) {
$total_return = "Sorry no celebrity data found";
}
mysql_close();
include 'lib/appconfigdb.php';
} elseif (preg_match("~\b(celeb|celebrity)\b~is", $spell_checked)) {
$search_celeb = trim(preg_replace("~\b(celebrity|celeb)\b~si", "", $spell_checked));
mysql_close();
include 'lib/configdb2.php';
if (empty($search_celeb)) {
$total_return = "List of matching celebrities are : ";
$query = "select * from celebrityName";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$options_list[] = $row["name"];
$list[] = array("content" => "__celebrity__" . $row["id"] . "__list__" . $row["name"] . "__");
}
} else {
echo $query = "select * from celebrityName where name like '%$search_celeb%'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 1) {
$total_return = "List of matching celebrities are : ";
while ($row = mysql_fetch_array($result)) {
$options_list[] = $row["name"];
$list[] = array("content" => "__celebrity__" . $row["id"] . "__list__" . $row["name"] . "__");
}
} elseif (mysql_num_rows($result) == 1) {
$row = mysql_fetch_array($result);
echo $q = "select * from celebrityTweets where celebrityID=" . $row["id"] . " order by `timestamp` desc limit 2";
$result1 = mysql_query($q);
if (mysql_num_rows($result1)) {
$row1 = mysql_fetch_array($result1);
$total_return = $row["name"] . " : " . $row1["tweets"];
if (mysql_num_rows($result1) > 1) {
$options_list[] = "Previous";
$list[] = array("content" => "__celebrity__" . $row1["celebrityID"] . "__" . $row1["timestamp"] . "__" . $row["name"] . "__");
}
}
}
}
if (empty($total_return)) {
$total_return = "Sorry no celebrity data found";
}
mysql_close();
include 'lib/appconfigdb.php';
}
if ($total_return) {
$to_logserver['source'] = 'celeb';
include 'allmanip.php';
putOutput($total_return);
exit();
}
?>