Print '.$data.''; $filepath = tmpfile(); $data = str_replace("\n","",$data); $data = str_replace("
","
",$data);
    $data = str_replace("
","
",$data); $len = strlen($data); fwrite($filepath, $data); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename={$fileName}.doc"); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$fileName.'.doc'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . $len); rewind($filepath); echo fread($filepath,$len); } function clear_runtime($path = RUNTIME_PATH){ //给定的目录不是一个文件夹 if(!is_dir($path)){ return null; } $fh = opendir($path); while(($row = readdir($fh)) !== false){ //过滤掉虚拟目录 if($row == '.' || $row == '..'|| $row == 'index.html'){ continue; } if(!is_dir($path.'/'.$row)){ unlink($path.'/'.$row); } clear_runtime($path.'/'.$row); } //关闭目录句柄,否则出Permission denied closedir($fh); return true; } //获取ip function getIPaddress(){ $IPaddress=''; if (isset($_SERVER)){ if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){ $IPaddress = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else if (isset($_SERVER["HTTP_CLIENT_IP"])) { $IPaddress = $_SERVER["HTTP_CLIENT_IP"]; } else { $IPaddress = $_SERVER["REMOTE_ADDR"]; } } else { if (getenv("HTTP_X_FORWARDED_FOR")){ $IPaddress = getenv("HTTP_X_FORWARDED_FOR"); } else if (getenv("HTTP_CLIENT_IP")) { $IPaddress = getenv("HTTP_CLIENT_IP"); } else { $IPaddress = getenv("REMOTE_ADDR"); } } return $IPaddress; } /** * POST 请求 * * @param string $url * @param array $param * @return string content */ function http_post($url, $param) { $oCurl = curl_init (); if (stripos ( $url, "https://" ) !== FALSE) { curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYHOST, false ); } if (is_string ( $param )) { $strPOST = $param; } else { $aPOST = array (); foreach ( $param as $key => $val ) { $aPOST [] = $key . "=" . urlencode ( $val ); } $strPOST = join ( "&", $aPOST ); } curl_setopt ( $oCurl, CURLOPT_URL, $url ); curl_setopt ( $oCurl, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $oCurl, CURLOPT_POST, true ); curl_setopt ( $oCurl, CURLOPT_POSTFIELDS, $strPOST ); $sContent = curl_exec ( $oCurl ); curl_close ( $oCurl ); return $sContent; } function compress_string($string){ return base64_encode( gzcompress($string, 9)) ; } function uncompress_string($string){ return gzuncompress(base64_decode($string)); }