InfoType.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. require("../../data/dbcache/class.php");
  7. require '../'.LoadLang('pub/fun.php');
  8. $link=db_connect();
  9. $empire=new mysqlquery();
  10. $editor=1;
  11. //验证用户
  12. $lur=is_login();
  13. $logininid=$lur['userid'];
  14. $loginin=$lur['username'];
  15. $loginrnd=$lur['rnd'];
  16. $loginlevel=$lur['groupid'];
  17. $loginadminstyleid=$lur['adminstyleid'];
  18. //ehash
  19. $ecms_hashur=hReturnEcmsHashStrAll();
  20. //验证权限
  21. CheckLevel($logininid,$loginin,$classid,"infotype");
  22. //处理分类字段变量
  23. function DoPostInfoTypeVar($add){
  24. if(empty($add['ttype']))
  25. {
  26. $add['ttype']='.html';
  27. }
  28. $add['tname']=hRepPostStr($add['tname'],1);
  29. $add['mid']=(int)$add['mid'];
  30. $add['myorder']=(int)$add['myorder'];
  31. $add['yhid']=(int)$add['yhid'];
  32. $add['tnum']=(int)$add['tnum'];
  33. $add['listtempid']=(int)$add['listtempid'];
  34. $add['maxnum']=(int)$add['maxnum'];
  35. $add['reorder']=RepPostVar2($add['reorder']);
  36. $add['intro']=eaddslashes(RepPhpAspJspcode($add['intro']));
  37. $add['pagekey']=eaddslashes(RepPhpAspJspcode($add['pagekey']));
  38. $add['newline']=(int)$add['newline'];
  39. $add['hotline']=(int)$add['hotline'];
  40. $add['goodline']=(int)$add['goodline'];
  41. $add['hotplline']=(int)$add['hotplline'];
  42. $add['firstline']=(int)$add['firstline'];
  43. $add['jstempid']=(int)$add['jstempid'];
  44. $add['nrejs']=(int)$add['nrejs'];
  45. $add['listdt']=(int)$add['listdt'];
  46. $add['repagenum']=(int)$add['repagenum'];
  47. $add['ttype']=hRepPostStr($add['ttype'],1);
  48. $add['timg']=hRepPostStr($add['timg'],1);
  49. //目录
  50. $add['tpath']=trim($add['tpath']);
  51. $add['tpath']=$add['pripath'].$add['tpath'];
  52. $add['tpath']=hRepPostStr($add['tpath'],1);
  53. return $add;
  54. }
  55. //增加分类
  56. function AddInfoType($add,$userid,$username){
  57. global $empire,$dbtbpre;
  58. if(!$add[mid]||!$add[tname]||!$add[listtempid]||!$add[tpath])
  59. {
  60. printerror("EmptyInfoTypeName","history.go(-1)");
  61. }
  62. $add=DoPostInfoTypeVar($add);
  63. CheckLevel($userid,$username,$classid,"infotype");
  64. $createpath=ECMS_PATH.$add[tpath];
  65. //检测目录是否存在
  66. if(file_exists($createpath))
  67. {
  68. printerror("ReInfoTypePath","");
  69. }
  70. CreateInfoTypePath($add[tpath]);//建立目录
  71. //取得表名
  72. $ecms_fclast=time();
  73. $tabler=GetModTable($add[mid]);
  74. $tabler[tid]=(int)$tabler[tid];
  75. $sql=$empire->query("insert into {$dbtbpre}enewsinfotype(tname,mid,myorder,yhid,tnum,listtempid,tpath,ttype,maxnum,reorder,tid,tbname,timg,intro,pagekey,newline,hotline,goodline,hotplline,firstline,jstempid,nrejs,listdt,repagenum,fclast) values('$add[tname]','$add[mid]','$add[myorder]','$add[yhid]','$add[tnum]','$add[listtempid]','$add[tpath]','$add[ttype]','$add[maxnum]','$add[reorder]','$tabler[tid]','$tabler[tbname]','$add[timg]','$add[intro]','$add[pagekey]','$add[newline]','$add[hotline]','$add[goodline]','$add[hotplline]','$add[firstline]','$add[jstempid]','$add[nrejs]','$add[listdt]','$add[repagenum]','$ecms_fclast');");
  76. $typeid=$empire->lastid();
  77. //生成页面
  78. if($add[listdt]==0)
  79. {
  80. //ListHtml($typeid,$ret_r,5);
  81. }
  82. GetClass();//更新缓存
  83. if($sql)
  84. {
  85. //操作日志
  86. insert_dolog("typeid=".$typeid."<br>tname=".$add[tname]);
  87. printerror("AddInfoTypeSuccess","InfoType.php".hReturnEcmsHashStrHref2(1));
  88. }
  89. else
  90. {printerror("DbError","history.go(-1)");}
  91. }
  92. //修改分类
  93. function EditInfoType($add,$userid,$username){
  94. global $empire,$dbtbpre;
  95. $typeid=(int)$add['typeid'];
  96. if(!$typeid||!$add[mid]||!$add[tname]||!$add[listtempid]||!$add[tpath])
  97. {
  98. printerror("EmptyInfoTypeName","history.go(-1)");
  99. }
  100. $add=DoPostInfoTypeVar($add);
  101. CheckLevel($userid,$username,$classid,"infotype");
  102. //改变目录
  103. if($add[oldtpath]<>$add[tpath])
  104. {
  105. $createpath=ECMS_PATH.$add[tpath];
  106. if(file_exists($createpath))
  107. {
  108. printerror("ReInfoTypePath","");
  109. }
  110. if($add['oldpripath']==$add['pripath'])
  111. {
  112. $new=ECMS_PATH;
  113. @rename($new.$add[oldtpath],$new.$add[tpath]);//改变目录名
  114. }
  115. else
  116. {
  117. CreateInfoTypePath($add[tpath]);//建立目录
  118. }
  119. }
  120. //取得表名
  121. $ecms_fclast=time();
  122. $tabler=GetModTable($add[mid]);
  123. $tabler[tid]=(int)$tabler[tid];
  124. //修改
  125. $sql=$empire->query("update {$dbtbpre}enewsinfotype set tname='$add[tname]',mid='$add[mid]',myorder='$add[myorder]',yhid='$add[yhid]',tnum='$add[tnum]',listtempid='$add[listtempid]',tpath='$add[tpath]',ttype='$add[ttype]',maxnum='$add[maxnum]',reorder='$add[reorder]',tid='$tabler[tid]',tbname='$tabler[tbname]',timg='$add[timg]',intro='$add[intro]',pagekey='$add[pagekey]',newline='$add[newline]',hotline='$add[hotline]',goodline='$add[goodline]',hotplline='$add[hotplline]',firstline='$add[firstline]',jstempid='$add[jstempid]',nrejs='$add[nrejs]',listdt='$add[listdt]',repagenum='$add[repagenum]',fclast='$ecms_fclast' where typeid='$typeid'");
  126. GetClass();//更新缓存
  127. //生成页面
  128. if($add[listdt]==0)
  129. {
  130. ListHtml($typeid,$ret_r,5);
  131. }
  132. if($sql)
  133. {
  134. insert_dolog("typeid=".$typeid."<br>tname=".$add[tname]);//操作日志
  135. printerror("EditInfoTypeSuccess","InfoType.php?mid=$add[fmid]".hReturnEcmsHashStrHref2(0));
  136. }
  137. else
  138. {
  139. printerror("DbError","");
  140. }
  141. }
  142. //删除分类
  143. function DelInfoType($add,$userid,$username){
  144. global $empire,$dbtbpre;
  145. $typeid=(int)$add[typeid];
  146. if(!$typeid)
  147. {
  148. printerror("NotDelInfoTypeid","");
  149. }
  150. CheckLevel($userid,$username,$classid,"infotype");
  151. $r=$empire->fetch1("select * from {$dbtbpre}enewsinfotype where typeid='$typeid'");
  152. if(empty($r[typeid]))
  153. {
  154. printerror("NotDelInfoTypeid","history.go(-1)");
  155. }
  156. //删除标题分类
  157. $sql=$empire->query("delete from {$dbtbpre}enewsinfotype where typeid='$typeid'");
  158. $delpath=ECMS_PATH.$r[tpath];
  159. $del=DelPath($delpath);
  160. //moreportdo
  161. if($r['tpath'])
  162. {
  163. $eautodofname='delpath|'.$r['tpath'].'||';
  164. eAutodo_AddDo('eDelFileTT',0,0,0,0,0,$eautodofname);
  165. }
  166. //改变信息分类值
  167. $usql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]." set ttid=0 where ttid='$typeid'");
  168. $usql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]."_check set ttid=0 where ttid='$typeid'");
  169. $usql=$empire->query("update {$dbtbpre}ecms_".$r[tbname]."_doc set ttid=0 where ttid='$typeid'");
  170. GetClass();//更新缓存
  171. if($sql)
  172. {
  173. insert_dolog("typeid=".$typeid."<br>tname=".$r[tname]);//操作日志
  174. printerror("DelInfoTypeSuccess","InfoType.php?mid=$add[fmid]".hReturnEcmsHashStrHref2(0));
  175. }
  176. else
  177. {
  178. printerror("DbError","");
  179. }
  180. }
  181. //修改分类顺序
  182. function EditInfoTypeOrder($typeid,$myorder,$userid,$username){
  183. global $empire,$dbtbpre;
  184. CheckLevel($userid,$username,$classid,"infotype");
  185. for($i=0;$i<count($typeid);$i++)
  186. {
  187. $newmyorder=(int)$myorder[$i];
  188. $typeid[$i]=(int)$typeid[$i];
  189. $sql=$empire->query("update {$dbtbpre}enewsinfotype set myorder='$newmyorder' where typeid='$typeid[$i]'");
  190. }
  191. //操作日志
  192. insert_dolog("");
  193. printerror("EditInfoTypeOrderSuccess",EcmsGetReturnUrl());
  194. }
  195. $enews=$_POST['enews'];
  196. if(empty($enews))
  197. {$enews=$_GET['enews'];}
  198. if($enews)
  199. {
  200. hCheckEcmsRHash();
  201. include('../../class/delpath.php');
  202. include('../../class/copypath.php');
  203. include('../../class/t_functions.php');
  204. }
  205. if($enews=="AddInfoType")//增加分类
  206. {
  207. AddInfoType($_POST,$logininid,$loginin);
  208. }
  209. elseif($enews=="EditInfoType")//修改分类
  210. {
  211. EditInfoType($_POST,$logininid,$loginin);
  212. }
  213. elseif($enews=="DelInfoType")//删除分类
  214. {
  215. DelInfoType($_GET,$logininid,$loginin);
  216. }
  217. elseif($enews=="EditInfoTypeOrder")//修改分类排序
  218. {
  219. EditInfoTypeOrder($_POST['typeid'],$_POST['myorder'],$logininid,$loginin);
  220. }
  221. $search='';
  222. $search.=$ecms_hashur['ehref'];
  223. $page=(int)$_GET['page'];
  224. $page=RepPIntvar($page);
  225. $start=0;
  226. $line=50;//每页显示条数
  227. $page_line=12;//每页显示链接数
  228. $offset=$page*$line;//总偏移量
  229. $query="select typeid,tname,mid,myorder,tpath from {$dbtbpre}enewsinfotype";
  230. $totalquery="select count(*) as total from {$dbtbpre}enewsinfotype";
  231. $add='';
  232. $mid=(int)$_GET['mid'];
  233. if($mid)
  234. {
  235. $add=" where mid='$mid'";
  236. $search.='&mid='.$mid;
  237. }
  238. $query.=$add;
  239. $totalquery.=$add;
  240. $num=$empire->gettotal($totalquery);//取得总条数
  241. $query=$query." order by myorder,typeid limit $offset,$line";
  242. $sql=$empire->query($query);
  243. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  244. //模型
  245. $mstr="";
  246. $msql=$empire->query("select mid,mname from {$dbtbpre}enewsmod where usemod=0 order by myorder,mid");
  247. while($mr=$empire->fetch($msql))
  248. {
  249. $select="";
  250. if($mr[mid]==$mid)
  251. {
  252. $select=" selected";
  253. }
  254. $mstr.="<option value='".$mr[mid]."'".$select.">".$mr[mname]."</option>";
  255. }
  256. ?>
  257. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  258. <html>
  259. <head>
  260. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  261. <title>标题分类</title>
  262. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  263. <script>
  264. function CheckAll(form)
  265. {
  266. for (var i=0;i<form.elements.length;i++)
  267. {
  268. var e = form.elements[i];
  269. if (e.name != 'chkall')
  270. e.checked = form.chkall.checked;
  271. }
  272. }
  273. </script>
  274. </head>
  275. <body>
  276. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  277. <tr>
  278. <td width="69%" height="25">位置:<a href="InfoType.php<?=$ecms_hashur['whehref']?>">管理标题分类</a> </td>
  279. <td width="31%"><div align="right" class="emenubutton">
  280. <input type="button" name="Submit5" value="增加标题分类" onclick="self.location.href='AddInfoType.php?enews=AddInfoType<?=$ecms_hashur['ehref']?>';">
  281. </div></td>
  282. </tr>
  283. </table>
  284. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  285. <tr>
  286. <td>选择所属系统模型:
  287. <select name="mid" id="mid" onchange="window.location='InfoType.php?<?=$ecms_hashur['ehref']?>&mid='+this.options[this.selectedIndex].value;">
  288. <option value="0">不限系统模型</option>
  289. <?=$mstr?>
  290. </select> </td>
  291. </tr>
  292. </table>
  293. <br>
  294. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  295. <form name="infotypeform" method="post" action="InfoType.php" onsubmit="return confirm('确认要提交?');">
  296. <?=$ecms_hashur['form']?>
  297. <input name="fmid" type="hidden" id="fmid" value="<?=$mid?>">
  298. <tr class="header">
  299. <td width="4%"><div align="center">选择 </div></td>
  300. <td width="6%"><div align="center">ID</div></td>
  301. <td width="4%"><div align="center">排序</div></td>
  302. <td width="32%" height="25"><div align="center">分类名称</div></td>
  303. <td width="21%"><div align="center">所属系统模型</div></td>
  304. <td width="16%" height="25"><div align="center">操作</div></td>
  305. <td width="17%">操作</td>
  306. </tr>
  307. <?php
  308. while($r=$empire->fetch($sql))
  309. {
  310. $modr=$empire->fetch1("select mid,mname from {$dbtbpre}enewsmod where mid='$r[mid]'");
  311. $turl=sys_ReturnBqInfoTypeUrl($r['typeid']);
  312. ?>
  313. <tr bgcolor="#FFFFFF">
  314. <td><div align="center">
  315. <input name="classid[]" type="checkbox" id="classid[]" value="<?=$r[typeid]?>">
  316. </div></td>
  317. <td><div align="center">
  318. <?=$r[typeid]?>
  319. <input name="typeid[]" type="hidden" id="typeid[]" value="<?=$r[typeid]?>">
  320. </div></td>
  321. <td><div align="center">
  322. <input name="myorder[]" type="text" id="myorder[]" value="<?=$r[myorder]?>" size="6">
  323. </div></td>
  324. <td height="25"> <div align="center"><a href="<?=$turl?>" target="_blank">
  325. <?=$r[tname]?>
  326. </a></div></td>
  327. <td><div align="center">[<a href="InfoType.php?mid=<?=$modr[mid]?><?=$ecms_hashur['ehref']?>">
  328. <?=$modr[mname]?>
  329. </a>]</div></td>
  330. <td height="25"><a href="AddInfoType.php?enews=EditInfoType&typeid=<?=$r[typeid]?>&fmid=<?=$mid?><?=$ecms_hashur['ehref']?>">修改</a>
  331. <a href="AddInfoType.php?enews=AddInfoType&docopy=1&typeid=<?=$r[typeid]?>&fmid=<?=$mid?><?=$ecms_hashur['ehref']?>">复制</a>
  332. <a href="InfoType.php?enews=DelInfoType&typeid=<?=$r[typeid]?>&fmid=<?=$mid?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a></td>
  333. <td><a href="../ecmschtml.php?enews=ReTtHtml&typeid=<?=$r[typeid]?>&fmid=<?=$mid?><?=$ecms_hashur['href']?>">刷新</a>
  334. <a href='../ecmschtml.php?enews=ReSingleJs&doing=1&classid=<?=$r[typeid]?><?=$ecms_hashur['href']?>'>JS</a>
  335. <a href="#ecms" onclick="window.open('../view/TtUrl.php?ttid=<?=$r[typeid]?><?=$ecms_hashur['ehref']?>','','width=500,height=250');">调用</a></td>
  336. </tr>
  337. <?
  338. }
  339. ?>
  340. <tr bgcolor="#FFFFFF">
  341. <td height="25"><div align="center">
  342. <input type=checkbox name=chkall value=on onclick=CheckAll(this.form)>
  343. </div></td>
  344. <td height="25" colspan="6"> <div align="right">
  345. <input type="submit" name="Submit" value="刷新页面" onClick="document.infotypeform.enews.value='GoReListHtmlMore';document.infotypeform.action='../ecmschtml.php';">
  346. &nbsp;&nbsp;
  347. <input type="submit" name="Submit52" value="修改排序" onClick="document.infotypeform.enews.value='EditInfoTypeOrder';document.infotypeform.action='InfoType.php';">
  348. &nbsp;
  349. <input name="enews" type="hidden" id="enews" value="EditInfoTypeOrder">
  350. <input name="gore" type="hidden" id="gore" value="2">
  351. <input name="from" type="hidden" id="from" value="info/InfoType.php<?=$ecms_hashur['whehref']?>">
  352. &nbsp; <font color="#666666">(排序值越小越前面)</font></div></td>
  353. </tr>
  354. <tr bgcolor="#FFFFFF">
  355. <td height="25" colspan="7">
  356. <?=$returnpage?>
  357. </td>
  358. </tr>
  359. </form>
  360. </table>
  361. </body>
  362. </html>
  363. <?php
  364. db_close();
  365. $empire=null;
  366. ?>