-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathNG_sportsnews.php
59 lines (55 loc) · 1.84 KB
/
NG_sportsnews.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
<?php
$object=new sportsnews($spell_checked,$req);
if (!empty($object->return["sportsnews"])) {
$total_return = $object->return["sportsnews"];
if (!empty($object->return["options"])) {
$options_list = array_merge($options_list, $object->return["options"]);
$list = array_merge($list, $object->return["list"]);
}
$source_machine = $machine_id;
$current_file = "/temp/$numbers";
file_put_contents(DATA_PATH . $current_file, $total_return);
$to_logserver['source'] = 'NGsports';
include 'allmanip.php';
putOutput($total_return);
exit();
}
class sportsnews{
function __construct($spell_checked,$req){
if($spell_checked=="sports"){
echo $url="http://www.completesportsnigeria.com/news/category/breaking-news";
$this->getallsportsnews($url);
}elseif(preg_match('~__sportsnews__(.+)__~Usi',$req,$match)){
$url=trim($match[1]);
$this->getdetailssports($url);
}
}
function getallsportsnews($url){
$contents=file_get_contents($url);
if(preg_match_all('~<h3><a href="(.+)">(.+)</a></h3>~Usi',$contents,$match)){
if(count($match[1])>1){
$this->return['sportsnews']="Your query matches more than one result";
for($i=0;$i<count($match[1]);$i++){
$link=trim($match[1][$i]);
$title=trim($match[2][$i]);
$this->return["options"][] = $title;
$this->return["list"][] = array("content" => "__sportsnews__" . $link . "__");
}
}else{
$this->return['sportsnews']="No data found";
}
}else{
$this->return['sportsnews']="No data found";
}
}
function getdetailssports($url){
$content=file_get_contents($url);
if(preg_match('~<div class="article_body">(.+)</div>~Usi',$content,$match)){
$data=trim($match[1]);
$data=preg_replace('~<script type="text/javascript">(.+)</script>~','',$data);
$data=strip_tags($data);
$this->return['sportsnews']=$data;
}
}
}
?>