12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133 |
- <?php
- //批量更新相关链接
- function ChangeInfoOtherLink($start,$classid,$from,$retype,$startday,$endday,$startid,$endid,$tbname,$userid,$username){
- global $empire,$public_r,$class_r,$fun_r,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"changedata");
- $start=(int)$start;
- $tbname=RepPostVar($tbname);
- if(empty($tbname)||!eCheckTbname($tbname))
- {
- printerror("ErrorUrl","history.go(-1)");
- }
- //按栏目刷新
- $classid=(int)$classid;
- if($classid)
- {
- if(empty($class_r[$classid][islast]))//父栏目
- {
- $where=ReturnClass($class_r[$classid][sonclass]);
- }
- else//终极栏目
- {
- $where="classid='$classid'";
- }
- $add1=" and (".$where.")";
- }
- //按ID刷新
- if($retype)
- {
- $startid=(int)$startid;
- $endid=(int)$endid;
- if($endid)
- {
- $add1.=" and id>=$startid and id<=$endid";
- }
- }
- else
- {
- $startday=RepPostVar($startday);
- $endday=RepPostVar($endday);
- if($startday&&$endday)
- {
- $add1.=" and truetime>=".to_time($startday." 00:00:00")." and truetime<=".to_time($endday." 23:59:59");
- }
- }
- $b=0;
- $sql=$empire->query("select id,classid,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[infolinknum]);
- while($r=$empire->fetch($sql))
- {
- $b=1;
- $new_start=$r[id];
- //手动相关链接
- $pubid=ReturnInfoPubid($r['classid'],$r['id']);
- $infopr=$empire->fetch1("select diyotherlink from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
- if($infopr['diyotherlink'])
- {
- continue;
- }
- //返回表
- $infotb=ReturnInfoMainTbname($tbname,$r['checked']);
- $infor=$empire->fetch1("select stb,keyboard from ".$infotb." where id='$r[id]' limit 1");
- //返回表信息
- $infodatatb=ReturnInfoDataTbname($tbname,$r['checked'],$infor['stb']);
- $newkeyid=GetKeyid($infor[keyboard],$r[classid],$r[id],$class_r[$r[classid]][link_num]);
- $usql=$empire->query("update ".$infodatatb." set keyid='$newkeyid' where id='$r[id]' limit 1");
- }
- if(empty($b))
- {
- insert_dolog("");//操作日志
- printerror("ChangeInfoLinkSuccess",$from);
- }
- echo $fun_r[OneChangeInfoLinkSuccess]."(ID:<font color=red><b>".$new_start."</b></font>)<script>self.location.href='ecmscom.php?enews=ChangeInfoOtherLink&tbname=$tbname&classid=$classid&start=$new_start&from=".urlencode($from)."&retype=$retype&startday=$startday&endday=$endday&startid=$startid&endid=$endid".hReturnEcmsHashStrHref(0)."';</script>";
- exit();
- }
- //检测目录已存在
- function CheckPath($classpath){
- global $fun_r;
- if(empty($classpath)){
- echo $fun_r['EmptyPath'];
- }
- else{
- if(file_exists("../../".$classpath)){
- echo $fun_r['RePath'];
- }
- else{
- echo $fun_r['PathNot'];
- }
- }
- exit();
- }
- //增加自定义页面
- function AddUserpage($add,$userid,$username){
- global $empire,$dbtbpre;
- //操作权限
- CheckLevel($userid,$username,$classid,"userpage");
- $classid=(int)$add[classid];
- $title=$add['title'];
- $path=$add['path'];
- $pagetext=$add['pagetext'];
- if(empty($title)||empty($path))
- {
- printerror("EmptyUserpagePath","history.go(-1)");
- }
- $title=hRepPostStr($title,1);
- $path=hRepPostStr($path,1);
- $pagetext=RepPhpAspJspcode($pagetext);
- $pagetitle=RepPhpAspJspcode($add[pagetitle]);
- $pagekeywords=RepPhpAspJspcode($add[pagekeywords]);
- $pagedescription=RepPhpAspJspcode($add[pagedescription]);
- $tempid=(int)$add['tempid'];
- $gid=(int)$add['gid'];
- $sql=$empire->query("insert into {$dbtbpre}enewspage(title,path,pagetext,classid,pagetitle,pagekeywords,pagedescription,tempid) values('$title','$path','".eaddslashes2($pagetext)."','$classid','".eaddslashes($pagetitle)."','".eaddslashes($pagekeywords)."','".eaddslashes($pagedescription)."','$tempid');");
- $id=$empire->lastid();
- ReUserpage($id,$pagetext,$path,$title,$pagetitle,$pagekeywords,$pagedescription,$tempid);
- if($sql)
- {
- //操作日志
- insert_dolog("id=$id&title=$title");
- printerror("AddUserpageSuccess","template/AddPage.php?enews=AddUserpage&gid=$gid&ChangePagemod=$add[pagemod]".hReturnEcmsHashStrHref2(0));
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //修改自定义页面
- function EditUserpage($add,$userid,$username){
- global $empire,$dbtbpre;
- //操作权限
- CheckLevel($userid,$username,$classid,"userpage");
- $id=(int)$add['id'];
- $classid=(int)$add[classid];
- $title=$add['title'];
- $path=$add['path'];
- $pagetext=$add['pagetext'];
- if(!$id||empty($title)||empty($path))
- {
- printerror("EmptyUserpagePath","history.go(-1)");
- }
- //改变地址
- if($add['oldpath']<>$path)
- {
- DelFiletext($add['oldpath']);
- }
- $title=hRepPostStr($title,1);
- $path=hRepPostStr($path,1);
- $pagetext=RepPhpAspJspcode($pagetext);
- $pagetitle=RepPhpAspJspcode($add[pagetitle]);
- $pagekeywords=RepPhpAspJspcode($add[pagekeywords]);
- $pagedescription=RepPhpAspJspcode($add[pagedescription]);
- $tempid=(int)$add['tempid'];
- $gid=(int)$add['gid'];
- $sql=$empire->query("update {$dbtbpre}enewspage set title='$title',path='$path',pagetext='".eaddslashes2($pagetext)."',classid='$classid',pagetitle='".eaddslashes($pagetitle)."',pagekeywords='".eaddslashes($pagekeywords)."',pagedescription='".eaddslashes($pagedescription)."',tempid='$tempid' where id='$id'");
- ReUserpage($id,$pagetext,$path,$title,$pagetitle,$pagekeywords,$pagedescription,$tempid);
- if($sql)
- {
- //操作日志
- insert_dolog("id=$id&title=$title");
- printerror("EditUserpageSuccess","template/ListPage.php?classid=$add[cid]&gid=$gid".hReturnEcmsHashStrHref2(0));
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //删除自定义页面
- function DelUserpage($id,$cid,$userid,$username){
- global $empire,$dbtbpre;
- //操作权限
- CheckLevel($userid,$username,$classid,"userpage");
- $id=(int)$id;
- if(empty($id))
- {
- printerror("EmptyDelUserpageid","history.go(-1)");
- }
- $gid=(int)$_GET['gid'];
- $r=$empire->fetch1("select title,id,path from {$dbtbpre}enewspage where id='$id'");
- if(empty($r['id']))
- {
- printerror("NotDelUserpageid","history.go(-1)");
- }
- $sql=$empire->query("delete from {$dbtbpre}enewspage where id='$id'");
- DelFiletext($r['path']);
- //moreportdo
- $eautodofile=str_replace('../../','',$r['path']);
- if($eautodofile)
- {
- $eautodofname='delfile|'.$eautodofile.'||';
- eAutodo_AddDo('eDelFileUserpage',0,0,0,0,0,$eautodofname);
- }
- if($sql)
- {
- //操作日志
- insert_dolog("id=$id&title=$r[title]");
- printerror("DelUserpageSuccess","template/ListPage.php?classid=$cid&gid=$gid".hReturnEcmsHashStrHref2(0));
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //刷新自定义页面
- function DoReUserpage($add,$userid,$username){
- global $empire,$dbtbpre;
- //操作权限
- CheckLevel($userid,$username,$classid,"userpage");
- $id=$add['id'];
- $count=count($id);
- if(!$count)
- {
- printerror("EmptyReUserpageid","history.go(-1)");
- }
- for($i=0;$i<$count;$i++)
- {
- $id[$i]=(int)$id[$i];
- if(empty($id[$i]))
- {
- continue;
- }
- $ur=$empire->fetch1("select id,path,pagetext,title,pagetitle,pagekeywords,pagedescription,tempid from {$dbtbpre}enewspage where id='".$id[$i]."'");
- ReUserpage($ur[id],$ur[pagetext],$ur[path],$ur[title],$ur[pagetitle],$ur[pagekeywords],$ur[pagedescription],$ur[tempid]);
- }
- //操作日志
- insert_dolog("");
- printerror("DoReUserpageSuccess",EcmsGetReturnUrl());
- }
- //批量替换字段值
- function DoRepNewstext($start,$oldword,$newword,$field,$classid,$tid,$tbname,$over,$dozz,$dotxt,$userid,$username){
- global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$emod_r;
- $tbname=RepPostVar($tbname);
- $field=RepPostVar($field);
- $tid=(int)$tid;
- $dotype=(int)$_POST['dotype'];
- $classid=(int)$classid;
- if(!$field||empty($tbname)||!$tid)
- {
- printerror("FailCX","history.go(-1)");
- }
- if($dotype==0&&strlen($oldword)==0)
- {
- printerror("FailCX","history.go(-1)");
- }
- CheckLevel($userid,$username,$classid,"repnewstext");//验证权限
- //变量替换
- $postoldword=ClearAddsData($oldword);
- $postnewword=ClearAddsData($newword);
- //替换条件
- if($classid)//按栏目替换
- {
- if(empty($class_r[$classid][islast]))//中级栏目
- {
- $where=ReturnClass($class_r[$classid][sonclass]);
- }
- else//终极栏目
- {
- $where="classid='$classid'";
- }
- $add1=" and (".$where.")";
- $add2=" where (".$where.")";
- }
- $fr=$empire->fetch1("select tid,savetxt,tbdataf from {$dbtbpre}enewsf where tbname='$tbname' and f='$field' limit 1");
- //系统字段
- $specialdatafield=',keyid,dokey,newstempid,closepl,haveaddfen,infotags,';
- if(!$fr['tid']&&stristr($specialdatafield,','.$field.','))
- {
- $fr['tbdataf']=1;
- }
- //覆盖方式
- if($dotype==1)
- {
- $repoldword=addslashes($oldword);
- $repnewword=addslashes($newword);
- if($over==1)//完全替换
- {
- if(empty($add2))
- {
- $and=" where ";
- }
- else
- {
- $and=" and ";
- }
- $add2.=$and.$field."='".$repoldword."'";
- }
- if($fr['tbdataf'])//副表
- {
- //已审核
- $tbr=$empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='$tbname' limit 1");
- if($tbr['datatbs'])
- {
- $dtbr=explode(',',$tbr['datatbs']);
- $count=count($dtbr);
- for($i=1;$i<$count-1;$i++)
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$dtbr[$i]." set ".$field."='$repnewword'".$add2);
- }
- }
- //未审核
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check_data set ".$field."='$repnewword'".$add2);
- }
- else//主表
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$field."='$repnewword'".$add2);
- //未审核
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check set ".$field."='$repnewword'".$add2);
- }
- //替换完毕
- insert_dolog("tbname=".$tbname."&field=".$field."&dotype=1<br>oldword=".$oldword."<br>newword=".$newword);//操作日志
- printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0));
- }
- //存文本替换
- elseif($fr['savetxt'])
- {
- $repoldword=addslashes($postoldword);
- $repnewword=addslashes($postnewword);
- //字段
- $selectf=$fr['tbdataf']?',stb':','.$field;
- $fieldform="<input type='hidden' name='field' value='".$field."'>";
- if(empty($public_r[dorepnum]))
- {
- $public_r[dorepnum]=600;
- }
- $start=(int)$start;
- $b=0;
- $sql=$empire->query("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[dorepnum]);
- while($r=$empire->fetch($sql))
- {
- $b=1;
- $newstart=$r[id];
- //返回表
- $infotb=ReturnInfoMainTbname($tbname,$r['checked']);
- //主表
- $infor=$empire->fetch1("select isurl".$selectf." from ".$infotb." where id='$r[id]' limit 1");
- if($infor['isurl'])
- {
- continue;
- }
- //副表
- if($fr['tbdataf'])
- {
- //返回表信息
- $infodatatb=ReturnInfoDataTbname($tbname,$r['checked'],$infor['stb']);
- $finfor=$empire->fetch1("select ".$field." from ".$infodatatb." where id='$r[id]' limit 1");
- $infor[$field]=$finfor[$field];
- }
- $value=GetTxtFieldText($infor[$field]);
- if(empty($value))
- {
- continue;
- }
- if($dozz==1)//正则
- {
- $newvalue=DoRepNewstextZz($repoldword,$repnewword,$value);//正则替换
- }
- else//普通
- {
- if(!stristr($value,$repoldword))
- {
- continue;
- }
- $newvalue=str_replace($repoldword,$repnewword,$value);
- }
- EditTxtFieldText($infor[$field],$newvalue);
- }
- //替换完毕
- if(empty($b))
- {
- insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志
- printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0));
- }
- EchoRepFieldForm($tid,$tbname,$over,$dozz,$dotxt,$newstart,$fieldform,$classid,$postoldword,$postnewword);
- }
- //正则替换
- elseif($dozz==1)
- {
- //字段
- $selectf=$fr['tbdataf']?',stb':','.$field;
- $fieldform="<input type='hidden' name='field' value='".$field."'>";
- if(empty($public_r[dorepnum]))
- {
- $public_r[dorepnum]=600;
- }
- $start=(int)$start;
- $b=0;
- $sql=$empire->query("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[dorepnum]);
- while($r=$empire->fetch($sql))
- {
- $b=1;
- $newstart=$r[id];
- //返回表
- $infotb=ReturnInfoMainTbname($tbname,$r['checked']);
- //主表
- $infor=$empire->fetch1("select isurl".$selectf." from ".$infotb." where id='$r[id]' limit 1");
- if($infor['isurl'])
- {
- continue;
- }
- if($fr['tbdataf'])//副表
- {
- //返回表信息
- $infodatatb=ReturnInfoDataTbname($tbname,$r['checked'],$infor['stb']);
- $finfor=$empire->fetch1("select ".$field." from ".$infodatatb." where id='$r[id]' limit 1");
- $newvalue=DoRepNewstextZz($oldword,$newword,stripSlashes($finfor[$field]));//正则替换
- $empire->query("update ".$infodatatb." set ".$field."='".addslashes($newvalue)."' where id='$r[id]'");
- }
- else//主表
- {
- $newvalue=DoRepNewstextZz($oldword,$newword,stripSlashes($infor[$field]));//正则替换
- $empire->query("update ".$infotb." set ".$field."='".addslashes($newvalue)."' where id='$r[id]'");
- }
- }
- //替换完毕
- if(empty($b))
- {
- insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志
- printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0));
- }
- EchoRepFieldForm($tid,$tbname,$over,$dozz,$dotxt,$newstart,$fieldform,$classid,$postoldword,$postnewword);
- }
- //普通替换
- else
- {
- $repoldword=eaddslashes2($oldword);
- $repnewword=eaddslashes2($newword);
- if($over==1)//完全替换
- {
- if(empty($add2))
- {
- $and=" where ";
- }
- else
- {
- $and=" and ";
- }
- $add2.=$and.$field."='".$repoldword."'";
- }
- if($fr['tbdataf'])//副表
- {
- //已审核
- $tbr=$empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='$tbname' limit 1");
- if($tbr['datatbs'])
- {
- $dtbr=explode(',',$tbr['datatbs']);
- $count=count($dtbr);
- for($i=1;$i<$count-1;$i++)
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$dtbr[$i]." set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2);
- }
- }
- //未审核
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check_data set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2);
- }
- else//主表
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2);
- //未审核
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2);
- }
- //替换完毕
- insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志
- printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0));
- }
- }
- //正则替换信息
- function DoRepNewstextZz($oldword,$newword,$text){
- $zztext=RepInfoZZ($oldword,"empire-cms-wm.chief-phome",0);
- $text=preg_replace($zztext,$newword,$text);
- return $text;
- }
- //输出批量替换字段表单
- function EchoRepFieldForm($tid,$tbname,$over,$dozz,$dotxt,$newstart,$fieldform,$classid,$oldword,$newword){
- global $fun_r;
- $dotype=(int)$_POST['dotype'];
- ?>
- <?=$fun_r['RepOneNewstextSuccess']?>(ID:<font color=red><b><?=$newstart?></b></font>)
- <form name="RepFieldForm" method="post" action="ecmscom.php">
- <?=hReturnEcmsHashStrForm(0)?>
- <input type=hidden name="enews" value="DoRepNewstext">
- <input type=hidden name="tid" value="<?=$tid?>">
- <input type=hidden name="tbname" value="<?=$tbname?>">
- <input type=hidden name="over" value="<?=$over?>">
- <input type=hidden name="dozz" value="<?=$dozz?>">
- <input type=hidden name="dotxt" value="<?=$dotxt?>">
- <input type=hidden name="dotype" value="<?=$dotype?>">
- <input type=hidden name="start" value="<?=$newstart?>">
- <?=$fieldform?>
- <input type=hidden name="classid" value="<?=$classid?>">
- <input type=hidden name="oldword" value="<?=ehtmlspecialchars($oldword)?>">
- <input type=hidden name="newword" value="<?=ehtmlspecialchars($newword)?>">
- </form>
- <script>
- document.RepFieldForm.submit();
- </script>
- <?
- exit();
- }
- //返回类别管理操作信息
- function ReturnDoclassVar($ecms){
- global $dbtbpre;
- //标签模板分类
- if($ecms=="bqtemp")
- {
- $r['tbname']=$dbtbpre."enewsbqtempclass";
- $r['mess']="Bqtemp";
- $r['thelevel']="template";
- $r['returnpage']="template/BqtempClass.php";
- }
- //用户自定义页面分类
- elseif($ecms=="page")
- {
- $r['tbname']=$dbtbpre."enewspageclass";
- $r['mess']="Page";
- $r['thelevel']="userpage";
- $r['returnpage']="template/PageClass.php";
- }
- //公共模板变量分类
- elseif($ecms=="tempvar")
- {
- $r['tbname']=$dbtbpre."enewstempvarclass";
- $r['mess']="Tempvar";
- $r['thelevel']="tempvar";
- $r['returnpage']="template/TempvarClass.php";
- }
- //列表模板分类
- elseif($ecms=="listtemp")
- {
- $r['tbname']=$dbtbpre."enewslisttempclass";
- $r['mess']="Listtemp";
- $r['thelevel']="template";
- $r['returnpage']="template/ListtempClass.php";
- }
- //内容模板分类
- elseif($ecms=="newstemp")
- {
- $r['tbname']=$dbtbpre."enewsnewstempclass";
- $r['mess']="Newstemp";
- $r['thelevel']="template";
- $r['returnpage']="template/NewstempClass.php";
- }
- //搜索模板分类
- elseif($ecms=="searchtemp")
- {
- $r['tbname']=$dbtbpre."enewssearchtempclass";
- $r['mess']="Searchtemp";
- $r['thelevel']="template";
- $r['returnpage']="template/SearchtempClass.php";
- }
- //标签分类
- elseif($ecms=="bq")
- {
- $r['tbname']=$dbtbpre."enewsbqclass";
- $r['mess']="Bq";
- $r['thelevel']="bq";
- $r['returnpage']="template/BqClass.php";
- }
- //JS模板
- elseif($ecms=="jstemp")
- {
- $r['tbname']=$dbtbpre."enewsjstempclass";
- $r['mess']="Jstemp";
- $r['thelevel']="template";
- $r['returnpage']="template/JsTempClass.php";
- }
- //专题
- elseif($ecms=="zt")
- {
- $r['tbname']=$dbtbpre."enewsztclass";
- $r['mess']="Ztclass";
- $r['thelevel']="zt";
- $r['returnpage']="special/ListZtClass.php";
- }
- //友情链接
- elseif($ecms=="link")
- {
- $r['tbname']=$dbtbpre."enewslinkclass";
- $r['mess']="Linkclass";
- $r['thelevel']="link";
- $r['returnpage']="tool/LinkClass.php";
- }
- //单页模板
- elseif($ecms=="classtemp")
- {
- $r['tbname']=$dbtbpre."enewsclasstempclass";
- $r['mess']="Classtemp";
- $r['thelevel']="template";
- $r['returnpage']="template/ClassTempClass.php";
- }
- //错误报告
- elseif($ecms=="error")
- {
- $r['tbname']=$dbtbpre."enewserrorclass";
- $r['mess']="Error";
- $r['thelevel']="downerror";
- $r['returnpage']="DownSys/ErrorClass.php";
- }
- //TAGS
- elseif($ecms=="tags")
- {
- $r['tbname']=$dbtbpre."enewstagsclass";
- $r['mess']="Tags";
- $r['thelevel']="tags";
- $r['returnpage']="tags/TagsClass.php";
- }
- //用户自定义列表
- elseif($ecms=="userlist")
- {
- $r['tbname']=$dbtbpre."enewsuserlistclass";
- $r['mess']="Userlist";
- $r['thelevel']="userlist";
- $r['returnpage']="other/UserlistClass.php";
- }
- //用户自定义JS
- elseif($ecms=="userjs")
- {
- $r['tbname']=$dbtbpre."enewsuserjsclass";
- $r['mess']="Userjs";
- $r['thelevel']="userjs";
- $r['returnpage']="other/UserjsClass.php";
- }
- else
- {
- printerror("ErrorUrl","history.go(-1)");
- }
- $r['returnpage'].=hReturnEcmsHashStrHref2(1);
- return $r;
- }
- //增加分类
- function AddThisClass($add,$userid,$username){
- global $empire,$dbtbpre;
- //取得返回信息
- $thisr=ReturnDoclassVar($add['doing']);
- if(!$add['classname'])
- {
- printerror("Empty".$thisr['mess']."Classname","history.go(-1)");
- }
- //验证权限
- CheckLevel($userid,$username,$classid,$thisr['thelevel']);
- $add['classname']=hRepPostStr($add['classname'],1);
- $sql=$empire->query("insert into ".$thisr['tbname']."(classname) values('$add[classname]');");
- if($sql)
- {
- $lastid=$empire->lastid();
- //操作日志
- insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);
- printerror("Add".$thisr['mess']."ClassSuccess",$thisr['returnpage']);
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //修改分类
- function EditThisClass($add,$userid,$username){
- global $empire,$dbtbpre;
- //取得返回信息
- $thisr=ReturnDoclassVar($add['doing']);
- $classid=(int)$add['classid'];
- if(!$add['classname']||!$classid)
- {
- printerror("Empty".$thisr['mess']."Classname","history.go(-1)");
- }
- //验证权限
- CheckLevel($userid,$username,$classid,$thisr['thelevel']);
- $add['classname']=hRepPostStr($add['classname'],1);
- $sql=$empire->query("update ".$thisr['tbname']." set classname='$add[classname]' where classid='$classid'");
- if($sql)
- {
- //操作日志
- insert_dolog("classid=".$classid."<br>classname=".$add[classname]);
- printerror("Edit".$thisr['mess']."ClassSuccess",$thisr['returnpage']);
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //删除分类
- function DelThisClass($classid,$doing,$userid,$username){
- global $empire,$dbtbpre;
- //取得返回信息
- $thisr=ReturnDoclassVar($doing);
- $classid=(int)$classid;
- if(!$classid)
- {
- printerror("NotChange".$thisr['mess']."Classid","history.go(-1)");
- }
- //验证权限
- CheckLevel($userid,$username,$classid,$thisr['thelevel']);
- $r=$empire->fetch1("select classname from ".$thisr['tbname']." where classid=$classid");
- $sql=$empire->query("delete from ".$thisr['tbname']." where classid=$classid");
- if($sql)
- {
- //操作日志
- insert_dolog("classid=".$classid."<br>classname=".$r[classname]);
- printerror("Del".$thisr['mess']."ClassSuccess",$thisr['returnpage']);
- }
- else
- {
- printerror("DbError","history.go(-1)");
- }
- }
- //批量替换地址权限
- function RepDownLevel($add,$userid,$username){
- global $empire,$public_r,$class_r,$fun_r,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"repdownpath");
- $tbname=RepPostVar($add['tbname']);
- if(!$tbname||!($add[downpath]||$add[onlinepath])||!($add[dogroup]||$add[dofen]||$add[doqz]||$add[dopath]||$add[doname]))
- {printerror("EmptyRepDownLevel","history.go(-1)");}
- $start=(int)$add['start'];
- //转换变量
- if(empty($add[oldgroupid]))
- {
- $add[oldgroupid]=0;
- }
- if(empty($add[newgroupid]))
- {
- $add[newgroupid]=0;
- }
- if(empty($add[oldfen]))
- {
- $add[oldfen]=0;
- }
- if(empty($add[newfen]))
- {
- $add[newfen]=0;
- }
- if(empty($add[oldqz]))
- {
- $add[oldqz]=0;
- }
- if(empty($add[newqz]))
- {
- $add[newqz]=0;
- }
- //字段
- $field='';
- $sfield='';
- if($add['downpath'])
- {
- $field.=",downpath";
- $dh=",";
- $checkf='downpath';
- }
- if($add['onlinepath'])
- {
- $field.=",onlinepath";
- $checkf='onlinepath';
- }
- $fr=$empire->fetch1("select tid,savetxt,tbdataf from {$dbtbpre}enewsf where tbname='$tbname' and f='$checkf' limit 1");
- if($fr['tbdataf'])//副表
- {
- $sfield=$field;
- $field='';
- }
- $wheresql="";
- //栏目
- $classid=(int)$add['classid'];
- if($classid)
- {
- if(empty($class_r[$classid][islast]))//中级栏目
- {
- $where=ReturnClass($class_r[$classid][sonclass]);
- }
- else//终极栏目
- {
- $where="classid='$classid'";
- }
- $wheresql.=" and (".$where.")";
- }
- //附加sql语句
- $query=$add['query'];
- if($query)
- {
- //取除adds
- $query=ClearAddsData($query);
- $wheresql.=" and (".$query.")";
- }
- $update="";
- $b=0;
- $sql=$empire->query("select id,stb".$field." from {$dbtbpre}ecms_".$tbname." where id>$start".$wheresql." order by id limit ".$public_r['dorepdlevelnum']);
- while($r=$empire->fetch($sql))
- {
- $b=1;
- $newstart=$r[id];
- //副表
- if($fr['tbdataf'])
- {
- $finfor=$empire->fetch1("select id".$sfield." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$r[id]'");
- $r['downpath']=$finfor['downpath'];
- $r['onlinepath']=$finfor['onlinepath'];
- }
- $update='';
- //下载地址
- $newdownpath="";
- if($add[downpath])
- {
- $newdownpath=RepDownLevelStrip($r[downpath],$add);
- $update="downpath='".addslashes($newdownpath)."'";
- }
- //在线地址
- $newonlinepath="";
- if($add[onlinepath])
- {
- $newonlinepath=RepDownLevelStrip($r[onlinepath],$add);
- $update.=$dh."onlinepath='".addslashes($newonlinepath)."'";
- }
- //副表
- if($fr['tbdataf'])
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." set ".$update." where id='$r[id]'");
- }
- else
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$update." where id='$r[id]'");
- }
- }
- //替换完毕
- if(empty($b))
- {
- //未审核
- $sql=$empire->query("select id,stb".$field." from {$dbtbpre}ecms_".$tbname."_check".($wheresql?' where '.substr($wheresql,5):''));
- while($r=$empire->fetch($sql))
- {
- //副表
- if($fr['tbdataf'])
- {
- $finfor=$empire->fetch1("select id".$sfield." from {$dbtbpre}ecms_".$tbname."_check_data where id='$r[id]' limit 1");
- $r['downpath']=$finfor['downpath'];
- $r['onlinepath']=$finfor['onlinepath'];
- }
- $update='';
- //下载地址
- $newdownpath="";
- if($add[downpath])
- {
- $newdownpath=RepDownLevelStrip($r[downpath],$add);
- $update="downpath='".addslashes($newdownpath)."'";
- }
- //在线地址
- $newonlinepath="";
- if($add[onlinepath])
- {
- $newonlinepath=RepDownLevelStrip($r[onlinepath],$add);
- $update.=$dh."onlinepath='".addslashes($newonlinepath)."'";
- }
- //副表
- if($fr['tbdataf'])
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check_data set ".$update." where id='$r[id]'");
- }
- else
- {
- $empire->query("update {$dbtbpre}ecms_".$tbname."_check set ".$update." where id='$r[id]'");
- }
- }
- //操作日志
- insert_dolog("tbname=$tbname<br>downpath=$add[downpath]<br>onlinepath=$add[onlinepath]");
- printerror("RepDownLevelSuccess","DownSys/RepDownLevel.php".hReturnEcmsHashStrHref2(1));
- }
- EchoRepDownLevelForm($add,$newstart);
- }
- //替换权限处理函数
- function RepDownLevelStrip($downpath,$add){
- if(empty($downpath))
- {
- return "";
- }
- $add[oldpath]=ClearAddsData($add[oldpath]);
- $add[newpath]=ClearAddsData($add[newpath]);
- $add[oldname]=ClearAddsData($add[oldname]);
- $add[newname]=ClearAddsData($add[newname]);
- $f_exp="::::::";
- $r_exp="\r\n";
- $newdownpath="";
- $downpath=stripSlashes($downpath);
- $down_rr=explode($r_exp,$downpath);
- $count=count($down_rr);
- for($i=0;$i<$count;$i++)
- {
- $down_fr=explode($f_exp,$down_rr[$i]);
- //权限替换
- $d_groupid=(int)$down_fr[2];
- if($add[dogroup])
- {
- if($add[oldgroupid]=="no")//不设置
- {
- $d_groupid=$add[newgroupid];
- }
- else//设置
- {
- if($d_groupid==$add[oldgroupid])
- {
- $d_groupid=$add[newgroupid];
- }
- }
- }
- //点数转换
- $d_fen=(int)$down_fr[3];
- if($add[dofen])
- {
- if($add[oldfen]=="no")//不设置
- {
- $d_fen=$add[newfen];
- }
- else//设置
- {
- if($d_fen==$add[oldfen])
- {
- $d_fen=$add[newfen];
- }
- }
- }
- //前缀转换
- $d_qz=(int)$down_fr[4];
- if($add[doqz])
- {
- if($add[oldqz]=="no")//不设置
- {
- $d_qz=$add['newqz'];
- }
- else//设置
- {
- if($d_qz==$add[oldqz])
- {
- $d_qz=$add[newqz];
- }
- }
- }
- //地址替换
- $d_path=$down_fr[1];
- if($add[dopath]&&$add[oldpath])
- {
- $d_path=str_replace($add[oldpath],$add[newpath],$down_fr[1]);
- }
- //名称替换
- $d_name=$down_fr[0];
- if($add[doname]&&$add[oldname])
- {
- $d_name=str_replace($add[oldname],$add[newname],$down_fr[0]);
- }
- //组合
- $newdownpath.=$d_name.$f_exp.$d_path.$f_exp.$d_groupid.$f_exp.$d_fen.$f_exp.$d_qz.$r_exp;
- }
- //去掉最后的字符
- $newdownpath=substr($newdownpath,0,strlen($newdownpath)-2);
- return $newdownpath;
- }
- //输出批量替换下载权限表单
- function EchoRepDownLevelForm($add,$newstart){
- global $fun_r;
- ?>
- <?=$fun_r['RepOneDLeveSuccess']?>(ID:<font color=red><b><?=$newstart?></b></font>)
- <form name="RepDownLevelForm" method="post" action="ecmscom.php">
- <?=hReturnEcmsHashStrForm(0)?>
- <input type=hidden name="enews" value="RepDownLevel">
- <input type=hidden name="start" value="<?=$newstart?>">
- <input type=hidden name="tbname" value="<?=$add['tbname']?>">
- <input type=hidden name="classid" value="<?=$add['classid']?>">
- <input type=hidden name="downpath" value="<?=$add['downpath']?>">
- <input type=hidden name="onlinepath" value="<?=$add['onlinepath']?>">
- <input type=hidden name="dogroup" value="<?=$add['dogroup']?>">
- <input type=hidden name="oldgroupid" value="<?=$add['oldgroupid']?>">
- <input type=hidden name="newgroupid" value="<?=$add['newgroupid']?>">
- <input type=hidden name="dofen" value="<?=$add['dofen']?>">
- <input type=hidden name="oldfen" value="<?=$add['oldfen']?>">
- <input type=hidden name="newfen" value="<?=$add['newfen']?>">
- <input type=hidden name="doqz" value="<?=$add['doqz']?>">
- <input type=hidden name="oldqz" value="<?=$add['oldqz']?>">
- <input type=hidden name="newqz" value="<?=$add['newqz']?>">
- <input type=hidden name="dopath" value="<?=$add['dopath']?>">
- <input type=hidden name="oldpath" value="<?=ehtmlspecialchars(ClearAddsData($add['oldpath']))?>">
- <input type=hidden name="newpath" value="<?=ehtmlspecialchars(ClearAddsData($add['newpath']))?>">
- <input type=hidden name="doname" value="<?=$add['doname']?>">
- <input type=hidden name="oldname" value="<?=ehtmlspecialchars(ClearAddsData($add['oldname']))?>">
- <input type=hidden name="newname" value="<?=ehtmlspecialchars(ClearAddsData($add['newname']))?>">
- <input type=hidden name="query" value="<?=ehtmlspecialchars(ClearAddsData($add['query']))?>">
- </form>
- <script>
- document.RepDownLevelForm.submit();
- </script>
- <?
- exit();
- }
- //清空临时数据与文件
- function ClearTmpFileData($add,$userid,$username){
- global $empire,$public_r,$dbtbpre;
- //验证权限
- CheckLevel($userid,$username,$classid,"changedata");
- //临时文件目录
- $tmppath=eReturnTrueEcmsPath().'e/data/tmp';
- $hand=@opendir($tmppath);
- while($file=@readdir($hand))
- {
- if($file=='.'||$file=='..'||$file=='test.txt'||$file=='index.html'||$file=='mod'||$file=='temp'||$file=='titlepic'||$file=='cj')
- {
- continue;
- }
- $filename=$tmppath.'/'.$file;
- if(!is_dir($filename))
- {
- DelFiletext($filename);
- }
- }
- //临时模板导出目录
- $temppath=eReturnTrueEcmsPath().'e/data/tmp/temp';
- $hand=@opendir($temppath);
- while($file=@readdir($hand))
- {
- if($file=='.'||$file=='..'||$file=='test.txt'||$file=='index.php')
- {
- continue;
- }
- $filename=$temppath.'/'.$file;
- if(!is_dir($filename))
- {
- DelFiletext($filename);
- }
- }
- //临时模型导出目录
- $modpath=eReturnTrueEcmsPath().'e/data/tmp/mod';
- $hand=@opendir($modpath);
- while($file=@readdir($hand))
- {
- if($file=='.'||$file=='..'||$file=='test.txt'||$file=='index.php')
- {
- continue;
- }
- $filename=$modpath.'/'.$file;
- if(!is_dir($filename))
- {
- DelFiletext($filename);
- }
- }
- //临时采集导出目录
- $cjpath=eReturnTrueEcmsPath().'e/data/tmp/cj';
- $hand=@opendir($cjpath);
- while($file=@readdir($hand))
- {
- if($file=='.'||$file=='..'||$file=='test.txt'||$file=='index.html')
- {
- continue;
- }
- $filename=$cjpath.'/'.$file;
- if(!is_dir($filename))
- {
- DelFiletext($filename);
- }
- }
- //采集临时表
- $empire->query("TRUNCATE `{$dbtbpre}enewslinktmp`;");
- //远程发布临时表
- $empire->query("TRUNCATE `{$dbtbpre}enewspostdata`;");
- printerror('ClearTmpFileDataSuccess','');
- }
- //清理多余信息
- function ClearBreakInfo($add,$userid,$username){
- global $empire,$dbtbpre;
- CheckLevel($userid,$username,$classid,"changedata");//验证权限
- $tid=(int)$add['tid'];
- if(!$tid)
- {
- printerror('EmptyDocTb','');
- }
- $tbr=$empire->fetch1("select datatbs,tbname from {$dbtbpre}enewstable where tid='$tid'");
- if(!$tbr['tbname'])
- {
- printerror('EmptyDocTb','');
- }
- $affnum=0;
- if($tbr['datatbs'])
- {
- $dtbr=explode(',',$tbr['datatbs']);
- $count=count($dtbr);
- $dodatatbs='';
- $andunion='';
- for($i=1;$i<$count-1;$i++)
- {
- $dodatatbs.=$andunion."select id from {$dbtbpre}ecms_".$tbr['tbname']."_data_".$dtbr[$i];
- $andunion=' union ';
- }
- if($dodatatbs)
- {
- $empire->query("delete from {$dbtbpre}ecms_".$tbr['tbname']." where id not in (".$dodatatbs.")");
- $affnum=$empire->affectnum();
- }
- }
- $GLOBALS['cbinfoaffnum']=$affnum;
- //操作日志
- insert_dolog("tid=".$tid."<br>tbname=".$tbr['tbname']);
- printerror("ClearBreakInfoSuccess","");
- }
- //重置信息或评论数统计
- function ResetAddDataNum($type,$from,$userid,$username){
- global $empire,$dbtbpre;
- if($type=='info')
- {
- //CheckLevel($userid,$username,$classid,"info");//验证权限
- }
- elseif($type=='pl')
- {
- //CheckLevel($userid,$username,$classid,"pl");//验证权限
- }
- else
- {
- printerror("ErrorUrl","");
- }
- CheckLevel($userid,$username,$classid,"changedata");//验证权限
- DoResetAddDataNum($type);
- $returnurl=$from?$from:EcmsGetReturnUrl();
- //操作日志
- insert_dolog("type=".$type);
- printerror("ResetAddDataNumSuccess",$returnurl);
- }
- ?>
|