Пример #1
0
/**
 * Regex Tester
 *
 * @param   string   $type       type
 * @param   string   $regex      regex
 * @param   array    $match      matchers
 * @param   array    $types      typers
 * @param   array    $logs       logs
 * @param   boolean  $headers    display header
 * @param   string   $multiline  multiline field
 *
 * @return  string               html
 */
function test($type, $regex, $match, $types, $logs, $headers = true, $multiline = '')
{
    $r = '<h4>' . $type . '</h4>';
    $r .= '<pre>';
    $r .= $headers === true ? '<strong>Regex</strong>: ' . $regex . "\n" : '';
    $r .= $headers === true ? '<strong>Log  </strong>: ' . $logs . "\n" : '';
    $r .= $headers === true ? "\n" : '';
    $logs = array_reverse(explode("\n", $logs));
    $rank = 0;
    $size = count(strval(count($logs))) + 2;
    $blan = str_pad('', $size);
    $buffer = array();
    foreach ($logs as $log) {
        $tokens = LogParser::parseLine($regex, $match, $log, $types);
        if (is_array($tokens)) {
            $rank++;
            $disp = $headers ? '' : str_pad('#' . $rank, $size);
            $maxlength = 0;
            foreach ($tokens as $token => $value) {
                $maxlength = max($maxlength, strlen($token));
            }
            $r .= $headers ? '' : '<strong>' . $disp . $log . "</strong>\n";
            foreach ($tokens as $token => $value) {
                if (substr($token, 0, 3) === 'pml') {
                    continue;
                }
                $r .= $blan . '<strong>' . str_pad($token, $maxlength) . '</strong>: ' . $value;
                if ($token === $multiline) {
                    if (count($buffer) > 0) {
                        $buffer = array_reverse($buffer);
                        foreach ($buffer as $append) {
                            $r .= "\n" . $blan . str_pad('', $maxlength) . '  ' . $append;
                        }
                    }
                }
                $r .= "\n";
            }
            $r .= "\n";
            $buffer = array();
        } else {
            $buffer[] = $log;
        }
    }
    $r .= '</pre>';
    return $r;
}
Пример #2
0
$v = new stdClass();
$v->combat = false;
$v->day = 1;
$v->date = 0;
$v->timestamp = 0;
$v->ts = null;
$v->ts_last = -1;
$v->combat_actions = array(2, 3, 4, 10, 15, 16, 19, 22, 23, 26);
//Log and line stuff.
$v->line = 0;
$v->byte_count = 0;
$v->killed_bosses = array();
$params = array();
$encounter = null;
//Now we need to parse it.
while ($parser->parseLine(true)) {
    $v->line++;
    $v->byte_count += $parser->getBytes();
    if ($v->line % 100000 == 0) {
        $params['milestone'][] = $v->byte_count;
    }
    //Check if time rolled over.
    $v->ts = $parser->getSeconds();
    if ($v->ts < $v->ts_last) {
        $v->date += 86400;
    }
    $v->timestamp = $v->date + ($v->ts_last = $v->ts);
    //We want to see if this is a permitted action to start combat.
    $is_action = in_array($parser->type_id, $v->combat_actions);
    //Starting condition to get us in combat.
    if (!$v->combat && $is_action) {
Пример #3
0
 /**
  *
  */
 function getUserData($log_id, $lower, $upper, $name)
 {
     //Return data if it is already loaded.
     if (isset($this->data)) {
         return $this->data;
     }
     //Initialize stuff.
     $data =& $this->data;
     $parser =& $this->parser;
     //Init vars.
     $parser = new LogParser($log_id, $lower, $upper, $this->db);
     $user_id = $parser->getID($name);
     //Start up the data class.
     $data = new stdClass();
     $data->abilities = array('dmg' => array(), 'heal' => array(), 'taken' => array());
     $data->deaths = array();
     $data->totals = array('dmg' => 0, 'heal' => 0, 'taken' => 0, 'heal_modified' => 0);
     //Loop through the contents and prepare data.
     while ($status = $parser->parseLine()) {
         //Skip misread lines.
         if ($status != LogParser::SUCCESS) {
             continue;
         }
         //Load up a timestamp.
         $timestamp = $parser->getSeconds();
         //Set the initial value for the timer if it hasn't started.
         if (!isset($data->l)) {
             $data->l = $timestamp;
             $data->timestamp = $timestamp;
         }
         //Check if this is even the person we want.
         if ($parser->origin_id != $user_id && $parser->target_id != $user_id || in_array($parser->attack_id, $this->global_filter)) {
             continue;
         }
         //Capture the data types.
         switch ($parser->type_id) {
             //Damage |3=hit,4=suffers,10=miss,15=dodge,16=parry,19=resist,23=crit|
             case 3:
             case 4:
             case 10:
             case 15:
             case 16:
             case 19:
             case 23:
                 //Check if this is a player.
                 $is_player = $parser->origin_id == $user_id;
                 if ($is_player) {
                     $attack =& $data->abilities['dmg'][$parser->attack_name];
                 } else {
                     $attack =& $data->abilities['taken'][$parser->attack_name];
                 }
                 //Set the variable if necessary.
                 if (!isset($attack)) {
                     $attack = array('total' => 0, 'cast' => 0, 'max' => 0, 'crits' => 0, 'misses' => 0, 'id' => $parser->attack_id);
                     //If this isn't a player we want to add more accurate details.
                     if (!$is_player) {
                         $attack += array('parry' => 0, 'dodge' => 0, 'origin' => $parser->origin_name, 'block_count' => 0, 'block_total' => 0);
                     }
                 }
                 $total = $is_player ? $parser->damage + $parser->absorbed : $parser->damage;
                 $attack['total'] += $total;
                 $attack['cast'] += 1;
                 $attack['max'] = $attack['max'] > $total ? $attack['max'] : $total;
                 //Calculating minimum.
                 if (isset($attack['min'])) {
                     $attack['min'] = $attack['min'] < $total ? $attack['min'] : $total;
                 } else {
                     $attack['min'] = $total;
                 }
                 $attack['crits'] += $parser->type_id == 23 ? 1 : 0;
                 $attack['misses'] += in_array($parser->type_id, array(10, 15, 16, 19)) ? 1 : 0;
                 //Log parry and dodges.
                 if (!$is_player) {
                     switch ($parser->type_id) {
                         case 15:
                             $attack['dodge']++;
                             break;
                         case 16:
                             $attack['parry']++;
                             break;
                     }
                 }
                 //Log some block details.
                 if (!$is_player && $parser->blocked > 0) {
                     $attack['block_count']++;
                     $attack['block_total'] += $parser->blocked;
                 }
                 $data->totals[$is_player ? 'dmg' : 'taken'] += $total;
                 if (!$is_player) {
                     //Logging a hostile action against the player.
                     $this->logAction($parser->type_id == 23 ? 'crits' : $parser->type_id == 3 ? 'hits' : 'damages');
                     //We want to find the deathblow if the character is going to die.
                     if ($parser->overkill > 0 || $this->is_dying) {
                         $this->processDeath();
                     }
                 }
                 break;
                 //Healing |5=heal,28=crit|
             //Healing |5=heal,28=crit|
             case 5:
             case 28:
                 //Dave: For some reason disarm attacks appear in here so there's an extra statement in the if.
                 if ($parser->origin_id == $user_id && ($parser->overheal != 0 || $parser->damage != 0)) {
                     //Filter out stuff we don't want.
                     if (in_array($parser->attack_id, $this->heal_filter)) {
                         continue;
                     }
                     $heal =& $data->abilities['heal'][$parser->attack_name];
                     if (!isset($heal)) {
                         $heal = array('total' => 0, 'total_modified' => 0, 'cast' => 0, 'max' => 0, 'min' => 0, 'crits' => 0, 'overheal' => 0, 'id' => $parser->attack_id);
                     }
                     $heal['total'] += $parser->damage;
                     $heal['total_modified'] += $parser->damage + $parser->overheal;
                     $heal['cast'] += 1;
                     $heal['max'] = $heal['max'] > $parser->damage ? $heal['max'] : $parser->damage;
                     $heal['min'] = isset($heal['min']) ? $heal['min'] < $parser->damage ? $heal['min'] : $parser->damage : $parser->damage;
                     $heal['crits'] += $parser->type_id == 28 ? 1 : 0;
                     $heal['overheal'] += $parser->overheal;
                     $data->totals['heal'] += $parser->damage;
                     $data->totals['heal_modified'] += $parser->damage + $parser->overheal;
                 } else {
                     //Logging an incoming heal to the player.
                     $this->logAction('heals');
                 }
                 break;
                 //Deaths |11=slain,12=died|
             //Deaths |11=slain,12=died|
             case 11:
             case 12:
                 if ($parser->type_id == 11 && $parser->origin_id != $user_id || $parser->type_id == 12) {
                     $this->is_dying = true;
                 }
                 break;
         }
     }
     //Calculate the final length.
     $data->l = $parser->getSeconds() - $data->l;
     //Uset unneccesary data and sort.
     unset($this->parser, $this->actions);
     uasort($data->abilities['dmg'], array('Data_model', 'sort'));
     uasort($data->abilities['heal'], array('Data_model', 'sort'));
     uasort($data->abilities['taken'], array('Data_model', 'sort'));
     return $data;
 }