/e/class/functions.php
PHP | 5626 lines | 5435 code | 50 blank | 141 comment | 161 complexity | 9f83a73e9c55885693e5955cc96ccf8e MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- define('InEmpireCMSHfun',TRUE);
- //-------------- 公共区 ----------------------
-
- //返回后台风格
- function EcmsReturnAdminStyle(){
- global $public_r;
- $adminstyle=(int)getcvar('loginadminstyleid',1);
- if(!strstr($public_r['adminstyle'],','.$adminstyle.','))
- {
- $adminstyle=$public_r['defadminstyle']?$public_r['defadminstyle']:1;
- }
- return $adminstyle;
- }
-
- //返回后台管理信息栏目导航字符串
- function AdminReturnClassLink($classid){
- global $class_r,$editor,$fun_r;
- if($editor==1)
- {
- $addurl='../';
- }
- if(empty($class_r[$classid][featherclass]))
- {
- $class_r[$classid][featherclass]="|";
- }
- $r=explode("|",$class_r[$classid][featherclass].$classid."|");
- $string="<a href=\"".$addurl."ListAllInfo.php?tbname=".$class_r[$classid][tbname]."\">".$fun_r['AdminInfo']."</a>";
- $count=count($r)-1;
- for($i=1;$i<$count;$i++)
- {
- $curl=$class_r[$r[$i]][islast]?"ListNews.php?classid=".$r[$i]:"ListAllInfo.php?tbname=".$class_r[$r[$i]][tbname]."&classid=".$r[$i];
- $string.=" > <a href=\"".$addurl."$curl\">".$class_r[$r[$i]][classname]."</a>";
- }
- return $string;
- }
-
- //加验证代码
- function AddCheckViewCode(){
- $code="if(!defined('InEmpireCMS'))
- {
- exit();
- }";
- return $code;
- }
-
- //加模板验证代码
- function AddCheckViewTempCode(){
- $code="<?php
- if(!defined('InEmpireCMS'))
- {
- exit();
- }
- ?>";
- return $code;
- }
-
- //后台分页
- function page2($num,$line,$page_line,$start,$page,$search){
- global $fun_r;
- if($num<=$line)
- {
- return '<span class="epages"><a title="'.$fun_r['admintrecord'].'"> <b>'.$num.'</b> </a> </span>';
- }
- $search=htmlspecialchars($search,ENT_QUOTES);
- $url=$_SERVER['PHP_SELF'].'?page';
- $snum=2;//最小页数
- $totalpage=ceil($num/$line);//取得总页数
- $firststr='<a title="'.$fun_r['admintrecord'].'"> <b>'.$num.'</b> </a> ';
- //上一页
- if($page<>0)
- {
- $toppage='<a href="'.$url.'=0'.$search.'">'.$fun_r['adminstartpage'].'</a> ';
- $pagepr=$page-1;
- $prepage='<a href="'.$url.'='.$pagepr.$search.'">'.$fun_r['adminpripage'].'</a>';
- }
- //下一页
- if($page!=$totalpage-1)
- {
- $pagenex=$page+1;
- $nextpage=' <a href="'.$url.'='.$pagenex.$search.'">'.$fun_r['adminnextpage'].'</a>';
- $lastpage=' <a href="'.$url.'='.($totalpage-1).$search.'">'.$fun_r['adminlastpage'].'</a>';
- }
- $starti=$page-$snum<0?0:$page-$snum;
- $no=0;
- for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
- {
- $no++;
- if($page==$i)
- {
- $is_1="<b>";
- $is_2="</b>";
- }
- else
- {
- $is_1='<a href="'.$url.'='.$i.$search.'">';
- $is_2="</a>";
- }
- $pagenum=$i+1;
- $returnstr.=" ".$is_1.$pagenum.$is_2;
- }
- $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
- return '<span class="epages">'.$returnstr.'</span>';
- }
-
- //后台分页
- function postpage($num,$line,$page_line,$start,$page,$form){
- global $fun_r;
- if($num<=$line)
- {
- return '';
- }
- $snum=2;//最小页数
- $totalpage=ceil($num/$line);//取得总页数
- $firststr='<a title="'.$fun_r['admintrecord'].'"> <b>'.$num.'</b> </a> ';
- //上一页
- if($page<>0)
- {
- $toppage='<a href="#ecms" onclick="javascript:GotoPostPage(0,0);">'.$fun_r['adminstartpage'].'</a> ';
- $pagepr=$page-1;
- $prepage='<a href="#ecms" onclick="javascript:GotoPostPage('.$pagepr.',0);">'.$fun_r['adminpripage'].'</a>';
- }
- //下一页
- if($page!=$totalpage-1)
- {
- $pagenex=$page+1;
- $nextpage=' <a href="#ecms" onclick="javascript:GotoPostPage('.$pagenex.',0);">'.$fun_r['adminnextpage'].'</a>';
- $lastpage=' <a href="#ecms" onclick="javascript:GotoPostPage('.($totalpage-1).',0);">'.$fun_r['adminlastpage'].'</a>';
- }
- $starti=$page-$snum<0?0:$page-$snum;
- $no=0;
- for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
- {
- $no++;
- if($page==$i)
- {
- $is_1="<b>";
- $is_2="</b>";
- }
- else
- {
- $is_1='<a href="#ecms" onclick="javascript:GotoPostPage('.$i.',0);">';
- $is_2="</a>";
- }
- $pagenum=$i+1;
- $returnstr.=" ".$is_1.$pagenum.$is_2;
- }
- $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
- $returnstr.="<script>
- function GotoPostPage(page,start){
- ".$form.".page.value=page;
- ".$form.".start.value=start;
- ".$form.".submit();
- }
- </script>";
- return $returnstr;
- }
-
- //取得模型表名
- function GetModTable($mid){
- global $empire,$dbtbpre;
- $r=$empire->fetch1("select tid,tbname from {$dbtbpre}enewsmod where mid='$mid'");
- return $r;
- }
-
- //建立专题目录
- function CreateZtPath($ztpath){
- $createpath=ECMS_PATH.$ztpath;
- $mk=DoMkdir($createpath);
- }
-
- //建立栏目目录
- function CreateClassPath($classpath){
- $createpath=ECMS_PATH.$classpath;
- $mk=DoMkdir($createpath);
- $createfilepath=ECMS_PATH.'d/file/'.$classpath;//建立附件目录
- $mk1=DoMkdir($createfilepath);
- }
-
- //删除栏目缓存文件
- function DelListEnews(){
- $file=ECMS_PATH."e/data/fc/ListEnews.php";
- DelFiletext($file);
- $file1=ECMS_PATH."e/data/fc/ListClass0.php";
- DelFiletext($file1);
- $file2=ECMS_PATH."e/data/fc/ListClass1.php";
- DelFiletext($file2);
- }
-
- //删除模板临时缓存文件
- function DelOneTempTmpfile($classid){
- $file=ECMS_PATH.'e/data/tmp/dt_temp'.$classid.'.php';
- if(file_exists($file))
- {
- DelFiletext($file);
- }
- }
-
- //替换php代码
- function RepPhpAspJspcode($string){
- global $public_r;
- if(!$public_r[candocode]){
- //$string=str_replace("<?xml","[!--ecms.xml--]",$string);
- $string=str_replace("<\\","<\\",$string);
- $string=str_replace("<?","<?",$string);
- $string=str_replace("<%","<%",$string);
- if(stristr($string,' language'))
- {
- $string=preg_replace(array('!<script!i','!</script>!i'),array('<script','</script>'),$string);
- }
- //$string=str_replace("[!--ecms.xml--]","<?xml",$string);
- }
- return $string;
- }
-
- //替换php代码
- function RepPhpAspJspcodeText($string){
- //$string=str_replace("<?xml","[!--ecms.xml--]",$string);
- $string=str_replace("<\\","<\\",$string);
- $string=str_replace("<?","<?",$string);
- $string=str_replace("<%","<%",$string);
- if(stristr($string,' language'))
- {
- $string=preg_replace(array('!<script!i','!</script>!i'),array('<script','</script>'),$string);
- }
- //$string=str_replace("[!--ecms.xml--]","<?xml",$string);
- $string=str_replace("<!--code.start-->","<!--code.start-->",$string);
- $string=str_replace("<!--code.end-->","<!--code.end-->",$string);
- return $string;
- }
-
- //替换文件前缀
- function RepFilenameQz($qz,$ecms=0){
- if(empty($ecms))
- {
- $qz=str_replace("/","",$qz);
- $qz=str_replace("\\","",$qz);
- }
- $qz=str_replace("#","",$qz);
- $qz=str_replace("&","",$qz);
- $qz=str_replace(":","",$qz);
- $qz=str_replace(";","",$qz);
- $qz=str_replace("<","",$qz);
- $qz=str_replace(">","",$qz);
- $qz=str_replace("?","",$qz);
- $qz=str_replace("*","",$qz);
- $qz=str_replace("%","",$qz);
- $qz=str_replace("|","",$qz);
- $qz=str_replace("\"","",$qz);
- $qz=str_replace("'","",$qz);
- $qz=str_replace(".","",$qz);
- return $qz;
- }
-
- //替换目录值
- function RepPathStr($path){
- $path=str_replace("\\","",$path);
- $path=str_replace("/","",$path);
- return $path;
- }
-
- //返回替换字符
- function ReturnCheckDoRep(){
- global $empire,$dbtbpre;
- //信息来源
- $befrom=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbefrom");
- //作者
- $writer=$empire->gettotal("select count(*) as total from {$dbtbpre}enewswriter");
- //替换字符
- $words=$empire->gettotal("select count(*) as total from {$dbtbpre}enewswords");
- //内容关键字
- $key=$empire->gettotal("select count(*) as total from {$dbtbpre}enewskey");
- $str=",$befrom,$writer,$words,$key,";
- return $str;
- }
-
- //返回替换验证
- function ReturnCheckDoRepStr(){
- global $public_r;
- return explode(',',$public_r[checkdorepstr]);
- }
-
- //取得栏目目录名称
- function GetPathname($classname){
- $c=explode("/",$classname);
- $count=count($c)-1;
- $cr[0]=$c[$count];//栏目目录名
- $len=strlen($cr[0]);
- //上级栏目目录名
- $cr[1]=substr($classname,0,strlen($classname)-$len);
- return $cr;
- }
-
- //更新缓存
- function ChangeEnewsData($userid,$username){
- //操作权限
- CheckLevel($userid,$username,$classid,"changedata");
- //更新参数设置
- GetConfig(1);
- //更新类别
- GetClass();
- //更新会员组
- GetMemberLevel();
- //更新全站搜索数据表
- GetSearchAllTb();
- //操作日志
- insert_dolog("");
- printerror("ChangeDataSuccess","history.go(-1)");
- }
-
- //返回文件名
- function ReturnPathFile($filename){
- $fr=explode("/",$filename);
- $count=count($fr)-1;
- return $fr[$count];
- }
-
- //返回栏目链接(无缓存)
- function sys_ReturnBqClassUrl($r){
- global $public_r;
- //外部栏目
- if($r[wburl])
- {
- $classurl=$r[wburl];
- }
- //动态列表
- elseif($r['listdt'])
- {
- $classurl=$public_r['newsurl']."e/action/ListInfo/?classid=$r[classid]";
- }
- elseif($r['classurl'])
- {
- $classurl=$r['classurl'];
- }
- else
- {
- $classurl=$public_r['newsurl'].$r['classpath']."/";
- }
- return $classurl;
- }
-
- //返回专题链接(无缓存)
- function sys_ReturnBqZtUrl($r){
- global $public_r;
- if($r['zturl'])
- {
- $zturl=$r['zturl'];
- }
- else
- {
- $zturl=$public_r['newsurl'].$r['ztpath']."/";
- }
- return $zturl;
- }
-
- //组合两数组
- function TogTwoArray($r,$ra){
- $returnr=array_merge($r,$ra);
- return $returnr;
- }
-
- //下载
- function DownLoadFile($file,$filepath,$ecms=0){
- if(empty($file))
- {
- printerror("FileNotExist","history.go(-1)");
- }
- if(!file_exists($filepath))
- {
- printerror("FileNotExist","");
- }
- $filesize=@filesize($filepath);
- //下载
- Header("Content-type: application/octet-stream");
- Header("Accept-Ranges: bytes");
- Header("Accept-Length: ".$filesize);
- Header("Content-Disposition: attachment; filename=".$file);
- echo ReadFiletext($filepath);
- if($ecms==1)
- {
- DelFiletext($filepath);
- }
- }
-
- //取得缓存文件内容
- function GetFcfiletext($file){
- $str1="document.write(\"";
- $str2="\");";
- $text=ReadFiletext($file);
- $text=stripSlashes(str_replace($str2,"",str_replace($str1,"",$text)));
- return $text;
- }
-
- //验证模板组是否存在
- function CheckTempGroup($gid){
- global $empire,$dbtbpre;
- if(empty($gid))
- {
- $gid=GetDoTempGid();
- }
- $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid='$gid'");
- if(empty($r['gid']))
- {
- printerror("ErrorUrl","");
- }
- return $r['gname'];
- }
-
- //附加隐藏表单项
- function ReturnFormHidden($vname,$value){
- $value=htmlspecialchars(ClearAddsData($value));
- return "<input type=hidden name=\"".$vname."\" value=\"".$value."\">";
- }
-
- //-------------- 信息处理区 ----------------------
-
- //替换关键字
- function ReplaceKey($newstext){
- global $empire,$dbtbpre,$public_r;
- if(empty($newstext))
- {return $newstext;}
- $sql=$empire->query("select keyname,keyurl from {$dbtbpre}enewskey");
- while($r=$empire->fetch($sql))
- {
- $newstext=empty($public_r[repkeynum])?str_replace($r[keyname],'<a href='.$r[keyurl].' target=_blank class=infotextkey>'.$r[keyname].'</a>',$newstext):preg_replace('/'.$r[keyname].'/','<a href='.$r[keyurl].' target=_blank class=infotextkey>'.$r[keyname].'</a>',$newstext,$public_r[repkeynum]);
- }
- return $newstext;
- }
-
- //替换禁用字符
- function ReplaceWord($newstext){
- global $empire,$dbtbpre;
- if(empty($newstext))
- {return $newstext;}
- $sql=$empire->query("select newword,oldword from {$dbtbpre}enewswords");
- while($r=$empire->fetch($sql))
- {
- $newstext=str_replace($r[oldword],$r[newword],$newstext);
- }
- return $newstext;
- }
-
- //编辑信息时替换关键字和过滤字符
- function DoReplaceKeyAndWord($newstext,$dokey){
- global $public_r;
- $docheckrep=ReturnCheckDoRepStr();//返回替换验证字符
- if($public_r['dorepword']==1&&$docheckrep[3])//过滤字符
- {
- $newstext=ReplaceWord($newstext);
- }
- if($public_r['dorepkey']==1&&$docheckrep[4]&&!empty($dokey))//内容关键字
- {
- $newstext=ReplaceKey($newstext);
- }
- return $newstext;
- }
-
- //重命名列表文件
- function RenameListfile($classid,$lencord,$num,$type,$newtype,$classpath){
- $page=ceil($num/$lencord);
- for($j=1;$j<=$page;$j++)
- {
- if($j==1)
- {
- $listfile=ECMS_PATH.$classpath."/index";
- }
- else
- {
- $listfile=ECMS_PATH.$classpath."/index_".$j;
- }
- @rename($listfile.$type,$listfile.$newtype);
- }
- }
-
- //组合标题属性
- function TitleFont($titlefont,$titlecolor=''){
- $add=$titlecolor.',';
- if($titlecolor=='no')
- {
- $add='';
- }
- if($titlefont[b])//粗体
- {$add.='b|';}
- if($titlefont[i])//斜体
- {$add.='i|';}
- if($titlefont[s])//删除线
- {$add.='s|';}
- if($add==',')
- {
- $add='';
- }
- return $add;
- }
-
- //组合专题ID
- function ZtId($ztid){
- for($i=0;$i<count($ztid);$i++)
- {
- $myztid.=intval($ztid[$i]).'|';
- }
- if($myztid)
- {
- $myztid='|'.$myztid;
- }
- return $myztid;
- }
-
- //信息送审
- function InfoInsertToWorkflow($id,$classid,$wfid,$userid,$username){
- global $empire,$dbtbpre,$class_r;
- $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfid' order by tno limit 1");
- //状态更新
- $empire->query("insert into {$dbtbpre}enewswfinfo(id,classid,wfid,tid,groupid,userclass,username,checknum,tstatus,checktno) values('$id','$classid','$wfid','$wfitemr[tid]','$wfitemr[groupid]','$wfitemr[userclass]','$wfitemr[username]',1,'$wfitemr[tstatus]',0);");
- //日志
- InsertWfLog($classid,$id,$wfid,0,$username,'',1,0);
- }
-
- //信息返工送审
- function InfoUpdateToWorkflow($id,$classid,$wfid,$userid,$username){
- global $empire,$dbtbpre,$class_r;
- $wfinfor=$empire->fetch1("select checknum,wfid,tid,checktno from {$dbtbpre}enewswfinfo where id='$id' and classid='$classid' limit 1");
- if($wfinfor[checktno]!='101')
- {
- return '';
- }
- if($wfinfor[tid])
- {
- $ywfitemr=$empire->fetch1("select tno from {$dbtbpre}enewsworkflowitem where tid='$wfinfor[tid]'");
- $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfinfor[wfid]' and tno>$ywfitemr[tno] order by tno limit 1");
- }
- else
- {
- $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfinfor[wfid]' order by tno limit 1");
- }
- //状态更新
- $empire->query("update {$dbtbpre}enewswfinfo set tid='$wfitemr[tid]',groupid='$wfitemr[groupid]',userclass='$wfitemr[userclass]',username='$wfitemr[username]',checknum=checknum+1,tstatus='$wfitemr[tstatus]',checktno='0' where id='$id' and classid='$classid' limit 1");
- //日志
- InsertWfLog($classid,$id,$wfinfor[wfid],0,$username,'',$wfinfor[checknum],0);
- }
-
- //写入签发日志
- function InsertWfLog($classid,$id,$wfid,$tid,$username,$checktext,$checknum,$checktype){
- global $empire,$dbtbpre,$class_r,$lur;
- $checktime=time();
- $checktext=RepPostStr($checktext);
- $empire->query("insert into {$dbtbpre}enewswfinfolog(id,classid,wfid,tid,username,checktime,checktext,checknum,checktype) values('$id','$classid','$wfid','$tid','$username','$checktime','$checktext','$checknum','$checktype');");
- }
-
- //加入TAG表
- function eInsertTags($tags,$classid,$id,$newstime){
- global $empire,$dbtbpre,$class_r;
- if(!trim($tags))
- {
- return '';
- }
- $tags=RepPostVar($tags);
- $classid=(int)$classid;
- $id=(int)$id;
- $mid=(int)$class_r[$classid][modid];
- $tr=explode(',',$tags);
- $count=count($tr);
- for($i=0;$i<$count;$i++)
- {
- $tagname=$tr[$i];
- if(empty($tagname))
- {
- continue;
- }
- $r=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tagname' limit 1");
- if($r[tagid])
- {
- $datar=$empire->fetch1("select tagid,classid,newstime from {$dbtbpre}enewstagsdata where tagid='$r[tagid]' and id='$id' and mid='$mid' limit 1");
- if($datar[tagid])
- {
- if($datar[classid]!=$classid||$datar[newstime]!=$newstime)
- {
- $empire->query("update {$dbtbpre}enewstagsdata set classid='$classid',newstime='$newstime' where tagid='$r[tagid]' and id='$id' and mid='$mid' limit 1");
- }
- }
- else
- {
- $empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$r[tagid]'");
- $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$r[tagid]','$classid','$id','$newstime','$mid');");
- }
- }
- else
- {
- $empire->query("insert into {$dbtbpre}enewstags(tagname,num,isgood,cid) values('$tagname',1,0,0);");
- $tagid=$empire->lastid();
- $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$tagid','$classid','$id','$newstime','$mid');");
- }
- }
- }
-
- //返回信息TAGS
- function eReturnInfoTags($classid,$id,$mid){
- global $empire,$dbtbpre,$class_r;
- if(!$mid||!$id)
- {
- return '';
- }
- $tags='';
- $dh='';
- $sql=$empire->query("select tagid from {$dbtbpre}enewstagsdata where id='$id' and mid='$mid' order by tagid");
- while($r=$empire->fetch($sql))
- {
- $tr=$empire->fetch1("select tagname from {$dbtbpre}enewstags where tagid='$r[tagid]'");
- $tags.=$dh.$tr[tagname];
- $dh=',';
- }
- return $tags;
- }
-
- //返回命名方式
- function ReturnInfoFilename($classid,$id,$filenameqz){
- global $class_r;
- if($class_r[$classid][filename]==1) //time命名
- {
- $filename=$class_r[$classid][filename_qz].time().$id;
- }
- elseif($class_r[$classid][filename]==2) //md5命名
- {
- $filename=$class_r[$classid][filename_qz].md5(uniqid(microtime()));
- }
- elseif($class_r[$classid][filename]==3) //目录
- {
- $filename=$class_r[$classid][filename_qz].$id.'/index';
- }
- else //id
- {
- $filename=$class_r[$classid][filename_qz].$id;
- }
- $filename=$filenameqz.$filename;
- return $filename;
- }
-
- //更新相应的附件
- function UpdateTheFile($id,$checkpass){
- global $empire,$dbtbpre;
- if(empty($id)||empty($checkpass))
- {
- return "";
- }
- $id=(int)$id;
- $checkpass=(int)$checkpass;
- $sql=$empire->query("update {$dbtbpre}enewsfile set id=$id,cjid=0 where cjid=$checkpass");
- }
-
- //修改时更新附件
- function UpdateTheFileEdit($classid,$id){
- global $empire,$dbtbpre;
- $sql=$empire->query("update {$dbtbpre}enewsfile set cjid=0 where id='$id' and classid='$classid'");
- }
-
- //更新ispic标识
- function UpdateTheIspic($classid,$id){
- global $empire,$dbtbpre,$class_r;
- $r=$empire->fetch1("select titlepic,ispic from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' limit 1");
- $ispic=$r['titlepic']?1:0;
- if($ispic<>$r['ispic'])
- {
- $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]." set ispic='$ispic' where id='$id'");
- }
- }
-
- //取第几张图片
- function GetFpicToTpic($classid,$id,$num=1,$getfirsttitlespic=0,$swidth=0,$sheight=0){
- global $empire,$dbtbpre,$public_r,$class_r;
- $num=$num-1;
- $picr=$empire->fetch1("select fileid,filename,path,id,classid,no,fpath from {$dbtbpre}enewsfile where id=$id and classid=$classid and type=1 order by fileid limit $num,1");
- $firsttitlepic="";
- if($picr['fileid'])
- {
- $rpath=$picr['path']?$picr['path'].'/':$picr['path'];
- $fspath=ReturnFileSavePath($picr[classid],$picr[fpath]);
- if($getfirsttitlespic==1&&$swidth&&$sheight)//缩略图
- {
- $path="../../".$fspath['filepath'].$rpath;
- $yname=$path.$picr[filename];
- $filetype=GetFiletype($picr[filename]);
- $insertfile=substr($picr[filename],0,strlen($picr[filename])-strlen($filetype)).time();
- $name=$path."small".$insertfile;
- $sfiler=GetMySmallImg($classid,$picr[no],$insertfile,$picr[path],$yname,$swidth,$sheight,$name,$add['filepass'],$add['filepass'],$userid,$username);
- $firsttitlepic=$fspath['fileurl'].$rpath."small".$insertfile.$sfiler['filetype'];
- }
- else
- {
- $firsttitlepic=$fspath['fileurl'].$rpath.$picr[filename];
- }
- }
- return $firsttitlepic;
- }
-
- //更新替换图片下一页链接内容
- function UpdateImgNexturl($classid,$id){
- global $empire,$dbtbpre,$class_r,$public_r,$emod_r;
- $mid=$class_r[$classid][modid];
- $tbname=$class_r[$classid][tbname];
- $pf=$emod_r[$mid]['pagef'];
- $stf=$emod_r[$mid]['savetxtf'];
- if(!$pf)
- {
- return '';
- }
- //分页字段
- $tbdataf=strstr($emod_r[$mid]['tbdataf'],','.$pf.',')?1:0;
- if($tbdataf)
- {
- $r=$empire->fetch1("select id,classid,titleurl,groupid,newspath,filename,stb from {$dbtbpre}ecms_".$tbname." where id='$id'");
- $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$id'");
- $r[$pf]=$finfor[$pf];
- }
- else
- {
- $r=$empire->fetch1("select id,classid,titleurl,groupid,newspath,filename,".$pf." from {$dbtbpre}ecms_".$tbname." where id='$id'");
- }
- //存文本
- if($stf&&$stf==$pf)
- {
- $newstextfile=$r[$stf];
- $r[$stf]=GetTxtFieldText($r[$stf]);
- }
- if(!$r[$pf])
- {
- return '';
- }
- $newstext=RepNewstextImgLink($r[$pf],$r);
- if(empty($newstext))
- {
- return '';
- }
- //存文本
- if($stf&&$stf==$pf)
- {
- EditTxtFieldText($newstextfile,$newstext);
- return '';
- }
- if($tbdataf)
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." set ".$pf."='$newstext' where id='$id'");
- }
- else
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$pf."='$newstext' where id='$id'");
- }
- }
-
- //给图片加下一页链接
- function RepNewstextImgLink($newstext,$add){
- global $public_r;
- $expage='[!--empirenews.page--]';//分页符
- if(!stristr($newstext,$expage)||!stristr($newstext,'<img '))
- {
- return '';
- }
- $newstext=stripSlashes($newstext);
- $repurl='[!--empirecms.rep.nextpageurl--]';
- $newstext=DoRepImgLink($newstext,$repurl);
- $nr=explode($expage,$newstext);
- $count=count($nr);
- //页面地址
- $urlqzr=ReturnInfoPageQz($add);
- $lastpageurl=$public_r['newsurl'].'e/public/ClassUrl/?classid='.$add['classid']; //最后一页链接地址
- $new_newstext='';
- $addexpage='';
- for($i=0;$i<$count;$i++)
- {
- $thispagetext=$nr[$i];
- if(stristr($thispagetext,'<img '))
- {
- if($i==$count-1)
- {
- $newurl=$lastpageurl;
- }
- else
- {
- //下一页链接
- if($urlqzr['nametype']==1)
- {
- $newurl=$urlqzr['titleurl'].'&page='.($i+1);
- }
- else
- {
- $newurl=$urlqzr['titleurl'].'_'.($i+2).$urlqzr['filetype'];
- }
- }
- $thispagetext=str_replace($repurl,$newurl,$thispagetext);
- }
- $new_newstext.=$addexpage.$thispagetext;
- $addexpage=$expage;
- }
- return addslashes($new_newstext);
- }
-
- //返回相关链接信息ID
- function GetKeyid($keyboard,$classid,$id,$link_num){
- global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$eyh_r,$etable_r;
- if($keyboard)
- {
- if(empty($link_num))
- {
- return '';
- }
- $keyboard=RepDyh($keyboard);
- $r=explode(",",$keyboard);
- for($i=0;$i<count($r);$i++)
- {
- if($i==0)
- {
- $or="";
- }
- else
- {
- $or=" or ";
- }
- $repadd.=$or."[!--f--!]"." like '%".$r[$i]."%'";
- }
- //搜索范围
- if($public_r['newslink']==1)
- {
- $add='('.str_replace('[!--f--!]','keyboard',$repadd).')';
- }
- elseif($public_r['newslink']==2)
- {
- $add='('.str_replace('[!--f--!]','keyboard',$repadd).' or '.str_replace('[!--f--!]','title',$repadd).')';
- }
- else
- {
- $add='('.str_replace('[!--f--!]','title',$repadd).')';
- }
- //模型
- if(!empty($class_r[$classid][modid]))
- {
- $mr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='".$class_r[$classid][modid]."'");
- $where=" and (".ReturnClass($mr[sonclass]).")";
- }
- //优化
- $tbname=$class_r[$classid][tbname];
- $yhvar='otherlink';
- $yhid=$etable_r[$tbname][yhid];
- $yhadd='';
- if($yhid)
- {
- $yhadd=ReturnYhSql($yhid,$yhvar);
- }
- //ID声名
- $keyid="";
- $first=0;
- $key_sql=$empire->query("select id from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd.$add.$where." and id<>$id and checked=1 order by newstime desc limit $link_num");
- while($link_r=$empire->fetch($key_sql))
- {
- if(empty($first))
- {
- $dh="";
- $first=1;
- }
- else
- {
- $dh=",";
- }
- $keyid.=$dh.$link_r[id];
- }
- }
- else
- {
- $keyid="";
- }
- return $keyid;
- }
-
- //删除信息附件
- function DelNewsTheFile($id,$classid,$delpl=0){
- global $empire,$dbtbpre;
- if(empty($id))
- {
- return "";
- }
- $i=0;
- $sql=$empire->query("select classid,filename,path,fpath from {$dbtbpre}enewsfile where id='$id' and classid='$classid'");
- while($r=$empire->fetch($sql))
- {
- $i=1;
- DoDelFile($r);
- }
- if($i)
- {
- $empire->query("delete from {$dbtbpre}enewsfile where id='$id' and classid='$classid'");
- }
- //删除评论
- if($delpl==0)
- {
- $empire->query("delete from {$dbtbpre}enewspl where id='$id' and classid='$classid'");
- $tbr=$empire->fetch1("select pldatatbs from {$dbtbpre}enewspublic limit 1");
- if($tbr['pldatatbs'])
- {
- $dtbr=explode(',',$tbr['pldatatbs']);
- $count=count($dtbr)-1;
- for($i=1;$i<$count;$i++)
- {
- $empire->query("delete from {$dbtbpre}enewspl_data_".$dtbr[$i]." where id='$id' and classid='$classid'");
- }
- }
- }
- }
-
- //删除信息文件
- function DelNewsFile($filename,$newspath,$classid,$newstext,$groupid=0){
- global $class_r,$addgethtmlpath;
- //文件类型
- if($groupid)
- {
- $filetype=".php";
- }
- else
- {
- $filetype=$class_r[$classid][filetype];
- }
- //是否有日期目录
- if(empty($newspath))
- {
- $mynewspath="";
- }
- else
- {
- $mynewspath=$newspath."/";
- }
- $iclasspath=ReturnSaveInfoPath($classid,$id);
- $r=explode("[!--empirenews.page--]",$newstext);
- for($i=1;$i<=count($r);$i++)
- {
- if(strstr($filename,'/'))
- {
- DelPath(ECMS_PATH.$iclasspath.$mynewspath.ReturnInfoSPath($filename));
- }
- else
- {
- if($i==1)
- {
- $file=ECMS_PATH.$iclasspath.$mynewspath.$filename.$filetype;
- }
- else
- {
- $file=ECMS_PATH.$iclasspath.$mynewspath.$filename."_".$i.$filetype;
- }
- DelFiletext($file);
- }
- }
- }
-
- //替换图片标签
- function RepImg($text,$copyflash){
- global $saveurlimgclearurl;
- $exp1="[--copyimg--]";
- $exp2="[/--copyimg--]";
- //去掉图片链接
- if($saveurlimgclearurl==1)
- {
- $zz2="/\<(a|A) (.*?)(href|Href)=('|\"|\\\\\"|)(.+?)><(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP|.jpeg|.JPEG)(.*?)><\/(a|A)>/is";
- $text=preg_replace($zz2,"<\\6 \\7\\8=\\9\\10\\11\\12>",$text);
- }
- $zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP|.jpeg|.JPEG)(.*?)>/is";
- $text=preg_replace($zz1,"<\\1 \\2\\3=\\4".$exp1."\\5\\6".$exp2."\\7>",$text);
- return $text;
- }
-
- //替换flash标签
- function RepFlash($text,$copyflash){
- $exp1="[--copyimg--]";
- $exp2="[/--copyimg--]";
- //去掉flash多余链接
- $zz2="/\<(embed|EMBED) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>(.*?)<\/(embed|EMBED)>/is";
- $text=preg_replace($zz2,"",$text);
- $zz3="/\<(param|PARAM) (name|NAME)=\"(Src|src|SRC)\" (.*?)(value|VALUE)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>/is";
- $text=preg_replace($zz3,"",$text);
-
- $zz1="/\<(param|PARAM) (.*?)(name|NAME)=\"(movie|MOVIE)\" (.*?)(value|VALUE)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>/is";
- $text=preg_replace($zz1,"<\\1 \\2\\3=\"\\4\" \\5\\6=\\7".$exp1."\\8\\9".$exp2."\\10>",$text);
- return $text;
- }
-
- //替换图片链接
- function DoRepImgLink($text,$newurl){
- //去掉图片链接
- $zz2="/\<(a|A) (.*?)(href|Href)=('|\"|\\\\\"|)(.+?)><(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.*?)><\/(a|A)>/is";
- $text=preg_replace($zz2,"<\\6 \\7\\8=\\9\\10>",$text);
- //新链接
- $zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.*?)>/is";
- $text=preg_replace($zz1,"<a href=\"".$newurl."\"><\\1 \\2\\3=\\4\\5></a>",$text);
- return $text;
- }
-
- //截取图片
- function CopyImg($text,$copyimg,$copyflash,$classid,$qz,$username,$theid,$cjid,$mark){
- global $empire,$public_r,$cjnewsurl,$navtheid,$dbtbpre;
- if(empty($text))
- {return "";}
- if($copyimg)
- {
- $text=RepImg($text,$copyflash);
- }
- if($copyflash)
- {$text=RepFlash($text,$copyflash);}
- $exp1="[--copyimg--]";
- $exp2="[/--copyimg--]";
- $r=explode($exp1,$text);
- for($i=1;$i<count($r);$i++)
- {
- $r1=explode($exp2,$r[$i]);
- if(strstr($r1[0],"http://")||strstr($r1[0],"https://"))
- {
- $dourl=$r1[0];
- }
- else
- {
- //是否是本地址
- if(!strstr($r1[0],"/")&&$cjnewsurl)
- {
- $fileqz_r=GetPageurlQz($cjnewsurl);
- $fileqz=$fileqz_r['selfqz'];
- $dourl=$fileqz.$r1[0];
- }
- else
- {
- $dourl=$qz.$r1[0];
- }
- }
- $return_r=DoTranUrl($dourl,$classid);
- $text=str_replace($exp1.$r1[0].$exp2,$return_r[url],$text);
- if($return_r[tran])
- {
- //记录数据库
- $filetime=date("Y-m-d H:i:s");
- //变量处理
- $return_r[filesize]=(int)$return_r[filesize];
- $classid=(int)$classid;
- $return_r[type]=(int)$return_r[type];
- $theid=(int)$theid;
- $cjid=(int)$cjid;
- $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$return_r[filename]',$return_r[filesize],'$username','$return_r[filepath]','$filetime',$classid,'[URL]".$return_r[filename]."',$return_r[type],$theid,$cjid,0,'$public_r[fpath]');");
- //加水
- if($mark&&$return_r[type]==1)
- {
- GetMyMarkImg($return_r['yname']);
- }
- }
- }
- return $text;
- }
-
- //生成缩略图
- function GetMySmallImg($classid,$no,$insertfile,$filepath,$yname,$maxwidth,$maxheight,$name,$id,$cjid,$userid,$username){
- global $empire,$dbtbpre,$public_r,$efileftp_fr;
- if(empty($yname))
- {
- return "";
- }
- $no="[s]".$no;
- $filer=ResizeImage($yname,$name,$maxwidth,$maxheight,$public_r['spickill']);
- if($filer['file'])
- {
- $insertfile="small".$insertfile.$filer['filetype'];
- $filesize=@filesize($filer['file']);
- //写入数据库
- $filetime=date("Y-m-d H:i:s");
- //变量处理
- $filesize=(int)$filesize;
- $classid=(int)$classid;
- $id=(int)$id;
- $cjid=(int)$cjid;
- $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$insertfile',$filesize,'$username','$filepath','$filetime',$classid,'$no',1,$id,$cjid,0,'$public_r[fpath]');");
- //FileServer
- if($public_r['openfileserver'])
- {
- $efileftp_fr[]=$name.$filer['filetype'];
- }
- }
- return $filer;
- }
-
- //图片加水印
- function GetMyMarkImg($groundImage){
- global $public_r;
- if(empty($groundImage))
- {
- return "";
- }
- imageWaterMark($groundImage,$public_r['markpos'],$public_r['markimg'],$public_r['marktext'],$public_r['markfontsize'],$public_r['markfontcolor'],$public_r['markfont'],$public_r['markpct'],$public_r['jpgquality']);
- }
-
- //投票组合
- function ReturnVote($votename,$votenum,$delvid,$vid,$enews=0){
- global $empire,$dbtbpre;
- $f_exp="::::::";
- $r_exp="\r\n";
- $returnstr="";
- //增加投票
- if(empty($enews))
- {
- for($i=0;$i<count($votename);$i++)
- {
- //替换非法字符
- $name=str_replace($f_exp,"",$votename[$i]);
- $name=str_replace($r_exp,"",$votename[$i]);
- $num=str_replace($f_exp,"",$votenum[$i]);
- $num=str_replace($r_exp,"",$votenum[$i]);
- if($name)
- {
- if(empty($num))
- {$num=0;}
- $returnstr.=$name.$f_exp.$num.$r_exp;
- }
- }
- }
- //修改投票
- else
- {
- for($i=0;$i<count($votename);$i++)
- {
- //删除下载地址
- $del=0;
- for($j=0;$j<count($delvid);$j++)
- {
- if($delvid[$j]==$vid[$i])
- {$del=1;}
- }
- if($del)
- {continue;}
- //替换非法字符
- $name=str_replace($f_exp,"",$votename[$i]);
- $name=str_replace($r_exp,"",$votename[$i]);
- $num=str_replace($f_exp,"",$votenum[$i]);
- $num=str_replace($r_exp,"",$votenum[$i]);
- if($name)
- {
- if(empty($num))
- {$num=0;}
- $returnstr.=$name.$f_exp.$num.$r_exp;
- }
- }
- }
- /*
- if(empty($returnstr))
- {printerror("EmptyVotenum","history.go(-1)");}
- */
- //去掉最后的字符
- $returnstr=substr($returnstr,0,strlen($returnstr)-2);
- return $returnstr;
- }
-
- //显示无限级栏目[增加栏目时]
- function ShowClass_AddClass($adminclass,$obclassid,$bclassid,$exp,$modid,$enews=0,$addminfocid=''){
- global $empire,$dbtbpre;
- if(empty($bclassid))
- {
- $bclassid=0;
- $exp="|-";
- if($enews==2)
- {
- $modr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='$modid'");
- $addminfocid=$modr['sonclass'];
- }
- }
- else
- {$exp=" ".$exp;}
- $sql=$empire->query("select classid,classname,bclassid,islast,openadd,modid,sonclass from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid");
- $returnstr="";
- while($r=$empire->fetch($sql))
- {
- //投稿显示
- if($enews==2)
- {
- if($r[openadd])
- {
- continue;
- }
- if(CheckHaveInClassid($r,$addminfocid)==0)
- {
- continue;
- }
- }
- if($r[islast])
- {
- if(empty($enews)||$enews==2||$enews==3||$enews==4)
- {
- $color=" style='background:#99C4E3'";
- }
- //隐藏不能投稿的栏目
- if($enews==2)
- {
- if($modid)
- {
- if($r[modid]<>$modid)
- {continue;}
- }
- }
- //模型
- if($enews==4)
- {
- if($r[modid]<>$modid)
- {continue;}
- }
- }
- else
- {$color="";}
- if($r[classid]==$obclassid)
- {$select=" selected";}
- else
- {$select="";}
- //-----------增加用户时
- if($enews==3)
- {
- $c=explode("|".$r[classid]."|",$adminclass);
- if(count($c)>1)
- {$select=" selected";}
- else
- {$select="";}
- }
- $returnstr.="<option value=".$r[classid].$select.$color.">".$exp.$r[classname]."</option>";
- if(empty($r[islast]))
- {
- $returnstr.=ShowClass_AddClass($adminclass,$obclassid,$r[classid],$exp,$modid,$enews,$addminfocid);
- }
- }
- return $returnstr;
- }
-
- //设置伸缩
- function SetDisplayClass($open){
- $time=time()+365*24*3600;
- $set=esetcookie("displayclass",$open,$time,1);
- echo"<script>self.location.href='ListClass.php';</script>";
- exit();
- }
-
- //删除目录函数
- function DelPath($DelPath){
- if($DelPath=="../../"||$DelPath=="../../d/file/")
- {return "";}
- $wm_chief=new del_path();
- $wm_chief_ok=$wm_chief->wm_chief_delpath($DelPath);
- return $wm_chief_ok;
- }
-
- //复制目录
- function CopyPath($oldpath,$newpath){
- $wm_chief=new copy_path();
- $wm_chief_ok=$wm_chief->wm_chief_copypath($oldpath,$newpath);
- return $wm_chief_ok;
- }
-
- //移动目录
- function MovePath($oldpath,$newpath){
- //复制
- CopyPath($oldpath,$newpath);
- //删除
- DelPath($oldpath);
- }
-
- //替换字符
- function RepInfoZZ($text,$exp,$enews=0){
- $text=str_replace(".","\\.",$text);
- $text=str_replace("(","\\(",$text);
- $text=str_replace(")","\\)",$text);
- $text=str_replace("?","\\?",$text);
- $text=str_replace("*","(.*?)",$text);
- $text=str_replace("[!--".$exp."--]","(.*?)",$text);
- //$text=str_replace("\\","\\\\",$text);
- //$text=str_replace("\"","\"",$text);
- $text=str_replace("/","\\/",$text);
- $text=str_replace("-","\\-",$text);
- $text=str_replace("|","\\|",$text);
- $text=str_replace("+","\\+",$text);
- $text=str_replace("^","\\^",$text);
- $text=str_replace("{","\\{",$text);
- $text=str_replace("}","\\}",$text);
- $text=str_replace("[","\\[",$text);
- $text=str_replace("]","\\]",$text);
- $text=str_replace("\$","\\\$",$text);
- $text="/".$text."/is";
- return $text;
- }
-
- //取得地址前缀
- function GetPageurlQz($self){
- $sr=explode("/",$self);
- $count=count($sr)-1;
- $sfile=$sr[$count];
- $r[selfqz]=substr($self,0,strlen($self)-strlen($sfile));
- //取得域名
- $sr1=explode("http://",$self);
- $sr2=explode("/",$sr1[1]);
- $r[domain]="http://".$sr2[0];
- return $r;
- }
-
- //去掉单引号
- function RepDyh($text){
- //$text=str_replace("\'","\\\'",stripSlashes($text));
- $text=addslashes(stripSlashes($text));
- return $text;
- }
-
- //补零
- function AddNumZero($no,$endno){
- $len=strlen($endno);
- $forlen=$len-strlen($no);
- for($i=1;$i<=$forlen;$i++)
- {
- $no="0".$no;
- }
- return $no;
- }
-
- //自动分页
- function AutoDoPage($mybody,$spsize){
- $sptag="[!--empirenews.page--]";
- if(strlen($mybody)<$spsize) return $mybody;
- $bds = explode('<',$mybody);
- $npageBody = "";
- $istable = 0;
- $mybody = "";
- foreach($bds as $i=>$k)
- {
- if($i==0){ $npageBody .= $bds[$i]; continue;}
- $bds[$i] = "<".$bds[$i];
- if(strlen($bds[$i])>6){
- $tname = substr($bds[$i],1,5);
- if(strtolower($tname)=='table') $istable++;
- else if(strtolower($tname)=='/tabl') $istable--;
- if($istable>0){ $npageBody .= $bds[$i]; continue; }
- else $npageBody .= $bds[$i];
- }else{
- $npageBody .= $bds[$i];
- }
- if(strlen($npageBody)>$spsize){
- $mybody .= $npageBody.$sptag;
- $npageBody = "";
- }
- }
- if($npageBody!="") $mybody .= $npageBody;
- return $mybody;
- }
-
-
-
- //-------------- 模板区 ----------------------
-
- //取得模型ID
- function GetListtempMid($tempid){
- global $empire;
- $r=$empire->fetch1("select modid from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");
- return $r[modid];
- }
-
- //替换模板JS地址
- function RepTemplateJsUrl($temp,$classid,$enews=0){
- global $public_r,$class_r,$class_zr;
- $allpath='[!--news.url--]d/js/js/';
- $temp=str_replace("[!--hotnews--]","<script src='".$allpath."hotnews.js'></script>",$temp);
- $temp=str_replace("[!--newnews--]","<script src='".$allpath."newnews.js'></script>",$temp);
- $temp=str_replace("[!--goodnews--]","<script src='".$allpath."goodnews.js'></script>",$temp);
- $temp=str_replace("[!--hotplnews--]","<script src='".$allpath."hotplnews.js'></script>",$temp);
- $temp=str_replace("[!--firstnews--]","<script src='".$allpath."firstnews.js'></script>",$temp);
- if(!empty($classid))
- {
- $path=$enews==1?'[!--news.url--]d/js/class/zt[!--self.classid--]_':'[!--news.url--]d/js/class/class[!--self.classid--]_';
- $temp=str_replace("[!--self.hotnews--]","<script src='".$path."hotnews.js'></script>",$temp);
- $temp=str_replace("[!--self.newnews--]","<script src='".$path."newnews.js'></script>",$temp);
- $temp=str_replace("[!--self.goodnews--]","<script src='".$path."goodnews.js'></script>",$temp);
- $temp=str_replace("[!--self.hotplnews--]","<script src='".$path."hotplnews.js'></script>",$temp);
- $temp=str_replace("[!--self.firstnews--]","<script src='".$path."firstnews.js'></script>",$temp);
- }
- return $temp;
- }
-
-
-
-
- //-------------- 生成区 ----------------------
-
- //取得列表模板
- function GetListTemp($tempid){
- global $empire;
- $r=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");
- $r[temptext]=InfoNewsBq('list'.$tempid,$r[temptext]);
- return $r;
- }
-
- //取得封面模板
- function GetClassTemp($tempid){
- global $empire;
- $r=$empire->fetch1("select temptext from ".GetTemptb("enewsclasstemp")." where tempid='$tempid'");
- return $r['temptext'];
- }
-
- //取得栏目页面内容
- function GetClassText($classid){
- global $empire,$dbtbpre;
- $r=$empire->fetch1("select classtext from {$dbtbpre}enewsclassadd where classid='$classid'");
- return $r['classtext'];
- }
-
- //取得专题页面内容
- function GetZtText($ztid){
- global $empire,$dbtbpre;
- $r=$empire->fetch1("select classtext from {$dbtbpre}enewsztadd where ztid='$ztid'");
- return $r['classtext'];
- }
-
- //取得首页模板
- function GetIndextemp(){
- global $empire,$dbtbpre,$public_r;
- if($public_r['indexpageid'])
- {
- $r=$empire->fetch1("select temptext from {$dbtbpre}enewsindexpage where tempid='".$public_r['indexpageid']."'");
- return $r['temptext'];
- }
- $r=$empire->fetch1("select indextemp from ".GetTemptb("enewspubtemp")." limit 1");
- return $r['indextemp'];
- }
-
- //取得内容模板
- function GetNewsTemp($newstempid){
- global $empire,$public_r;
- $r=$empire->fetch1("select temptext,showdate from ".GetTemptb("enewsnewstemp")." where tempid='$newstempid'");
- $r[temptext]=InfoNewsBq('news'.$newstempid,$r[temptext]);
- if($public_r[opennotcj])//启用反采集
- {
- $r[temptext]=ReturnNotcj($r[temptext]);
- }
- return $r;
- }
-
- //取得js模板
- function GetTheJstemp($tempid){
- global $empire;
- $r=$empire->fetch1("select temptext,showdate,modid,subnews,subtitle from ".GetTemptb("enewsjstemp")." where tempid='$tempid'");
- return $r;
- }
-
- //替换全局模板变量
- function ReplaceTempvar($temp){
- global $empire;
- if(empty($temp))
- {return $temp;}
- $sql=$empire->query("select myvar,varvalue from ".GetTemptb("enewstempvar")." where isclose=0 order by myorder desc,varid");
- while($r=$empire->fetch($sql))
- {
- $temp=str_replace('[!--temp.'.$r[myvar].'--]',$r[varvalue],$temp);;
- }
- return $temp;
- }
-
- //栏目页替换公共标记
- function Class_ReplaceSvars($temp,$url,$classid,$title,$key,$des,$classimg,$add,$enews=0){
- global $public_r,$class_r,$class_zr;
- $temp=str_replace('[!--class.menu--]',$public_r['classnavs'],$temp);//栏目导航
- $temp=str_replace('[!--pagetitle--]',$title,$temp);
- $temp=str_replace('[!--pagekey--]',$key,$temp);
- $temp=str_replace('[!--pagedes--]',$des,$temp);
- $temp=str_replace('[!--class.intro--]',$des,$temp);
- $temp=str_replace('[!--class.keywords--]',$key,$temp);
- $temp=str_replace('[!--class.classimg--]',$classimg,$temp);
- $temp=str_replace('[!--self.classid--]',$classid,$temp);
- if($enews==0)//栏目
- {
- $temp=str_replace('[!--class.name--]',$class_r[$classid]['classname'],$temp);
- $bclassid=$class_r[$classid]['bclassid'];
- $temp=str_replace('[!--bclass.id--]',$bclassid,$temp);
- $temp=str_replace('[!--bclass.name--]',$class_r[$bclassid]['classname'],$temp);
- $path=$public_r['newsurl'].'d/js/class/class'.$classid.'_';
- }
- else//专题
- {
- $temp=str_replace('[!--class.name--]',$class_zr[$classid]['ztname'],$temp);
- $path=$public_r['newsurl'].'d/js/class/zt'.$classid.'_';
- }
- $allpath=$public_r[newsurl].'d/js/js/';
- //热门文章
- $temp=str_replace("[!--hotnews--]","<script src='".$allpath."hotnews.js'></script>",$temp);
- $temp=str_replace("[!--self.hotnews--]","<script src='".$path."hotnews.js'></script>",$temp);
- //点击排行
- $temp=str_replace("[!--newnews--]","<script src='".$allpath."newnews.js'></script>",$temp);
- $temp=str_replace("[!--self.newnews--]","<script src='".$path."newnews.js'></script>",$temp);
- //推荐
- $temp=str_replace("[!--goodnews--]","<script src='".$allpath."goodnews.js'></script>",$temp);
- $temp=str_replace("[!--self.goodnews--]","<script src='".$path."goodnews.js'></script>",$temp);
- //评论排行
- $temp=str_replace("[!--hotplnews--]","<script src='".$allpath."hotplnews.js'></script>",$temp);
- $temp=str_replace("[!--self.hotplnews--]","<script src='".$path."hotplnews.js'></script>",$temp);
- //头条排行
- $temp=str_replace("[!--firstnews--]","<script src='".$allpath."firstnews.js'></script>",$temp);
- $temp=str_replace("[!--self.firstnews--]","<script src='".$path."firstnews.js'></script>",$temp);
- $temp=str_replace('[!--news.url--]',$public_r['newsurl'],$temp);
- return $temp;
- }
-
- //内容页替换公共标记
- function Info_ReplaceSvars($temp,$url,$classid,$title,$key,$des){
- global $public_r,$class_r;
- $temp=str_replace('[!--class.menu--]',$public_r['classnavs'],$temp);//栏目导航
- $temp=str_replace('[!--newsnav--]',$url,$temp);//位置导航
- $temp=str_replace('[!--pagetitle--]',$title,$temp);
- $temp=str_replace('[!--pagekey--]',$key,$temp);
- $temp=str_replace('[!--pagedes--]',$des,$temp);
- $temp=str_replace('[!--self.classid--]',$classid,$temp);
- $bclassid=$class_r[$classid]['bclassid'];
- $temp=str_replace('[!--bclass.id--]',$bclassid,$temp);
- $temp=str_replace('[!--bclass.name--]',$class_r[$bclassid]['classname'],$temp);
- $temp=str_replace('[!--news.url--]',$public_r['newsurl'],$temp);
- return $temp;
- }
-
- //替换搜索模板文件
- function ReplaceStemp($temptext,$class,$url,$classid,$title,$key,$des,$repvar=1){
- global $public_r;
- if($repvar==1)//全局模板变量
- {
- $temptext=ReplaceTempvar($temptext);
- }
- $temptext=str_replace('[!--class.menu--]',$public_r['classnavs'],$temptext);//栏目导航
- $temptext=str_replace("[!--class--]",$class,$temptext);
- $temptext=str_replace('[!--pagetitle--]',$title,$temptext);
- $temptext=str_replace('[!--pagekey--]',$key,$temptext);
- $temptext=str_replace('[!--pagedes--]',$des,$temptext);
- $temptext=str_replace('[!--self.classid--]',$classid,$temptext);
- //热门文章
- $temptext=str_replace("[!--hotnews--]","<script src='".$public_r[newsurl]."d/js/js/hotnews.js'></script>",$temptext);
- //点击排行
- $temptext=str_replace("[!--newnews--]","<script src='".$public_r[newsurl]."d/js/js/newnews.js'></script>",$temptext);
- //推荐
- $temptext=str_replace("[!--goodnews--]","<script src='".$public_r[newsurl]."d/js/js/goodnews.js'></script>",$temptext);
- //评论排行
- $temptext=str_replace("[!--hotplnews--]","<script src='".$public_r[newsurl]."d/js/js/hotplnews.js'></script>",$temptext);
- //导航条
- $temptext=str_replace("[!--url--]",$url,$temptext);
- $temptext=str_replace('[!--newsnav--]',$url,$temptext);//位置导航
- $temptext=str_replace("[!--news.url--]",$public_r[newsurl],$temptext);
- $temptext=str_replace("[!--newsurl--]",$public_r[newsurl],$temptext);
- return $temptext;
- }
-
- //栏目页验证
- function AddCheckClassLevel($classid,$groupid,$classpath){
- $classpath=ReturnSaveClassPath($classid);
- $pr=explode('/',$classpath);
- $pcount=count($pr);
- for($i=0;$i<$pcount;$i++)
- {
- $include.='../';
- }
- $include1=$include;
- $include.='e/class/CheckClassLevel.php';
- $addlevel="<?php
- define('empirecms','wm_chief');
- \$check_groupid=\"".$groupid."\";
- \$check_classid=".$classid.";
- \$check_path=\"".$include1."\";
- require(\"".$include."\");
- ?>";
- return $addlevel;
- }
-
- //生成栏目绑定信息页面
- function ReClassBdInfo($classid){
- global $empire,$dbtbpre;
- $cr=$empire->fetch1("select classid,bdinfoid from {$dbtbpre}enewsclass where classid='$classid'");
- if(!$cr['classid']||!$cr['bdinfoid'])
- {
- return '';
- }
- $infor=explode(',',$cr['bdinfoid']);
- $infofile=GetInfoFilename(intval($infor[0]),intval($infor[1]));
- $classtext='';
- if($infofile)
- {
- $classtext=ReadFiletext($infofile);
- }
- $classfile=ECMS_PATH.ReturnSaveClassPath($classid,1);
- WriteFiletext_n($classfile,$classtext);
- }
-
- //标签替换
- function NewsBq($classid,$indextext,$enews=0,$doing=0){
- global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
- $indextext=stripSlashes($indextext);
- $indextext=ReplaceTempvar($indextext);//替换全局模板变量
- $classlevel='';
- if($enews==0)//生成大栏目
- {
- if($class_r[$classid]['listdt']||$class_r[$classid]['wburl']||strstr($public_r['nreclass'],','.$classid.','))//不生成栏目
- {
- return '';
- }
- $GLOBALS['navclassid']=$classid;
- $url=ReturnClassLink($classid);//导航
- $cf=$doing==1?',classpath,classtype,classname':'';
- $cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid".$cf." from {$dbtbpre}enewsclass where classid='$classid'");
- if(!empty($cf))
- {
- $class_r[$classid][classpath]=$cr[classpath];
- $class_r[$classid][classtype]=$cr[classtype];
- $class_r[$classid][classname]=$cr[classname];
- }
- //权限
- if($cr['cgroupid'])
- {
- $classlevel=AddCheckClassLevel($classid,$cr['cgroupid'],'');
- }
- //页面
- $pagetitle=htmlspecialchars($class_r[$classid][classname]);
- $pagekey=htmlspecialchars($cr['classpagekey']);
- $pagedes=htmlspecialchars($cr['intro']);
- $classimg=$cr['classimg'];
- $onclick="<script src=".$public_r[newsurl]."e/public/onclick?enews=doclass&classid=$classid></script>";
- $truefile=ECMS_PATH.ReturnSaveClassPath($classid,1);
- $file=ECMS_PATH.'e/data/tmp/class'.$classid.'.php';
- $indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
- $indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,0);
- }
- elseif($enews==3)//专题
- {
- $GLOBALS['navclassid']=$classid;
- $url=ReturnZtLink($classid);//导航
- $cf=$doing==1?',ztpath,zttype,ztname':'';
- $cr=$empire->fetch1("select ztpagekey,intro,ztimg".$cf." from {$dbtbpre}enewszt where ztid='$classid'");
- if(!empty($cf))
- {
- $class_zr[$classid][ztpath]=$cr[ztpath];
- $class_zr[$classid][zttype]=$cr[zttype];
- $class_zr[$classid][ztname]=$cr[ztname];
- }
- $pagetitle=htmlspecialchars($class_zr[$classid][ztname]);
- $pagekey=htmlspecialchars($cr['ztpagekey']);
- $pagedes=htmlspecialchars($cr['intro']);
- $classimg=$cr['ztimg'];
- $onclick="<script src=".$public_r[newsurl]."e/public/onclick?enews=dozt&ztid=$ztid></script>";
- $truefile=ECMS_PATH.ReturnSaveZtPath($classid,1);
- $file=ECMS_PATH.'e/data/tmp/zt'.$classid.'.php';
- $indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
- $indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,1);
- }
- elseif($enews==1)//生成首页文件
- {
- $pr=$empire->fetch1("select sitekey,siteintro,indexpagedt from {$dbtbpre}enewspublic limit 1");
- if($pr['indexpagedt'])
- {
- return '';
- }
- //页面
- $pagetitle=htmlspecialchars($public_r['sitename']);
- $pagekey=htmlspecialchars($pr['sitekey']);
- $pagedes=htmlspecialchars($pr['siteintro']);
- $url="<a href=\"".$public_r[newsurl]."\">".$fun_r['index']."</a>";//栏目导航
- $onclick='';
- $truefile=ECMS_PATH.ReturnSaveIndexFile();
- $file=ECMS_PATH.'e/data/tmp/index.php';
- $indextext=ReplaceSvars($indextext,$url,0,$pagetitle,$pagekey,$pagedes,$add,0);
- }
- $indextext=str_replace("[!--page.stats--]",$onclick,$indextext);
- //替换标签
- $indextext=DoRepEcmsLoopBq($indextext);
- $indextext=RepBq($indextext);
- //写文件
- WriteFiletext($file,AddCheckViewTempCode().$indextext);
- //读取文件内容
- ob_start();
- include($file);
- $string=ob_get_contents…
Large files files are truncated, but you can click here to view the full file