View Single Post
djazz djazz's Avatar

JCF Member

Joined: Feb 2009

Posts: 257

djazz is OFF DA CHARTdjazz is OFF DA CHARTdjazz is OFF DA CHART

Oct 22, 2009, 05:16 AM
djazz is offline
Reply With Quote
PHP Code:
<?php

// Parse each log from playlog001.txt
$file='./playlog001.txt';
$playLog=array_slice(explode("
[["
,file_get_contents($file)),1);



$playArray=array();
$playLength=count($playArray);
foreach(
$playLog as $key => $value) {
    
    
$playLog[$key]=explode('
'
,$playLog[$key]);
    
array_pop($playLog[$key]);
    
    
$playLog[$key][0]=preg_replace("/(\w+), (\w+) (\d)(\d), (\d)(\d)(\d)(\d) at (\d)(\d):(\d)(\d):(\d)(\d)\]\]/","$1 $2 $3$4, $5$6$7$8 - $9$10:$11$12:$13$14",$playLog[$key][0]);
    
    
$playLog[$key][1]=preg_replace("/\*\*Current level: \"(.*?)\" - (.*?)/","$1 | $2",$playLog[$key][1]);
    
    
$playLog[$key][2]=preg_replace("/\*\*Next level: (.*?)/","$1",$playLog[$key][2]);
    
    
$playLog[$key][3]=preg_replace("/\*\*Game Mode: /","",$playLog[$key][3]);
    
    
$customMode=preg_replace("/\*\*Custom Mode: /","",$playLog[$key][4]);
    if(
$customMode!='OFF'){
        
$playLog[$key][3]=$customMode;
        
//echo $playLog[$key][3];
    
}
    
    
//$playLog[$key][4]=preg_replace("/\[(\d)(\d):(\d)(\d):(\d)(\d)\] >>> Game Start/","$1$2:$3$4:$5$6",$playLog[$key][5]);
    
    
$line=0;
    
$endLine=0;
    for(
$i=5;$i count($playLog[$key]);$i++) {
        if(
strchr($playLog[$key][$i],"*** Game End Stats")){
            
$playLog[$key][4]=preg_replace("/\*\*\* Game End Stats \[\[(\w+), (\w+) (\d)(\d), (\d)(\d)(\d)(\d) at (\d)(\d):(\d)(\d):(\d)(\d)\]\] \*\*\*/","$1 $2 $3$4, $5$6$7$8 - $9$10:$11$12:$13$14",$playLog[$key][$i]);
            
$line=$i+1;
        }
        if(
$line && ($i >= $line) && ($i count($playLog[$key]))) {
            
$tmp=preg_replace("/( +)  /"," | ",$playLog[$key][$i]);
            
$playLog[$key][$i]="";
            
$playLog[$key][$i-$line+5]=trim($tmp,' | 
'
);
            
$endLine=$i-6;
        }
        else {}
    }
    if(
$endLine 0) {
        
//$playLog[$key][count($playLog[$key])]="lol";
        
$playLog[$key]=array_slice($playLog[$key],0,$endLine);
    }
}

print_r($playLog);
?>
Made this some time ago, not working fully yet.
Do whatever you want with it
__________________
WebJCS 2 (new and in progress)
WebJCS 1 (old but complete)
SGIP Simple Games in Progress list
Level Packer v2 - With a GUI!
PHP Tileset Compiler