$start=microtime(true);
require('db_init.php');
$server_cnt=2;
$db=0;
$actions=array(
'connect' => '" is connected (id=',
'disconnect' => ') has been disconnected',
'start_bleeding' => ') STARTS BLEEDING."',
'stop_bleeding' => ') STOPS BLEEDING."',
'kill' => ') was KILLED by ',
'hit' => ') HIT ',
'status' => ') STATUS S::',
'shot' => ') SHOT ',
'unconsciousness' => ') has fallen into unconsciousness."',
'kill_oldlog' => ') has been killed by player "',
'hard_hit' => ') has fallen into unconsciousness. HARD HIT Total S::'
);
$af=array(' was KILLED by ',' HIT ',' SHOT ');
exec('rm -fr kill1/split; mkdir kill1/split; cd kill1/split; split -a 6 -d -l 100 ../DayZServer.ADM; cd ../..');
exec('rm -fr kill2/split; mkdir kill2/split; cd kill2/split; split -a 6 -d -l 100 ../DayZServer.ADM; cd ../..');
for($svrcnt=1;$svrcnt<=$server_cnt;$svrcnt++){
$linecnt=1;
$splitfiles=scandir('kill'.$svrcnt.'/split');
asort($splitfiles);
unset($splitfiles[0]);
unset($splitfiles[1]);
$lastlog=mysql_ifr("SELECT log FROM dayzlogs WHERE server='$svrcnt' ORDER BY id DESC LIMIT 1");
$skip=true;
$set_new_date=false;
foreach($splitfiles as $logfile){
$lines=file('kill'.$svrcnt.'/split/'.$logfile);
foreach($lines as $str){
$str=ltrim(rtrim($str));
$insert=$name=$steamid=$guid=array();
$aktion=$waffe=$koerperteil=$schock=$blut=$gesundheit=$energie='';
$spieler=1;
if(strpos($str,'dminLog started on ')){
$str=str_replace('AdminLog started on ','',$str);
$tmp=explode(' ',$str);
$datum=$tmp[0];
unset($tmp);
} else if($str[8]==' ' && $str[9]=='|' && $str[10]==' '){
$tmp=explode(' | ',$str);
$zeit=$tmp[0];
$xzeit=explode(':',$zeit);
if($set_new_date==true && $xzeit[0]>=0 && $xzeit[0]<=4){
$datum=date("Y-m-d",strtotime($datum)+(3600*24));
$set_new_date=false;
}
if($xzeit[0]==23){
$set_new_date=true;
}
$tmp[1]=str_replace(array('(uid=','"Player '),array('(id=','"'),$tmp[1]);
$ids=explode('(id=',$tmp[1]);
foreach($ids as $id) if(strpos($id,')')){
$steamid[$spieler]=substr($id,0,strpos($id,')'));
$spieler++;
}
$name[1]=substr($tmp[1],strpos($tmp[1],' "')+1);
$name[1]=substr($name[1],0,strpos($name[1],'(id='));
if($name[1][0]=='"') $name[1]=substr($name[1],1,-1);
$name[1]=str_replace('" is connected','',$name[1]);
foreach($actions as $short => $long) if(strpos($str,$long)) $aktion=$short;
if($aktion=='kill_oldlog'){
$name_tmp=explode(') has been killed by player "',$tmp[1]);
$name[2]=substr($name_tmp[1],0,strrpos($name_tmp[1],'"'));
if($steamid[1]==$steamid[2]) $aktion='suicide';
}
if($aktion=='kill'){
$name_tmp=explode(') was KILLED by ',$tmp[1]);
$name[2]=substr($name_tmp[1],0,strrpos($name_tmp[1],'('));
if($steamid[1]==$steamid[2]) $aktion='suicide';
}
if($aktion=='hard_hit') $schock=substr($tmp[1],strrpos($tmp[1],'::')+2,-1);
if($aktion=='hit' || $aktion=='shot'){
$name_tmp=explode(' '.strtoupper($aktion).' ',$tmp[1]);
$name[2]=substr($name_tmp[1],0,strrpos($name_tmp[1],'('));
$waffe=substr($str,strpos($str,') by ')+5);
$waffe=substr($waffe,0,strpos($waffe,' into '));
$koerperteil=substr($str,strpos($str,' into ')+6,-2);
}
if($aktion=='status'){
$stat_tmp=explode('STATUS',$tmp[1]);
$stat_tmp2=substr($stat_tmp[1],0,-2);
$status=explode('::',$stat_tmp2);
$schock=substr($status[1],0,-2);
$blut=substr($status[2],0,-2);
$gesundheit=substr($status[3],0,-2);
$energie=$status[4];
}
}
$insert['server']=$svrcnt;
$insert['datum']=$datum;
$insert['zeit']=$zeit;
$insert['spieler1']=$spieler1=$name[1];
if($name[2]<>'') $insert['spieler2']=$name[2];
$insert['aktion']=$aktion;
$insert['spieler1_steamid']=$steamid1=$steamid[1];
if($steamid[2]<>'') $insert['spieler2_steamid']=$steamid[2];
if($waffe<>'') $insert['waffe']=$waffe;
if($koerperteil<>'') $insert['koerperteil']=$koerperteil;
if($schock<>'') $insert['schock']=$schock;
if($blut<>'') $insert['blut']=$blut;
if($gesundheit<>'') $insert['gesundheit']=$gesundheit;
if($energie<>'') $insert['energie']=$energie;
$insert['log']=$str;
if($aktion<>''){
if($skip==false) mysql_insert('dayzlogs',$insert);
}
if($str==$lastlog) $skip=false;
}
}
}
echo round((microtime(true)-$start),2).'s';
Alles anzeigen