<?php $max_allow_links = 100; // 最大许可检查的链接数目 function my_file_get_contents($url, $timeout = 30) { if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } else if (ini_get('allow_url_fopen') == 1 || strtolower(ini_get('allow_url_fopen')) == 'on') { $file_contents = @file_get_contents($url); } else { $file_contents = ''; } return $file_contents; } function isExistsContentUrl($url, &$retMsg, $mydomain = "") { if (!isset($url) || empty($url)) { $retMsg = "配置URL为空"; return false; } if (!isset($mydomain) || empty($mydomain)) { $mydomain = $_SERVER['SERVER_NAME']; } $resultContent = my_file_get_contents($url); if (trim($resultContent) == '') { $retMsg = "网站无法访问"; return false; } if (strripos($resultContent, $mydomain)) { $retMsg = "友链正常"; return true; } else { $retMsg = "未添加本站"; return false; } } ?>
|