Its just script to calculate kills and save to MySQL.
Table structure:
table name: kills
PHP file which saves to MySQL:Code:CREATE TABLE IF NOT EXISTS `kills` ( `time` int(11) NOT NULL, `corpseid` int(22) NOT NULL, `killerid` int(22) NOT NULL, `type` tinyint(4) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
saver.php
Sh file which reads logs:Code:<?php mysql_connect("localhost","user","pass"); //to change mysql_select_db("db"); //to change $tmp=mysql_query("SELECT `time` FROM `kills` ORDER BY `time` DESC LIMIT 1"); $last_time=mysql_fetch_row($tmp); $file = file("/home/rain/logs/kills.formatlog"); //logs folder foreach($file as $f){ $a = strpos($f, "die:roleid")+11; $time=substr($f,0,19); $time=explode(' ',$time); $tim1=explode('-',$time[0]); $tim2=explode(':',$time[1]); $tim=mktime($tim2[0], $tim2[1], $tim2[2], $tim1[1], $tim1[2], $tim1[0]); $data=substr($f,$a); $data=str_replace('type=','',$data); $data=str_replace('attacker=','',$data); $data=explode(':',$data); if($data[1]==2) $data[2]=0; if($tim>$last_time[0]) mysql_query("INSERT INTO `kills` (`time`, `corpseid`,`killerid`,`type`) VALUES ('$tim', '$data[0]','$data[2]','$data[1]')"); } ?>
rank.sh
eg for crontab:Code:#!/bin/sh cd /home/rain/logs grep -e ':die:' world2.formatlog > kills.formatlog chmod 777 kills.formatlog /opt/lampp/bin/php -f /root/saver.php >> ranklogfile.txt 2>&1 rm kills.formatlog
If u set if right, ull get all kills saved in database.Code:0 * * * * root /auto60/rank.sh
It also remembers last kill date so it works even if you remove old log files.



Reply With Quote



