forked from Innoz-Technologies/SMSGyan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diffQuestions.php
47 lines (40 loc) · 1.76 KB
/
diffQuestions.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
<?php
if (preg_match("~\b^((difference|diff) between)|diffbtw\b~", $spell_checked)) {
$diffQuestion = trim(preg_replace("~(The|differences?|diff|between|diffbtw)~", "", $spell_checked));
echo "<br>" . $query = "SELECT *,MATCH (question) AGAINST('$diffQuestion') as relv FROM diffquestions WHERE MATCH (question) AGAINST('$diffQuestion') having relv >6 order by relv desc limit 1";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
if (empty($row["response"])) {
$url = $row["url"];
$content = file_get_contents($url);
if (preg_match("~<div class=\"entry clearfloat\">(.+)</div>~Usi", $content, $matches)) {
$out = $matches[1];
$out = str_replace("</strong>", "***", $out);
$out = strip_tags($out);
$out = preg_replace("~[\s]+~", " ", $out);
$out = str_replace("***", "\n", $out);
$out = str_replace("\n ", "\n", $out);
$out = clean($out);
$out = str_replace("‘", "", $out);
$out = str_replace("’", "", $out);
$total_return = trim($out);
$q = "Update diffquestions set response='$out' where id=" . $row["id"];
mysql_query($q);
}
} else {
echo "<br>From Data base<br>";
$total_return = $row["response"];
}
}
if ($total_return) {
$source_machine = $machine_id;
$current_file = "/temp/$numbers";
file_put_contents(DATA_PATH . $current_file, $total_return);
$to_logserver['source'] = 'diffbtw';
include 'allmanip.php';
putOutput($total_return);
exit();
}
}
?>