-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
50 lines (45 loc) · 1.55 KB
/
index.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
<?php
// ini_set('display_errors',1);
// error_reporting(E_ALL);
define("ROOT", __DIR__);
//require(ROOT."/config.php");
require(ROOT."/Toro.php");
//require(ROOT."/lib/db.php");
require(ROOT."/handlers/home.php"); //function requires all the files stored in ROOT."/handlers/"
require(ROOT."/handlers/getpop.php");
//require(ROOT."/handlers/search.php");
require 'config/settings.php';
ToroHook::add("404", function() {
echo "Not found";
});
class searchHandler{
function get($name=NULL) {
if($name){
$pop = new getpop();
global $csURL;
$response=file_get_contents($csURL."&q={$name}");
$response=json_decode($response,true);
$searchResults = $response["items"];
$i = 0;
foreach($searchResults as $item)
{ if($i>2)
break;
$url = $item["link"];
$score[$i] = $pop->pop_score($url);
//echo $score[$i];
$i = $i + 1;
}
echo array_sum($score)/3;
}
else{
include "views/csearch.php";
}
;
}
}
Toro::serve(array(
"/" => "HomeHandler",
"/csearch" => "searchHandler",
"/csearch/([a-zA-Z0-9-_]+)" => "searchHandler"
));
?>