xnd Posted March 31, 2006 Share Posted March 31, 2006 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:accessname2:password:accessand 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! Quote Link to comment Share on other sites More sharing options...
xnd Posted March 31, 2006 Author Share Posted March 31, 2006 ..anyone? please.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.