ChangeField.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. $editor=1;
  10. //验证用户
  11. $lur=is_login();
  12. $logininid=$lur['userid'];
  13. $loginin=$lur['username'];
  14. $loginrnd=$lur['rnd'];
  15. $loginlevel=$lur['groupid'];
  16. $loginadminstyleid=$lur['adminstyleid'];
  17. //ehash
  18. $ecms_hashur=hReturnEcmsHashStrAll();
  19. $tid=(int)$_GET['tid'];
  20. if($tid)
  21. {
  22. $tbwhere="tid='$tid'";
  23. $search="&tid=$tid";
  24. }
  25. else
  26. {
  27. $tbname=RepPostVar($_GET['tbname']);
  28. $tbwhere="tbname='$tbname'";
  29. $search="&tbname=$tbname";
  30. }
  31. $search.=$ecms_hashur['ehref'];
  32. $viewf=RepPostVar($_GET['viewf']);
  33. $changef=RepPostVar($_GET['changef']);
  34. if(!$viewf||!$changef)
  35. {
  36. printerror('ErrorUrl','');
  37. }
  38. //取得表名
  39. $tbr=$empire->fetch1("select tbname from {$dbtbpre}enewstable where ".$tbwhere);
  40. if(!$tbr['tbname'])
  41. {
  42. printerror('ErrorUrl','');
  43. }
  44. $tbname=$tbr['tbname'];
  45. //字段
  46. $sysf=',id,classid,onclick,newspath,keyboard,userid,username,istop,truetime,ismember,userfen,isgood,titlefont,isurl,filename,groupid,plnum,firsttitle,isqf,totaldown,havehtml,lastdotime,stb,ttid,';
  47. $viewfr=$empire->fetch1("select f,fname from {$dbtbpre}enewsf where ".$tbwhere." and f='$viewf' and tbdataf=0 limit 1");
  48. $changefr=$empire->fetch1("select f,fname from {$dbtbpre}enewsf where ".$tbwhere." and f='$changef' and tbdataf=0 limit 1");
  49. if(!$viewfr[f]&&!strstr($sysf,','.$viewf.','))
  50. {
  51. printerror('ErrorUrl','');
  52. }
  53. if(!$changefr[f]&&!strstr($sysf,','.$changef.','))
  54. {
  55. printerror('ErrorUrl','');
  56. }
  57. if(strstr($sysf,','.$viewf.','))
  58. {
  59. $viewfr[fname]=$viewf;
  60. }
  61. if(strstr($sysf,','.$changef.','))
  62. {
  63. $changefr[fname]=$changef;
  64. }
  65. $form=RepPostVar($_GET['form']);
  66. if(empty($form))
  67. {
  68. $form='add';
  69. }
  70. $field=RepPostVar($_GET['field']);
  71. $add='';
  72. //关键字
  73. $keyboard=RepPostVar2($_GET['keyboard']);
  74. if(!empty($keyboard))
  75. {
  76. $show=RepPostVar($_GET['show']);
  77. if($show==$viewf||$show==$changef)
  78. {
  79. $add=" where ".$show." like '%".$keyboard."%'";
  80. }
  81. if($show==$changef)
  82. {
  83. $searchoptionselect=' selected';
  84. }
  85. }
  86. $changeline=(int)$_GET['changeline'];
  87. if($changeline<1)
  88. {
  89. $changeline=2;
  90. }
  91. $search.="&viewf=$viewf&changef=$changef&form=$form&field=$field&show=$show&keyboard=$keyboard&changeline=$changeline";
  92. if($viewf==$changef)
  93. {
  94. $searchoption="<option value='$viewf'>$viewfr[fname]</option>";
  95. }
  96. else
  97. {
  98. $searchoption="<option value='$viewf'>$viewfr[fname]</option><option value='$changef'".$searchoptionselect.">$changefr[fname]</option>";
  99. }
  100. //分页
  101. $page=(int)$_GET['page'];
  102. $page=RepPIntvar($page);
  103. $start=0;
  104. $line=50;//每页显示条数
  105. $page_line=12;//每页显示链接数
  106. $offset=$page*$line;//总偏移量
  107. $query="select ".$viewf.",".$changef." from {$dbtbpre}ecms_".$tbname.$add;
  108. $totalquery="select count(*) as total from {$dbtbpre}ecms_".$tbname.$add;
  109. $num=$empire->gettotal($totalquery);//取得总条数
  110. $query=$query." order by id desc limit $offset,$line";
  111. $sql=$empire->query($query);
  112. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  113. ?>
  114. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  115. <html>
  116. <head>
  117. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  118. <title>选择</title>
  119. <link href="edit.css" rel="stylesheet" type="text/css">
  120. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  121. <script>
  122. function ChangeFieldVal(val)
  123. {
  124. opener.document.<?=$form?>.<?=$field?>.value=val;
  125. window.close();
  126. }
  127. </script>
  128. </head>
  129. <body>
  130. <form name="form1" id="form1" method="get" action="ChangeField.php">
  131. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  132. <?=$ecms_hashur['eform']?>
  133. <tr>
  134. <td width="70%"><div align="center">搜索:
  135. <input name="keyboard" type="text" value="<?=$keyboard?>">
  136. <select name="show">
  137. <?=$searchoption?>
  138. </select>
  139. <input type="submit" name="Submit" value="搜索">
  140. <input type=hidden name="form" value="<?=$form?>">
  141. <input type=hidden name="field" value="<?=$field?>">
  142. <input name="tid" type="hidden" id="tid" value="<?=$tid?>">
  143. <input name="tbname" type="hidden" value="<?=$tbname?>">
  144. <input name="viewf" type="hidden" id="viewf" value="<?=$viewf?>">
  145. <input name="changef" type="hidden" id="changef" value="<?=$changef?>">
  146. <input name="changeline" type="hidden" value="<?=$changeline?>">
  147. </div></td>
  148. <td width="30%">
  149. <span id="showaddclassnav"></span>
  150. <input type="button" name="Submit" value="增加信息" onclick="if(document.getElementById('addclassid').value!=0){window.open('../AddNews.php?<?=$ecms_hashur['ehref']?>&enews=AddNews&classid='+document.getElementById('addclassid').value,'','');}else{alert('请选择要增加信息的栏目');document.getElementById('addclassid').focus();}">
  151. </td>
  152. </tr>
  153. </table>
  154. </form>
  155. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  156. <tr>
  157. <td height="25" bgcolor="#FFFFFF"> <div align="center">
  158. <?php
  159. //输出
  160. $i=0;
  161. $class_text="";
  162. while($r=$empire->fetch($sql))
  163. {
  164. $i++;
  165. if(($i-1)%$changeline==0||$i==1)
  166. {
  167. $class_text.="<tr>";
  168. }
  169. $class_text.="<td align=center height=25><a href='#ecms' onclick=\"ChangeFieldVal('".ehtmlspecialchars(stripSlashes($r[$changef]))."');\" title='选择'>".stripSlashes($r[$viewf])."</a></td>";
  170. //分割
  171. if($i%$changeline==0)
  172. {
  173. $class_text.="</tr>";
  174. }
  175. }
  176. if($i<>0)
  177. {
  178. $table="<table width=100% border=0 cellpadding=3 cellspacing=0>";$table1="</table>";
  179. $ys=$changeline-$i%$changeline;
  180. $p=0;
  181. for($j=0;$j<$ys&&$ys!=$changeline;$j++)
  182. {
  183. $p=1;
  184. $class_text.="<td></td>";
  185. }
  186. if($p==1)
  187. {
  188. $class_text.="</tr>";
  189. }
  190. }
  191. $text=$table.$class_text.$table1;
  192. echo"$text";
  193. ?>
  194. </div></td>
  195. </tr>
  196. <tr>
  197. <td height="25" bgcolor="#FFFFFF" align=center>
  198. <?=$returnpage?>
  199. </td>
  200. </tr>
  201. </table>
  202. <div align="center"> <br>
  203. [<a href="#empirecms" onclick="window.close();">关闭</a>]</div>
  204. <IFRAME frameBorder="0" id="showclassnav" name="showclassnav" scrolling="no" src="../ShowClassNav.php?ecms=7<?=$ecms_hashur['ehref']?>" style="HEIGHT:0;VISIBILITY:inherit;WIDTH:0;Z-INDEX:1"></IFRAME>
  205. </body>
  206. </html>
  207. <?php
  208. db_close();
  209. $empire=null;
  210. ?>