四、Alexa/Google Page Rank
- function page_rank($page, $type = 'alexa'){
- switch($type){
- case 'alexa':
- $url = 'http://alexa.com/siteinfo/';
- $handle = fopen($url.$page, 'r');
- break;
- case 'google':
- $url = 'http://google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:';
- $handle = fopen($url.'http://'.$page, 'r');
- break;
- }
- $content = stream_get_contents($handle);
- fclose($handle);
- $content = preg_replace("~(n|t|ss+)~",'', $content);
- switch($type){
- case 'alexa':
- if(preg_match('~<div class="data (down|up)"><img.+?>(.+?) </div>~im',$content,$matches)){
- return $matches[2];
- }else{
- return FALSE;
- }
- break;
- case 'google':
- $rank = explode(':',$content);
- if($rank[2] != '')
- return $rank[2];
- else
- return FALSE;
- break;
- default:
- return FALSE;
- break;
- }
- }
- // Alexa Page Rank:
- echo 'Alexa Rank: '.page_rank('techug.com');
- echo ' ';
- // Google Page Rank
- echo 'Google Rank: '.page_rank('techug.com', 'google');
五、强制下载文件
- $filename = $_GET['file']; //Get the fileid from the URL
- // Query the file ID
- $query = sprintf("SELECT * FROM tableName WHERE id = '%s'",mysql_real_escape_string($filename));
- $sql = mysql_query($query);
- if(mysql_num_rows($sql) > 0){
- $row = mysql_fetch_array($sql);
- // Set some headers
- header("Pragma: public");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Content-Type: application/force-download");
- header("Content-Type: application/octet-stream");
- header("Content-Type: application/download");
- header("Content-Disposition: attachment; filename=".basename($row['FileName']).";");
- header("Content-Transfer-Encoding: binary");
- header("Content-Length: ".filesize($row['FileName']));
-
- @readfile($row['FileName']);
- exit(0);
- }else{
- header("Location: /");
- exit;
- }
六、用Email显示用户的Gravator头像
- $gravatar_link = 'http://www.gravatar.com/avatar/' . md5($comment_author_email) . '?s=32';
- echo '<img src="' . $gravatar_link . '" />';
七、用cURL获取RSS订阅数
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,'https://feedburner.google.com/api/awareness/1.0/GetFeedData?id=7qkrmib4r9rscbplq5qgadiiq4');
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2);
- $content = curl_exec($ch);
- $subscribers = get_match('/circulation="(.*)"/isU',$content);
- curl_close($ch);
(编辑:PHP编程网 - 黄冈站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|