/admin/addNewsUser.php
PHP | 216 lines | 180 code | 27 blank | 9 comment | 18 complexity | cfcdd8836faba0f2f73538cfad8ca9dc MD5 | raw file
- <?php
- //import global function
-
- include_once ('admin_global.php');
-
- //estimate the user's state
- $r=$db->Get_user_shell_check($username, $shell);
-
- //read data
- $qy = $db->findall('admin');
- while($row = $db->fetch_array($qy))
- {
- $row_array[] = $row[username];
- }
-
- if(isset($_POST['Submit']))
- {
- foreach($_POST as $name=>$values)
- {
- if($name == 'password') {
- $values = query_encode($values);
- $password = $values;
- } elseif($name == 'm_id') {
- $m_id = $values;
- } elseif($name == 'username') {
- if(in_array($values,$row_array)) {
- $db->Get_admin_msg("addNewsUser.php",'??????');
- } else {
- $username = $values;
- }
- } elseif($name == 'name') {
- $name2 = $values;
- }
-
- }
- $name = 'username,password,m_id,name';
- $values = $username . "','" . $password ."','" . $m_id . "','" .$name2;
- $db->insert('admin',$name,$values);
- $db->Get_admin_msg("addNewsUser.php");
- }
-
- if(!empty($_GET[deleteid])) {
- $sql = "DELETE FROM `admin` WHERE `id` = '$_GET[deleteid]' ";
- $db->query($sql);
- $db->Get_admin_msg("addNewsUser.php","?????");
- }
-
- function query_encode($sQuery){
- if(strlen($sQuery)==0){
- return '';
- }else{
- $s_tem = preg_replace("/&/i", '&', $sQuery);
- $s_tem = preg_replace("/&/i", '&', $s_tem);
- $a_tem = explode('&', $s_tem);
- shuffle($a_tem);
- $hash='id8ap';
- $verifyCode='';
- foreach($a_tem as $rs){
- $verifyCode.=$hash.$rs;
- }
- $verifyCode=substr(md5($verifyCode),3,7);
- $s_tem = implode('&', $a_tem);
- $s_tem='vcode='.$verifyCode.'&'.$s_tem;
- $s_tem = rawurlencode($s_tem);
- $s_tem = base64_encode($s_tem);
- $s_tem = strrev($s_tem);
- return $s_tem;
- }
- }
-
-
-
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>????</title>
- <link rel="stylesheet" rev="stylesheet" href="css/style.css" type="text/css" media="all" />
- <script type="text/javascript">
-
- function check()
- {
- //?????
- var id = document.getElementById("username");
- if(id.value == "")
- {
- alert("?????????");
- id.focus(); id.select();
- return false;
- }
- //????
- var pwd = document.getElementById("password");
- if(pwd.value == "")
- {
- alert("???????");
- pwd.focus(); pwd.select();
- return false;
- }
-
- var pwd = document.getElementById("name");
- if(pwd.value == "")
- {
- alert("???????");
- pwd.focus(); pwd.select();
- return false;
- }
- return true;
- }
-
- </script>
- </head>
-
- <body class="ContentBody">
- <form action="" method="post" onSubmit="return check()">
- <div class="MainDiv">
- <table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
- <tr>
- <th class="tablestyle_title" >????</th>
- </tr>
-
- <tr>
- <td class="CPanel"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td height="40" class="font42"><table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">
- <tr class="CTitle" >
- <td height="22" colspan="7" align="center" style="font-size:16px">??????</td>
- </tr>
- <tr bgcolor="#EEEEEE">
- <td width="4%" align="center" height="30">??ID</td>
- <td width="10%" align="center">?????</td>
- <td width="6%" align="center">????</td>
- <!--<td width="6%" align="center">????</td> -->
- <td width="6%" align="center">?????</td>
- <td width="6%" align="center">??</td>
- </tr>
- <?php
- //???????
- $result = mysql_query("select id from admin");
- //??????? num
- $total = mysql_num_rows($result);
- //????
- pageft($total, 10);
- //
- if ($firstcount < 0) $firstcount = 0;
- $query = $db->findall("admin order by id desc limit $firstcount, $displaypg");
-
- while ($row = $db->fetch_array($query)) {
- ?>
- <tr bgcolor="#FFFFFF">
- <td align="center"><?php echo $row[id] ?></td>
- <td align="center"><?php echo $row[username];?></td>
- <td align="center"><?php echo $row[name];?></td>
- <!--<td align="center"><?php echo $row[password];?></td> -->
- <td align="center"><?php echo $row[m_id];?></td>
- <td align="center"><a href="editUser.php?edit=<?php echo $row[id] ?>">??</a>/<a href="addNewsUser.php?deleteid=<?php echo $row[id]?>">??</a></td>
- </tr><?php } ?>
- </table></td>
- </tr>
-
- <tr>
- <td class="CPanel">
-
- <table border="0" cellpadding="0" cellspacing="0" style="width:100%">
-
- <TR>
- <TD width="100%">
- <fieldset style="height:100%;">
- <legend>????</legend>
- <table border="0" cellpadding="2" cellspacing="1" style="width:100%">
- <tr>
- <td nowrap align="right">?????</td>
- <td><input name="username" class="text" style="width:154px" value="" id="username"/></td>
- <td align="right">?????</td>
- <td><input name="password" class="text" style="width:154px" value="" id="password"/></td>
- </tr>
- <tr>
- <td align="right">?????</td>
- <td><input name="name" class="text" style="width:154px" value="" id="name"/></td>
- <td align="right">?????</td>
- <td>
- <select name="m_id">
- <option value="1">1(??)</option>
- <option value="2">2(??)</option>
- <option value="3">3(??)</option>
- </select>
- </td>
- </tr>
- </table>
- <br />
- </fieldset> </TD>
- </TR>
-
- </TABLE>
-
-
- </td>
- </tr>
- <TR>
- <TD colspan="2" align="center" height="50px">
- <input type="submit" name="Submit" value="??" class="button" onclick="link();"/>?
- <input type="button" name="Submit2" value="??" class="button" onclick="window.history.go(-1);"/></TD>
- </TR>
- </TABLE>
- </td>
- </tr>
-
-
-
-
- </table>
-
- </div>
- </form>
- </body>
- </html>