搜索
 找回密码
 加入

检测服务器信息---ASP和PHP代码

yale122755 2009-1-4 14:10:45 497
ASP
  1. <%@ CODEPAGE=936%>
  2. <%
  3. Session.CodePage=936
  4. Response.Charset="GBK"

  5. Dim Conn
  6. sub OpenConn()
  7.         On Error Resume next
  8.         Set Conn= Server.CreateObject("ADODB.Connection")
  9.         '链接access
  10.         'databaseurl="#KO.mdb"
  11.         'Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(databaseurl)
  12.         '链接2000
  13.         Conn.ConnectionString="Provider=SQLOLEDB;Data Source=127.0.0.1;DATABASE=kn_online;UID=kofans;pwd=kofansct"
  14.         Conn.Open
  15.         if err.number<>0 then
  16.                 response.write("<div style='font-size:11px;font-weight:bold;border:1px #ccc solid;background:#fdfdea;padding:6px 10px;text-align:left;margin-bottom:8px;color:red;'>SQL数据库连接失败!请联系管理员解决!</div>")
  17.                 response.End
  18.         end if
  19. end sub

  20. sub CloseConn()
  21.         On Error Resume Next
  22.         If IsObject(Conn) Then
  23.                 conn.close
  24.                 set conn=nothing
  25.         end if
  26. end sub

  27. openconn()


  28. '账号状态
  29. function getTotalAccount(stype)
  30.         getTotalAccount=0
  31.         if stype=1 then'统计总角色数
  32.                 sqlcnt="select count(*) as cnt from [USERDATA]"
  33.         elseif stype=2 then'统计在线人数
  34.                 sqlcnt="select count(*) as cnt from [CURRENTUSER]"
  35.         elseIf stype=3 then
  36.                 sqlcnt="select count(*) as cnt from [ACCOUNT_CHAR] where bNation=1"
  37.         elseIf stype=4 then
  38.                 sqlcnt="select count(*) as cnt from [ACCOUNT_CHAR] where bNation=2"
  39.         else'总ID数
  40.                 sqlcnt="select count(*) as cnt from [TB_USER]"
  41.         end if
  42.         set gtas=conn.execute(sqlcnt)
  43.         if not gtas.eof then        
  44.                 getTotalAccount=gtas("cnt")
  45.         end if
  46.         gtas.close:set gtas=nothing
  47. end Function

  48. '取得国王名
  49. function getKing(stype)
  50.         getKing="空缺中..."
  51.         If stype=1 Then
  52.                 sql="select byNation,strKingName from [KING_SYSTEM] where byNation=1"
  53.         Else
  54.                 sql="select byNation,strKingName from [KING_SYSTEM] where byNation=2"
  55.         End if
  56.         Set gks=conn.execute(sql)
  57.         If Not gks.eof Then
  58.                 If gks("strKingName")<>"" Then getKing=gks("strKingName")
  59.         End If
  60.         gks.close:Set gks=nothing
  61. end function
  62. %>


  63. <style>
  64. *{font-family:arial;font-size:12px;color:#000;}
  65. .listTbl{border-top:1px #777574 solid;border-left:1px #777574 solid;}
  66. .listTbl th{font-weight:bold;background:#4d4e48;}
  67. .listTbl th,
  68. .listTbl td{border-right:1px #777574 solid;border-bottom:1px #777574 solid;padding:4px;}
  69. </style>
  70. <table width="98%" border="0" cellspacing="0" cellpadding="0" class="listTbl">
  71.         <tr>
  72.                 <td width="70">服务器IP:</td>
  73.                 <td align="left"><%=Request.ServerVariables("LOCAL_ADDR")%></td>
  74.         </tr>
  75.         <tr>
  76.                 <td>玩家总数:</td>
  77.                 <td align="left"><%=getTotalAccount(0)%></td>
  78.         </tr>
  79.         <tr>
  80.                 <td>总角色数:</td>
  81.                 <td align="left"><%=getTotalAccount(1)%></td>
  82.         </tr>
  83.         <tr>
  84.                 <td>当前在线:</td>
  85.                 <td align="left"><%=getTotalAccount(2)%></td>
  86.         </tr>
  87.         <tr>
  88.                 <td>人族玩家:</td>
  89.                 <td align="left"><%=getTotalAccount(3)%></td>
  90.         </tr>
  91.         <tr>
  92.                 <td>兽族玩家:</td>
  93.                 <td align="left"><%=getTotalAccount(4)%></td>
  94.         </tr>
  95.         <tr>
  96.                 <td>人族国王:</td>
  97.                 <td align="left"><%=getKing(1)%> </td>
  98.         </tr>
  99.         <tr>
  100.                 <td>兽族国王:</td>
  101.                 <td align="left"><%=getKing(2)%> </td>
  102.         </tr>
  103. </table>

  104. GM列表<br />

  105. <table width="98%" border="0" cellspacing="0" cellpadding="0" class="listTbl">
  106.         <%
  107.         set rs=conn.execute("select strUserId,[Nation],Authority from [USERDATA] where Authority=0")
  108.         do while not rs.eof
  109.         %>
  110.         <tr>
  111.                 <td width="60" align="left"><%=rs("strUserId")%></td>
  112.                 <td align="center"><%=rs("nation")%></td>
  113.                 <td align="left" width="40">
  114.                 <%
  115.                         set ccs=conn.execute("select * from [CURRENTUSER] where strCharID='"&rs("strUserId")&"'")
  116.                         if not ccs.eof then
  117.                                 response.write("不在线")
  118.                         else
  119.                                 response.write("在线")
  120.                         end if
  121.                         ccs.close:set ccs=nothing
  122.                 %>
  123.                 </td>
  124.         </tr>
  125.         <%
  126.                 rs.movenext
  127.         loop
  128.         rs.close:set rs=nothing
  129.         %>
  130. </table>

  131. <%closeconn()%>
复制代码
PHP的
  1. <?php
  2. // rows

  3. function parth1tr()
  4. {
  5.     echo '        <tbody id="" style="">
  6. <tr align="center">';
  7. }
  8. function parth1($width,$colspan,$align)
  9. {
  10.     echo '<td class="thead" width="'.$width.'" colspan="'.$colspan.'" align="'.$align.'" height="4">';
  11. }
  12. function parth2()
  13. {
  14.     echo '</td>';
  15. }
  16. function image($img)
  17. {
  18.         echo '<IMG SRC="'. $img .'">';
  19. }
  20. function parth2tr()
  21. {
  22.     echo '
  23. </tr>';
  24. }
  25. function part1tr()
  26. {
  27.     echo '        <tbody id="" style="">
  28. <tr align="center">';
  29. }
  30. function part1($width,$colspan,$alt,$align)
  31. {
  32.     echo '<td class="alt'.$alt.'" width="'.$width.'" colspan="'.$colspan.'" align="'.$align.'">
  33. <div>';
  34. }
  35. function part2()
  36. {
  37.     echo '</div>
  38. </td>';
  39. }
  40. function part2tr()
  41. {
  42.     echo '                </tr>
  43. </tbody>';
  44. }

  45. parth1tr();        
  46. parth1('100%',3,'center');
  47. echo 'Server Info';               
  48. parth2();
  49. parth2tr();        

  50. $msconnect = odbc_connect("$dbname","$dbuser","$dbpass");

  51. $usersonline = odbc_exec($msconnect, "SELECT COUNT(*) FROM CURRENTUSER");
  52. $totusers = odbc_exec($msconnect, "SELECT COUNT(*) FROM USERDATA");
  53. $totacc = odbc_exec($msconnect, "SELECT COUNT(*) FROM TB_USER");

  54. $totalusersonline = odbc_result($usersonline, 1);
  55. $totalusers = odbc_result($totusers, 1);
  56. $totalaccounts = odbc_result($totacc, 1);

  57. part1tr();
  58. part1('50%',1,2,'center');
  59. echo 'Users Online:';
  60. part2();
  61. part1('50%',2,1,'center');
  62. echo $totalusersonline;
  63. part2();
  64. part2tr();

  65. part1('50%',1,2,'center');
  66. echo 'Total Accounts:';
  67. part2();
  68. part1('50%',2,1,'center');
  69. echo $totalaccounts;
  70. part2();
  71. part2tr();

  72. part1('50%',1,2,'center');
  73. echo 'Total Users:';
  74. part2();
  75. part1('50%',2,1,'center');
  76. echo $totalusers;
  77. part2();
  78. part2tr();

  79. parth1tr();                                                        //nations
  80. parth1('50%',1,'center');               
  81. parth2();

  82. parth1('25%',1,'center');               
  83. echo 'Count';
  84. parth2();

  85. parth1('25%',1,'center');               
  86. echo '%';
  87. parth2();
  88. parth2tr();        

  89. $totkarus = odbc_exec($msconnect, "SELECT COUNT(*) FROM USERDATA WHERE Nation=1");

  90. $totalkarus = odbc_result ($totkarus, 1);

  91. part1('50%',1,2,'center');
  92. echo 'Karus Characters:';
  93. part2();
  94. part1('25%',1,1,'center');
  95. echo $totalkarus;
  96. part2();
  97. part1('25%',1,1,'center');
  98. echo round((($totalkarus / $totalusers)*100),1);
  99. part2();
  100. part2tr();

  101. $totelmo = odbc_exec($msconnect, "SELECT COUNT(*) FROM USERDATA WHERE Nation=2");

  102. $totalelmo = odbc_result ($totelmo, 1);

  103. part1('50%',1,2,'center');
  104. echo 'El Morad Characters:';
  105. part2();
  106. part1('25%',1,1,'center');
  107. echo $totalelmo;
  108. part2();
  109. part2();
  110. part1('25%',1,1,'center');
  111. echo round((($totalelmo / $totalusers)*100),1);
  112. part2();
  113. part2tr();

  114. parth1tr();                                                //Classes
  115. parth1('50%',1,'center');        
  116. parth2();

  117. parth1('25%',1,'center');               
  118. echo 'Count';
  119. parth2();

  120. parth1('25%',1,'center');               
  121. echo '%';
  122. parth2();
  123. parth2tr();        

  124. $classes = odbc_exec($msconnect, "SELECT COUNT(Class) FROM USERDATA WHERE Class=105 OR Class=205");

  125. $totwar = odbc_result ($classes, 1);

  126. part1('50%',1,2,'center');
  127. echo 'Warriors:';
  128. part2();
  129. part1('25%',1,1,'center');
  130. echo $totwar;
  131. part2();
  132. part1('25%',1,1,'center');
  133. echo round((($totwar / $totalusers)*100), 1);
  134. part2();
  135. part2tr();

  136. $classes = odbc_exec($msconnect, "SELECT COUNT(Class) FROM USERDATA WHERE Class=109 OR Class=209");

  137. $totmage = odbc_result ($classes, 1);

  138. part1('50%',1,2,'center');
  139. echo 'Mages:';
  140. part2();
  141. part1('25%',1,1,'center');
  142. echo $totmage;
  143. part2();
  144. part1('25%',1,1,'center');
  145. echo round((($totmage / $totalusers)*100), 1);
  146. part2();
  147. part2tr();

  148. $classes = odbc_exec($msconnect, "SELECT COUNT(Class) FROM USERDATA WHERE Class=107 OR Class=207");

  149. $totrog = odbc_result ($classes, 1);

  150. part1('50%',1,2,'center');
  151. echo 'Rogues:';
  152. part2();
  153. part1('25%',1,1,'center');
  154. echo $totrog;
  155. part2();
  156. part1('25%',1,1,'center');
  157. echo round((($totrog / $totalusers)*100), 1);
  158. part2();
  159. part2tr();

  160. $classes = odbc_exec($msconnect, "SELECT COUNT(Class) FROM USERDATA WHERE Class=111 OR Class=211");

  161. $totpr = odbc_result ($classes, 1);

  162. part1('50%',1,2,'center');
  163. echo 'Priests:';
  164. part2();
  165. part1('25%',1,1,'center');
  166. echo $totpr;
  167. part2();
  168. part1('25%',1,1,'center');
  169. echo round((($totpr / $totalusers)*100), 1);
  170. part2();
  171. part2tr();

  172. part1('50%',1,2,'center');
  173. echo 'Newbies:';
  174. part2();
  175. part1('25%',1,1,'center');
  176. $totnewb = (($totalusers - ($totwar + $totmage + $totpr + $totrog)));
  177. echo $totnewb;
  178. part2();
  179. part1('25%',1,1,'center');
  180. echo round((($totnewb / $totalusers)*100), 1);
  181. part2();
  182. part2tr();





  183. ?>
复制代码
随机推荐

5 回复

ctgwglzc
2008-8-1 23:14:39
点击查看详情
原帖由 yale122755 于 2008-8-1 01:33 发表
幾八沒一個能下載稿屁?

哪个不能下
hhbwzh
2009-1-1 22:39:59
{:1_203:}
风月无边
2009-1-4 07:45:02
呵呵 貌似楼主不会下载  连接有外国网站~~
syq-wf
2009-1-4 10:06:00
楼主阳火过盛啊,不排除一些网盘上的文件过期的可能,但大部分是好的。楼主搞东西没有耐性哪行。
28085279
2009-1-4 14:10:45
我下个1097的客户端都找了我一个星期,可算是在老外那里下了个英文版的,现在还没有汉化包可用
高级模式
游客