搜索
 找回密码
 加入

ASP&PHP更名程序...

wxm750218 2009-1-4 17:42:56 318
ASP代码
  1. <!--#include file="conn.asp"-->
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  6. <title>人物角色名称修改</title>
  7. <link href="css.css" rel="stylesheet" type="text/css" />
  8. <script language="javascript">
  9. function check1()
  10. {
  11. if (form1.username.value==''||form1.rusername.value==''||form1.strid.value==''||form1.psw.value=='')
  12. {
  13. alert('error!');
  14. return false;
  15. }
  16. else
  17. {
  18. if(form1.rusername.value.length>10)
  19. {
  20. alert('太长了!');
  21. return false;
  22. }
  23. else

  24. return true;
  25. }
  26. }
  27. </script>
  28. <%
  29. if request.Form("submit")<>"" then
  30. strid=TRIM(Request.Form("strid"))
  31. psw=TRIM(Request.Form("psw"))
  32. username=TRIM(Request.Form("username"))
  33. rusername=TRIM(Request.Form("rusername"))
  34. if len(rusername)>10 then
  35. Response.write("<script>alert('输入的角色名太长了!');window.history.back();</script>")
  36. Response.End()
  37. end if

  38. '==========
  39. Sql="Select * from Account_char where strAccountID='"& strid &"' and (strcharID1='"& username &"' or strcharID2='"& username &"' or strcharID3='"& username &"')"
  40. set ors=conn.execute(Sql)
  41. if ors.eof then
  42. Response.write("<script>alert('输入的信息不正确!');window.history.back();</script>")
  43. Response.End()
  44. end if
  45. Sql="Select * from TB_USER where strAccountid='"& strid &"' and strpasswd='"& psw &"'"
  46. set ors=conn.execute(Sql)
  47. if ors.eof then
  48. Response.write("<script>alert('输入的密码不正确!');window.history.back();</script>")
  49. Response.End()
  50. end if

  51. '===============
  52. Sql="Select * from USERDATA where struserID='" & username & "'"
  53. set ors=conn.Execute(Sql)
  54. if ors.eof then
  55. Response.write("<script>alert('输入的角色名有误!');window.history.back();</script>")
  56. Response.End()
  57. end if
  58. if ors("knights")<>0 then
  59. Response.write("<script>alert('该角色未退出骑士团!');window.history.back();</script>")
  60. Response.End()
  61. end if
  62. ors.close
  63. set ors=nothing
  64. Sql="Select * from userdata where struserID='"& rusername &"'"
  65. set ors=conn.Execute(Sql)
  66. if not ors.eof then
  67. Response.write("<script>alert('输入的新角色名已经存在!');window.history.back();</script>")
  68. Response.End()
  69. end if
  70. ors.close
  71. set ors=nothing

  72. Sql="Select * from namechanges where newname='"& username &"'"
  73. set ors=conn.Execute(Sql)
  74. if not ors.eof then
  75. Response.write("<script>alert('一个角色只能修改一次!');window.history.back();</script>")
  76. Response.End()
  77. end if
  78. ors.close
  79. set ors=nothing


  80. Sql="insert into namechanges (newname)values ('"& rusername &"')"
  81. conn.Execute(Sql)


  82. Sql="update ACCOUNT_CHAR set strCharID1='"& rusername &"' where strCharID1='"& username &"'"
  83. conn.execute(Sql)
  84. Sql="update ACCOUNT_CHAR set strCharID2='"& rusername &"' where strCharID2='"& username &"'"
  85. conn.execute(Sql)
  86. Sql="update ACCOUNT_CHAR set strCharID3='"& rusername &"' where strCharID3='"& username &"'"
  87. conn.execute(Sql)
  88. Sql="update USERDATA set strUserID='"& rusername &"' where strUserID='"& username &"'"
  89. conn.Execute(Sql)
  90. Response.write("<script>alert('角色名修改成功!');</script>")
  91. end if

  92. %>
  93. <body>
  94. <table width="100%" border="0" cellspacing="0" cellpadding="0">

  95. <tr>
  96. <td> </td>
  97. </tr>
  98. <tr>
  99. <td><form id="form1" name="form1" method="post" action="">
  100. <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
  101. <tr>
  102. <td>帐号:</td>
  103. <td><input name="strid" type="text" id="strid" /></td>
  104. </tr>
  105. <tr>
  106. <td> </td>
  107. <td> </td>
  108. </tr>
  109. <tr>
  110. <td>密码:</td>
  111. <td><input name="psw" type="text" id="psw" /></td>
  112. </tr>
  113. <tr>
  114. <td> </td>
  115. <td> </td>
  116. </tr>
  117. <tr>
  118. <td>原角色名称: </td>
  119. <td><input name="username" type="text" id="username" /></td>
  120. </tr>
  121. <tr>
  122. <td> </td>
  123. <td> </td>
  124. </tr>
  125. <tr>
  126. <td>新角色名称:</td>
  127. <td><input name="rusername" type="text" id="rusername" /></td>
  128. </tr>
  129. <tr>
  130. <td> </td>
  131. <td>(不要含有特殊符号,修改前保证人物已经下线,并没有团)</td>
  132. </tr>
  133. <tr>
  134. <td> </td>
  135. <td> </td>
  136. </tr>
  137. <tr>
  138. <td> </td>
  139. <td><input type="submit" name="Submit" value="提交" /></td>
  140. </tr>
  141. </table>
  142. </form></td>
  143. </tr>
  144. <tr>
  145. <td> </td>
  146. </tr>
  147. <tr>
  148. <td> </td>
  149. </tr>
  150. <tr>
  151. <td> </td>
  152. </tr>
  153. <tr>
  154. <td><div align="center"></div></td>
  155. </tr>
  156. </table>
  157. </body>
  158. </html>
复制代码
PHP更名:
  1. <?php
  2. include('./include/anti_inject.php');
  3. ?>
  4. <?php
  5. //$link=mssql_connect($servername,$dbuser,$dbpass);
  6. //mssql_select_db($dbname,$link);
  7. $connect = odbc_connect("$dbname", "$dbuser", "$dbpass") or die("Sql Servera baglanilamiyor, odbc_error()");
  8. ?>

  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head>
  12. <title>Knightonline-角色更名系统</title>
  13. <script language="javascript">
  14. function check1()
  15. {
  16. if (form1.username.value==''||form1.rusername.value==''||form1.strid.value==''||form1.psw.value=='')
  17. {
  18. alert('error!');
  19. return false;
  20. }
  21. else
  22. {
  23. if(form1.rusername.value.length>10)
  24. {
  25. alert('您输入的新角色名超过10个字符的限制,请重新输入!');
  26. return false;
  27. }
  28. else

  29. return true;
  30. }
  31. }
  32. </script>
  33. <?php
  34. if($_POST["Submit"]!="")
  35. {
  36. $strid=trim($_POST["strid"]);
  37. $psw=trim($_POST["psw"]);
  38. $username=trim($_POST["username"]);
  39. $rusername=trim($_POST["rusername"]);

  40. $strid = test($strid);
  41. $psw = test($psw);
  42. $username = test($username);
  43. $rusername = test($rusername);

  44. if(!($strid && $psw && $username && $rusername)){
  45.         echo "<script>alert('请不要非法注入!');</script>";
  46.         echo '<meta http-equiv="refresh" content="0" />';
  47.         die();
  48. }
  49. //必须包含中文
  50. if(!preg_match('/[^\x00-\x80]/',$rusername)){
  51.         echo "<script>alert('必须包含中文!');</script>";
  52.         echo '<meta http-equiv="refresh" content="0" />';
  53.         die();
  54. }

  55. if(strlen($rusername)>10)
  56.         {
  57.         echo "<script>alert('输入的角色名太长了!');</script>";
  58.         echo '<meta http-equiv="refresh" content="0" />';
  59.         die();
  60.         }
  61. //------------------------------------------------------------

  62. $sql="Select * from currentuser where strACCOUNTID='".$strid."' ";

  63. $result=odbc_exec($connect,$sql) or die("error");
  64. $num=odbc_fetch_row($result);

  65. if($num==true)
  66.         {
  67. echo "<script>alert('该帐号未退出游戏!');</script>";
  68. echo '<meta http-equiv="refresh" content="0" />';
  69. die();
  70. }

  71. //--------------------------------------------------------------------------
  72. $sql="Select * from Account_char where strAccountID='".$strid."' and (strcharID1='".$username."' or strcharID2='".$username."' or strcharID3='".$username."')";

  73. $result=odbc_exec($connect,$sql) or die("error");
  74. $num=odbc_fetch_row($result);

  75. if($num==false)
  76.         {
  77. echo "<script>alert('输入的信息不正确!');</script>";
  78. echo '<meta http-equiv="refresh" content="0" />';
  79. die();
  80. }
  81. $sql="Select * from TB_USER where strAccountid='".$strid."' and strpasswd='".$psw."'";

  82. $result=odbc_exec($connect,$sql) or die("error");
  83. $num=odbc_fetch_row($result);

  84. if($num==false)
  85.         {
  86. echo "<script>alert('输入的密码不正确!');</script>";
  87. echo '<meta http-equiv="refresh" content="0" />';
  88. die();
  89.         }

  90. //===============
  91. $sql="Select * from USERDATA where struserID='".$username."'";

  92. $result=odbc_exec($connect,$sql) or die("error");
  93. $num=odbc_fetch_row($result);

  94. if($num==false)
  95.         {
  96. echo "<script>alert('输入的角色名有误!');</script>";
  97. echo '<meta http-equiv="refresh" content="0" />';
  98. die();

  99.         }
  100.         $knights=odbc_result($result,"knights");

  101. if($knights!="0")
  102.         {
  103. echo "<script>alert('该角色未退出骑士团!');</script>";
  104. echo '<meta http-equiv="refresh" content="0" />';
  105. die();
  106.         }else{


  107. $sql="Select * from userdata where struserID='".$rusername."'";

  108. $result=odbc_exec($connect,$sql) or die("error");
  109. $num=odbc_fetch_row($result);

  110. $name2=odbc_result($result,"struserID");

  111. if($name2!="")
  112.         {
  113. echo "<script>alert('输入的新角色名已经存在!');</script>";
  114. echo '<meta http-equiv="refresh" content="0" />';
  115. die();

  116.         }

  117. $sql="Select * from namechanges where newname='".$username."'";
  118. $result=odbc_exec($connect,$sql) or die("error");
  119. $num=odbc_fetch_row($result);

  120. if($num==true)
  121.         {
  122. echo "<script>alert('一个角色只能修改一次!');</script>";
  123. echo '<meta http-equiv="refresh" content="0" />';
  124. die();
  125.         }
  126. $sql="insert into namechanges (newname,oldname)values ('".$rusername."','".$username."')";
  127. odbc_exec($connect,$sql);


  128. $sql="update ACCOUNT_CHAR set strCharID1='".$rusername."' where strCharID1='".$username."'";
  129. odbc_exec($connect,$sql);
  130. $sql="update ACCOUNT_CHAR set strCharID2='".$rusername."' where strCharID2='".$username."'";
  131. odbc_exec($connect,$sql);
  132. $sql="update ACCOUNT_CHAR set strCharID3='".$rusername."' where strCharID3='".$username."'";
  133. odbc_exec($connect,$sql);
  134. $sql="update USERDATA set strUserID='".$rusername."' where strUserID='".$username."'";

  135. odbc_exec($connect,$sql);

  136. echo "<script>alert('角色名修改成功!');</script>";
  137. echo '<meta http-equiv="refresh" content="0;URL=index.php" />';
  138. die();


  139.         }


  140. }
  141. ?>            
  142. <form id="form1" name="form1" method="post" action="">
  143.       <div align="right"><strong>帐号: </strong></div>
  144.     </div></td>
  145.     <td width="50%"><input type="TEXT" name="strid" maxlength="12" id="strid" /></td>
  146.   </tr>
  147.   <tr>
  148.     <td>
  149.       <div align="right"><strong>密码 : </strong></div>
  150.     </div></td>
  151.     <td><input type="PASSWORD" name="psw"  maxlength="21" id="psw"/></td>
  152.   </tr>
  153.   <tr>
  154.     <td>
  155.       <div align="right"><strong>原角色名 : </strong></div>
  156.     </div></td>
  157.         <td><input type="text" name="username"  maxlength="10" id="username"/></td>
  158.         </tr>
  159.   <tr>
  160.            <td>
  161.              <div align="right"><strong>新角色名: </strong></div>
  162.            </div></td>
  163.         <td><input type="text" name="rusername" maxlength="10" id="rusername" /></td>
  164.         </tr>
  165.   <tr>
  166.     <td> </td>
  167.     <td><input type="submit" name="Submit" value="提交" />
  168.       
  169.   <label>
  170.   <input type="reset" name="button" id="button" value="重置" />
  171.   </label></td>
  172.   </tr>
  173. </FORM>
  174.    骑士在线更名系统<br /><br />
  175.     提示:每个角色只能更名一次,请勿做无谓的尝试,新角色名必须含有中文名称<br />
  176.                更名前请确保:要修改名字的帐号已经下线,要更改的角色没有加入团
  177.                            
  178.   
复制代码
随机推荐

0 回复

高级模式
游客