IP Lookup Script

🚫
Exiled
Joined
May 26, 2010
Messages
116
Reaction score
65
I was bored lately and made this ip lookup script in php.
It looks up by character name, and does not show duplicates.
I think I could have done a lot more things differently and that this script could be much more organized and optimized.
PHP:
<?php
    $ip='';//IP/SERVER INSTANCE HERE(ie: FAIL\SQLEXPRESS)
    $user='';//DATABASE USER(usually sa)
    $pass='';//DATABASE PASSWORD
    if(!isset($_POST['submit'])){
    ?>
    <form action='' method="POST">
        Character:<input type='text' name='user'>
        <input type='submit' name='submit'></form>
    <?php
    }
    else{
        $link=mssql_connect($ip ,$user,$pass);
        $nub=array(';', "'", '"', '#', '--');
        $char=str_replace($nub, '', $_POST['user']);
        $getacc=mssql_query("SELECT account FROM [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] where m_szName='".$char."'");
        if(mssql_num_rows($getacc) != 1){
            die('Character does not exist');
        }
        $acc=mssql_fetch_row($getacc);
        $result=mssql_query("SELECT remoteIP FROM [LOGGING_01_DBF].[dbo].[LOG_LOGIN_TBL] where account='".$acc[0]."'");
        echo 'All RemoteIP Records for '.$char.'['.$acc[0].']<BR>';
        echo '<table border="1">'; 
        $i=1;
        $last=array();
        while ($row = mssql_fetch_assoc($result)){
            if(!in_array($row['remoteIP'],$last)){
                echo '<tr><td>'.$i.'</td>';
                echo '<td>'.$row['remoteIP'].'</td></tr>';
                $i++;
                $last[]=$row['remoteIP'];
            }
        } 
    } 
?>
 
yes it wouldn't but did I say it would? Tom, and ErlyGuard should be logging those ip addresses themselves. You can always use the %whois command in erly, forgot tom's :)
 
because the ip that send to database logging_01_dbf is 127.0.0.1 using antihack.


but very nice work pre.

---------- Post added at 04:40 AM ---------- Previous post was at 04:38 AM ----------

in toms commands to see the players ip are %get_ip <character name>
 
yes it wouldn't but did I say it would? Tom, and ErlyGuard should be logging those ip addresses themselves. You can always use the %whois command in erly, forgot tom's :)
You didn't say it wouldn't either /ridicule just thought i'd inform anyone that isn't aware of that fact.
 
Didn't I say that it could have been better? :) It is messy and uses a little more resources then it should, but it's okay :)
 
Back