<?php 

function filedate( $flietime ){    
$_flietime = date( "Y-m-d H:i:s", @filemtime( $flietime ) );    
return $_flietime;
}
function removedir($dirName) 
{ 
    if(!is_dir($dirName)) 
    { 
        return false; 
    } 
    $handle = @opendir($dirName); 
    while(($file = @readdir($handle)) !== false) 
    { 
        if($file != '.' && $file != '..') 
        { 
            $dir = $dirName . '/' . $file; 
            is_dir($dir) ? removeDir($dir) : @unlink($dir); 
        } 
    } 
    closedir($handle); 
     
    return rmdir($dirName) ; 
}
function DeleteHtml($str) {
	$str = trim ( $str );
	$str = strip_tags ( $str, "" );
	$str = ereg_replace ( "\t", "", $str );
	$str = ereg_replace ( "\r\n", "", $str );
	$str = ereg_replace ( "\r", "", $str );
	$str = ereg_replace ( "\n", "", $str );
	$str = ereg_replace ( " ", " ", $str );
	return trim ( $str );
}
function qq86226656($url){
	if($caiji="curl_init"){
	$ch = curl_init($url);
	$user_agent = "Baiduspider+(+http://www.baidu.com/search/spider.htm)";
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_REFERER, 'http://www.baidu.com');//
	curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
	$data = curl_exec($ch);
	curl_close($ch);
	return $data;
	}if($caiji="file_get_contents"){
	
	for($i=0;$i<3;$i++){
    $data = @file_get_contents($url);
    if($data) break;
	}
	return $data;
	}
	if($caiji="fsock"){
	$timeout = 5;
	$referer = "";
	$bits = @parse_url ( $url );
	if (! $bits [host]) {
		return "";
	}
	if ($bits [port]) {
		$port = intval ( $bits [port] );
	} else {
		$port = $bits [scheme] == "https" ? 443 : 80;
	}
	$portq = $port == 80 ? "" : ":{$port}";
	$stime = time ();
	$fp = @fsockopen ( $bits [host], $port, $errno, $errstr, $timeout );
	if (! $fp) {
		return "";
	} else {
		$stime = time () - $stime;
		$timeout = $timeout - $stime;
		if ($timeout < 1) {
			$timeout = 1;
		}
		stream_set_timeout ( $fp, $timeout );
		if (! $referer) {
			$referer = $bits [scheme] . "://" . $bits [host] . "/";
		}
		$path = $bits [path] ? $bits [path] : "/";
		if ($bits [query]) {
			$path .= "?" . $bits [query];
		}
		$out = "GET {$path} HTTP/1.0\r\n";
		$out .= "Host: {$bits[host]}{$portq}\r\n";
		$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n";
		$out .= "Accept: *//*\r\n";
		$out .= "Accept-Language: zh-cn\r\n";
		$out .= "Accept-Encoding: identity\r\n";
		$out .= "Referer: {$referer}\r\n";
		$out .= "Connection: Close\r\n\r\n";
		fputs ( $fp, $out );
		$data = "";
		$inHeaders = TRUE;
		while ( $line = @fgets ( $fp, 2048 ) ) {
			if ($inHeaders) {
				$line = trim ( $line );
				if (empty ( $line )) {
					$inHeaders = FALSE;
				}
				continue;
			}
			$data .= $line;
		}
		fclose ( $fp );
		return $data;
	}
	
	}
	if($caiji="pfsock"){
	$timeout = 5;
	$referer = "";
	$bits = @parse_url ( $url );
	if (! $bits [host]) {
		return "";
	}
	if ($bits [port]) {
		$port = intval ( $bits [port] );
	} else {
		$port = $bits [scheme] == "https" ? 443 : 80;
	}
	$portq = $port == 80 ? "" : ":{$port}";
	$stime = time ();
	$fp = @pfsockopen ( $bits [host], $port, $errno, $errstr, $timeout );
	if (! $fp) {
		return "";
	} else {
		$stime = time () - $stime;
		$timeout = $timeout - $stime;
		if ($timeout < 1) {
			$timeout = 1;
		}
		stream_set_timeout ( $fp, $timeout );
		if (! $referer) {
			$referer = $bits [scheme] . "://" . $bits [host] . "/";
		}
		$path = $bits [path] ? $bits [path] : "/";
		if ($bits [query]) {
			$path .= "?" . $bits [query];
		}
		$out = "GET {$path} HTTP/1.0\r\n";
		$out .= "Host: {$bits[host]}{$portq}\r\n";
		$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n";
		$out .= "Accept: *//*\r\n";
		$out .= "Accept-Language: zh-cn\r\n";
		$out .= "Accept-Encoding: identity\r\n";
		$out .= "Referer: {$referer}\r\n";
		$out .= "Connection: Close\r\n\r\n";
		fputs ( $fp, $out );
		$data = "";
		$inHeaders = TRUE;
		while ( $line = @fgets ( $fp, 2048 ) ) {
			if ($inHeaders) {
				$line = trim ( $line );
				if (empty ( $line )) {
					$inHeaders = FALSE;
				}
				continue;
			}
			$data .= $line;
		}
		fclose ( $fp );
		return $data;
	}
	
	}
}
function shu($str,$start,$len) { 
$tmpstr = ""; 
$strlen = $start +$len; 
for($i = 0;$i <$strlen;$i++) { 
if(ord(substr($str,$i,1)) >0xa0) { 
$tmpstr .= substr($str,$i,2); 
$i++; 
}else 
$tmpstr .= substr($str,$i,1); 
} 
return $tmpstr; 
} 
?>