[RELEASE]Previous connections info php script (2 designs)

12/10/2009 09:03 Zombe#1
I made 2 designs because I was bored.


The 1st one just spits out the array using print_r(), making it a lot faster to display all info then the 2nd, if you have a big server.

Design 1: ([Only registered and activated users can see links. Click Here To Register...])
PHP Code:
<?php
/* ----------{Zombe's connection info retrieval page}---------- */
/* -----------------------{Design nr.1}------------------------ */

$MSSQLserverIP 'localhost'// IP goes here
$MSSQLusername 'sa'// MSSQL username goes here
$MSSQLpassword 'password'// MSSQL password goes here

//        Don't edit below if you don't know what you are doing.
ob_start();
echo(
'<title>Previous Connections Info</title>');
$link mssql_connect ("$MSSQLserverIP""$MSSQLusername""$MSSQLpassword") or die('<hr><b>Failed to connect to the database.</b>');

$a=mssql_query("SELECT * FROM character.dbo.CHAR_CONNLOG_KEY",$link);
echo
'<pre><hr>';
while(
$b=mssql_fetch_array($a))
{
    foreach(
array_keys($b) as $c)
    {
        if (
is_int($c))
        {
            unset(
$b[$c]);
        }
    }
    if(isset(
$b[conn_ip])) $b[conn_ip] = long2ip(hexdec(bin2hex($b[conn_ip])));
    
print_r($b);
    echo
'<hr>';
}
echo
'</pre>';
ob_end_flush();
?>

And the second one is my classic layout using a table, like my old designs.

Design 2: ([Only registered and activated users can see links. Click Here To Register...])
PHP Code:
<?php
/* ----------{Zombe's connection info retrieval page}---------- */
/* -----------------------{Design nr.2}------------------------ */

$MSSQLserverIP 'localhost'// IP goes here
$MSSQLusername 'sa'// MSSQL username goes here
$MSSQLpassword 'password'// MSSQL password goes here

//        Don't edit below if you don't know what you are doing.
ob_start();
echo(
'<title>Previous Connections Info</title>');
$link mssql_connect ("$MSSQLserverIP""$MSSQLusername""$MSSQLpassword") or die('<hr><b>Failed to connect to the database.</b>');

$a=mssql_query("SELECT * FROM character.dbo.CHAR_CONNLOG_KEY",$link);

echo(
"
    <center>
    <b><font size = 5>Previous Connections Info:</font></b>
    <br><table border='1'><p>&nbsp
    <tr>
    <td align='center'><b>Nr.</b></td>
    <td align='center'><b>Connection no</b></td>
    <td align='center'><b>Character no</b></td>
    <td align='center'><b>User no</b></td>
    <td align='center'><b>Login time</b></td>
    <td align='center'><b>Logout time</b></td>
    <td align='center'><b>Connected from</b></td>
    </tr>
"
);
while(
$b=mssql_fetch_array($a))
{
    
$nr++;
    
$ip long2ip(hexdec(bin2hex($b[conn_ip])));
    echo(
"
        <tr>
        <td align='center'>
$nr</td>
        <td align='center'>
$b[conn_no]</td>
        <td align='center'>
$b[character_no]</td>
        <td align='center'>
$b[user_no]</td>
        <td align='center'>
$b[login_time]</td>
        <td align='center'>
$b[logout_time]</td>
        <td align='center'>
$ip</td>
        </tr>
    "
);
}
echo
'</table></center>';
ob_end_flush();
?>
Don't forget to change the database info according to your server.

Enjoy.
12/10/2009 16:28 Nosferatu.#2
nice work :)
01/13/2010 23:16 l2zeo#3
thx.!
good job :-)