-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_get_tic.php
69 lines (53 loc) · 2 KB
/
project_get_tic.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
<?php
# zloy.org
function get_download($url){
$ret = false;
if( function_exists('curl_init') ){
if( $curl = curl_init() ){
if( !curl_setopt($curl,CURLOPT_URL,$url) ) return $ret;
if( !curl_setopt($curl,CURLOPT_RETURNTRANSFER,true) ) return $ret;
if( !curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,30) ) return $ret;
if( !curl_setopt($curl,CURLOPT_HEADER,false) ) return $ret;
if( !curl_setopt($curl,CURLOPT_ENCODING,"gzip,deflate") ) return $ret;
$ret = curl_exec($curl);
curl_close($curl);
}
}
else{
$u = parse_url($url);
if( $fp = @fsockopen($u['host'],!empty($u['port']) ? $u['port'] : 80 ) ){
$headers = 'GET '. $u['path'] . '?' . $u['query'] .' HTTP/1.0'. "\r\n";
$headers .= 'Host: '. $u['host'] ."\r\n";
$headers .= 'Connection: Close' . "\r\n\r\n";
fwrite($fp, $headers);
$ret = '';
while( !feof($fp) ){
$ret .= fgets($fp,1024);
}
$ret = substr($ret,strpos($ret,"\r\n\r\n") + 4);
fclose($fp);
}
}
return $ret;
}
function get_yandex($url){
$ret = 'N/A';
if( substr($url,0,7) != 'http://' )
$url = 'http://' . $url;
if( $content = get_download('http://bar-navig.yandex.ru/u?ver=2&url='. urlencode($url) .'&show=1&post=0') ){
if( class_exists('SimpleXMLElement') ){
if( $xmldoc = new SimpleXMLElement($content) ){
$tcy = $xmldoc->tcy;
if( !empty($tcy) ){
$ret = $tcy['value'];
}
}
}
else{
preg_match("/value=\"(.\d*)\"/",$content,$tic);
if( !empty($tic[1]) ) $ret = $tic[1];
}
}
return $ret;
}
?>