yale122755 发表于 2008-8-1 01:33:29

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

ASP<%@ CODEPAGE=936%>
<%
Session.CodePage=936
Response.Charset="GBK"

Dim Conn
sub OpenConn()
      On Error Resume next
      Set Conn= Server.CreateObject("ADODB.Connection")
      '链接access
      'databaseurl="#KO.mdb"
      'Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(databaseurl)
      '链接2000
      Conn.ConnectionString="Provider=SQLOLEDB;Data Source=127.0.0.1;DATABASE=kn_online;UID=kofans;pwd=kofansct"
      Conn.Open
      if err.number<>0 then
                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>")
                response.End
      end if
end sub

sub CloseConn()
      On Error Resume Next
      If IsObject(Conn) Then
                conn.close
                set conn=nothing
      end if
end sub

openconn()


'账号状态
function getTotalAccount(stype)
      getTotalAccount=0
      if stype=1 then'统计总角色数
                sqlcnt="select count(*) as cnt from "
      elseif stype=2 then'统计在线人数
                sqlcnt="select count(*) as cnt from "
      elseIf stype=3 then
                sqlcnt="select count(*) as cnt from where bNation=1"
      elseIf stype=4 then
                sqlcnt="select count(*) as cnt from where bNation=2"
      else'总ID数
                sqlcnt="select count(*) as cnt from "
      end if
      set gtas=conn.execute(sqlcnt)
      if not gtas.eof then      
                getTotalAccount=gtas("cnt")
      end if
      gtas.close:set gtas=nothing
end Function

'取得国王名
function getKing(stype)
      getKing="空缺中..."
      If stype=1 Then
                sql="select byNation,strKingName from where byNation=1"
      Else
                sql="select byNation,strKingName from where byNation=2"
      End if
      Set gks=conn.execute(sql)
      If Not gks.eof Then
                If gks("strKingName")<>"" Then getKing=gks("strKingName")
      End If
      gks.close:Set gks=nothing
end function
%>


<style>
*{font-family:arial;font-size:12px;color:#000;}
.listTbl{border-top:1px #777574 solid;border-left:1px #777574 solid;}
.listTbl th{font-weight:bold;background:#4d4e48;}
.listTbl th,
.listTbl td{border-right:1px #777574 solid;border-bottom:1px #777574 solid;padding:4px;}
</style>
<table width="98%" border="0" cellspacing="0" cellpadding="0" class="listTbl">
      <tr>
                <td width="70">服务器IP:</td>
                <td align="left"><%=Request.ServerVariables("LOCAL_ADDR")%></td>
      </tr>
      <tr>
                <td>玩家总数:</td>
                <td align="left"><%=getTotalAccount(0)%></td>
      </tr>
      <tr>
                <td>总角色数:</td>
                <td align="left"><%=getTotalAccount(1)%></td>
      </tr>
      <tr>
                <td>当前在线:</td>
                <td align="left"><%=getTotalAccount(2)%></td>
      </tr>
      <tr>
                <td>人族玩家:</td>
                <td align="left"><%=getTotalAccount(3)%></td>
      </tr>
      <tr>
                <td>兽族玩家:</td>
                <td align="left"><%=getTotalAccount(4)%></td>
      </tr>
      <tr>
                <td>人族国王:</td>
                <td align="left"><%=getKing(1)%> </td>
      </tr>
      <tr>
                <td>兽族国王:</td>
                <td align="left"><%=getKing(2)%> </td>
      </tr>
</table>

GM列表<br />

<table width="98%" border="0" cellspacing="0" cellpadding="0" class="listTbl">
      <%
      set rs=conn.execute("select strUserId,,Authority from where Authority=0")
      do while not rs.eof
      %>
      <tr>
                <td width="60" align="left"><%=rs("strUserId")%></td>
                <td align="center"><%=rs("nation")%></td>
                <td align="left" width="40">
                <%
                        set ccs=conn.execute("select * from where strCharID='"&rs("strUserId")&"'")
                        if not ccs.eof then
                              response.write("不在线")
                        else
                              response.write("在线")
                        end if
                        ccs.close:set ccs=nothing
                %>
                </td>
      </tr>
      <%
                rs.movenext
      loop
      rs.close:set rs=nothing
      %>
</table>

<%closeconn()%>PHP的<?php
// rows

function parth1tr()
{
    echo '      <tbody id="" style="">
<tr align="center">';
}
function parth1($width,$colspan,$align)
{
    echo '<td class="thead" width="'.$width.'" colspan="'.$colspan.'" align="'.$align.'" height="4">';
}
function parth2()
{
    echo '</td>';
}
function image($img)
{
      echo '<IMG SRC="'. $img .'">';
}
function parth2tr()
{
    echo '
</tr>';
}
function part1tr()
{
    echo '      <tbody id="" style="">
<tr align="center">';
}
function part1($width,$colspan,$alt,$align)
{
    echo '<td class="alt'.$alt.'" width="'.$width.'" colspan="'.$colspan.'" align="'.$align.'">
<div>';
}
function part2()
{
    echo '</div>
</td>';
}
function part2tr()
{
    echo '                </tr>
</tbody>';
}

parth1tr();      
parth1('100%',3,'center');
echo 'Server Info';               
parth2();
parth2tr();      

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

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

$totalusersonline = odbc_result($usersonline, 1);
$totalusers = odbc_result($totusers, 1);
$totalaccounts = odbc_result($totacc, 1);

part1tr();
part1('50%',1,2,'center');
echo 'Users Online:';
part2();
part1('50%',2,1,'center');
echo $totalusersonline;
part2();
part2tr();

part1('50%',1,2,'center');
echo 'Total Accounts:';
part2();
part1('50%',2,1,'center');
echo $totalaccounts;
part2();
part2tr();

part1('50%',1,2,'center');
echo 'Total Users:';
part2();
part1('50%',2,1,'center');
echo $totalusers;
part2();
part2tr();

parth1tr();                                                      //nations
parth1('50%',1,'center');               
parth2();

parth1('25%',1,'center');               
echo 'Count';
parth2();

parth1('25%',1,'center');               
echo '%';
parth2();
parth2tr();      

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

$totalkarus = odbc_result ($totkarus, 1);

part1('50%',1,2,'center');
echo 'Karus Characters:';
part2();
part1('25%',1,1,'center');
echo $totalkarus;
part2();
part1('25%',1,1,'center');
echo round((($totalkarus / $totalusers)*100),1);
part2();
part2tr();

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

$totalelmo = odbc_result ($totelmo, 1);

part1('50%',1,2,'center');
echo 'El Morad Characters:';
part2();
part1('25%',1,1,'center');
echo $totalelmo;
part2();
part2();
part1('25%',1,1,'center');
echo round((($totalelmo / $totalusers)*100),1);
part2();
part2tr();

parth1tr();                                                //Classes
parth1('50%',1,'center');      
parth2();

parth1('25%',1,'center');               
echo 'Count';
parth2();

parth1('25%',1,'center');               
echo '%';
parth2();
parth2tr();      

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

$totwar = odbc_result ($classes, 1);

part1('50%',1,2,'center');
echo 'Warriors:';
part2();
part1('25%',1,1,'center');
echo $totwar;
part2();
part1('25%',1,1,'center');
echo round((($totwar / $totalusers)*100), 1);
part2();
part2tr();

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

$totmage = odbc_result ($classes, 1);

part1('50%',1,2,'center');
echo 'Mages:';
part2();
part1('25%',1,1,'center');
echo $totmage;
part2();
part1('25%',1,1,'center');
echo round((($totmage / $totalusers)*100), 1);
part2();
part2tr();

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

$totrog = odbc_result ($classes, 1);

part1('50%',1,2,'center');
echo 'Rogues:';
part2();
part1('25%',1,1,'center');
echo $totrog;
part2();
part1('25%',1,1,'center');
echo round((($totrog / $totalusers)*100), 1);
part2();
part2tr();

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

$totpr = odbc_result ($classes, 1);

part1('50%',1,2,'center');
echo 'Priests:';
part2();
part1('25%',1,1,'center');
echo $totpr;
part2();
part1('25%',1,1,'center');
echo round((($totpr / $totalusers)*100), 1);
part2();
part2tr();

part1('50%',1,2,'center');
echo 'Newbies:';
part2();
part1('25%',1,1,'center');
$totnewb = (($totalusers - ($totwar + $totmage + $totpr + $totrog)));
echo $totnewb;
part2();
part1('25%',1,1,'center');
echo round((($totnewb / $totalusers)*100), 1);
part2();
part2tr();





?>

ctgwglzc 发表于 2008-8-1 23:14:39

原帖由 yale122755 于 2008-8-1 01:33 发表 http://www.kofans.cn/bbs/static/image/common/back.gif
幾八沒一個能下載稿屁?
哪个不能下

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的客户端都找了我一个星期,可算是在老外那里下了个英文版的,现在还没有汉化包可用
页: [1]
查看完整版本: 检测服务器信息---ASP和PHP代码