PageRenderTime 77ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/e/class/classfun.php

https://github.com/westeast/xwdede
PHP | 2608 lines | 2312 code | 51 blank | 245 comment | 315 complexity | 71177aa698955b09ca393bdb49439f28 MD5 | raw file
  1. <?php
  2. //*********************** 专题 *********************
  3. //返回字段值
  4. function ReturnZFvalue($value)
  5. {
  6. $value=str_replace("\r\n","|",$value);
  7. return $value;
  8. }
  9. //取得专题表单元素html代码
  10. function GetZtFform($type,$f,$fvalue,$fformsize=''){
  11. if($type=="select"||$type=="radio"||$type=="checkbox")
  12. {
  13. return GetZFformSelect($type,$f,$fvalue,$fformsize);
  14. }
  15. $file="../data/html/classfhtml.txt";
  16. $data=ReadFiletext($file);
  17. $exp="[!--".$type."--]";
  18. $r=explode($exp,$data);
  19. $string=str_replace("[!--enews.var--]",$f,$r[1]);
  20. $string=str_replace("[!--enews.def.val--]",$fvalue,$string);
  21. if($type=='editor')//编辑器
  22. {
  23. $editortype='Default';
  24. $string=str_replace("[!--editor.type--]",$editortype,$string);
  25. $string=str_replace("[!--editor.basepath--]",'',$string);
  26. }
  27. $string=RepZFformSize($f,$string,$type,$fformsize);
  28. return addslashes($string);
  29. }
  30. //取得select/radio元素代码
  31. function GetZFformSelect($type,$f,$fvalue,$fformsize=''){
  32. $vr=explode("|",$fvalue);
  33. $count=count($vr);
  34. $change="";
  35. $def=':default';
  36. for($i=0;$i<$count;$i++)
  37. {
  38. $val=$vr[$i];
  39. $isdef="";
  40. if(strstr($val,$def))
  41. {
  42. $dr=explode($def,$val);
  43. $val=$dr[0];
  44. $isdef="||\$ecmsfirstpost==1";
  45. }
  46. if($type=='select')
  47. {
  48. $change.="<option value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' selected':''?>>".$val."</option>";
  49. }
  50. elseif($type=='checkbox')
  51. {
  52. $change.="<input name=\"".$f."[]\" type=\"checkbox\" value=\"".$val."\"<?=strstr(\$r[".$f."],\"|".$val."|\")".$isdef."?' checked':''?>>".$val;
  53. }
  54. else
  55. {
  56. $change.="<input name=\"".$f."\" type=\"radio\" value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' checked':''?>>".$val;
  57. }
  58. }
  59. if($type=="select")
  60. {
  61. if($fformsize)
  62. {
  63. $addsize=' style="width:'.$fformsize.'"';
  64. }
  65. $change="<select name=\"".$f."\" id=\"".$f."\"".$addsize.">".$change."</select>";
  66. }
  67. return $change;
  68. }
  69. //替换表单元素长度
  70. function RepZFformSize($f,$string,$type,$fformsize=''){
  71. $fformsize=ReturnDefZFformSize($f,$type,$fformsize);
  72. if($type=='textarea'||$type=='editor')
  73. {
  74. $r=explode(',',$fformsize);
  75. $string=str_replace('[!--fsize.w--]',$r[0],$string);
  76. $string=str_replace('[!--fsize.h--]',$r[1],$string);
  77. }
  78. else
  79. {
  80. $string=str_replace('[!--fsize.w--]',$fformsize,$string);
  81. }
  82. return $string;
  83. }
  84. //返回默认长度
  85. function ReturnDefZFformSize($f,$type,$fformsize){
  86. if(empty($fformsize))
  87. {
  88. if($type=='textarea')
  89. {
  90. $fformsize='60,10';
  91. }
  92. elseif($type=='img')
  93. {
  94. $fformsize='45';
  95. }
  96. elseif($type=='file')
  97. {
  98. $fformsize='45';
  99. }
  100. elseif($type=='flash')
  101. {
  102. $fformsize='45';
  103. }
  104. elseif($type=='date')
  105. {
  106. $fformsize='12';
  107. }
  108. elseif($type=='color')
  109. {
  110. $fformsize='10';
  111. }
  112. elseif($type=='linkfield')
  113. {
  114. $fformsize='45';
  115. }
  116. elseif($type=='downpath')
  117. {
  118. $fformsize='45';
  119. }
  120. elseif($type=='onlinepath')
  121. {
  122. $fformsize='45';
  123. }
  124. elseif($type=='editor')
  125. {
  126. $fformsize='100%,300';
  127. }
  128. }
  129. return $fformsize;
  130. }
  131. //更新栏目表单文件
  132. function ChangeZtForm(){
  133. global $empire,$dbtbpre;
  134. $file='../data/html/ztaddform.php';
  135. $mtemp='';
  136. $sql=$empire->query("select fname,f,fhtml from {$dbtbpre}enewsztf order by myorder,fid");
  137. while($r=$empire->fetch($sql))
  138. {
  139. $mtemp.="<tr bgcolor='#FFFFFF' height=25><td>".$r['fname']."</td><td>".$r['fhtml']."</td></tr>";
  140. }
  141. $mtemp="<?php
  142. if(!defined('InEmpireCMS'))
  143. {exit();}
  144. ?>".$mtemp;
  145. WriteFiletext($file,$mtemp);
  146. }
  147. //增加专题字段
  148. function AddZtF($add,$userid,$username){
  149. global $empire,$dbtbpre;
  150. //验证权限
  151. CheckLevel($userid,$username,$classid,"ztf");
  152. $add[f]=RepPostVar($add[f]);
  153. if(empty($add[f])||empty($add[fname]))
  154. {
  155. printerror("EmptyF","");
  156. }
  157. //字段是否重复
  158. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsztadd");
  159. $b=0;
  160. while($r=$empire->fetch($s))
  161. {
  162. if($r[Field]==$add[f])
  163. {
  164. $b=1;
  165. break;
  166. }
  167. }
  168. if($b)
  169. {
  170. printerror("ReF","");
  171. }
  172. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewszt");
  173. $b=0;
  174. while($r=$empire->fetch($s))
  175. {
  176. if($r[Field]==$add[f])
  177. {
  178. $b=1;
  179. break;
  180. }
  181. }
  182. if($b)
  183. {
  184. printerror("ReF","");
  185. }
  186. $add[fvalue]=ReturnZFvalue($add[fvalue]);//初始化值
  187. //字段类型
  188. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  189. {
  190. $def=" default '0'";
  191. }
  192. elseif($add[ftype]=="VARCHAR")
  193. {
  194. $def=" default ''";
  195. }
  196. else
  197. {
  198. $def="";
  199. }
  200. $type=$add[ftype];
  201. //VARCHAR
  202. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  203. {
  204. $add[flen]='255';
  205. }
  206. //字段长度
  207. if($add[flen]){
  208. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  209. $type.="(".$add[flen].")";
  210. }
  211. }
  212. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  213. //新增字段
  214. $asql=$empire->query("alter table {$dbtbpre}enewsztadd add ".$field);
  215. //替换代码
  216. $fhtml=GetZtFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  217. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  218. {
  219. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  220. }
  221. //处理变量
  222. $add[myorder]=(int)$add[myorder];
  223. $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]');");
  224. $lastid=$empire->lastid();
  225. //更新表单
  226. ChangeZtForm();
  227. if($asql&&$sql)
  228. {
  229. //操作日志
  230. insert_dolog("fid=".$lastid."<br>f=".$add[f]);
  231. printerror("AddFSuccess","info/AddZtF.php?enews=AddZtF");
  232. }
  233. else
  234. {
  235. printerror("DbError","history.go(-1)");
  236. }
  237. }
  238. //修改专题字段
  239. function EditZtF($add,$userid,$username){
  240. global $empire,$dbtbpre;
  241. //验证权限
  242. CheckLevel($userid,$username,$classid,"ztf");
  243. $fid=(int)$add['fid'];
  244. $add[f]=RepPostVar($add[f]);
  245. $add[oldf]=RepPostVar($add[oldf]);
  246. if(empty($add[f])||empty($add[fname])||!$fid){
  247. printerror("EmptyF","history.go(-1)");
  248. }
  249. if($add[f]<>$add[oldf]){
  250. //字段是否重复
  251. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsztadd");
  252. $b=0;
  253. while($r=$empire->fetch($s)){
  254. if($r[Field]==$add[f]){
  255. $b=1;
  256. break;
  257. }
  258. }
  259. if($b){
  260. printerror("ReF","history.go(-1)");
  261. }
  262. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewszt");
  263. $b=0;
  264. while($r=$empire->fetch($s))
  265. {
  266. if($r[Field]==$add[f])
  267. {
  268. $b=1;
  269. break;
  270. }
  271. }
  272. if($b)
  273. {
  274. printerror("ReF","");
  275. }
  276. }
  277. $add[fvalue]=ReturnZFvalue($add[fvalue]);//初始化值
  278. //字段类型
  279. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  280. {
  281. $def=" default '0'";
  282. }
  283. elseif($add[ftype]=="VARCHAR")
  284. {
  285. $def=" default ''";
  286. }
  287. else
  288. {
  289. $def="";
  290. }
  291. $type=$add[ftype];
  292. //VARCHAR
  293. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  294. {
  295. $add[flen]='255';
  296. }
  297. //字段长度
  298. if($add[flen]){
  299. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  300. $type.="(".$add[flen].")";
  301. }
  302. }
  303. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  304. $usql=$empire->query("alter table {$dbtbpre}enewsztadd change `".$add[oldf]."` ".$field);
  305. //替换代码
  306. if($add[f]<>$add[oldf]||$add[fform]<>$add[oldfform]||$add[fvalue]<>$add[oldfvalue]||$add[fformsize]<>$add[oldfformsize]){
  307. $fhtml=GetZtFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  308. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  309. {
  310. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  311. }
  312. }
  313. else{
  314. $fhtml=$add[fhtml];
  315. }
  316. //处理变量
  317. $add[myorder]=(int)$add[myorder];
  318. $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");
  319. //更新表单
  320. ChangeZtForm();
  321. if($usql&&$sql)
  322. {
  323. insert_dolog("fid=".$fid."<br>f=".$add[f]);//操作日志
  324. printerror("EditFSuccess","info/ListZtF.php");
  325. }
  326. else
  327. {printerror("DbError","history.go(-1)");}
  328. }
  329. //删除专题字段
  330. function DelZtF($add,$userid,$username){
  331. global $empire,$dbtbpre;
  332. //验证权限
  333. CheckLevel($userid,$username,$classid,"ztf");
  334. $fid=(int)$add['fid'];
  335. if(empty($fid)){
  336. printerror("EmptyFid","history.go(-1)");
  337. }
  338. $r=$empire->fetch1("select f from {$dbtbpre}enewsztf where fid='$fid'");
  339. if(!$r[f]){
  340. printerror("EmptyFid","history.go(-1)");
  341. }
  342. $usql=$empire->query("alter table {$dbtbpre}enewsztadd drop COLUMN `".$r[f]."`");
  343. $sql=$empire->query("delete from {$dbtbpre}enewsztf where fid='$fid'");
  344. //更新表单表
  345. ChangeZtForm();
  346. if($usql&&$sql)
  347. {
  348. insert_dolog("fid=".$fid."<br>f=".$r[f]);//操作日志
  349. printerror("DelFSuccess","info/ListZtF.php");
  350. }
  351. else
  352. {printerror("DbError","history.go(-1)");}
  353. }
  354. //修改专题字段顺序
  355. function EditZtFOrder($fid,$myorder,$userid,$username){
  356. global $empire,$dbtbpre;
  357. //验证权限
  358. CheckLevel($userid,$username,$classid,"ztf");
  359. for($i=0;$i<count($myorder);$i++)
  360. {
  361. $fid[$i]=(int)$fid[$i];
  362. $newmyorder=(int)$myorder[$i];
  363. $usql=$empire->query("update {$dbtbpre}enewsztf set myorder=$newmyorder where fid='$fid[$i]'");
  364. }
  365. //更新表单表
  366. ChangeZtForm();
  367. printerror("EditFOrderSuccess","info/ListZtF.php");
  368. }
  369. //返回专题字段
  370. function ReturnZtAddF($add,$ecms=0){
  371. global $empire,$dbtbpre;
  372. $ret_r[0]='';
  373. $ret_r[1]='';
  374. $fsql=$empire->query("select f from {$dbtbpre}enewsztf");
  375. if($ecms==0)//增加
  376. {
  377. while($fr=$empire->fetch($fsql))
  378. {
  379. $f=$fr['f'];
  380. $fval=$add[$f];
  381. $fval=RepPhpAspJspcode($fval);
  382. $ret_r[0].=",`".$f."`";
  383. $ret_r[1].=",'".AddAddsData($fval)."'";
  384. }
  385. }
  386. else//修改
  387. {
  388. while($fr=$empire->fetch($fsql))
  389. {
  390. $f=$fr['f'];
  391. $fval=$add[$f];
  392. $fval=RepPhpAspJspcode($fval);
  393. $ret_r[0].=",`".$f."`='".AddAddsData($fval)."'";
  394. }
  395. }
  396. return $ret_r;
  397. }
  398. //处理专题提交变量
  399. function DoPostZtVar($add){
  400. if(empty($add[zttype])){
  401. $add[zttype]=".html";
  402. }
  403. if(empty($add[ztnum])){
  404. $add[ztnum]=25;
  405. }
  406. $add[zcid]=(int)$add['zcid'];
  407. $add[jstempid]=(int)$add['jstempid'];
  408. $add[ztname]=addslashes(htmlspecialchars($add[ztname]));
  409. $add[intro]=addslashes(RepPhpAspJspcode($add[intro]));
  410. $add[ztpagekey]=addslashes(RepPhpAspJspcode($add[ztpagekey]));
  411. $add[ztnum]=(int)$add[ztnum];
  412. $add[listtempid]=(int)$add[listtempid];
  413. $add[newline]=(int)$add[newline];
  414. $add[hotline]=(int)$add[hotline];
  415. $add[goodline]=(int)$add[goodline];
  416. $add[classid]=(int)$add[classid];
  417. $add[hotplline]=(int)$add[hotplline];
  418. $add[firstline]=(int)$add[firstline];
  419. $add[islist]=(int)$add[islist];
  420. $add[maxnum]=(int)$add[maxnum];
  421. $add[showzt]=(int)$add[showzt];
  422. $add[classtempid]=(int)$add[classtempid];
  423. $add['myorder']=(int)$add['myorder'];
  424. $add[nrejs]=(int)$add[nrejs];
  425. $add[reorder]=RepPostVar2($add[reorder]);
  426. $add[classtext]=RepPhpAspJspcode($add[classtext]);
  427. $add[usezt]=(int)$add[usezt];
  428. $add[yhid]=(int)$add[yhid];
  429. //目录
  430. $add[ztpath]=$add['pripath'].$add['ztpath'];
  431. return $add;
  432. }
  433. //增加专题
  434. function AddZt($add,$userid,$username){
  435. global $empire,$class_r,$dbtbpre;
  436. $add[ztpath]=trim($add[ztpath]);
  437. if(!$add[ztname]||!$add[listtempid]||!$add[ztpath]){
  438. printerror("EmptyZt","");
  439. }
  440. CheckLevel($userid,$username,$classid,"zt");
  441. $add=DoPostZtVar($add);
  442. $createpath='../../'.$add[ztpath];
  443. //检测目录是否存在
  444. if(file_exists($createpath)){
  445. printerror("ReZtpath","");
  446. }
  447. CreateZtPath($add[ztpath]);//建立专题目录
  448. //取得表名
  449. $tabler=GetModTable(GetListtempMid($add[listtempid]));
  450. $tabler[tid]=(int)$tabler[tid];
  451. $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]');");
  452. $ztid=$empire->lastid();
  453. //副表
  454. $ret_zr=ReturnZtAddF($add,0);
  455. $empire->query("replace into {$dbtbpre}enewsztadd(ztid,classtext".$ret_zr[0].") values('$ztid','".addslashes($add[classtext])."'".$ret_zr[1].");");
  456. //生成页面
  457. if($add[islist]==0||$add[islist]==2)
  458. {
  459. $classtemp=$add[islist]==2?GetZtText($ztid):GetClassTemp($add['classtempid']);
  460. NewsBq($ztid,$classtemp,3,1);
  461. }
  462. GetClass();//更新缓存
  463. if($sql){
  464. insert_dolog("ztid=".$ztid."<br>ztname=".$add[ztname]);//操作日志
  465. printerror("AddZtSuccess","AddZt.php?enews=AddZt");
  466. }
  467. else{
  468. printerror("DbError","");
  469. }
  470. }
  471. //修改专题
  472. function EditZt($add,$userid,$username){
  473. global $empire,$class_r,$dbtbpre;
  474. $add[ztid]=(int)$add[ztid];
  475. $add[ztpath]=trim($add[ztpath]);
  476. if(!$add[ztname]||!$add[listtempid]||!$add[ztpath]||!$add[ztid]){
  477. printerror("EmptyZt","");
  478. }
  479. CheckLevel($userid,$username,$classid,"zt");
  480. $add=DoPostZtVar($add);
  481. //改变目录
  482. if($add[oldztpath]<>$add[ztpath]){
  483. $createpath='../../'.$add[ztpath];
  484. if(file_exists($createpath)){
  485. printerror("ReZtpath","");
  486. }
  487. if($add['oldpripath']==$add['pripath']){
  488. $new="../../";
  489. @rename($new.$add[oldztpath],$new.$add[ztpath]);//改变目录名
  490. }
  491. else{
  492. CreateZtPath($add[ztpath]);//建立专题目录
  493. }
  494. }
  495. //取得表名
  496. $tabler=GetModTable(GetListtempMid($add[listtempid]));
  497. $tabler[tid]=(int)$tabler[tid];
  498. $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]'");
  499. //副表
  500. $ret_zr=ReturnZtAddF($add,1);
  501. $empire->query("update {$dbtbpre}enewsztadd set classtext='".addslashes($add[classtext])."'".$ret_zr[0]." where ztid='$add[ztid]'");
  502. GetClass();//更新缓存
  503. //生成页面
  504. if($add[islist]==0||$add[islist]==2)
  505. {
  506. $classtemp=$add[islist]==2?GetZtText($add[ztid]):GetClassTemp($add['classtempid']);
  507. NewsBq($add[ztid],$classtemp,3,1);
  508. }
  509. if($sql){
  510. insert_dolog("ztid=".$add[ztid]."<br>ztname=".$add[ztname]);//操作日志
  511. printerror("EditZtSuccess","ListZt.php");
  512. }
  513. else{
  514. printerror("DbError","");
  515. }
  516. }
  517. //删除专题
  518. function DelZt($ztid,$userid,$username){
  519. global $empire,$dbtbpre;
  520. $ztid=(int)$ztid;
  521. if(!$ztid){
  522. printerror("NotDelZtid","");
  523. }
  524. CheckLevel($userid,$username,$classid,"zt");
  525. $r=$empire->fetch1("select * from {$dbtbpre}enewszt where ztid='$ztid'");
  526. if(empty($r[ztid])){
  527. printerror("NotDelZtid","history.go(-1)");
  528. }
  529. //删除专题
  530. $sql=$empire->query("delete from {$dbtbpre}enewszt where ztid='$ztid'");
  531. $empire->query("delete from {$dbtbpre}enewsztadd where ztid='$ztid'");
  532. $delpath="../../".$r[ztpath];
  533. $del=DelPath($delpath);
  534. //改变信息专题值
  535. $nsql=$empire->query("select id,ztid from {$dbtbpre}ecms_".$r[tbname]." where ztid like '%|".$ztid."|%'");
  536. while($nr=$empire->fetch($nsql))
  537. {
  538. $newztid=str_replace("|".$ztid."|","|",$nr[ztid]);
  539. $usql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]." set ztid='$newztid' where id='$nr[id]'");
  540. }
  541. GetClass();//更新缓存
  542. if($sql){
  543. insert_dolog("ztid=".$ztid."<br>ztname=".$r[ztname]);//操作日志
  544. printerror("DelZtSuccess","ListZt.php");
  545. }
  546. else{
  547. printerror("DbError","");
  548. }
  549. }
  550. //组合专题
  551. function TogZt($add,$userid,$username){
  552. global $empire,$class_r,$dbtbpre;
  553. $ztid=(int)$add['ztid'];
  554. if(empty($ztid))
  555. {
  556. printerror("ErrorUrl","history.go(-1)");
  557. }
  558. $r=$empire->fetch1("select ztid,ztname,tbname from {$dbtbpre}enewszt where ztid=$ztid");
  559. if(empty($r['ztid'])||empty($r['tbname']))
  560. {
  561. printerror("ErrorUrl","history.go(-1)");
  562. }
  563. $wheresql="";
  564. $formvar="";
  565. //关键字
  566. $keyboard=RepPostVar2($add['keyboard']);
  567. if($keyboard)
  568. {
  569. $formvar.=ReturnFormHidden('keyboard',$add['keyboard']);
  570. $searchfsql='';
  571. if($add['stitle'])//标题
  572. {
  573. $searchfsql.="title like '%$keyboard%'";
  574. $formvar.=ReturnFormHidden('stitle',$add['stitle']);
  575. }
  576. if($add['susername'])//增加者
  577. {
  578. if($searchfsql)
  579. {
  580. $or=" or ";
  581. }
  582. $searchfsql.=$or."username like '%$keyboard%'";
  583. $formvar.=ReturnFormHidden('susername',$add['susername']);
  584. }
  585. if($add['snewstext'])//内容
  586. {
  587. $or="";
  588. if($searchfsql)
  589. {
  590. $or=" or ";
  591. }
  592. $searchfsql.=$or."newstext like '%$keyboard%'";
  593. $formvar.=ReturnFormHidden('snewstext',$add['snewstext']);
  594. }
  595. if($searchfsql)
  596. {
  597. $wheresql=" and (".$searchfsql.")";
  598. }
  599. }
  600. //是否推荐
  601. if($add['isgood'])
  602. {
  603. $wheresql.=" and isgood>0";
  604. $formvar.=ReturnFormHidden('isgood',$add['isgood']);
  605. }
  606. //头条
  607. if($add['firsttitle'])
  608. {
  609. $wheresql.=" and firsttitle>0";
  610. $formvar.=ReturnFormHidden('firsttitle',$add['firsttitle']);
  611. }
  612. //有标题图片
  613. if($add['titlepic'])
  614. {
  615. $wheresql.=" and ispic=1";
  616. $formvar.=ReturnFormHidden('titlepic',$add['titlepic']);
  617. }
  618. //审核
  619. if($add['checked'])
  620. {
  621. $wheresql.=" and checked=1";
  622. $formvar.=ReturnFormHidden('checked',$add['checked']);
  623. }
  624. //按栏目刷新
  625. $classid=(int)$add['classid'];
  626. if($classid)
  627. {
  628. $formvar.=ReturnFormHidden('classid',$add['classid']);
  629. //大栏目
  630. if(empty($class_r[$classid][islast]))
  631. {
  632. $where=ReturnClass($class_r[$classid][sonclass]);
  633. }
  634. //终极栏目
  635. else
  636. {
  637. $where="classid='$classid'";
  638. }
  639. $wheresql.=" and (".$where.")";
  640. }
  641. $startid=(int)$add[startid];
  642. $endid=(int)$add[endid];
  643. $startday=RepPostVar($add[startday]);
  644. $endday=RepPostVar($add[endday]);
  645. $formvar.=ReturnFormHidden('retype',$add['retype']);
  646. //按ID
  647. if($add['retype'])
  648. {
  649. if($endid)
  650. {
  651. $wheresql.=" and id>=$startid and id<=$endid";
  652. $formvar.=ReturnFormHidden('startid',$add[startid]).ReturnFormHidden('endid',$add[endid]);
  653. }
  654. }
  655. else
  656. {
  657. if($startday&&$endday)
  658. {
  659. $wheresql.=" and truetime>=".to_time($startday." 00:00:00")." and truetime<=".to_time($endday." 23:59:59");
  660. $formvar.=ReturnFormHidden('startday',$add[startday]).ReturnFormHidden('endday',$add[endday]);
  661. }
  662. }
  663. //附件sql条件
  664. $query=$add['query'];
  665. if($query)
  666. {
  667. $query=ClearAddsData($query);//去除adds
  668. $wheresql.=" and (".$query.")";
  669. $formvar.=ReturnFormHidden('query',$add['query']);
  670. }
  671. $wheresql=" where ztid not like '%|".$ztid."|%'".$wheresql;
  672. $owheresql=$wheresql." and ztid=''";
  673. if($add['doecmszt'])
  674. {
  675. if($add['inid'])
  676. {
  677. $add['inid']=RepPostVar($add['inid']);
  678. $wheresql.=" and id not in (".$add['inid'].")";
  679. $owheresql.=" and id not in (".$add['inid'].")";
  680. }
  681. $repztid="|".$ztid."|";
  682. $conztid=$ztid."|";
  683. //将空格转换成|
  684. $usql=$empire->query("update {$dbtbpre}ecms_".$r['tbname']." set ztid='|'".$owheresql);
  685. //组成新专题
  686. $sql=$empire->query("update {$dbtbpre}ecms_".$r['tbname']." set ztid=CONCAT(REPLACE(ztid,'".$repztid."','|'),'".$conztid."')".$wheresql);
  687. if($usql&&$sql)
  688. {
  689. //操作日志
  690. insert_dolog("ztid=$ztid&ztname=$r[ztname]");
  691. printerror("TogZtSuccess","TogZt.php?ztid=$ztid");
  692. }
  693. else
  694. {
  695. printerror("DbError","history.go(-1)");
  696. }
  697. }
  698. $re[0]=$wheresql;
  699. $re[1]=$formvar.ReturnFormHidden('ztid',$ztid).ReturnFormHidden('pline',$add[pline]).ReturnFormHidden('doecmszt',$add[doecmszt]).ReturnFormHidden('enews',$add[enews]).ReturnFormHidden('inid',$add[inid]);
  700. $re[2]=$r['tbname'];
  701. $re[3]=$r['ztname'];
  702. return $re;
  703. }
  704. //保存专题信息
  705. function SaveTogZtInfo($add,$userid,$username){
  706. global $empire,$dbtbpre;
  707. if(!trim($add[togztname]))
  708. {
  709. printerror('EmptySaveTogZtname','history.go(-1)');
  710. }
  711. $add['doecmszt']=(int)$add['doecmszt'];
  712. $add[classid]=(int)$add[classid];
  713. //搜索字段
  714. $searchf=',';
  715. if($add[stitle]==1)
  716. {
  717. $searchf.='stitle,';
  718. }
  719. if($add[susername]==1)
  720. {
  721. $searchf.='susername,';
  722. }
  723. if($add[snewstext]==1)
  724. {
  725. $searchf.='snewstext,';
  726. }
  727. //特殊字段
  728. $specialsearch=',';
  729. if($add[isgood])
  730. {
  731. $specialsearch.='isgood,';
  732. }
  733. if($add[firsttitle])
  734. {
  735. $specialsearch.='firsttitle,';
  736. }
  737. if($add[titlepic])
  738. {
  739. $specialsearch.='titlepic,';
  740. }
  741. if($add[checked])
  742. {
  743. $specialsearch.='checked,';
  744. }
  745. $add['retype']=(int)$add['retype'];
  746. $add['startid']=(int)$add['startid'];
  747. $add['endid']=(int)$add['endid'];
  748. $add['pline']=(int)$add['pline'];
  749. $r=$empire->fetch1("select togid from {$dbtbpre}enewstogzts where togztname='$add[togztname]'");
  750. if($r[togid])
  751. {
  752. $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]'");
  753. $togid=$r[togid];
  754. }
  755. else
  756. {
  757. $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])."');");
  758. $togid=$empire->lastid();
  759. }
  760. if($sql)
  761. {
  762. insert_dolog("togid=$togid&togztname=$add[togztname]");//操作日志
  763. printerror("SaveTogZtInfoSuccess","TogZt.php?ztid=$add[ztid]&togid=$togid");
  764. }
  765. else
  766. {
  767. printerror("DbError","history.go(-1)");
  768. }
  769. }
  770. //删除保存专题信息
  771. function DelTogZtInfo($add,$userid,$username){
  772. global $empire,$dbtbpre;
  773. $togid=intval($add[togid]);
  774. if(!$togid)
  775. {
  776. printerror('EmptyDelTogztid','history.go(-1)');
  777. }
  778. $r=$empire->fetch1("select togid,togztname from {$dbtbpre}enewstogzts where togid='$togid'");
  779. if(!$r[togid])
  780. {
  781. printerror('EmptyDelTogztid','history.go(-1)');
  782. }
  783. $sql=$empire->query("delete from {$dbtbpre}enewstogzts where togid='$togid'");
  784. if($sql)
  785. {
  786. insert_dolog("togid=$togid&togztname=$r[togztname]");//操作日志
  787. printerror('DelTogZtInfoSuccess',$_SERVER['HTTP_REFERER']);
  788. }
  789. else
  790. {
  791. printerror("DbError","history.go(-1)");
  792. }
  793. }
  794. //************************************ 栏目 ************************************
  795. //返回字段值
  796. function ReturnCFvalue($value)
  797. {
  798. $value=str_replace("\r\n","|",$value);
  799. return $value;
  800. }
  801. //取得栏目表单元素html代码
  802. function GetClassFform($type,$f,$fvalue,$fformsize=''){
  803. if($type=="select"||$type=="radio"||$type=="checkbox")
  804. {
  805. return GetCFformSelect($type,$f,$fvalue,$fformsize);
  806. }
  807. $file="../data/html/classfhtml.txt";
  808. $data=ReadFiletext($file);
  809. $exp="[!--".$type."--]";
  810. $r=explode($exp,$data);
  811. $string=str_replace("[!--enews.var--]",$f,$r[1]);
  812. $string=str_replace("[!--enews.def.val--]",$fvalue,$string);
  813. if($type=='editor')//编辑器
  814. {
  815. $editortype='Default';
  816. $string=str_replace("[!--editor.type--]",$editortype,$string);
  817. $string=str_replace("[!--editor.basepath--]",'',$string);
  818. }
  819. $string=RepCFformSize($f,$string,$type,$fformsize);
  820. return addslashes($string);
  821. }
  822. //取得select/radio元素代码
  823. function GetCFformSelect($type,$f,$fvalue,$fformsize=''){
  824. $vr=explode("|",$fvalue);
  825. $count=count($vr);
  826. $change="";
  827. $def=':default';
  828. for($i=0;$i<$count;$i++)
  829. {
  830. $val=$vr[$i];
  831. $isdef="";
  832. if(strstr($val,$def))
  833. {
  834. $dr=explode($def,$val);
  835. $val=$dr[0];
  836. $isdef="||\$ecmsfirstpost==1";
  837. }
  838. if($type=='select')
  839. {
  840. $change.="<option value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' selected':''?>>".$val."</option>";
  841. }
  842. elseif($type=='checkbox')
  843. {
  844. $change.="<input name=\"".$f."[]\" type=\"checkbox\" value=\"".$val."\"<?=strstr(\$r[".$f."],\"|".$val."|\")".$isdef."?' checked':''?>>".$val;
  845. }
  846. else
  847. {
  848. $change.="<input name=\"".$f."\" type=\"radio\" value=\"".$val."\"<?=\$r[".$f."]==\"".$val."\"".$isdef."?' checked':''?>>".$val;
  849. }
  850. }
  851. if($type=="select")
  852. {
  853. if($fformsize)
  854. {
  855. $addsize=' style="width:'.$fformsize.'"';
  856. }
  857. $change="<select name=\"".$f."\" id=\"".$f."\"".$addsize.">".$change."</select>";
  858. }
  859. return $change;
  860. }
  861. //替换表单元素长度
  862. function RepCFformSize($f,$string,$type,$fformsize=''){
  863. $fformsize=ReturnDefCFformSize($f,$type,$fformsize);
  864. if($type=='textarea'||$type=='editor')
  865. {
  866. $r=explode(',',$fformsize);
  867. $string=str_replace('[!--fsize.w--]',$r[0],$string);
  868. $string=str_replace('[!--fsize.h--]',$r[1],$string);
  869. }
  870. else
  871. {
  872. $string=str_replace('[!--fsize.w--]',$fformsize,$string);
  873. }
  874. return $string;
  875. }
  876. //返回默认长度
  877. function ReturnDefCFformSize($f,$type,$fformsize){
  878. if(empty($fformsize))
  879. {
  880. if($type=='textarea')
  881. {
  882. $fformsize='60,10';
  883. }
  884. elseif($type=='img')
  885. {
  886. $fformsize='45';
  887. }
  888. elseif($type=='file')
  889. {
  890. $fformsize='45';
  891. }
  892. elseif($type=='flash')
  893. {
  894. $fformsize='45';
  895. }
  896. elseif($type=='date')
  897. {
  898. $fformsize='12';
  899. }
  900. elseif($type=='color')
  901. {
  902. $fformsize='10';
  903. }
  904. elseif($type=='linkfield')
  905. {
  906. $fformsize='45';
  907. }
  908. elseif($type=='downpath')
  909. {
  910. $fformsize='45';
  911. }
  912. elseif($type=='onlinepath')
  913. {
  914. $fformsize='45';
  915. }
  916. elseif($type=='editor')
  917. {
  918. $fformsize='100%,300';
  919. }
  920. }
  921. return $fformsize;
  922. }
  923. //更新栏目表单文件
  924. function ChangeClassForm(){
  925. global $empire,$dbtbpre;
  926. $file='../data/html/classaddform.php';
  927. $mtemp='';
  928. $sql=$empire->query("select fname,f,fhtml from {$dbtbpre}enewsclassf order by myorder,fid");
  929. while($r=$empire->fetch($sql))
  930. {
  931. $mtemp.="<tr bgcolor='#FFFFFF' height=25><td>".$r['fname']."</td><td>".$r['fhtml']."</td></tr>";
  932. }
  933. $mtemp="<?php
  934. if(!defined('InEmpireCMS'))
  935. {exit();}
  936. ?>".$mtemp;
  937. WriteFiletext($file,$mtemp);
  938. }
  939. //增加栏目字段
  940. function AddClassF($add,$userid,$username){
  941. global $empire,$dbtbpre;
  942. //验证权限
  943. CheckLevel($userid,$username,$classid,"classf");
  944. $add[f]=RepPostVar($add[f]);
  945. if(empty($add[f])||empty($add[fname]))
  946. {
  947. printerror("EmptyF","");
  948. }
  949. //字段是否重复
  950. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclassadd");
  951. $b=0;
  952. while($r=$empire->fetch($s))
  953. {
  954. if($r[Field]==$add[f])
  955. {
  956. $b=1;
  957. break;
  958. }
  959. }
  960. if($b)
  961. {
  962. printerror("ReF","");
  963. }
  964. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclass");
  965. $b=0;
  966. while($r=$empire->fetch($s))
  967. {
  968. if($r[Field]==$add[f])
  969. {
  970. $b=1;
  971. break;
  972. }
  973. }
  974. if($b)
  975. {
  976. printerror("ReF","");
  977. }
  978. $add[fvalue]=ReturnCFvalue($add[fvalue]);//初始化值
  979. //字段类型
  980. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  981. {
  982. $def=" default '0'";
  983. }
  984. elseif($add[ftype]=="VARCHAR")
  985. {
  986. $def=" default ''";
  987. }
  988. else
  989. {
  990. $def="";
  991. }
  992. $type=$add[ftype];
  993. //VARCHAR
  994. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  995. {
  996. $add[flen]='255';
  997. }
  998. //字段长度
  999. if($add[flen]){
  1000. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  1001. $type.="(".$add[flen].")";
  1002. }
  1003. }
  1004. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  1005. //新增字段
  1006. $asql=$empire->query("alter table {$dbtbpre}enewsclassadd add ".$field);
  1007. //替换代码
  1008. $fhtml=GetClassFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  1009. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  1010. {
  1011. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  1012. }
  1013. //处理变量
  1014. $add[myorder]=(int)$add[myorder];
  1015. $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]');");
  1016. $lastid=$empire->lastid();
  1017. //更新表单
  1018. ChangeClassForm();
  1019. if($asql&&$sql)
  1020. {
  1021. //操作日志
  1022. insert_dolog("fid=".$lastid."<br>f=".$add[f]);
  1023. printerror("AddFSuccess","info/AddClassF.php?enews=AddClassF");
  1024. }
  1025. else
  1026. {
  1027. printerror("DbError","history.go(-1)");
  1028. }
  1029. }
  1030. //修改栏目字段
  1031. function EditClassF($add,$userid,$username){
  1032. global $empire,$dbtbpre;
  1033. //验证权限
  1034. CheckLevel($userid,$username,$classid,"classf");
  1035. $fid=(int)$add['fid'];
  1036. $add[f]=RepPostVar($add[f]);
  1037. $add[oldf]=RepPostVar($add[oldf]);
  1038. if(empty($add[f])||empty($add[fname])||!$fid){
  1039. printerror("EmptyF","history.go(-1)");
  1040. }
  1041. if($add[f]<>$add[oldf]){
  1042. //字段是否重复
  1043. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclassadd");
  1044. $b=0;
  1045. while($r=$empire->fetch($s)){
  1046. if($r[Field]==$add[f]){
  1047. $b=1;
  1048. break;
  1049. }
  1050. }
  1051. if($b){
  1052. printerror("ReF","history.go(-1)");
  1053. }
  1054. $s=$empire->query("SHOW FIELDS FROM {$dbtbpre}enewsclass");
  1055. $b=0;
  1056. while($r=$empire->fetch($s))
  1057. {
  1058. if($r[Field]==$add[f])
  1059. {
  1060. $b=1;
  1061. break;
  1062. }
  1063. }
  1064. if($b)
  1065. {
  1066. printerror("ReF","");
  1067. }
  1068. }
  1069. $add[fvalue]=ReturnCFvalue($add[fvalue]);//初始化值
  1070. //字段类型
  1071. if($add[ftype]=="TINYINT"||$add[ftype]=="SMALLINT"||$add[ftype]=="INT"||$add[ftype]=="BIGINT"||$add[ftype]=="FLOAT"||$add[ftype]=="DOUBLE")
  1072. {
  1073. $def=" default '0'";
  1074. }
  1075. elseif($add[ftype]=="VARCHAR")
  1076. {
  1077. $def=" default ''";
  1078. }
  1079. else
  1080. {
  1081. $def="";
  1082. }
  1083. $type=$add[ftype];
  1084. //VARCHAR
  1085. if($add[ftype]=='VARCHAR'&&empty($add[flen]))
  1086. {
  1087. $add[flen]='255';
  1088. }
  1089. //字段长度
  1090. if($add[flen]){
  1091. if($add[ftype]!="TEXT"&&$add[ftype]!="MEDIUMTEXT"&&$add[ftype]!="LONGTEXT"){
  1092. $type.="(".$add[flen].")";
  1093. }
  1094. }
  1095. $field="`".$add[f]."` ".$type." NOT NULL".$def;
  1096. $usql=$empire->query("alter table {$dbtbpre}enewsclassadd change `".$add[oldf]."` ".$field);
  1097. //替换代码
  1098. if($add[f]<>$add[oldf]||$add[fform]<>$add[oldfform]||$add[fvalue]<>$add[oldfvalue]||$add[fformsize]<>$add[oldfformsize]){
  1099. $fhtml=GetClassFform($add[fform],$add[f],$add[fvalue],$add[fformsize]);
  1100. if($add[fform]=='select'||$add[fform]=='radio'||$add[fform]=='checkbox')
  1101. {
  1102. $fhtml=str_replace("\$r[","\$addr[",$fhtml);
  1103. }
  1104. }
  1105. else{
  1106. $fhtml=$add[fhtml];
  1107. }
  1108. //处理变量
  1109. $add[myorder]=(int)$add[myorder];
  1110. $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");
  1111. //更新表单
  1112. ChangeClassForm();
  1113. if($usql&&$sql)
  1114. {
  1115. insert_dolog("fid=".$fid."<br>f=".$add[f]);//操作日志
  1116. printerror("EditFSuccess","info/ListClassF.php");
  1117. }
  1118. else
  1119. {printerror("DbError","history.go(-1)");}
  1120. }
  1121. //删除栏目字段
  1122. function DelClassF($add,$userid,$username){
  1123. global $empire,$dbtbpre;
  1124. //验证权限
  1125. CheckLevel($userid,$username,$classid,"classf");
  1126. $fid=(int)$add['fid'];
  1127. if(empty($fid)){
  1128. printerror("EmptyFid","history.go(-1)");
  1129. }
  1130. $r=$empire->fetch1("select f from {$dbtbpre}enewsclassf where fid='$fid'");
  1131. if(!$r[f]){
  1132. printerror("EmptyFid","history.go(-1)");
  1133. }
  1134. $usql=$empire->query("alter table {$dbtbpre}enewsclassadd drop COLUMN `".$r[f]."`");
  1135. $sql=$empire->query("delete from {$dbtbpre}enewsclassf where fid='$fid'");
  1136. //更新表单表
  1137. ChangeClassForm();
  1138. if($usql&&$sql)
  1139. {
  1140. insert_dolog("fid=".$fid."<br>f=".$r[f]);//操作日志
  1141. printerror("DelFSuccess","info/ListClassF.php");
  1142. }
  1143. else
  1144. {printerror("DbError","history.go(-1)");}
  1145. }
  1146. //修改栏目字段顺序
  1147. function EditClassFOrder($fid,$myorder,$userid,$username){
  1148. global $empire,$dbtbpre;
  1149. //验证权限
  1150. CheckLevel($userid,$username,$classid,"classf");
  1151. for($i=0;$i<count($myorder);$i++)
  1152. {
  1153. $fid[$i]=(int)$fid[$i];
  1154. $newmyorder=(int)$myorder[$i];
  1155. $usql=$empire->query("update {$dbtbpre}enewsclassf set myorder=$newmyorder where fid='$fid[$i]'");
  1156. }
  1157. //更新表单表
  1158. ChangeClassForm();
  1159. printerror("EditFOrderSuccess","info/ListClassF.php");
  1160. }
  1161. //返回栏目字段
  1162. function ReturnClassAddF($add,$ecms=0){
  1163. global $empire,$dbtbpre;
  1164. $ret_r[0]='';
  1165. $ret_r[1]='';
  1166. $fsql=$empire->query("select f from {$dbtbpre}enewsclassf");
  1167. if($ecms==0)//增加
  1168. {
  1169. while($fr=$empire->fetch($fsql))
  1170. {
  1171. $f=$fr['f'];
  1172. $fval=$add[$f];
  1173. $fval=RepPhpAspJspcode($fval);
  1174. $ret_r[0].=",`".$f."`";
  1175. $ret_r[1].=",'".AddAddsData($fval)."'";
  1176. }
  1177. }
  1178. else//修改
  1179. {
  1180. while($fr=$empire->fetch($fsql))
  1181. {
  1182. $f=$fr['f'];
  1183. $fval=$add[$f];
  1184. $fval=RepPhpAspJspcode($fval);
  1185. $ret_r[0].=",`".$f."`='".AddAddsData($fval)."'";
  1186. }
  1187. }
  1188. return $ret_r;
  1189. }
  1190. //组合不生成的栏目信息
  1191. function TogNotReClass($changecache=0){
  1192. global $empire,$dbtbpre;
  1193. $sql=$empire->query("select classid,nreclass,nreinfo,nrejs,nottobq from {$dbtbpre}enewsclass where nreclass=1 or nreinfo=1 or nrejs=1 or nottobq=1");
  1194. $nreclass=',';
  1195. $nreinfo=',';
  1196. $nrejs=',';
  1197. $nottobq=',';
  1198. while($r=$empire->fetch($sql))
  1199. {
  1200. if($r['nreclass']==1)
  1201. {
  1202. $nreclass.=$r['classid'].',';
  1203. }
  1204. if($r['nreinfo']==1)
  1205. {
  1206. $nreinfo.=$r['classid'].',';
  1207. }
  1208. if($r['nrejs']==1)
  1209. {
  1210. $nrejs.=$r['classid'].',';
  1211. }
  1212. if($r['nottobq']==1)
  1213. {
  1214. $nottobq.=$r['classid'].',';
  1215. }
  1216. }
  1217. $empire->query("update {$dbtbpre}enewspublic set nreclass='$nreclass',nreinfo='$nreinfo',nrejs='$nrejs',nottobq='$nottobq' limit 1");
  1218. if($changecache==1)
  1219. {
  1220. GetConfig();
  1221. }
  1222. }
  1223. //返回投稿权限
  1224. function DoPostClassQAddGroupid($groupid){
  1225. $count=count($groupid);
  1226. if(!$count)
  1227. {
  1228. return '';
  1229. }
  1230. $qg=',';
  1231. for($i=0;$i<$count;$i++)
  1232. {
  1233. $groupid[$i]=(int)$groupid[$i];
  1234. $qg.=$groupid[$i].',';
  1235. }
  1236. return $qg;
  1237. }
  1238. //处理栏目提交变量
  1239. function DoPostClassVar($add){
  1240. if(empty($add[classtype])){
  1241. $add[classtype]=".html";
  1242. }
  1243. $add[classname]=addslashes(htmlspecialchars($add[classname]));
  1244. $add[intro]=addslashes(RepPhpAspJspcode($add[intro]));
  1245. $add[classpagekey]=addslashes(RepPhpAspJspcode($add[classpagekey]));
  1246. //过滤字符
  1247. $add[listorder]=RepPostVar2($add[listorder]);
  1248. $add[reorder]=RepPostVar2($add[reorder]);
  1249. //处理变量
  1250. $add[jstempid]=(int)$add['jstempid'];
  1251. $add[bclassid]=(int)$add[bclassid];
  1252. $add[link_num]=(int)$add[link_num];
  1253. $add[newstempid]=(int)$add[newstempid];
  1254. $add[islast]=(int)$add[islast];
  1255. $add[filename]=(int)$add[filename];
  1256. $add[openpl]=(int)$add[openpl];
  1257. $add[openadd]=(int)$add[openadd];
  1258. $add[newline]=(int)$add[newline];
  1259. $add[hotline]=(int)$add[hotline];
  1260. $add[goodline]=(int)$add[goodline];
  1261. $add[groupid]=(int)$add[groupid];
  1262. $add[hotplline]=(int)$add[hotplline];
  1263. $add[modid]=(int)$add[modid];
  1264. $add[checked]=(int)$add[checked];
  1265. $add[firstline]=(int)$add[firstline];
  1266. $add[islist]=(int)$add[islist];
  1267. $add[searchtempid]=(int)$add[searchtempid];
  1268. $add[checkpl]=(int)$add[checkpl];
  1269. $add[down_num]=(int)$add[down_num];
  1270. if(empty($add[down_num])){
  1271. $add[down_num]=1;
  1272. }
  1273. $add[online_num]=(int)$add[online_num];
  1274. if(empty($add[online_num])){
  1275. $add[online_num]=1;
  1276. }
  1277. $add[addinfofen]=(int)$add[addinfofen];
  1278. $add[listdt]=(int)$add[listdt];
  1279. $add[showdt]=(int)$add[showdt];
  1280. $add[maxnum]=(int)$add[maxnum];
  1281. $add[showclass]=(int)$add[showclass];
  1282. $add[checkqadd]=(int)$add[checkqadd];
  1283. $add[qaddlist]=(int)$add[qaddlist];
  1284. $add[qaddgroupid]=DoPostClassQAddGroupid($add[qaddgroupidck]);
  1285. $add[qaddshowkey]=(int)$add[qaddshowkey];
  1286. $add[adminqinfo]=(int)$add[adminqinfo];
  1287. $add[doctime]=(int)$add[doctime];
  1288. $add[nreclass]=(int)$add[nreclass];
  1289. $add[nreinfo]=(int)$add[nreinfo];
  1290. $add[nrejs]=(int)$add[nrejs];
  1291. $add[nottobq]=(int)$add[nottobq];
  1292. $add[lencord]=(int)$add[lencord];
  1293. $add[listtempid]=(int)$add[listtempid];
  1294. $add[dtlisttempid]=(int)$add[dtlisttempid];
  1295. $add[classtempid]=(int)$add[classtempid];
  1296. if(empty($add[bname])){
  1297. $add[bname]=$add[classname];
  1298. }
  1299. $add[myorder]=(int)$add[myorder];
  1300. if($add[infopath]==0)
  1301. {
  1302. $add[ipath]='';
  1303. }
  1304. $add[addreinfo]=(int)$add[addreinfo];
  1305. $add[haddlist]=(int)$add[haddlist];
  1306. $add[sametitle]=(int)$add[sametitle];
  1307. $add[definfovoteid]=(int)$add[definfovoteid];
  1308. $add[qeditchecked]=(int)$add[qeditchecked];
  1309. $add[wapstyleid]=(int)$add[wapstyleid];
  1310. $add[repreinfo]=(int)$add[repreinfo];
  1311. $add[pltempid]=(int)$add[pltempid];
  1312. $add[classtext]=RepPhpAspJspcode($add[classtext]);
  1313. $add[yhid]=(int)$add[yhid];
  1314. $add[wfid]=(int)$add[wfid];
  1315. if($add['islist']==3)
  1316. {
  1317. $add['bdinfoid']=RepPostVar($add['bdinfoid']);
  1318. }
  1319. else
  1320. {
  1321. $add['bdinfoid']='';
  1322. }
  1323. //设置访问权限
  1324. $add[cgroupid]=DoPostClassQAddGroupid($add[cgroupidck]);
  1325. $add[cgtoinfo]=(int)$add[cgtoinfo];
  1326. if($add[cgroupid])
  1327. {
  1328. $add[classtype]='.php';
  1329. if($add[cgtoinfo])
  1330. {
  1331. $add[filetype]='.php';
  1332. }
  1333. }
  1334. else
  1335. {
  1336. $add[cgtoinfo]=0;
  1337. }
  1338. return $add;
  1339. }
  1340. //增加外部栏目
  1341. function AddWbClass($add,$userid,$username){
  1342. global $empire,$dbtbpre;
  1343. //操作权限
  1344. CheckLevel($userid,$username,$classid,"class");
  1345. $add=DoPostClassVar($add);
  1346. if(!$add[classname]||!$add[wburl])
  1347. {
  1348. printerror("EmptyWbClass","");
  1349. }
  1350. $add[islast]=0;
  1351. //取得表名
  1352. $tabler=GetModTable($add[modid]);
  1353. $tabler[tid]=(int)$tabler[tid];
  1354. if(empty($add[bclassid]))//主栏目
  1355. {
  1356. $sonclass="";
  1357. $featherclass="";
  1358. }
  1359. else//中级栏目
  1360. {
  1361. //取得上一级父栏目
  1362. $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1363. if($r[islast])//是否终极栏目
  1364. {
  1365. printerror("BclassNotLast","");
  1366. }
  1367. if($r[wburl])
  1368. {
  1369. printerror("BclassNotWb","");
  1370. }
  1371. if(empty($r[featherclass]))
  1372. {
  1373. $r[featherclass]="|";
  1374. }
  1375. $featherclass=$r[featherclass].$add[bclassid]."|";
  1376. $sonclass="";
  1377. }
  1378. $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]');");
  1379. $lastid=$empire->lastid();
  1380. //副表
  1381. $ret_cr=ReturnClassAddF($add,0);
  1382. $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
  1383. GetClass();
  1384. DelListEnews();//删除缓存文件
  1385. if($sql)
  1386. {
  1387. insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
  1388. printerror("AddClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
  1389. }
  1390. else
  1391. {
  1392. printerror("DbError","");
  1393. }
  1394. }
  1395. //增加栏目
  1396. function AddClass($add,$userid,$username){
  1397. global $empire,$dbtbpre;
  1398. //增加外部栏目
  1399. if($add[ecmsclasstype])
  1400. {
  1401. AddWbClass($add,$userid,$username);
  1402. }
  1403. $add[classpath]=trim($add[classpath]);
  1404. if(!$add[classname]||!$add[classpath]||!$add[modid])
  1405. {
  1406. printerror("EmptyClass","");
  1407. }
  1408. if($add[islast]&&(!$add[newstempid]||!$add[listtempid]))
  1409. {
  1410. printerror("LastMustChange","");
  1411. }
  1412. //操作权限
  1413. CheckLevel($userid,$username,$classid,"class");
  1414. $add=DoPostClassVar($add);
  1415. //目录已存在
  1416. if(strstr($add[classpath],".")||strstr($add[classpath],"/")||strstr($add[classpath],"\\"))
  1417. {
  1418. printerror("badpath","");
  1419. }
  1420. $classpath=$add[pripath].$add[classpath];
  1421. if(file_exists("../../".$classpath))
  1422. {
  1423. printerror("ReClasspath","");
  1424. }
  1425. //取得表名
  1426. $tabler=GetModTable($add[modid]);
  1427. $tabler[tid]=(int)$tabler[tid];
  1428. //增加大栏目
  1429. if(!$add[islast])
  1430. {
  1431. if(empty($add[bclassid]))//主栏目
  1432. {
  1433. $sonclass="";
  1434. $featherclass="";
  1435. }
  1436. else//中级栏目
  1437. {
  1438. //取得上一级父栏目
  1439. $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1440. if($r[islast])//是否终极栏目
  1441. {
  1442. printerror("BclassNotLast","");
  1443. }
  1444. if($r[wburl])
  1445. {
  1446. printerror("BclassNotWb","");
  1447. }
  1448. if(empty($r[featherclass]))
  1449. {
  1450. $r[featherclass]="|";
  1451. }
  1452. $featherclass=$r[featherclass].$add[bclassid]."|";
  1453. $sonclass="";
  1454. }
  1455. //建立目录
  1456. CreateClassPath($classpath);
  1457. $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]');");
  1458. $lastid=$empire->lastid();
  1459. //副表
  1460. $ret_cr=ReturnClassAddF($add,0);
  1461. $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
  1462. TogNotReClass(1);
  1463. GetClass();
  1464. if($add[islist]==0||$add[islist]==2)
  1465. {
  1466. $classtemp=$add[islist]==2?GetClassText($lastid):GetClassTemp($add['classtempid']);
  1467. NewsBq($lastid,$classtemp,0,1);
  1468. }
  1469. elseif($add[islist]==3)//栏目绑定信息
  1470. {
  1471. ReClassBdInfo($lastid);
  1472. }
  1473. DelListEnews();//删除缓存文件
  1474. GetSearch($add[modid]);//更新缓存
  1475. if($sql){
  1476. insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
  1477. printerror("AddClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
  1478. }
  1479. else{
  1480. printerror("DbError","");
  1481. }
  1482. }
  1483. //增加终级栏目
  1484. else
  1485. {
  1486. //文件前缀
  1487. $add[filename_qz]=RepFilenameQz($add[filename_qz]);
  1488. if(empty($add[bclassid]))//主类别为终级栏目时
  1489. {
  1490. $sonclass="";
  1491. $featherclass="";
  1492. }
  1493. else//子栏目
  1494. {
  1495. //取得上一级父栏目
  1496. $r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1497. //是否终极类别
  1498. if($r[islast])
  1499. {
  1500. printerror("BclassNotLast","");
  1501. }
  1502. if($r[wburl])
  1503. {
  1504. printerror("BclassNotWb","");
  1505. }
  1506. if(empty($r[featherclass])){
  1507. $r[featherclass]="|";
  1508. }
  1509. $featherclass=$r[featherclass].$add[bclassid]."|";
  1510. $sonclass="";
  1511. }
  1512. //建立栏目目录
  1513. CreateClassPath($classpath);
  1514. $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]');");
  1515. $lastid=$empire->lastid();
  1516. //副表
  1517. $ret_cr=ReturnClassAddF($add,0);
  1518. $empire->query("replace into {$dbtbpre}enewsclassadd(classid,classtext".$ret_cr[0].") values('$lastid','".addslashes($add[classtext])."'".$ret_cr[1].");");
  1519. //修改父栏目的子栏目
  1520. if($add[bclassid])
  1521. {
  1522. $b_r=$empire->fetch1("select sonclass,featherclass from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1523. if(empty($b_r[sonclass]))
  1524. {
  1525. $b_r[sonclass]="|";
  1526. }
  1527. $new_sonclass=$b_r[sonclass].$lastid."|";
  1528. $update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$add[bclassid]'");
  1529. //更改父类别的父栏目的子栏目
  1530. $where=ReturnClass($b_r[featherclass]);
  1531. if(empty($where)){
  1532. $where="classid=0";
  1533. }
  1534. $bsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  1535. while($br=$empire->fetch($bsql))
  1536. {
  1537. if(empty($br[sonclass]))
  1538. {
  1539. $br[sonclass]="|";
  1540. }
  1541. $new_sonclass=$br[sonclass].$lastid."|";
  1542. $update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classid='$br[classid]'");
  1543. }
  1544. }
  1545. DelListEnews();//删除缓存文件
  1546. TogNotReClass(1);
  1547. GetClass();
  1548. GetSearch($add[modid]);//更新缓存
  1549. if($sql){
  1550. insert_dolog("classid=".$lastid."<br>classname=".$add[classname]);//操作日志
  1551. printerror("AddLastClassSuccess","AddClass.php?enews=AddClass&from=$add[from]");
  1552. }
  1553. else{
  1554. printerror("DbError","history.go(-1)");
  1555. }
  1556. }
  1557. }
  1558. //绑定域名应用于子栏目
  1559. function UpdateSmallClassDomain($classid,$classurl,$classpath){
  1560. global $empire,$dbtbpre;
  1561. if(empty($classurl)){
  1562. $query="update {$dbtbpre}enewsclass set classurl='' where featherclass like '%|".$classid."|%'";
  1563. }
  1564. else{
  1565. $query="update {$dbtbpre}enewsclass set classurl=CONCAT('".$classurl."',SUBSTRING(classpath,LENGTH('".$classpath."')+1)) where featherclass like '%|".$classid."|%'";
  1566. }
  1567. $sql=$empire->query($query);
  1568. }
  1569. //栏目目录修改
  1570. function AlterClassPath($classid,$islast,$oldclasspath,$classpath){
  1571. global $empire,$dbtbpre;
  1572. //更新目录名
  1573. if($oldclasspath!=$classpath)
  1574. {
  1575. @rename("../../".$oldclasspath,"../../".$classpath);
  1576. @rename("../../d/file/".$oldclasspath,"../../d/file/".$classpath);
  1577. if(empty($islast))
  1578. {
  1579. $sql=$empire->query("update {$dbtbpre}enewsclass set classpath=REPLACE(classpath,'".$oldclasspath."/','".$classpath."/') where featherclass like '%|".$classid."|%'");
  1580. }
  1581. DelListEnews();
  1582. }
  1583. }
  1584. //修改外部栏目
  1585. function EditWbClass($add,$userid,$username){
  1586. global $empire,$class_r,$dbtbpre;
  1587. //操作权限
  1588. CheckLevel($userid,$username,$classid,"class");
  1589. $add=DoPostClassVar($add);
  1590. $add[classid]=(int)$add[classid];
  1591. if(!$add[classname]||!$add[classid]||!$add[wburl])
  1592. {
  1593. printerror("EmptyWbClass","");
  1594. }
  1595. $add[islast]=0;
  1596. //取得表名
  1597. $tabler=GetModTable($add[modid]);
  1598. $tabler[tid]=(int)$tabler[tid];
  1599. //改变大栏目
  1600. if($add[bclassid]<>$add[oldbclassid])
  1601. {
  1602. //转到主栏目
  1603. if(empty($add[bclassid]))
  1604. {
  1605. $sonclass="";
  1606. $featherclass="";
  1607. }
  1608. //转到中级栏目
  1609. else
  1610. {
  1611. //大栏目跟原栏目相同
  1612. if($add[classid]==$add[bclassid])
  1613. {
  1614. printerror("BclassIsself","");
  1615. }
  1616. //取得现在大栏目的值
  1617. $b=$empire->fetch1("select featherclass,sonclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1618. //检测大栏目是否为终级栏目
  1619. if($b[islast])
  1620. {
  1621. printerror("BclassNotLast","");
  1622. }
  1623. if($b[wburl])
  1624. {
  1625. printerror("BclassNotWb","");
  1626. }
  1627. //是否非法父栏目
  1628. if($b[featherclass])
  1629. {
  1630. $c_nb_r=explode("|".$add[classid]."|",$b[featherclass]);
  1631. if(count($c_nb_r)<>1)
  1632. {
  1633. printerror("BclassIssmall","");
  1634. }
  1635. }
  1636. if(empty($b[featherclass]))
  1637. {
  1638. $b[featherclass]="|";
  1639. }
  1640. $featherclass=$b[featherclass].$add[bclassid]."|";
  1641. }
  1642. $change=",bclassid=$add[bclassid],featherclass='$featherclass'";
  1643. }
  1644. //修改数据库资料
  1645. $sql=$empire->query("update {$dbtbpre}enewsclass set classname='$add[classname]',classpath='$classpath',classtype='$add[classtype]',newline=$add[newline],hotline=$add[hotline],goodline=$add[goodline],classurl='$add[classurl]',groupid=$add[groupid],myorder=$add[myorder],filename_qz='$add[filename_qz]',hotplline=$add[hotplline],modid=$add[modid],checked=$add[checked],firstline=$add[firstline],bname='$add[bname]',islist=$add[islist],listtempid=$add[listtempid],lencord=$add[lencord],searchtempid=$add[searchtempid],tid=$tabler[tid],tbname='$tabler[tbname]',maxnum=$add[maxnum],checkpl=$add[checkpl],down_num=$add[down_num],online_num=$add[online_num],listorder='$add[listorder]',reorder='$add[reorder]',intro='$add[intro]',classimg='$add[classimg]',jstempid=$add[jstempid],listdt=$add[listdt],showclass=$add[showclass],showdt=$add[showdt],qaddgroupid='$add[qaddgroupid]',qaddshowkey=$add[qaddshowkey],adminqinfo=$add[adminqinfo],doctime=$add[doctime],classpagekey='$add[classpagekey]',dtlisttempid='$add[dtlisttempid]',classtempid='$add[classtempid]',nreclass=$add[nreclass],nreinfo=$add[nreinfo],nrejs=$add[nrejs],nottobq=$add[nottobq],ipath='$add[ipath]',addreinfo=$add[addreinfo],haddlist=$add[haddlist],sametitle=$add[sametitle],definfovoteid=$add[definfovoteid],wburl='$add[wburl]',qeditchecked=$add[qeditchecked],openadd=$add[openadd],wapstyleid='$add[wapstyleid]',repreinfo='$add[repreinfo]',pltempid='$add[pltempid]',cgroupid='$add[cgroupid]',yhid='$add[yhid]',wfid='$add[wfid]',cgtoinfo='$add[cgtoinfo]',bdinfoid='$add[bdinfoid]'".$change." where classid='$add[classid]'");
  1646. //副表
  1647. $ret_cr=ReturnClassAddF($add,1);
  1648. $empire->query("update {$dbtbpre}enewsclassadd set classtext='".addslashes($add[classtext])."'".$ret_cr[0]." where classid='$add[classid]'");
  1649. GetClass();
  1650. //删除缓存文件
  1651. if($add[oldclassname]<>$add[classname]||$add[bclassid]<>$add[oldbclassid]||$add[wburl]<>$add[oldwburl])
  1652. {
  1653. DelListEnews();
  1654. }
  1655. //来源
  1656. if($add['from'])
  1657. {
  1658. $returnurl="ListPageClass.php";
  1659. }
  1660. else
  1661. {
  1662. $returnurl="ListClass.php";
  1663. }
  1664. if($sql)
  1665. {
  1666. insert_dolog("classid=".$add[classid]."<br>classname=".$add[classname]);//操作日志
  1667. printerror("EditClassSuccess",$returnurl);
  1668. }
  1669. else
  1670. {
  1671. printerror("DbError","history.go(-1)");
  1672. }
  1673. }
  1674. //修改栏目
  1675. function EditClass($add,$userid,$username){
  1676. global $empire,$class_r,$dbtbpre;
  1677. //修改外部栏目
  1678. if($add[ecmsclasstype])
  1679. {
  1680. EditWbClass($add,$userid,$username);
  1681. }
  1682. $add[classid]=(int)$add[classid];
  1683. $add[classpath]=trim($add[classpath]);
  1684. $checkclasspath=$add['classpath'];
  1685. if($add['oldclasspath']<>$add['pripath'].$add['oldcpath'])//更换父栏目
  1686. {
  1687. $add[classpath]=$add['oldcpath'];
  1688. }
  1689. if(!$add[classname]||!$add[classpath]||!$add[modid]||!$add[classid]){
  1690. printerror("EmptyClass","");
  1691. }
  1692. if($add[islast]&&(!$add[newstempid]||!$add[listtempid])){
  1693. printerror("LastMustChange","");
  1694. }
  1695. //操作权限
  1696. CheckLevel($userid,$username,$classid,"class");
  1697. $add=DoPostClassVar($add);
  1698. $add[oldmodid]=(int)$add[oldmodid];
  1699. //改变目录
  1700. $classpath=$add[pripath].$add[classpath];
  1701. if($add[oldclasspath]<>$classpath&&$checkclasspath==$add['oldcpath']){
  1702. if(file_exists("../../".$classpath)){//检测目录是否存在
  1703. printerror("ReClasspath","");
  1704. }
  1705. }
  1706. //取得表名
  1707. $tabler=GetModTable($add[modid]);
  1708. $tabler[tid]=(int)$tabler[tid];
  1709. //修改大栏目
  1710. if(!$add[islast]){
  1711. //改变大栏目
  1712. if($add[bclassid]<>$add[oldbclassid]){
  1713. //转到主栏目
  1714. if(empty($add[bclassid])){
  1715. $sonclass="";
  1716. $featherclass="";
  1717. //取得本栏目的子栏目
  1718. $r=$empire->fetch1("select sonclass,featherclass,classpath from {$dbtbpre}enewsclass where classid='$add[classid]'");
  1719. //改变父栏目的子栏目
  1720. $where=ReturnClass($r[featherclass]);
  1721. if(empty($where)){
  1722. $where="classid=0";
  1723. }
  1724. $osql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  1725. while($o=$empire->fetch($osql)){
  1726. $newsonclass=str_replace($r[sonclass],"|",$o[sonclass]);
  1727. $uosql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$o[classid]'");
  1728. }
  1729. //修改子栏目的父栏目
  1730. $osql=$empire->query("select featherclass,classid,classpath from {$dbtbpre}enewsclass where featherclass like '%|".$add[classid]."%|'");
  1731. while($o=$empire->fetch($osql)){
  1732. $newclasspath=str_replace($r[classpath]."/",$classpath."/",$o[classpath]);
  1733. $newfeatherclass=str_replace($r[featherclass],"|",$o[featherclass]);
  1734. $uosql=$empire->query("update {$dbtbpre}enewsclass set featherclass='$newfeatherclass',classpath='$newclasspath' where classid='$o[classid]'");
  1735. }
  1736. }
  1737. //转到中级栏目
  1738. else
  1739. {
  1740. //大栏目跟原栏目相同
  1741. if($add[classid]==$add[bclassid]){
  1742. printerror("BclassIsself","");
  1743. }
  1744. //取得现在大栏目的值
  1745. $b=$empire->fetch1("select featherclass,sonclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1746. //检测大栏目是否为终级栏目
  1747. if($b[islast])
  1748. {
  1749. printerror("BclassNotLast","");
  1750. }
  1751. if($b[wburl])
  1752. {
  1753. printerror("BclassNotWb","");
  1754. }
  1755. //是否非法父栏目
  1756. if($b[featherclass]){
  1757. $c_nb_r=explode("|".$add[classid]."|",$b[featherclass]);
  1758. if(count($c_nb_r)<>1){
  1759. printerror("BclassIssmall","");
  1760. }
  1761. }
  1762. if(empty($b[featherclass])){
  1763. $b[featherclass]="|";
  1764. }
  1765. $featherclass=$b[featherclass].$add[bclassid]."|";
  1766. //取得现在栏目本身的值
  1767. $o=$empire->fetch1("select featherclass,sonclass,classpath from {$dbtbpre}enewsclass where classid='$add[classid]'");
  1768. //修改子栏目的父栏目
  1769. $osql=$empire->query("select featherclass,classid,classpath from {$dbtbpre}enewsclass where featherclass like '%|".$add[classid]."|%'");
  1770. while($or=$empire->fetch($osql)){
  1771. $newclasspath=str_replace($o[classpath]."/",$classpath."/",$or[classpath]);
  1772. if(empty($o[featherclass])){
  1773. $newfeatherclass=$b[featherclass].$add[bclassid].$or[featherclass];
  1774. }
  1775. else{
  1776. $newfeatherclass=str_replace($o[featherclass],$featherclass,$or[featherclass]);
  1777. }
  1778. $uosql=$empire->query("update {$dbtbpre}enewsclass set featherclass='$newfeatherclass',classpath='$newclasspath' where classid='$or[classid]'");
  1779. }
  1780. //改变旧大栏目的所有子栏目
  1781. $owhere=ReturnClass($o[featherclass]);
  1782. if(empty($owhere)){
  1783. $owhere="classid=0";
  1784. }
  1785. $oosql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$owhere);
  1786. while($oo=$empire->fetch($oosql)){
  1787. $newsonclass=str_replace($o[sonclass],"|",$oo[sonclass]);
  1788. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$oo[classid]'");
  1789. }
  1790. //改变新大栏目的子栏目
  1791. $where=ReturnClass($featherclass);
  1792. if(empty($where)){
  1793. $where="classid=0";
  1794. }
  1795. $nbsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  1796. while($nb=$empire->fetch($nbsql)){
  1797. if(empty($nb[sonclass]))
  1798. {$nb[sonclass]="|";}
  1799. $newsonclass=$nb[sonclass].substr($o[sonclass],1);
  1800. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$nb[classid]'");
  1801. }
  1802. }
  1803. $change=",bclassid=$add[bclassid],featherclass='$featherclass'";
  1804. }
  1805. //绑定域名应用于子栏目
  1806. if($add['UrlToSmall']){
  1807. UpdateSmallClassDomain($add['classid'],$add['classurl'],$classpath);
  1808. }
  1809. //wap模板应用于子栏目
  1810. if($add['wapstylesclass'])
  1811. {
  1812. $empire->query("update {$dbtbpre}enewsclass set wapstyleid='$add[wapstyleid]' where featherclass like '%|".$add[classid]."|%'");
  1813. }
  1814. //修改数据库资料
  1815. $sql=$empire->query("update {$dbtbpre}enewsclass set classname='$add[classname]',classpath='$classpath',classtype='$add[classtype]',newline=$add[newline],hotline=$add[hotline],goodline=$add[goodline],classurl='$add[classurl]',groupid=$add[groupid],myorder=$add[myorder],filename_qz='$add[filename_qz]',hotplline=$add[hotplline],modid=$add[modid],checked=$add[checked],firstline=$add[firstline],bname='$add[bname]',islist=$add[islist],listtempid=$add[listtempid],lencord=$add[lencord],searchtempid=$add[searchtempid],tid=$tabler[tid],tbname='$tabler[tbname]',maxnum=$add[maxnum],checkpl=$add[checkpl],down_num=$add[down_num],online_num=$add[online_num],listorder='$add[listorder]',reorder='$add[reorder]',intro='$add[intro]',classimg='$add[classimg]',jstempid=$add[jstempid],listdt=$add[listdt],showclass=$add[showclass],showdt=$add[showdt],qaddgroupid='$add[qaddgroupid]',qaddshowkey=$add[qaddshowkey],adminqinfo=$add[adminqinfo],doctime=$add[doctime],classpagekey='$add[classpagekey]',dtlisttempid='$add[dtlisttempid]',classtempid='$add[classtempid]',nreclass=$add[nreclass],nreinfo=$add[nreinfo],nrejs=$add[nrejs],nottobq=$add[nottobq],ipath='$add[ipath]',addreinfo=$add[addreinfo],haddlist=$add[haddlist],sametitle=$add[sametitle],definfovoteid=$add[definfovoteid],wburl='',qeditchecked=$add[qeditchecked],openadd=$add[openadd],wapstyleid='$add[wapstyleid]',repreinfo='$add[repreinfo]',pltempid='$add[pltempid]',cgroupid='$add[cgroupid]',yhid='$add[yhid]',wfid='$add[wfid]',cgtoinfo='$add[cgtoinfo]',bdinfoid='$add[bdinfoid]'".$change." where classid='$add[classid]'");
  1816. //副表
  1817. $ret_cr=ReturnClassAddF($add,1);
  1818. $empire->query("update {$dbtbpre}enewsclassadd set classtext='".addslashes($add[classtext])."'".$ret_cr[0]." where classid='$add[classid]'");
  1819. GetClass();
  1820. //生成栏目文件
  1821. if($add[islist]==0||$add[islist]==2)
  1822. {
  1823. $classtemp=$add[islist]==2?GetClassText($add[classid]):GetClassTemp($add['classtempid']);
  1824. NewsBq($add[classid],$classtemp,0,1);
  1825. }
  1826. elseif($add[islist]==3)
  1827. {
  1828. ReClassBdInfo($add[classid]);
  1829. }
  1830. if($add[islist]==2)
  1831. {
  1832. //删除动态模板缓存文件
  1833. DelOneTempTmpfile('classpage'.$add[classid]);
  1834. }
  1835. }
  1836. //终级栏目
  1837. else
  1838. {
  1839. if($add[modid]<>$add[oldmodid])//换系统模型
  1840. {
  1841. $chmtbr=GetModTable($add[oldmodid]);
  1842. if($chmtbr[tid]<>$tabler[tid]&&$chmtbr[tbname])
  1843. {
  1844. $chmchecknum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$chmtbr[tbname]." where classid='$add[classid]'");
  1845. if($chmchecknum)
  1846. {
  1847. printerror("ClassChangeModHaveInfo","history.go(-1)");
  1848. }
  1849. }
  1850. }
  1851. //改变大栏目
  1852. if($add[bclassid]<>$add[oldbclassid]){
  1853. //转到主栏目
  1854. if(empty($add[bclassid])){
  1855. $sonclass="";
  1856. $featherclass="";
  1857. //取得栏目原本的大栏目
  1858. $r=$empire->fetch1("select featherclass,classpath from {$dbtbpre}enewsclass where classid='$add[classid]'");
  1859. //改变原本大栏目的子栏目
  1860. $where=ReturnClass($r[featherclass]);
  1861. if(empty($where)){
  1862. $where="classid=0";
  1863. }
  1864. $bsql=$empire->query("select classid,sonclass from {$dbtbpre}enewsclass where ".$where);
  1865. while($br=$empire->fetch($bsql)){
  1866. $newsonclass=str_replace("|".$add[classid]."|","|",$br[sonclass]);
  1867. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$br[classid]'");
  1868. }
  1869. }
  1870. //转到中级栏目
  1871. else
  1872. {
  1873. //取得现在大栏目的值
  1874. $b=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classid='$add[bclassid]'");
  1875. //检测大栏目是否为终级栏目
  1876. if($b[islast])
  1877. {
  1878. printerror("BclassNotLast","");
  1879. }
  1880. if($b[wburl])
  1881. {
  1882. printerror("BclassNotWb","");
  1883. }
  1884. if(empty($b[featherclass])){
  1885. $b[featherclass]="|";
  1886. }
  1887. $featherclass=$b[featherclass].$add[bclassid]."|";
  1888. //改变新大栏目的子栏目
  1889. $where=ReturnClass($featherclass);
  1890. if(empty($where)){
  1891. $where="classid=0";
  1892. }
  1893. $bsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  1894. while($nb=$empire->fetch($bsql))
  1895. {
  1896. if(empty($nb[sonclass]))
  1897. {$nb[sonclass]="|";}
  1898. $newsonclass=$nb[sonclass].$add[classid]."|";
  1899. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$nb[classid]'");
  1900. }
  1901. //改变旧大栏目的子栏目
  1902. $o=$empire->fetch1("select sonclass,featherclass from {$dbtbpre}enewsclass where classid='$add[classid]'");
  1903. $where=ReturnClass($o[featherclass]);
  1904. if(empty($where)){
  1905. $where="classid=0";
  1906. }
  1907. $osql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  1908. while($ob=$empire->fetch($osql)){
  1909. $newsonclass=str_replace("|".$add[classid]."|","|",$ob[sonclass]);
  1910. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$ob[classid]'");
  1911. }
  1912. }
  1913. $change=",bclassid=$add[bclassid],featherclass='$featherclass'";
  1914. }
  1915. //应用于已生成的信息
  1916. if($add['tobetempinfo']){
  1917. $upsql=$empire->query("update {$dbtbpre}ecms_".$tabler[tbname]." set newstempid=$add[newstempid] where classid='$add[classid]'");
  1918. }
  1919. //文件前缀
  1920. $add[filename_qz]=RepFilenameQz($add[filename_qz]);
  1921. $sql=$empire->query("update {$dbtbpre}enewsclass set classname='$add[classname]',classpath='$classpath',classtype='$add[classtype]',link_num=$add[link_num],lencord=$add[lencord],newstempid=$add[newstempid],listtempid=$add[listtempid],newspath='$add[newspath]',filename=$add[filename],filetype='$add[filetype]',openpl=$add[openpl],openadd=$add[openadd],newline=$add[newline],hotline=$add[hotline],goodline=$add[goodline],classurl='$add[classurl]',groupid=$add[groupid],myorder=$add[myorder],filename_qz='$add[filename_qz]',hotplline=$add[hotplline],modid=$add[modid],checked=$add[checked],firstline=$add[firstline],bname='$add[bname]',searchtempid=$add[searchtempid],tid=$tabler[tid],tbname='$tabler[tbname]',maxnum=$add[maxnum],checkpl=$add[checkpl],down_num=$add[down_num],online_num=$add[online_num],listorder='$add[listorder]',reorder='$add[reorder]',intro='$add[intro]',classimg='$add[classimg]',jstempid=$add[jstempid],addinfofen=$add[addinfofen],listdt=$add[listdt],showclass=$add[showclass],showdt=$add[showdt],checkqadd=$add[checkqadd],qaddlist=$add[qaddlist],qaddgroupid='$add[qaddgroupid]',qaddshowkey=$add[qaddshowkey],adminqinfo=$add[adminqinfo],doctime=$add[doctime],classpagekey='$add[classpagekey]',dtlisttempid='$add[dtlisttempid]',classtempid='$add[classtempid]',nreclass=$add[nreclass],nreinfo=$add[nreinfo],nrejs=$add[nrejs],nottobq=$add[nottobq],ipath='$add[ipath]',addreinfo=$add[addreinfo],haddlist=$add[haddlist],sametitle=$add[sametitle],definfovoteid=$add[definfovoteid],wburl='',qeditchecked=$add[qeditchecked],wapstyleid='$add[wapstyleid]',repreinfo='$add[repreinfo]',pltempid='$add[pltempid]',cgroupid='$add[cgroupid]',yhid='$add[yhid]',wfid='$add[wfid]',cgtoinfo='$add[cgtoinfo]',bdinfoid='$add[bdinfoid]'".$change." where classid='$add[classid]'");
  1922. //副表
  1923. $ret_cr=ReturnClassAddF($add,1);
  1924. $empire->query("update {$dbtbpre}enewsclassadd set classtext='".addslashes($add[classtext])."'".$ret_cr[0]." where classid='$add[classid]'");
  1925. GetClass();
  1926. }
  1927. //移动目录
  1928. if($add[bclassid]<>$add[oldbclassid]||($add[oldclasspath]<>$classpath&&$add['classpath']==$add['oldcpath'])){
  1929. $opath="../../".$add[oldclasspath];
  1930. $newpath="../../".$classpath;
  1931. MovePath($opath,$newpath);
  1932. $opath="../../d/file/".$add[oldclasspath];
  1933. $npath="../../d/file/".$classpath;
  1934. CopyPath($opath,$npath);
  1935. }
  1936. else{
  1937. if($add['oldcpath']<>$add['classpath'])//更换栏目目录
  1938. {
  1939. AlterClassPath($add['classid'],$add['islast'],$add['oldclasspath'],$classpath);
  1940. GetClass();
  1941. }
  1942. }
  1943. //删除缓存文件
  1944. if($add[oldclassname]<>$add[classname]||$add[bclassid]<>$add[oldbclassid]){
  1945. DelListEnews();
  1946. GetSearch($add[modid]);
  1947. }
  1948. else{
  1949. if(($add[oldclasspath]<>$classpath&&$add['classpath']==$add['oldcpath'])||$add[listdt]<>$add[oldlistdt])
  1950. {
  1951. DelListEnews();
  1952. }
  1953. if($add[openadd]<>$add[oldopenadd]||$add[modid]<>$add[oldmodid]){
  1954. GetSearch($add[modid]);
  1955. if($add[modid]<>$add[oldmodid]){
  1956. GetSearch($add[oldmodid]);
  1957. }
  1958. }
  1959. }
  1960. //修改栏目扩展名
  1961. if($add[oldclasstype]<>$add[classtype]){
  1962. $todaytime=date("Y-m-d H:i:s");
  1963. if($add[islast]){
  1964. $query="select count(*) as total from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where checked=1 and classid='$add[classid]'";
  1965. $lencord=$add[oldlencord];
  1966. $num=$empire->gettotal($query);
  1967. }
  1968. else{
  1969. $lencord=$add[oldlencord];
  1970. if($add[oldislist]==1){
  1971. $where=ReturnClass($class_r[$add[classid]][sonclass]);
  1972. $query="select count(*) as total from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where checked=1 and (".$where.")";
  1973. $num=$empire->gettotal($query);
  1974. }
  1975. else
  1976. {
  1977. $num=1;
  1978. }
  1979. }
  1980. RenameListfile($add[classid],$lencord,$num,$add[oldclasstype],$add[classtype],$classpath);
  1981. }
  1982. //来源
  1983. if($add['from']){
  1984. $returnurl="ListPageClass.php";
  1985. }
  1986. else{
  1987. $returnurl="ListClass.php";
  1988. }
  1989. TogNotReClass(1);
  1990. if($sql){
  1991. insert_dolog("classid=".$add[classid]."<br>classname=".$add[classname]);//操作日志
  1992. printerror("EditClassSuccess",$returnurl);
  1993. }
  1994. else{
  1995. printerror("DbError","history.go(-1)");
  1996. }
  1997. }
  1998. //终极栏目与非终极栏目之间的转换
  1999. function ChangeClassIslast($reclassid,$userid,$username){
  2000. global $empire,$dbtbpre;
  2001. //操作权限
  2002. CheckLevel($userid,$username,$classid,"class");
  2003. $count=count($reclassid);
  2004. $classid=(int)$reclassid[0];
  2005. if($count==0||!$classid)
  2006. {
  2007. printerror("NotChangeIslastClassid","");
  2008. }
  2009. //取得本栏目信息
  2010. $r=$empire->fetch1("select classid,sonclass,featherclass,islist,islast,classname,modid,tbname,wburl from {$dbtbpre}enewsclass where classid=$classid");
  2011. if(empty($r[classid]))
  2012. {
  2013. printerror("NotChangeIslastClassid","");
  2014. }
  2015. if($r[wburl])
  2016. {
  2017. printerror("NotChangeWbClassid","");
  2018. }
  2019. //非终极栏目
  2020. if(!$r[islast])
  2021. {
  2022. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsclass where bclassid=$classid");
  2023. if($num)
  2024. {
  2025. printerror("LastTheClassHaveSonclass","history.go(-1)");
  2026. }
  2027. //修改父栏目的子栏目
  2028. $where=ReturnClass($r[featherclass]);
  2029. if(empty($where))
  2030. {
  2031. $where="classid=0";
  2032. }
  2033. $sql=$empire->query("select classid,sonclass from {$dbtbpre}enewsclass where ".$where);
  2034. while($br=$empire->fetch($sql))
  2035. {
  2036. if(empty($br[sonclass]))
  2037. {
  2038. $br[sonclass]="|";
  2039. }
  2040. $newsonclass=$br[sonclass].$classid."|";
  2041. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid=$br[classid]");
  2042. }
  2043. $dosql=$empire->query("update {$dbtbpre}enewsclass set islast=1 where classid=$classid");
  2044. $mess="ChangeClassToLastSuccess";
  2045. }
  2046. //终极栏目
  2047. else
  2048. {
  2049. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$r[tbname]." where classid=$classid");
  2050. if($num)
  2051. {
  2052. printerror("LastTheClassHaveInfo","history.go(-1)");
  2053. }
  2054. //修改父栏目的子栏目
  2055. $where=ReturnClass($r[featherclass]);
  2056. if(empty($where))
  2057. {
  2058. $where="classid=0";
  2059. }
  2060. $sql=$empire->query("select classid,sonclass from {$dbtbpre}enewsclass where ".$where);
  2061. while($br=$empire->fetch($sql))
  2062. {
  2063. if(empty($br[sonclass]))
  2064. {
  2065. $br[sonclass]="|";
  2066. }
  2067. $newsonclass=str_replace("|".$classid."|","|",$br[sonclass]);
  2068. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid=$br[classid]");
  2069. }
  2070. $dosql=$empire->query("update {$dbtbpre}enewsclass set islast=0 where classid=$classid");
  2071. $mess="ChangeClassToNolastSuccess";
  2072. }
  2073. //删除缓存文件
  2074. DelListEnews();
  2075. //更新缓存
  2076. GetClass();
  2077. GetSearch($r[modid]);
  2078. if($dosql)
  2079. {
  2080. //操作日志
  2081. insert_dolog("classid=".$classid."<br>classname=".$r[classname]);
  2082. printerror($mess,$_SERVER['HTTP_REFERER']);
  2083. }
  2084. else
  2085. {
  2086. printerror("DbError","history.go(-1)");
  2087. }
  2088. }
  2089. //删除栏目
  2090. function DelClass($classid,$userid,$username){
  2091. global $empire,$dbtbpre;
  2092. $classid=(int)$classid;
  2093. if(!$classid)
  2094. {
  2095. printerror("NotDelClassid","");
  2096. }
  2097. //操作权限
  2098. CheckLevel($userid,$username,$classid,"class");
  2099. $r=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$classid'");
  2100. if(empty($r[classid]))
  2101. {
  2102. printerror("NotClassid","history.go(-1)");
  2103. }
  2104. DelClass1($classid);
  2105. GetClass();
  2106. GetSearch($r[modid]);
  2107. //返回地址
  2108. if($_GET['from'])
  2109. {$returnurl="ListPageClass.php";}
  2110. else
  2111. {$returnurl="ListClass.php";}
  2112. TogNotReClass(1);
  2113. insert_dolog("classid=".$classid."<br>classname=".$r[classname]);//操作日志
  2114. printerror("DelClassSuccess",$returnurl);
  2115. }
  2116. //删除栏目,不返回值
  2117. function DelClass1($classid){
  2118. global $empire,$class_r,$dbtbpre;
  2119. $r=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$classid'");
  2120. //外部栏目
  2121. if($r[wburl])
  2122. {
  2123. $sql=$empire->query("delete from {$dbtbpre}enewsclass where classid='$classid'");
  2124. $empire->query("delete from {$dbtbpre}enewsclassadd where classid='$classid'");
  2125. //删除缓存
  2126. DelListEnews();
  2127. return "";
  2128. }
  2129. //删除终极栏目
  2130. if($r[islast])
  2131. {
  2132. //删除附件
  2133. DelClassTranFile($classid);
  2134. $filepath="../../d/file/".$r[classpath];
  2135. $delf=DelPath($filepath);
  2136. $usql=$empire->query("delete from {$dbtbpre}enewsfile where classid='$classid'");
  2137. //删除信息
  2138. $sql=$empire->query("delete from {$dbtbpre}ecms_".$r[tbname]." where classid='$classid'");
  2139. DelClassTbDataInfo($classid);
  2140. //删除信息附加表
  2141. $delsql=$empire->query("delete from {$dbtbpre}enewswfinfo where classid='$classid'");
  2142. $delsql=$empire->query("delete from {$dbtbpre}enewswfinfolog where classid='$classid'");
  2143. $delsql=$empire->query("delete from {$dbtbpre}enewsinfovote where classid='$classid'");
  2144. $delsql=$empire->query("delete from {$dbtbpre}enewsdiggips where classid='$classid'");
  2145. //删除栏目本身
  2146. $sql1=$empire->query("delete from {$dbtbpre}enewsclass where classid='$classid'");
  2147. $empire->query("delete from {$dbtbpre}enewsclassadd where classid='$classid'");
  2148. $delpath="../../".$r[classpath];
  2149. $del=DelPath($delpath);
  2150. //更新大栏目的子栏目
  2151. $where=ReturnClass($r[featherclass]);
  2152. if(empty($where))
  2153. {$where="classid=0";}
  2154. $bsql=$empire->query("select sonclass,classid from {$dbtbpre}enewsclass where ".$where);
  2155. while($br=$empire->fetch($bsql))
  2156. {
  2157. $newsonclass=str_replace("|".$classid."|","|",$br[sonclass]);
  2158. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$br[classid]'");
  2159. }
  2160. }
  2161. //删除大栏目
  2162. else
  2163. {
  2164. //删除栏目
  2165. $where=ReturnClass($r[sonclass]);
  2166. if(empty($where))
  2167. {$where="classid=0";}
  2168. $delcr=explode("|",$r[sonclass]);
  2169. $count=count($delcr);
  2170. for($i=1;$i<$count-1;$i++)
  2171. {
  2172. $delcid=$delcr[$i];
  2173. //删除附件
  2174. DelClassTranFile($delcid);
  2175. $sql=$empire->query("delete from {$dbtbpre}ecms_".$class_r[$delcid][tbname]." where classid='$delcid'");
  2176. DelClassTbDataInfo($delcid);
  2177. //删除信息附加表
  2178. $delsql=$empire->query("delete from {$dbtbpre}enewswfinfo where classid='$delcid'");
  2179. $delsql=$empire->query("delete from {$dbtbpre}enewswfinfolog where classid='$delcid'");
  2180. $delsql=$empire->query("delete from {$dbtbpre}enewsinfovote where classid='$delcid'");
  2181. $delsql=$empire->query("delete from {$dbtbpre}enewsdiggips where classid='$delcid'");
  2182. }
  2183. //删除附件
  2184. $filepath="../../d/file/".$r[classpath];
  2185. $delf=DelPath($filepath);
  2186. if($where<>'classid=0')
  2187. {
  2188. $usql=$empire->query("delete from {$dbtbpre}enewsfile where ".$where);
  2189. }
  2190. //删除子栏目副表
  2191. $fcsql=$empire->query("select classid from {$dbtbpre}enewsclass where featherclass like '%|".$classid."|%'");
  2192. while($fcr=$empire->fetch($fcsql))
  2193. {
  2194. $empire->query("delete from {$dbtbpre}enewsclassadd where classid='$fcr[classid]'");
  2195. }
  2196. //删除子栏目
  2197. $sql1=$empire->query("delete from {$dbtbpre}enewsclass where featherclass like '%|".$classid."|%'");
  2198. //改变父栏目的子类
  2199. $where=ReturnClass($r[featherclass]);
  2200. if(empty($where))
  2201. {$where="classid=0";}
  2202. $bbsql=$empire->query("select classid,sonclass from {$dbtbpre}enewsclass where ".$where);
  2203. while($bbr=$empire->fetch($bbsql))
  2204. {
  2205. $newsonclass=str_replace($r[sonclass],"|",$bbr[sonclass]);
  2206. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$newsonclass' where classid='$bbr[classid]'");
  2207. }
  2208. //删除栏目本身
  2209. $sql2=$empire->query("delete from {$dbtbpre}enewsclass where classid='$classid'");
  2210. $empire->query("delete from {$dbtbpre}enewsclassadd where classid='$classid'");
  2211. $delpath="../../".$r[classpath];
  2212. $del=DelPath($delpath);
  2213. }
  2214. //删除缓存
  2215. DelListEnews();
  2216. }
  2217. //删除栏目附件
  2218. function DelClassTranFile($classid){
  2219. global $empire,$class_r,$dbtbpre,$emod_r;
  2220. //删除存文本
  2221. $mid=$class_r[$classid][modid];
  2222. $savetxtf=$emod_r[$mid]['savetxtf'];
  2223. if($savetxtf)
  2224. {
  2225. $txtsql=$empire->query("select ".$savetxtf." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid'");
  2226. while($txtr=$empire->fetch($txtsql))
  2227. {
  2228. $newstextfile=$txtr[$savetxtf];
  2229. $txtr[$savetxtf]=GetTxtFieldText($txtr[$savetxtf]);
  2230. DelTxtFieldText($newstextfile);//删除文件
  2231. }
  2232. }
  2233. //删除附件
  2234. $filesql=$empire->query("select id from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid='$classid'");
  2235. while($filer=$empire->fetch($filesql))
  2236. {
  2237. DelNewsTheFile($filer[id],$classid);//删除附件
  2238. }
  2239. }
  2240. //删除栏目副表信息
  2241. function DelClassTbDataInfo($classid){
  2242. global $empire,$class_r,$dbtbpre,$emod_r;
  2243. $mid=$class_r[$classid][modid];
  2244. $tbname=$class_r[$classid][tbname];
  2245. $dtbr=explode(',',$emod_r[$mid][datatbs]);
  2246. $tbcount=count($dtbr);
  2247. for($i=1;$i<$tbcount-1;$i++)
  2248. {
  2249. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_data_".$dtbr[$i]." where classid='$classid'");
  2250. }
  2251. }
  2252. //修改栏目顺序
  2253. function EditClassOrder($classid,$myorder,$userid,$username){
  2254. global $empire,$dbtbpre;
  2255. //验证权限
  2256. CheckLevel($userid,$username,$classid,"class");
  2257. for($i=0;$i<count($classid);$i++)
  2258. {
  2259. $newmyorder=(int)$myorder[$i];
  2260. $sql=$empire->query("update {$dbtbpre}enewsclass set myorder=$newmyorder where classid='$classid[$i]'");
  2261. }
  2262. //删除缓存
  2263. DelListEnews();
  2264. //操作日志
  2265. insert_dolog("");
  2266. printerror("EditClassOrderSuccess",$_SERVER['HTTP_REFERER']);
  2267. }
  2268. //更新栏目关系
  2269. function ChangeSonclass($start,$userid,$username){
  2270. global $empire,$public_r,$fun_r,$dbtbpre;
  2271. //验证权限
  2272. CheckLevel($userid,$username,$classid,"changedata");
  2273. $start=(int)$start;
  2274. $b=0;
  2275. $sql=$empire->query("select classid from {$dbtbpre}enewsclass where islast=0 and classid>".$start." order by classid limit ".$public_r[relistnum]);
  2276. while($r=$empire->fetch($sql))
  2277. {
  2278. $b=1;
  2279. $newstart=$r[classid];
  2280. //子栏目
  2281. $sonclass="|";
  2282. $ssql=$empire->query("select classid from {$dbtbpre}enewsclass where islast=1 and featherclass like '%|".$r[classid]."|%' order by classid");
  2283. while($sr=$empire->fetch($ssql))
  2284. {
  2285. $sonclass.=$sr[classid]."|";
  2286. }
  2287. $usql=$empire->query("update {$dbtbpre}enewsclass set sonclass='$sonclass' where classid='$r[classid]'");
  2288. }
  2289. //完毕
  2290. if(empty($b))
  2291. {
  2292. GetClass();
  2293. printerror("ChangeSonclassSuccess","ReHtml/ChangeData.php");
  2294. }
  2295. echo $fun_r['OneChangeSonclassSuccess']."(ID:<font color=red><b>".$newstart."</b></font>)<script>self.location.href='ecmsclass.php?enews=ChangeSonclass&start=$newstart';</script>";
  2296. exit();
  2297. }
  2298. //删除栏目缓存文件
  2299. function DelFcListClass(){
  2300. DelListEnews();
  2301. //操作日志
  2302. insert_dolog("");
  2303. printerror("DelListEnewsSuccess","history.go(-1)");
  2304. }
  2305. //批量设置栏目
  2306. function SetMoreClass($add,$userid,$username){
  2307. global $empire,$dbtbpre;
  2308. //验证权限
  2309. CheckLevel($userid,$username,$classid,"setmclass");
  2310. //栏目
  2311. $classid=$add['classid'];
  2312. $count=count($classid);
  2313. if($count==0)
  2314. {
  2315. printerror("NotChangeSetClass","");
  2316. }
  2317. $cids='';
  2318. $dh='';
  2319. for($i=0;$i<$count;$i++)
  2320. {
  2321. $cids.=$dh.intval($classid[$i]);
  2322. $dh=',';
  2323. }
  2324. $whereclass='classid in ('.$cids.')';
  2325. $seting='';
  2326. //基本属性
  2327. if($add['doclasstype'])
  2328. {
  2329. $seting.=",classtype='$add[classtype]'";
  2330. }
  2331. if($add['dolisttempid']&&$add[listtempid])
  2332. {
  2333. $seting.=",listtempid='$add[listtempid]'";
  2334. }
  2335. if($add['dodtlisttempid'])
  2336. {
  2337. $seting.=",dtlisttempid='$add[dtlisttempid]'";
  2338. }
  2339. if($add['domaxnum'])
  2340. {
  2341. $seting.=",maxnum='$add[maxnum]'";
  2342. }
  2343. if($add['dolencord'])
  2344. {
  2345. $seting.=",lencord='$add[lencord]'";
  2346. }
  2347. if($add['dosearchtempid'])
  2348. {
  2349. $seting.=",searchtempid='$add[searchtempid]'";
  2350. }
  2351. if($add['dowapstyleid'])
  2352. {
  2353. $seting.=",wapstyleid='$add[wapstyleid]'";
  2354. }
  2355. if($add['dolistorder'])
  2356. {
  2357. $seting.=",listorder='$add[listorder]'";
  2358. }
  2359. if($add['doreorder'])
  2360. {
  2361. $seting.=",reorder='$add[reorder]'";
  2362. }
  2363. if($add['dolistdt'])
  2364. {
  2365. $seting.=",listdt='$add[listdt]'";
  2366. }
  2367. if($add['doshowdt'])
  2368. {
  2369. $seting.=",showdt='$add[showdt]'";
  2370. }
  2371. if($add['doshowclass'])
  2372. {
  2373. $seting.=",showclass='$add[showclass]'";
  2374. }
  2375. if($add['doopenadd'])
  2376. {
  2377. $seting.=",openadd='$add[openadd]'";
  2378. }
  2379. //选项设置[大栏目]
  2380. if($add['doclasstempid'])
  2381. {
  2382. $seting.=",classtempid='$add[classtempid]'";
  2383. }
  2384. if($add['doislist'])
  2385. {
  2386. $seting.=",islist='$add[islist]'";
  2387. }
  2388. //选项设置[终极栏目]
  2389. if($add['donewstempid']&&$add[newstempid])
  2390. {
  2391. $seting.=",newstempid='$add[newstempid]'";
  2392. if($add['tobetempinfo'])
  2393. {
  2394. $donewstemp=1;
  2395. }
  2396. }
  2397. if($add['dopltempid'])
  2398. {
  2399. $seting.=",pltempid='$add[pltempid]'";
  2400. }
  2401. if($add['dolink_num'])
  2402. {
  2403. $seting.=",link_num='$add[link_num]'";
  2404. }
  2405. if($add['doinfopath'])
  2406. {
  2407. if($add['infopath']==0)
  2408. {
  2409. $add['ipath']='';
  2410. }
  2411. $seting.=",ipath='$add[ipath]'";
  2412. }
  2413. if($add['donewspath'])
  2414. {
  2415. $seting.=",newspath='$add[newspath]'";
  2416. }
  2417. if($add['dofilename_qz'])
  2418. {
  2419. $seting.=",filename_qz='$add[filename_qz]'";
  2420. }
  2421. if($add['dofilename'])
  2422. {
  2423. $seting.=",filename='$add[filename]'";
  2424. }
  2425. if($add['dofiletype'])
  2426. {
  2427. $seting.=",filetype='$add[filetype]'";
  2428. }
  2429. if($add['doopenpl'])
  2430. {
  2431. $seting.=",openpl='$add[openpl]'";
  2432. }
  2433. if($add['docheckpl'])
  2434. {
  2435. $seting.=",checkpl='$add[checkpl]'";
  2436. }
  2437. if($add['doqaddshowkey'])
  2438. {
  2439. $seting.=",qaddshowkey='$add[qaddshowkey]'";
  2440. }
  2441. if($add['docheckqadd'])
  2442. {
  2443. $seting.=",checkqadd='$add[checkqadd]'";
  2444. }
  2445. if($add['doqaddgroupid'])
  2446. {
  2447. $add[qaddgroupid]=DoPostClassQAddGroupid($add[qaddgroupidck]);
  2448. $seting.=",qaddgroupid='$add[qaddgroupid]'";
  2449. }
  2450. if($add['doqaddlist'])
  2451. {
  2452. $seting.=",qaddlist='$add[qaddlist]'";
  2453. }
  2454. if($add['doaddinfofen'])
  2455. {
  2456. $seting.=",addinfofen='$add[addinfofen]'";
  2457. }
  2458. if($add['doadminqinfo'])
  2459. {
  2460. $seting.=",adminqinfo='$add[adminqinfo]'";
  2461. }
  2462. if($add['doqeditchecked'])
  2463. {
  2464. $seting.=",qeditchecked='$add[qeditchecked]'";
  2465. }
  2466. if($add['doaddreinfo'])
  2467. {
  2468. $seting.=",addreinfo='$add[addreinfo]'";
  2469. }
  2470. if($add['dohaddlist'])
  2471. {
  2472. $seting.=",haddlist='$add[haddlist]'";
  2473. }
  2474. if($add['dosametitle'])
  2475. {
  2476. $seting.=",sametitle='$add[sametitle]'";
  2477. }
  2478. if($add['dochecked'])
  2479. {
  2480. $seting.=",checked='$add[checked]'";
  2481. }
  2482. if($add['dorepreinfo'])
  2483. {
  2484. $seting.=",repreinfo='$add[repreinfo]'";
  2485. }
  2486. if($add['dodefinfovoteid'])
  2487. {
  2488. $seting.=",definfovoteid='$add[definfovoteid]'";
  2489. }
  2490. if($add['dogroupid'])
  2491. {
  2492. $seting.=",groupid='$add[groupid]'";
  2493. }
  2494. if($add['dodoctime'])
  2495. {
  2496. $seting.=",doctime='$add[doctime]'";
  2497. }
  2498. //特殊模型设置
  2499. if($add['dodown_num'])
  2500. {
  2501. $seting.=",down_num='$add[down_num]'";
  2502. }
  2503. if($add['doonline_num'])
  2504. {
  2505. $seting.=",online_num='$add[online_num]'";
  2506. }
  2507. //JS调用设置
  2508. if($add['dojstempid'])
  2509. {
  2510. $seting.=",jstempid='$add[jstempid]'";
  2511. }
  2512. if($add['donewjs'])
  2513. {
  2514. $seting.=",newline='$add[newline]'";
  2515. }
  2516. if($add['dohotjs'])
  2517. {
  2518. $seting.=",hotline='$add[hotline]'";
  2519. }
  2520. if($add['dogoodjs'])
  2521. {
  2522. $seting.=",goodline='$add[goodline]'";
  2523. }
  2524. if($add['dohotpljs'])
  2525. {
  2526. $seting.=",hotplline='$add[hotplline]'";
  2527. }
  2528. if($add['dofirstjs'])
  2529. {
  2530. $seting.=",firstline='$add[firstline]'";
  2531. }
  2532. if(empty($seting))
  2533. {
  2534. printerror("NotChangeSetClassInfo","");
  2535. }
  2536. $seting=substr($seting,1);
  2537. $sql=$empire->query("update {$dbtbpre}enewsclass set ".$seting." where ".$whereclass);
  2538. //内容模板应用于子生成的信息
  2539. if($donewstemp==1)
  2540. {
  2541. $csql=$empire->query("select classid,tbname from {$dbtbpre}enewsclass where (".$whereclass.") and islast=1");
  2542. while($r=$empire->fetch($csql))
  2543. {
  2544. $upsql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]." set newstempid='$add[newstempid]' where classid='$r[classid]'");
  2545. }
  2546. }
  2547. if($sql)
  2548. {
  2549. GetClass();
  2550. //操作日志
  2551. insert_dolog("");
  2552. printerror("SetMoreClassSuccess","SetMoreClass.php");
  2553. }
  2554. else
  2555. {printerror("DbError","");}
  2556. }
  2557. ?>