/e/class/classfun.php
PHP | 2608 lines | 2312 code | 51 blank | 245 comment | 315 complexity | 71177aa698955b09ca393bdb49439f28 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- //*********************** 专题 *********************
-
- //返回字段值
- function ReturnZFvalue($value)
- {
- $value=str_replace("\r\n","|",$value);
- return $value;
- }
-
- //取得专题表单元素html代码
- function GetZtFform($type,$f,$fvalue,$fformsize=''){
- if($type=="select"||$type=="radio"||$type=="checkbox")
- {
- return GetZFformSelect($type,$f,$fvalue,$fformsize);
- }
- $file="../data/html/classfhtml.txt";
- $data=ReadFiletext($file);
- $exp="[!--".$type."--]";
- $r=explode($exp,$data);
- $string=str_replace("[!--enews.var--]",$f,$r[1]);
- $string=str_replace("[!--enews.def.val--]",$fvalue,$string);
- if($type=='editor')//编辑器
- {
- $editortype='Default';
- $string=str_replace("[!--editor.type--]",$editortype,$string);
- $string=str_replace("[!--editor.basepath--]",'',$string);
- }
- $string=RepZFformSize($f,$string,$type,$fformsize);
- return addslashes($string);
- }
-
- //取得select/radio元素代码
- function GetZFformSelect($type,$f,$fvalue,$fformsize=''){
- $vr=explode("|",$fvalue);
- $count=count($vr);
- $change="";
- $def=':default';
- for($i=0;$i<$count;$i++)
- {
- $val=$vr[$i];
- $isdef="";
- if(strstr($val,$def))
- {
- $dr=explode($def,$val);
- $val=$dr[0];
- $isdef="||\$ecmsfirstpost==1";
- }
- if($type=='select')
- {
- $change.="<option value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' selected':''?>>".$val."</option>";
- }
- elseif($type=='checkbox')
- {
- $change.="<input name=\"".$f."[]\" type=\"checkbox\" value=\"".$val."\"<?=strstr(\$r[".$f."],\"|".$val."|\")".$isdef."?' checked':''?>>".$val;
- }
- else
- {
- $change.="<input name=\"".$f."\" type=\"radio\" value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' checked':''?>>".$val;
- }
- }
- if($type=="select")
- {
- if($fformsize)
- {
- $addsize=' style="width:'.$fformsize.'"';
- }
- $change="<select name=\"".$f."\" id=\"".$f."\"".$addsize.">".$change."</select>";
- }
- return $change;
- }
-
- //替换表单元素长度
- function RepZFformSize($f,$string,$type,$fformsize=''){
- $fformsize=ReturnDefZFformSize($f,$type,$fformsize);
- if($type=='textarea'||$type=='editor')
- {
- $r=explode(',',$fformsize);
- $string=str_replace('[!--fsize.w--]',$r[0],$string);
- $string=str_replace('[!--fsize.h--]',$r[1],$string);
- }
- else
- {
- $string=str_replace('[!--fsize.w--]',$fformsize,$string);
- }
- return $string;
- }
-
- //返回默认长度
- function ReturnDefZFformSize($f,$type,$fformsize){
- if(empty($fformsize))
- {
- if($type=='textarea')
- {
- $fformsize='60,10';
- }
- elseif($type=='img')
- {
- $fformsize='45';
- }
- elseif($type=='file')
- {
- $fformsize='45';
- }
- elseif($type=='flash')
- {
- $fformsize='45';
- }
- elseif($type=='date')
- {
- $fformsize='12';
- }
- elseif($type=='color')
- {
- $fformsize='10';
- }
- elseif($type=='linkfield')
- {
- $fformsize='45';
- }
- elseif($type=='downpath')
- {
- $fformsize='45';
- }
- elseif($type=='onlinepath')
- {
- $fformsize='45';
- }
- elseif($type=='editor')
- {
- $fformsize='100%,300';
- }
- }
- return $fformsize;
- }
-
- //更新栏目表单文件
- function ChangeZtForm(){
- global $empire,$dbtbpre;
- $file='../data/html/ztaddform.php';
- $mtemp='';
- $sql=$empire->query("select fname,f,fhtml from {$dbtbpre}enewsztf order by myorder,fid");
- while($r=$empire->fetch($sql))
- {
- $mtemp.="<tr bgcolor='#FFFFFF' height=25><td>".$r['fname']."</td><td>".$r['fhtml']."</td></tr>";
- }
- $mtemp="<?php
- if(!defined('InEmpireCMS'))
- {exit();}
- ?>".$mtemp;
- WriteFiletext($file,$mtemp);
- }
-
- //增加专题字段
- function AddZtF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"ztf");
- $add[f]=RepPostVar($add[f]);
- if(empty($add[f])||empty($add[fname]))
- {
- printerror("EmptyF","");
- }
- //字段是否重复
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsztadd");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewszt");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- $add[fvalue]=ReturnZFvalue($add[fvalue]);//初始化值
- //字段类型
- if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
- {
- $def=" default '0'";
- }
- elseif($add[ftype]=="VARCHAR")
- {
- $def=" default ''";
- }
- else
- {
- $def="";
- }
- $type=$add[ftype];
- //VARCHAR
- if($add[ftype]=='VARCHAR'&&empty($add[flen]))
- {
- $add[flen]='255';
- }
- //字段长度
- if($add[flen]){
- if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
- $type.="(".$add[flen].")";
- }
- }
- $field="`".$add[f]."` ".$type." NOT NULL".$def;
- //新增字段
- $asql=$empire->query("alter table {$dbtbpre}enewsztadd add ".$field);
- //替换代码
- $fhtml=GetZtFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
- if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
- {
- $fhtml=str_replace("\$r[","\$addr[",$fhtml);
- }
- //处理变量
- $add[myorder]=(int)$add[myorder];
- $sql=$empire->query("insert into {$dbtbpre}enewsztf(f,fname,fform,fhtml,fzs,myorder,ftype,flen,fvalue,fformsize) values('$add[f]','$add[fname]','$add[fform]','".addslashes($fhtml)."','".addslashes($add[fzs])."',$add[myorder],'$add[ftype]','$add[flen]','".addslashes($add[fvalue])."','$add[fformsize]');");
- $lastid=$empire->lastid();
- //更新表单
- ChangeZtForm();
- if($asql&&$sql)
- {
- //操作日志
- insert_dolog("fid=".$lastid."<br>f=".$add[f]);
- printerror("AddFSuccess","info/AddZtF.php?enews=AddZtF");
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
-
- //修改专题字段
- function EditZtF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"ztf");
- $fid=(int)$add['fid'];
- $add[f]=RepPostVar($add[f]);
- $add[oldf]=RepPostVar($add[oldf]);
- if(empty($add[f])||empty($add[fname])||!$fid){
- printerror("EmptyF","history.go(-1)");
- }
- if($add[f]<>$add[oldf]){
- //字段是否重复
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsztadd");
- $b=0;
- while($r=$empire->fetch($s)){
- if($r[Field]==$add[f]){
- $b=1;
- break;
- }
- }
- if($b){
- printerror("ReF","history.go(-1)");
- }
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewszt");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- }
- $add[fvalue]=ReturnZFvalue($add[fvalue]);//初始化值
- //字段类型
- if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
- {
- $def=" default '0'";
- }
- elseif($add[ftype]=="VARCHAR")
- {
- $def=" default ''";
- }
- else
- {
- $def="";
- }
- $type=$add[ftype];
- //VARCHAR
- if($add[ftype]=='VARCHAR'&&empty($add[flen]))
- {
- $add[flen]='255';
- }
- //字段长度
- if($add[flen]){
- if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
- $type.="(".$add[flen].")";
- }
- }
- $field="`".$add[f]."` ".$type." NOT NULL".$def;
- $usql=$empire->query("alter table {$dbtbpre}enewsztadd change `".$add[oldf]."` ".$field);
- //替换代码
- if($add[f]<>$add[oldf]||$add[fform]<>$add[oldfform]||$add[fvalue]<>$add[oldfvalue]||$add[fformsize]<>$add[oldfformsize]){
- $fhtml=GetZtFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
- if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
- {
- $fhtml=str_replace("\$r[","\$addr[",$fhtml);
- }
- }
- else{
- $fhtml=$add[fhtml];
- }
- //处理变量
- $add[myorder]=(int)$add[myorder];
- $sql=$empire->query("update {$dbtbpre}enewsztf set f='$add[f]',fname='$add[fname]',fform='$add[fform]',fhtml='".addslashes($fhtml)."',fzs='".addslashes($add[fzs])."',myorder=$add[myorder],ftype='$add[ftype]',flen='$add[flen]',fvalue='".addslashes($add[fvalue])."',fformsize='$add[fformsize]' where fid=$fid");
- //更新表单
- ChangeZtForm();
- if($usql&&$sql)
- {
- insert_dolog("fid=".$fid."<br>f=".$add[f]);//操作日志
- printerror("EditFSuccess","info/ListZtF.php");
- }
- else
- {printerror("DbError","history.go(-1)");}
- }
-
- //删除专题字段
- function DelZtF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"ztf");
- $fid=(int)$add['fid'];
- if(empty($fid)){
- printerror("EmptyFid","history.go(-1)");
- }
- $r=$empire->fetch1("select f from {$dbtbpre}enewsztf where fid='$fid'");
- if(!$r[f]){
- printerror("EmptyFid","history.go(-1)");
- }
- $usql=$empire->query("alter table {$dbtbpre}enewsztadd drop COLUMN `".$r[f]."`");
- $sql=$empire->query("delete from {$dbtbpre}enewsztf where fid='$fid'");
- //更新表单表
- ChangeZtForm();
- if($usql&&$sql)
- {
- insert_dolog("fid=".$fid."<br>f=".$r[f]);//操作日志
- printerror("DelFSuccess","info/ListZtF.php");
- }
- else
- {printerror("DbError","history.go(-1)");}
- }
-
- //修改专题字段顺序
- function EditZtFOrder($fid,$myorder,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"ztf");
- for($i=0;$i<count($myorder);$i++)
- {
- $fid[$i]=(int)$fid[$i];
- $newmyorder=(int)$myorder[$i];
- $usql=$empire->query("update {$dbtbpre}enewsztf set myorder=$newmyorder where fid='$fid[$i]'");
- }
- //更新表单表
- ChangeZtForm();
- printerror("EditFOrderSuccess","info/ListZtF.php");
- }
-
- //返回专题字段
- function ReturnZtAddF($add,$ecms=0){
- global $empire,$dbtbpre;
- $ret_r[0]='';
- $ret_r[1]='';
- $fsql=$empire->query("select f from {$dbtbpre}enewsztf");
- if($ecms==0)//增加
- {
- while($fr=$empire->fetch($fsql))
- {
- $f=$fr['f'];
- $fval=$add[$f];
- $fval=RepPhpAspJspcode($fval);
- $ret_r[0].=",`".$f."`";
- $ret_r[1].=",'".AddAddsData($fval)."'";
- }
- }
- else//修改
- {
- while($fr=$empire->fetch($fsql))
- {
- $f=$fr['f'];
- $fval=$add[$f];
- $fval=RepPhpAspJspcode($fval);
- $ret_r[0].=",`".$f."`='".AddAddsData($fval)."'";
- }
- }
- return $ret_r;
- }
-
-
- //处理专题提交变量
- function DoPostZtVar($add){
- if(empty($add[zttype])){
- $add[zttype]=".html";
- }
- if(empty($add[ztnum])){
- $add[ztnum]=25;
- }
- $add[zcid]=(int)$add['zcid'];
- $add[jstempid]=(int)$add['jstempid'];
- $add[ztname]=addslashes(htmlspecialchars($add[ztname]));
- $add[intro]=addslashes(RepPhpAspJspcode($add[intro]));
- $add[ztpagekey]=addslashes(RepPhpAspJspcode($add[ztpagekey]));
- $add[ztnum]=(int)$add[ztnum];
- $add[listtempid]=(int)$add[listtempid];
- $add[newline]=(int)$add[newline];
- $add[hotline]=(int)$add[hotline];
- $add[goodline]=(int)$add[goodline];
- $add[classid]=(int)$add[classid];
- $add[hotplline]=(int)$add[hotplline];
- $add[firstline]=(int)$add[firstline];
- $add[islist]=(int)$add[islist];
- $add[maxnum]=(int)$add[maxnum];
- $add[showzt]=(int)$add[showzt];
- $add[classtempid]=(int)$add[classtempid];
- $add['myorder']=(int)$add['myorder'];
- $add[nrejs]=(int)$add[nrejs];
- $add[reorder]=RepPostVar2($add[reorder]);
- $add[classtext]=RepPhpAspJspcode($add[classtext]);
- $add[usezt]=(int)$add[usezt];
- $add[yhid]=(int)$add[yhid];
- //目录
- $add[ztpath]=$add['pripath'].$add['ztpath'];
- return $add;
- }
-
- //增加专题
- function AddZt($add,$userid,$username){
- global $empire,$class_r,$dbtbpre;
- $add[ztpath]=trim($add[ztpath]);
- if(!$add[ztname]||!$add[listtempid]||!$add[ztpath]){
- printerror("EmptyZt","");
- }
- CheckLevel($userid,$username,$classid,"zt");
- $add=DoPostZtVar($add);
- $createpath='../../'.$add[ztpath];
- //检测目录是否存在
- if(file_exists($createpath)){
- printerror("ReZtpath","");
- }
- CreateZtPath($add[ztpath]);//建立专题目录
- //取得表名
- $tabler=GetModTable(GetListtempMid($add[listtempid]));
- $tabler[tid]=(int)$tabler[tid];
- $sql=$empire->query("insert into {$dbtbpre}enewszt(ztname,ztnum,listtempid,onclick,ztpath,zttype,newline,zturl,hotline,goodline,classid,hotplline,firstline,islist,maxnum,tid,tbname,reorder,intro,ztimg,zcid,jstempid,showzt,ztpagekey,classtempid,myorder,nrejs,usezt,yhid) values('$add[ztname]',$add[ztnum],$add[listtempid],0,'$add[ztpath]','$add[zttype]',$add[newline],'$add[zturl]',$add[hotline],$add[goodline],$add[classid],$add[hotplline],$add[firstline],$add[islist],$add[maxnum],$tabler[tid],'$tabler[tbname]','$add[reorder]','$add[intro]','$add[ztimg]',$add[zcid],$add[jstempid],$add[showzt],'$add[ztpagekey]','$add[classtempid]',$add[myorder],$add[nrejs],'$add[usezt]','$add[yhid]');");
- $ztid=$empire->lastid();
- //副表
- $ret_zr=ReturnZtAddF($add,0);
- $empire->query("replace into {$dbtbpre}enewsztadd(ztid,classtext".$ret_zr[0].") values('$ztid','".addslashes($add[classtext])."'".$ret_zr[1].");");
- //生成页面
- if($add[islist]==0||$add[islist]==2)
- {
- $classtemp=$add[islist]==2?GetZtText($ztid):GetClassTemp($add['classtempid']);
- NewsBq($ztid,$classtemp,3,1);
- }
- GetClass();//更新缓存
- if($sql){
- insert_dolog("ztid=".$ztid."<br>ztname=".$add[ztname]);//操作日志
- printerror("AddZtSuccess","AddZt.php?enews=AddZt");
- }
- else{
- printerror("DbError","");
- }
- }
-
- //修改专题
- function EditZt($add,$userid,$username){
- global $empire,$class_r,$dbtbpre;
- $add[ztid]=(int)$add[ztid];
- $add[ztpath]=trim($add[ztpath]);
- if(!$add[ztname]||!$add[listtempid]||!$add[ztpath]||!$add[ztid]){
- printerror("EmptyZt","");
- }
- CheckLevel($userid,$username,$classid,"zt");
- $add=DoPostZtVar($add);
- //改变目录
- if($add[oldztpath]<>$add[ztpath]){
- $createpath='../../'.$add[ztpath];
- if(file_exists($createpath)){
- printerror("ReZtpath","");
- }
- if($add['oldpripath']==$add['pripath']){
- $new="../../";
- @rename($new.$add[oldztpath],$new.$add[ztpath]);//改变目录名
- }
- else{
- CreateZtPath($add[ztpath]);//建立专题目录
- }
- }
- //取得表名
- $tabler=GetModTable(GetListtempMid($add[listtempid]));
- $tabler[tid]=(int)$tabler[tid];
- $sql=$empire->query("update {$dbtbpre}enewszt set ztname='$add[ztname]',ztnum=$add[ztnum],listtempid=$add[listtempid],ztpath='$add[ztpath]',zttype='$add[zttype]',newline=$add[newline],zturl='$add[zturl]',hotline=$add[hotline],goodline=$add[goodline],classid=$add[classid],hotplline=$add[hotplline],firstline=$add[firstline],islist=$add[islist],maxnum=$add[maxnum],tid=$tabler[tid],tbname='$tabler[tbname]',reorder='$add[reorder]',intro='$add[intro]',ztimg='$add[ztimg]',zcid=$add[zcid],jstempid=$add[jstempid],showzt=$add[showzt],ztpagekey='$add[ztpagekey]',classtempid='$add[classtempid]',myorder=$add[myorder],nrejs=$add[nrejs],usezt='$add[usezt]',yhid='$add[yhid]' where ztid='$add[ztid]'");
- //副表
- $ret_zr=ReturnZtAddF($add,1);
- $empire->query("update {$dbtbpre}enewsztadd set classtext='".addslashes($add[classtext])."'".$ret_zr[0]." where ztid='$add[ztid]'");
- GetClass();//更新缓存
- //生成页面
- if($add[islist]==0||$add[islist]==2)
- {
- $classtemp=$add[islist]==2?GetZtText($add[ztid]):GetClassTemp($add['classtempid']);
- NewsBq($add[ztid],$classtemp,3,1);
- }
- if($sql){
- insert_dolog("ztid=".$add[ztid]."<br>ztname=".$add[ztname]);//操作日志
- printerror("EditZtSuccess","ListZt.php");
- }
- else{
- printerror("DbError","");
- }
- }
-
- //删除专题
- function DelZt($ztid,$userid,$username){
- global $empire,$dbtbpre;
- $ztid=(int)$ztid;
- if(!$ztid){
- printerror("NotDelZtid","");
- }
- CheckLevel($userid,$username,$classid,"zt");
- $r=$empire->fetch1("select * from {$dbtbpre}enewszt where ztid='$ztid'");
- if(empty($r[ztid])){
- printerror("NotDelZtid","history.go(-1)");
- }
- //删除专题
- $sql=$empire->query("delete from {$dbtbpre}enewszt where ztid='$ztid'");
- $empire->query("delete from {$dbtbpre}enewsztadd where ztid='$ztid'");
- $delpath="../../".$r[ztpath];
- $del=DelPath($delpath);
- //改变信息专题值
- $nsql=$empire->query("select id,ztid from {$dbtbpre}ecms_".$r[tbname]." where ztid like '%|".$ztid."|%'");
- while($nr=$empire->fetch($nsql))
- {
- $newztid=str_replace("|".$ztid."|","|",$nr[ztid]);
- $usql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]." set ztid='$newztid' where id='$nr[id]'");
- }
- GetClass();//更新缓存
- if($sql){
- insert_dolog("ztid=".$ztid."<br>ztname=".$r[ztname]);//操作日志
- printerror("DelZtSuccess","ListZt.php");
- }
- else{
- printerror("DbError","");
- }
- }
-
- //组合专题
- function TogZt($add,$userid,$username){
- global $empire,$class_r,$dbtbpre;
- $ztid=(int)$add['ztid'];
- if(empty($ztid))
- {
- printerror("ErrorUrl","history.go(-1)");
- }
- $r=$empire->fetch1("select ztid,ztname,tbname from {$dbtbpre}enewszt where ztid=$ztid");
- if(empty($r['ztid'])||empty($r['tbname']))
- {
- printerror("ErrorUrl","history.go(-1)");
- }
- $wheresql="";
- $formvar="";
- //关键字
- $keyboard=RepPostVar2($add['keyboard']);
- if($keyboard)
- {
- $formvar.=ReturnFormHidden('keyboard',$add['keyboard']);
- $searchfsql='';
- if($add['stitle'])//标题
- {
- $searchfsql.="title like '%$keyboard%'";
- $formvar.=ReturnFormHidden('stitle',$add['stitle']);
- }
- if($add['susername'])//增加者
- {
- if($searchfsql)
- {
- $or=" or ";
- }
- $searchfsql.=$or."username like '%$keyboard%'";
- $formvar.=ReturnFormHidden('susername',$add['susername']);
- }
- if($add['snewstext'])//内容
- {
- $or="";
- if($searchfsql)
- {
- $or=" or ";
- }
- $searchfsql.=$or."newstext like '%$keyboard%'";
- $formvar.=ReturnFormHidden('snewstext',$add['snewstext']);
- }
- if($searchfsql)
- {
- $wheresql=" and (".$searchfsql.")";
- }
- }
- //是否推荐
- if($add['isgood'])
- {
- $wheresql.=" and isgood>0";
- $formvar.=ReturnFormHidden('isgood',$add['isgood']);
- }
- //头条
- if($add['firsttitle'])
- {
- $wheresql.=" and firsttitle>0";
- $formvar.=ReturnFormHidden('firsttitle',$add['firsttitle']);
- }
- //有标题图片
- if($add['titlepic'])
- {
- $wheresql.=" and ispic=1";
- $formvar.=ReturnFormHidden('titlepic',$add['titlepic']);
- }
- //审核
- if($add['checked'])
- {
- $wheresql.=" and checked=1";
- $formvar.=ReturnFormHidden('checked',$add['checked']);
- }
- //按栏目刷新
- $classid=(int)$add['classid'];
- if($classid)
- {
- $formvar.=ReturnFormHidden('classid',$add['classid']);
- //大栏目
- if(empty($class_r[$classid][islast]))
- {
- $where=ReturnClass($class_r[$classid][sonclass]);
- }
- //终极栏目
- else
- {
- $where="classid='$classid'";
- }
- $wheresql.=" and (".$where.")";
- }
- $startid=(int)$add[startid];
- $endid=(int)$add[endid];
- $startday=RepPostVar($add[startday]);
- $endday=RepPostVar($add[endday]);
- $formvar.=ReturnFormHidden('retype',$add['retype']);
- //按ID
- if($add['retype'])
- {
- if($endid)
- {
- $wheresql.=" and id>=$startid and id<=$endid";
- $formvar.=ReturnFormHidden('startid',$add[startid]).ReturnFormHidden('endid',$add[endid]);
- }
- }
- else
- {
- if($startday&&$endday)
- {
- $wheresql.=" and truetime>=".to_time($startday." 00:00:00")." and truetime<=".to_time($endday." 23:59:59");
- $formvar.=ReturnFormHidden('startday',$add[startday]).ReturnFormHidden('endday',$add[endday]);
- }
- }
- //附件sql条件
- $query=$add['query'];
- if($query)
- {
- $query=ClearAddsData($query);//去除adds
- $wheresql.=" and (".$query.")";
- $formvar.=ReturnFormHidden('query',$add['query']);
- }
- $wheresql=" where ztid not like '%|".$ztid."|%'".$wheresql;
- $owheresql=$wheresql." and ztid=''";
- if($add['doecmszt'])
- {
- if($add['inid'])
- {
- $add['inid']=RepPostVar($add['inid']);
- $wheresql.=" and id not in (".$add['inid'].")";
- $owheresql.=" and id not in (".$add['inid'].")";
- }
- $repztid="|".$ztid."|";
- $conztid=$ztid."|";
- //将空格转换成|
- $usql=$empire->query("update {$dbtbpre}ecms_".$r['tbname']." set ztid='|'".$owheresql);
- //组成新专题
- $sql=$empire->query("update {$dbtbpre}ecms_".$r['tbname']." set ztid=CONCAT(REPLACE(ztid,'".$repztid."','|'),'".$conztid."')".$wheresql);
- if($usql&&$sql)
- {
- //操作日志
- insert_dolog("ztid=$ztid&ztname=$r[ztname]");
- printerror("TogZtSuccess","TogZt.php?ztid=$ztid");
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- $re[0]=$wheresql;
- $re[1]=$formvar.ReturnFormHidden('ztid',$ztid).ReturnFormHidden('pline',$add[pline]).ReturnFormHidden('doecmszt',$add[doecmszt]).ReturnFormHidden('enews',$add[enews]).ReturnFormHidden('inid',$add[inid]);
- $re[2]=$r['tbname'];
- $re[3]=$r['ztname'];
- return $re;
- }
-
- //保存专题信息
- function SaveTogZtInfo($add,$userid,$username){
- global $empire,$dbtbpre;
- if(!trim($add[togztname]))
- {
- printerror('EmptySaveTogZtname','history.go(-1)');
- }
- $add['doecmszt']=(int)$add['doecmszt'];
- $add[classid]=(int)$add[classid];
- //搜索字段
- $searchf=',';
- if($add[stitle]==1)
- {
- $searchf.='stitle,';
- }
- if($add[susername]==1)
- {
- $searchf.='susername,';
- }
- if($add[snewstext]==1)
- {
- $searchf.='snewstext,';
- }
- //特殊字段
- $specialsearch=',';
- if($add[isgood])
- {
- $specialsearch.='isgood,';
- }
- if($add[firsttitle])
- {
- $specialsearch.='firsttitle,';
- }
- if($add[titlepic])
- {
- $specialsearch.='titlepic,';
- }
- if($add[checked])
- {
- $specialsearch.='checked,';
- }
- $add['retype']=(int)$add['retype'];
- $add['startid']=(int)$add['startid'];
- $add['endid']=(int)$add['endid'];
- $add['pline']=(int)$add['pline'];
- $r=$empire->fetch1("select togid from {$dbtbpre}enewstogzts where togztname='$add[togztname]'");
- if($r[togid])
- {
- $sql=$empire->query("update {$dbtbpre}enewstogzts set keyboard='".addslashes($add[keyboard])."',searchf='$searchf',query='".addslashes($add[query])."',specialsearch='$specialsearch',classid=$add[classid],retype=$add[retype],startday='".addslashes($add[startday])."',endday='".addslashes($add[endday])."',startid=$add[startid],endid=$add[endid],pline=$add[pline],doecmszt=$add[doecmszt] where togid='$r[togid]'");
- $togid=$r[togid];
- }
- else
- {
- $sql=$empire->query("insert into {$dbtbpre}enewstogzts(keyboard,searchf,query,specialsearch,classid,retype,startday,endday,startid,endid,pline,doecmszt,togztname) values('".addslashes($add[keyboard])."','$searchf','".addslashes($add[query])."','$specialsearch',$add[classid],$add[retype],'".addslashes($add[startday])."','".addslashes($add[endday])."',$add[startid],$add[endid],$add[pline],$add[doecmszt],'".addslashes($add[togztname])."');");
- $togid=$empire->lastid();
- }
- if($sql)
- {
- insert_dolog("togid=$togid&togztname=$add[togztname]");//操作日志
- printerror("SaveTogZtInfoSuccess","TogZt.php?ztid=$add[ztid]&togid=$togid");
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
-
- //删除保存专题信息
- function DelTogZtInfo($add,$userid,$username){
- global $empire,$dbtbpre;
- $togid=intval($add[togid]);
- if(!$togid)
- {
- printerror('EmptyDelTogztid','history.go(-1)');
- }
- $r=$empire->fetch1("select togid,togztname from {$dbtbpre}enewstogzts where togid='$togid'");
- if(!$r[togid])
- {
- printerror('EmptyDelTogztid','history.go(-1)');
- }
- $sql=$empire->query("delete from {$dbtbpre}enewstogzts where togid='$togid'");
- if($sql)
- {
- insert_dolog("togid=$togid&togztname=$r[togztname]");//操作日志
- printerror('DelTogZtInfoSuccess',$_SERVER['HTTP_REFERER']);
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
-
-
- //************************************ 栏目 ************************************
-
- //返回字段值
- function ReturnCFvalue($value)
- {
- $value=str_replace("\r\n","|",$value);
- return $value;
- }
-
- //取得栏目表单元素html代码
- function GetClassFform($type,$f,$fvalue,$fformsize=''){
- if($type=="select"||$type=="radio"||$type=="checkbox")
- {
- return GetCFformSelect($type,$f,$fvalue,$fformsize);
- }
- $file="../data/html/classfhtml.txt";
- $data=ReadFiletext($file);
- $exp="[!--".$type."--]";
- $r=explode($exp,$data);
- $string=str_replace("[!--enews.var--]",$f,$r[1]);
- $string=str_replace("[!--enews.def.val--]",$fvalue,$string);
- if($type=='editor')//编辑器
- {
- $editortype='Default';
- $string=str_replace("[!--editor.type--]",$editortype,$string);
- $string=str_replace("[!--editor.basepath--]",'',$string);
- }
- $string=RepCFformSize($f,$string,$type,$fformsize);
- return addslashes($string);
- }
-
- //取得select/radio元素代码
- function GetCFformSelect($type,$f,$fvalue,$fformsize=''){
- $vr=explode("|",$fvalue);
- $count=count($vr);
- $change="";
- $def=':default';
- for($i=0;$i<$count;$i++)
- {
- $val=$vr[$i];
- $isdef="";
- if(strstr($val,$def))
- {
- $dr=explode($def,$val);
- $val=$dr[0];
- $isdef="||\$ecmsfirstpost==1";
- }
- if($type=='select')
- {
- $change.="<option value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' selected':''?>>".$val."</option>";
- }
- elseif($type=='checkbox')
- {
- $change.="<input name=\"".$f."[]\" type=\"checkbox\" value=\"".$val."\"<?=strstr(\$r[".$f."],\"|".$val."|\")".$isdef."?' checked':''?>>".$val;
- }
- else
- {
- $change.="<input name=\"".$f."\" type=\"radio\" value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' checked':''?>>".$val;
- }
- }
- if($type=="select")
- {
- if($fformsize)
- {
- $addsize=' style="width:'.$fformsize.'"';
- }
- $change="<select name=\"".$f."\" id=\"".$f."\"".$addsize.">".$change."</select>";
- }
- return $change;
- }
-
- //替换表单元素长度
- function RepCFformSize($f,$string,$type,$fformsize=''){
- $fformsize=ReturnDefCFformSize($f,$type,$fformsize);
- if($type=='textarea'||$type=='editor')
- {
- $r=explode(',',$fformsize);
- $string=str_replace('[!--fsize.w--]',$r[0],$string);
- $string=str_replace('[!--fsize.h--]',$r[1],$string);
- }
- else
- {
- $string=str_replace('[!--fsize.w--]',$fformsize,$string);
- }
- return $string;
- }
-
- //返回默认长度
- function ReturnDefCFformSize($f,$type,$fformsize){
- if(empty($fformsize))
- {
- if($type=='textarea')
- {
- $fformsize='60,10';
- }
- elseif($type=='img')
- {
- $fformsize='45';
- }
- elseif($type=='file')
- {
- $fformsize='45';
- }
- elseif($type=='flash')
- {
- $fformsize='45';
- }
- elseif($type=='date')
- {
- $fformsize='12';
- }
- elseif($type=='color')
- {
- $fformsize='10';
- }
- elseif($type=='linkfield')
- {
- $fformsize='45';
- }
- elseif($type=='downpath')
- {
- $fformsize='45';
- }
- elseif($type=='onlinepath')
- {
- $fformsize='45';
- }
- elseif($type=='editor')
- {
- $fformsize='100%,300';
- }
- }
- return $fformsize;
- }
-
- //更新栏目表单文件
- function ChangeClassForm(){
- global $empire,$dbtbpre;
- $file='../data/html/classaddform.php';
- $mtemp='';
- $sql=$empire->query("select fname,f,fhtml from {$dbtbpre}enewsclassf order by myorder,fid");
- while($r=$empire->fetch($sql))
- {
- $mtemp.="<tr bgcolor='#FFFFFF' height=25><td>".$r['fname']."</td><td>".$r['fhtml']."</td></tr>";
- }
- $mtemp="<?php
- if(!defined('InEmpireCMS'))
- {exit();}
- ?>".$mtemp;
- WriteFiletext($file,$mtemp);
- }
-
- //增加栏目字段
- function AddClassF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"classf");
- $add[f]=RepPostVar($add[f]);
- if(empty($add[f])||empty($add[fname]))
- {
- printerror("EmptyF","");
- }
- //字段是否重复
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclassadd");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclass");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- $add[fvalue]=ReturnCFvalue($add[fvalue]);//初始化值
- //字段类型
- if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
- {
- $def=" default '0'";
- }
- elseif($add[ftype]=="VARCHAR")
- {
- $def=" default ''";
- }
- else
- {
- $def="";
- }
- $type=$add[ftype];
- //VARCHAR
- if($add[ftype]=='VARCHAR'&&empty($add[flen]))
- {
- $add[flen]='255';
- }
- //字段长度
- if($add[flen]){
- if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
- $type.="(".$add[flen].")";
- }
- }
- $field="`".$add[f]."` ".$type." NOT NULL".$def;
- //新增字段
- $asql=$empire->query("alter table {$dbtbpre}enewsclassadd add ".$field);
- //替换代码
- $fhtml=GetClassFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
- if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
- {
- $fhtml=str_replace("\$r[","\$addr[",$fhtml);
- }
- //处理变量
- $add[myorder]=(int)$add[myorder];
- $sql=$empire->query("insert into {$dbtbpre}enewsclassf(f,fname,fform,fhtml,fzs,myorder,ftype,flen,fvalue,fformsize) values('$add[f]','$add[fname]','$add[fform]','".addslashes($fhtml)."','".addslashes($add[fzs])."',$add[myorder],'$add[ftype]','$add[flen]','".addslashes($add[fvalue])."','$add[fformsize]');");
- $lastid=$empire->lastid();
- //更新表单
- ChangeClassForm();
- if($asql&&$sql)
- {
- //操作日志
- insert_dolog("fid=".$lastid."<br>f=".$add[f]);
- printerror("AddFSuccess","info/AddClassF.php?enews=AddClassF");
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
-
- //修改栏目字段
- function EditClassF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"classf");
- $fid=(int)$add['fid'];
- $add[f]=RepPostVar($add[f]);
- $add[oldf]=RepPostVar($add[oldf]);
- if(empty($add[f])||empty($add[fname])||!$fid){
- printerror("EmptyF","history.go(-1)");
- }
- if($add[f]<>$add[oldf]){
- //字段是否重复
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclassadd");
- $b=0;
- while($r=$empire->fetch($s)){
- if($r[Field]==$add[f]){
- $b=1;
- break;
- }
- }
- if($b){
- printerror("ReF","history.go(-1)");
- }
- $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclass");
- $b=0;
- while($r=$empire->fetch($s))
- {
- if($r[Field]==$add[f])
- {
- $b=1;
- break;
- }
- }
- if($b)
- {
- printerror("ReF","");
- }
- }
- $add[fvalue]=ReturnCFvalue($add[fvalue]);//初始化值
- //字段类型
- if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
- {
- $def=" default '0'";
- }
- elseif($add[ftype]=="VARCHAR")
- {
- $def=" default ''";
- }
- else
- {
- $def="";
- }
- $type=$add[ftype];
- //VARCHAR
- if($add[ftype]=='VARCHAR'&&empty($add[flen]))
- {
- $add[flen]='255';
- }
- //字段长度
- if($add[flen]){
- if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
- $type.="(".$add[flen].")";
- }
- }
- $field="`".$add[f]."` ".$type." NOT NULL".$def;
- $usql=$empire->query("alter table {$dbtbpre}enewsclassadd change `".$add[oldf]."` ".$field);
- //替换代码
- if($add[f]<>$add[oldf]||$add[fform]<>$add[oldfform]||$add[fvalue]<>$add[oldfvalue]||$add[fformsize]<>$add[oldfformsize]){
- $fhtml=GetClassFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
- if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
- {
- $fhtml=str_replace("\$r[","\$addr[",$fhtml);
- }
- }
- else{
- $fhtml=$add[fhtml];
- }
- //处理变量
- $add[myorder]=(int)$add[myorder];
- $sql=$empire->query("update {$dbtbpre}enewsclassf set f='$add[f]',fname='$add[fname]',fform='$add[fform]',fhtml='".addslashes($fhtml)."',fzs='".addslashes($add[fzs])."',myorder=$add[myorder],ftype='$add[ftype]',flen='$add[flen]',fvalue='".addslashes($add[fvalue])."',fformsize='$add[fformsize]' where fid=$fid");
- //更新表单
- ChangeClassForm();
- if($usql&&$sql)
- {
- insert_dolog("fid=".$fid."<br>f=".$add[f]);//操作日志
- printerror("EditFSuccess","info/ListClassF.php");
- }
- else
- {printerror("DbError","history.go(-1)");}
- }
-
- //删除栏目字段
- function DelClassF($add,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"classf");
- $fid=(int)$add['fid'];
- if(empty($fid)){
- printerror("EmptyFid","history.go(-1)");
- }
- $r=$empire->fetch1("select f from {$dbtbpre}enewsclassf where fid='$fid'");
- if(!$r[f]){
- printerror("EmptyFid","history.go(-1)");
- }
- $usql=$empire->query("alter table {$dbtbpre}enewsclassadd drop COLUMN `".$r[f]."`");
- $sql=$empire->query("delete from {$dbtbpre}enewsclassf where fid='$fid'");
- //更新表单表
- ChangeClassForm();
- if($usql&&$sql)
- {
- insert_dolog("fid=".$fid."<br>f=".$r[f]);//操作日志
- printerror("DelFSuccess","info/ListClassF.php");
- }
- else
- {printerror("DbError","history.go(-1)");}
- }
-
- //修改栏目字段顺序
- function EditClassFOrder($fid,$myorder,$userid,$username){
- global $empire,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"classf");
- for($i=0;$i<count($myorder);$i++)
- {
- $fid[$i]=(int)$fid[$i];
- $newmyorder=(int)$myorder[$i];
- $usql=$empire->query("update {$dbtbpre}enewsclassf set myorder=$newmyorder where fid='$fid[$i]'");
- }
- //更新表单表
- ChangeClassForm();
- printerror("EditFOrderSuccess","info/ListClassF.php");
- }
-
- //返回栏目字段
- function ReturnClassAddF($add,$ecms=0){
- global $empire,$dbtbpre;
- $ret_r[0]='';
- $ret_r[1]='';
- $fsql=$empire->query("select f from {$dbtbpre}enewsclassf");
- if($ecms==0)//增加
- {
- while($fr=$empire->fetch($fsql))
- {
- $f=$fr['f'];
- $fval=$add[$f];
- $fval=RepPhpAspJspcode($fval);
- $ret_r[0].=",`".$f."`";
- $ret_r[1].=",'".AddAddsData($fval)."'";
- }
- }
- else//修改
- {
- while($fr=$empire->fetch($fsql))
- {
- $f=$fr['f'];
- $fval=$add[$f];
- $fval=RepPhpAspJspcode($fval);
- $ret_r[0].=",`".$f."`='".AddAddsData($fval)."'";
- }
- }
- return $ret_r;
- }
-
-
- //组合不生成的栏目信息
- function TogNotReClass($changecache=0){
- global $empire,$dbtbpre;
- $sql=$empire->query("select classid,nreclass,nreinfo,nrejs,nottobq from {$dbtbpre}enewsclass where nreclass=1 or nreinfo=1 or nrejs=1 or nottobq=1");
- $nreclass=',';
- $nreinfo=',';
- $nrejs=',';
- $nottobq=',';
- while($r=$empire->fetch($sql))
- {
- if($r['nreclass']==1)
- {
- $nreclass.=$r['classid'].',';
- }
- if($r['nreinfo']==1)
- {
- $nreinfo.=$r['classid'].',';
- }
- if($r['nrejs']==1)
- {
- $nrejs.=$r['classid'].',';
- }
- if($r['nottobq']==1)
- {
- $nottobq.=$r['classid'].',';
- }
- }
- $empire->query("update {$dbtbpre}enewspublic set nreclass='$nreclass',nreinfo='$nreinfo',nrejs='$nrejs',nottobq='$nottobq' limit 1");
- if($changecache==1)
- {
- GetConfig();
- }
- }
-
- //返回投稿权限
- function DoPostClassQAddGroupid($groupid){
- $count=count($groupid);
- if(!$count)
- {
- return '';
- }
- $qg=',';
- for($i=0;$i<$count;$i++)
- {
- $groupid[$i]=(int)$groupid[$i];
- $qg.=$groupid[$i].',';
- }
- return $qg;
- }
-
- //处理栏目提交变量
- function DoPostClassVar($add){
- if(empty($add[classtype])){
- $add[classtype]=".html";
- }
- $add[classname]=addslashes(htmlspecialchars($add[classname]));
- $add[intro]=addslashes(RepPhpAspJspcode($add[intro]));
- $add[classpagekey]=addslashes(RepPhpAspJspcode($add[classpagekey]));
- //过滤字符
- $add[listorder]=RepPostVar2($add[listorder]);
- $add[reorder]=RepPostVar2($add[reorder]);
- //处理变量
- $add[jstempid]=(int)$add['jstempid'];
- $add[bclassid]=(int)$add[bclassid];
- $add[link_num]=(int)$add[link_num];
- $add[newstempid]=(int)$add[newstempid];
- $add[islast]=(int)$add[islast];
- $add[filename]=(int)$add[filename];
- $add[openpl]=(int)$add[openpl];
- $add[openadd]=(int)$add[openadd];
- $add[newline]=(int)$add[newline];
- $add[hotline]=(int)$add[hotline];
- $add[goodline]=(int)$add[goodline];
- $add[groupid]=(int)$add[groupid];
- $add[hotplline]=(int)$add[hotplline];
- $add[modid]=(int)$add[modid];
- $add[checked]=(int)$add[checked];
- $add[firstline]=(int)$add[firstline];
- $add[islist]=(int)$add[islist];
- $add[searchtempid]=(int)$add[searchtempid];
- $add[checkpl]=(int)$add[checkpl];
- $add[down_num]=(int)$add[down_num];
- if(empty($add[down_num])){
- $add[down_num]=1;
- }
- $add[online_num]=(int)$add[online_num];
- if(empty($add[online_num])){
- $add[online_num]=1;
- }
- $add[addinfofen]=(int)$add[addinfofen];
- $add[listdt]=(int)$add[listdt];
- $add[showdt]=(int)$add[showdt];
- $add[maxnum]=(int)$add[maxnum];
- $add[showclass]=(int)$add[showclass];
- $add[checkqadd]=(int)$add[checkqadd];
- $add[qaddlist]=(int)$add[qaddlist];
- $add[qaddgroupid]=DoPostClassQAddGroupid($add[qaddgroupidck]);
- $add[qaddshowkey]=(int)$add[qaddshowkey];
- $add[adminqinfo]=(int)$add[adminqinfo];
- $add[doctime]=(int)$add[doctime];
- $add[nreclass]=(int)$add[nreclass];
- $add[nreinfo]=(int)$add[nreinfo];
- $add[nrejs]=(int)$add[nrejs];
- $add[nottobq]=(int)$add[nottobq];
- $add[lencord]=(int)$add[lencord];
- $add[listtempid]=(int)$add[listtempid];
- $add[dtlisttempid]=(int)$add[dtlisttempid];
- $add[classtempid]=(int)$add[classtempid];
- if(empty($add[bname])){
- $add[bname]=$add[classname];
- }
- $add[myorder]=(int)$add[myorder];
- if($add[infopath]==0)
- {
- $add[ipath]='';
- }
- $add[addreinfo]=(int)$add[addreinfo];
- $add[haddlist]=(int)$add[haddlist];
- $add[sametitle]=(int)$add[sametitle];
- $add[definfovoteid]=(int)$add[definfovoteid];
- $add[qeditchecked]=(int)$add[qeditchecked];
- $add[wapstyleid]=(int)$add[wapstyleid];
- $add[repreinfo]=(int)$add[repreinfo];
- $add[pltempid]=(int)$add[pltempid];
- $add[classtext]=RepPhpAspJspcode($add[classtext]);
- $add[yhid]=(int)$add[yhid];
- $add[wfid]=(int)$add[wfid];
- if($add['islist']==3)
- {
- $add['bdinfoid']=RepPostVar($add['bdinfoid']);
- }
- else
- {
- $add['bdinfoid']='';
- }
- //设置访问权限
- $add[cgroupid]=DoPostClassQAddGroupid($add[cgroupidck]);
- $add[cgtoinfo]=(int)$add[cgtoinfo];
- if($add[cgroupid])
- {
- $add[classtype]='.php';
- if($add[cgtoinfo])
- {
- $add[filetype]='.php';
- }
- }
- else
- {
- $add[cgtoinfo]=0;
- }
- return $add;
- }
-
- //增加外部栏目
- function AddWbClass($add,$userid,$username){
- global $empire,$dbtbpre;
- //操作权限
- CheckLevel($userid,$username,$classid,"class");
- $add=DoPostClassVar($add);
- if(!$add[classname]||!$add[wburl])
- {
- printerror("EmptyWbClass","");
- }
- $add[islast]=0;
- //取得表名
- $tabler=GetModTable($add[modid]);
- $tabler[tid]=(int)$tabler[tid];
- if(empty($add[bclassid]))//主栏目
- {
- $sonclass="";
- $featherclass="";
- }
- else//中级栏目
- {
- //取得上一级父栏目
- $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
- if($r[islast])//是否终极栏目
- {
- printerror("BclassNotLast","");
- }
- if($r[wburl])
- {
- printerror("BclassNotWb","");
- }
- if(empty($r[featherclass]))
- {
- $r[featherclass]="|";
- }
- $featherclass=$r[featherclass].$add[bclassid]."|";
- $sonclass="";
- }
- $sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassid,classname,is_zt,sonclass,lencord,link_num,newstempid,onclick,listtempid,featherclass,islast,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupid,myorder,filename_qz,hotplline,modid,checked,firstline,bname,islist,searchtempid,tid,tbname,maxnum,checkpl,down_num,online_num,listorder,reorder,intro,classimg,jstempid,addinfofen,listdt,showclass,showdt,checkqadd,qaddlist,qaddgroupid,qaddshowkey,adminqinfo,doctime,classpagekey,dtlisttempid,classtempid,nreclass,nreinfo,nrejs,nottobq,ipath,addreinfo,haddlist,sametitle,definfovoteid,wburl,qeditchecked,wapstyleid,repreinfo,pltempid,cgroupid,yhid,wfid,cgtoinfo,bdinfoid) values($add[bclassid],'$add[classname]',0,'$sonclass',$add[lencord],$add[link_num],$add[newstempid],0,$add[listtempid],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupid],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modid],$add[checked],$add[firstline],'$add[bname]',$add[islist],$add[searchtempid],$tabler[tid],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[listorder]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempid],$add[addinfofen],$add[listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddlist],'$add[qaddgroupid]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtlisttempid]','$add[classtempid]',$add[nreclass],$add[nreinfo],$add[nrejs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddlist],$add[sametitle],$add[definfovoteid],'$add[wburl]',$add[qeditchecked],$add[wapstyleid],'$add[repreinfo]','$add[pltempid]','$add[cgroupid]','$add[yhid]','$add[wfid]','$add[cgtoinfo]','$add[bdinfoid]');");
- $lastid=$empire->lastid();
- //副表
- $ret_cr=ReturnClassAddF($add,0);
- $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
- GetClass();
- DelListEnews();//删除缓存文件
- if($sql)
- {
- insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
- printerror("AddClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
- }
- else
- {
- printerror("DbError","");
- }
- }
-
- //增加栏目
- function AddClass($add,$userid,$username){
- global $empire,$dbtbpre;
- //增加外部栏目
- if($add[ecmsclasstype])
- {
- AddWbClass($add,$userid,$username);
- }
- $add[classpath]=trim($add[classpath]);
- if(!$add[classname]||!$add[classpath]||!$add[modid])
- {
- printerror("EmptyClass","");
- }
- if($add[islast]&&(!$add[newstempid]||!$add[listtempid]))
- {
- printerror("LastMustChange","");
- }
- //操作权限
- CheckLevel($userid,$username,$classid,"class");
- $add=DoPostClassVar($add);
- //目录已存在
- if(strstr($add[classpath],".")||strstr($add[classpath],"/")||strstr($add[classpath],"\\"))
- {
- printerror("badpath","");
- }
- $classpath=$add[pripath].$add[classpath];
- if(file_exists("../../".$classpath))
- {
- printerror("ReClasspath","");
- }
- //取得表名
- $tabler=GetModTable($add[modid]);
- $tabler[tid]=(int)$tabler[tid];
- //增加大栏目
- if(!$add[islast])
- {
- if(empty($add[bclassid]))//主栏目
- {
- $sonclass="";
- $featherclass="";
- }
- else//中级栏目
- {
- //取得上一级父栏目
- $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
- if($r[islast])//是否终极栏目
- {
- printerror("BclassNotLast","");
- }
- if($r[wburl])
- {
- printerror("BclassNotWb","");
- }
- if(empty($r[featherclass]))
- {
- $r[featherclass]="|";
- }
- $featherclass=$r[featherclass].$add[bclassid]."|";
- $sonclass="";
- }
- //建立目录
- CreateClassPath($classpath);
- $sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassid,classname,is_zt,sonclass,lencord,link_num,newstempid,onclick,listtempid,featherclass,islast,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupid,myorder,filename_qz,hotplline,modid,checked,firstline,bname,islist,searchtempid,tid,tbname,maxnum,checkpl,down_num,online_num,listorder,reorder,intro,classimg,jstempid,addinfofen,listdt,showclass,showdt,checkqadd,qaddlist,qaddgroupid,qaddshowkey,adminqinfo,doctime,classpagekey,dtlisttempid,classtempid,nreclass,nreinfo,nrejs,nottobq,ipath,addreinfo,haddlist,sametitle,definfovoteid,wburl,qeditchecked,wapstyleid,repreinfo,pltempid,cgroupid,yhid,wfid,cgtoinfo,bdinfoid) values($add[bclassid],'$add[classname]',0,'$sonclass',$add[lencord],$add[link_num],$add[newstempid],0,$add[listtempid],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupid],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modid],$add[checked],$add[firstline],'$add[bname]',$add[islist],$add[searchtempid],$tabler[tid],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[listorder]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempid],$add[addinfofen],$add[listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddlist],'$add[qaddgroupid]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtlisttempid]','$add[classtempid]',$add[nreclass],$add[nreinfo],$add[nrejs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddlist],$add[sametitle],$add[definfovoteid],'',$add[qeditchecked],$add[wapstyleid],'$add[repreinfo]','$add[pltempid]','$add[cgroupid]','$add[yhid]','$add[wfid]','$add[cgtoinfo]','$add[bdinfoid]');");
- $lastid=$empire->lastid();
- //副表
- $ret_cr=ReturnClassAddF($add,0);
- $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
- TogNotReClass(1);
- GetClass();
- if($add[islist]==0||$add[islist]==2)
- {
- $classtemp=$add[islist]==2?GetClassText($lastid):GetClassTemp($add['classtempid']);
- NewsBq($lastid,$classtemp,0,1);
- }
- elseif($add[islist]==3)//栏目绑定信息
- {
- ReClassBdInfo($lastid);
- }
- DelListEnews();//删除缓存文件
- GetSearch($add[modid]);//更新缓存
- if($sql){
- insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
- printerror("AddClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
- }
- else{
- printerror("DbError","");
- }
- }
- //增加终级栏目
- else
- {
- //文件前缀
- $add[filename_qz]=RepFilenameQz($add[filename_qz]);
- if(empty($add[bclassid]))//主类别为终级栏目时
- {
- $sonclass="";
- $featherclass="";
- }
- else//子栏目
- {
- //取得上一级父栏目
- $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
- //是否终极类别
- if($r[islast])
- {
- printerror("BclassNotLast","");
- }
- if($r[wburl])
- {
- printerror("BclassNotWb","");
- }
- if(empty($r[featherclass])){
- $r[featherclass]="|";
- }
- $featherclass=$r[featherclass].$add[bclassid]."|";
- $sonclass="";
- }
- //建立栏目目录
- CreateClassPath($classpath);
- $sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassid,classname,sonclass,is_zt,lencord,link_num,newstempid,onclick,listtempid,featherclass,islast,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupid,myorder,filename_qz,hotplline,modid,checked,firstline,bname,islist,searchtempid,tid,tbname,maxnum,checkpl,down_num,online_num,listorder,reorder,intro,classimg,jstempid,addinfofen,listdt,showclass,showdt,checkqadd,qaddlist,qaddgroupid,qaddshowkey,adminqinfo,doctime,classpagekey,dtlisttempid,classtempid,nreclass,nreinfo,nrejs,nottobq,ipath,addreinfo,haddlist,sametitle,definfovoteid,wburl,qeditchecked,wapstyleid,repreinfo,pltempid,cgroupid,yhid,wfid,cgtoinfo,bdinfoid) values($add[bclassid],'$add[classname]','$sonclass',0,$add[lencord],$add[link_num],$add[newstempid],0,$add[listtempid],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupid],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modid],$add[checked],$add[firstline],'$add[bname]',$add[islist],$add[searchtempid],$tabler[tid],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[listorder]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempid],$add[addinfofen],$add[listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddlist],'$add[qaddgroupid]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtlisttempid]','$add[classtempid]',$add[nreclass],$add[nreinfo],$add[nrejs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddlist],$add[sametitle],$add[definfovoteid],'',$add[qeditchecked],$add[wapstyleid],'$add[repreinfo]','$add[pltempid]','$add[cgroupid]','$add[yhid]','$add[wfid]','$add[cgtoinfo]','$add[bdinfoid]');");
- $lastid=$empire->lastid();
- //副表
- $ret_cr=ReturnClassAddF($add,0);
- $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
- //修改父栏目的子栏目
- if($add[bclassid])
- {
- $b_r=$empire->fetch1("select sonclass,featherclass from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
- if(empty($b_r[sonclass]))
- {
- $b_r[sonclass]="|";
- }
- $new_sonclass=$b_r[sonclass].$lastid."|";
- $update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$add[bclassid]'");
- //更改父类别的父栏目的子栏目
- $where=ReturnClass($b_r[featherclass]);
- if(empty($where)){
- $where="classid=0";
- }
- $bsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
- while($br=$empire->fetch($bsql))
- {
- if(empty($br[sonclass]))
- {
- $br[sonclass]="|";
- }
- $new_sonclass=$br[sonclass].$lastid."|";
- $update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$br[classid]'");
- }
- }
- DelListEnews();//删除缓存文件
- TogNotReClass(1);
- GetClass();
- GetSearch($add[modid]);//更新缓存
- if($sql){
- insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
- printerror("AddLastClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
- }
- …
Large files files are truncated, but you can click here to view the full file