Jump to content

A complicated script


xnd

Recommended Posts

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):

[code]<?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";
    }
}
?>[/code]

Thank you so much for your time and eventual replies!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.