Ignore:
Timestamp:
Aug 5, 2009, 7:30:23 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Při aktualizaci realmu neanačítat soubory databáze serveru a naopak.
  • Opraveno: Zobrazování podstránek ladících výstupů realmů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/model/mangos_debug.php

    r54 r62  
    99  {
    1010    $this->Database = $Database;
    11   }
     11  } 
    1212 
    13   function Show($ServerId)
    14   {
    15     global $System;
    16    
    17     $Output = '';
    18     $Form = new Form('DebugItem');
    19     if($Form->LoadValuesFromDatabase($_GET['Id']))
    20     {
    21         $Form->Values['Uptime'] = TimeToHumanTime($Form->Values['Uptime']);
    22         $Output .= $Form->ShowTable();
    23      
    24         $Output .= '<a href="?Action=ServerDebug&amp;Id='.$_GET['Id'].'&amp;Show=Backtrace">Backtrace</a>'.
    25           '  <a href="?Action=ServerDebug&amp;Id='.$_GET['Id'].'&amp;Show=Log">Mangos log</a>'.
    26           '  <a href="?Action=ServerDebug&amp;Id='.$_GET['Id'].'&amp;Show=Error">Console error log</a>'.
    27           '  <a href="?Action=ServerDebug&amp;Id='.$_GET['Id'].'&amp;Show=DbErrors">Database error log</a>'.
    28           '  <a href="?Action=ServerDebug&amp;Id='.$_GET['Id'].'&amp;Show=Configuration">Mangos configuration</a>'.
    29           '<hr>';
    30         if(array_key_exists('Show', $_GET))
    31         {
    32           $Show = addslashes($_GET['Show']);     
    33           switch($Show)
    34           {
    35             case 'Backtrace':
    36               $DbResult = $this->Database->select('Debug', 'Backtrace', 'Id='.$_GET['Id']);
    37               $DbRow = $DbResult->fetch_assoc();
    38               $Content = htmlspecialchars($DbRow['Backtrace']);
    39               for($I = 1; $I < $this->MaxMangosThreadCount; $I++)
    40               {
    41                 $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content);
    42                 $Content = str_replace(' '.$I.' Thread ', '<a href="#'.$I.'"">'.$I.' Thread</a>', $Content);
    43               }
    44               $Output .= '<strong>Backtrace:</strong> <br><pre>'.$Content.'</pre>';
    45               break;
    46             case 'Log':
    47               $DbResult = $this->Database->select('Debug', 'Log', 'Id='.$_GET['Id']);
    48               $DbRow = $DbResult->fetch_assoc();
    49               $Output .= '<strong>Console standard output log:</strong> <br><pre>'.htmlspecialchars($DbRow['Log']).'</pre>';
    50               break;
    51             case 'Error':
    52               $DbResult = $this->Database->select('Debug', 'ErrorLog', 'Id='.$_GET['Id']);
    53               $DbRow = $DbResult->fetch_assoc();
    54               $Output .= '<strong>Console error log:</strong> <br><pre>'.htmlspecialchars($DbRow['ErrorLog']).'</pre>';
    55               break;
    56             case 'DbErrors':
    57               $DbResult = $this->Database->select('Debug', 'DbErrors', 'Id='.$_GET['Id']);
    58               $DbRow = $DbResult->fetch_assoc();
    59               $Output .= '<strong>Database error log:</strong> <br><pre>'.htmlspecialchars($DbRow['DbErrors']).'</pre>';
    60               break;
    61             case 'Configuration':
    62               $DbResult = $this->Database->select('Debug', 'Configuration', 'Id='.$_GET['Id']);
    63               $DbRow = $DbResult->fetch_assoc();
    64               $Output .= '<strong>Mangos configuration:</strong> <br><pre>'.htmlspecialchars($DbRow['Configuration']).'</pre>';
    65               break;
    66           }
    67         }
    68     } else $Output = 'Položka nenalezena';
    69     return($Output);
    70   }
    71  
    72   function ProcessLog($ServerId)
     13  function ProcessLog()
    7314  {
    7415    global $Config;
     
    7617    $Output = '';
    7718    // Read server Id from first parameter
    78     $ServerId = $_SERVER['argv'][1];
    79     $LogDir = '../server/'.$ServerId.'/log/';
    80     $MangosConfFile = '../server/'.$ServerId.'/etc/mangosd.conf';
     19    $RealmId = $_SERVER['argv'][1];
     20    $Realm = new Realm($this->Database, $RealmId);
     21   
     22    $LogDir = '../realm/'.$RealmId.'/log/';
     23    $MangosConfFile = '../realm/'.$RealmId.'/etc/mangosd.conf';
    8124    $StdOutLogFile = $LogDir.'mangos-worldd.log';
    8225    $ErrOutLogFile = $LogDir.'mangos-worldd.err';
     
    10548 
    10649    // Get used database version from database
    107     $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_mangos`.`db_version`');
     50    $DbResult = $this->Database->query('SELECT * FROM `realm'.$RealmId.'_mangos`.`db_version`');
    10851    $DbRow = $DbResult->fetch_array();
    10952    $DbVersion = $DbRow['version'];
    110 
     53   
    11154    // Get last uptime info
    112     $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1');
     55    $DbResult = $this->Database->query('SELECT * FROM `server'.$Realm->Data['Server'].'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1');
    11356    //$Output = $this->Database->error;
    11457    $DbRow = $DbResult->fetch_array();
     
    11760
    11861    // Insert data to database
    119     $this->Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');
     62    $this->Database->query('INSERT INTO `Debug` (`Realm`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$RealmId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');
    12063    $InsertId = $this->Database->insert_id;
    12164
Note: See TracChangeset for help on using the changeset viewer.