Jump to content


Photo

A complicated script


  • Please log in to reply
1 reply to this topic

#1 xnd

xnd
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 March 2006 - 10:30 AM

Hello all!

I need a script that generates a report based on HLDS logs (half life dedicated server) and Admin List (users.ini). Basically it takes first name from users.ini, searches for it in the logs, then prints the name and the last date he connected. Then takes the same name, some thing and so on.

Admins from users.ini are listed like this:

name1:password:access
name2:password:access

and logs are like this:

L 02/08/2006 - 14:20:11: "name1<96><STEAM_ID_LAN><>" connected, address "192.168.1.2:27005"
L 02/08/2006 - 14:24:13: "name2<96><STEAM_ID_LAN><>" connected, address "192.168.1.3:27005"

Now for the tricky part:

If someone with the admin accont "name2" joins the server with "SOMETHING - name2", server recognises him as an admin and i would like the script to do the same.

Something else, i have two server with different kind of logging. For the first one, there are no special lines for admin logins in the log but for the second one, it logs a like for every admin login like this:

Login: "SOMETHING - name1<1540><VALVE_ID_LAN><>" became an admin (account "name1") (access "abcdefghijklmnopqrstu") (address "192.168.1.2")

I've tryed a script that prints the admins that didn't join the server in 30 days based on that kind of log. Maybe you can use this code and adapt it to use the kind of logging for first server (no additional log lines for admin logins):

<?php

$dir="/hlds/cstrike/addons/amxmodx/logs";
$itime=30;

if(is_dir($dir)){
    if($dh=opendir($dir)){
    while(($file=readdir($dh))!==false){
        if(is_file($dir."/".$file)){
        $fc=explode("\n", file_get_contents($dir."/".$file));
        $cc=count($fc);
        for($i=0;$i<$cc;$i++){
            $rr=$fc[$i];
            if(preg_match("/^L (.*) \- (.*)\: \[admin(.*)\.amxx\] Login\: \\\"(.*)\\\" became an admin \(account \\\"(.*)\\\"\) \(access \\\"(.*)\\\"\) \(address \\\"(.*)\\\"\)/", $rr, $m)){
                $ldate=strtotime($m[1]." ".$m[2]);
            $acc=$m[5];
            if($last[$acc]<$ldate){
                $last[$acc]=$ldate;
            }
            }
        }
        }
    }
    }
}

$ltime=time()-86400*$itime;
foreach($last as $ke => $va){
    if($ltime>$va){
    echo $ke." was last seen on ".date("Y-m-d H:i:s", $va)."\n";
    }
}
?>

Thank you so much for your time and eventual replies!

#2 xnd

xnd
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 March 2006 - 05:19 PM

..anyone? please..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users