PageRenderTime 27ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/addNewsUser.php

http://cp3046team06bj.codeplex.com
PHP | 216 lines | 180 code | 27 blank | 9 comment | 18 complexity | cfcdd8836faba0f2f73538cfad8ca9dc MD5 | raw file
  1. <?php
  2. //import global function
  3. include_once ('admin_global.php');
  4. //estimate the user's state
  5. $r=$db->Get_user_shell_check($username, $shell);
  6. //read data
  7. $qy = $db->findall('admin');
  8. while($row = $db->fetch_array($qy))
  9. {
  10. $row_array[] = $row[username];
  11. }
  12. if(isset($_POST['Submit']))
  13. {
  14. foreach($_POST as $name=>$values)
  15. {
  16. if($name == 'password') {
  17. $values = query_encode($values);
  18. $password = $values;
  19. } elseif($name == 'm_id') {
  20. $m_id = $values;
  21. } elseif($name == 'username') {
  22. if(in_array($values,$row_array)) {
  23. $db->Get_admin_msg("addNewsUser.php",'??????');
  24. } else {
  25. $username = $values;
  26. }
  27. } elseif($name == 'name') {
  28. $name2 = $values;
  29. }
  30. }
  31. $name = 'username,password,m_id,name';
  32. $values = $username . "','" . $password ."','" . $m_id . "','" .$name2;
  33. $db->insert('admin',$name,$values);
  34. $db->Get_admin_msg("addNewsUser.php");
  35. }
  36. if(!empty($_GET[deleteid])) {
  37. $sql = "DELETE FROM `admin` WHERE `id` = '$_GET[deleteid]' ";
  38. $db->query($sql);
  39. $db->Get_admin_msg("addNewsUser.php","?????");
  40. }
  41. function query_encode($sQuery){
  42. if(strlen($sQuery)==0){
  43. return '';
  44. }else{
  45. $s_tem = preg_replace("/&/i", '&', $sQuery);
  46. $s_tem = preg_replace("/&/i", '&', $s_tem);
  47. $a_tem = explode('&', $s_tem);
  48. shuffle($a_tem);
  49. $hash='id8ap';
  50. $verifyCode='';
  51. foreach($a_tem as $rs){
  52. $verifyCode.=$hash.$rs;
  53. }
  54. $verifyCode=substr(md5($verifyCode),3,7);
  55. $s_tem = implode('&', $a_tem);
  56. $s_tem='vcode='.$verifyCode.'&'.$s_tem;
  57. $s_tem = rawurlencode($s_tem);
  58. $s_tem = base64_encode($s_tem);
  59. $s_tem = strrev($s_tem);
  60. return $s_tem;
  61. }
  62. }
  63. ?>
  64. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  65. <html xmlns="http://www.w3.org/1999/xhtml">
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  68. <title>????</title>
  69. <link rel="stylesheet" rev="stylesheet" href="css/style.css" type="text/css" media="all" />
  70. <script type="text/javascript">
  71. function check()
  72. {
  73. //?????
  74. var id = document.getElementById("username");
  75. if(id.value == "")
  76. {
  77. alert("?????????");
  78. id.focus(); id.select();
  79. return false;
  80. }
  81. //????
  82. var pwd = document.getElementById("password");
  83. if(pwd.value == "")
  84. {
  85. alert("???????");
  86. pwd.focus(); pwd.select();
  87. return false;
  88. }
  89. var pwd = document.getElementById("name");
  90. if(pwd.value == "")
  91. {
  92. alert("???????");
  93. pwd.focus(); pwd.select();
  94. return false;
  95. }
  96. return true;
  97. }
  98. </script>
  99. </head>
  100. <body class="ContentBody">
  101. <form action="" method="post" onSubmit="return check()">
  102. <div class="MainDiv">
  103. <table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  104. <tr>
  105. <th class="tablestyle_title" >????</th>
  106. </tr>
  107. <tr>
  108. <td class="CPanel"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  109. <tr>
  110. <td height="40" class="font42"><table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">
  111. <tr class="CTitle" >
  112. <td height="22" colspan="7" align="center" style="font-size:16px">??????</td>
  113. </tr>
  114. <tr bgcolor="#EEEEEE">
  115. <td width="4%" align="center" height="30">??ID</td>
  116. <td width="10%" align="center">?????</td>
  117. <td width="6%" align="center">????</td>
  118. <!--<td width="6%" align="center">????</td> -->
  119. <td width="6%" align="center">?????</td>
  120. <td width="6%" align="center">??</td>
  121. </tr>
  122. <?php
  123. //???????
  124. $result = mysql_query("select id from admin");
  125. //??????? num
  126. $total = mysql_num_rows($result);
  127. //????
  128. pageft($total, 10);
  129. //
  130. if ($firstcount < 0) $firstcount = 0;
  131. $query = $db->findall("admin order by id desc limit $firstcount, $displaypg");
  132. while ($row = $db->fetch_array($query)) {
  133. ?>
  134. <tr bgcolor="#FFFFFF">
  135. <td align="center"><?php echo $row[id] ?></td>
  136. <td align="center"><?php echo $row[username];?></td>
  137. <td align="center"><?php echo $row[name];?></td>
  138. <!--<td align="center"><?php echo $row[password];?></td> -->
  139. <td align="center"><?php echo $row[m_id];?></td>
  140. <td align="center"><a href="editUser.php?edit=<?php echo $row[id] ?>">??</a>/<a href="addNewsUser.php?deleteid=<?php echo $row[id]?>">??</a></td>
  141. </tr><?php } ?>
  142. </table></td>
  143. </tr>
  144. <tr>
  145. <td class="CPanel">
  146. <table border="0" cellpadding="0" cellspacing="0" style="width:100%">
  147. <TR>
  148. <TD width="100%">
  149. <fieldset style="height:100%;">
  150. <legend>????</legend>
  151. <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
  152. <tr>
  153. <td nowrap align="right">?????</td>
  154. <td><input name="username" class="text" style="width:154px" value="" id="username"/></td>
  155. <td align="right">?????</td>
  156. <td><input name="password" class="text" style="width:154px" value="" id="password"/></td>
  157. </tr>
  158. <tr>
  159. <td align="right">?????</td>
  160. <td><input name="name" class="text" style="width:154px" value="" id="name"/></td>
  161. <td align="right">?????</td>
  162. <td>
  163. <select name="m_id">
  164. <option value="1">1(??)</option>
  165. <option value="2">2(??)</option>
  166. <option value="3">3(??)</option>
  167. </select>
  168. </td>
  169. </tr>
  170. </table>
  171. <br />
  172. </fieldset> </TD>
  173. </TR>
  174. </TABLE>
  175. </td>
  176. </tr>
  177. <TR>
  178. <TD colspan="2" align="center" height="50px">
  179. <input type="submit" name="Submit" value="??" class="button" onclick="link();"/>?
  180. <input type="button" name="Submit2" value="??" class="button" onclick="window.history.go(-1);"/></TD>
  181. </TR>
  182. </TABLE>
  183. </td>
  184. </tr>
  185. </table>
  186. </div>
  187. </form>
  188. </body>
  189. </html>