-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.php
63 lines (55 loc) · 1.75 KB
/
router.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
<?
function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$url = $_GET["q"];
$html = file_get_contents_curl($url);
//parsing begins here:
$doc = new DOMDocument();
$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
//get and display what you need:
$title = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description')
$description = $meta->getAttribute('content');
if($meta->getAttribute('name') == 'keywords')
$keywords = $meta->getAttribute('content');
}
$imgs = $doc->getElementsByTagName('img');
$srcimg="";
$count=0;
for ($i = 0; $i < $imgs->length; $i++)
{
$img = $imgs->item($i);
$aux = $img->getAttribute('src');
if (preg_match("#^https?://(.*).[png|jpg]$#", $aux) ){
$srcimg.= "&p[images][$i]=".urlencode($aux);
$count++;
}
if ($count == 4) break;
}
/*print $srcimg;
exit;*/
/*echo "Title: $title". '<br/><br/>';
echo "Description: $description". '<br/><br/>';
echo "Keywords: $keywords";
*/
//$description = "<a href='http://search.titanbrowser.com/'>Im browsing safe with TitanBrowser</a> $description";
$title="$title - I'm browsing Safely with TitanBrowser";
$url2="http://titanbrowser.com/page.php?url=$url";
$newURL="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=".urlencode($url2).$srcimg."&p[title]=".urlencode($title)."&p[summary]=".urlencode($description);
//print $newURL;
header('Location: '.$newURL);
?>