CreateCache.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../class/connect.php");
  4. require("../class/db_sql.php");
  5. require("../class/functions.php");
  6. require LoadLang("pub/fun.php");
  7. $link=db_connect();
  8. $empire=new mysqlquery();
  9. //验证用户
  10. $lur=is_login();
  11. $logininid=(int)$lur['userid'];
  12. $loginin=$lur['username'];
  13. $loginrnd=$lur['rnd'];
  14. $loginlevel=$lur['groupid'];
  15. $loginadminstyleid=$lur['adminstyleid'];
  16. //ehash
  17. $ecms_hashur=hReturnEcmsHashStrAll();
  18. //显示无限级栏目缓存
  19. function CreateClassCache($bclassid,$exp,$expjs,$expmodjs,$adminclass,$doall,$mid,$addminfocid,$oldmid,$oldaddminfocid,$userid){
  20. global $empire,$fun_r,$dbtbpre,$public_r;
  21. if(empty($bclassid))
  22. {
  23. $bclassid=0;
  24. $exp='';
  25. $expjs='|-';
  26. $expmodjs='|-';
  27. }
  28. else
  29. {
  30. $exp='&nbsp;&nbsp;&nbsp;'.$exp;
  31. $expjs='&nbsp;&nbsp;'.$expjs;
  32. $expmodjs="&nbsp;&nbsp;".$expmodjs;
  33. }
  34. $sql=$empire->query("select classid,classname,bclassid,islast,classpath,classurl,listdt,sonclass,tbname,modid,myorder,onclick,openadd,wburl from {$dbtbpre}enewsclass where bclassid='$bclassid' order by myorder,classid");
  35. $returnr['listclass']='';
  36. $returnr['listclasshidden']='';
  37. $returnr['listenews']='';
  38. $returnr['userenews']='';
  39. $returnr['jsstr']='';
  40. $returnr['jsmod']='';
  41. $returnr['oldjsmod']='';
  42. $returnr['userjs']='';
  43. $num=$empire->num1($sql);
  44. if($num==0)
  45. {
  46. return $returnr;
  47. }
  48. $returnr['listenews'].='<table border=0 cellspacing=0 cellpadding=0>';
  49. $returnr['userenews'].='<table border=0 cellspacing=0 cellpadding=0>';
  50. $i=1;
  51. while($r=$empire->fetch($sql))
  52. {
  53. $classurl=sys_ReturnBqClassUrl($r);
  54. //------ 管理栏目页面 ------
  55. $divonclick="";
  56. $start_tbody="";
  57. $end_tbody="";
  58. $start_tbody1="";
  59. $docinfo="";
  60. $classinfotype='';
  61. //终级栏目
  62. if($r[islast])
  63. {
  64. $img="<a href='#e' onclick=addi(".$r[classid].")><img src='../data/images/txt.gif' border=0></a>";
  65. $bgcolor="#ffffff";
  66. $renewshtml=" <a href='#e' onclick=renews(".$r[classid].",'".$r[tbname]."')>".$fun_r['news']."</a> ";
  67. $docinfo=" <a href='#e' onclick=docinfo(".$r[classid].")>归档</a>";
  68. $classinfotype=" <a href='#e' onclick=ttc(".$r[classid].")>分类</a>";
  69. }
  70. else
  71. {
  72. $img="<img src='../data/images/dir.gif'>";
  73. if(empty($r[bclassid]))
  74. {
  75. $bgcolor="#DBEAF5";
  76. $divonclick=" onMouseUp='turnit(classdiv".$r[classid].");' style='CURSOR:hand'";
  77. $start_tbody="<tbody id='classdiv".$r[classid]."'>";
  78. $end_tbody="</tbody>";
  79. //缩
  80. $start_tbody1="<tbody id='classdiv".$r[classid]."' style='display:none'>";
  81. }
  82. else
  83. {$bgcolor="#ffffff";}
  84. $renewshtml=" <a href='#e' onclick=renews(".$r[classid].",'".$r[tbname]."')>".$fun_r['news']."</a> ";
  85. }
  86. //外部栏目
  87. $classname=$r[classname];
  88. if($r['wburl'])
  89. {
  90. $classname="<font color='#666666'>".$classname."&nbsp;(外部)</font>";
  91. }
  92. $onelistclass="<tr bgcolor='".$bgcolor."' height=25><td><input type=text name=myorder[] value=".$r[myorder]." size=2><input type=hidden name=classid[] value=".$r[classid]."></td><td".$divonclick.">".$exp.$img."</td><td align=center>".$r[classid]."</td><td><input type=checkbox name=reclassid[] value=".$r[classid]."> <a href='".$classurl."' target=_blank>".$classname."</a></td><td align=center>".$r[onclick]."</td><td><a href='#e' onclick=editc(".$r[classid].")>".$fun_r['edit']."</a> <a href='#e' onclick=copyc(".$r[classid].")>".$fun_r['copyclass']."</a> <a href='#e' onclick=delc(".$r[classid].")>".$fun_r['del']."</a></td><td><a href='#e' onclick=relist(".$r[classid].")>".$fun_r['re']."</a>".$renewshtml."<a href='#e' onclick=rejs(".$r[classid].")>JS</a> <a href='#e' onclick=tvurl(".$r[classid].")>调用</a>".$classinfotype.$docinfo."</td></tr>";
  93. $returnr['listclass'].=$onelistclass;
  94. $returnr['listclasshidden'].=$onelistclass;
  95. if(empty($r['wburl']))
  96. {
  97. //------ 管理信息页面 ------
  98. //链接地址
  99. $infoclassurl='';
  100. //终级栏目
  101. if($r[islast])
  102. {
  103. //最后一个子栏目
  104. if($i==$num)
  105. {$menutype="file1";}
  106. else
  107. {$menutype="file";}
  108. $infoclassname="<a onclick=tourl($r[bclassid],$r[classid]) onmouseout=chft(this,0,$r[classid]) onmouseover=chft(this,1,$r[classid]) oncontextmenu=ShRM(this,".$r[bclassid].",".$r[classid].",'".$infoclassurl."',1)>".$r[classname]."</a>";
  109. $onmouseup="";
  110. }
  111. else
  112. {
  113. //最后一个大栏目
  114. if($i==$num)
  115. {
  116. $menutype="menu3";
  117. $listtype="list1";
  118. $onmouseup="chengstate('".$r[classid]."')";
  119. }
  120. else
  121. {
  122. $menutype="menu1";
  123. $listtype="list";
  124. $onmouseup="chengstate('".$r[classid]."')";
  125. }
  126. $infoclassname="<a onmouseout=chft(this,0,$r[classid]) onmouseover=chft(this,1,$r[classid]) oncontextmenu=ShRM(this,".$r[bclassid].",".$r[classid].",'".$infoclassurl."',0)>".$r[classname]."</a>";
  127. }
  128. $returnr['listenews'].='<tr><td id="pr'.$r[classid].'" class="'.$menutype.'" onclick="'.$onmouseup.'">'.$infoclassname.'</td></tr>';
  129. //JS颜色
  130. if($r[islast])
  131. {
  132. $jscolor=" style='background:#".$public_r['chclasscolor']."'";
  133. }
  134. else
  135. {
  136. $jscolor="";
  137. }
  138. //------ 权限栏目显示 ------
  139. $havelevel=0;
  140. if($userid&&empty($doall))
  141. {
  142. if(CheckHaveInClassid($r,$adminclass))
  143. {
  144. $returnr['userenews'].='<tr><td id="pr'.$r[classid].'" class="'.$menutype.'" onclick="'.$onmouseup.'">'.$infoclassname.'</td></tr>';
  145. $returnr['userjs'].="<option value='".$r[classid]."'".$jscolor.">".$expjs.$r[classname]."</option>";
  146. $havelevel=1;
  147. }
  148. }
  149. //------ JS显示 ------
  150. $returnr['jsstr'].="<option value='".$r[classid]."'".$jscolor.">".$expjs.$r[classname]."</option>";
  151. //------ 投稿 ------
  152. $haveadd=0;
  153. if($mid)
  154. {
  155. if($r[openadd]==0&&CheckHaveInClassid($r,$addminfocid))
  156. {
  157. $returnr['jsmod'].="<option value='".$r[classid]."'".$jscolor.">".$expmodjs.$r[classname]."</option>";
  158. $haveadd=1;
  159. }
  160. }
  161. $oldhaveadd=0;
  162. if($oldmid)
  163. {
  164. if($r[openadd]==0&&CheckHaveInClassid($r,$oldaddminfocid))
  165. {
  166. $returnr['oldjsmod'].="<option value='".$r[classid]."'".$jscolor.">".$expmodjs.$r[classname]."</option>";
  167. $oldhaveadd=1;
  168. }
  169. }
  170. }
  171. //取得子栏目
  172. if(empty($r[islast]))
  173. {
  174. $retr=CreateClassCache($r['classid'],$exp,$expjs,$expmodjs,$adminclass,$doall,$mid,$addminfocid,$oldmid,$oldaddminfocid,$userid);
  175. $returnr['listclass'].=$start_tbody.$retr['listclass'].$end_tbody;
  176. $returnr['listclasshidden'].=$start_tbody1.$retr['listclasshidden'].$end_tbody;
  177. if(empty($r['wburl']))
  178. {
  179. $returnr['listenews'].='<tr id="item'.$r[classid].'" style="display:none"><td class="'.$listtype.'">'.$retr['listenews'].'</td></tr>';
  180. if($havelevel)
  181. {
  182. $returnr['userenews'].='<tr id="item'.$r[classid].'" style="display:none"><td class="'.$listtype.'">'.$retr['userenews'].'</td></tr>';
  183. $returnr['userjs'].=$retr['userjs'];
  184. }
  185. $returnr['jsstr'].=$retr['jsstr'];
  186. if($haveadd)
  187. {
  188. $returnr['jsmod'].=$retr['jsmod'];
  189. }
  190. if($oldhaveadd)
  191. {
  192. $returnr['oldjsmod'].=$retr['oldjsmod'];
  193. }
  194. }
  195. }
  196. $i+=1;
  197. }
  198. $returnr['listenews'].='</table>';
  199. $returnr['userenews'].='</table>';
  200. return $returnr;
  201. }
  202. //验证缓存
  203. function HaveNavClassCache($where){
  204. global $empire,$dbtbpre;
  205. if(empty($where))
  206. {
  207. return '';
  208. }
  209. $navcachenum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsclassnavcache where ".$where." limit 1");
  210. return $navcachenum;
  211. }
  212. //写入缓存
  213. function InsertNavClassCache($navtype,$userid,$modid){
  214. global $empire,$dbtbpre;
  215. $userid=(int)$userid;
  216. $modid=(int)$modid;
  217. $empire->query("insert into {$dbtbpre}enewsclassnavcache(navtype,userid,modid) values('$navtype','$userid','$modid');");
  218. }
  219. $enews=RepPostVar($_GET['enews']);
  220. $mess=RepPostVar($_GET['mess']);
  221. $ecmstourl=RepPostStrUrl($_GET['ecmstourl']);
  222. if(!$mess)
  223. {
  224. db_close();
  225. $empire=null;
  226. exit();
  227. }
  228. if(!$enews)
  229. {
  230. printerror($mess,$ecmstourl);
  231. }
  232. $uid=(int)$_GET['uid'];
  233. if(empty($uid))
  234. {
  235. $thisuid=$logininid;
  236. }
  237. else
  238. {
  239. $thisuid=$uid;
  240. }
  241. $user_r=$empire->fetch1("select adminclass,groupid from {$dbtbpre}enewsuser where userid='$thisuid'");
  242. if(!$user_r['groupid'])
  243. {
  244. db_close();
  245. $empire=null;
  246. exit();
  247. }
  248. //用户组权限
  249. $gr=$empire->fetch1("select doall from {$dbtbpre}enewsgroup where groupid='$user_r[groupid]'");
  250. //用户
  251. $userid=$thisuid;
  252. if($gr['doall'])
  253. {
  254. $userid=0;
  255. }
  256. //模型
  257. $mid=(int)$_GET['mid'];
  258. if($mid&&$emod_r[$mid]['mid'])
  259. {
  260. $modr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='$mid'");
  261. $addminfocid=$modr['sonclass'];
  262. }
  263. else
  264. {
  265. $mid=0;
  266. $addminfocid='';
  267. }
  268. //模型2
  269. $oldmid=(int)$_GET['oldmid'];
  270. if($oldmid&&$emod_r[$oldmid]['mid'])
  271. {
  272. $oldmodr=$empire->fetch1("select sonclass from {$dbtbpre}enewsmod where mid='$oldmid'");
  273. $oldaddminfocid=$oldmodr['sonclass'];
  274. }
  275. else
  276. {
  277. $oldmid=0;
  278. $oldaddminfocid='';
  279. }
  280. $cacher=CreateClassCache(0,'','','',$user_r['adminclass'],$gr['doall'],$mid,$addminfocid,$oldmid,$oldaddminfocid,$userid);
  281. $enews=','.$enews.',';
  282. //------ 管理栏目缓存 ------
  283. if(stristr($enews,',doclass,'))
  284. {
  285. if(!HaveNavClassCache("navtype='listclass'"))
  286. {
  287. $classfcfile='../data/fc/ListClass0.php';
  288. $classfcfile2='../data/fc/ListClass1.php';
  289. WriteFiletext($classfcfile,AddCheckViewTempCode().$cacher['listclass']);
  290. WriteFiletext($classfcfile2,AddCheckViewTempCode().$cacher['listclasshidden']);
  291. InsertNavClassCache('listclass',0,0);
  292. }
  293. }
  294. //------ 管理信息缓存 ------
  295. $notrecordword="您还未添加栏目,<br><a href='#ecms' onclick=goaddclass()><u><b>点击这里</b></u></a>进行添加操作";
  296. if(stristr($enews,',doinfo,'))
  297. {
  298. if(!HaveNavClassCache("navtype='listenews'"))
  299. {
  300. if(empty($cacher['listenews']))
  301. {
  302. $cacher['listenews']=$notrecordword;
  303. }
  304. $infofcfile='../data/fc/ListEnews.php';
  305. WriteFiletext($infofcfile,AddCheckViewTempCode().$cacher['listenews']);
  306. InsertNavClassCache('listenews',0,0);
  307. }
  308. }
  309. //用户信息缓存
  310. if(stristr($enews,',douserinfo,'))
  311. {
  312. if($userid)
  313. {
  314. if(!HaveNavClassCache("navtype='userenews' and userid='$userid'"))
  315. {
  316. $userinfofcfile='../data/fc/ListEnews'.$userid.'.php';
  317. WriteFiletext($userinfofcfile,AddCheckViewTempCode().$cacher['userenews']);
  318. $userinfojsfile='../data/fc/userclass'.$userid.'.js';
  319. WriteFiletext_n($userinfojsfile,"document.write(\"".addslashes($cacher['userjs'])."\");");
  320. InsertNavClassCache('userenews',$userid,0);
  321. }
  322. }
  323. }
  324. //------ JS ------
  325. if(stristr($enews,',doinfo,'))
  326. {
  327. if(!HaveNavClassCache("navtype='jsclass'"))
  328. {
  329. $jsfile="../data/fc/cmsclass.js";
  330. $search_jsfile="../data/fc/searchclass.js";
  331. $search_jsstr=str_replace(" style='background:#".$public_r['chclasscolor']."'","",$cacher['jsstr']);
  332. WriteFiletext_n($jsfile,"document.write(\"".addslashes($cacher['jsstr'])."\");");
  333. WriteFiletext_n($search_jsfile,"document.write(\"".addslashes($search_jsstr)."\");");
  334. InsertNavClassCache('jsclass',0,0);
  335. }
  336. }
  337. //------ 投稿JS ------
  338. if(stristr($enews,',domod,'))
  339. {
  340. if($mid)
  341. {
  342. if(!HaveNavClassCache("navtype='modclass' and modid='$mid'"))
  343. {
  344. $addinfofile="../../d/js/js/addinfo".$mid.".js";
  345. $addnews_class="document.write(\"".addslashes($cacher['jsmod'])."\");";
  346. WriteFiletext_n($addinfofile,$addnews_class);
  347. InsertNavClassCache('modclass',0,$mid);
  348. }
  349. }
  350. if($oldmid)
  351. {
  352. if(!HaveNavClassCache("navtype='modclass' and modid='$oldmid'"))
  353. {
  354. $oldaddinfofile="../../d/js/js/addinfo".$oldmid.".js";
  355. $oldaddnews_class="document.write(\"".addslashes($cacher['oldjsmod'])."\");";
  356. WriteFiletext_n($oldaddinfofile,$oldaddnews_class);
  357. InsertNavClassCache('modclass',0,$oldmid);
  358. }
  359. }
  360. }
  361. //------ 更新模板 ------
  362. if(stristr($enews,',dostemp,'))
  363. {
  364. GetSearch();
  365. }
  366. printerror($mess,$ecmstourl);
  367. //echo"<meta http-equiv=\"refresh\" content=\"0;url=$ecmstourl\">缓存更新完毕,正在返回......";
  368. ?>