File : index.php
Last modification : 2016-05-27 21:31:08
Source :

<?php 

require_once dirname(__FILE__) . '/ryzomapi_lite.php';

//$color = array(1 => "FFFF|F99F", 2 => "FF4F|F44F", 3 => "97FF|BBFF", 4 => "FCCF|9EEF", 5 => "BE9F|4F4F", 6 => "AFBF", 7 => "F80F"); 
$channame = array(=> "SAY"=> "SHOUT"=> "TEAM"=> "REGION"=> "GUILD"=> "DYN0|DYN1|DYN2"=> "UNIVERSE"); 

$ig = (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Ryzom') !== false) || (isset($_REQUEST['ig']) && strpos($_REQUEST['ig'], 'test') !== false )|| (isset($_POST['ig']) && $_POST['ig'] );
if (isset(
$_REQUEST['lang'])) {
    
// ingame language
    
$lang $_REQUEST['lang'];
} else if (isset(
$_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    
// outgame language
    
$lang substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 02);
} else {
    
$lang '';
}
if (!
in_array($lang, array('en''fr'))) {
    
// fallback
    
$lang 'en';
}



if (isset(
$_COOKIE['channame']) && count($_COOKIE['channame'])) 

    foreach(
$_COOKIE['channame'] as $id => $col
    { 
        if (
trim($col)) $channame[$id] = trim($col); 
    } 


if (isset(
$_COOKIE['nom'])) $nom trim($_COOKIE['nom']); 

if (
$_POST["log"]) 

    
header("Content-type: text/plain; charset=UTF-8"); 

    
setcookie("nom"trim($_POST['nom']), time()+60*60*24*365); 


    if (isset(
$_POST['channame']) && count($_POST['channame'])) 
    { 
        foreach(
$_POST['channame'] as $id => $col
        { 
            
setcookie("channame[$id]"trim($col), time()+60*60*24*365); 

            
$channame[$id] = trim($col); 
        } 
    } 
    
    
$chans '';
    if (isset(
$_POST['modes']) && count($_POST['modes'])) 
    { 
        foreach(
$_POST['modes'] as $id => $mode
        { 
            if(
$chans$chans .= '|'
            
$chans .= $channame[$id]; 
        } 
    } 

    
    
$log str_replace(array("&#8217;""\r"), array("'"""), stripslashes($_POST["log"])); 

    if (isset(
$_POST['nom']) && $_POST['nom']) $log str_replace(array("Vous dites""Vous criez""You say""You shout"), array($_POST['nom']." dit"$_POST['nom']." crie"$_POST['nom']." says"$_POST['nom']." shout"), $log); 

    
//$log = str_replace(array(" says :", " shout :"), array(" dit :", " crie :"), $log); 

    
if ($_POST["full"]) 
    { 
        
$log preg_replace(array("`DBG [ 0-9a-z]+ client_ryzom_rd.exe net_manager.cpp [0-9]+ : <impulseChat> Received CHAT :`""` with category sys`"), array("*"""), $log); 
    } 

    
$rows explode("\n"$log); 

    
$result "";
    
    if (
count($rows)) foreach($rows as $row
    { 
        if (
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \(($chans)\) \* @\{(CC3F|EE3F)\}(.+): @\{([0-9A-F]{4})\}(.+)`"$row$regs)) 
        { 
            if (!isset(
$_POST['hrp']) || (isset($_POST['hrp']) && $_POST['hrp'] && substr($regs[5], 11) != '(')) $result.= trim($regs[3])." : ".trim($regs[5])."\n"
        } 
        else if (
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \([A-Z0-9/]+\) \* @\{[0-9A-F]{4}\}(.+): @\{[0-9A-F]{4}\}(.+)`"$row$regs)) 
        { 
        } 
        else if (
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \([A-Z0-9/]+\) \* (.+) : (.+)`"$row$regs)) 
        { 
            if (!isset(
$_POST['hrp']) || (isset($_POST['hrp']) && $_POST['hrp'] && substr($regs[2], 01) != '(')) $result.= $regs[1]." : ".$regs[2]."\n"
        } 
        else if (
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \([A-Z0-9/]+\) \* \"`"$row$regs)) 
        { 
        } 
        else if (
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \(([A-Z0-9/]+)\) \* (.+)`"$row$regs)) 
        { 
            if (!isset(
$_POST['emotes']) && $regs[1] == "SAY/EMT"$result.= $regs[2]."\n"
            if (!isset(
$_POST['system']) && substr$regs[1], 0) === "SYSTEM"$result.= $regs[2]."\n"
        } 
        else if (!
preg_match("`[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} (INF|WRN|DBG)`"$row$regs)) 
        { 
            
$result.= $row."\n"
        } 
    }

    if(
$lang == 'fr')
        
$content 'Résultat de l\'analyse :<br/> <textarea  rows="50" cols="100" name="log">'.$result.'</textarea>';
    else{
        
$content 'Analysis result :<br/> <textarea  rows="50" cols="100" name="log">'.$result.'</textarea>';
    }

elseif(
$ig){
    if(
$lang == 'fr'){
        
$content .= '<p>Malheureusement, le script n\'est pas accessible en jeu mais uniquement sur votre navigateur web, le client crash facilement si le log est un peu trop long.</p>';
    }else{
        
$content .= '<p>Unfortunately, this script does not work in-game but only on your web browser, the game client crashes if the chatlog is just a bit too big.</p>';
    }
}else{ 
    
$content '';
    if(
$lang == 'fr'){
        
$content .= 'Ce script accepte uniquement les logs obtenus avec la commande /chatLog et permet de filtrer les dialogues que vous désirez conserver ainsi qu\'enlever les informations superflues. 
        <ul>
        <li>Vous pouvez choisir ce que vous souhaitez garder.</li>
        <li>Vous pouvez remplacer "Vous" par le nom de votre personnage, en l\'indiquant dans la case correspondante.</li>
        <li>Vous pouvez retirer tous les propos HRP.</li> 
        <li>Vous pouvez choisir des canaux complémentaires (factions,event, etc) en séparants leurs id par des | dans le champ prévu à cet effet.</li>
        </ul>
        <p>Vos préférences seront enregistrées dans des cookies. </p> 
        <form action="index.php" method="post" id="log"> 
        <label for="log">Log :</label><br/>
        <textarea rows="20" cols="100" name="log"></textarea><br /> 
        Garder uniquement :<br /> 
        <input type="checkbox" name="modes[1]" value="1" checked="checked" id="chk1"/> <label for="chk1">Alentours</label><br /> 
        <input type="checkbox" name="modes[2]" value="1" checked="checked" id="chk2" /> <label for="chk2">Cris alentours</label><br /> 
        <input type="checkbox" name="modes[3]" value="1" checked="checked" id="chk3" /> <label for="chk3">Equipe</label><br /> 
        <input type="checkbox" name="modes[4]" value="1" checked="checked" id="chk4" /> <label for="chk4">Région</label><br /> 
        <input type="checkbox" name="modes[5]" value="1" checked="checked" id="chk5" /> <label for="chk5">Guilde</label><br />  
        <input type="checkbox" name="modes[7]" value="1" checked="checked" id="chk6" /> <label for="chk6">Univers</label><br /> 
        <input type="checkbox" name="modes[6]" value="1" checked="checked" id="chk7" /> <label for="chk7">Faction et autres canaux</label>&nbsp;/&nbsp;<label for="inp1">Codes</label>&nbsp;<input id="inp1" type="text" name="channame[6]" value="'
.$channame[6].'"/><br />
        <label for="inp2">Nom de votre perso</label> : <input type="text" name="nom" value="'
.$nom.'" id="inp2" /><br /> 
        <input type="checkbox" name="hrp" value="1" checked="checked" id="chk8" /> <label for="chk8">Supprimer les propos HRP (entre parenthèses)</label><br /> 
        <input type="checkbox" name="system" value="1" checked="checked" id="chk9" /> <label for="chk9">Supprimer les informations système (combat/achats/craft)</label><br /> 
        <input type="checkbox" name="emotes" value="1" id="chk10" /> <label for="chk10">Supprimer les emotes</label><br /> 
        <input type="checkbox" name="full" value="1" id="chk11"/> <label for="chk11">Fichier log.log ou client.log</label><br /> 
        <input type="submit" value="Valider" /> 
        </form><p><a href="logs_src.php">Script sources</a></p>
            <p>Script original : &copy; 1993-'
.date("Y").' <a href="http://kervala.net">Kervala</a> <br/>
            Modifications : &copy; 2016-'
.date("Y").' <a href="http://ryzom.natara.fr">Natara</a></p>';        
    }else{
        
$content 'This script accepts only logs obtained thanks to the /chatlog function. It will let you filter dialogs you want to keep and remove unwanted informations. 
        <ul>
        <li>You could choose what you want to keep.</li>
        <li>You can replace "You" by the name of your character by writing in the "name" field.</li>
        <li>You may remove every OOC comments.</li> 
        <li>You could add complementary channel (faction, event...) by putting their id and separate them with | in the "Codes" field.</li>
        </ul>
        <p>Your preferences might be stocked in a cookie.</p>
        <form action="index.php" method="post"> 
        <label for="log">Log :</label><br/>
        <textarea rows="20" cols="100" id="log" name="log"></textarea><br /> 
        Keep only :<br /> 
        <input type="checkbox" name="modes[1]" value="1" checked="checked" id="chk1"/> <label for="chk1">Say</label><br /> 
        <input type="checkbox" name="modes[2]" value="1" checked="checked" id="chk2" /> <label for="chk2">Shout</label><br /> 
        <input type="checkbox" name="modes[3]" value="1" checked="checked" id="chk3" /> <label for="chk3">Team</label><br /> 
        <input type="checkbox" name="modes[4]" value="1" checked="checked" id="chk4" /> <label for="chk4">Region</label><br /> 
        <input type="checkbox" name="modes[5]" value="1" checked="checked" id="chk5" /> <label for="chk5">Guild</label><br />  
        <input type="checkbox" name="modes[7]" value="1" checked="checked" id="chk6" /> <label for="chk6">Universe</label><br /> 
        <input type="checkbox" name="modes[6]" value="1" checked="checked" id="chk7" /> <label for="chk7">Faction and other labels</label>&nbsp;/&nbsp;<label for="inp1">Codes</label>&nbsp;<input id="inp1" type="text" name="channame[6]" value="'
.$channame[6].'"/><br />
        <label for="inp2">Your character name</label> : <input type="text" name="nom" value="'
.$nom.'" id="inp2" /><br /> 
        <input type="checkbox" name="hrp" value="1" checked="checked" id="chk8" /> <label for="chk8">Delete OOC comment (between brackets)</label><br /> 
        <input type="checkbox" name="system" value="1" checked="checked" id="chk9" /> <label for="chk9">Delete system informations (fight/buying/craft)</label><br /> 
        <input type="checkbox" name="emotes" value="1" id="chk10" /> <label for="chk10">Delete emotes</label><br /> 
        <input type="checkbox" name="full" value="1" id="chk11"/> <label for="chk11">log.log or client.log file</label><br /> 
        <input type="submit" value="Validate" /> 
        </form> <p><a href="logs_src.php">Script sources</a></p>
            <p>Original script : &copy; 1993-'
.date("Y").' <a href="http://kervala.net">Kervala</a> <br/>
            Updated by : &copy; 2016-'
.date("Y").' <a href="http://ryzom.natara.fr">Natara</a></p>';
        
    }
}

header('Content-Type: text/html; charset=utf-8');

$tpl '
<!doctype html>
<html>
    <head>
        <title>Ryzom ChatLog decoder</title>
        <link type="text/css" href="http://api.ryzom.com/data/css/ryzom_ui.css" rel="stylesheet" media="all" />
        <style type="text/css">
            html, body {
                width: 95%;
                margin: 10px auto;
            }
            body {
                background-color: #000010;
            }
            input{max-width:250px;}
            a{color: #FF1}
            a:hover{color:#FF8}
        </style>
    </head>    
    <body>
    {content}
    </body>
</html>
'
;

$tplIG '<!doctype html>
<html>
    <head>
        <title>Ryzom ChatLog decoder</title>
        <style type="text/css">
            input{max-width:250px;}
            textarea{max-width:600px;min-height:200px;}
            a{color: #FF1}
            a:hover{color:#FF8}
        </style>
    </head>
    <body style="background-image: url(ryzom.png);">
    {content}
    </body>
</html>'
;

$links = array(
  array(
'href' => 'http://www.ryzom.com/''text' => 'Ryzom website'),
  array(
'href' => 'http://app.ryzom.com/''text' => 'App zone'),
);

if(!
$ig){
    echo 
strtr(
        
$tpl,
        array(
            
'{content}' => ryzom_render_window('Ryzom ChatLog decoder'$content$links),
        )
    ); 
}else{
    echo 
strtr(
        
$tplIG,
        array(
            
'{content}' =>  $content,
        )
    ); 
}


?> 

File : logs_src.php
Last modification : 2016-05-22 00:41:46
Source :

<?php 

print "<"."?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n"
print 
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
print 
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">\n"
print 
"<head><title>Logs sources by Kervala</title></head>\n"
print 
"<body>\n"

$files = array("index.php""logs_src.php"); 

function 
display_src($file

    print 
"<p>\n"
    print 
"<b>File :</b> <a href=\"$file\">$file</a><br/>\n"
    print 
"<b>Last modification :</b> ".date("Y-m-d H:i:s"filemtime($file))."<br/>\n"
    print 
"<b>Source :</b></p>\n"
    print 
"<div style=\"font-size: 12px;\">\n"
    
highlight_string(file_get_contents($file)); 
    print 
"</div>\n"


if (
count($files) && $files) foreach($files as $filedisplay_src($file); 

print 
"</body>\n"
print 
"</html>\n"

?>