-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathhoroscope.php
163 lines (152 loc) · 8.88 KB
/
horoscope.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
<?php
$hor_req = strtolower($hor_req);
$horo_len = strlen($hor_req);
echo "<br>HOROSCOPEREQUERST: $hor_req <br>";
$return_zodiac = "";
$hor = '';
$time = (int) date('G');
echo $time;
$flag = 0;
if ($horo_len > 2) {
$srchs = explode(' ', $hor_req);
print_r($srchs);
$lev_arry = array();
if ($appQueryFrom == "thai")
$zodiac = array("rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "sheep", "monkey", "rooster", "dog", "pig");
else
$zodiac = array('aries', 'taurus', 'gemini', 'cancer', 'leo', 'virgo', 'scorpio', 'sagittarius', 'aquarius', 'pisces', 'libra', 'capricorn');
foreach ($srchs as $que) {
foreach ($zodiac as $key => $ti) {
if (strcmp($ti, $que) == 0) {
$hor = $ti;
break;
} else if ($horo_len <= 15) {
$leven = levenshtein($ti, $que);
if ($leven <= strlen($ti) / 3) {
if (!isset($lev_arry[$key]) || $leven > $lev_arry[$key]) {
$lev_arry[$key] = $leven;
}
}
}
}
if ($hor)
break;
}
if ($horo_len <= 15 && count($lev_arry)) {
asort($lev_arry);
print_r($lev_arry);
$temp = each($lev_arry);
$key = $temp["key"];
$hor = $zodiac[$key];
}
if ($hor) {
$result1 = mysql_query("SELECT details FROM horoscope where sign='$hor' and time='" . (date("Y-m-d")) . "' ");
$row = mysql_fetch_array($result1);
if ($row) {
echo'its entering';
echo '<br>...From Database....';
$return_zodiac = $row['details'];
if ($userid == "51de6d17b3e9a")
$add_below = "";
else
$add_below = "\n--\nInternet search on sms! Sms HELP to $shortcode to find out more.$tollfree";
} else {
//$url = "http://astrology.oneindia.in/include/signname.asp?content=d&subcontent=$hor";
// $url = "http://astrology.oneindia.in/horoscopes/daily-horoscope/$hor/";
//
// start changes made on 02/02/2012
if ($appQueryFrom == "thai") {
echo $url = "http://www.chinese-tools.com/astrology/horoscope/daily/sign_$hor.html";
$content = file_get_contents($url);
if (preg_match('~<div class="astroTitle">(.+)</table></div>~Usi', $content, $match)) {
$hordata = $match[1];
$hordata = preg_replace("~[\s]+~", " ", $hordata);
$hordata = str_replace("</div>", ":", $hordata);
$hordata = str_replace("</p>", "+++", $hordata);
$hordata = str_replace("</td></tr>", "+++", $hordata);
$hordata = strip_tags($hordata);
$hordata = preg_replace("~[\s]+~", " ", $hordata);
$hordata = str_replace("+++", "\n", $hordata);
$return_zodiac = trim($hordata);
//$add_below = "\n--\nInternet search on sms! Sms HELP to $shortcode to find out more.$tollfree";
if ($time >= 8) {
echo $query = "replace into horoscope(sign,time,details) values ('" . mysql_escape_string($hor) . "','" . (date("Y-m-d ")) . "','" . mysql_escape_string($return_zodiac) . "')";
$result1 = mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
}
}
} else {
$url = "http://my.horoscope.com/astrology/free-daily-horoscope-$hor.html";
echo "<br>................$url.................<br>";
$result = file_get_contents($url);
if (preg_match("~<div class=\".+\" style=\".+\" id=\".+\">(.+)</div>~", $result, $match)) {
$data = strip_tags($match[1]);
$return_zodiac = trim($data);
$add_below = "\n--\nInternet search on sms! Sms HELP to $shortcode to find out more.$tollfree";
if ($time >= 8) {
echo $query = "replace into horoscope(sign,time,details) values ('" . mysql_escape_string($hor) . "','" . (date("Y-m-d ")) . "','" . mysql_escape_string($return_zodiac) . "')";
$result1 = mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
}
}
}
//end hanges made on 02/02/2012
// var_dump($result);
// $start = strpos($result, "Horoscope for");
// if ($start != 0) {
// $result = substr($result, $start);
// $end = strpos($result, '<br />');
// if ($end != 0) {
// $result = trim(substr($result, 0, $end));
// $result = str_replace('</h1>', ' *** ', $result);
// $result = strip_tags($result);
// $result = preg_replace("~[\s]+~", " ", $result);
// $result = str_replace(' *** ', "\n", $result);
// $return_zodiac = trim($result);
// $add_below = "\n--\nInternet search on sms! Sms HELP to $shortcode to find out more.$tollfree";
// }
// if ($time >= 8) {
// echo $query = "replace into horoscope(sign,time,details) values ('" . mysql_escape_string($hor) . "','" . (date("Y-m-d ")) . "','" . mysql_escape_string($return_zodiac) . "')";
// $result1 = mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
// }
// }
}
} else if ($horo_must) {
$return_zodiac = "Sorry, no horoscope found for $hor_req\nSelect one.";
$to_logserver['isresult'] = 0;
$free = true;
foreach ($zodiac as $key => $ti) {
$options_list[] = strtoupper($ti);
$list[] = array('content' => "horoscope $ti");
}
}
}
// $url = "http://living.oneindia.in/astrology/astro/horoscope.php?func=change_sunsign&duration=daily&sunsign=$hor";
// echo "<br>................$url.................<br>";
// $data = file_get_contents($url);
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/aries.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/taurus.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/gemini.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/cancer.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/leo.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/virgo.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/scorpio.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/sagittarius.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/aquarius.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/pisces.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/libra.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
// $find = "<div class='sun_sign_horscope_top sun_sign_horscope'><img src='/astrology/astro/images/horoscope/capricorn.jpg' border='0' align='left' class='sunsign_image_alignment'>";
// $data = (str_replace($find, "", $data));
//
// $data = (str_replace('</div>', "", $data));
// $data = trim($data);
?>