PageRenderTime 80ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/e/class/functions.php

https://github.com/westeast/xwdede
PHP | 5626 lines | 5435 code | 50 blank | 141 comment | 161 complexity | 9f83a73e9c55885693e5955cc96ccf8e MD5 | raw file
  1. <?php
  2. define('InEmpireCMSHfun',TRUE);
  3. //-------------- 公共区 ----------------------
  4. //返回后台风格
  5. function EcmsReturnAdminStyle(){
  6. global $public_r;
  7. $adminstyle=(int)getcvar('loginadminstyleid',1);
  8. if(!strstr($public_r['adminstyle'],','.$adminstyle.','))
  9. {
  10. $adminstyle=$public_r['defadminstyle']?$public_r['defadminstyle']:1;
  11. }
  12. return $adminstyle;
  13. }
  14. //返回后台管理信息栏目导航字符串
  15. function AdminReturnClassLink($classid){
  16. global $class_r,$editor,$fun_r;
  17. if($editor==1)
  18. {
  19. $addurl='../';
  20. }
  21. if(empty($class_r[$classid][featherclass]))
  22. {
  23. $class_r[$classid][featherclass]="|";
  24. }
  25. $r=explode("|",$class_r[$classid][featherclass].$classid."|");
  26. $string="<a href=\"".$addurl."ListAllInfo.php?tbname=".$class_r[$classid][tbname]."\">".$fun_r['AdminInfo']."</a>";
  27. $count=count($r)-1;
  28. for($i=1;$i<$count;$i++)
  29. {
  30. $curl=$class_r[$r[$i]][islast]?"ListNews.php?classid=".$r[$i]:"ListAllInfo.php?tbname=".$class_r[$r[$i]][tbname]."&classid=".$r[$i];
  31. $string.="&nbsp;>&nbsp;<a href=\"".$addurl."$curl\">".$class_r[$r[$i]][classname]."</a>";
  32. }
  33. return $string;
  34. }
  35. //加验证代码
  36. function AddCheckViewCode(){
  37. $code="if(!defined('InEmpireCMS'))
  38. {
  39. exit();
  40. }";
  41. return $code;
  42. }
  43. //加模板验证代码
  44. function AddCheckViewTempCode(){
  45. $code="<?php
  46. if(!defined('InEmpireCMS'))
  47. {
  48. exit();
  49. }
  50. ?>";
  51. return $code;
  52. }
  53. //后台分页
  54. function page2($num,$line,$page_line,$start,$page,$search){
  55. global $fun_r;
  56. if($num<=$line)
  57. {
  58. return '<span class="epages"><a title="'.$fun_r['admintrecord'].'">&nbsp;<b>'.$num.'</b> </a>&nbsp;&nbsp;</span>';
  59. }
  60. $search=htmlspecialchars($search,ENT_QUOTES);
  61. $url=$_SERVER['PHP_SELF'].'?page';
  62. $snum=2;//最小页数
  63. $totalpage=ceil($num/$line);//取得总页数
  64. $firststr='<a title="'.$fun_r['admintrecord'].'">&nbsp;<b>'.$num.'</b> </a>&nbsp;&nbsp;';
  65. //上一页
  66. if($page<>0)
  67. {
  68. $toppage='<a href="'.$url.'=0'.$search.'">'.$fun_r['adminstartpage'].'</a>&nbsp;';
  69. $pagepr=$page-1;
  70. $prepage='<a href="'.$url.'='.$pagepr.$search.'">'.$fun_r['adminpripage'].'</a>';
  71. }
  72. //下一页
  73. if($page!=$totalpage-1)
  74. {
  75. $pagenex=$page+1;
  76. $nextpage='&nbsp;<a href="'.$url.'='.$pagenex.$search.'">'.$fun_r['adminnextpage'].'</a>';
  77. $lastpage='&nbsp;<a href="'.$url.'='.($totalpage-1).$search.'">'.$fun_r['adminlastpage'].'</a>';
  78. }
  79. $starti=$page-$snum<0?0:$page-$snum;
  80. $no=0;
  81. for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
  82. {
  83. $no++;
  84. if($page==$i)
  85. {
  86. $is_1="<b>";
  87. $is_2="</b>";
  88. }
  89. else
  90. {
  91. $is_1='<a href="'.$url.'='.$i.$search.'">';
  92. $is_2="</a>";
  93. }
  94. $pagenum=$i+1;
  95. $returnstr.="&nbsp;".$is_1.$pagenum.$is_2;
  96. }
  97. $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
  98. return '<span class="epages">'.$returnstr.'</span>';
  99. }
  100. //后台分页
  101. function postpage($num,$line,$page_line,$start,$page,$form){
  102. global $fun_r;
  103. if($num<=$line)
  104. {
  105. return '';
  106. }
  107. $snum=2;//最小页数
  108. $totalpage=ceil($num/$line);//取得总页数
  109. $firststr='<a title="'.$fun_r['admintrecord'].'">&nbsp;<b>'.$num.'</b> </a>&nbsp;&nbsp;';
  110. //上一页
  111. if($page<>0)
  112. {
  113. $toppage='<a href="#ecms" onclick="javascript:GotoPostPage(0,0);">'.$fun_r['adminstartpage'].'</a>&nbsp;';
  114. $pagepr=$page-1;
  115. $prepage='<a href="#ecms" onclick="javascript:GotoPostPage('.$pagepr.',0);">'.$fun_r['adminpripage'].'</a>';
  116. }
  117. //下一页
  118. if($page!=$totalpage-1)
  119. {
  120. $pagenex=$page+1;
  121. $nextpage='&nbsp;<a href="#ecms" onclick="javascript:GotoPostPage('.$pagenex.',0);">'.$fun_r['adminnextpage'].'</a>';
  122. $lastpage='&nbsp;<a href="#ecms" onclick="javascript:GotoPostPage('.($totalpage-1).',0);">'.$fun_r['adminlastpage'].'</a>';
  123. }
  124. $starti=$page-$snum<0?0:$page-$snum;
  125. $no=0;
  126. for($i=$starti;$i<$totalpage&&$no<$page_line;$i++)
  127. {
  128. $no++;
  129. if($page==$i)
  130. {
  131. $is_1="<b>";
  132. $is_2="</b>";
  133. }
  134. else
  135. {
  136. $is_1='<a href="#ecms" onclick="javascript:GotoPostPage('.$i.',0);">';
  137. $is_2="</a>";
  138. }
  139. $pagenum=$i+1;
  140. $returnstr.="&nbsp;".$is_1.$pagenum.$is_2;
  141. }
  142. $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
  143. $returnstr.="<script>
  144. function GotoPostPage(page,start){
  145. ".$form.".page.value=page;
  146. ".$form.".start.value=start;
  147. ".$form.".submit();
  148. }
  149. </script>";
  150. return $returnstr;
  151. }
  152. //取得模型表名
  153. function GetModTable($mid){
  154. global $empire,$dbtbpre;
  155. $r=$empire->fetch1("select tid,tbname from {$dbtbpre}enewsmod where mid='$mid'");
  156. return $r;
  157. }
  158. //建立专题目录
  159. function CreateZtPath($ztpath){
  160. $createpath=ECMS_PATH.$ztpath;
  161. $mk=DoMkdir($createpath);
  162. }
  163. //建立栏目目录
  164. function CreateClassPath($classpath){
  165. $createpath=ECMS_PATH.$classpath;
  166. $mk=DoMkdir($createpath);
  167. $createfilepath=ECMS_PATH.'d/file/'.$classpath;//建立附件目录
  168. $mk1=DoMkdir($createfilepath);
  169. }
  170. //删除栏目缓存文件
  171. function DelListEnews(){
  172. $file=ECMS_PATH."e/data/fc/ListEnews.php";
  173. DelFiletext($file);
  174. $file1=ECMS_PATH."e/data/fc/ListClass0.php";
  175. DelFiletext($file1);
  176. $file2=ECMS_PATH."e/data/fc/ListClass1.php";
  177. DelFiletext($file2);
  178. }
  179. //删除模板临时缓存文件
  180. function DelOneTempTmpfile($classid){
  181. $file=ECMS_PATH.'e/data/tmp/dt_temp'.$classid.'.php';
  182. if(file_exists($file))
  183. {
  184. DelFiletext($file);
  185. }
  186. }
  187. //替换php代码
  188. function RepPhpAspJspcode($string){
  189. global $public_r;
  190. if(!$public_r[candocode]){
  191. //$string=str_replace("<?xml","[!--ecms.xml--]",$string);
  192. $string=str_replace("<\\","&lt;\\",$string);
  193. $string=str_replace("<?","&lt;?",$string);
  194. $string=str_replace("<%","&lt;%",$string);
  195. if(stristr($string,' language'))
  196. {
  197. $string=preg_replace(array('!<script!i','!</script>!i'),array('&lt;script','&lt;/script&gt;'),$string);
  198. }
  199. //$string=str_replace("[!--ecms.xml--]","<?xml",$string);
  200. }
  201. return $string;
  202. }
  203. //替换php代码
  204. function RepPhpAspJspcodeText($string){
  205. //$string=str_replace("<?xml","[!--ecms.xml--]",$string);
  206. $string=str_replace("<\\","&lt;\\",$string);
  207. $string=str_replace("<?","&lt;?",$string);
  208. $string=str_replace("<%","&lt;%",$string);
  209. if(stristr($string,' language'))
  210. {
  211. $string=preg_replace(array('!<script!i','!</script>!i'),array('&lt;script','&lt;/script&gt;'),$string);
  212. }
  213. //$string=str_replace("[!--ecms.xml--]","<?xml",$string);
  214. $string=str_replace("<!--code.start-->","&lt;!--code.start--&gt;",$string);
  215. $string=str_replace("<!--code.end-->","&lt;!--code.end--&gt;",$string);
  216. return $string;
  217. }
  218. //替换文件前缀
  219. function RepFilenameQz($qz,$ecms=0){
  220. if(empty($ecms))
  221. {
  222. $qz=str_replace("/","",$qz);
  223. $qz=str_replace("\\","",$qz);
  224. }
  225. $qz=str_replace("#","",$qz);
  226. $qz=str_replace("&","",$qz);
  227. $qz=str_replace(":","",$qz);
  228. $qz=str_replace(";","",$qz);
  229. $qz=str_replace("<","",$qz);
  230. $qz=str_replace(">","",$qz);
  231. $qz=str_replace("?","",$qz);
  232. $qz=str_replace("*","",$qz);
  233. $qz=str_replace("%","",$qz);
  234. $qz=str_replace("|","",$qz);
  235. $qz=str_replace("\"","",$qz);
  236. $qz=str_replace("'","",$qz);
  237. $qz=str_replace(".","",$qz);
  238. return $qz;
  239. }
  240. //替换目录值
  241. function RepPathStr($path){
  242. $path=str_replace("\\","",$path);
  243. $path=str_replace("/","",$path);
  244. return $path;
  245. }
  246. //返回替换字符
  247. function ReturnCheckDoRep(){
  248. global $empire,$dbtbpre;
  249. //信息来源
  250. $befrom=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbefrom");
  251. //作者
  252. $writer=$empire->gettotal("select count(*) as total from {$dbtbpre}enewswriter");
  253. //替换字符
  254. $words=$empire->gettotal("select count(*) as total from {$dbtbpre}enewswords");
  255. //内容关键字
  256. $key=$empire->gettotal("select count(*) as total from {$dbtbpre}enewskey");
  257. $str=",$befrom,$writer,$words,$key,";
  258. return $str;
  259. }
  260. //返回替换验证
  261. function ReturnCheckDoRepStr(){
  262. global $public_r;
  263. return explode(',',$public_r[checkdorepstr]);
  264. }
  265. //取得栏目目录名称
  266. function GetPathname($classname){
  267. $c=explode("/",$classname);
  268. $count=count($c)-1;
  269. $cr[0]=$c[$count];//栏目目录名
  270. $len=strlen($cr[0]);
  271. //上级栏目目录名
  272. $cr[1]=substr($classname,0,strlen($classname)-$len);
  273. return $cr;
  274. }
  275. //更新缓存
  276. function ChangeEnewsData($userid,$username){
  277. //操作权限
  278. CheckLevel($userid,$username,$classid,"changedata");
  279. //更新参数设置
  280. GetConfig(1);
  281. //更新类别
  282. GetClass();
  283. //更新会员组
  284. GetMemberLevel();
  285. //更新全站搜索数据表
  286. GetSearchAllTb();
  287. //操作日志
  288. insert_dolog("");
  289. printerror("ChangeDataSuccess","history.go(-1)");
  290. }
  291. //返回文件名
  292. function ReturnPathFile($filename){
  293. $fr=explode("/",$filename);
  294. $count=count($fr)-1;
  295. return $fr[$count];
  296. }
  297. //返回栏目链接(无缓存)
  298. function sys_ReturnBqClassUrl($r){
  299. global $public_r;
  300. //外部栏目
  301. if($r[wburl])
  302. {
  303. $classurl=$r[wburl];
  304. }
  305. //动态列表
  306. elseif($r['listdt'])
  307. {
  308. $classurl=$public_r['newsurl']."e/action/ListInfo/?classid=$r[classid]";
  309. }
  310. elseif($r['classurl'])
  311. {
  312. $classurl=$r['classurl'];
  313. }
  314. else
  315. {
  316. $classurl=$public_r['newsurl'].$r['classpath']."/";
  317. }
  318. return $classurl;
  319. }
  320. //返回专题链接(无缓存)
  321. function sys_ReturnBqZtUrl($r){
  322. global $public_r;
  323. if($r['zturl'])
  324. {
  325. $zturl=$r['zturl'];
  326. }
  327. else
  328. {
  329. $zturl=$public_r['newsurl'].$r['ztpath']."/";
  330. }
  331. return $zturl;
  332. }
  333. //组合两数组
  334. function TogTwoArray($r,$ra){
  335. $returnr=array_merge($r,$ra);
  336. return $returnr;
  337. }
  338. //下载
  339. function DownLoadFile($file,$filepath,$ecms=0){
  340. if(empty($file))
  341. {
  342. printerror("FileNotExist","history.go(-1)");
  343. }
  344. if(!file_exists($filepath))
  345. {
  346. printerror("FileNotExist","");
  347. }
  348. $filesize=@filesize($filepath);
  349. //下载
  350. Header("Content-type: application/octet-stream");
  351. Header("Accept-Ranges: bytes");
  352. Header("Accept-Length: ".$filesize);
  353. Header("Content-Disposition: attachment; filename=".$file);
  354. echo ReadFiletext($filepath);
  355. if($ecms==1)
  356. {
  357. DelFiletext($filepath);
  358. }
  359. }
  360. //取得缓存文件内容
  361. function GetFcfiletext($file){
  362. $str1="document.write(\"";
  363. $str2="\");";
  364. $text=ReadFiletext($file);
  365. $text=stripSlashes(str_replace($str2,"",str_replace($str1,"",$text)));
  366. return $text;
  367. }
  368. //验证模板组是否存在
  369. function CheckTempGroup($gid){
  370. global $empire,$dbtbpre;
  371. if(empty($gid))
  372. {
  373. $gid=GetDoTempGid();
  374. }
  375. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid='$gid'");
  376. if(empty($r['gid']))
  377. {
  378. printerror("ErrorUrl","");
  379. }
  380. return $r['gname'];
  381. }
  382. //附加隐藏表单项
  383. function ReturnFormHidden($vname,$value){
  384. $value=htmlspecialchars(ClearAddsData($value));
  385. return "<input type=hidden name=\"".$vname."\" value=\"".$value."\">";
  386. }
  387. //-------------- 信息处理区 ----------------------
  388. //替换关键字
  389. function ReplaceKey($newstext){
  390. global $empire,$dbtbpre,$public_r;
  391. if(empty($newstext))
  392. {return $newstext;}
  393. $sql=$empire->query("select keyname,keyurl from {$dbtbpre}enewskey");
  394. while($r=$empire->fetch($sql))
  395. {
  396. $newstext=empty($public_r[repkeynum])?str_replace($r[keyname],'<a href='.$r[keyurl].' target=_blank class=infotextkey>'.$r[keyname].'</a>',$newstext):preg_replace('/'.$r[keyname].'/','<a href='.$r[keyurl].' target=_blank class=infotextkey>'.$r[keyname].'</a>',$newstext,$public_r[repkeynum]);
  397. }
  398. return $newstext;
  399. }
  400. //替换禁用字符
  401. function ReplaceWord($newstext){
  402. global $empire,$dbtbpre;
  403. if(empty($newstext))
  404. {return $newstext;}
  405. $sql=$empire->query("select newword,oldword from {$dbtbpre}enewswords");
  406. while($r=$empire->fetch($sql))
  407. {
  408. $newstext=str_replace($r[oldword],$r[newword],$newstext);
  409. }
  410. return $newstext;
  411. }
  412. //编辑信息时替换关键字和过滤字符
  413. function DoReplaceKeyAndWord($newstext,$dokey){
  414. global $public_r;
  415. $docheckrep=ReturnCheckDoRepStr();//返回替换验证字符
  416. if($public_r['dorepword']==1&&$docheckrep[3])//过滤字符
  417. {
  418. $newstext=ReplaceWord($newstext);
  419. }
  420. if($public_r['dorepkey']==1&&$docheckrep[4]&&!empty($dokey))//内容关键字
  421. {
  422. $newstext=ReplaceKey($newstext);
  423. }
  424. return $newstext;
  425. }
  426. //重命名列表文件
  427. function RenameListfile($classid,$lencord,$num,$type,$newtype,$classpath){
  428. $page=ceil($num/$lencord);
  429. for($j=1;$j<=$page;$j++)
  430. {
  431. if($j==1)
  432. {
  433. $listfile=ECMS_PATH.$classpath."/index";
  434. }
  435. else
  436. {
  437. $listfile=ECMS_PATH.$classpath."/index_".$j;
  438. }
  439. @rename($listfile.$type,$listfile.$newtype);
  440. }
  441. }
  442. //组合标题属性
  443. function TitleFont($titlefont,$titlecolor=''){
  444. $add=$titlecolor.',';
  445. if($titlecolor=='no')
  446. {
  447. $add='';
  448. }
  449. if($titlefont[b])//粗体
  450. {$add.='b|';}
  451. if($titlefont[i])//斜体
  452. {$add.='i|';}
  453. if($titlefont[s])//删除线
  454. {$add.='s|';}
  455. if($add==',')
  456. {
  457. $add='';
  458. }
  459. return $add;
  460. }
  461. //组合专题ID
  462. function ZtId($ztid){
  463. for($i=0;$i<count($ztid);$i++)
  464. {
  465. $myztid.=intval($ztid[$i]).'|';
  466. }
  467. if($myztid)
  468. {
  469. $myztid='|'.$myztid;
  470. }
  471. return $myztid;
  472. }
  473. //信息送审
  474. function InfoInsertToWorkflow($id,$classid,$wfid,$userid,$username){
  475. global $empire,$dbtbpre,$class_r;
  476. $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfid' order by tno limit 1");
  477. //状态更新
  478. $empire->query("insert into {$dbtbpre}enewswfinfo(id,classid,wfid,tid,groupid,userclass,username,checknum,tstatus,checktno) values('$id','$classid','$wfid','$wfitemr[tid]','$wfitemr[groupid]','$wfitemr[userclass]','$wfitemr[username]',1,'$wfitemr[tstatus]',0);");
  479. //日志
  480. InsertWfLog($classid,$id,$wfid,0,$username,'',1,0);
  481. }
  482. //信息返工送审
  483. function InfoUpdateToWorkflow($id,$classid,$wfid,$userid,$username){
  484. global $empire,$dbtbpre,$class_r;
  485. $wfinfor=$empire->fetch1("select checknum,wfid,tid,checktno from {$dbtbpre}enewswfinfo where id='$id' and classid='$classid' limit 1");
  486. if($wfinfor[checktno]!='101')
  487. {
  488. return '';
  489. }
  490. if($wfinfor[tid])
  491. {
  492. $ywfitemr=$empire->fetch1("select tno from {$dbtbpre}enewsworkflowitem where tid='$wfinfor[tid]'");
  493. $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfinfor[wfid]' and tno>$ywfitemr[tno] order by tno limit 1");
  494. }
  495. else
  496. {
  497. $wfitemr=$empire->fetch1("select tid,tno,groupid,userclass,username,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfinfor[wfid]' order by tno limit 1");
  498. }
  499. //状态更新
  500. $empire->query("update {$dbtbpre}enewswfinfo set tid='$wfitemr[tid]',groupid='$wfitemr[groupid]',userclass='$wfitemr[userclass]',username='$wfitemr[username]',checknum=checknum+1,tstatus='$wfitemr[tstatus]',checktno='0' where id='$id' and classid='$classid' limit 1");
  501. //日志
  502. InsertWfLog($classid,$id,$wfinfor[wfid],0,$username,'',$wfinfor[checknum],0);
  503. }
  504. //写入签发日志
  505. function InsertWfLog($classid,$id,$wfid,$tid,$username,$checktext,$checknum,$checktype){
  506. global $empire,$dbtbpre,$class_r,$lur;
  507. $checktime=time();
  508. $checktext=RepPostStr($checktext);
  509. $empire->query("insert into {$dbtbpre}enewswfinfolog(id,classid,wfid,tid,username,checktime,checktext,checknum,checktype) values('$id','$classid','$wfid','$tid','$username','$checktime','$checktext','$checknum','$checktype');");
  510. }
  511. //加入TAG表
  512. function eInsertTags($tags,$classid,$id,$newstime){
  513. global $empire,$dbtbpre,$class_r;
  514. if(!trim($tags))
  515. {
  516. return '';
  517. }
  518. $tags=RepPostVar($tags);
  519. $classid=(int)$classid;
  520. $id=(int)$id;
  521. $mid=(int)$class_r[$classid][modid];
  522. $tr=explode(',',$tags);
  523. $count=count($tr);
  524. for($i=0;$i<$count;$i++)
  525. {
  526. $tagname=$tr[$i];
  527. if(empty($tagname))
  528. {
  529. continue;
  530. }
  531. $r=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tagname' limit 1");
  532. if($r[tagid])
  533. {
  534. $datar=$empire->fetch1("select tagid,classid,newstime from {$dbtbpre}enewstagsdata where tagid='$r[tagid]' and id='$id' and mid='$mid' limit 1");
  535. if($datar[tagid])
  536. {
  537. if($datar[classid]!=$classid||$datar[newstime]!=$newstime)
  538. {
  539. $empire->query("update {$dbtbpre}enewstagsdata set classid='$classid',newstime='$newstime' where tagid='$r[tagid]' and id='$id' and mid='$mid' limit 1");
  540. }
  541. }
  542. else
  543. {
  544. $empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$r[tagid]'");
  545. $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$r[tagid]','$classid','$id','$newstime','$mid');");
  546. }
  547. }
  548. else
  549. {
  550. $empire->query("insert into {$dbtbpre}enewstags(tagname,num,isgood,cid) values('$tagname',1,0,0);");
  551. $tagid=$empire->lastid();
  552. $empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$tagid','$classid','$id','$newstime','$mid');");
  553. }
  554. }
  555. }
  556. //返回信息TAGS
  557. function eReturnInfoTags($classid,$id,$mid){
  558. global $empire,$dbtbpre,$class_r;
  559. if(!$mid||!$id)
  560. {
  561. return '';
  562. }
  563. $tags='';
  564. $dh='';
  565. $sql=$empire->query("select tagid from {$dbtbpre}enewstagsdata where id='$id' and mid='$mid' order by tagid");
  566. while($r=$empire->fetch($sql))
  567. {
  568. $tr=$empire->fetch1("select tagname from {$dbtbpre}enewstags where tagid='$r[tagid]'");
  569. $tags.=$dh.$tr[tagname];
  570. $dh=',';
  571. }
  572. return $tags;
  573. }
  574. //返回命名方式
  575. function ReturnInfoFilename($classid,$id,$filenameqz){
  576. global $class_r;
  577. if($class_r[$classid][filename]==1) //time命名
  578. {
  579. $filename=$class_r[$classid][filename_qz].time().$id;
  580. }
  581. elseif($class_r[$classid][filename]==2) //md5命名
  582. {
  583. $filename=$class_r[$classid][filename_qz].md5(uniqid(microtime()));
  584. }
  585. elseif($class_r[$classid][filename]==3) //目录
  586. {
  587. $filename=$class_r[$classid][filename_qz].$id.'/index';
  588. }
  589. else //id
  590. {
  591. $filename=$class_r[$classid][filename_qz].$id;
  592. }
  593. $filename=$filenameqz.$filename;
  594. return $filename;
  595. }
  596. //更新相应的附件
  597. function UpdateTheFile($id,$checkpass){
  598. global $empire,$dbtbpre;
  599. if(empty($id)||empty($checkpass))
  600. {
  601. return "";
  602. }
  603. $id=(int)$id;
  604. $checkpass=(int)$checkpass;
  605. $sql=$empire->query("update {$dbtbpre}enewsfile set id=$id,cjid=0 where cjid=$checkpass");
  606. }
  607. //修改时更新附件
  608. function UpdateTheFileEdit($classid,$id){
  609. global $empire,$dbtbpre;
  610. $sql=$empire->query("update {$dbtbpre}enewsfile set cjid=0 where id='$id' and classid='$classid'");
  611. }
  612. //更新ispic标识
  613. function UpdateTheIspic($classid,$id){
  614. global $empire,$dbtbpre,$class_r;
  615. $r=$empire->fetch1("select titlepic,ispic from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' limit 1");
  616. $ispic=$r['titlepic']?1:0;
  617. if($ispic<>$r['ispic'])
  618. {
  619. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]." set ispic='$ispic' where id='$id'");
  620. }
  621. }
  622. //取第几张图片
  623. function GetFpicToTpic($classid,$id,$num=1,$getfirsttitlespic=0,$swidth=0,$sheight=0){
  624. global $empire,$dbtbpre,$public_r,$class_r;
  625. $num=$num-1;
  626. $picr=$empire->fetch1("select fileid,filename,path,id,classid,no,fpath from {$dbtbpre}enewsfile where id=$id and classid=$classid and type=1 order by fileid limit $num,1");
  627. $firsttitlepic="";
  628. if($picr['fileid'])
  629. {
  630. $rpath=$picr['path']?$picr['path'].'/':$picr['path'];
  631. $fspath=ReturnFileSavePath($picr[classid],$picr[fpath]);
  632. if($getfirsttitlespic==1&&$swidth&&$sheight)//缩略图
  633. {
  634. $path="../../".$fspath['filepath'].$rpath;
  635. $yname=$path.$picr[filename];
  636. $filetype=GetFiletype($picr[filename]);
  637. $insertfile=substr($picr[filename],0,strlen($picr[filename])-strlen($filetype)).time();
  638. $name=$path."small".$insertfile;
  639. $sfiler=GetMySmallImg($classid,$picr[no],$insertfile,$picr[path],$yname,$swidth,$sheight,$name,$add['filepass'],$add['filepass'],$userid,$username);
  640. $firsttitlepic=$fspath['fileurl'].$rpath."small".$insertfile.$sfiler['filetype'];
  641. }
  642. else
  643. {
  644. $firsttitlepic=$fspath['fileurl'].$rpath.$picr[filename];
  645. }
  646. }
  647. return $firsttitlepic;
  648. }
  649. //更新替换图片下一页链接内容
  650. function UpdateImgNexturl($classid,$id){
  651. global $empire,$dbtbpre,$class_r,$public_r,$emod_r;
  652. $mid=$class_r[$classid][modid];
  653. $tbname=$class_r[$classid][tbname];
  654. $pf=$emod_r[$mid]['pagef'];
  655. $stf=$emod_r[$mid]['savetxtf'];
  656. if(!$pf)
  657. {
  658. return '';
  659. }
  660. //分页字段
  661. $tbdataf=strstr($emod_r[$mid]['tbdataf'],','.$pf.',')?1:0;
  662. if($tbdataf)
  663. {
  664. $r=$empire->fetch1("select id,classid,titleurl,groupid,newspath,filename,stb from {$dbtbpre}ecms_".$tbname." where id='$id'");
  665. $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$id'");
  666. $r[$pf]=$finfor[$pf];
  667. }
  668. else
  669. {
  670. $r=$empire->fetch1("select id,classid,titleurl,groupid,newspath,filename,".$pf." from {$dbtbpre}ecms_".$tbname." where id='$id'");
  671. }
  672. //存文本
  673. if($stf&&$stf==$pf)
  674. {
  675. $newstextfile=$r[$stf];
  676. $r[$stf]=GetTxtFieldText($r[$stf]);
  677. }
  678. if(!$r[$pf])
  679. {
  680. return '';
  681. }
  682. $newstext=RepNewstextImgLink($r[$pf],$r);
  683. if(empty($newstext))
  684. {
  685. return '';
  686. }
  687. //存文本
  688. if($stf&&$stf==$pf)
  689. {
  690. EditTxtFieldText($newstextfile,$newstext);
  691. return '';
  692. }
  693. if($tbdataf)
  694. {
  695. $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." set ".$pf."='$newstext' where id='$id'");
  696. }
  697. else
  698. {
  699. $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$pf."='$newstext' where id='$id'");
  700. }
  701. }
  702. //给图片加下一页链接
  703. function RepNewstextImgLink($newstext,$add){
  704. global $public_r;
  705. $expage='[!--empirenews.page--]';//分页符
  706. if(!stristr($newstext,$expage)||!stristr($newstext,'<img '))
  707. {
  708. return '';
  709. }
  710. $newstext=stripSlashes($newstext);
  711. $repurl='[!--empirecms.rep.nextpageurl--]';
  712. $newstext=DoRepImgLink($newstext,$repurl);
  713. $nr=explode($expage,$newstext);
  714. $count=count($nr);
  715. //页面地址
  716. $urlqzr=ReturnInfoPageQz($add);
  717. $lastpageurl=$public_r['newsurl'].'e/public/ClassUrl/?classid='.$add['classid']; //最后一页链接地址
  718. $new_newstext='';
  719. $addexpage='';
  720. for($i=0;$i<$count;$i++)
  721. {
  722. $thispagetext=$nr[$i];
  723. if(stristr($thispagetext,'<img '))
  724. {
  725. if($i==$count-1)
  726. {
  727. $newurl=$lastpageurl;
  728. }
  729. else
  730. {
  731. //下一页链接
  732. if($urlqzr['nametype']==1)
  733. {
  734. $newurl=$urlqzr['titleurl'].'&page='.($i+1);
  735. }
  736. else
  737. {
  738. $newurl=$urlqzr['titleurl'].'_'.($i+2).$urlqzr['filetype'];
  739. }
  740. }
  741. $thispagetext=str_replace($repurl,$newurl,$thispagetext);
  742. }
  743. $new_newstext.=$addexpage.$thispagetext;
  744. $addexpage=$expage;
  745. }
  746. return addslashes($new_newstext);
  747. }
  748. //返回相关链接信息ID
  749. function GetKeyid($keyboard,$classid,$id,$link_num){
  750. global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$eyh_r,$etable_r;
  751. if($keyboard)
  752. {
  753. if(empty($link_num))
  754. {
  755. return '';
  756. }
  757. $keyboard=RepDyh($keyboard);
  758. $r=explode(",",$keyboard);
  759. for($i=0;$i<count($r);$i++)
  760. {
  761. if($i==0)
  762. {
  763. $or="";
  764. }
  765. else
  766. {
  767. $or=" or ";
  768. }
  769. $repadd.=$or."[!--f--!]"." like '%".$r[$i]."%'";
  770. }
  771. //搜索范围
  772. if($public_r['newslink']==1)
  773. {
  774. $add='('.str_replace('[!--f--!]','keyboard',$repadd).')';
  775. }
  776. elseif($public_r['newslink']==2)
  777. {
  778. $add='('.str_replace('[!--f--!]','keyboard',$repadd).' or '.str_replace('[!--f--!]','title',$repadd).')';
  779. }
  780. else
  781. {
  782. $add='('.str_replace('[!--f--!]','title',$repadd).')';
  783. }
  784. //模型
  785. if(!empty($class_r[$classid][modid]))
  786. {
  787. $mr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='".$class_r[$classid][modid]."'");
  788. $where=" and (".ReturnClass($mr[sonclass]).")";
  789. }
  790. //优化
  791. $tbname=$class_r[$classid][tbname];
  792. $yhvar='otherlink';
  793. $yhid=$etable_r[$tbname][yhid];
  794. $yhadd='';
  795. if($yhid)
  796. {
  797. $yhadd=ReturnYhSql($yhid,$yhvar);
  798. }
  799. //ID声名
  800. $keyid="";
  801. $first=0;
  802. $key_sql=$empire->query("select id from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd.$add.$where." and id<>$id and checked=1 order by newstime desc limit $link_num");
  803. while($link_r=$empire->fetch($key_sql))
  804. {
  805. if(empty($first))
  806. {
  807. $dh="";
  808. $first=1;
  809. }
  810. else
  811. {
  812. $dh=",";
  813. }
  814. $keyid.=$dh.$link_r[id];
  815. }
  816. }
  817. else
  818. {
  819. $keyid="";
  820. }
  821. return $keyid;
  822. }
  823. //删除信息附件
  824. function DelNewsTheFile($id,$classid,$delpl=0){
  825. global $empire,$dbtbpre;
  826. if(empty($id))
  827. {
  828. return "";
  829. }
  830. $i=0;
  831. $sql=$empire->query("select classid,filename,path,fpath from {$dbtbpre}enewsfile where id='$id' and classid='$classid'");
  832. while($r=$empire->fetch($sql))
  833. {
  834. $i=1;
  835. DoDelFile($r);
  836. }
  837. if($i)
  838. {
  839. $empire->query("delete from {$dbtbpre}enewsfile where id='$id' and classid='$classid'");
  840. }
  841. //删除评论
  842. if($delpl==0)
  843. {
  844. $empire->query("delete from {$dbtbpre}enewspl where id='$id' and classid='$classid'");
  845. $tbr=$empire->fetch1("select pldatatbs from {$dbtbpre}enewspublic limit 1");
  846. if($tbr['pldatatbs'])
  847. {
  848. $dtbr=explode(',',$tbr['pldatatbs']);
  849. $count=count($dtbr)-1;
  850. for($i=1;$i<$count;$i++)
  851. {
  852. $empire->query("delete from {$dbtbpre}enewspl_data_".$dtbr[$i]." where id='$id' and classid='$classid'");
  853. }
  854. }
  855. }
  856. }
  857. //删除信息文件
  858. function DelNewsFile($filename,$newspath,$classid,$newstext,$groupid=0){
  859. global $class_r,$addgethtmlpath;
  860. //文件类型
  861. if($groupid)
  862. {
  863. $filetype=".php";
  864. }
  865. else
  866. {
  867. $filetype=$class_r[$classid][filetype];
  868. }
  869. //是否有日期目录
  870. if(empty($newspath))
  871. {
  872. $mynewspath="";
  873. }
  874. else
  875. {
  876. $mynewspath=$newspath."/";
  877. }
  878. $iclasspath=ReturnSaveInfoPath($classid,$id);
  879. $r=explode("[!--empirenews.page--]",$newstext);
  880. for($i=1;$i<=count($r);$i++)
  881. {
  882. if(strstr($filename,'/'))
  883. {
  884. DelPath(ECMS_PATH.$iclasspath.$mynewspath.ReturnInfoSPath($filename));
  885. }
  886. else
  887. {
  888. if($i==1)
  889. {
  890. $file=ECMS_PATH.$iclasspath.$mynewspath.$filename.$filetype;
  891. }
  892. else
  893. {
  894. $file=ECMS_PATH.$iclasspath.$mynewspath.$filename."_".$i.$filetype;
  895. }
  896. DelFiletext($file);
  897. }
  898. }
  899. }
  900. //替换图片标签
  901. function RepImg($text,$copyflash){
  902. global $saveurlimgclearurl;
  903. $exp1="[--copyimg--]";
  904. $exp2="[/--copyimg--]";
  905. //去掉图片链接
  906. if($saveurlimgclearurl==1)
  907. {
  908. $zz2="/\<(a|A) (.*?)(href|Href)=('|\"|\\\\\"|)(.+?)><(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP|.jpeg|.JPEG)(.*?)><\/(a|A)>/is";
  909. $text=preg_replace($zz2,"<\\6 \\7\\8=\\9\\10\\11\\12>",$text);
  910. }
  911. $zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP|.jpeg|.JPEG)(.*?)>/is";
  912. $text=preg_replace($zz1,"<\\1 \\2\\3=\\4".$exp1."\\5\\6".$exp2."\\7>",$text);
  913. return $text;
  914. }
  915. //替换flash标签
  916. function RepFlash($text,$copyflash){
  917. $exp1="[--copyimg--]";
  918. $exp2="[/--copyimg--]";
  919. //去掉flash多余链接
  920. $zz2="/\<(embed|EMBED) (.*?)(src|SRC)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>(.*?)<\/(embed|EMBED)>/is";
  921. $text=preg_replace($zz2,"",$text);
  922. $zz3="/\<(param|PARAM) (name|NAME)=\"(Src|src|SRC)\" (.*?)(value|VALUE)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>/is";
  923. $text=preg_replace($zz3,"",$text);
  924. $zz1="/\<(param|PARAM) (.*?)(name|NAME)=\"(movie|MOVIE)\" (.*?)(value|VALUE)=('|\"|\\\\\"|)(.+?)(.swf|.SWF)(.*?)>/is";
  925. $text=preg_replace($zz1,"<\\1 \\2\\3=\"\\4\" \\5\\6=\\7".$exp1."\\8\\9".$exp2."\\10>",$text);
  926. return $text;
  927. }
  928. //替换图片链接
  929. function DoRepImgLink($text,$newurl){
  930. //去掉图片链接
  931. $zz2="/\<(a|A) (.*?)(href|Href)=('|\"|\\\\\"|)(.+?)><(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.*?)><\/(a|A)>/is";
  932. $text=preg_replace($zz2,"<\\6 \\7\\8=\\9\\10>",$text);
  933. //新链接
  934. $zz1="/\<(img|IMG) (.*?)(src|SRC)=('|\"|\\\\\"|)(.*?)>/is";
  935. $text=preg_replace($zz1,"<a href=\"".$newurl."\"><\\1 \\2\\3=\\4\\5></a>",$text);
  936. return $text;
  937. }
  938. //截取图片
  939. function CopyImg($text,$copyimg,$copyflash,$classid,$qz,$username,$theid,$cjid,$mark){
  940. global $empire,$public_r,$cjnewsurl,$navtheid,$dbtbpre;
  941. if(empty($text))
  942. {return "";}
  943. if($copyimg)
  944. {
  945. $text=RepImg($text,$copyflash);
  946. }
  947. if($copyflash)
  948. {$text=RepFlash($text,$copyflash);}
  949. $exp1="[--copyimg--]";
  950. $exp2="[/--copyimg--]";
  951. $r=explode($exp1,$text);
  952. for($i=1;$i<count($r);$i++)
  953. {
  954. $r1=explode($exp2,$r[$i]);
  955. if(strstr($r1[0],"http://")||strstr($r1[0],"https://"))
  956. {
  957. $dourl=$r1[0];
  958. }
  959. else
  960. {
  961. //是否是本地址
  962. if(!strstr($r1[0],"/")&&$cjnewsurl)
  963. {
  964. $fileqz_r=GetPageurlQz($cjnewsurl);
  965. $fileqz=$fileqz_r['selfqz'];
  966. $dourl=$fileqz.$r1[0];
  967. }
  968. else
  969. {
  970. $dourl=$qz.$r1[0];
  971. }
  972. }
  973. $return_r=DoTranUrl($dourl,$classid);
  974. $text=str_replace($exp1.$r1[0].$exp2,$return_r[url],$text);
  975. if($return_r[tran])
  976. {
  977. //记录数据库
  978. $filetime=date("Y-m-d H:i:s");
  979. //变量处理
  980. $return_r[filesize]=(int)$return_r[filesize];
  981. $classid=(int)$classid;
  982. $return_r[type]=(int)$return_r[type];
  983. $theid=(int)$theid;
  984. $cjid=(int)$cjid;
  985. $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$return_r[filename]',$return_r[filesize],'$username','$return_r[filepath]','$filetime',$classid,'[URL]".$return_r[filename]."',$return_r[type],$theid,$cjid,0,'$public_r[fpath]');");
  986. //加水
  987. if($mark&&$return_r[type]==1)
  988. {
  989. GetMyMarkImg($return_r['yname']);
  990. }
  991. }
  992. }
  993. return $text;
  994. }
  995. //生成缩略图
  996. function GetMySmallImg($classid,$no,$insertfile,$filepath,$yname,$maxwidth,$maxheight,$name,$id,$cjid,$userid,$username){
  997. global $empire,$dbtbpre,$public_r,$efileftp_fr;
  998. if(empty($yname))
  999. {
  1000. return "";
  1001. }
  1002. $no="[s]".$no;
  1003. $filer=ResizeImage($yname,$name,$maxwidth,$maxheight,$public_r['spickill']);
  1004. if($filer['file'])
  1005. {
  1006. $insertfile="small".$insertfile.$filer['filetype'];
  1007. $filesize=@filesize($filer['file']);
  1008. //写入数据库
  1009. $filetime=date("Y-m-d H:i:s");
  1010. //变量处理
  1011. $filesize=(int)$filesize;
  1012. $classid=(int)$classid;
  1013. $id=(int)$id;
  1014. $cjid=(int)$cjid;
  1015. $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$insertfile',$filesize,'$username','$filepath','$filetime',$classid,'$no',1,$id,$cjid,0,'$public_r[fpath]');");
  1016. //FileServer
  1017. if($public_r['openfileserver'])
  1018. {
  1019. $efileftp_fr[]=$name.$filer['filetype'];
  1020. }
  1021. }
  1022. return $filer;
  1023. }
  1024. //图片加水印
  1025. function GetMyMarkImg($groundImage){
  1026. global $public_r;
  1027. if(empty($groundImage))
  1028. {
  1029. return "";
  1030. }
  1031. imageWaterMark($groundImage,$public_r['markpos'],$public_r['markimg'],$public_r['marktext'],$public_r['markfontsize'],$public_r['markfontcolor'],$public_r['markfont'],$public_r['markpct'],$public_r['jpgquality']);
  1032. }
  1033. //投票组合
  1034. function ReturnVote($votename,$votenum,$delvid,$vid,$enews=0){
  1035. global $empire,$dbtbpre;
  1036. $f_exp="::::::";
  1037. $r_exp="\r\n";
  1038. $returnstr="";
  1039. //增加投票
  1040. if(empty($enews))
  1041. {
  1042. for($i=0;$i<count($votename);$i++)
  1043. {
  1044. //替换非法字符
  1045. $name=str_replace($f_exp,"",$votename[$i]);
  1046. $name=str_replace($r_exp,"",$votename[$i]);
  1047. $num=str_replace($f_exp,"",$votenum[$i]);
  1048. $num=str_replace($r_exp,"",$votenum[$i]);
  1049. if($name)
  1050. {
  1051. if(empty($num))
  1052. {$num=0;}
  1053. $returnstr.=$name.$f_exp.$num.$r_exp;
  1054. }
  1055. }
  1056. }
  1057. //修改投票
  1058. else
  1059. {
  1060. for($i=0;$i<count($votename);$i++)
  1061. {
  1062. //删除下载地址
  1063. $del=0;
  1064. for($j=0;$j<count($delvid);$j++)
  1065. {
  1066. if($delvid[$j]==$vid[$i])
  1067. {$del=1;}
  1068. }
  1069. if($del)
  1070. {continue;}
  1071. //替换非法字符
  1072. $name=str_replace($f_exp,"",$votename[$i]);
  1073. $name=str_replace($r_exp,"",$votename[$i]);
  1074. $num=str_replace($f_exp,"",$votenum[$i]);
  1075. $num=str_replace($r_exp,"",$votenum[$i]);
  1076. if($name)
  1077. {
  1078. if(empty($num))
  1079. {$num=0;}
  1080. $returnstr.=$name.$f_exp.$num.$r_exp;
  1081. }
  1082. }
  1083. }
  1084. /*
  1085. if(empty($returnstr))
  1086. {printerror("EmptyVotenum","history.go(-1)");}
  1087. */
  1088. //去掉最后的字符
  1089. $returnstr=substr($returnstr,0,strlen($returnstr)-2);
  1090. return $returnstr;
  1091. }
  1092. //显示无限级栏目[增加栏目时]
  1093. function ShowClass_AddClass($adminclass,$obclassid,$bclassid,$exp,$modid,$enews=0,$addminfocid=''){
  1094. global $empire,$dbtbpre;
  1095. if(empty($bclassid))
  1096. {
  1097. $bclassid=0;
  1098. $exp="|-";
  1099. if($enews==2)
  1100. {
  1101. $modr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='$modid'");
  1102. $addminfocid=$modr['sonclass'];
  1103. }
  1104. }
  1105. else
  1106. {$exp="&nbsp;&nbsp;".$exp;}
  1107. $sql=$empire->query("select classid,classname,bclassid,islast,openadd,modid,sonclass from {$dbtbpre}enewsclass where bclassid='$bclassid' and wburl='' order by myorder,classid");
  1108. $returnstr="";
  1109. while($r=$empire->fetch($sql))
  1110. {
  1111. //投稿显示
  1112. if($enews==2)
  1113. {
  1114. if($r[openadd])
  1115. {
  1116. continue;
  1117. }
  1118. if(CheckHaveInClassid($r,$addminfocid)==0)
  1119. {
  1120. continue;
  1121. }
  1122. }
  1123. if($r[islast])
  1124. {
  1125. if(empty($enews)||$enews==2||$enews==3||$enews==4)
  1126. {
  1127. $color=" style='background:#99C4E3'";
  1128. }
  1129. //隐藏不能投稿的栏目
  1130. if($enews==2)
  1131. {
  1132. if($modid)
  1133. {
  1134. if($r[modid]<>$modid)
  1135. {continue;}
  1136. }
  1137. }
  1138. //模型
  1139. if($enews==4)
  1140. {
  1141. if($r[modid]<>$modid)
  1142. {continue;}
  1143. }
  1144. }
  1145. else
  1146. {$color="";}
  1147. if($r[classid]==$obclassid)
  1148. {$select=" selected";}
  1149. else
  1150. {$select="";}
  1151. //-----------增加用户时
  1152. if($enews==3)
  1153. {
  1154. $c=explode("|".$r[classid]."|",$adminclass);
  1155. if(count($c)>1)
  1156. {$select=" selected";}
  1157. else
  1158. {$select="";}
  1159. }
  1160. $returnstr.="<option value=".$r[classid].$select.$color.">".$exp.$r[classname]."</option>";
  1161. if(empty($r[islast]))
  1162. {
  1163. $returnstr.=ShowClass_AddClass($adminclass,$obclassid,$r[classid],$exp,$modid,$enews,$addminfocid);
  1164. }
  1165. }
  1166. return $returnstr;
  1167. }
  1168. //设置伸缩
  1169. function SetDisplayClass($open){
  1170. $time=time()+365*24*3600;
  1171. $set=esetcookie("displayclass",$open,$time,1);
  1172. echo"<script>self.location.href='ListClass.php';</script>";
  1173. exit();
  1174. }
  1175. //删除目录函数
  1176. function DelPath($DelPath){
  1177. if($DelPath=="../../"||$DelPath=="../../d/file/")
  1178. {return "";}
  1179. $wm_chief=new del_path();
  1180. $wm_chief_ok=$wm_chief->wm_chief_delpath($DelPath);
  1181. return $wm_chief_ok;
  1182. }
  1183. //复制目录
  1184. function CopyPath($oldpath,$newpath){
  1185. $wm_chief=new copy_path();
  1186. $wm_chief_ok=$wm_chief->wm_chief_copypath($oldpath,$newpath);
  1187. return $wm_chief_ok;
  1188. }
  1189. //移动目录
  1190. function MovePath($oldpath,$newpath){
  1191. //复制
  1192. CopyPath($oldpath,$newpath);
  1193. //删除
  1194. DelPath($oldpath);
  1195. }
  1196. //替换字符
  1197. function RepInfoZZ($text,$exp,$enews=0){
  1198. $text=str_replace(".","\\.",$text);
  1199. $text=str_replace("(","\\(",$text);
  1200. $text=str_replace(")","\\)",$text);
  1201. $text=str_replace("?","\\?",$text);
  1202. $text=str_replace("*","(.*?)",$text);
  1203. $text=str_replace("[!--".$exp."--]","(.*?)",$text);
  1204. //$text=str_replace("\\","\\\\",$text);
  1205. //$text=str_replace("\"","\"",$text);
  1206. $text=str_replace("/","\\/",$text);
  1207. $text=str_replace("-","\\-",$text);
  1208. $text=str_replace("|","\\|",$text);
  1209. $text=str_replace("+","\\+",$text);
  1210. $text=str_replace("^","\\^",$text);
  1211. $text=str_replace("{","\\{",$text);
  1212. $text=str_replace("}","\\}",$text);
  1213. $text=str_replace("[","\\[",$text);
  1214. $text=str_replace("]","\\]",$text);
  1215. $text=str_replace("\$","\\\$",$text);
  1216. $text="/".$text."/is";
  1217. return $text;
  1218. }
  1219. //取得地址前缀
  1220. function GetPageurlQz($self){
  1221. $sr=explode("/",$self);
  1222. $count=count($sr)-1;
  1223. $sfile=$sr[$count];
  1224. $r[selfqz]=substr($self,0,strlen($self)-strlen($sfile));
  1225. //取得域名
  1226. $sr1=explode("http://",$self);
  1227. $sr2=explode("/",$sr1[1]);
  1228. $r[domain]="http://".$sr2[0];
  1229. return $r;
  1230. }
  1231. //去掉单引号
  1232. function RepDyh($text){
  1233. //$text=str_replace("\'","\\\'",stripSlashes($text));
  1234. $text=addslashes(stripSlashes($text));
  1235. return $text;
  1236. }
  1237. //补零
  1238. function AddNumZero($no,$endno){
  1239. $len=strlen($endno);
  1240. $forlen=$len-strlen($no);
  1241. for($i=1;$i<=$forlen;$i++)
  1242. {
  1243. $no="0".$no;
  1244. }
  1245. return $no;
  1246. }
  1247. //自动分页
  1248. function AutoDoPage($mybody,$spsize){
  1249. $sptag="[!--empirenews.page--]";
  1250. if(strlen($mybody)<$spsize) return $mybody;
  1251. $bds = explode('<',$mybody);
  1252. $npageBody = "";
  1253. $istable = 0;
  1254. $mybody = "";
  1255. foreach($bds as $i=>$k)
  1256. {
  1257. if($i==0){ $npageBody .= $bds[$i]; continue;}
  1258. $bds[$i] = "<".$bds[$i];
  1259. if(strlen($bds[$i])>6){
  1260. $tname = substr($bds[$i],1,5);
  1261. if(strtolower($tname)=='table') $istable++;
  1262. else if(strtolower($tname)=='/tabl') $istable--;
  1263. if($istable>0){ $npageBody .= $bds[$i]; continue; }
  1264. else $npageBody .= $bds[$i];
  1265. }else{
  1266. $npageBody .= $bds[$i];
  1267. }
  1268. if(strlen($npageBody)>$spsize){
  1269. $mybody .= $npageBody.$sptag;
  1270. $npageBody = "";
  1271. }
  1272. }
  1273. if($npageBody!="") $mybody .= $npageBody;
  1274. return $mybody;
  1275. }
  1276. //-------------- 模板区 ----------------------
  1277. //取得模型ID
  1278. function GetListtempMid($tempid){
  1279. global $empire;
  1280. $r=$empire->fetch1("select modid from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");
  1281. return $r[modid];
  1282. }
  1283. //替换模板JS地址
  1284. function RepTemplateJsUrl($temp,$classid,$enews=0){
  1285. global $public_r,$class_r,$class_zr;
  1286. $allpath='[!--news.url--]d/js/js/';
  1287. $temp=str_replace("[!--hotnews--]","<script src='".$allpath."hotnews.js'></script>",$temp);
  1288. $temp=str_replace("[!--newnews--]","<script src='".$allpath."newnews.js'></script>",$temp);
  1289. $temp=str_replace("[!--goodnews--]","<script src='".$allpath."goodnews.js'></script>",$temp);
  1290. $temp=str_replace("[!--hotplnews--]","<script src='".$allpath."hotplnews.js'></script>",$temp);
  1291. $temp=str_replace("[!--firstnews--]","<script src='".$allpath."firstnews.js'></script>",$temp);
  1292. if(!empty($classid))
  1293. {
  1294. $path=$enews==1?'[!--news.url--]d/js/class/zt[!--self.classid--]_':'[!--news.url--]d/js/class/class[!--self.classid--]_';
  1295. $temp=str_replace("[!--self.hotnews--]","<script src='".$path."hotnews.js'></script>",$temp);
  1296. $temp=str_replace("[!--self.newnews--]","<script src='".$path."newnews.js'></script>",$temp);
  1297. $temp=str_replace("[!--self.goodnews--]","<script src='".$path."goodnews.js'></script>",$temp);
  1298. $temp=str_replace("[!--self.hotplnews--]","<script src='".$path."hotplnews.js'></script>",$temp);
  1299. $temp=str_replace("[!--self.firstnews--]","<script src='".$path."firstnews.js'></script>",$temp);
  1300. }
  1301. return $temp;
  1302. }
  1303. //-------------- 生成区 ----------------------
  1304. //取得列表模板
  1305. function GetListTemp($tempid){
  1306. global $empire;
  1307. $r=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewslisttemp")." where tempid='$tempid'");
  1308. $r[temptext]=InfoNewsBq('list'.$tempid,$r[temptext]);
  1309. return $r;
  1310. }
  1311. //取得封面模板
  1312. function GetClassTemp($tempid){
  1313. global $empire;
  1314. $r=$empire->fetch1("select temptext from ".GetTemptb("enewsclasstemp")." where tempid='$tempid'");
  1315. return $r['temptext'];
  1316. }
  1317. //取得栏目页面内容
  1318. function GetClassText($classid){
  1319. global $empire,$dbtbpre;
  1320. $r=$empire->fetch1("select classtext from {$dbtbpre}enewsclassadd where classid='$classid'");
  1321. return $r['classtext'];
  1322. }
  1323. //取得专题页面内容
  1324. function GetZtText($ztid){
  1325. global $empire,$dbtbpre;
  1326. $r=$empire->fetch1("select classtext from {$dbtbpre}enewsztadd where ztid='$ztid'");
  1327. return $r['classtext'];
  1328. }
  1329. //取得首页模板
  1330. function GetIndextemp(){
  1331. global $empire,$dbtbpre,$public_r;
  1332. if($public_r['indexpageid'])
  1333. {
  1334. $r=$empire->fetch1("select temptext from {$dbtbpre}enewsindexpage where tempid='".$public_r['indexpageid']."'");
  1335. return $r['temptext'];
  1336. }
  1337. $r=$empire->fetch1("select indextemp from ".GetTemptb("enewspubtemp")." limit 1");
  1338. return $r['indextemp'];
  1339. }
  1340. //取得内容模板
  1341. function GetNewsTemp($newstempid){
  1342. global $empire,$public_r;
  1343. $r=$empire->fetch1("select temptext,showdate from ".GetTemptb("enewsnewstemp")." where tempid='$newstempid'");
  1344. $r[temptext]=InfoNewsBq('news'.$newstempid,$r[temptext]);
  1345. if($public_r[opennotcj])//启用反采集
  1346. {
  1347. $r[temptext]=ReturnNotcj($r[temptext]);
  1348. }
  1349. return $r;
  1350. }
  1351. //取得js模板
  1352. function GetTheJstemp($tempid){
  1353. global $empire;
  1354. $r=$empire->fetch1("select temptext,showdate,modid,subnews,subtitle from ".GetTemptb("enewsjstemp")." where tempid='$tempid'");
  1355. return $r;
  1356. }
  1357. //替换全局模板变量
  1358. function ReplaceTempvar($temp){
  1359. global $empire;
  1360. if(empty($temp))
  1361. {return $temp;}
  1362. $sql=$empire->query("select myvar,varvalue from ".GetTemptb("enewstempvar")." where isclose=0 order by myorder desc,varid");
  1363. while($r=$empire->fetch($sql))
  1364. {
  1365. $temp=str_replace('[!--temp.'.$r[myvar].'--]',$r[varvalue],$temp);;
  1366. }
  1367. return $temp;
  1368. }
  1369. //栏目页替换公共标记
  1370. function Class_ReplaceSvars($temp,$url,$classid,$title,$key,$des,$classimg,$add,$enews=0){
  1371. global $public_r,$class_r,$class_zr;
  1372. $temp=str_replace('[!--class.menu--]',$public_r['classnavs'],$temp);//栏目导航
  1373. $temp=str_replace('[!--pagetitle--]',$title,$temp);
  1374. $temp=str_replace('[!--pagekey--]',$key,$temp);
  1375. $temp=str_replace('[!--pagedes--]',$des,$temp);
  1376. $temp=str_replace('[!--class.intro--]',$des,$temp);
  1377. $temp=str_replace('[!--class.keywords--]',$key,$temp);
  1378. $temp=str_replace('[!--class.classimg--]',$classimg,$temp);
  1379. $temp=str_replace('[!--self.classid--]',$classid,$temp);
  1380. if($enews==0)//栏目
  1381. {
  1382. $temp=str_replace('[!--class.name--]',$class_r[$classid]['classname'],$temp);
  1383. $bclassid=$class_r[$classid]['bclassid'];
  1384. $temp=str_replace('[!--bclass.id--]',$bclassid,$temp);
  1385. $temp=str_replace('[!--bclass.name--]',$class_r[$bclassid]['classname'],$temp);
  1386. $path=$public_r['newsurl'].'d/js/class/class'.$classid.'_';
  1387. }
  1388. else//专题
  1389. {
  1390. $temp=str_replace('[!--class.name--]',$class_zr[$classid]['ztname'],$temp);
  1391. $path=$public_r['newsurl'].'d/js/class/zt'.$classid.'_';
  1392. }
  1393. $allpath=$public_r[newsurl].'d/js/js/';
  1394. //热门文章
  1395. $temp=str_replace("[!--hotnews--]","<script src='".$allpath."hotnews.js'></script>",$temp);
  1396. $temp=str_replace("[!--self.hotnews--]","<script src='".$path."hotnews.js'></script>",$temp);
  1397. //点击排行
  1398. $temp=str_replace("[!--newnews--]","<script src='".$allpath."newnews.js'></script>",$temp);
  1399. $temp=str_replace("[!--self.newnews--]","<script src='".$path."newnews.js'></script>",$temp);
  1400. //推荐
  1401. $temp=str_replace("[!--goodnews--]","<script src='".$allpath."goodnews.js'></script>",$temp);
  1402. $temp=str_replace("[!--self.goodnews--]","<script src='".$path."goodnews.js'></script>",$temp);
  1403. //评论排行
  1404. $temp=str_replace("[!--hotplnews--]","<script src='".$allpath."hotplnews.js'></script>",$temp);
  1405. $temp=str_replace("[!--self.hotplnews--]","<script src='".$path."hotplnews.js'></script>",$temp);
  1406. //头条排行
  1407. $temp=str_replace("[!--firstnews--]","<script src='".$allpath."firstnews.js'></script>",$temp);
  1408. $temp=str_replace("[!--self.firstnews--]","<script src='".$path."firstnews.js'></script>",$temp);
  1409. $temp=str_replace('[!--news.url--]',$public_r['newsurl'],$temp);
  1410. return $temp;
  1411. }
  1412. //内容页替换公共标记
  1413. function Info_ReplaceSvars($temp,$url,$classid,$title,$key,$des){
  1414. global $public_r,$class_r;
  1415. $temp=str_replace('[!--class.menu--]',$public_r['classnavs'],$temp);//栏目导航
  1416. $temp=str_replace('[!--newsnav--]',$url,$temp);//位置导航
  1417. $temp=str_replace('[!--pagetitle--]',$title,$temp);
  1418. $temp=str_replace('[!--pagekey--]',$key,$temp);
  1419. $temp=str_replace('[!--pagedes--]',$des,$temp);
  1420. $temp=str_replace('[!--self.classid--]',$classid,$temp);
  1421. $bclassid=$class_r[$classid]['bclassid'];
  1422. $temp=str_replace('[!--bclass.id--]',$bclassid,$temp);
  1423. $temp=str_replace('[!--bclass.name--]',$class_r[$bclassid]['classname'],$temp);
  1424. $temp=str_replace('[!--news.url--]',$public_r['newsurl'],$temp);
  1425. return $temp;
  1426. }
  1427. //替换搜索模板文件
  1428. function ReplaceStemp($temptext,$class,$url,$classid,$title,$key,$des,$repvar=1){
  1429. global $public_r;
  1430. if($repvar==1)//全局模板变量
  1431. {
  1432. $temptext=ReplaceTempvar($temptext);
  1433. }
  1434. $temptext=str_replace('[!--class.menu--]',$public_r['classnavs'],$temptext);//栏目导航
  1435. $temptext=str_replace("[!--class--]",$class,$temptext);
  1436. $temptext=str_replace('[!--pagetitle--]',$title,$temptext);
  1437. $temptext=str_replace('[!--pagekey--]',$key,$temptext);
  1438. $temptext=str_replace('[!--pagedes--]',$des,$temptext);
  1439. $temptext=str_replace('[!--self.classid--]',$classid,$temptext);
  1440. //热门文章
  1441. $temptext=str_replace("[!--hotnews--]","<script src='".$public_r[newsurl]."d/js/js/hotnews.js'></script>",$temptext);
  1442. //点击排行
  1443. $temptext=str_replace("[!--newnews--]","<script src='".$public_r[newsurl]."d/js/js/newnews.js'></script>",$temptext);
  1444. //推荐
  1445. $temptext=str_replace("[!--goodnews--]","<script src='".$public_r[newsurl]."d/js/js/goodnews.js'></script>",$temptext);
  1446. //评论排行
  1447. $temptext=str_replace("[!--hotplnews--]","<script src='".$public_r[newsurl]."d/js/js/hotplnews.js'></script>",$temptext);
  1448. //导航条
  1449. $temptext=str_replace("[!--url--]",$url,$temptext);
  1450. $temptext=str_replace('[!--newsnav--]',$url,$temptext);//位置导航
  1451. $temptext=str_replace("[!--news.url--]",$public_r[newsurl],$temptext);
  1452. $temptext=str_replace("[!--newsurl--]",$public_r[newsurl],$temptext);
  1453. return $temptext;
  1454. }
  1455. //栏目页验证
  1456. function AddCheckClassLevel($classid,$groupid,$classpath){
  1457. $classpath=ReturnSaveClassPath($classid);
  1458. $pr=explode('/',$classpath);
  1459. $pcount=count($pr);
  1460. for($i=0;$i<$pcount;$i++)
  1461. {
  1462. $include.='../';
  1463. }
  1464. $include1=$include;
  1465. $include.='e/class/CheckClassLevel.php';
  1466. $addlevel="<?php
  1467. define('empirecms','wm_chief');
  1468. \$check_groupid=\"".$groupid."\";
  1469. \$check_classid=".$classid.";
  1470. \$check_path=\"".$include1."\";
  1471. require(\"".$include."\");
  1472. ?>";
  1473. return $addlevel;
  1474. }
  1475. //生成栏目绑定信息页面
  1476. function ReClassBdInfo($classid){
  1477. global $empire,$dbtbpre;
  1478. $cr=$empire->fetch1("select classid,bdinfoid from {$dbtbpre}enewsclass where classid='$classid'");
  1479. if(!$cr['classid']||!$cr['bdinfoid'])
  1480. {
  1481. return '';
  1482. }
  1483. $infor=explode(',',$cr['bdinfoid']);
  1484. $infofile=GetInfoFilename(intval($infor[0]),intval($infor[1]));
  1485. $classtext='';
  1486. if($infofile)
  1487. {
  1488. $classtext=ReadFiletext($infofile);
  1489. }
  1490. $classfile=ECMS_PATH.ReturnSaveClassPath($classid,1);
  1491. WriteFiletext_n($classfile,$classtext);
  1492. }
  1493. //标签替换
  1494. function NewsBq($classid,$indextext,$enews=0,$doing=0){
  1495. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  1496. $indextext=stripSlashes($indextext);
  1497. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  1498. $classlevel='';
  1499. if($enews==0)//生成大栏目
  1500. {
  1501. if($class_r[$classid]['listdt']||$class_r[$classid]['wburl']||strstr($public_r['nreclass'],','.$classid.','))//不生成栏目
  1502. {
  1503. return '';
  1504. }
  1505. $GLOBALS['navclassid']=$classid;
  1506. $url=ReturnClassLink($classid);//导航
  1507. $cf=$doing==1?',classpath,classtype,classname':'';
  1508. $cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid".$cf." from {$dbtbpre}enewsclass where classid='$classid'");
  1509. if(!empty($cf))
  1510. {
  1511. $class_r[$classid][classpath]=$cr[classpath];
  1512. $class_r[$classid][classtype]=$cr[classtype];
  1513. $class_r[$classid][classname]=$cr[classname];
  1514. }
  1515. //权限
  1516. if($cr['cgroupid'])
  1517. {
  1518. $classlevel=AddCheckClassLevel($classid,$cr['cgroupid'],'');
  1519. }
  1520. //页面
  1521. $pagetitle=htmlspecialchars($class_r[$classid][classname]);
  1522. $pagekey=htmlspecialchars($cr['classpagekey']);
  1523. $pagedes=htmlspecialchars($cr['intro']);
  1524. $classimg=$cr['classimg'];
  1525. $onclick="<script src=".$public_r[newsurl]."e/public/onclick?enews=doclass&classid=$classid></script>";
  1526. $truefile=ECMS_PATH.ReturnSaveClassPath($classid,1);
  1527. $file=ECMS_PATH.'e/data/tmp/class'.$classid.'.php';
  1528. $indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
  1529. $indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,0);
  1530. }
  1531. elseif($enews==3)//专题
  1532. {
  1533. $GLOBALS['navclassid']=$classid;
  1534. $url=ReturnZtLink($classid);//导航
  1535. $cf=$doing==1?',ztpath,zttype,ztname':'';
  1536. $cr=$empire->fetch1("select ztpagekey,intro,ztimg".$cf." from {$dbtbpre}enewszt where ztid='$classid'");
  1537. if(!empty($cf))
  1538. {
  1539. $class_zr[$classid][ztpath]=$cr[ztpath];
  1540. $class_zr[$classid][zttype]=$cr[zttype];
  1541. $class_zr[$classid][ztname]=$cr[ztname];
  1542. }
  1543. $pagetitle=htmlspecialchars($class_zr[$classid][ztname]);
  1544. $pagekey=htmlspecialchars($cr['ztpagekey']);
  1545. $pagedes=htmlspecialchars($cr['intro']);
  1546. $classimg=$cr['ztimg'];
  1547. $onclick="<script src=".$public_r[newsurl]."e/public/onclick?enews=dozt&ztid=$ztid></script>";
  1548. $truefile=ECMS_PATH.ReturnSaveZtPath($classid,1);
  1549. $file=ECMS_PATH.'e/data/tmp/zt'.$classid.'.php';
  1550. $indextext=str_replace("[!--newsnav--]",$url,$indextext);//位置导航
  1551. $indextext=Class_ReplaceSvars($indextext,$url,$classid,$pagetitle,$pagekey,$pagedes,$classimg,$add,1);
  1552. }
  1553. elseif($enews==1)//生成首页文件
  1554. {
  1555. $pr=$empire->fetch1("select sitekey,siteintro,indexpagedt from {$dbtbpre}enewspublic limit 1");
  1556. if($pr['indexpagedt'])
  1557. {
  1558. return '';
  1559. }
  1560. //页面
  1561. $pagetitle=htmlspecialchars($public_r['sitename']);
  1562. $pagekey=htmlspecialchars($pr['sitekey']);
  1563. $pagedes=htmlspecialchars($pr['siteintro']);
  1564. $url="<a href=\"".$public_r[newsurl]."\">".$fun_r['index']."</a>";//栏目导航
  1565. $onclick='';
  1566. $truefile=ECMS_PATH.ReturnSaveIndexFile();
  1567. $file=ECMS_PATH.'e/data/tmp/index.php';
  1568. $indextext=ReplaceSvars($indextext,$url,0,$pagetitle,$pagekey,$pagedes,$add,0);
  1569. }
  1570. $indextext=str_replace("[!--page.stats--]",$onclick,$indextext);
  1571. //替换标签
  1572. $indextext=DoRepEcmsLoopBq($indextext);
  1573. $indextext=RepBq($indextext);
  1574. //写文件
  1575. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  1576. //读取文件内容
  1577. ob_start();
  1578. include($file);
  1579. $string=ob_get_contents();
  1580. ob_end_clean();
  1581. $string=RepExeCode($string);//解析代码
  1582. WriteFiletext($truefile,$classlevel.$string);
  1583. return $string;
  1584. }
  1585. //标签替换2
  1586. function InfoNewsBq($classid,$indextext){
  1587. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  1588. if($_GET['reallinfotime'])
  1589. {
  1590. $classid.='_all';
  1591. }
  1592. $file=ECMS_PATH.'e/data/tmp/temp'.$classid.'.php';
  1593. if($_GET['reallinfotime']&&file_exists($file))
  1594. {
  1595. $filetime=filemtime($file);
  1596. if($_GET['reallinfotime']<=$filetime)
  1597. {
  1598. ob_start();
  1599. include($file);
  1600. $string=ob_get_contents();
  1601. ob_end_clean();
  1602. $string=RepExeCode($string);//解析代码
  1603. return $string;
  1604. }
  1605. }
  1606. $indextext=stripSlashes($indextext);
  1607. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  1608. //替换标签
  1609. $indextext=DoRepEcmsLoopBq($indextext);
  1610. $indextext=RepBq($indextext);
  1611. //写文件
  1612. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  1613. //读取文件内容
  1614. ob_start();
  1615. include($file);
  1616. $string=ob_get_contents();
  1617. ob_end_clean();
  1618. $string=RepExeCode($string);//解析代码
  1619. return $string;
  1620. }
  1621. //标签替换3
  1622. function DtNewsBq($classid,$indextext,$ecms=0){
  1623. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  1624. $cachetime=$ecms==1?$public_r['dtncachetime']:$public_r['dtcachetime'];
  1625. $file=ECMS_PATH.'e/data/tmp/dt_temp'.$classid.'.php';
  1626. if($cachetime&&file_exists($file))
  1627. {
  1628. $filetime=filemtime($file);
  1629. if(time()-$cachetime*60<=$filetime)
  1630. {
  1631. ob_start();
  1632. include($file);
  1633. $string=ob_get_contents();
  1634. ob_end_clean();
  1635. $string=RepExeCode($string);//解析代码
  1636. return $string;
  1637. }
  1638. }
  1639. $indextext=stripSlashes($indextext);
  1640. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  1641. //替换标签
  1642. $indextext=DoRepEcmsLoopBq($indextext);
  1643. $indextext=RepBq($indextext);
  1644. //写文件
  1645. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  1646. //读取文件内容
  1647. ob_start();
  1648. include($file);
  1649. $string=ob_get_contents();
  1650. ob_end_clean();
  1651. $string=RepExeCode($string);//解析代码
  1652. return $string;
  1653. }
  1654. //解析代码
  1655. function RepExeCode($string){
  1656. global $public_r;
  1657. if($public_r[candocode])
  1658. {
  1659. $string=str_replace('<!--code.start-->','<',$string);
  1660. $string=str_replace('<!--code.end-->','>',$string);
  1661. }
  1662. return $string;
  1663. }
  1664. function ClearRepDoECode($string){
  1665. $string=str_replace('<!--code.start-->','&lt;!--code.start--&gt;',$string);
  1666. $string=str_replace('<!--code.end-->','&lt;!--code.end--&gt;',$string);
  1667. return $string;
  1668. }
  1669. //替换标签
  1670. function RepBq($indextext){
  1671. global $empire,$dbtbpre;
  1672. $sql=$empire->query("select bq,funname from {$dbtbpre}enewsbq where isclose=0 order by bqid");
  1673. while($r=$empire->fetch($sql))
  1674. {
  1675. $preg_str="/\[".$r[bq]."\](.+?)\[\/".$r[bq]."\]/is";
  1676. $indextext=preg_replace($preg_str,"<? @".$r[funname]."(\\1);?>",$indextext);
  1677. }
  1678. return $indextext;
  1679. }
  1680. //替换灵动标签
  1681. function DoRepEcmsLoopBq($temp){
  1682. $yzz="/\[e:loop={(.+?)}\](.+?)\[\/e:loop\]/is";
  1683. $xzz="<?php
  1684. \$bqno=0;
  1685. \$ecms_bq_sql=sys_ReturnEcmsLoopBq(\\1);
  1686. while(\$bqr=\$empire->fetch(\$ecms_bq_sql)){
  1687. \$bqsr=sys_ReturnEcmsLoopStext(\$bqr);
  1688. \$bqno++;
  1689. ?>\\2<?php
  1690. }
  1691. ?>";
  1692. return preg_replace($yzz,$xzz,$temp);
  1693. }
  1694. //无信息的信息列表
  1695. function NotinfoListHtml($path,$list_r,$classlevel){
  1696. global $fun_r;
  1697. $word=$fun_r['HaveNotListInfo'];
  1698. $pagetext=$list_r[0].$word.$list_r[2];
  1699. $pagetext=str_replace('[!--show.page--]','',$pagetext);
  1700. $pagetext=str_replace('[!--show.listpage--]','',$pagetext);
  1701. $pagetext=str_replace('[!--list.pageno--]','',$pagetext);
  1702. WriteFiletext($path,$classlevel.$pagetext);
  1703. }
  1704. //生成信息列表
  1705. function ListHtml($classid,$fields,$enews=0,$userlistr=""){
  1706. global $empire,$dbtbpre,$emod_r,$public_r,$class_r,$class_zr,$fun_r,$class_tr,$level_r,$etable_r;
  1707. //不生成栏目
  1708. if(($enews==0||$enews==3)&&($class_r[$classid]['listdt']||$class_r[$classid]['wburl']||strstr($public_r['nreclass'],','.$classid.',')))
  1709. {
  1710. return '';
  1711. }
  1712. $GLOBALS['navclassid']=$classid;
  1713. $doclass="index";
  1714. $classlevel='';
  1715. $yhvar='qlist';
  1716. if($enews==0)//子栏目列表
  1717. {
  1718. $selfclassid=$classid;
  1719. $doenews=0;
  1720. $cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='$classid'");
  1721. $mid=$class_r[$classid][modid];
  1722. //权限
  1723. if($cr['cgroupid'])
  1724. {
  1725. $classlevel=AddCheckClassLevel($classid,$cr['cgroupid'],'');
  1726. }
  1727. //页面
  1728. $pagetitle=htmlspecialchars($class_r[$classid][classname]);
  1729. $pagekey=htmlspecialchars($cr['classpagekey']);
  1730. $pagedes=htmlspecialchars($cr['intro']);
  1731. $classimg=$cr['classimg'];
  1732. $url=ReturnClassLink($classid);
  1733. $haveclass=0;
  1734. //排序
  1735. if(empty($class_r[$classid][reorder]))
  1736. {
  1737. $addorder="newstime desc";
  1738. }
  1739. else
  1740. {
  1741. $addorder=$class_r[$classid][reorder];
  1742. }
  1743. if($class_r[$classid][maxnum])//总记录数
  1744. {
  1745. $limit=" limit ".$class_r[$classid][maxnum];
  1746. $limitnum=$class_r[$classid][maxnum];
  1747. }
  1748. //优化
  1749. $yhid=$class_r[$classid][yhid];
  1750. if($yhid)
  1751. {
  1752. $yhadd=ReturnYhSql($yhid,$yhvar);
  1753. }
  1754. $query="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd."classid='$classid' and checked=1 order by ".ReturnSetTopSql('list').$addorder.$limit;
  1755. $totalquery="select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd."classid='$classid' and checked=1";//统计
  1756. $doclasspath=ReturnSaveClassPath($classid,0);
  1757. $dopath=ECMS_PATH.$doclasspath."/";
  1758. if(empty($class_r[$classid][classurl]))
  1759. {
  1760. $dolink=$public_r[newsurl].$doclasspath."/";
  1761. }
  1762. else
  1763. {
  1764. $dolink=$class_r[$classid][classurl]."/";
  1765. }
  1766. $dotype=$class_r[$classid][classtype];
  1767. $classname=$class_r[$classid][classname];
  1768. $lencord=$class_r[$classid][lencord];//记录数
  1769. $onclick="<script src='".$public_r[newsurl]."e/public/onclick/?enews=doclass&classid=$classid'></script>";
  1770. //模板
  1771. $listtempid=$class_r[$classid][listtempid];
  1772. }
  1773. elseif($enews==1)//专题列表
  1774. {
  1775. $selfclassid=$classid;
  1776. $doenews=1;
  1777. $cr=$empire->fetch1("select ztpagekey,intro,ztimg,classtempid from {$dbtbpre}enewszt where ztid='$classid'");
  1778. //页面
  1779. $pagetitle=htmlspecialchars($class_zr[$classid][ztname]);
  1780. $pagekey=htmlspecialchars($cr['ztpagekey']);
  1781. $pagedes=htmlspecialchars($cr['intro']);
  1782. $classimg=$cr['ztimg'];
  1783. $url=ReturnZtLink($classid);
  1784. $haveclass=1;
  1785. if($class_zr[$classid][islist]!=1)//非列表式
  1786. {
  1787. $classtemp=$class_zr[$classid][islist]==2?GetZtText($classid):GetClassTemp($cr['classtempid']);
  1788. NewsBq($classid,$classtemp,3,0);
  1789. return "";
  1790. }
  1791. //排序
  1792. if(empty($class_zr[$classid][reorder]))
  1793. {
  1794. $addorder="newstime desc";
  1795. }
  1796. else
  1797. {
  1798. $addorder=$class_zr[$classid][reorder];
  1799. }
  1800. if($class_zr[$classid][maxnum])
  1801. {
  1802. $limit=" limit ".$class_zr[$classid][maxnum];
  1803. $limitnum=$class_zr[$classid][maxnum];
  1804. }
  1805. //优化
  1806. $tbname=$class_zr[$classid][tbname];
  1807. $mid=$etable_r[$tbname][mid];
  1808. $yhid=$class_zr[$classid][yhid];
  1809. if($yhid)
  1810. {
  1811. $yhadd=ReturnYhSql($yhid,$yhvar);
  1812. }
  1813. $query="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$class_zr[$classid][tbname]." where ".$yhadd."ztid like '%|".$classid."|%' and checked=1 order by ".$addorder.$limit;
  1814. $totalquery="select count(*) as total from {$dbtbpre}ecms_".$class_zr[$classid][tbname]." where ".$yhadd."ztid like '%|".$classid."|%' and checked=1";//统计
  1815. $doclasspath=ReturnSaveZtPath($classid,0);
  1816. $dopath=ECMS_PATH.$doclasspath."/";
  1817. if(empty($class_zr[$classid][zturl]))
  1818. {
  1819. $dolink=$public_r[newsurl].$doclasspath."/";
  1820. }
  1821. else
  1822. {
  1823. $dolink=$class_zr[$classid][zturl]."/";
  1824. }
  1825. $dotype=$class_zr[$classid][zttype];
  1826. $classname=$class_zr[$classid][ztname];
  1827. $lencord=$class_zr[$classid][ztnum];//记录数
  1828. $onclick="<script src='".$public_r[newsurl]."e/public/onclick/?enews=dozt&ztid=$classid'></script>";
  1829. //模板
  1830. $listtempid=$class_zr[$classid][listtempid];
  1831. }
  1832. elseif($enews==3)//大栏目列表
  1833. {
  1834. $selfclassid=$classid;
  1835. $doenews=0;
  1836. $cr=$empire->fetch1("select classpagekey,intro,classimg,cgroupid from {$dbtbpre}enewsclass where classid='$classid'");
  1837. $mid=$class_r[$classid][modid];
  1838. //权限
  1839. if($cr['cgroupid'])
  1840. {
  1841. $classlevel=AddCheckClassLevel($classid,$cr['cgroupid'],'');
  1842. }
  1843. //页面
  1844. $pagetitle=htmlspecialchars($class_r[$classid][classname]);
  1845. $pagekey=htmlspecialchars($cr['classpagekey']);
  1846. $pagedes=htmlspecialchars($cr['intro']);
  1847. $classimg=$cr['classimg'];
  1848. $url=ReturnClassLink($classid);
  1849. $haveclass=1;
  1850. //排序
  1851. if(empty($class_r[$classid][reorder]))
  1852. {
  1853. $addorder="newstime desc";
  1854. }
  1855. else
  1856. {
  1857. $addorder=$class_r[$classid][reorder];
  1858. }
  1859. if($class_r[$classid][maxnum])
  1860. {
  1861. $limit=" limit ".$class_r[$classid][maxnum];
  1862. $limitnum=$class_r[$classid][maxnum];
  1863. }
  1864. $whereclass=ReturnClass($class_r[$classid][sonclass]);
  1865. //优化
  1866. $yhid=$class_r[$classid][yhid];
  1867. if($yhid)
  1868. {
  1869. $yhadd=ReturnYhSql($yhid,$yhvar);
  1870. }
  1871. $query="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd."(".$whereclass.") and checked=1 order by ".ReturnSetTopSql('list').$addorder.$limit;
  1872. $totalquery="select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$yhadd."(".$whereclass.") and checked=1";//统计
  1873. $doclasspath=ReturnSaveClassPath($classid,0);
  1874. $dopath=ECMS_PATH.$doclasspath."/";
  1875. if(empty($class_r[$classid][classurl]))
  1876. {
  1877. $dolink=$public_r[newsurl].$doclasspath."/";
  1878. }
  1879. else
  1880. {
  1881. $dolink=$class_r[$classid][classurl]."/";
  1882. }
  1883. $dotype=$class_r[$classid][classtype];
  1884. $classname=$class_r[$classid][classname];
  1885. $lencord=$class_r[$classid][lencord];//记录数
  1886. $onclick="<script src='".$public_r[newsurl]."e/public/onclick/?enews=doclass&classid=$classid'></script>";
  1887. //模板
  1888. $listtempid=$class_r[$classid][listtempid];
  1889. }
  1890. elseif($enews==4)//按sql语句生成列表
  1891. {
  1892. $selfclassid=0;
  1893. $doenews=1;
  1894. $userlistr['listsql']=RepSqlTbpre($userlistr['listsql']);
  1895. $userlistr['totalsql']=RepSqlTbpre($userlistr['totalsql']);
  1896. //页面
  1897. $pagetitle=htmlspecialchars($userlistr['pagetitle']);
  1898. $pagekey=$pagetitle;
  1899. $pagedes=$pagetitle;
  1900. $haveclass=1;
  1901. if($userlistr['maxnum'])//最大查询数
  1902. {
  1903. $limit=" limit ".$userlistr['maxnum'];
  1904. $limitnum=$userlistr['maxnum'];
  1905. }
  1906. $query=stripSlashes($userlistr['listsql']).$limit;
  1907. //统计
  1908. $totalquery=stripSlashes($userlistr['totalsql']);
  1909. $dopath=$userlistr['addpath'].$userlistr['filepath'];
  1910. $dolink=$public_r[newsurl].str_replace($userlistr['addpath'].'../../','',$dopath);
  1911. $dotype=$userlistr['filetype'];
  1912. $classname=$userlistr['pagetitle'];
  1913. $lencord=$userlistr['lencord'];//记录数
  1914. $onclick='';
  1915. $url=ReturnUserPLink($pagetitle,$dolink);
  1916. //模板
  1917. $listtempid=$userlistr['listtempid'];
  1918. }
  1919. if(empty($lencord))
  1920. {
  1921. $lencord=25;
  1922. }
  1923. //列表模板
  1924. $listtemp_r=GetListTemp($listtempid);
  1925. $listtemp=$listtemp_r[temptext];
  1926. $subnews=$listtemp_r[subnews];
  1927. $subtitle=$listtemp_r[subtitle];
  1928. $docode=$listtemp_r[docode];
  1929. $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$listtemp_r[listvar]);
  1930. $rownum=$listtemp_r[rownum];
  1931. $formatdate=$listtemp_r[showdate];
  1932. if(empty($rownum))
  1933. {
  1934. $rownum=1;
  1935. }
  1936. if(empty($mid))
  1937. {
  1938. $mid=$listtemp_r[modid];
  1939. }
  1940. $field=ReturnReplaceListF($mid);
  1941. //分页列表函数
  1942. if(!empty($public_r['listpagefun'])||!empty($public_r['listpagelistfun']))
  1943. {
  1944. if(strstr($listtemp,'[!--show.page--]'))//下拉式
  1945. {
  1946. $thefun=$public_r['listpagefun'];
  1947. $bereplistpage='[!--show.page--]';
  1948. }
  1949. else//列表式
  1950. {
  1951. $thefun=$public_r['listpagelistfun'];
  1952. $bereplistpage='[!--show.listpage--]';
  1953. }
  1954. }
  1955. else
  1956. {
  1957. $thefun='sys_ShowListPage';
  1958. $bereplistpage='[!--show.page--]';
  1959. }
  1960. //替换模板变量
  1961. $listtemp=str_replace('[!--newsnav--]',$url,$listtemp);//位置导航
  1962. $listtemp=Class_ReplaceSvars($listtemp,$url,$selfclassid,$pagetitle,$pagekey,$pagedes,$classimg,$add,$doenews);
  1963. $listtemp=str_replace('[!--page.stats--]',$onclick,$listtemp);
  1964. $no=1;
  1965. $ok=0;
  1966. $changerow=1;
  1967. $num=$empire->gettotal($totalquery);
  1968. //最大数
  1969. if($limitnum&&$limitnum<$num)
  1970. {
  1971. $num=$limitnum;
  1972. }
  1973. $page=ceil($num/$lencord);
  1974. //取得列表模板
  1975. $list_exp="[!--empirenews.listtemp--]";
  1976. $list_r=explode($list_exp,$listtemp);
  1977. //无信息
  1978. if(empty($num))
  1979. {
  1980. $noinfopath=$dopath."index".$dotype;
  1981. NotinfoListHtml($noinfopath,$list_r,$classlevel);
  1982. return "";
  1983. }
  1984. $sql=$empire->query($query);
  1985. $listtext=$list_r[1];
  1986. while($k=$empire->fetch($sql))
  1987. {
  1988. //替换列表变量
  1989. $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$haveclass,$k,$field,$docode);
  1990. $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
  1991. $changerow+=1;
  1992. //超过行数
  1993. if($changerow>$rownum)
  1994. {
  1995. $changerow=1;
  1996. $string.=$listtext;
  1997. $listtext=$list_r[1];
  1998. }
  1999. if($no%$lencord==0||($num%$lencord<>0&&$num==$no))
  2000. {
  2001. $ok+=1;
  2002. $pagenum=ceil($no/$lencord);
  2003. //首页
  2004. if($pagenum==1)
  2005. {
  2006. $path=$dopath."index".$dotype;
  2007. }
  2008. else
  2009. {
  2010. $path=$dopath."index_".$ok.$dotype;
  2011. }
  2012. //取得分页参数
  2013. $returnpager=$thefun($num,$pagenum,$dolink,$dotype,$page,$lencord,$ok,$myoptions);
  2014. $showpage=$returnpager['showpage'];
  2015. $myoptions=$returnpager['option'];
  2016. $list1=str_replace($bereplistpage,$showpage,$list_r[0]);
  2017. $list2=str_replace($bereplistpage,$showpage,$list_r[2]);
  2018. //多余数据
  2019. if($changerow<=$rownum&&$listtext<>$list_r[1])
  2020. {
  2021. $string.=$listtext;
  2022. }
  2023. $listtext=$list_r[1];
  2024. $changerow=1;
  2025. $string=$list1.$string.$list2;
  2026. //替换分页数
  2027. $string=str_replace('[!--list.pageno--]',$pagenum,$string);
  2028. WriteFiletext($path,$classlevel.$string);
  2029. $string='';
  2030. }
  2031. $no++;
  2032. }
  2033. $empire->free($sql);
  2034. }
  2035. //返回分页
  2036. function ReturnListpageStr($pagenum,$page,$lencord,$num,$pagelink,$options){
  2037. global $public_r;
  2038. $temp=$public_r['listpagetemp'];
  2039. $temp=str_replace('[!--thispage--]',$pagenum,$temp);//页次
  2040. $temp=str_replace('[!--pagenum--]',$page,$temp);//总页数
  2041. $temp=str_replace('[!--lencord--]',$lencord,$temp);//每页显示条数
  2042. $temp=str_replace('[!--num--]',$num,$temp);//总条数
  2043. $temp=str_replace('[!--pagelink--]',$pagelink,$temp);//页面链接
  2044. $temp=str_replace('[!--options--]',$options,$temp);//下拉分页
  2045. return $temp;
  2046. }
  2047. //投稿生成html
  2048. function DoGetHtml($classid,$id){
  2049. global $empire,$class_r,$public_r,$dbtbpre;
  2050. $classid=intval($classid);
  2051. $id=intval($id);
  2052. $tbname=$class_r[$classid][tbname];
  2053. //不存在
  2054. if(!$id||!$classid||!$tbname)
  2055. {
  2056. echo"<script>self.location.href='".$public_r['newsurl']."';</script>";
  2057. exit();
  2058. }
  2059. $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id'");
  2060. if(!$r[id]||!$r['checked'])
  2061. {
  2062. echo"<script>self.location.href='".$public_r['newsurl']."';</script>";
  2063. exit();
  2064. }
  2065. $titleurl=sys_ReturnBqAutoTitleLink($r);
  2066. //已生成
  2067. if(!empty($r[havehtml]))
  2068. {
  2069. return $titleurl;
  2070. }
  2071. //生成html
  2072. GetHtml($r,$ret_r);
  2073. return $titleurl;
  2074. }
  2075. //生成内容文件
  2076. function GetHtml($add,$fields,$doall=0){
  2077. global $public_r,$class_r,$class_zr,$fun_r,$empire,$dbtbpre,$emod_r,$class_tr,$level_r,$etable_r;
  2078. if(empty($doall))
  2079. {
  2080. if($add['titleurl']||$add['checked']==0||$class_r[$add[classid]][showdt]==2||strstr($public_r['nreinfo'],','.$add['classid'].','))//不生成
  2081. {
  2082. return '';
  2083. }
  2084. }
  2085. $mid=$class_r[$add[classid]]['modid'];
  2086. $tbname=$class_r[$add[classid]][tbname];
  2087. //副表
  2088. if($emod_r[$mid]['tbdataf']&&$emod_r[$mid]['tbdataf']<>',')
  2089. {
  2090. $selectdataf=substr($emod_r[$mid]['tbdataf'],1,-1);
  2091. $addr=$empire->fetch1("select ".$selectdataf." from {$dbtbpre}ecms_".$tbname."_data_".$add[stb]." where id='$add[id]'");
  2092. $add=array_merge($add,$addr);
  2093. }
  2094. $iclasspath=ReturnSaveInfoPath($add[classid],$add[id]);
  2095. $doclasspath=ECMS_PATH.$iclasspath;
  2096. $createinfopath=$doclasspath;
  2097. //建立日期目录
  2098. $newspath='';
  2099. if($add[newspath])
  2100. {
  2101. $createpath=$doclasspath.$add[newspath];
  2102. if(!file_exists($createpath))
  2103. {
  2104. $r[newspath]=FormatPath($add[classid],$add[newspath],1);
  2105. }
  2106. $createinfopath.=$add[newspath].'/';
  2107. $newspath=$add[newspath].'/';
  2108. }
  2109. //新建存放目录
  2110. if($class_r[$add[classid]][filename]==3)
  2111. {
  2112. $createinfopath.=ReturnInfoSPath($add['filename']);
  2113. DoMkdir($createinfopath);
  2114. $fn3=1;
  2115. }
  2116. //存文本
  2117. if($emod_r[$mid]['savetxtf'])
  2118. {
  2119. $stf=$emod_r[$mid]['savetxtf'];
  2120. if($add[$stf])
  2121. {
  2122. $add[$stf]=GetTxtFieldText($add[$stf]);
  2123. }
  2124. }
  2125. $GLOBALS['navclassid']=$add[classid];
  2126. $GLOBALS['navinfor']=$add;
  2127. //取得内容模板
  2128. $add[newstempid]=$add[newstempid]?$add[newstempid]:$class_r[$add[classid]][newstempid];
  2129. $newstemp_r=GetNewsTemp($add[newstempid]);
  2130. $newstemptext=$newstemp_r[temptext];
  2131. $formatdate=$newstemp_r[showdate];
  2132. //页面
  2133. $pagetitle=htmlspecialchars($add[title]);
  2134. $url=ReturnClassLink($add[classid]);//导航
  2135. $newstemptext=Info_ReplaceSvars($newstemptext,$url,$add[classid],$pagetitle,$add[keyboard],$pagetitle);
  2136. //文件类型/权限
  2137. if($add[groupid]||$class_r[$add[classid]]['cgtoinfo'])
  2138. {
  2139. if(empty($add[newspath]))
  2140. {
  2141. $include='';
  2142. }
  2143. else
  2144. {
  2145. $pr=explode('/',$add[newspath]);
  2146. for($i=0;$i<count($pr);$i++)
  2147. {
  2148. $include.='../';
  2149. }
  2150. }
  2151. if($fn3==1)
  2152. {
  2153. $include.='../';
  2154. }
  2155. $pr=explode('/',$iclasspath);
  2156. $pcount=count($pr);
  2157. for($i=0;$i<$pcount-1;$i++)
  2158. {
  2159. $include.='../';
  2160. }
  2161. $include1=$include;
  2162. $include.='e/class/CheckLevel.php';
  2163. $filetype='.php';
  2164. $addlevel="<?php
  2165. define('empirecms','wm_chief');
  2166. \$check_tbname='".$class_r[$add[classid]][tbname]."';
  2167. \$check_infoid=".$add[id].";
  2168. \$check_classid=".$add[classid].";
  2169. \$check_path=\"".$include1."\";
  2170. require(\"".$include."\");
  2171. ?>";
  2172. }
  2173. else
  2174. {
  2175. $filetype=$class_r[$add[classid]][filetype];
  2176. $addlevel='';
  2177. }
  2178. //取得本目录链接
  2179. if($class_r[$add[classid]][classurl]&&$class_r[$add[classid]][ipath]=='')//域名
  2180. {
  2181. $dolink=$class_r[$add[classid]][classurl].'/'.$newspath;
  2182. }
  2183. else
  2184. {
  2185. $dolink=$public_r[newsurl].$iclasspath.$newspath;
  2186. }
  2187. //相关信息
  2188. if(strstr($newstemptext,'[!--other.link--]'))
  2189. {
  2190. $keyboardtext=GetKeyboard($add[keyboard],$add[keyid],$add[classid],$add[id],$class_r[$add[classid]][link_num]);
  2191. }
  2192. $onclick="<script src='".$public_r[newsurl]."e/public/onclick?enews=donews&classid=$add[classid]&id=".$add[id]."'></script>";
  2193. //返回替换验证字符
  2194. $docheckrep=ReturnCheckDoRepStr();
  2195. if($add[newstext])
  2196. {
  2197. if(empty($public_r['dorepword'])&&$docheckrep[3])
  2198. {
  2199. $add[newstext]=ReplaceWord($add[newstext]);//过滤字符
  2200. }
  2201. if(empty($public_r['dorepkey'])&&$docheckrep[4]&&!empty($add[dokey]))//替换关键字
  2202. {
  2203. $add[newstext]=ReplaceKey($add[newstext]);
  2204. }
  2205. if($public_r['opencopytext'])
  2206. {
  2207. $add[newstext]=AddNotCopyRndStr($add[newstext]);//随机复制字符
  2208. }
  2209. }
  2210. //分页字段
  2211. $expage='[!--empirenews.page--]';//分页符
  2212. $pf=$emod_r[$mid]['pagef'];
  2213. //变量
  2214. $tempf=$emod_r[$mid]['tempf'];
  2215. if($pf&&strstr($add[$pf],$expage))
  2216. {
  2217. $tempf=str_replace(','.$pf.',',',',$tempf);
  2218. }
  2219. $fr=explode(',',$tempf);
  2220. $fcount=count($fr)-1;
  2221. //变量替换
  2222. $newstempstr=$newstemptext;//模板
  2223. for($i=1;$i<$fcount;$i++)
  2224. {
  2225. $f=$fr[$i];
  2226. $value=$add[$f];
  2227. if($f=='downpath')//下载地址
  2228. {
  2229. if(strstr($newstemptext,'[!--downpath--]'))
  2230. {
  2231. $value=ReturnDownSoftHtml($add);
  2232. }
  2233. }
  2234. elseif($f=='onlinepath')//观看地址
  2235. {
  2236. if(strstr($newstemptext,'[!--onlinepath--]'))
  2237. {
  2238. $value=ReturnOnlinepathHtml($add);
  2239. }
  2240. }
  2241. elseif($f=='morepic')//图片集
  2242. {
  2243. if(strstr($newstemptext,'[!--morepic--]'))
  2244. {
  2245. $value=ReturnMorepicpathHtml($add);
  2246. }
  2247. }
  2248. elseif($f=='newstime')//时间
  2249. {
  2250. if(strstr($newstemptext,'[!--newstime--]'))
  2251. {
  2252. $value=date($formatdate,$value);
  2253. }
  2254. }
  2255. elseif($f=='befrom')//信息来源
  2256. {
  2257. if($docheckrep[1]&&strstr($newstemptext,'[!--befrom--]'))
  2258. {
  2259. $value=ReplaceBefrom($value);
  2260. }
  2261. }
  2262. elseif($f=='writer')//作者
  2263. {
  2264. if($docheckrep[2]&&strstr($newstemptext,'[!--writer--]'))
  2265. {
  2266. $value=ReplaceWriter($value);
  2267. }
  2268. }
  2269. elseif($f=='titlepic')//标题图片
  2270. {
  2271. if(empty($value))
  2272. {$value=$public_r[newsurl].'e/data/images/notimg.gif';}
  2273. }
  2274. elseif($f=='title')//标题
  2275. {
  2276. }
  2277. else//正常字段
  2278. {
  2279. if(!strstr($emod_r[$mid]['editorf'],','.$f.','))
  2280. {
  2281. if(strstr($emod_r[$mid]['tobrf'],','.$f.','))//加br
  2282. {
  2283. $value=nl2br($value);
  2284. }
  2285. if(!strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//去除html
  2286. {
  2287. $value=RepFieldtextNbsp(htmlspecialchars($value));
  2288. }
  2289. }
  2290. }
  2291. $newstempstr=str_replace('[!--'.$f.'--]',$value,$newstempstr);
  2292. }
  2293. //固定变量
  2294. $newstempstr=str_replace('[!--id--]',$add[id],$newstempstr);
  2295. $newstempstr=str_replace('[!--classid--]',$add[classid],$newstempstr);
  2296. $newstempstr=str_replace('[!--class.name--]',$class_r[$add[classid]][classname],$newstempstr);
  2297. $newstempstr=str_replace('[!--ttid--]',$add[ttid],$newstempstr);
  2298. $newstempstr=str_replace('[!--tt.name--]',$class_tr[$add[ttid]][tname],$newstempstr);
  2299. $newstempstr=str_replace('[!--onclick--]',$add[onclick],$newstempstr);
  2300. $newstempstr=str_replace('[!--userfen--]',$add[userfen],$newstempstr);
  2301. $newstempstr=str_replace('[!--username--]',$add[username],$newstempstr);
  2302. //带链接的用户名
  2303. if($add[ismember]==1&&$add[userid])
  2304. {
  2305. $newstempstr=str_replace('[!--linkusername--]',"<a href='".$public_r[newsurl]."e/space/?userid=".$add[userid]."' target=_blank>".$add[username]."</a>",$newstempstr);
  2306. }
  2307. else
  2308. {
  2309. $newstempstr=str_replace('[!--linkusername--]',$add[username],$newstempstr);
  2310. }
  2311. $newstempstr=str_replace('[!--userid--]',$add[userid],$newstempstr);
  2312. $newstempstr=str_replace('[!--other.link--]',$keyboardtext,$newstempstr);
  2313. $newstempstr=str_replace('[!--news.url--]',$public_r[newsurl],$newstempstr);
  2314. $newstempstr=str_replace('[!--plnum--]',$add[plnum],$newstempstr);
  2315. $newstempstr=str_replace('[!--totaldown--]',$add[totaldown],$newstempstr);
  2316. $newstempstr=str_replace('[!--keyboard--]',$add[keyboard],$newstempstr);
  2317. //链接
  2318. $titleurl=sys_ReturnBqTitleLink($add);
  2319. $newstempstr=str_replace('[!--titleurl--]',$titleurl,$newstempstr);
  2320. $newstempstr=str_replace('[!--page.stats--]',$onclick,$newstempstr);
  2321. $classurl=sys_ReturnBqClassname($add,9);
  2322. $newstempstr=str_replace('[!--class.url--]',$classurl,$newstempstr);
  2323. //下一篇
  2324. if(strstr($newstemptext,'[!--info.next--]'))
  2325. {
  2326. $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id>$add[id] and classid='$add[classid]' and checked=1 order by id limit 1");
  2327. if(empty($next_r[id]))
  2328. {
  2329. $infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>";
  2330. }
  2331. else
  2332. {
  2333. //链接
  2334. $nexttitleurl=sys_ReturnBqTitleLink($next_r);
  2335. $infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>";
  2336. }
  2337. $newstempstr=str_replace('[!--info.next--]',$infonext,$newstempstr);
  2338. }
  2339. //上一篇
  2340. if(strstr($newstemptext,'[!--info.pre--]'))
  2341. {
  2342. $next_r=$empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$add[id] and classid='$add[classid]' and checked=1 order by id desc limit 1");
  2343. if(empty($next_r[id]))
  2344. {
  2345. $infonext="<a href='".$classurl."'>".$fun_r['HaveNoNextLink']."</a>";
  2346. }
  2347. else
  2348. {
  2349. //链接
  2350. $nexttitleurl=sys_ReturnBqTitleLink($next_r);
  2351. $infonext="<a href='".$nexttitleurl."'>".$next_r[title]."</a>";
  2352. }
  2353. $newstempstr=str_replace('[!--info.pre--]',$infonext,$newstempstr);
  2354. }
  2355. //投票
  2356. if(strstr($newstemptext,'[!--info.vote--]'))
  2357. {
  2358. $myvotetext=sys_GetInfoVote($add[classid],$add[id]);
  2359. $newstempstr=str_replace('[!--info.vote--]',$myvotetext,$newstempstr);
  2360. }
  2361. //评分
  2362. if(strstr($newstemptext,'[!--pinfopfen--]'))
  2363. {
  2364. $pinfopfen=$add[infopfennum]?round($add[infopfen]/$add[infopfennum]):0;
  2365. $newstempstr=str_replace('[!--pinfopfen--]',$pinfopfen,$newstempstr);
  2366. $newstempstr=str_replace('[!--infopfennum--]',$add[infopfennum],$newstempstr);
  2367. }
  2368. if($pf&&strstr($add[$pf],$expage))//有分页
  2369. {
  2370. $n_r=explode($expage,$add[$pf]);
  2371. $thispagenum=count($n_r);
  2372. //取得分页
  2373. $thefun=$public_r['textpagefun']?$public_r['textpagefun']:'sys_ShowTextPage';
  2374. //下拉式分页
  2375. if(strstr($newstemptext,'[!--title.select--]'))
  2376. {
  2377. $dotitleselect=sys_ShowTextPageSelect($thispagenum,$dolink,$add,$filetype,$n_r);
  2378. }
  2379. for($j=1;$j<=$thispagenum;$j++)
  2380. {
  2381. $string=$newstempstr;//模板
  2382. $truepage='';
  2383. $titleselect='';
  2384. //下一页链接
  2385. if($thispagenum==$j)
  2386. {
  2387. $thisnextlink=$dolink.$add[filename].$filetype;
  2388. }
  2389. else
  2390. {
  2391. $thisj=$j+1;
  2392. $thisnextlink=$dolink.$add[filename].'_'.$thisj.$filetype;
  2393. }
  2394. $k=$j-1;
  2395. if($j==1)
  2396. {
  2397. $file=$doclasspath.$newspath.$add[filename].$filetype;
  2398. $ptitle=$add[title];
  2399. }
  2400. else
  2401. {
  2402. $file=$doclasspath.$newspath.$add[filename].'_'.$j.$filetype;
  2403. $ti_r=explode('[/!--empirenews.page--]',$n_r[$k]);
  2404. if(count($ti_r)>=2)
  2405. {
  2406. $ptitle=$ti_r[0];
  2407. $n_r[$k]=$ti_r[1];
  2408. }
  2409. else
  2410. {
  2411. $ptitle=$add[title].'('.$j.')';
  2412. }
  2413. }
  2414. //取得当前页
  2415. if($thispagenum!=1)
  2416. {
  2417. $truepage=$thefun($thispagenum,$j,$dolink,$add,$filetype,'');
  2418. $titleselect=str_replace("?".$j."\">","?".$j."\" selected>",$dotitleselect);
  2419. }
  2420. //替换变量
  2421. $newstext=$n_r[$k];
  2422. if(!strstr($emod_r[$mid]['editorf'],','.$pf.','))
  2423. {
  2424. if(strstr($emod_r[$mid]['tobrf'],','.$pf.','))//加br
  2425. {
  2426. $newstext=nl2br($newstext);
  2427. }
  2428. if(!strstr($emod_r[$mid]['dohtmlf'],','.$pf.','))//去除html
  2429. {
  2430. $newstext=htmlspecialchars($newstext);
  2431. $newstext=RepFieldtextNbsp($newstext);
  2432. }
  2433. }
  2434. $string=str_replace('[!--'.$pf.'--]',$newstext,$string);
  2435. $string=str_replace('[!--p.title--]',$ptitle,$string);
  2436. $string=str_replace('[!--next.page--]',$thisnextlink,$string);
  2437. $string=str_replace('[!--page.url--]',$truepage,$string);
  2438. $string=str_replace('[!--title.select--]',$titleselect,$string);
  2439. //写文件
  2440. WriteFiletext($file,$addlevel.$string);
  2441. }
  2442. }
  2443. else
  2444. {
  2445. $file=$doclasspath.$newspath.$add[filename].$filetype;
  2446. $string=$newstempstr;//模板
  2447. //替换变量
  2448. $string=str_replace('[!--p.title--]',$add[title],$string);
  2449. $string=str_replace('[!--next.page--]','',$string);
  2450. $string=str_replace('[!--page.url--]','',$string);
  2451. $string=str_replace('[!--title.select--]','',$string);
  2452. //写文件
  2453. WriteFiletext($file,$addlevel.$string);
  2454. }
  2455. //设为已生成
  2456. if(empty($add['havehtml']))
  2457. {
  2458. $empire->query("update {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." set havehtml=1 where id='$add[id]' limit 1");
  2459. }
  2460. }
  2461. //返回随机字符
  2462. function ReturnNotcj($string){
  2463. global $notcj_r,$notcjnum;
  2464. if(empty($notcjnum))
  2465. {
  2466. $rep="";
  2467. }
  2468. else
  2469. {
  2470. $i=rand(1,$notcjnum);
  2471. $rep=$notcj_r[$i];
  2472. }
  2473. $cjword="<!--ecms.*-->";
  2474. $string=str_replace($cjword,$rep,$string);
  2475. return $string;
  2476. }
  2477. //取得相关链接
  2478. function GetKeyboard($keyboard,$keyid,$classid,$id,$link_num){
  2479. global $empire,$public_r,$class_r,$fun_r,$dbtbpre;
  2480. if($keyid&&$link_num)
  2481. {
  2482. $add="id in (".$keyid.")";
  2483. $tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板
  2484. $temp_r=explode("[!--empirenews.listtemp--]",$tr[otherlinktemp]);
  2485. $key_sql=$empire->query("select id,newspath,newstime,title,filename,titleurl,groupid,classid,titlepic from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add." order by newstime desc limit $link_num");
  2486. while($link_r=$empire->fetch($key_sql))
  2487. {
  2488. $keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);
  2489. }
  2490. $keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];
  2491. }
  2492. else
  2493. {
  2494. $keyboardtext=$fun_r['NotLinkNews'];
  2495. }
  2496. return $keyboardtext;
  2497. }
  2498. //替换相关链接模板
  2499. function RepOtherTemp($temptext,$r,$tr){
  2500. global $public_r,$class_r;
  2501. $title=sub($r[title],0,$tr['otherlinktempsub'],false);
  2502. $r['newstime']=date($tr['otherlinktempdate'],$r['newstime']);
  2503. $titlelink=sys_ReturnBqTitleLink($r);//标题链接
  2504. $temptext=str_replace("[!--title--]",$title,$temptext);
  2505. $temptext=str_replace("[!--oldtitle--]",$r[title],$temptext);
  2506. $temptext=str_replace("[!--titleurl--]",$titlelink,$temptext);
  2507. $temptext=str_replace("[!--newstime--]",$r[newstime],$temptext);
  2508. if(empty($r[titlepic]))
  2509. {
  2510. $titlepic=$public_r[newsurl]."e/data/images/notimg.gif";
  2511. }
  2512. else
  2513. {
  2514. $titlepic=$r[titlepic];
  2515. }
  2516. $temptext=str_replace("[!--titlepic--]",$titlepic,$temptext);
  2517. return $temptext;
  2518. }
  2519. //返回下载地址html代码
  2520. function ReturnDownSoftHtml($add){
  2521. global $class_r,$public_r,$fun_r,$level_r;
  2522. if(empty($add[downpath]))
  2523. {
  2524. return '';
  2525. }
  2526. //每行显示条数
  2527. $down_num=$class_r[$add[classid]][down_num]?$class_r[$add[classid]][down_num]:1;
  2528. //替换模板
  2529. $ydownsofttemp=$public_r[downsofttemp];
  2530. $ydownsofttemp=str_replace('[!--classid--]',$add[classid],$ydownsofttemp);
  2531. $ydownsofttemp=str_replace('[!--id--]',$add[id],$ydownsofttemp);
  2532. $ydownsofttemp=str_replace('[!--title--]',$add[title],$ydownsofttemp);
  2533. $ydownsofttemp=str_replace('[!--news.url--]',$public_r[newsurl],$ydownsofttemp);
  2534. //组合地址
  2535. $all_downpath='';
  2536. $path_r=explode("\r\n",$add[downpath]);
  2537. $count=count($path_r);
  2538. for($pj=0;$pj<$count;$pj++)
  2539. {
  2540. $p=$pj+1;
  2541. if($p%$down_num==0)
  2542. {
  2543. $ok='<br>';
  2544. }
  2545. else
  2546. {
  2547. $ok='';
  2548. }
  2549. //相同
  2550. if($count==$p)
  2551. {
  2552. $ok='';
  2553. }
  2554. if($pj%$down_num==0||$pj==0)
  2555. {
  2556. $nbsp='';
  2557. }
  2558. else
  2559. {
  2560. $nbsp='&nbsp;&nbsp;';
  2561. }
  2562. $showdown_r=explode('::::::',$path_r[$pj]);
  2563. if(count($showdown_r)<2)
  2564. {
  2565. $showdown_r[0]=$fun_r['DownPath'].$p;
  2566. }
  2567. //模板
  2568. $downsofttemp=RepDownOnlinePathTemp($add,$ydownsofttemp,$pj,$showdown_r,0);
  2569. $all_downpath.=$nbsp.stripSlashes($downsofttemp).$ok;
  2570. }
  2571. $value=$all_downpath;
  2572. return $value;
  2573. }
  2574. //替换下载在线地址模板
  2575. function RepDownOnlinePathTemp($add,$downsofttemp,$pj,$showdown_r,$ecms){
  2576. global $public_r,$level_r,$fun_r;
  2577. if($ecms==0)//下载
  2578. {
  2579. $downurl=$public_r[newsurl]."e/DownSys/DownSoft/?classid=$add[classid]&id=$add[id]&pathid=$pj";
  2580. }
  2581. else//在线
  2582. {
  2583. $downurl=$public_r[newsurl]."e/DownSys/play/?classid=$add[classid]&id=$add[id]&pathid=$pj";
  2584. }
  2585. $downsofttemp=str_replace('[!--down.url--]',$downurl,$downsofttemp);
  2586. $downsofttemp=str_replace('[!--down.name--]',$showdown_r[0],$downsofttemp);
  2587. $downsofttemp=str_replace('[!--pathid--]',$pj,$downsofttemp);
  2588. $downsofttemp=str_replace('[!--fen--]',$showdown_r[3],$downsofttemp);
  2589. $group=$showdown_r[2]?$level_r[$showdown_r[2]][groupname]:$fun_r['hguest'];
  2590. $downsofttemp=str_replace('[!--group--]',$group,$downsofttemp);
  2591. if(strstr($downsofttemp,'[!--true.down.url--]'))
  2592. {
  2593. $durl=stripSlashes($showdown_r[1]);
  2594. $durlr=ReturnDownQzPath($durl,$showdown_r[4]);
  2595. $durl=$durlr['repath'];
  2596. $downsofttemp=str_replace('[!--true.down.url--]',$durl,$downsofttemp);
  2597. }
  2598. return $downsofttemp;
  2599. }
  2600. //返回在线地址html代码
  2601. function ReturnOnlinepathHtml($add){
  2602. global $class_r,$public_r,$fun_r,$level_r;
  2603. if(empty($add[onlinepath]))
  2604. {
  2605. return '';
  2606. }
  2607. //每行显示条数
  2608. $down_num=$class_r[$add[classid]][online_num]?$class_r[$add[classid]][online_num]:1;
  2609. //替换模板
  2610. $yonlinemovietemp=$public_r[onlinemovietemp];
  2611. $yonlinemovietemp=str_replace('[!--classid--]',$add[classid],$yonlinemovietemp);
  2612. $yonlinemovietemp=str_replace('[!--id--]',$add[id],$yonlinemovietemp);
  2613. $yonlinemovietemp=str_replace('[!--title--]',$add[title],$yonlinemovietemp);
  2614. $yonlinemovietemp=str_replace('[!--news.url--]',$public_r[newsurl],$yonlinemovietemp);
  2615. //地址
  2616. $all_downpath='';
  2617. $path_r=explode("\r\n",$add[onlinepath]);
  2618. $count=count($path_r);
  2619. for($pj=0;$pj<$count;$pj++)
  2620. {
  2621. $p=$pj+1;
  2622. if($p%$down_num==0)
  2623. {
  2624. $ok='<br>';
  2625. }
  2626. else
  2627. {
  2628. $ok='';
  2629. }
  2630. //相同
  2631. if($count==$p)
  2632. {
  2633. $ok='';
  2634. }
  2635. if($pj%$down_num==0||$pj==0)
  2636. {
  2637. $nbsp='';
  2638. }
  2639. else
  2640. {
  2641. $nbsp='&nbsp;&nbsp;';
  2642. }
  2643. $showdown_r=explode('::::::',$path_r[$pj]);
  2644. if(count($showdown_r)<2)
  2645. {
  2646. $showdown_r[0]=$p;
  2647. }
  2648. //模板
  2649. $downsofttemp=RepDownOnlinePathTemp($add,$yonlinemovietemp,$pj,$showdown_r,1);
  2650. $all_downpath.=$nbsp.stripSlashes($downsofttemp).$ok;
  2651. }
  2652. $value=$all_downpath;
  2653. return $value;
  2654. }
  2655. //返回图片集html代码
  2656. function ReturnMorepicpathHtml($add){
  2657. global $public_r,$fun_r;
  2658. if(empty($add[morepic]))
  2659. {
  2660. return '';
  2661. }
  2662. $line=$add[num]?$add[num]:1;//每行显示
  2663. $picpath='';
  2664. $path_r=explode("\r\n",$add[morepic]);
  2665. for($pj=0;$pj<count($path_r);$pj++)
  2666. {
  2667. $p=$pj+1;
  2668. if(($p-1)%$line==0||$p==1)
  2669. {
  2670. $picpath.='<tr>';
  2671. }
  2672. $showdown_r=explode('::::::',$path_r[$pj]);
  2673. //显示图片名称
  2674. $name='';
  2675. if(!empty($showdown_r[2]))
  2676. {
  2677. $name="<br><span style='line-height=18pt'>".$showdown_r[2]."</span>";
  2678. }
  2679. $width=$add[width]?" width='".$add[width]."'":'';//宽度
  2680. $height=$add[height]?" height='".$add[height]."'":'';//高度
  2681. $picpath.="<td align=center><a href='".$public_r[newsurl]."e/ViewImg/index.html?url=".$showdown_r[1]."' target=_blank><img src='".$showdown_r[0]."'".$width.$height." border=0>".$name."</a></td>";
  2682. //分割
  2683. if($p%$line==0)
  2684. {
  2685. $picpath.='</tr>';
  2686. }
  2687. }
  2688. if($p<>0)
  2689. {
  2690. $table="<table width='100%' border=0 cellpadding=4 cellspacing=4>";
  2691. $table1="</table>";
  2692. $ys=$line-$p%$line;
  2693. $dotr=0;
  2694. for($j=0;$j<$ys&&$ys!=$line;$j++)
  2695. {
  2696. $dotr=1;
  2697. $picpath.='<td></td>';
  2698. }
  2699. if($dotr==1)
  2700. {
  2701. $picpath.='</tr>';
  2702. }
  2703. }
  2704. $value=$table.$picpath.$table1;
  2705. return $value;
  2706. }
  2707. //生成js
  2708. function GetNewsJs($classid,$line,$sub,$showdate,$enews=0,$tempr){
  2709. global $empire,$public_r,$class_r,$class_zr,$emod_r,$etable_r,$dbtbpre,$eyh_r;
  2710. if(empty($line))
  2711. {
  2712. $line=10;
  2713. }
  2714. if(empty($sub))
  2715. {
  2716. $sub=26;
  2717. }
  2718. //栏目
  2719. if($enews==0||$enews==1||$enews==2||$enews==9||$enews==12||$enews==15)
  2720. {
  2721. $where=$class_r[$classid][islast]?"classid='$classid'":ReturnClass($class_r[$classid][sonclass]);
  2722. }
  2723. $allpath=ECMS_PATH.'d/js/js/';
  2724. $ztpath=ECMS_PATH.'d/js/class/zt'.$classid.'_';
  2725. $classpath=ECMS_PATH.'d/js/class/class'.$classid.'_';
  2726. if($enews==0)//栏目最新
  2727. {
  2728. $tbname=$class_r[$classid][tbname];
  2729. $query=$where.' and checked=1';
  2730. $order='newstime';
  2731. $newsjs=$classpath.'newnews.js';
  2732. $mid=$class_r[$classid][modid];
  2733. $yhid=$class_r[$classid][yhid];
  2734. $yhvar='bqnew';
  2735. }
  2736. elseif($enews==1)//栏目热门
  2737. {
  2738. $tbname=$class_r[$classid][tbname];
  2739. $query=$where.' and checked=1';
  2740. $order="onclick";
  2741. $newsjs=$classpath.'hotnews.js';
  2742. $mid=$class_r[$classid][modid];
  2743. $yhid=$class_r[$classid][yhid];
  2744. $yhvar='bqhot';
  2745. }
  2746. elseif($enews==2)//栏目推荐
  2747. {
  2748. $tbname=$class_r[$classid][tbname];
  2749. $query=$where.' and isgood>0 and checked=1';
  2750. $order='newstime';
  2751. $newsjs=$classpath.'goodnews.js';
  2752. $mid=$class_r[$classid][modid];
  2753. $yhid=$class_r[$classid][yhid];
  2754. $yhvar='bqgood';
  2755. }
  2756. elseif($enews==9)//各栏目评论排行
  2757. {
  2758. $tbname=$class_r[$classid][tbname];
  2759. $query=$where.' and checked=1';
  2760. $order='plnum';
  2761. $newsjs=$classpath.'hotplnews.js';
  2762. $mid=$class_r[$classid][modid];
  2763. $yhid=$class_r[$classid][yhid];
  2764. $yhvar='bqpl';
  2765. }
  2766. elseif($enews==12)//各栏目头条
  2767. {
  2768. $tbname=$class_r[$classid][tbname];
  2769. $query=$where.' and firsttitle>0 and checked=1';
  2770. $order='newstime';
  2771. $newsjs=$classpath.'firstnews.js';
  2772. $mid=$class_r[$classid][modid];
  2773. $yhid=$class_r[$classid][yhid];
  2774. $yhvar='bqfirst';
  2775. }
  2776. elseif($enews==3)//所有最新
  2777. {
  2778. $tbname=$public_r['tbname'];
  2779. $query='checked=1';
  2780. $order='newstime';
  2781. $newsjs=$allpath.'newnews.js';
  2782. $mid=$etable_r[$tbname][mid];
  2783. $yhvar='bqnew';
  2784. $yhid=$etable_r[$tbname][yhid];
  2785. }
  2786. elseif($enews==4)//所有点击排行
  2787. {
  2788. $tbname=$public_r['tbname'];
  2789. $query='checked=1';
  2790. $order='onclick';
  2791. $newsjs=$allpath.'hotnews.js';
  2792. $mid=$etable_r[$tbname][mid];
  2793. $yhvar='bqhot';
  2794. $yhid=$etable_r[$tbname][yhid];
  2795. }
  2796. elseif($enews==5)//所有推荐
  2797. {
  2798. $tbname=$public_r['tbname'];
  2799. $query='isgood>0 and checked=1';
  2800. $order='newstime';
  2801. $newsjs=$allpath.'goodnews.js';
  2802. $mid=$etable_r[$tbname][mid];
  2803. $yhvar='bqgood';
  2804. $yhid=$etable_r[$tbname][yhid];
  2805. }
  2806. elseif($enews==10)//所有评论排行
  2807. {
  2808. $tbname=$public_r['tbname'];
  2809. $query='checked=1';
  2810. $order='plnum';
  2811. $newsjs=$allpath.'hotplnews.js';
  2812. $mid=$etable_r[$tbname][mid];
  2813. $yhvar='bqpl';
  2814. $yhid=$etable_r[$tbname][yhid];
  2815. }
  2816. elseif($enews==13)//所有头条
  2817. {
  2818. $tbname=$public_r['tbname'];
  2819. $query='firsttitle>0 and checked=1';
  2820. $order='newstime';
  2821. $newsjs=$allpath.'firstnews.js';
  2822. $mid=$etable_r[$tbname][mid];
  2823. $yhvar='bqfirst';
  2824. $yhid=$etable_r[$tbname][yhid];
  2825. }
  2826. elseif($enews==6)//专题最新
  2827. {
  2828. $tbname=$class_zr[$classid][tbname];
  2829. $query="ztid like '%|".$classid."|%' and checked=1";
  2830. $order='newstime';
  2831. $newsjs=$ztpath.'newnews.js';
  2832. $mid=$etable_r[$tbname][mid];
  2833. $yhid=$class_zr[$classid][yhid];
  2834. $yhvar='bqnew';
  2835. }
  2836. elseif($enews==7)//专题点击排行
  2837. {
  2838. $tbname=$class_zr[$classid][tbname];
  2839. $query="ztid like '%|".$classid."|%' and checked=1";
  2840. $order='onclick';
  2841. $newsjs=$ztpath.'hotnews.js';
  2842. $mid=$etable_r[$tbname][mid];
  2843. $yhid=$class_zr[$classid][yhid];
  2844. $yhvar='bqhot';
  2845. }
  2846. elseif($enews==8)//专题推荐
  2847. {
  2848. $tbname=$class_zr[$classid][tbname];
  2849. $query="ztid like '%|".$classid."|%' and isgood>0 and checked=1";
  2850. $order='newstime';
  2851. $newsjs=$ztpath.'goodnews.js';
  2852. $mid=$etable_r[$tbname][mid];
  2853. $yhid=$class_zr[$classid][yhid];
  2854. $yhvar='bqgood';
  2855. }
  2856. elseif($enews==11)//专题评论排行
  2857. {
  2858. $tbname=$class_zr[$classid][tbname];
  2859. $query="ztid like '%|".$classid."|%' and checked=1";
  2860. $order='plnum';
  2861. $newsjs=$ztpath.'hotplnews.js';
  2862. $mid=$etable_r[$tbname][mid];
  2863. $yhid=$class_zr[$classid][yhid];
  2864. $yhvar='bqpl';
  2865. }
  2866. elseif($enews==14)//专题头条
  2867. {
  2868. $tbname=$class_zr[$classid][tbname];
  2869. $query="ztid like '%|".$classid."|%' and firsttitle>0 and checked=1";
  2870. $order='newstime';
  2871. $newsjs=$ztpath.'firstnews.js';
  2872. $mid=$etable_r[$tbname][mid];
  2873. $yhid=$class_zr[$classid][yhid];
  2874. $yhvar='bqfirst';
  2875. }
  2876. $ret_r=ReturnReplaceListF($tempr[modid]);//字段
  2877. //优化
  2878. $yhadd='';
  2879. if(!empty($eyh_r[$yhid]['dojs']))
  2880. {
  2881. $yhadd=ReturnYhSql($yhid,$yhvar);
  2882. }
  2883. $query='select '.ReturnSqlListF($mid).' from '.$dbtbpre.'ecms_'.$tbname.' where '.$yhadd.$query.' order by '.ReturnSetTopSql('js').$order.' desc limit '.$line;
  2884. $sql=$empire->query($query);
  2885. //取得js模板
  2886. $tempr[temptext]=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[temptext]);
  2887. $temp_r=explode("[!--empirenews.listtemp--]",$tempr[temptext]);
  2888. $no=1;
  2889. while($r=$empire->fetch($sql))
  2890. {
  2891. $r[oldtitle]=$r[title];
  2892. //替换列表变量
  2893. $repvar=ReplaceListVars($no,$temp_r[1],$tempr[subnews],$tempr[subtitle],$tempr[showdate],$url,0,$r,$ret_r);
  2894. $allnew.=$repvar;
  2895. $no++;
  2896. }
  2897. $allnew="document.write(\"".addslashes(stripSlashes(str_replace("\r\n","",$temp_r[0].$allnew.$temp_r[2])))."\");";
  2898. WriteFiletext_n($newsjs,$allnew);
  2899. }
  2900. //生成自定义js
  2901. function ReUserjs($jsr,$addpath){
  2902. global $empire,$public_r;
  2903. DoFileMkDir($addpath.$jsr['jsfilename']);//建目录
  2904. //取得js模板
  2905. $jstemptext=GetTheJstemp($jsr[jstempid]);
  2906. $ret_r=ReturnReplaceListF($jstemptext[modid]);//字段
  2907. $jstemptext[temptext]=str_replace('[!--news.url--]',$public_r[newsurl],$jstemptext[temptext]);
  2908. $temp_r=explode("[!--empirenews.listtemp--]",$jstemptext[temptext]);
  2909. $query=stripSlashes($jsr[jssql]);
  2910. $query=RepSqlTbpre($query);
  2911. $sql=$empire->query($query);
  2912. $no=1;
  2913. while($r=$empire->fetch($sql))
  2914. {
  2915. $r[oldtitle]=$r[title];
  2916. //替换列表变量
  2917. $repvar=ReplaceListVars($no,$temp_r[1],$jstemptext[subnews],$jstemptext[subtitle],$jstemptext[showdate],$url,0,$r,$ret_r);
  2918. $allnew.=$repvar;
  2919. $no++;
  2920. }
  2921. $allnew="document.write(\"".addslashes(stripSlashes(str_replace("\r\n","",$temp_r[0].$allnew.$temp_r[2])))."\");";
  2922. WriteFiletext_n($addpath.$jsr['jsfilename'],$allnew);
  2923. }
  2924. //刷新信息列表
  2925. function ReListHtml($classid,$enews=0){
  2926. global $empire,$class_r,$dbtbpre;
  2927. $classid=(int)$classid;
  2928. if(!$classid)
  2929. {
  2930. printerror("NotChangeReClassid","history.go(-1)");
  2931. }
  2932. $r=$empire->fetch1("select classtempid,islist from {$dbtbpre}enewsclass where classid='$classid'");
  2933. if($class_r[$classid][islast])//终极栏目
  2934. {
  2935. ListHtml($classid,$ret_r,0);
  2936. }
  2937. else
  2938. {
  2939. if($r[islist]==1)
  2940. {
  2941. ListHtml($classid,$ret_r,3);
  2942. }
  2943. elseif($r[islist]==3)
  2944. {
  2945. ReClassBdInfo($classid);
  2946. }
  2947. else
  2948. {
  2949. $classtemp=$r[islist]==2?GetClassText($classid):GetClassTemp($r['classtempid']);
  2950. NewsBq($classid,$classtemp,0,0);
  2951. }
  2952. }
  2953. if($enews==1)//内部刷新
  2954. {return "";}
  2955. insert_dolog("");//操作日志
  2956. printerror("ReClassidSuccess","history.go(-1)");
  2957. }
  2958. //取得自定义页面模板
  2959. function GetPageTemp($tempid){
  2960. global $empire;
  2961. $r=$empire->fetch1("select temptext from ".GetTemptb("enewspagetemp")." where tempid='$tempid'");
  2962. return $r['temptext'];
  2963. }
  2964. //替换自定义页面标签
  2965. function RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id){
  2966. $pagestr=str_replace("[!--pagetext--]",$pagetext,$pagestr);
  2967. $pagestr=str_replace("[!--pagetitle--]",$pagetitle,$pagestr);
  2968. $pagestr=str_replace("[!--pagekeywords--]",$pagekeywords,$pagestr);
  2969. $pagestr=str_replace("[!--pagedescription--]",$pagedescription,$pagestr);
  2970. $pagestr=str_replace("[!--pageid--]",$id,$pagestr);
  2971. $pagestr=str_replace("[!--pagename--]",$title,$pagestr);
  2972. return $pagestr;
  2973. }
  2974. //生成自定义页面
  2975. function ReUserpage($id,$pagetext,$path,$title="",$pagetitle,$pagekeywords,$pagedescription,$tempid=0){
  2976. global $public_r;
  2977. if(empty($path))
  2978. {
  2979. return "";
  2980. }
  2981. DoFileMkDir($path);//建目录
  2982. if(empty($pagetitle))
  2983. {
  2984. $pagetitle=$title;
  2985. }
  2986. //模板式
  2987. if($tempid)
  2988. {
  2989. $pagestr=GetPageTemp($tempid);
  2990. }
  2991. else
  2992. {
  2993. $pagestr=$pagetext;
  2994. }
  2995. $pagestr=InfoNewsBq("page".$id,$pagestr);
  2996. $pagestr=RepUserpageVar($pagetext,$title,$pagetitle,$pagekeywords,$pagedescription,$pagestr,$id);
  2997. $pagestr=str_replace("[!--news.url--]",$public_r['newsurl'],$pagestr);
  2998. WriteFiletext($path,$pagestr);
  2999. }
  3000. //生成自定义信息列表
  3001. function ReUserlist($listr,$addpath){
  3002. $listr['addpath']=$addpath;
  3003. DoFileMkDir($listr['addpath'].$listr['filepath']);//建目录
  3004. ListHtml($classid,$field,4,$listr);
  3005. }
  3006. //生成搜索文件
  3007. function GetSearch($mid=0){
  3008. global $empire,$public_r,$fun_r,$dbtbpre;
  3009. //取得模板
  3010. $tr=$empire->fetch1("select searchtemp,searchjstemp,searchjstemp1 from ".GetTemptb("enewspubtemp")." limit 1");
  3011. //返回栏目搜索
  3012. $fcfile="../data/fc/ListEnews.php";
  3013. $fcjsfile="../data/fc/cmsclass.js";
  3014. if(file_exists($fcjsfile)&&file_exists($fcfile))
  3015. {
  3016. $options=GetFcfiletext($fcjsfile);
  3017. }
  3018. else
  3019. {
  3020. $options=ShowClass_AddClass("","n",0,"|-",0,1);
  3021. }
  3022. //$options="<script src=".$public_r[newsurl]."e/data/fc/searchclass.js></script>";
  3023. $functions="function search_check(obj){if(obj.keyboard.value.length==0){alert('".$fun_r['EmptyKey']."');return false;}return true;}";
  3024. //横向搜索
  3025. $searchjstemp=ReplaceStemp($tr[searchjstemp],$options,$url,0,'','','');
  3026. $text2=$functions."document.write(\"".$searchjstemp."\");";
  3027. //纵向搜索
  3028. $searchjstemp1=ReplaceStemp($tr[searchjstemp1],$options,$url,0,'','','');
  3029. $text3.=$functions."document.write(\"".$searchjstemp1."\");";
  3030. //高级搜索
  3031. $url="<a href='".$public_r[newsurl]."'>".$fun_r['index']."</a>&nbsp;>&nbsp;<a href='../search/'>".$fun_r['adsearch']."</a>&nbsp;>";//导航栏
  3032. //搜索模板替换
  3033. $dbsearchtemp=ReplaceStemp($tr[searchtemp],$options,$url,0,$fun_r['adsearch'],$fun_r['adsearch'],$fun_r['adsearch'],1);
  3034. $text4=$dbsearchtemp;
  3035. //增加信息栏目
  3036. if($mid)
  3037. {
  3038. $options1=ShowClass_AddClass("","n",0,"|-",$mid,2);
  3039. $addnews_class="document.write(\"".addslashes($options1)."\");";
  3040. $filename3="../../d/js/js/addinfo".$mid.".js";
  3041. WriteFiletext_n($filename3,$addnews_class);
  3042. }
  3043. $filename="../../d/js/js/search_news1.js";
  3044. WriteFiletext_n($filename,$text2);
  3045. $filename1="../../d/js/js/search_news2.js";
  3046. WriteFiletext_n($filename1,$text3);
  3047. $filename2="../../search/index".$public_r[searchtype];
  3048. WriteFiletext($filename2,$text4);
  3049. }
  3050. //替换搜索结果变量
  3051. function RepSearchRtemp($temptext,$url){
  3052. global $public_r;
  3053. //热门文章
  3054. $temptext=str_replace("[!--hotnews--]","<script src=".$public_r[newsurl]."d/js/js/hotnews.js></script>",$temptext);
  3055. //点击排行
  3056. $temptext=str_replace("[!--newnews--]","<script src=".$public_r[newsurl]."d/js/js/newnews.js></script>",$temptext);
  3057. //推荐
  3058. $temptext=str_replace("[!--goodnews--]","<script src=".$public_r[newsurl]."d/js/js/goodnews.js></script>",$temptext);
  3059. //评论排行
  3060. $temptext=str_replace("[!--hotplnews--]","<script src=".$public_r[newsurl]."d/js/js/hotplnews.js></script>",$temptext);
  3061. //分页
  3062. $temptext=str_replace("[!--listpage--]","<?=\$listpage?>",$temptext);
  3063. //关键字
  3064. $temptext=str_replace("[!--keyboard--]","<?=\$keyboard?>",$temptext);
  3065. //总记录数
  3066. $temptext=str_replace("[!--num--]","<?=\$num?>",$temptext);
  3067. //导行条
  3068. $temptext=str_replace("[!--url--]",$url,$temptext);
  3069. $temptext=str_replace("[!--newsurl--]",$public_r[newsurl],$temptext);
  3070. return $temptext;
  3071. }
  3072. //生成评论文件
  3073. function GetPlTempPage($pltempid=0){
  3074. global $empire,$public_r,$fun_r,$dbtbpre;
  3075. $pl_t_filename=ECMS_PATH.'e/data/template/pltemp.txt';
  3076. $yplfiletemp=ReadFiletext($pl_t_filename);
  3077. $yplfiletemp=str_replace("\\","\\\\",$yplfiletemp);
  3078. //导航栏
  3079. $url="<a href=".$public_r[newsurl].">".$fun_r['index']."</a>&nbsp;>&nbsp;[!--title--]&nbsp;>&nbsp;".$fun_r['newspl']."&nbsp;>";
  3080. $pagetitle="<?=\$pagetitle?> ".$fun_r['newspl'];
  3081. $pagekey=$pagetitle;
  3082. $pagedes=$pagetitle;
  3083. $pr=$empire->fetch1("select plf from {$dbtbpre}enewspublic limit 1");
  3084. //回车字段
  3085. $tobrf=',';
  3086. $plfsql=$empire->query("select f from {$dbtbpre}enewsplf where ftype='VARCHAR' or ftype='TEXT' or ftype='MEDIUMTEXT' or ftype='LONGTEXT'");
  3087. while($plfr=$empire->fetch($plfsql))
  3088. {
  3089. $tobrf.=$plfr[f].',';
  3090. }
  3091. $pr['pltobrf']=$tobrf;
  3092. //取得评论页面模板
  3093. $where=$pltempid?" where tempid='$pltempid'":'';
  3094. $ptsql=$empire->query("select tempid,temptext from ".GetTemptb("enewspltemp").$where);
  3095. while($ptr=$empire->fetch($ptsql))
  3096. {
  3097. $plfiletemp=$yplfiletemp;
  3098. $pl_filename=ECMS_PATH.'e/data/filecache/template/pl'.$ptr[tempid].'.php';
  3099. $pltemp=$ptr['temptext'];
  3100. //头部变量
  3101. $pltemp=ReplaceSvars($pltemp,$url,0,$pagetitle,$pagekey,$pagedes,$add,1);
  3102. $pltemp=RepSearchRtemp($pltemp,$url);
  3103. //变量
  3104. $pltemp=str_replace("[!--title--]","<?=\$title?>",$pltemp);
  3105. $pltemp=str_replace("[!--titleurl--]","<?=\$titleurl?>",$pltemp);
  3106. $pltemp=str_replace("[!--id--]","<?=\$id?>",$pltemp);
  3107. $pltemp=str_replace("[!--classid--]","<?=\$classid?>",$pltemp);
  3108. $pltemp=str_replace("[!--plnum--]","<?=\$num?>",$pltemp);
  3109. //评分
  3110. $pltemp=str_replace("[!--pinfopfen--]","<?=\$pinfopfen?>",$pltemp);
  3111. $pltemp=str_replace("[!--infopfennum--]","<?=\$infopfennum?>",$pltemp);
  3112. //登录
  3113. $pltemp=str_replace("[!--key.url--]",$public_r[newsurl]."e/ShowKey/?v=pl",$pltemp);
  3114. $pltemp=str_replace("[!--lusername--]","<?=\$lusername?>",$pltemp);
  3115. $pltemp=str_replace("[!--lpassword--]","<?=\$lpassword?>",$pltemp);
  3116. //列表变量
  3117. $listtemp_r=explode("[!--empirenews.listtemp--]",$pltemp);
  3118. $plfiletemp=str_replace("<!--empire.listtemp.top-->",$listtemp_r[0],$plfiletemp);
  3119. $plfiletemp=str_replace("<!--empire.listtemp.footer-->",$listtemp_r[2],$plfiletemp);
  3120. //列表中间
  3121. $listtemp_center=str_replace("[!--plid--]","<?=\$r[plid]?>",$listtemp_r[1]);
  3122. $listtemp_center=str_replace("[!--pltext--]","<?=\$saytext?>",$listtemp_center);
  3123. $listtemp_center=str_replace("[!--pltime--]","<?=\$r[saytime]?>",$listtemp_center);
  3124. $listtemp_center=str_replace("[!--plip--]","<?=\$sayip?>",$listtemp_center);
  3125. $listtemp_center=str_replace("[!--username--]","<?=\$plusername?>",$listtemp_center);
  3126. $listtemp_center=str_replace("[!--userid--]","<?=\$r[userid]?>",$listtemp_center);
  3127. $listtemp_center=str_replace("[!--includelink--]","<?=\$includelink?>",$listtemp_center);
  3128. $listtemp_center=str_replace("[!--zcnum--]","<?=\$r[zcnum]?>",$listtemp_center);
  3129. $listtemp_center=str_replace("[!--fdnum--]","<?=\$r[fdnum]?>",$listtemp_center);
  3130. $listtemp_center=ReplacePlListVars($listtemp_center,$r,$pr,0);
  3131. $plfiletemp=str_replace("<!--empire.listtemp.center-->",$listtemp_center,$plfiletemp);
  3132. WriteFiletext($pl_filename,$plfiletemp);
  3133. }
  3134. }
  3135. //替换评论字段
  3136. function ReplacePlListVars($temp,$r,$pr,$ecms=0){
  3137. $fr=explode(',',$pr['plf']);
  3138. $count=count($fr)-1;
  3139. for($i=1;$i<$count;$i++)
  3140. {
  3141. $f=$fr[$i];
  3142. if($ecms==1)
  3143. {
  3144. if(strstr($pr['pltobrf'],','.$f.','))
  3145. {
  3146. $temp=str_replace('[!--'.$f.'--]',"<?=addslashes(stripSlashes(str_replace(\"\\r\\n\",\"\",\$fr[".$f."])))?>",$temp);
  3147. }
  3148. else
  3149. {
  3150. $temp=str_replace('[!--'.$f.'--]',"<?=\$fr[".$f."]?>",$temp);
  3151. }
  3152. }
  3153. else
  3154. {
  3155. if(strstr($pr['pltobrf'],','.$f.','))
  3156. {
  3157. $temp=str_replace('[!--'.$f.'--]',"<?=stripSlashes(\$fr[".$f."])?>",$temp);
  3158. }
  3159. else
  3160. {
  3161. $temp=str_replace('[!--'.$f.'--]',"<?=\$fr[".$f."]?>",$temp);
  3162. }
  3163. }
  3164. }
  3165. return $temp;
  3166. }
  3167. //生成评论JS文件
  3168. function GetPlJsPage(){
  3169. global $empire,$public_r,$fun_r,$dbtbpre;
  3170. $pl_t_filename="../data/template/pljstemp.txt";
  3171. $pl_filename="../pl/more/index.php";
  3172. $pltemp=ReadFiletext($pl_t_filename);
  3173. $pr=$empire->fetch1("select plf from {$dbtbpre}enewspublic limit 1");
  3174. //回车字段
  3175. $tobrf=',';
  3176. $plfsql=$empire->query("select f from {$dbtbpre}enewsplf where ftype='VARCHAR' or ftype='TEXT' or ftype='MEDIUMTEXT' or ftype='LONGTEXT'");
  3177. while($plfr=$empire->fetch($plfsql))
  3178. {
  3179. $tobrf.=$plfr[f].',';
  3180. }
  3181. $pr['pltobrf']=$tobrf;
  3182. //取得评论JS模板
  3183. $pl_r=$empire->fetch1("select pljstemp from ".GetTemptb("enewspubtemp")." limit 1");
  3184. $pljstemp=str_replace("\r\n","",$pl_r['pljstemp']);
  3185. $pljstemp=addslashes(stripSlashes($pljstemp));
  3186. $pljstemp=str_replace("[!--id--]","<?=\$id?>",$pljstemp);
  3187. $pljstemp=str_replace("[!--classid--]","<?=\$classid?>",$pljstemp);
  3188. $pljstemp=str_replace("[!--news.url--]",$public_r[newsurl],$pljstemp);
  3189. $listtemp_r=explode("[!--empirenews.listtemp--]",$pljstemp);
  3190. $pltemp=str_replace("<!--empire.listtemp.top-->",$listtemp_r[0],$pltemp);
  3191. $pltemp=str_replace("<!--empire.listtemp.footer-->",$listtemp_r[2],$pltemp);
  3192. //列表中间
  3193. $listtemp_center=str_replace("[!--plid--]","<?=\$r[plid]?>",$listtemp_r[1]);
  3194. $listtemp_center=str_replace("[!--pltext--]","<?=\$saytext?>",$listtemp_center);
  3195. $listtemp_center=str_replace("[!--pltime--]","<?=\$r[saytime]?>",$listtemp_center);
  3196. $listtemp_center=str_replace("[!--plip--]","<?=\$sayip?>",$listtemp_center);
  3197. $listtemp_center=str_replace("[!--username--]","<?=\$plusername?>",$listtemp_center);
  3198. $listtemp_center=str_replace("[!--userid--]","<?=\$r[userid]?>",$listtemp_center);
  3199. $listtemp_center=str_replace("[!--zcnum--]","<?=\$r[zcnum]?>",$listtemp_center);
  3200. $listtemp_center=str_replace("[!--fdnum--]","<?=\$r[fdnum]?>",$listtemp_center);
  3201. $listtemp_center=ReplacePlListVars($listtemp_center,$r,$pr,1);
  3202. $pltemp=str_replace("<!--empire.listtemp.center-->",$listtemp_center,$pltemp);
  3203. WriteFiletext_n($pl_filename,$pltemp);
  3204. }
  3205. //生成留言板文件
  3206. function ReGbooktemp(){
  3207. global $empire,$public_r,$fun_r,$dbtbpre;
  3208. $tfile="../data/template/gbooktemp.txt";
  3209. $file="../tool/gbook/index.php";
  3210. $gbtemp=ReadFiletext($tfile);
  3211. //取得留言页面模板
  3212. $pr=$empire->fetch1("select gbooktemp from ".GetTemptb("enewspubtemp")." limit 1");
  3213. $url="<?=\$url?>";
  3214. $pagetitle="<?=\$bname?>";
  3215. $pr['gbooktemp']=ReplaceSvars($pr['gbooktemp'],$url,0,$pagetitle,$pagetitle,$pagetitle,$add,1);
  3216. $pr['gbooktemp']=RepSearchRtemp($pr['gbooktemp'],$url);
  3217. $pr['gbooktemp']=str_replace("[!--bname--]","<?=\$bname?>",$pr['gbooktemp']);
  3218. $pr['gbooktemp']=str_replace("[!--bid--]","<?=\$bid?>",$pr['gbooktemp']);
  3219. $listtemp_r=explode("[!--empirenews.listtemp--]",$pr['gbooktemp']);
  3220. $gbtemp=str_replace("<!--empire.listtemp.top-->",$listtemp_r[0],$gbtemp);
  3221. $gbtemp=str_replace("<!--empire.listtemp.footer-->",$listtemp_r[2],$gbtemp);
  3222. //---列表中间
  3223. //处理回复
  3224. $restart="
  3225. <?
  3226. if(\$r[retext])
  3227. {
  3228. ?>
  3229. ";
  3230. $endstart="
  3231. <?
  3232. }
  3233. ?>";
  3234. $listtemp_center=str_replace("[!--start.regbook--]",$restart,$listtemp_r[1]);
  3235. $listtemp_center=str_replace("[!--end.regbook--]",$endstart,$listtemp_center);
  3236. $listtemp_center=str_replace("[!--lyid--]","<?=\$r[lyid]?>",$listtemp_center);
  3237. $listtemp_center=str_replace("[!--name--]","<?=\$r[name]?>",$listtemp_center);
  3238. $listtemp_center=str_replace("[!--email--]","<?=\$r[email]?>",$listtemp_center);
  3239. $listtemp_center=str_replace("[!--call--]","<?=\$r[call]?>",$listtemp_center);
  3240. $listtemp_center=str_replace("[!--lytime--]","<?=\$r[lytime]?>",$listtemp_center);
  3241. $listtemp_center=str_replace("[!--lytext--]","<?=\$r[lytext]?>",$listtemp_center);
  3242. $listtemp_center=str_replace("[!--retext--]","<?=\$r[retext]?>",$listtemp_center);
  3243. $gbtemp=str_replace("<!--empire.listtemp.center-->",$listtemp_center,$gbtemp);
  3244. WriteFiletext($file,$gbtemp);
  3245. }
  3246. //更新控制面板模板
  3247. function ReCptemp(){
  3248. global $empire,$public_r,$dbtbpre,$fun_r;
  3249. $pr=$empire->fetch1("select cptemp from ".GetTemptb("enewspubtemp")." limit 1");
  3250. $url="<?=\$url?>";
  3251. $pagetitle="<?=defined('empirecms')?\$r[title]:'".$fun_r['membercp']."'?>";
  3252. $temptext=ReplaceSvars($pr['cptemp'],$url,0,$pagetitle,$pagetitle,$pagetitle,$add,1);
  3253. //生成头尾文件
  3254. $r=explode("[!--empirenews.template--]",$temptext);
  3255. $file1="../data/template/cp_1.php";
  3256. WriteFiletext($file1,AddCheckViewTempCode().$r[0]);
  3257. $file2="../data/template/cp_2.php";
  3258. WriteFiletext($file2,AddCheckViewTempCode().$r[1]);
  3259. }
  3260. //更新登陆状态模板
  3261. function ReLoginIframe(){
  3262. global $empire,$public_r,$dbtbpre;
  3263. $tfile="../data/template/loginiframetemp.txt";
  3264. $loginiframetemp=ReadFiletext($tfile);
  3265. $pr=$empire->fetch1("select loginiframe,loginjstemp from ".GetTemptb("enewspubtemp")." limit 1");
  3266. //框架登陆状态调用
  3267. $temptext=str_replace("[!--news.url--]",$public_r['newsurl'],$pr['loginiframe']);
  3268. $temptext=str_replace("[!--userid--]","<?=\$myuserid?>",$temptext);
  3269. $temptext=str_replace("[!--username--]","<?=\$myusername?>",$temptext);
  3270. $temptext=str_replace("[!--groupname--]","<?=\$groupname?>",$temptext);
  3271. $temptext=str_replace("[!--money--]","<?=\$money?>",$temptext);
  3272. $temptext=str_replace("[!--userdate--]","<?=\$userdate?>",$temptext);
  3273. $temptext=str_replace("[!--havemsg--]","<?=\$havemsg?>",$temptext);
  3274. $temptext=str_replace("[!--userfen--]","<?=\$userfen?>",$temptext);
  3275. $r=explode("[!--empirenews.template--]",$temptext);
  3276. $text=str_replace("<!--login-->",$r[0],$loginiframetemp);
  3277. $text=str_replace("<!--loginin-->",$r[1],$text);
  3278. $file="../member/iframe/index.php";
  3279. WriteFiletext($file,$text);
  3280. //JS登陆状态调用
  3281. $temptext=str_replace("[!--news.url--]",$public_r['newsurl'],$pr['loginjstemp']);
  3282. $temptext=str_replace("[!--userid--]","<?=\$myuserid?>",$temptext);
  3283. $temptext=str_replace("[!--username--]","<?=\$myusername?>",$temptext);
  3284. $temptext=str_replace("[!--groupname--]","<?=\$groupname?>",$temptext);
  3285. $temptext=str_replace("[!--money--]","<?=\$money?>",$temptext);
  3286. $temptext=str_replace("[!--userdate--]","<?=\$userdate?>",$temptext);
  3287. $temptext=str_replace("[!--havemsg--]","<?=\$havemsg?>",$temptext);
  3288. $temptext=str_replace("[!--userfen--]","<?=\$userfen?>",$temptext);
  3289. $r=explode("[!--empirenews.template--]",$temptext);
  3290. $login="document.write(\"".addslashes(stripSlashes(str_replace("\r\n","",$r[0])))."\");";
  3291. $loginin="document.write(\"".addslashes(stripSlashes(str_replace("\r\n","",$r[1])))."\");";
  3292. $text=str_replace("<!--login-->",$login,$loginiframetemp);
  3293. $text=str_replace("<!--loginin-->",$loginin,$text);
  3294. $file="../member/login/loginjs.php";
  3295. WriteFiletext_n($file,$text);
  3296. }
  3297. //返回投票模板
  3298. function ReturnVoteTemp($tempid,$enews=0){
  3299. global $empire;
  3300. $r=$empire->fetch1("select temptext from ".GetTemptb("enewsvotetemp")." where tempid='$tempid'");
  3301. if($enews)
  3302. {
  3303. $r[temptext]=str_replace("\r\n","",$r[temptext]);
  3304. }
  3305. return $r[temptext];
  3306. }
  3307. //替换投票模板总体变量
  3308. function RepVoteTempAllvar($temptext,$r){
  3309. global $public_r;
  3310. $action=$public_r['newsurl']."e/enews/index.php";
  3311. $temptext=str_replace("[!--vote.action--]",$action,$temptext);
  3312. $temptext=str_replace("[!--title--]",$r[title],$temptext);
  3313. $viewurl=$public_r[newsurl]."e/tool/vote/?voteid=".$r[voteid];
  3314. $temptext=str_replace("[!--vote.view--]",$viewurl,$temptext);
  3315. $temptext=str_replace("[!--width--]",$r[width],$temptext);
  3316. $temptext=str_replace("[!--height--]",$r[height],$temptext);
  3317. $temptext=str_replace("[!--voteid--]",$r[voteid],$temptext);
  3318. $temptext=str_replace("[!--id--]",$r[id],$temptext);
  3319. $temptext=str_replace("[!--classid--]",$r[classid],$temptext);
  3320. $temptext=str_replace("[!--news.url--]",$public_r[newsurl],$temptext);
  3321. return $temptext;
  3322. }
  3323. //替换投票模板列表
  3324. function RepVoteTempListvar($temptext,$votebox,$votename){
  3325. $temptext=str_replace("[!--vote.box--]",$votebox,$temptext);
  3326. $temptext=str_replace("[!--vote.name--]",$votename,$temptext);
  3327. return $temptext;
  3328. }
  3329. //生成打印页面
  3330. function GetPrintPage($printtempid=0){
  3331. global $empire,$dbtbpre,$fun_r,$public_r;
  3332. $file=ECMS_PATH.'e/data/template/printtemp.txt';
  3333. $string=ReadFiletext($file);
  3334. $url="<?=\$url?>";
  3335. $pagetitle="<?=htmlspecialchars(\$r[title])?> ".$fun_r['PrintPage'];
  3336. //取得评论页面模板
  3337. $where=$printtempid?" where tempid='$printtempid'":'';
  3338. $ptsql=$empire->query("select tempid,temptext,showdate,modid from ".GetTemptb("enewsprinttemp").$where);
  3339. while($ptr=$empire->fetch($ptsql))
  3340. {
  3341. $ptr[temptext]=ReplaceSvars($ptr[temptext],$url,0,$pagetitle,$pagetitle,$pagetitle,$add,1);
  3342. $printtemp=RepPrintTempV($ptr);
  3343. $printtemp=str_replace("<!--empire.print-->",$printtemp,$string);
  3344. $truefile=ECMS_PATH.'e/data/filecache/template/print'.$ptr[tempid].'.php';
  3345. WriteFiletext($truefile,$printtemp);
  3346. }
  3347. }
  3348. //替换打印模板变量
  3349. function RepPrintTempV($tr){
  3350. global $empire,$dbtbpre,$fun_r,$public_r,$emod_r;
  3351. $temptext=$tr['temptext'];
  3352. $mid=$tr['modid'];
  3353. //字段
  3354. $tempf=$emod_r[$mid]['tempf'];
  3355. $fr=explode(',',$tempf);
  3356. $fcount=count($fr)-1;
  3357. for($i=1;$i<$fcount;$i++)
  3358. {
  3359. $f=$fr[$i];
  3360. $value="stripSlashes(\$r[".$f."])";
  3361. if($f=='newstime')//时间
  3362. {
  3363. $value="date('".$tr[showdate]."',\$r[".$f."])";
  3364. }
  3365. elseif($f=='title')//标题
  3366. {
  3367. }
  3368. else//正常字段
  3369. {
  3370. if(!strstr($emod_r[$mid]['editorf'],','.$f.','))
  3371. {
  3372. if(strstr($emod_r[$mid]['tobrf'],','.$f.','))//加br
  3373. {
  3374. $value='nl2br('.$value.')';
  3375. }
  3376. if(!strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//去除html
  3377. {
  3378. $value='RepFieldtextNbsp(htmlspecialchars('.$value.'))';
  3379. }
  3380. }
  3381. }
  3382. $temptext=str_replace('[!--'.$f.'--]','<?='.$value.'?>',$temptext);
  3383. }
  3384. $temptext=str_replace("[!--id--]","<?=\$r[id]?>",$temptext);
  3385. $temptext=str_replace("[!--classid--]","<?=\$r[classid]?>",$temptext);
  3386. $temptext=str_replace("[!--keyboard--]","<?=\$r[keyboard]?>",$temptext);
  3387. $temptext=str_replace("[!--class.name--]","<?=\$class_r[\$classid][classname]?>",$temptext);
  3388. $temptext=str_replace("[!--bclass.id--]","<?=\$bclassid?>",$temptext);
  3389. $temptext=str_replace("[!--bclass.name--]","<?=\$class_r[\$bclassid][classname]?>",$temptext);
  3390. $temptext=str_replace('[!--ttid--]',"<?=\$r[ttid]?>",$temptext);
  3391. $temptext=str_replace('[!--tt.name--]',"<?=\$class_r[\$r[ttid]][tname]?>",$temptext);
  3392. $temptext=str_replace("[!--userfen--]","<?=\$r[userfen]?>",$temptext);
  3393. $temptext=str_replace("[!--onclick--]","<?=\$r[onclick]?>",$temptext);
  3394. $temptext=str_replace("[!--totaldown--]","<?=\$r[totaldown]?>",$temptext);
  3395. $temptext=str_replace("[!--plnum--]","<?=\$r[plnum]?>",$temptext);
  3396. $temptext=str_replace("[!--userid--]","<?=\$r[userid]?>",$temptext);
  3397. $temptext=str_replace("[!--username--]","<?=\$r[username]?>",$temptext);
  3398. $temptext=str_replace("[!--titlelink--]","<?=\$titleurl?>",$temptext);
  3399. $temptext=str_replace("[!--titleurl--]","<?=\$titleurl?>",$temptext);
  3400. $temptext=str_replace("[!--url--]","<?=\$url?>",$temptext);
  3401. return $temptext;
  3402. }
  3403. //更新下载页面模板
  3404. function GetDownloadPage(){
  3405. global $empire,$public_r,$dbtbpre,$fun_r;
  3406. $pr=$empire->fetch1("select downpagetemp from ".GetTemptb("enewspubtemp")." limit 1");
  3407. $temptext=$pr['downpagetemp'];
  3408. $url="<a href='".$public_r[newsurl]."'>".$fun_r['index']."</a>&nbsp;>&nbsp;<a href='<?=\$titleurl?>'><?=\$r[title]?></a>&nbsp;>&nbsp;<?=\$thisdownname?>";
  3409. $pagetitle="<?=htmlspecialchars(\$r[title])?> - <?=htmlspecialchars(\$thisdownname)?>";
  3410. $temptext=ReplaceSvars($temptext,$url,"<?=\$r[classid]?>",$pagetitle,$pagetitle,$pagetitle,$add,1);
  3411. //分类
  3412. $temptext=str_replace("[!--classid--]","<?=\$r[classid]?>",$temptext);
  3413. $temptext=str_replace("[!--class.name--]","<?=\$classname?>",$temptext);
  3414. $temptext=str_replace("[!--bclass.id--]","<?=\$bclassid?>",$temptext);
  3415. $temptext=str_replace("[!--bclass.name--]","<?=\$bclassname?>",$temptext);
  3416. //下载地址
  3417. $temptext=str_replace("[!--down.url--]","<?=\$url?>",$temptext);
  3418. $temptext=str_replace("[!--true.down.url--]","<?=\$trueurl?>",$temptext);
  3419. $temptext=str_replace("[!--down.name--]","<?=\$thisdownname?>",$temptext);
  3420. //下载权限
  3421. $temptext=str_replace("[!--fen--]","<?=\$fen?>",$temptext);
  3422. $temptext=str_replace("[!--group--]","<?=\$downuser?>",$temptext);
  3423. //信息
  3424. $temptext=str_replace("[!--id--]","<?=\$r[id]?>",$temptext);
  3425. $temptext=str_replace("[!--titleurl--]","<?=\$titleurl?>",$temptext);
  3426. $temptext=str_replace("[!--title--]","<?=\$r[title]?>",$temptext);
  3427. $temptext=str_replace("[!--newstime--]","<?=\$newstime?>",$temptext);
  3428. $temptext=str_replace("[!--titlepic--]","<?=\$titlepic?>",$temptext);
  3429. $temptext=str_replace("[!--keyboard--]","<?=\$r[keyboard]?>",$temptext);
  3430. $temptext=str_replace("[!--userid--]","<?=\$r[userid]?>",$temptext);
  3431. $temptext=str_replace("[!--username--]","<?=\$r[username]?>",$temptext);
  3432. $temptext=str_replace("[!--pathid--]","<?=\$pathid?>",$temptext);
  3433. $temptext=str_replace("[!--totaldown--]","<?=\$r[totaldown]?>",$temptext);
  3434. $temptext=str_replace("[!--onclick--]","<?=\$r[onclick]?>",$temptext);
  3435. $file="../data/template/downpagetemp.php";
  3436. WriteFiletext($file,AddCheckViewTempCode().$temptext);
  3437. }
  3438. //生成全站搜索文件
  3439. function ReSchAlltemp(){
  3440. global $empire,$public_r,$fun_r,$dbtbpre;
  3441. $tfile="../data/template/schalltemp.txt";
  3442. $file="../sch/index.php";
  3443. $temp=ReadFiletext($tfile);
  3444. //取得页面模板
  3445. $pr=$empire->fetch1("select schalltemp,schallsubnum,schalldate from ".GetTemptb("enewspubtemp")." limit 1");
  3446. $url="<?=\$url?>";
  3447. $pagetitle=$fun_r['SearchAllNav'];
  3448. $pr['schalltemp']=ReplaceSvars($pr['schalltemp'],$url,0,$pagetitle,$pagetitle,$pagetitle,$add,1);
  3449. $temp=str_replace("<!--empire.listtemp.subnum-->",$pr['schallsubnum'],$temp);
  3450. $temp=str_replace("<!--empire.listtemp.formatdate-->",$pr['schalldate'],$temp);
  3451. $pr['schalltemp']=str_replace("[!--keyboard--]","<?=\$keyboard?>",$pr['schalltemp']);
  3452. $pr['schalltemp']=str_replace("[!--num--]","<?=\$num?>",$pr['schalltemp']);
  3453. $pr['schalltemp']=str_replace("[!--listpage--]","<?=\$listpage?>",$pr['schalltemp']);
  3454. $listtemp_r=explode("[!--empirenews.listtemp--]",$pr['schalltemp']);
  3455. $temp=str_replace("<!--empire.listtemp.top-->",$listtemp_r[0],$temp);
  3456. $temp=str_replace("<!--empire.listtemp.footer-->",$listtemp_r[2],$temp);
  3457. //---列表中间
  3458. $listtemp_center=str_replace("[!--no.num--]","<?=\$no?>",$listtemp_r[1]);
  3459. $listtemp_center=str_replace("[!--titleurl--]","<?=\$titleurl?>",$listtemp_center);
  3460. $listtemp_center=str_replace("[!--id--]","<?=\$r[id]?>",$listtemp_center);
  3461. $listtemp_center=str_replace("[!--classid--]","<?=\$r[classid]?>",$listtemp_center);
  3462. $listtemp_center=str_replace("[!--titlepic--]","<?=\$titlepic?>",$listtemp_center);
  3463. $listtemp_center=str_replace("[!--newstime--]","<?=\$newstime?>",$listtemp_center);
  3464. $listtemp_center=str_replace("[!--title--]","<?=\$title?>",$listtemp_center);
  3465. $listtemp_center=str_replace("[!--smalltext--]","<?=\$smalltext?>",$listtemp_center);
  3466. $temp=str_replace("<!--empire.listtemp.center-->",$listtemp_center,$temp);
  3467. WriteFiletext($file,$temp);
  3468. }
  3469. //-------------- 用户区 ----------------------
  3470. //返回操作权限
  3471. function ReturnLeftLevel($groupid){
  3472. global $empire,$dbtbpre;
  3473. if(empty($groupid))
  3474. {return "";}
  3475. $groupid=(int)$groupid;
  3476. $r=$empire->fetch1("select * from {$dbtbpre}enewsgroup where groupid='$groupid'");
  3477. return $r;
  3478. }
  3479. //返回操作权限
  3480. function CheckLevel($userid,$username,$classid,$enews){
  3481. global $empire,$dbtbpre;
  3482. $userid=(int)$userid;
  3483. $r=$empire->fetch1("select groupid,adminclass from {$dbtbpre}enewsuser where userid='$userid' limit 1");
  3484. //操作信息
  3485. if($enews=="news")
  3486. {
  3487. //操作所有栏目权限
  3488. $gr=$empire->fetch1("select doall,doselfinfo,doaddinfo,doeditinfo,dodelinfo from {$dbtbpre}enewsgroup where groupid='$r[groupid]'");
  3489. if(empty($gr[doall]))
  3490. {
  3491. $e_r=explode("|".$classid."|",$r[adminclass]);
  3492. if(count($e_r)!=2)
  3493. {printerror("NotNewsLevel","history.go(-1)");}
  3494. }
  3495. return $gr;
  3496. }
  3497. else
  3498. {
  3499. //用户组
  3500. $gr=$empire->fetch1("select * from {$dbtbpre}enewsgroup where groupid='$r[groupid]'");
  3501. $enews="do".$enews;
  3502. if(empty($gr[$enews]))
  3503. {
  3504. printerror("NotLevel","history.go(-1)");
  3505. }
  3506. }
  3507. }
  3508. //验证设置权限
  3509. function CheckDoLevel($lur,$groupid,$userclass,$username,$ecms=0){
  3510. $ret=0;
  3511. if(strstr($groupid,','.$lur[groupid].','))
  3512. {
  3513. $ret=1;
  3514. }
  3515. elseif(strstr($userclass,','.$lur[classid].','))
  3516. {
  3517. $ret=1;
  3518. }
  3519. elseif(stristr($username,','.$lur[username].','))
  3520. {
  3521. $ret=1;
  3522. }
  3523. if($ecms==0&&$ret==0)
  3524. {
  3525. printerror('NotLevel','history.go(-1)');
  3526. }
  3527. return $ret;
  3528. }
  3529. //是否登陆
  3530. function is_login($uid=0,$uname='',$urnd=''){
  3531. global $empire,$public_r,$dbtbpre;
  3532. $userid=$uid?$uid:getcvar('loginuserid',1);
  3533. $username=$uname?$uname:getcvar('loginusername',1);
  3534. $rnd=$urnd?$urnd:getcvar('loginrnd',1);
  3535. $userid=(int)$userid;
  3536. $username=RepPostVar($username);
  3537. $rnd=RepPostVar($rnd);
  3538. if(!$userid||!$username||!$rnd)
  3539. {
  3540. printerror("NotLogin","index.php");
  3541. }
  3542. $groupid=(int)getcvar('loginlevel',1);
  3543. $adminstyle=(int)getcvar('loginadminstyleid',1);
  3544. if(!strstr($public_r['adminstyle'],','.$adminstyle.','))
  3545. {
  3546. $adminstyle=$public_r['defadminstyle']?$public_r['defadminstyle']:1;
  3547. }
  3548. $truelogintime=(int)getcvar('truelogintime',1);
  3549. //COOKIE验证
  3550. if(getcvar('loginusername',1))
  3551. {
  3552. $cdbdata=getcvar('ecmsdodbdata',1)?1:0;
  3553. DoChECookieRnd($userid,$username,$rnd,$cdbdata,$groupid,$adminstyle,$truelogintime);
  3554. }
  3555. //db
  3556. $adminr=$empire->fetch1("select userid,groupid,classid from {$dbtbpre}enewsuser where userid='$userid' and username='".$username."' and rnd='".$rnd."' and checked=0 limit 1");
  3557. if(!$adminr['userid'])
  3558. {
  3559. printerror("SingleUser","index.php");
  3560. }
  3561. //登陆超时
  3562. $logintime=getcvar('logintime',1);
  3563. if($logintime)
  3564. {
  3565. if(time()-$logintime>$public_r['exittime']*60)
  3566. {
  3567. printerror("LoginTime","index.php");
  3568. }
  3569. esetcookie("logintime",time(),0,1);
  3570. }
  3571. if(getcvar('eloginlic',1)<>"empirecmslic")
  3572. {
  3573. printerror("NotLogin","index.php");
  3574. }
  3575. $ur[userid]=$userid;
  3576. $ur[username]=$username;
  3577. $ur[rnd]=$rnd;
  3578. $ur[groupid]=$adminr[groupid];
  3579. $ur[adminstyleid]=(int)$adminstyle;
  3580. $ur[classid]=$adminr[classid];
  3581. return $ur;
  3582. }
  3583. function is_login_ebak($userid,$username,$rnd){
  3584. global $empire,$public_r;
  3585. $userid=(int)$userid;
  3586. $username=RepPostVar($username);
  3587. $dodbdata=getcvar('ecmsdodbdata',1);
  3588. if(!$userid||!$username)
  3589. {
  3590. printerror("NotLogin","index.php");
  3591. }
  3592. if($dodbdata!="empirecms")
  3593. {
  3594. printerror("NotLogin","index.php");
  3595. }
  3596. $rnd=RepPostVar($rnd);
  3597. //COOKIE验证
  3598. $cdbdata=$dodbdata?1:0;
  3599. $groupid=(int)getcvar('loginlevel',1);
  3600. $adminstyle=(int)getcvar('loginadminstyleid',1);
  3601. $truelogintime=(int)getcvar('truelogintime',1);
  3602. DoChECookieRnd($userid,$username,$rnd,$cdbdata,$groupid,$adminstyle,$truelogintime);
  3603. //超时
  3604. $logintime=getcvar('logintime',1);
  3605. if($logintime)
  3606. {
  3607. if(time()-$logintime>$public_r['exittime']*60)
  3608. {
  3609. printerror("LoginTime","index.php");
  3610. }
  3611. esetcookie("logintime",time(),0,1);
  3612. }
  3613. $ur[userid]=$userid;
  3614. $ur[username]=$username;
  3615. $ur[rnd]=$rnd;
  3616. $ur[groupid]=$groupid;
  3617. $ur[adminstyleid]=$adminstyle;
  3618. $ur[classid]=0;
  3619. return $ur;
  3620. }
  3621. //COOKIE加密
  3622. function DoECookieRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime){
  3623. global $do_ecookiernd,$do_ckhloginip,$do_ckhloginfile;
  3624. $ip=$do_ckhloginip==0?'127.0.0.1':egetip();
  3625. $ecmsckpass=md5(md5($rnd.$do_ecookiernd).'-'.$ip.'-'.$userid.'-'.$username.'-'.$dbdata.$rnd.$groupid.'-'.$adminstyle);
  3626. esetcookie("loginecmsckpass",$ecmsckpass,0,1);
  3627. if(empty($do_ckhloginfile))
  3628. {
  3629. DoECreatFileRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime,$ip);
  3630. }
  3631. }
  3632. function DoChECookieRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime){
  3633. global $do_ecookiernd,$do_ckhloginip,$do_ckhloginfile;
  3634. $ip=$do_ckhloginip==0?'127.0.0.1':egetip();
  3635. $ecmsckpass=md5(md5($rnd.$do_ecookiernd).'-'.$ip.'-'.$userid.'-'.$username.'-'.$dbdata.$rnd.$groupid.'-'.$adminstyle);
  3636. if($ecmsckpass<>getcvar('loginecmsckpass',1))
  3637. {
  3638. printerror("NotLogin","index.php");
  3639. }
  3640. if(empty($do_ckhloginfile))
  3641. {
  3642. DoECheckFileRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime,$ip);
  3643. }
  3644. }
  3645. //文件认证
  3646. function DoECreatFileRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime,$ip){
  3647. global $do_ecookiernd,$do_ckhloginip;
  3648. $file=ECMS_PATH.'e/data/adminlogin/user'.$userid.'_'.md5(md5($username.'-empirecms!check.file'.$truelogintime.'-'.$rnd.$do_ecookiernd).'-'.$ip.'-'.$userid.'-'.$rnd.$adminstyle.'-'.$groupid.'-'.$dbdata).'.log';
  3649. WriteFiletext_n($file,'EmpireCMS');
  3650. }
  3651. function DoECheckFileRnd($userid,$username,$rnd,$dbdata,$groupid,$adminstyle,$truelogintime,$ip){
  3652. global $do_ecookiernd,$do_ckhloginip;
  3653. $file=ECMS_PATH.'e/data/adminlogin/user'.$userid.'_'.md5(md5($username.'-empirecms!check.file'.$truelogintime.'-'.$rnd.$do_ecookiernd).'-'.$ip.'-'.$userid.'-'.$rnd.$adminstyle.'-'.$groupid.'-'.$dbdata).'.log';
  3654. if(!file_exists($file))
  3655. {
  3656. printerror('NotLogin','index.php');
  3657. }
  3658. /*
  3659. $filetime=filemtime($file);
  3660. if($filetime>$truelogintime)
  3661. {
  3662. printerror('NotLogin','index.php');
  3663. }
  3664. */
  3665. }
  3666. function DoEDelFileRnd($userid){
  3667. $path=ECMS_PATH.'e/data/adminlogin/';
  3668. $hand=@opendir($path);
  3669. while($file=@readdir($hand))
  3670. {
  3671. if($file=='.'||$file=='..')
  3672. {
  3673. continue;
  3674. }
  3675. if(strstr($file,'user'.$userid.'_'))
  3676. {
  3677. DelFiletext($path.$file);
  3678. }
  3679. }
  3680. }
  3681. //写入操作日志
  3682. function insert_dolog($doing){
  3683. global $empire,$enews,$phome,$logininid,$loginin,$do_thedolog,$dbtbpre;
  3684. if($do_thedolog)
  3685. {
  3686. return "";
  3687. }
  3688. if(empty($doing))
  3689. {$doing="---";}
  3690. $doing=addslashes(stripSlashes($doing));
  3691. //ip
  3692. $logip=egetip();
  3693. $logtime=date("Y-m-d H:i:s");
  3694. if(empty($enews))
  3695. {$enews=$phome;}
  3696. $enews=RepPostVar($enews);
  3697. $sql=$empire->query("insert into {$dbtbpre}enewsdolog(username,logip,logtime,enews,doing) values('$loginin','$logip','$logtime','$enews','$doing');");
  3698. }
  3699. //返回安全提问问题
  3700. function ReturnHLoginQuestionStr($userid,$username,$question,$answer){
  3701. $pass=md5(md5('-#20empire27#-'.$question.'-empirecms-'.$userid.'-www.phome.net-'.$answer.'-wm-').'-dg2002-'.$answer.'-wm_chief-'.$userid.'-wangmeng-');
  3702. return $pass;
  3703. }
  3704. //-------------- 远程发布区 ----------------------
  3705. //返回FTP目录或文件绝对地址
  3706. function FtpRTruePath($ftppath,$path){
  3707. $truepath=$ftppath.'/'.$path;
  3708. return $truepath;
  3709. }
  3710. //目录转向
  3711. function FtpChPath($e,$r){
  3712. $path=$r[ftppath].'/e/ftp';
  3713. $e->fChdir($path);
  3714. return '';
  3715. }
  3716. //上传ftp目录
  3717. function FtpTranPath($ftpid,$ldir,$hdir){
  3718. $r=ReturnFtpInfo($ftpid);
  3719. $e=new EmpireCMSFTP();
  3720. $e->fconnect($r[ftphost],$r[ftpport],$r[ftpusername],$r[ftppassword],$r[ftppath],$r[ftpssl],$r[ftppasv],$r[ftpmode],$r[ftpouttime]);
  3721. FtpChPath($e,$r);
  3722. //上传目录
  3723. $e->ftp_copy($ldir,$hdir);
  3724. $e->fExit();
  3725. }
  3726. //删除ftp目录
  3727. function FtpDelPath($ftpid,$dir){
  3728. $r=ReturnFtpInfo($ftpid);
  3729. $e=new EmpireCMSFTP();
  3730. $e->fconnect($r[ftphost],$r[ftpport],$r[ftpusername],$r[ftppassword],$r[ftppath],$r[ftpssl],$r[ftppasv],$r[ftpmode],$r[ftpouttime]);
  3731. FtpChPath($e,$r);
  3732. //删除目录
  3733. $e->ftp_rmAll($dir);
  3734. $e->fExit();
  3735. }
  3736. //删除ftp文件
  3737. function FtpDelFile($ftpid,$fr){
  3738. $r=ReturnFtpInfo($ftpid);
  3739. $e=new EmpireCMSFTP();
  3740. $e->fconnect($r[ftphost],$r[ftpport],$r[ftpusername],$r[ftppassword],$r[ftppath],$r[ftpssl],$r[ftppasv],$r[ftpmode],$r[ftpouttime]);
  3741. FtpChPath($e,$r);
  3742. //删除文件
  3743. $e->fMoreDelFile($fr);
  3744. $e->fExit();
  3745. }
  3746. //上传文件
  3747. function FtpTranFile($ftpid,$fr,$fr1){
  3748. $r=ReturnFtpInfo($ftpid);
  3749. $e=new EmpireCMSFTP();
  3750. $e->fconnect($r[ftphost],$r[ftpport],$r[ftpusername],$r[ftppassword],$r[ftppath],$r[ftpssl],$r[ftppasv],$r[ftpmode],$r[ftpouttime]);
  3751. FtpChPath($e,$r);
  3752. //上传文件
  3753. $e->fMoreTranFile($fr1,$fr);
  3754. $e->fExit();
  3755. }
  3756. //建立ftp目录
  3757. function FtpMkdir($ftpid,$pr,$mod){
  3758. $r=ReturnFtpInfo($ftpid);
  3759. $e=new EmpireCMSFTP();
  3760. $e->fconnect($r[ftphost],$r[ftpport],$r[ftpusername],$r[ftppassword],$r[ftppath],$r[ftpssl],$r[ftppasv],$r[ftpmode],$r[ftpouttime]);
  3761. FtpChPath($e,$r);
  3762. for($i=0;$i<count($pr);$i++)
  3763. {
  3764. if(stristr($pr[$i],ECMS_PATH))
  3765. {
  3766. $pr[$i]=FtpRTruePath($r[ftppath],str_replace(ECMS_PATH,'',$pr[$i]));
  3767. }
  3768. if(!$e->fChdir($pr[$i]))
  3769. {
  3770. $e->fMkdir($pr[$i]);
  3771. if($mod)
  3772. {
  3773. $e->fChmoddir($mod,$pr[$i]);
  3774. }
  3775. }
  3776. }
  3777. $e->fExit();
  3778. }
  3779. //返回ftp信息
  3780. function ReturnFtpInfo($ftpid){
  3781. global $empire,$dbtbpre;
  3782. $r=$empire->fetch1("select * from {$dbtbpre}enewspublic limit 1");
  3783. return $r;
  3784. }
  3785. //初使化发布任务
  3786. function AddPostUrlData($postdata,$userid,$username){
  3787. global $empire,$fun_r,$dbtbpre;
  3788. $count=count($postdata);
  3789. if(empty($count))
  3790. {printerror("NotPostData","history.go(-1)");}
  3791. //操作权限
  3792. CheckLevel($userid,$username,$classid,"postdata");
  3793. $e="!!!";
  3794. $rnd=md5(uniqid(microtime()));
  3795. for($i=0;$i<$count;$i++)
  3796. {
  3797. $r=explode($e,$postdata[$i]);
  3798. $r[1]=(int)$r[1];
  3799. $sql=$empire->query("insert into {$dbtbpre}enewspostdata(rnd,postdata,ispath) values('$rnd','$r[0]',$r[1]);");
  3800. }
  3801. $line=(int)$_POST['line'];
  3802. if($line==0)
  3803. {
  3804. $line=10;
  3805. }
  3806. echo $fun_r[AddPostDataSuccess]."<script>self.location.href='enews.php?enews=PostUrlData&start=0&line=$line&rnd=$rnd';</script>";
  3807. exit();
  3808. }
  3809. //远程发布
  3810. function PostUrlData($start,$rnd,$userid,$username){
  3811. global $empire,$fun_r,$dbtbpre,$incftp;
  3812. $rnd=RepPostVar($rnd);
  3813. if(empty($rnd))
  3814. {printerror("FailCX","history.go(-1)");}
  3815. //操作权限
  3816. CheckLevel($userid,$username,$classid,"postdata");
  3817. //链接FTP
  3818. if(empty($incftp))
  3819. {
  3820. @include(ECMS_PATH."e/class/ftp.php");
  3821. }
  3822. $pr=ReturnFtpInfo($ftpid);
  3823. $e=new EmpireCMSFTP();
  3824. $e->fconnect($pr[ftphost],$pr[ftpport],$pr[ftpusername],$pr[ftppassword],$pr[ftppath],$pr[ftpssl],$pr[ftppasv],$pr[ftpmode],$pr[ftpouttime]);
  3825. FtpChPath($e,$pr);
  3826. $line=(int)$_GET['line'];//每10个为一组
  3827. $start=(int)$start;
  3828. $b=0;
  3829. $sql=$empire->query("select postid,postdata,ispath from {$dbtbpre}enewspostdata where rnd='$rnd' and postid>$start order by postid limit ".$line);
  3830. while($r=$empire->fetch($sql))
  3831. {
  3832. $b=1;
  3833. $newstart=$r[postid];
  3834. //文件
  3835. if($r[ispath])
  3836. {
  3837. $fr=explode(",",$r[postdata]);
  3838. for($i=0;$i<count($fr);$i++)
  3839. {
  3840. $e->fTranFile(FtpRTruePath($pr[ftppath],$fr[$i]),ECMS_PATH.$fr[$i]);
  3841. }
  3842. }
  3843. //目录
  3844. else
  3845. {
  3846. $e->ftp_copy(ECMS_PATH.$r[postdata],FtpRTruePath($pr[ftppath],$r[postdata]));
  3847. }
  3848. }
  3849. $e->fExit();
  3850. if(empty($b))
  3851. {
  3852. $sql=$empire->query("delete from {$dbtbpre}enewspostdata where rnd='$rnd'");
  3853. //操作日志
  3854. insert_dolog("");
  3855. printerror("PostDataSuccess","PostUrlData.php");
  3856. }
  3857. echo $fun_r[OnePostDataSuccess]."<script>self.location.href='enews.php?enews=PostUrlData&start=$newstart&line=$line&rnd=$rnd';</script>";
  3858. exit();
  3859. }
  3860. //测试FTP
  3861. function CheckFtpConnect($ftphost,$ftpport,$ftpusername,$ftppassword,$ftppath,$ftpssl=0,$pasv=0,$tranmode=0,$timeout=0){
  3862. if(!defined('InEmpireCMSFtp'))
  3863. {
  3864. include(ECMS_PATH.'e/class/ftp.php');
  3865. }
  3866. $eftp=new EmpireCMSFTP();
  3867. $result=$eftp->fconnect($ftphost,$ftpport,$ftpusername,$ftppassword,$ftppath,$ftpssl,$pasv,$tranmode,$timeout,1);
  3868. if($result=='HostFail')
  3869. {
  3870. printerror('FtpHostFail','',8);
  3871. }
  3872. elseif($result=='UserFail')
  3873. {
  3874. printerror('FtpUserFail','',8);
  3875. }
  3876. elseif($result=='PathFail')
  3877. {
  3878. printerror('FtpPathFail','',8);
  3879. }
  3880. else
  3881. {
  3882. printerror('FtpConnectSuccess','',8);
  3883. }
  3884. $eftp->fExit();
  3885. }
  3886. //-------------- 模型区 ----------------------
  3887. //复制表
  3888. function CopyEcmsTb($otb,$tb){
  3889. global $empire;
  3890. $usql=$empire->query("SET SQL_QUOTE_SHOW_CREATE=1;");//设置引号
  3891. $r=$empire->fetch1("SHOW CREATE TABLE `$otb`;");//数据表结构
  3892. $create=str_replace("\"","\\\"",$r[1]);
  3893. $create=str_replace($otb,$tb,$create);
  3894. $empire->query($create);
  3895. }
  3896. //建立数据表
  3897. function SetCreateTable($sql,$dbcharset) {
  3898. global $phome_use_dbver;
  3899. $type=strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
  3900. $type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
  3901. return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
  3902. ($phome_use_dbver>='4.1'&&$dbcharset ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
  3903. }
  3904. //组合存文本
  3905. function TogSaveTxtF($ecms=0){
  3906. global $empire,$dbtbpre;
  3907. $savesql=$empire->query("select f,tbname from {$dbtbpre}enewsf where savetxt=1");
  3908. $savef=',';
  3909. while($saver=$empire->fetch($savesql))
  3910. {
  3911. $savef.=$saver[tbname].'.'.$saver[f].',';
  3912. }
  3913. $empire->query("update {$dbtbpre}enewspublic set savetxtf='$savef' limit 1");
  3914. if($ecms==0)
  3915. {
  3916. GetConfig();
  3917. }
  3918. }
  3919. //返回附件字段
  3920. function ReturnMFileF($enter,$tbname,$tid,$fform="file"){
  3921. global $empire;
  3922. $record="<!--record-->";
  3923. $field="<!--field--->";
  3924. if($tid)
  3925. {
  3926. $a=" and tid='$tid'";
  3927. }
  3928. $f=",";
  3929. $sql=$empire->query("select f from ".$tbname." where fform='$fform'".$a);
  3930. while($r=$empire->fetch($sql))
  3931. {
  3932. if(strstr($enter,$field.$r[f].$record))
  3933. {
  3934. $f.=$r[f].",";
  3935. }
  3936. }
  3937. return $f;
  3938. }
  3939. //执行字段函数
  3940. function DoFFun($mid,$f,$value,$isadd=1,$isq=0){
  3941. global $empire,$dbtbpre,$emod_r;
  3942. if($isq==1)//前台
  3943. {
  3944. $dofun=$isadd==1?$emod_r[$mid]['qadddofunf']:$emod_r[$mid]['qeditdofunf'];
  3945. }
  3946. else//后台
  3947. {
  3948. $dofun=$isadd==1?$emod_r[$mid]['adddofunf']:$emod_r[$mid]['editdofunf'];
  3949. }
  3950. if(!strstr($dofun,'||'.$f.'!#!'))
  3951. {
  3952. return $value;
  3953. }
  3954. $dfr=explode('||'.$f.'!#!',$dofun);
  3955. $dfr1=explode('||',$dfr[1]);
  3956. $r=explode('##',$dfr1[0]);
  3957. if($r[0])
  3958. {
  3959. $fun=$r[0];
  3960. $value=$fun($mid,$f,$isadd,$isq,$value,$r[1]);
  3961. }
  3962. return $value;
  3963. }
  3964. //取得字段名
  3965. function ChGetFname($mid,$f){
  3966. global $empire,$dbtbpre,$emod_r;
  3967. $r=$empire->fetch1("select fname from {$dbtbpre}enewsf where f='$f' and tid='".$emod_r[$mid]['tid']."' limit 1");
  3968. return $r[fname]?$r[fname]:$f;
  3969. }
  3970. //验证必填项
  3971. function ChMustAddF($mid,$f,$value){
  3972. global $empire,$dbtbpre,$emod_r;
  3973. if(strstr($emod_r[$mid]['mustqenterf'],','.$f.','))
  3974. {
  3975. if(!trim($value))
  3976. {
  3977. $GLOBALS['msgmustf']=ChGetFname($mid,$f);
  3978. printerror("EmptyMustF","history.go(-1)");
  3979. }
  3980. }
  3981. }
  3982. //验证唯一项
  3983. function ChIsOnlyAddF($mid,$id,$f,$value,$isq=0){
  3984. global $empire,$dbtbpre,$emod_r;
  3985. if(strstr($emod_r[$mid]['onlyf'],','.$f.','))
  3986. {
  3987. if($id)
  3988. {
  3989. $and=" and id<>$id";
  3990. }
  3991. $value=RepPostStr($value);
  3992. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$emod_r[$mid]['tbname']." where ".$f."='".addslashes($value)."'".$and." limit 1");
  3993. if($num)
  3994. {
  3995. $GLOBALS['msgisonlyf']=ChGetFname($mid,$f);
  3996. if($isq==1)
  3997. {
  3998. printerror("ReIsOnlyF","history.go(-1)",1);
  3999. }
  4000. else
  4001. {
  4002. printerror("ReIsOnlyF","history.go(-1)");
  4003. }
  4004. }
  4005. }
  4006. }
  4007. //数据同步
  4008. function SameDataAddF($id,$classid,$mid,$f,$value){
  4009. global $empire,$public_r,$dbtbpre,$emod_r,$emod_pubr;
  4010. if(strstr($emod_pubr['linkfields'],','.$emod_r[$mid]['tbname'].'.'.$f.'|'))
  4011. {
  4012. $value=addslashes($value);
  4013. $r=$empire->fetch1("select ".$f." from {$dbtbpre}ecms_".$emod_r[$mid]['tbname']." where id='$id' limit 1");
  4014. if($r[$f]<>$value)
  4015. {
  4016. $tbr=ReturnSameDataTb($emod_r[$mid]['tbname'],$f);
  4017. $ltbname=$tbr[0];
  4018. $lf=$tbr[1];
  4019. if($ltbname&&$lf)
  4020. {
  4021. $empire->query("update {$dbtbpre}ecms_".$ltbname." set ".$lf."='$value' where ".$lf."='$r[$f]'");
  4022. }
  4023. }
  4024. }
  4025. }
  4026. //返回数据同步表与字段名
  4027. function ReturnSameDataTb($tbname,$f){
  4028. global $public_r,$emod_pubr;
  4029. $expr=explode(','.$tbname.'.'.$f.'|',$emod_pubr['linkfields']);
  4030. $expr1=explode('|',$expr[0]);
  4031. $count=count($expr1)-1;
  4032. $tbr=explode('.',$expr1[$count]);
  4033. return $tbr;
  4034. }
  4035. //自定义字段返回模板字段处理
  4036. function doReturnAddTempf($temp){
  4037. $record="<!--record-->";
  4038. $field="<!--field--->";
  4039. $r=explode($record,$temp);
  4040. $count=count($r);
  4041. $str=',';
  4042. for($i=0;$i<$count-1;$i++)
  4043. {
  4044. $r1=explode($field,$r[$i]);
  4045. $str.=$r1[1].",";
  4046. }
  4047. if($str==',,')
  4048. {
  4049. $str=',';
  4050. }
  4051. return $str;
  4052. }
  4053. //组合复选框数据
  4054. function ReturnCheckboxAddF($r,$mid,$f){
  4055. global $public_r,$emod_r;
  4056. $val=$r;
  4057. if(is_array($r)&&strstr($emod_r[$mid]['checkboxf'],','.$f.','))
  4058. {
  4059. $val='';
  4060. $count=count($r);
  4061. for($i=0;$i<$count;$i++)
  4062. {
  4063. $val.=$r[$i].'|';
  4064. }
  4065. if($val)
  4066. {
  4067. $val='|'.$val;
  4068. }
  4069. }
  4070. return $val;
  4071. }
  4072. //返回自定义字段
  4073. function ReturnAddF($add,$modid,$userid,$username,$do=0,$rdata=0,$ch=0){
  4074. global $empire,$public_r,$dbtbpre,$emod_r;
  4075. if($do==0||$do==1)
  4076. {
  4077. //导入gd处理文件
  4078. if($add['mark']||$add['getfirsttitlespic']||$add['mcreatespic'])
  4079. {
  4080. include_once(ECMS_PATH.'e/class/gd.php');
  4081. }
  4082. }
  4083. $ret_r['tb']=$emod_r[$modid]['deftb'];
  4084. $r=explode(',',$emod_r[$modid][enter]);
  4085. $count=count($r)-1;
  4086. if(empty($do))//增加
  4087. {
  4088. //数据库操作
  4089. for($i=1;$i<$count;$i++)
  4090. {
  4091. $f=$r[$i];
  4092. if($f=='special.field'||!strstr($emod_r[$modid]['canaddf'],','.$f.','))
  4093. {
  4094. continue;
  4095. }
  4096. $add[$f]=ReturnCheckboxAddF($add[$f],$modid,$f);//复选框
  4097. $value=RepPhpAspJspcodeText($add[$f]);
  4098. if($f=='newstime')//时间
  4099. {
  4100. $value=empty($value)?time():to_time($value);
  4101. }
  4102. elseif($f=="morepic")//图片集
  4103. {
  4104. $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],0);
  4105. }
  4106. elseif($f=="downpath")//下载地址
  4107. {
  4108. $value=ReturnDownpath($add['downname'],$add['downpath'],$add['delpathid'],$add['pathid'],$add['downuser'],$add['fen'],$add['thedownqz'],$add,$add['foruser'],$add['downurl_qz'],0);
  4109. }
  4110. elseif($f=="onlinepath")//在线地址
  4111. {
  4112. $value=ReturnDownpath($add['odownname'],$add['odownpath'],$add['odelpathid'],$add['opathid'],$add['odownuser'],$add['ofen'],$add['othedownqz'],$add,$add['oforuser'],$add['onlineurl_qz'],0);
  4113. }
  4114. elseif($f=="smalltext")//简介
  4115. {
  4116. if(!trim($value))
  4117. {
  4118. $value=SubSmalltextVal($add[newstext],$public_r[smalltextlen]);//截取新闻内容
  4119. }
  4120. }
  4121. elseif($f=='infoip')//ip
  4122. {
  4123. $value=egetip();
  4124. }
  4125. elseif($f=='infozm')//字母
  4126. {
  4127. $value=$value?$value:GetInfoZm($add[title]);
  4128. }
  4129. //处理函数
  4130. $value=DoFFun($modid,$f,$value,1,0);
  4131. //检测必填字段
  4132. if($ch==1&&empty($add['titleurl']))
  4133. {
  4134. ChMustAddF($modid,$f,$value);
  4135. ChIsOnlyAddF($modid,0,$f,$value,0);//唯一值
  4136. }
  4137. //编辑器
  4138. if($f=="newstext")
  4139. {
  4140. //远程保存
  4141. $value=addslashes(CopyImg(stripSlashes($value),$add[copyimg],$add[copyflash],$add[classid],$add[qz_url],$username,$add['id'],$add['filepass'],$add['mark']));
  4142. //替换关键字和字符
  4143. $value=DoReplaceKeyAndWord($value,$add['dokey']);
  4144. //自动分页
  4145. if($add[autopage]&&!strstr($value,"[!--empirenews.page--]"))
  4146. {
  4147. if(empty($add[autosize]))
  4148. {$add[autosize]=5000;}
  4149. $value=AutoDoPage($value,$add[autosize]);
  4150. }
  4151. }
  4152. //存文本
  4153. if($emod_r[$modid]['savetxtf']&&$f==$emod_r[$modid]['savetxtf'])
  4154. {
  4155. //建立目录
  4156. $thetxtfile=GetFileMd5();
  4157. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  4158. //写放文件
  4159. EditTxtFieldText($truevalue,$value);
  4160. $value=$truevalue;
  4161. }
  4162. if(strstr($emod_r[$modid]['tbdataf'],','.$f.','))//副表
  4163. {
  4164. $ret_r['datafields'].=",".$f;
  4165. $ret_r['datavalues'].=",'".addslashes($value)."'";
  4166. }
  4167. else//主表
  4168. {
  4169. $ret_r['fields'].=",".$f;
  4170. $ret_r['values'].=",'".addslashes($value)."'";
  4171. }
  4172. }
  4173. }
  4174. elseif($do==1)//修改
  4175. {
  4176. //数据库操作
  4177. for($i=1;$i<$count;$i++)
  4178. {
  4179. $f=$r[$i];
  4180. if($f=="special.field"||!strstr($emod_r[$modid]['caneditf'],','.$f.','))
  4181. {
  4182. continue;
  4183. }
  4184. $add[$f]=ReturnCheckboxAddF($add[$f],$modid,$f);//复选框
  4185. $value=RepPhpAspJspcodeText($add[$f]);
  4186. if($f=='newstime')//时间
  4187. {
  4188. $value=empty($value)?time():to_time($value);
  4189. }
  4190. elseif($f=="morepic")//图片集
  4191. {
  4192. $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1);
  4193. }
  4194. elseif($f=="downpath")//下载地址
  4195. {
  4196. $value=ReturnDownpath($add['downname'],$add['downpath'],$add['delpathid'],$add['pathid'],$add['downuser'],$add['fen'],$add['thedownqz'],$add,$add['foruser'],$add['downurl_qz'],1);
  4197. }
  4198. elseif($f=="onlinepath")//在线地址
  4199. {
  4200. $value=ReturnDownpath($add['odownname'],$add['odownpath'],$add['odelpathid'],$add['opathid'],$add['odownuser'],$add['ofen'],$add['othedownqz'],$add,$add['oforuser'],$add['onlineurl_qz'],1);
  4201. }
  4202. elseif($f=="smalltext")//简介
  4203. {
  4204. if(!trim($value))
  4205. {
  4206. $value=SubSmalltextVal($add[newstext],$public_r[smalltextlen]);//截取新闻内容
  4207. }
  4208. }
  4209. elseif($f=='infozm')//字母
  4210. {
  4211. $value=$value?$value:GetInfoZm($add[title]);
  4212. }
  4213. //处理函数
  4214. $value=DoFFun($modid,$f,$value,0,0);
  4215. //检测必填字段
  4216. if($ch==1&&empty($add['titleurl']))
  4217. {
  4218. ChMustAddF($modid,$f,$value);
  4219. ChIsOnlyAddF($modid,$add[id],$f,$value,0);//唯一值
  4220. }
  4221. //数据同步
  4222. SameDataAddF($add[id],$add[classid],$modid,$f,$value);
  4223. //内容
  4224. if($f=="newstext")
  4225. {
  4226. //远程保存
  4227. $value=addslashes(CopyImg(stripSlashes($value),$add[copyimg],$add[copyflash],$add[classid],$add[qz_url],$username,$add['id'],$add['filepass'],$add['mark']));
  4228. //自动分页
  4229. if($add[autopage]&&!strstr($value,"[!--empirenews.page--]"))
  4230. {
  4231. if(empty($add[autosize]))
  4232. {$add[autosize]=5000;}
  4233. $value=AutoDoPage($value,$add[autosize]);
  4234. }
  4235. }
  4236. //存文本
  4237. if($emod_r[$modid]['savetxtf']&&$f==$emod_r[$modid]['savetxtf'])
  4238. {
  4239. //建立目录
  4240. $newstexttxt_r=explode("/",$add[newstext_url]);
  4241. $thetxtfile=$newstexttxt_r[2];
  4242. $truevalue=MkDirTxtFile($newstexttxt_r[0]."/".$newstexttxt_r[1],$thetxtfile);
  4243. //写放文件
  4244. EditTxtFieldText($truevalue,$value);
  4245. $value=$truevalue;
  4246. }
  4247. if(strstr($emod_r[$modid]['tbdataf'],','.$f.','))//副表
  4248. {
  4249. $ret_r['datafields'].=",".$f;
  4250. $ret_r['datavalues'].=",".$f."='".addslashes($value)."'";
  4251. }
  4252. else//主表
  4253. {
  4254. $ret_r['fields'].=",".$f;
  4255. $ret_r['values'].=",".$f."='".addslashes($value)."'";
  4256. }
  4257. }
  4258. }
  4259. elseif($do==8)//同步修改
  4260. {
  4261. //数据库操作
  4262. for($i=1;$i<$count;$i++)
  4263. {
  4264. $f=$r[$i];
  4265. if($f=='special.field')
  4266. {
  4267. continue;
  4268. }
  4269. $value=$add[$f];
  4270. //存文本
  4271. if($emod_r[$modid]['savetxtf']&&$f==$emod_r[$modid]['savetxtf'])
  4272. {
  4273. //建立目录
  4274. $newstexttxt_r=explode("/",$add[newstext_url]);
  4275. $thetxtfile=$newstexttxt_r[2];
  4276. $truevalue=MkDirTxtFile($newstexttxt_r[0]."/".$newstexttxt_r[1],$thetxtfile);
  4277. //写放文件
  4278. EditTxtFieldText($truevalue,$value);
  4279. $value=$truevalue;
  4280. }
  4281. if(strstr($emod_r[$modid]['tbdataf'],','.$f.','))//副表
  4282. {
  4283. $ret_r['datafields'].=",".$f;
  4284. $ret_r['datavalues'].=",".$f."='".StripAddsData($value)."'";
  4285. }
  4286. else//主表
  4287. {
  4288. $ret_r['fields'].=",".$f;
  4289. $ret_r['values'].=",".$f."='".StripAddsData($value)."'";
  4290. }
  4291. }
  4292. }
  4293. elseif($do==9)//复制
  4294. {
  4295. //数据库操作
  4296. for($i=1;$i<$count;$i++)
  4297. {
  4298. $f=$r[$i];
  4299. if($f=='special.field')
  4300. {
  4301. continue;
  4302. }
  4303. $value=$add[$f];
  4304. //存文本
  4305. if($emod_r[$modid]['savetxtf']&&$f==$emod_r[$modid]['savetxtf'])
  4306. {
  4307. //建立目录
  4308. $thetxtfile=GetFileMd5();
  4309. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  4310. //写放文件
  4311. EditTxtFieldText($truevalue,$value);
  4312. $value=$truevalue;
  4313. }
  4314. if(strstr($emod_r[$modid]['tbdataf'],','.$f.','))//副表
  4315. {
  4316. $ret_r['datafields'].=",".$f;
  4317. $ret_r['datavalues'].=",'".StripAddsData($value)."'";
  4318. }
  4319. else//主表
  4320. {
  4321. $ret_r['fields'].=",".$f;
  4322. $ret_r['values'].=",'".StripAddsData($value)."'";
  4323. }
  4324. }
  4325. }
  4326. elseif($do==10)//归档
  4327. {
  4328. //数据库操作
  4329. for($i=1;$i<$count;$i++)
  4330. {
  4331. $f=$r[$i];
  4332. if($f=='special.field')
  4333. {
  4334. continue;
  4335. }
  4336. $value=$add[$f];
  4337. if(strstr($emod_r[$modid]['tbdataf'],','.$f.','))//副表
  4338. {
  4339. $ret_r['datafields'].=",".$f;
  4340. $ret_r['datavalues'].=",'".StripAddsData($value)."'";
  4341. }
  4342. else//主表
  4343. {
  4344. $ret_r['fields'].=",".$f;
  4345. $ret_r['values'].=",'".StripAddsData($value)."'";
  4346. }
  4347. }
  4348. }
  4349. return $ret_r;
  4350. }
  4351. //返回采集字段
  4352. function ReturnAddCj($add,$cj,$do=0){
  4353. global $empire;
  4354. $record="<!--record-->";
  4355. $field="<!--field--->";
  4356. $record_r=explode($record,$cj);
  4357. for($i=0;$i<count($record_r)-1;$i++)
  4358. {
  4359. $field_r=explode($field,$record_r[$i]);
  4360. //增加
  4361. if(empty($do))
  4362. {
  4363. $f1="zz_".$field_r[1];
  4364. $f2="z_".$field_r[1];
  4365. $f3="qz_".$field_r[1];
  4366. $f4="save_".$field_r[1];
  4367. $ret_r[0].=",".$f1.",".$f2.",".$f3.",".$f4;
  4368. $ret_r[1].=",'".addslashes($add[$f1])."','".addslashes($add[$f2])."','".addslashes($add[$f3])."','".$add[$f4]."'";
  4369. }
  4370. //修改
  4371. else
  4372. {
  4373. $f1="zz_".$field_r[1];
  4374. $f2="z_".$field_r[1];
  4375. $f3="qz_".$field_r[1];
  4376. $f4="save_".$field_r[1];
  4377. $ret_r[0].=",".$f1."='".addslashes($add[$f1])."',".$f2."='".addslashes($add[$f2])."',".$f3."='".addslashes($add[$f3])."',".$f4."='".$add[$f4]."'";
  4378. }
  4379. }
  4380. return $ret_r;
  4381. }
  4382. //图片集上传图片
  4383. function SaveMorepicFile($varname,$msavepic,$i,$picurl,$picname,$classid,$id,$add){
  4384. global $public_r,$empire,$loginin,$dbtbpre,$tranpicturetype;
  4385. if($varname=="mbigpfile")
  4386. {
  4387. $addname="[b]";
  4388. }
  4389. $type=1;
  4390. $r[url]=$picurl;
  4391. //上传
  4392. if($_FILES[$varname]['name'][$i])
  4393. {
  4394. //取得文件类型
  4395. $filetype=GetFiletype($_FILES[$varname]['name'][$i]);
  4396. //允许上传类型
  4397. if(CheckSaveTranFiletype($filetype))
  4398. {
  4399. return $r;
  4400. }
  4401. if(!strstr($public_r['filetype'],"|".$filetype."|"))
  4402. {
  4403. return $r;
  4404. }
  4405. //图片文件
  4406. if(!strstr($tranpicturetype,','.$filetype.','))
  4407. {
  4408. return $r;
  4409. }
  4410. //文件大小
  4411. if($_FILES[$varname]['size'][$i]>$public_r['filesize']*1024)
  4412. {
  4413. return $r;
  4414. }
  4415. //上传
  4416. $r=DoTranFile($_FILES[$varname]['tmp_name'][$i],$_FILES[$varname]['name'][$i],$_FILES[$varname]['type'][$i],$_FILES[$varname]['size'][$i],$classid);
  4417. //------------------------写入数据库
  4418. $r[filesize]=(int)$r[filesize];
  4419. $classid=(int)$classid;
  4420. $filetime=date("Y-m-d H:i:s");
  4421. if(empty($picname))
  4422. {
  4423. $picname=$r[filename];
  4424. }
  4425. else
  4426. {
  4427. $picname=$addname.$picname;
  4428. }
  4429. $picname=RepPostStr($picname);
  4430. $id=(int)$id;
  4431. $cjid=0;
  4432. if(!$id)
  4433. {
  4434. $cjid=(int)$add['filepass'];
  4435. }
  4436. $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,onclick,id,cjid,fpath) values('$r[filename]',$r[filesize],'$loginin','$r[filepath]','$filetime',$classid,'$picname',$type,0,$id,$cjid,'$public_r[fpath]');");
  4437. return $r;
  4438. }
  4439. //远程保存
  4440. else
  4441. {
  4442. if(empty($msavepic))
  4443. {
  4444. return $r;
  4445. }
  4446. if(empty($picurl))
  4447. {
  4448. return $r;
  4449. }
  4450. //----------------取得文件类型
  4451. $filetype=GetFiletype($picurl);
  4452. //允许上传类型
  4453. if(CheckSaveTranFiletype($filetype))
  4454. {
  4455. return $r;
  4456. }
  4457. if(!strstr($public_r['filetype'],"|".$filetype."|"))
  4458. {
  4459. return $r;
  4460. }
  4461. //图片文件
  4462. if(!strstr($tranpicturetype,','.$filetype.','))
  4463. {
  4464. return $r;
  4465. }
  4466. //保存
  4467. $r=DoTranUrl($picurl,$classid);
  4468. if($r['tran'])
  4469. {
  4470. //记录数据库
  4471. $filetime=date("Y-m-d H:i:s");
  4472. //变量处理
  4473. $r[filesize]=(int)$r[filesize];
  4474. $classid=(int)$classid;
  4475. $r[type]=(int)$r[type];
  4476. if(empty($picname))
  4477. {
  4478. $picname=$r[filename];
  4479. }
  4480. else
  4481. {
  4482. $picname=$addname.$picname;
  4483. }
  4484. $picname=RepPostStr($picname);
  4485. $id=(int)$id;
  4486. $cjid=0;
  4487. if(!$id)
  4488. {
  4489. $cjid=(int)$add['filepass'];
  4490. }
  4491. $sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$r[filename]',$r[filesize],'$loginin','$r[filepath]','$filetime',$classid,'$picname',$type,$id,$cjid,0,'$public_r[fpath]');");
  4492. return $r;
  4493. }
  4494. return $r;
  4495. }
  4496. }
  4497. //入库时远程保存
  4498. function LoadInSaveMorepicFile($morepic,$msavepic,$classid,$id,$add){
  4499. if(empty($morepic)||!$msavepic)
  4500. {
  4501. return $morepic;
  4502. }
  4503. $f_exp="::::::";
  4504. $r_exp="\r\n";
  4505. $returnstr="";
  4506. $r=explode($r_exp,$morepic);
  4507. $countr=count($r);
  4508. for($i=0;$i<$countr;$i++)
  4509. {
  4510. $r1=explode($f_exp,$r[$i]);
  4511. //小图
  4512. $smpr=SaveMorepicFile("msmallpfile",$msavepic,0,$r1[0],$r1[2],$classid,$id,$add);
  4513. $spic=$smpr[url];
  4514. //大图
  4515. if($r1[0]!=$r1[1])
  4516. {
  4517. $bmpr=SaveMorepicFile("mbigpfile",$msavepic,0,$r1[1],$r1[2],$classid,$id,$add);
  4518. $bpic=$bmpr[url];
  4519. }
  4520. else
  4521. {
  4522. $bpic=$spic;
  4523. }
  4524. if($spic)
  4525. {
  4526. $returnstr.=$spic.$f_exp.$bpic.$f_exp.$r1[2].$r_exp;
  4527. }
  4528. }
  4529. //去掉最后的字符
  4530. $returnstr=substr($returnstr,0,strlen($returnstr)-2);
  4531. return $returnstr;
  4532. }
  4533. //---------图片地址组合
  4534. function ReturnMorepicpath($smallpic,$bigpic,$picname,$delpicid,$picid,$add,$downurl,$down=0){
  4535. global $loginin,$logininid;
  4536. $f_exp="::::::";
  4537. $r_exp="\r\n";
  4538. $returnstr="";
  4539. $downurl=str_replace($f_exp,"",$downurl);
  4540. $downurl=str_replace($r_exp,"",$downurl);
  4541. //增加信息
  4542. if(empty($down))
  4543. {
  4544. for($i=0;$i<count($smallpic);$i++)
  4545. {
  4546. $name=str_replace($f_exp,"",$picname[$i]);
  4547. $name=str_replace($r_exp,"",$name);
  4548. //替换非法字符
  4549. $spic=str_replace($f_exp,"",$smallpic[$i]);
  4550. $spic=str_replace($r_exp,"",$spic);
  4551. $spic=$spic?$downurl.$spic:'';
  4552. //保存图片
  4553. $smpr=SaveMorepicFile("msmallpfile",$add[msavepic],$i,$spic,$name,$add[classid],$add[id],$add);
  4554. $spic=$smpr[url];
  4555. //如没有大图的话跟缩略图一样
  4556. if(empty($bigpic[$i])&&!$_FILES['mbigpfile']['name'][$i])
  4557. {
  4558. $bpic=$spic;
  4559. }
  4560. else
  4561. {
  4562. $bpic=str_replace($f_exp,"",$bigpic[$i]);
  4563. $bpic=str_replace($r_exp,"",$bpic);
  4564. $bpic=$bpic?$downurl.$bpic:'';
  4565. //保存图片
  4566. $bmpr=SaveMorepicFile("mbigpfile",$add[msavepic],$i,$bpic,$name,$add[classid],$add[id],$add);
  4567. $bpic=$bmpr[url];
  4568. //生成缩图
  4569. if(empty($spic)&&$bpic&&$bmpr[tran]&&$add[mcreatespic])
  4570. {
  4571. $picno='[b]'.($name?$name:$bmpr[filename]);
  4572. $sfiler=GetMySmallImg($add['classid'],$picno,$bmpr[insertfile],$bmpr[filepath],$bmpr[yname],$add[mcreatespicwidth],$add[mcreatespicheight],$bmpr[name],$add['filepass'],$add['filepass'],$logininid,$loginin);
  4573. $spic=str_replace("/".$bmpr[filename],"/small".$bmpr[insertfile].$sfiler['filetype'],$bmpr[url]);
  4574. }
  4575. }
  4576. if(empty($spic))
  4577. {
  4578. $spic=$bpic;
  4579. }
  4580. if($spic)
  4581. {$returnstr.=$spic.$f_exp.$bpic.$f_exp.$name.$r_exp;}
  4582. }
  4583. }
  4584. //修改信息
  4585. else
  4586. {
  4587. for($i=0;$i<count($smallpic);$i++)
  4588. {
  4589. //删除地址
  4590. $del=0;
  4591. for($j=0;$j<count($delpicid);$j++)
  4592. {
  4593. if($delpicid[$j]==$picid[$i])
  4594. {$del=1;}
  4595. }
  4596. if($del)
  4597. {continue;}
  4598. $name=str_replace($f_exp,"",$picname[$i]);
  4599. $name=str_replace($r_exp,"",$name);
  4600. //替换非法字符
  4601. $spic=str_replace($f_exp,"",$smallpic[$i]);
  4602. $spic=str_replace($r_exp,"",$spic);
  4603. $spic=$spic?$downurl.$spic:'';
  4604. //保存图片
  4605. $smpr=SaveMorepicFile("msmallpfile",$add[msavepic],$i,$spic,$name,$add[classid],$add[id],$add);
  4606. $spic=$smpr[url];
  4607. //如没有大图的话跟缩略图一样
  4608. if(empty($bigpic[$i])&&!$_FILES['mbigpfile']['name'][$i])
  4609. {
  4610. $bpic=$spic;
  4611. }
  4612. else
  4613. {
  4614. $bpic=str_replace($f_exp,"",$bigpic[$i]);
  4615. $bpic=str_replace($r_exp,"",$bpic);
  4616. $bpic=$bpic?$downurl.$bpic:'';
  4617. //保存图片
  4618. $bmpr=SaveMorepicFile("mbigpfile",$add[msavepic],$i,$bpic,$name,$add[classid],$add[id],$add);
  4619. $bpic=$bmpr[url];
  4620. //生成缩图
  4621. if(empty($spic)&&$bpic&&$bmpr[tran]&&$add[mcreatespic])
  4622. {
  4623. $picno='[b]'.($name?$name:$bmpr[filename]);
  4624. $sfiler=GetMySmallImg($add['classid'],$picno,$bmpr[insertfile],$bmpr[filepath],$bmpr[yname],$add[mcreatespicwidth],$add[mcreatespicheight],$bmpr[name],$add['filepass'],$add['filepass'],$logininid,$loginin);
  4625. $spic=str_replace("/".$bmpr[filename],"/small".$bmpr[insertfile].$sfiler['filetype'],$bmpr[url]);
  4626. }
  4627. }
  4628. if(empty($spic))
  4629. {
  4630. $spic=$bpic;
  4631. }
  4632. if($spic)
  4633. {$returnstr.=$spic.$f_exp.$bpic.$f_exp.$name.$r_exp;}
  4634. }
  4635. }
  4636. //去掉最后的字符
  4637. $returnstr=substr($returnstr,0,strlen($returnstr)-2);
  4638. return $returnstr;
  4639. }
  4640. //---------下载地址组合
  4641. function ReturnDownpath($downname,$downpath,$delpathid,$pathid,$downuser,$fen,$thedownqz,$add,$foruser,$downurl,$down=0){
  4642. $f_exp="::::::";
  4643. $r_exp="\r\n";
  4644. $returnstr="";
  4645. $downurl=str_replace($f_exp,"",$downurl);
  4646. $downurl=str_replace($r_exp,"",$downurl);
  4647. //增加软件
  4648. if(empty($down))
  4649. {
  4650. for($i=0;$i<count($downname);$i++)
  4651. {
  4652. //替换非法字符
  4653. $name=str_replace($f_exp,"",$downname[$i]);
  4654. $name=str_replace($r_exp,"",$downname[$i]);
  4655. $path=str_replace($f_exp,"",$downpath[$i]);
  4656. $path=str_replace($r_exp,"",$downpath[$i]);
  4657. //批量更换权限
  4658. if($add[doforuser])
  4659. {
  4660. if(empty($foruser))
  4661. {
  4662. $foruser=0;
  4663. }
  4664. $fuser=$foruser;
  4665. }
  4666. else
  4667. {
  4668. if(empty($downuser[$i]))
  4669. {
  4670. $fuser=0;
  4671. }
  4672. else
  4673. {
  4674. $fuser=$downuser[$i];
  4675. }
  4676. }
  4677. //批量更新点数
  4678. if($add[dodownfen])
  4679. {
  4680. if(empty($add[downfen]))
  4681. {
  4682. $add[downfen]=0;
  4683. }
  4684. $ffen=$add[downfen];
  4685. }
  4686. else
  4687. {
  4688. if(empty($fen[$i]))
  4689. {
  4690. $ffen=0;
  4691. }
  4692. else
  4693. {
  4694. $ffen=$fen[$i];
  4695. }
  4696. }
  4697. $downqz=$thedownqz[$i];
  4698. if($path&&$name)
  4699. {$returnstr.=$name.$f_exp.$downurl.$path.$f_exp.$fuser.$f_exp.$ffen.$f_exp.$downqz.$r_exp;}
  4700. }
  4701. }
  4702. //修改软件
  4703. else
  4704. {
  4705. for($i=0;$i<count($downname);$i++)
  4706. {
  4707. //删除下载地址
  4708. $del=0;
  4709. for($j=0;$j<count($delpathid);$j++)
  4710. {
  4711. if($delpathid[$j]==$pathid[$i])
  4712. {$del=1;}
  4713. }
  4714. if($del)
  4715. {continue;}
  4716. //替换非法字符
  4717. $name=str_replace($f_exp,"",$downname[$i]);
  4718. $name=str_replace($r_exp,"",$downname[$i]);
  4719. $path=str_replace($f_exp,"",$downpath[$i]);
  4720. $path=str_replace($r_exp,"",$downpath[$i]);
  4721. //批量更换权限
  4722. if($add[doforuser])
  4723. {
  4724. if(empty($foruser))
  4725. {
  4726. $foruser=0;
  4727. }
  4728. $fuser=$foruser;
  4729. }
  4730. else
  4731. {
  4732. if(empty($downuser[$i]))
  4733. {
  4734. $fuser=0;
  4735. }
  4736. else
  4737. {
  4738. $fuser=$downuser[$i];
  4739. }
  4740. }
  4741. //批量更新点数
  4742. if($add[dodownfen])
  4743. {
  4744. if(empty($add[downfen]))
  4745. {
  4746. $add[downfen]=0;
  4747. }
  4748. $ffen=$add[downfen];
  4749. }
  4750. else
  4751. {
  4752. if(empty($fen[$i]))
  4753. {
  4754. $ffen=0;
  4755. }
  4756. else
  4757. {
  4758. $ffen=$fen[$i];
  4759. }
  4760. }
  4761. $downqz=$thedownqz[$i];
  4762. if($path&&$name)
  4763. {$returnstr.=$name.$f_exp.$downurl.$path.$f_exp.$fuser.$f_exp.$ffen.$f_exp.$downqz.$r_exp;}
  4764. }
  4765. }
  4766. //去掉最后的字符
  4767. $returnstr=substr($returnstr,0,strlen($returnstr)-2);
  4768. return $returnstr;
  4769. }
  4770. //-------------- 缓存区 ----------------------
  4771. //一级栏目导航
  4772. function GetClassNavCache($line,$navfh){
  4773. global $empire,$dbtbpre,$public_r;
  4774. $limit='';
  4775. if($line)
  4776. {
  4777. $limit=" limit ".$line;
  4778. }
  4779. $navs='';
  4780. $fh='';
  4781. $sql=$empire->query("select classid,classname,wburl,listdt,classurl,classpath from {$dbtbpre}enewsclass where bclassid=0 and showclass=0 order by myorder,classid".$limit);
  4782. while($r=$empire->fetch($sql))
  4783. {
  4784. $classurl=sys_ReturnBqClassUrl($r);
  4785. if($navs)
  4786. {
  4787. $fh=$navfh;
  4788. }
  4789. $navs.=$fh."<a href=\"".$classurl."\">".$r[classname]."</a>";
  4790. }
  4791. return $navs;
  4792. }
  4793. //生成配置文件
  4794. function GetConfig($domod=0){
  4795. $filename=ECMS_PATH."e/class/config.php";
  4796. $exp='//-------EmpireCMS.Public.Cache-------';
  4797. $text=ReadFiletext($filename);
  4798. $r=explode($exp,$text);
  4799. if($r[0]=='')
  4800. {
  4801. return false;
  4802. }
  4803. $r[1]=GetPubCache();
  4804. if($domod==1)
  4805. {
  4806. $r[2]=GetModCache();
  4807. }
  4808. $setting=$r[0].$exp.$r[1].$exp.$r[2].$exp.$r[3];
  4809. WriteFiletext_n($filename,$setting);
  4810. }
  4811. //更新公共缓存
  4812. function GetPubCache(){
  4813. global $empire,$dbtbpre;
  4814. //扩展变量
  4815. $pvstring='';
  4816. $pvsql=$empire->query("select myvar,varvalue from {$dbtbpre}enewspubvar where tocache=1");
  4817. while($pvr=$empire->fetch($pvsql))
  4818. {
  4819. $pvstring.=",'add_".$pvr['myvar']."'=>'".addslashes($pvr['varvalue'])."'";
  4820. }
  4821. //公共变量
  4822. $r=$empire->fetch1("select * from {$dbtbpre}enewspublic limit 1");
  4823. $tr=$empire->fetch1("select downsofttemp,onlinemovietemp,listpagetemp from ".GetTemptb("enewspubtemp")." limit 1");
  4824. $fsr=$empire->fetch1("select purl from {$dbtbpre}enewspostserver where ptype=1 limit 1");
  4825. $GLOBALS['public_r']['newsurl']=$r['newsurl'];
  4826. $classnavs=GetClassNavCache($r[classnavline],$r[classnavfh]);
  4827. $checkdorepstr=ReturnCheckDoRep();
  4828. $setting.="
  4829. //------------e_public
  4830. \$public_r=array('sitename'=>'".addslashes($r[sitename])."',
  4831. 'newsurl'=>'".addslashes($r[newsurl])."',
  4832. 'filetype'=>'".addslashes($r[filetype])."',
  4833. 'filesize'=>".$r[filesize].",
  4834. 'relistnum'=>".$r[relistnum].",
  4835. 'renewsnum'=>".$r[renewsnum].",
  4836. 'min_keyboard'=>".$r[min_keyboard].",
  4837. 'max_keyboard'=>".$r[max_keyboard].",
  4838. 'search_num'=>".$r[search_num].",
  4839. 'search_pagenum'=>".$r[search_pagenum].",
  4840. 'newslink'=>".$r[newslink].",
  4841. 'checked'=>".$r[checked].",
  4842. 'pltime'=>".$r[pltime].",
  4843. 'searchtime'=>".$r[searchtime].",
  4844. 'loginnum'=>".$r[loginnum].",
  4845. 'logintime'=>".$r[logintime].",
  4846. 'addnews_ok'=>".$r[addnews_ok].",
  4847. 'register_ok'=>".$r[register_ok].",
  4848. 'indextype'=>'".addslashes($r[indextype])."',
  4849. 'goodlencord'=>".$r[goodlencord].",
  4850. 'goodtype'=>'".addslashes($r[goodtype])."',
  4851. 'searchtype'=>'".addslashes($r[searchtype])."',
  4852. 'exittime'=>".$r[exittime].",
  4853. 'smalltextlen'=>".$r[smalltextlen].",
  4854. 'defaultgroupid'=>".$r[defaultgroupid].",
  4855. 'fileurl'=>'".addslashes($r[fileurl])."',
  4856. 'install'=>".$r[install].",
  4857. 'phpmode'=>".$r[phpmode].",
  4858. 'plsize'=>".$r[plsize].",
  4859. 'plincludesize'=>".$r[plincludesize].",
  4860. 'dorepnum'=>".$r[dorepnum].",
  4861. 'loadtempnum'=>".$r[loadtempnum].",
  4862. 'bakdbpath'=>'".addslashes($r[bakdbpath])."',
  4863. 'bakdbzip'=>'".addslashes($r[bakdbzip])."',
  4864. 'downpass'=>'".addslashes($r[downpass])."',
  4865. 'filechmod'=>".$r[filechmod].",
  4866. 'loginkey_ok'=>".$r[loginkey_ok].",
  4867. 'tbname'=>'".addslashes($r[tbname])."',
  4868. 'limittype'=>".$r[limittype].",
  4869. 'plkey_ok'=>".$r[plkey_ok].",
  4870. 'redodown'=>".$r[redodown].",
  4871. 'downsofttemp'=>'".addslashes(stripSlashes($tr[downsofttemp]))."',
  4872. 'onlinemovietemp'=>'".addslashes(stripSlashes($tr[onlinemovietemp]))."',
  4873. 'havefp'=>".$r[havefp].",
  4874. 'fpnum'=>".$r[fpnum].",
  4875. 'lctime'=>".$r[lctime].",
  4876. 'candocode'=>".$r[candocode].",
  4877. 'opennotcj'=>".$r[opennotcj].",
  4878. 'listpagetemp'=>'".addslashes(stripSlashes($tr[listpagetemp]))."',
  4879. 'reuserpagenum'=>".$r[reuserpagenum].",
  4880. 'revotejsnum'=>".$r[revotejsnum].",
  4881. 'readjsnum'=>".$r[readjsnum].",
  4882. 'qaddtran'=>".$r[qaddtran].",
  4883. 'qaddtransize'=>".$r[qaddtransize].",
  4884. 'ebakthisdb'=>".$r[ebakthisdb].",
  4885. 'delnewsnum'=>".$r[delnewsnum].",
  4886. 'markpos'=>".$r[markpos].",
  4887. 'markimg'=>'".addslashes($r[markimg])."',
  4888. 'marktext'=>'".addslashes($r[marktext])."',
  4889. 'markfontsize'=>'".addslashes($r[markfontsize])."',
  4890. 'markfontcolor'=>'".addslashes($r[markfontcolor])."',
  4891. 'markfont'=>'".addslashes($r[markfont])."',
  4892. 'adminloginkey'=>".$r[adminloginkey].",
  4893. 'php_outtime'=>".$r[php_outtime].",
  4894. 'listpagefun'=>'".addslashes($r[listpagefun])."',
  4895. 'textpagefun'=>'".addslashes($r[textpagefun])."',
  4896. 'adfile'=>'".addslashes($r[adfile])."',
  4897. 'notsaveurl'=>'".addslashes($r[notsaveurl])."',
  4898. 'rssnum'=>".$r[rssnum].",
  4899. 'rsssub'=>".$r[rsssub].",
  4900. 'savetxtf'=>'".addslashes($r[savetxtf])."',
  4901. 'dorepdlevelnum'=>".$r[dorepdlevelnum].",
  4902. 'listpagelistfun'=>'".addslashes($r[listpagelistfun])."',
  4903. 'listpagelistnum'=>".$r[listpagelistnum].",
  4904. 'infolinknum'=>".$r[infolinknum].",
  4905. 'searchgroupid'=>".$r[searchgroupid].",
  4906. 'opencopytext'=>".$r[opencopytext].",
  4907. 'reuserjsnum'=>".$r[reuserjsnum].",
  4908. 'reuserlistnum'=>".$r[reuserlistnum].",
  4909. 'opentitleurl'=>".$r[opentitleurl].",
  4910. 'searchtempvar'=>".$r[searchtempvar].",
  4911. 'showinfolevel'=>".$r[showinfolevel].",
  4912. 'navfh'=>'".addslashes($r[navfh])."',
  4913. 'spicwidth'=>".$r[spicwidth].",
  4914. 'spicheight'=>".$r[spicheight].",
  4915. 'spickill'=>".$r[spickill].",
  4916. 'jpgquality'=>".$r[jpgquality].",
  4917. 'markpct'=>".$r[markpct].",
  4918. 'redoview'=>".$r[redoview].",
  4919. 'reggetfen'=>".$r[reggetfen].",
  4920. 'regbooktime'=>".$r[regbooktime].",
  4921. 'revotetime'=>".$r[revotetime].",
  4922. 'fpath'=>".$r[fpath].",
  4923. 'filepath'=>'".addslashes($r[filepath])."',
  4924. 'nreclass'=>'".addslashes($r[nreclass])."',
  4925. 'nreinfo'=>'".addslashes($r[nreinfo])."',
  4926. 'nrejs'=>'".addslashes($r[nrejs])."',
  4927. 'nottobq'=>'".addslashes($r[nottobq])."',
  4928. 'defspacestyleid'=>".$r[defspacestyleid].",
  4929. 'canposturl'=>'".addslashes($r[canposturl])."',
  4930. 'openspace'=>".$r[openspace].",
  4931. 'defadminstyle'=>".$r[defadminstyle].",
  4932. 'realltime'=>".$r[realltime].",
  4933. 'closeip'=>'".addslashes($r[closeip])."',
  4934. 'openip'=>'".addslashes($r[openip])."',
  4935. 'hopenip'=>'".addslashes($r[hopenip])."',
  4936. 'plface'=>'".addslashes($r[plface])."',
  4937. 'plfacenum'=>".$r[plfacenum].",
  4938. 'textpagelistnum'=>".$r[textpagelistnum].",
  4939. 'memberlistlevel'=>".$r[memberlistlevel].",
  4940. 'ebakcanlistdb'=>".$r[ebakcanlistdb].",
  4941. 'keytog'=>".$r[keytog].",
  4942. 'keytime'=>".$r[keytime].",
  4943. 'keyrnd'=>'".addslashes($r[keyrnd])."',
  4944. 'checkdorepstr'=>'".addslashes($checkdorepstr)."',
  4945. 'regkey_ok'=>".$r[regkey_ok].",
  4946. 'opengetdown'=>".$r[opengetdown].",
  4947. 'gbkey_ok'=>".$r[gbkey_ok].",
  4948. 'fbkey_ok'=>".$r[fbkey_ok].",
  4949. 'newaddinfotime'=>".$r[newaddinfotime].",
  4950. 'classnavs'=>'".addslashes($classnavs)."',
  4951. 'plgroupid'=>".$r[plgroupid].",
  4952. 'adminstyle'=>'".addslashes($r[adminstyle])."',
  4953. 'docnewsnum'=>".$r[docnewsnum].",
  4954. 'openschall'=>".$r[openschall].",
  4955. 'schallfield'=>".$r[schallfield].",
  4956. 'schallminlen'=>".$r[schallminlen].",
  4957. 'schallmaxlen'=>".$r[schallmaxlen].",
  4958. 'schallnum'=>".$r[schallnum].",
  4959. 'schallpagenum'=>".$r[schallpagenum].",
  4960. 'dtcanbq'=>".$r[dtcanbq].",
  4961. 'dtcachetime'=>".$r[dtcachetime].",
  4962. 'defpltempid'=>".$r[defpltempid].",
  4963. 'buycarnum'=>".$r[buycarnum].",
  4964. 'shopddgroupid'=>".$r[shopddgroupid].",
  4965. 'repkeynum'=>".$r[repkeynum].",
  4966. 'regacttype'=>".$r[regacttype].",
  4967. 'opengetpass'=>".$r[opengetpass].",
  4968. 'hlistinfonum'=>".$r[hlistinfonum].",
  4969. 'qlistinfonum'=>".$r[qlistinfonum].",
  4970. 'dtncanbq'=>".$r[dtncanbq].",
  4971. 'dtncachetime'=>".$r[dtncachetime].",
  4972. 'readdinfotime'=>".$r[readdinfotime].",
  4973. 'qeditinfotime'=>".$r[qeditinfotime].",
  4974. 'onclicktype'=>".$r[onclicktype].",
  4975. 'onclickfilesize'=>".$r[onclickfilesize].",
  4976. 'onclickfiletime'=>".$r[onclickfiletime].",
  4977. 'schalltime'=>".$r[schalltime].",
  4978. 'defprinttempid'=>".$r[defprinttempid].",
  4979. 'opentags'=>".$r[opentags].",
  4980. 'tagstempid'=>".$r[tagstempid].",
  4981. 'usetags'=>'".addslashes($r[usetags])."',
  4982. 'chtags'=>'".addslashes($r[chtags])."',
  4983. 'tagslistnum'=>".$r[tagslistnum].",
  4984. 'closeqdt'=>".$r[closeqdt].",
  4985. 'settop'=>".$r[settop].",
  4986. 'qlistinfomod'=>".$r[qlistinfomod].",
  4987. 'pl_num'=>".$r[pl_num].",
  4988. 'gb_num'=>".$r[gb_num].",
  4989. 'member_num'=>".$r[member_num].",
  4990. 'space_num'=>".$r[space_num].",
  4991. 'infolday'=>".$r[infolday].",
  4992. 'filelday'=>".$r[filelday].",
  4993. 'dorepkey'=>".$r[dorepkey].",
  4994. 'dorepword'=>".$r[dorepword].",
  4995. 'onclickrnd'=>'".addslashes($r[onclickrnd])."',
  4996. 'keybgcolor'=>'".addslashes($r[keybgcolor])."',
  4997. 'keyfontcolor'=>'".addslashes($r[keyfontcolor])."',
  4998. 'keydistcolor'=>'".addslashes($r[keydistcolor])."',
  4999. 'indexpageid'=>".$r[indexpageid].",
  5000. 'closeqdtmsg'=>'".addslashes($r[closeqdtmsg])."',
  5001. 'openfileserver'=>".$r[openfileserver].",
  5002. 'fs_purl'=>'".addslashes($fsr[purl])."',
  5003. 'closemods'=>'".addslashes($r[closemods])."',
  5004. 'deftempid'=>".$r[deftempid].$pvstring.");
  5005. //------------e_public
  5006. ";
  5007. return $setting;
  5008. }
  5009. //更新模型缓存
  5010. function GetModCache(){
  5011. global $empire,$dbtbpre;
  5012. //数据表
  5013. $tablesql=$empire->query("select tbname,deftb,yhid,mid from {$dbtbpre}enewstable");
  5014. while($tabler=$empire->fetch($tablesql))
  5015. {
  5016. $tables.="\$etable_r['".$tabler[tbname]."']=Array('deftb'=>'".addslashes($tabler[deftb])."',
  5017. 'yhid'=>".$tabler[yhid].",
  5018. 'mid'=>".$tabler[mid].");
  5019. ";
  5020. }
  5021. //系统模型
  5022. $alllinkfields='|';//关联同步
  5023. $modsql=$empire->query("select * from {$dbtbpre}enewsmod");
  5024. while($mr=$empire->fetch($modsql))
  5025. {
  5026. $listtempf=doReturnAddTempf($mr['listtempvar']);//列表模板
  5027. $texttempf=doReturnAddTempf($mr['tempvar']);//内容模板
  5028. $enter=doReturnAddTempf($mr['enter']);//录入项
  5029. $qenter=doReturnAddTempf($mr['qenter']);//投稿项
  5030. $cj=doReturnAddTempf($mr['cj']);//采集项
  5031. //表字段
  5032. $dataf=',';//副表字段
  5033. $tobrf=',';//回车字段
  5034. $dohtmlf=',';//html字段
  5035. $savetxtf='';//存文本字段
  5036. $pagef='';//分页字段
  5037. $smalltextf=',';//简介字段
  5038. $checkboxf=',';//复选框字段
  5039. $filef=',';//附件字段
  5040. $imgf=',';//图片字段
  5041. $flashf=',';//FLASH字段
  5042. $onlyf=',';//唯一字段
  5043. $linkfields='|';//关联同步
  5044. $editorf=',';//编辑器字段
  5045. $ubbeditorf=',';//UBB编辑器字段
  5046. $adddofunf='||';//增加处理函数
  5047. $editdofunf='||';//修改处理函数
  5048. $qadddofunf='||';//投稿增加处理函数
  5049. $qeditdofunf='||';//投稿修改处理函数
  5050. $fsql=$empire->query("select * from {$dbtbpre}enewsf where tid='$mr[tid]'");
  5051. while($fr=$empire->fetch($fsql))
  5052. {
  5053. if($fr['tbdataf'])
  5054. {
  5055. $dataf.=$fr['f'].',';
  5056. }
  5057. if($fr['tobr'])
  5058. {
  5059. $tobrf.=$fr['f'].',';
  5060. }
  5061. if($fr['dohtml'])
  5062. {
  5063. $dohtmlf.=$fr['f'].',';
  5064. }
  5065. if($fr['savetxt'])
  5066. {
  5067. $savetxtf=$fr['f'];
  5068. }
  5069. if($fr['ispage'])
  5070. {
  5071. $pagef=$fr['f'];
  5072. }
  5073. if($fr['issmalltext'])
  5074. {
  5075. $smalltextf.=$fr['f'].',';
  5076. }
  5077. if($fr['fform']=='checkbox')
  5078. {
  5079. $checkboxf.=$fr['f'].',';
  5080. }
  5081. if($fr['fform']=='file')
  5082. {
  5083. $filef.=$fr['f'].',';
  5084. }
  5085. if($fr['fform']=='img')
  5086. {
  5087. $imgf.=$fr['f'].',';
  5088. }
  5089. if($fr['fform']=='flash')
  5090. {
  5091. $flashf.=$fr['f'].',';
  5092. }
  5093. if($fr['isonly'])
  5094. {
  5095. $onlyf.=$fr['f'].',';
  5096. }
  5097. if(($fr['fform']=='linkfield'||$fr['fform']=='linkfieldselect')&&$fr['samedata']&&$fr['linkfieldval'])
  5098. {
  5099. $linkfields.=$fr[f].','.$fr[linkfieldtb].'.'.$fr[linkfieldval].'|';
  5100. $alllinkfields.=$fr[tbname].'.'.$fr[f].','.$fr[linkfieldtb].'.'.$fr[linkfieldval].'|';
  5101. }
  5102. if($fr['fform']=='editor')
  5103. {
  5104. $editorf.=$fr['f'].',';
  5105. }
  5106. if($fr['fform']=='ubbeditor')
  5107. {
  5108. $ubbeditorf.=$fr['f'].',';
  5109. }
  5110. if($fr['adddofun'])
  5111. {
  5112. $adddofunf.=$fr[f].'!#!'.$fr[adddofun].'||';
  5113. }
  5114. if($fr['editdofun'])
  5115. {
  5116. $editdofunf.=$fr[f].'!#!'.$fr[editdofun].'||';
  5117. }
  5118. if($fr['qadddofun'])
  5119. {
  5120. $qadddofunf.=$fr[f].'!#!'.$fr[qadddofun].'||';
  5121. }
  5122. if($fr['qeditdofun'])
  5123. {
  5124. $qeditdofunf.=$fr[f].'!#!'.$fr[qeditdofun].'||';
  5125. }
  5126. }
  5127. //表数据
  5128. $tr=$empire->fetch1("select * from {$dbtbpre}enewstable where tid='$mr[tid]'");
  5129. //字符
  5130. $mods.="\$emod_r[".$mr[mid]."]=Array('mid'=>".$mr[mid].",
  5131. 'mname'=>'".addslashes($mr[mname])."',
  5132. 'qmname'=>'".addslashes($mr[qmname])."',
  5133. 'defaulttb'=>".$tr[isdefault].",
  5134. 'datatbs'=>'".addslashes($tr[datatbs])."',
  5135. 'deftb'=>'".addslashes($tr[deftb])."',
  5136. 'enter'=>'".addslashes($enter)."',
  5137. 'qenter'=>'".addslashes($qenter)."',
  5138. 'listtempf'=>'".addslashes($listtempf)."',
  5139. 'tempf'=>'".addslashes($texttempf)."',
  5140. 'mustqenterf'=>'".addslashes($mr[mustqenterf])."',
  5141. 'listandf'=>'".addslashes($mr[listandf])."',
  5142. 'setandf'=>".$mr[setandf].",
  5143. 'searchvar'=>'".addslashes($mr[searchvar])."',
  5144. 'cj'=>'".addslashes($cj)."',
  5145. 'canaddf'=>'".addslashes($mr[canaddf])."',
  5146. 'caneditf'=>'".addslashes($mr[caneditf])."',
  5147. 'tbdataf'=>'".addslashes($dataf)."',
  5148. 'tobrf'=>'".addslashes($tobrf)."',
  5149. 'dohtmlf'=>'".addslashes($dohtmlf)."',
  5150. 'checkboxf'=>'".addslashes($checkboxf)."',
  5151. 'savetxtf'=>'".addslashes($savetxtf)."',
  5152. 'editorf'=>'".addslashes($editorf)."',
  5153. 'ubbeditorf'=>'".addslashes($ubbeditorf)."',
  5154. 'pagef'=>'".addslashes($pagef)."',
  5155. 'smalltextf'=>'".addslashes($smalltextf)."',
  5156. 'filef'=>'".addslashes($filef)."',
  5157. 'imgf'=>'".addslashes($imgf)."',
  5158. 'flashf'=>'".addslashes($flashf)."',
  5159. 'linkfields'=>'".addslashes($linkfields)."',
  5160. 'onlyf'=>'".addslashes($onlyf)."',
  5161. 'adddofunf'=>'".addslashes($adddofunf)."',
  5162. 'editdofunf'=>'".addslashes($editdofunf)."',
  5163. 'qadddofunf'=>'".addslashes($qadddofunf)."',
  5164. 'qeditdofunf'=>'".addslashes($qeditdofunf)."',
  5165. 'definfovoteid'=>".$mr[definfovoteid].",
  5166. 'orderf'=>'".addslashes($mr[orderf])."',
  5167. 'sonclass'=>'".addslashes($mr[sonclass])."',
  5168. 'tid'=>".$mr[tid].",
  5169. 'tbname'=>'".addslashes($mr[tbname])."');
  5170. ";
  5171. }
  5172. $mods="
  5173. \$emod_pubr=Array('linkfields'=>'".addslashes($alllinkfields)."');
  5174. \$etable_r=array();
  5175. ".$tables."
  5176. \$emod_r=array();
  5177. ".$mods."
  5178. ";
  5179. return $mods;
  5180. }
  5181. //会员组缓存
  5182. function GetMemberLevel(){
  5183. global $empire,$dbtbpre;
  5184. $file=ECMS_PATH."e/data/dbcache/MemberLevel.php";
  5185. $sql=$empire->query("select * from {$dbtbpre}enewsmembergroup order by groupid");
  5186. while($r=$empire->fetch($sql))
  5187. {
  5188. $levels.="\$level_r[".$r[groupid]."]=Array('groupid'=>".$r[groupid].",
  5189. 'groupname'=>'".addslashes($r[groupname])."',
  5190. 'level'=>".$r[level].",
  5191. 'checked'=>".$r[checked].",
  5192. 'favanum'=>".$r[favanum].",
  5193. 'daydown'=>".$r[daydown].",
  5194. 'msglen'=>".$r[msglen].",
  5195. 'regchecked'=>".$r[regchecked].",
  5196. 'spacestyleid'=>".$r[spacestyleid].",
  5197. 'dayaddinfo'=>".$r[dayaddinfo].",
  5198. 'infochecked'=>".$r[infochecked].",
  5199. 'msgnum'=>".$r[msgnum].");
  5200. ";
  5201. }
  5202. $levels="<?php
  5203. //level
  5204. \$level_r=array();
  5205. ".$levels."
  5206. //level
  5207. ?>";
  5208. WriteFiletext_n($file,$levels);
  5209. }
  5210. //优化缓存
  5211. function GetYh(){
  5212. global $empire,$dbtbpre;
  5213. $sql=$empire->query("select * from {$dbtbpre}enewsyh");
  5214. while($r=$empire->fetch($sql))
  5215. {
  5216. $yhs.="\$eyh_r[".$r[id]."]=Array('id'=>".$r[id].",
  5217. 'hlist'=>".$r[hlist].",
  5218. 'qlist'=>".$r[qlist].",
  5219. 'bqnew'=>".$r[bqnew].",
  5220. 'bqhot'=>".$r[bqhot].",
  5221. 'bqpl'=>".$r[bqpl].",
  5222. 'bqgood'=>".$r[bqgood].",
  5223. 'bqfirst'=>".$r[bqfirst].",
  5224. 'qmlist'=>".$r[qmlist].",
  5225. 'dobq'=>".$r[dobq].",
  5226. 'dojs'=>".$r[dojs].",
  5227. 'dosbq'=>".$r[dosbq].",
  5228. 'rehtml'=>".$r[rehtml].",
  5229. 'otherlink'=>".$r[otherlink].",
  5230. 'bqdown'=>".$r[bqdown].");
  5231. ";
  5232. }
  5233. $yhs="
  5234. ".$yhs."
  5235. ";
  5236. return $yhs;
  5237. }
  5238. //返回字段缓存
  5239. function ReturnEmptyFCache($f,$val,$isint=0){
  5240. $str='';
  5241. if($val)
  5242. {
  5243. if($isint)
  5244. {
  5245. $str="'".$f."'=>".$val.",";
  5246. }
  5247. else
  5248. {
  5249. $str="'".$f."'=>'".addslashes($val)."',";
  5250. }
  5251. }
  5252. return $str;
  5253. }
  5254. //栏目缓存
  5255. function GetClass(){
  5256. global $empire,$dbtbpre;
  5257. $fileqz=ECMS_PATH.'e/data/dbcache/';
  5258. $filename=$fileqz.'class.php';
  5259. $line=250;//每个文件存放栏目数
  5260. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsclass");
  5261. $sql=$empire->query("select * from {$dbtbpre}enewsclass");
  5262. $no=0;
  5263. $p=0;
  5264. $l="";
  5265. $mod="";
  5266. $modstr=",";
  5267. while($r=$empire->fetch($sql))
  5268. {
  5269. $no++;
  5270. $l="";
  5271. if($r[wburl])//外部栏目
  5272. {
  5273. $l=",
  5274. 'wburl'=>'".addslashes($r[wburl])."'";
  5275. }
  5276. elseif($r[islast])//终极栏目
  5277. {
  5278. //组合模型
  5279. if(empty($mod[$r[modid]]))
  5280. {
  5281. $mod[$r[modid]]="|";
  5282. }
  5283. $mod[$r[modid]].=$r[classid]."|";
  5284. if(!strstr($modstr,",".$r[modid].","))
  5285. {
  5286. $modstr.=$r[modid].",";
  5287. }
  5288. $l=",
  5289. 'lencord'=>".$r[lencord].",".ReturnEmptyFCache('link_num',$r[link_num],1)."
  5290. 'newstempid'=>".$r[newstempid].",
  5291. 'listtempid'=>".$r[listtempid].",".ReturnEmptyFCache('pltempid',$r[pltempid],1)."
  5292. ".ReturnEmptyFCache('newspath',$r[newspath],0).ReturnEmptyFCache('filename',$r[filename],1)."
  5293. 'filetype'=>'".addslashes($r[filetype])."',".ReturnEmptyFCache('ipath',$r[ipath],0)."
  5294. ".ReturnEmptyFCache('openpl',$r[openpl],1).ReturnEmptyFCache('openadd',$r[openadd],1)."
  5295. ".ReturnEmptyFCache('groupid',$r[groupid],0).ReturnEmptyFCache('filename_qz',$r[filename_qz],0)."
  5296. 'checked'=>".$r[checked].",".ReturnEmptyFCache('wfid',$r[wfid],1)."
  5297. 'bname'=>'".addslashes($r[bname])."',".ReturnEmptyFCache('cgtoinfo',$r[cgtoinfo],1)."
  5298. ".ReturnEmptyFCache('showdt',$r[showdt],1).ReturnEmptyFCache('checkpl',$r[checkpl],1)."
  5299. 'reorder'=>'".addslashes($r[reorder])."'";
  5300. }
  5301. else
  5302. {
  5303. //列表式
  5304. if($r[islist]==1&&empty($r[islast]))
  5305. {
  5306. $l=",
  5307. 'lencord'=>".$r[lencord].",
  5308. 'reorder'=>'".addslashes($r[reorder])."',
  5309. 'listtempid'=>".$r[listtempid];
  5310. }
  5311. elseif($r[listtempid])
  5312. {
  5313. $l=",
  5314. 'lencord'=>".$r[lencord].",
  5315. 'reorder'=>'".addslashes($r[reorder])."',
  5316. 'listtempid'=>".$r[listtempid];
  5317. }
  5318. }
  5319. if($r[dtlisttempid])
  5320. {
  5321. $l.=",
  5322. 'dtlisttempid'=>".$r[dtlisttempid];
  5323. }
  5324. $classes.="\$class_r[".$r[classid]."]=Array('classid'=>".$r[classid].",
  5325. 'bclassid'=>".$r[bclassid].",
  5326. 'classname'=>'".addslashes($r[classname])."',
  5327. 'sonclass'=>'".addslashes($r[sonclass])."',
  5328. 'featherclass'=>'".addslashes($r[featherclass])."',
  5329. 'islast'=>".$r[islast].",
  5330. 'classpath'=>'".addslashes($r[classpath])."',".ReturnEmptyFCache('searchtempid',$r[searchtempid],1)."
  5331. 'classtype'=>'".addslashes($r[classtype])."',".ReturnEmptyFCache('classurl',$r[classurl],0)."
  5332. ".ReturnEmptyFCache('maxnum',$r[maxnum],1).ReturnEmptyFCache('yhid',$r[yhid],1)."
  5333. 'down_num'=>".$r[down_num].",
  5334. 'online_num'=>".$r[online_num].",
  5335. 'islist'=>".$r[islist].",".ReturnEmptyFCache('listdt',$r[listdt],1)."
  5336. 'tbname'=>'".addslashes($r[tbname])."',
  5337. 'modid'=>".$r[modid].$l.");
  5338. ";
  5339. if($no%$line==0||($num%$line<>0&&$num==$no))
  5340. {
  5341. $p++;
  5342. $file="class".$p.".php";
  5343. $include.="require(ECMS_PATH.'e/data/dbcache/".$file."');\r\n";
  5344. $classes="<?php
  5345. ".$classes."?>";
  5346. WriteFiletext_n($fileqz.$file,$classes);
  5347. $classes="";
  5348. }
  5349. }
  5350. //-----专题缓存
  5351. $zsql=$empire->query("select * from {$dbtbpre}enewszt");
  5352. $zt="";
  5353. $zfile=$fileqz."ztclass.php";
  5354. while($zr=$empire->fetch($zsql))
  5355. {
  5356. $zt.="\$class_zr[".$zr[ztid]."]=Array('ztid'=>".$zr[ztid].",
  5357. 'ztname'=>'".addslashes($zr[ztname])."',
  5358. 'ztnum'=>".$zr[ztnum].",
  5359. 'listtempid'=>".$zr[listtempid].",
  5360. 'ztpath'=>'".addslashes($zr[ztpath])."',
  5361. 'zttype'=>'".addslashes($zr[zttype])."',".ReturnEmptyFCache('zturl',$zr[zturl],0)."
  5362. 'islist'=>".$zr[islist].",".ReturnEmptyFCache('maxnum',$zr[maxnum],1)."
  5363. 'reorder'=>'".addslashes($zr[reorder])."',".ReturnEmptyFCache('yhid',$zr[yhid],1)."
  5364. 'tbname'=>'".addslashes($zr[tbname])."');
  5365. ";
  5366. }
  5367. $zt="<?php
  5368. ".$zt.GetTitleTypeCache()."?>";
  5369. WriteFiletext_n($zfile,$zt);
  5370. $include.="require(ECMS_PATH.'e/data/dbcache/ztclass.php');\r\n";
  5371. $include="<?php
  5372. ".AddCheckViewCode()."
  5373. \$class_r=array();
  5374. \$class_zr=array();
  5375. \$class_tr=array();
  5376. \$eyh_r=array();
  5377. ".$include."
  5378. ".GetYh()."
  5379. ?>";
  5380. WriteFiletext_n($filename,$include);
  5381. //组合模型
  5382. $er=explode(",",$modstr);
  5383. for($i=1;$i<count($er)-1;$i++)
  5384. {
  5385. $mid=$er[$i];
  5386. $usql=$empire->query("update {$dbtbpre}enewsmod set sonclass='".$mod[$mid]."' where mid='$mid'");
  5387. }
  5388. }
  5389. //标题分类缓存
  5390. function GetTitleTypeCache(){
  5391. global $empire,$dbtbpre;
  5392. $sql=$empire->query("select typeid,tname,mid,yhid from {$dbtbpre}enewsinfotype");
  5393. while($r=$empire->fetch($sql))
  5394. {
  5395. $string.="\$class_tr[".$r[typeid]."]=Array('typeid'=>".$r[typeid].",
  5396. 'tname'=>'".addslashes($r[tname])."',
  5397. 'yhid'=>".$r[yhid].",
  5398. 'mid'=>".$r[mid].");
  5399. ";
  5400. }
  5401. return $string;
  5402. }
  5403. //全站搜索数据源缓存
  5404. function GetSearchAllTb(){
  5405. global $empire,$dbtbpre;
  5406. $file=ECMS_PATH."e/data/dbcache/SearchAllTb.php";
  5407. $sql=$empire->query("select tbname,titlefield,smalltextfield from {$dbtbpre}enewssearchall_load");
  5408. while($r=$empire->fetch($sql))
  5409. {
  5410. $tbs.="\$schalltb_r['".$r[tbname]."']=Array('tbname'=>'".addslashes($r[tbname])."',
  5411. 'titlefield'=>'".addslashes($r[titlefield])."',
  5412. 'smalltextfield'=>'".addslashes($r[smalltextfield])."');
  5413. ";
  5414. }
  5415. $tbs="<?php
  5416. //tbs
  5417. \$schalltb_r=array();
  5418. ".$tbs."
  5419. //tbs
  5420. ?>";
  5421. WriteFiletext_n($file,$tbs);
  5422. }
  5423. ?>