3)$moshi=2; if($moshi==2)require('mht.php');//生成wor文档需要 $link=db_connect(); $empire=new mysqlquery(); //$id=125130; $classid=(int)$_GET['classid']; $id=(int)$_GET['id']; $tpid=(int)$_GET['tpid'];// 内容模板id // $agree=(int)$_POST['agree']; $userid=(int)getcvar('mluserid');//用户id $username=RepPostVar(getcvar('mlusername'));//用户名 $groupid=(int)getcvar('mlgroupid');//会员组id $tbname=$class_r[$classid]['tbname']; if(!$tbname)printerror2('参数错误'); //验证会员信息 //$mloginauthr=qCheckLoginAuthstr(); //if(!$userid){ // printerror2('登录后才能下载'); //} /* // 看看有没有下载记录 $jilu=$empire->fetch1("select id from {$dbtbpre}enewsdownrecord where id=$id and classid=$classid and userid=$userid and online=2 limit 1"); if(!$jilu){ //取得登陆会员资料 if($userid&&$mloginauthr['islogin']){ $memberinfor=$empire->fetch1("select ".eReturnSelectMemberF('*','u.').",ui.* from ".eReturnMemberTable()." u LEFT JOIN {$dbtbpre}enewsmemberadd ui ON u.".egetmf('userid')."=ui.userid where u.".egetmf('userid')."='$userid' limit 1"); } //print_r($memberinfor);exit; $groupid=$memberinfor['groupid']; //$level=$empire->gettotal("select level as total from {$dbtbpre}enewsmembergroup where groupid='$groupid'"); $level=$groupid; //$guize=','.$public_r['add_chakan'].','; //preg_match("/,$level\\-([0-9]+),/",$guize,$chakan); /* if(!$chakan){ $flag="显示信息失败,请确认权限或稍后再试"; echo $flag;over(); } */ /* $cardfen=1; //intval($chakan[1]); //没有下载记录,同意扣点吗? /* if(!$agree){ echo "查看会消费点{$cardfen}积分。点击查看"; over(); } */ // 看分数够扣吗?不够拉到 /* if( $memberinfor['userfen']-$cardfen<0){ printerror2("您积分不够,无法查看,请冲值。"); } //点数足够,扣点 $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' and classid='$classid' limit 1"); $empire->query("update ".eReturnMemberTable()." set userfen=userfen-{$cardfen} where userid=$userid"); // 写消费记录 BakDown($classid,$id,0,$userid,$username,$r['title'],$cardfen,2); } */ $r=$empire->fetch1("select * from {$dbtbpre}ecms_{$tbname} where classid='$classid' and id='$id' limit 1"); $addr=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$id' limit 1"); $r=array_merge($r,$addr); $r['newstext']=stripslashes($r['newstext']); //查询新录 // require('template/index.temp.php'); //导入模板文件 if(!$r)printerror2('参数错误'); // 读取模板 $newstemp_r=$empire->fetch1("select temptext,showdate from ".GetTemptb("enewsnewstemp")." where tempid='$tpid' limit 1"); if(!$newstemp_r){ $newstemp_r['temptext']='

[!--title--]

[!--newstext--]
'; } if($moshi==3){ $hzh='.txt'; }else{ $hzh='.doc'; } //$newstemptext=$newstemp_r[temptext]; //返回替换验证字符 $docheckrep=ReturnCheckDoRepStr(); //返回编译 $newstemptext=GetInfoNewsBq($classid,$newstemp_r,$r,$docheckrep); $xieyi=is_https(); $qzhui=($xieyi?'https://':"http://"). $_SERVER[HTTP_HOST]; // 图片加绝对路径 $newstemptext=formaturl($newstemptext,$qzhui); //echo $newstemptext;exit; ob_start(); //打开缓冲区 if($moshi==1){ echo ''.$newstemptext.''; }else if($moshi==2){ echo getWordDocument($newstemptext, $qzhui); } else{ echo html2text($newstemptext); } header("Cache-Control: public"); header("Content-type: application/octet-stream"); header("Accept-Ranges: bytes"); if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) { header('Content-Disposition: attachment; filename='.$r['title'].$hzh); }else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) { header('Content-Disposition: attachment; filename='.$r['title'].$hzh); } else { header('Content-Disposition: attachment; filename='.$r['title'].$hzh); } header("Pragma:no-cache"); header("Expires:0"); ob_end_flush();//输出全部内容到浏览器 db_close(); //关闭MYSQL链接 $empire=null; //注消操作类变量 function over($flag=''){ global $empire; db_close(); $empire=null; exit($flag); } /** * PHP判断当前协议是否为HTTPS */ function is_https() { if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { return true; } elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) { return true; } elseif ( !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { return true; } return false; } function formaturl($l1, $l2) { if (preg_match_all ( "/(]+src=\"([^\"]+)\"[^>]*>)|(]+href=\"([^\"]+)\"[^>]*>)|(]+src='([^']+)'[^>]*>)|(]+href='([^']+)'[^>]*>)/i", $l1, $regs )) { foreach ( $regs [0] as $num => $url ) { $l1 = str_replace ( $url, lIIIIl ( $url, $l2 ), $l1 ); } } return $l1; } function lIIIIl($l1, $l2) { if (preg_match ( "/(.*)(href|src)\=(.+?)( |\/\>|\>).*/i", $l1, $regs )) { $I2 = $regs [3]; } if (strlen ( $I2 ) > 0) { $I1 = str_replace ( chr ( 34 ), "", $I2 ); $I1 = str_replace ( chr ( 39 ), "", $I1 ); } else { return $l1; } $url_parsed = parse_url ( $l2 ); $scheme = $url_parsed ["scheme"]; if ($scheme != "") { $scheme = $scheme . "://"; } $host = $url_parsed ["host"]; $l3 = $scheme . $host; if (strlen ( $l3 ) == 0) { return $l1; } $path = dirname ( $url_parsed ["path"] ); if ($path [0] == "\\") { $path = ""; } $pos = strpos ( $I1, "#" ); if ($pos > 0) $I1 = substr ( $I1, 0, $pos ); //判断类型 if (preg_match ( "/^(http|https|ftp):(\/\/|\\\\)(([\w\/\\\+\-~`@:%])+\.)+([\w\/\\\.\=\?\+\-~`@\':!%#]|(&)|&)+/i", $I1 )) { return $l1; } //http开头的url类型要跳过 elseif ($I1 [0] == "/") { $I1 = $l3 . $I1; } //绝对路径 elseif (substr ( $I1, 0, 3 ) == "../") { //相对路径 while ( substr ( $I1, 0, 3 ) == "../" ) { $I1 = substr ( $I1, strlen ( $I1 ) - (strlen ( $I1 ) - 3), strlen ( $I1 ) - 3 ); if (strlen ( $path ) > 0) { $path = dirname ( $path ); } } $I1 = $l3 . $path . "/" . $I1; } elseif (substr ( $I1, 0, 2 ) == "./") { $I1 = $l3 . $path . substr ( $I1, strlen ( $I1 ) - (strlen ( $I1 ) - 1), strlen ( $I1 ) - 1 ); } elseif (strtolower ( substr ( $I1, 0, 7 ) ) == "mailto:" || strtolower ( substr ( $I1, 0, 11 ) ) == "javascript:") { return $l1; } else { $I1 = $l3 . $path . "/" . $I1; } return str_replace ( $I2, "\"$I1\"", $l1 ); } function html2text($str){ $str = preg_replace("/