Changeset 62


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ů.
Location:
trunk/www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/index.php

    r59 r62  
    142142        $Output .= $EmulatorView->AddFinish();
    143143      } else     
    144       if($_GET['Action'] == 'ServerDebug')
    145       {
    146         $DebugView = new DebugView($this->Database, $this->System);
    147         $Output .= $DebugView->Item();
    148       } else     
    149144      if($_GET['Action'] == 'ClientList')
    150145      {
     
    157152        $Output .= $BackupView->ItemList();
    158153      } else     
     154      if($_GET['Action'] == 'DebugView')
     155      {
     156        $DebugView = new DebugView($this->Database, $this->System);
     157        $Output .= $DebugView->Item();
     158      } else     
    159159      if($_GET['Action'] == 'DebugList')
    160160      {
  • 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
  • trunk/www/model/realm.php

    r59 r62  
    9090    $CommandList = array_merge($CommandList, array(
    9191      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < database/'.$Database['Id'].'/'.$Database['SourceFileName'],
    92       'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql',
    93       'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql',
    94       'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql',
    95       'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_characters < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/characters.sql',
     92      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql',
     93      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql',
     94      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < emulator/'.$Database['Emulator'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql',
     95      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_characters < emulator/'.$Database['Emulator'].'/share/mangos/sql/characters.sql',
    9696      'php www/shell.php RealmDatabaseChange '.$this->Id.' '.$Database['Id'],
    9797      'php www/shell.php RealmUnLock '.$this->Id,
     
    182182      'while [ 1=1 ] ; do',
    183183      'gdb emulator/'.$this->Data['Database']['Emulator']['Id'].'/bin/mangos-worldd -x realm/'.$this->Id.'/bin/mangos.gdb --batch >>realm/'.$this->Id.'/log/mangos-worldd.log 2>>realm/'.$this->Id.'/log/mangos-worldd.err',
    184       'cd www',
    185       'php shell.php ServerProcessLog '.$this->Id.' >>realm/'.$this->Id.'/log/mangos_debug.log 2>>realm/'.$this->Id.'/log/mangos_debug.err',
    186       'cd ..',
     184      'php www/shell.php ServerProcessLog '.$this->Id.' >>realm/'.$this->Id.'/log/mangos_debug.log 2>>realm/'.$this->Id.'/log/mangos_debug.err',
    187185      'sleep 3',
    188186      'done',
     
    215213    $EmulatorConfig = new MangosConfigurationFile($this->Database);
    216214    $EmulatorConfig->Load($EmulatorEtcDir.'mangosd.conf.dist');
    217     $EmulatorConfig->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_realmd';
    218     $EmulatorConfig->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Id.'_mangos';
     215    $EmulatorConfig->ParameterList['LoginDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';server'.$this->Data['Server'].'_realmd';
     216    $EmulatorConfig->ParameterList['WorldDatabaseInfo'] = 'localhost;3306;server'.$this->Id.';server'.$this->Id.';realm'.$this->Id.'_mangos';
    219217    $EmulatorConfig->ParameterList['CharacterDatabaseInfo'] = 'localhost;3306;server'.$this->Data['Server'].';server'.$this->Data['Server'].';realm'.$this->Id.'_characters';
    220218    $EmulatorConfig->ParameterList['ScriptDev2DatabaseInfo'] = 'localhost;3306;server'.$this->Data['Server'].';server'.$this->Data['Server'].';realm'.$this->Id.'_scriptdev2';
     
    258256    // Do update
    259257    $Commands = array(
    260      'php www/shell.php RealmLock '.$this->Id,
     258      'php www/shell.php RealmLock '.$this->Id,
    261259    );
    262260    $DbResult = $this->Database->query('SELECT `Revision` FROM `Database` WHERE `Id` = '.$this->Data['Database']['Id']);
     
    274272      {
    275273        $Parts = explode('|', $Update);
    276         $Command = 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1];
     274        if($Parts[0] != 'realmd')
     275          $Command = 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1];
    277276        $Commands[] = $Command;
    278277      }     
  • trunk/www/model/server.php

    r57 r62  
    4040    $this->Database->query('DROP USER "server'.$this->Id.'"@"localhost"');
    4141  }
    42  
    43   function ImportDatabase($Delete = false)
    44   {
    45     $this->Lock();
    46     $CommandList = array(
    47       'php www/shell.php ServerLock '.$this->Id,
    48     );
    49     if($Delete == true)
    50     {
    51       $CommandList = array_merge($CommandList, array(
    52       'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd',
    53       ));
    54     }
    55     // Lookup nearest database with full import
    56     $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Server['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC');
    57     $Database = $DbResult->fetch_assoc();
    58    
    59     $CommandList = array_merge($CommandList, array(
    60       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/realmd.sql',
    61       'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$Database['Id'],
    62       'php www/shell.php ServerUnLock '.$this->Id,
    63     ));   
    64     $this->Task->Add('Inicializace databáze', $CommandList);
    65    
    66     if($Database['Id'] != $this->Server['Database']['Id'])
    67     {
    68       $NewDatabaseId = $this->Server['Database']['Id'];
    69       $this->Server['Database']['Id'] = $Database['Id'];
    70       $this->Update($NewDatabaseId, false, false);
    71     }
    72     return('Úloha načtení nové databáze zařazena do fronty.');
    73   }
    7442 
    7543  function Start()
     
    228196  }
    229197 
     198  function ImportDatabase($Delete = false)
     199  {
     200    $this->Lock();
     201    $CommandList = array(
     202      'php www/shell.php ServerLock '.$this->Id,
     203    );
     204    if($Delete == true)
     205    {
     206      $CommandList = array_merge($CommandList, array(
     207      'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_realmd',
     208      ));
     209    }
     210    // Lookup nearest database with full import
     211    $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Server['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC');
     212    $Database = $DbResult->fetch_assoc();
     213   
     214    $CommandList = array_merge($CommandList, array(
     215      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/realmd.sql',
     216      'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$Database['Id'],
     217      'php www/shell.php ServerUnLock '.$this->Id,
     218    ));   
     219    $this->Task->Add('Inicializace databáze', $CommandList);
     220   
     221    if($Database['Id'] != $this->Server['Database']['Id'])
     222    {
     223      $NewDatabaseId = $this->Server['Database']['Id'];
     224      $this->Server['Database']['Id'] = $Database['Id'];
     225      $this->Update($NewDatabaseId, false, false);
     226    }
     227    return('Úloha načtení nové databáze zařazena do fronty.');
     228  }
     229
    230230  function Update($DatabaseId, $DoBackup = true, $DoStop = true)
    231231  {
     
    264264      {
    265265        $Parts = explode('|', $Update);
    266         $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1];
     266        if($Parts[0] == 'realmd')
     267          $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1];
    267268        $Commands[] = $Command;
    268269      }     
  • trunk/www/view/debug.php

    r56 r62  
    2828  function ShowListOnRow($Row)
    2929  {
    30     $Row['Time'] = '<a href="?Action=ServerDebug&amp;Id='.$Row['Id'].'&amp;Show=Backtrace">'.str_replace(' ', '&nbsp;', $Row['Time']).'</a>';
     30    $Row['Time'] = '<a href="?Action=DebugView&amp;Id='.$Row['Id'].'&amp;Show=Backtrace">'.str_replace(' ', '&nbsp;', $Row['Time']).'</a>';
    3131    $Row['Uptime'] = TimeToHumanTime($Row['Uptime']);
    3232    return($Row);
     
    3939    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
    4040    {
    41       $Server = new Server($this->Database, $_GET['Id']);
    42       if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     41      $Realm = new Realm($this->Database, $_GET['Id']);
     42      if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    4343      {
    4444        $Output = '<h4>Ladící záznamy restartů</h4>';
    4545        $Table = new Table($this->ItemListFormClass);
    4646        $Table->OnRow = array($this, 'ShowListOnRow');
    47         $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Server='.$_GET['Id'].')';
     47        $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Realm='.$_GET['Id'].')';
    4848        $Table->LoadValuesFromDatabase($this->Database);
    4949        $Output .= $Table->Show();
     
    5959  function Item()
    6060  {
     61    global $System;
     62
    6163    if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
    6264    {
    63       $Server = new Server($this->Database, $_GET['Id']);
    64       if(($this->System->Modules['User']->User['Id'] == $Server->Server['User']) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
     65      $Realm = new Realm($this->Database, $_GET['Id']);
     66      if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
    6567      {
    6668        $Output = '<div>Ladící informace serveru</div>';
    67         $MangosDebug = new MangosDebug($this->Database);
    68         $Output .= $MangosDebug->Show($Server->Id);
     69   
     70    $MangosDebug = new MangosDebug($this->Database, $this->System);
     71    $Form = new Form($this->ItemFormClass);
     72    if($Form->LoadValuesFromDatabase($_GET['Id']))
     73    {
     74        $Form->Values['Uptime'] = TimeToHumanTime($Form->Values['Uptime']);
     75        $Output .= $Form->ShowTable();
     76     
     77        $Output .= '<a href="?Action=DebugView&amp;Id='.$_GET['Id'].'&amp;Show=Backtrace">Backtrace</a>'.
     78          '  <a href="?Action=DebugView&amp;Id='.$_GET['Id'].'&amp;Show=Log">Mangos log</a>'.
     79          '  <a href="?Action=DebugView&amp;Id='.$_GET['Id'].'&amp;Show=Error">Console error log</a>'.
     80          '  <a href="?Action=DebugView&amp;Id='.$_GET['Id'].'&amp;Show=DbErrors">Database error log</a>'.
     81          '  <a href="?Action=DebugView&amp;Id='.$_GET['Id'].'&amp;Show=Configuration">Mangos configuration</a>'.
     82          '<hr>';
     83        if(array_key_exists('Show', $_GET))
     84        {
     85          $Show = addslashes($_GET['Show']);     
     86          switch($Show)
     87          {
     88            case 'Backtrace':
     89              $DbResult = $this->Database->select('Debug', 'Backtrace', 'Id='.$_GET['Id']);
     90              $DbRow = $DbResult->fetch_assoc();
     91              $Content = htmlspecialchars($DbRow['Backtrace']);
     92              for($I = 1; $I < $MangosDebug->MaxMangosThreadCount; $I++)
     93              {
     94                $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content);
     95                $Content = str_replace(' '.$I.' Thread ', '<a href="#'.$I.'"">'.$I.' Thread</a>', $Content);
     96              }
     97              $Output .= '<strong>Backtrace:</strong> <br><pre>'.$Content.'</pre>';
     98              break;
     99            case 'Log':
     100              $DbResult = $this->Database->select('Debug', 'Log', 'Id='.$_GET['Id']);
     101              $DbRow = $DbResult->fetch_assoc();
     102              $Output .= '<strong>Console standard output log:</strong> <br><pre>'.htmlspecialchars($DbRow['Log']).'</pre>';
     103              break;
     104            case 'Error':
     105              $DbResult = $this->Database->select('Debug', 'ErrorLog', 'Id='.$_GET['Id']);
     106              $DbRow = $DbResult->fetch_assoc();
     107              $Output .= '<strong>Console error log:</strong> <br><pre>'.htmlspecialchars($DbRow['ErrorLog']).'</pre>';
     108              break;
     109            case 'DbErrors':
     110              $DbResult = $this->Database->select('Debug', 'DbErrors', 'Id='.$_GET['Id']);
     111              $DbRow = $DbResult->fetch_assoc();
     112              $Output .= '<strong>Database error log:</strong> <br><pre>'.htmlspecialchars($DbRow['DbErrors']).'</pre>';
     113              break;
     114            case 'Configuration':
     115              $DbResult = $this->Database->select('Debug', 'Configuration', 'Id='.$_GET['Id']);
     116              $DbRow = $DbResult->fetch_assoc();
     117              $Output .= '<strong>Mangos configuration:</strong> <br><pre>'.htmlspecialchars($DbRow['Configuration']).'</pre>';
     118              break;
     119          }
     120        }
     121    } else $Output = 'Položka nenalezena';
    69122      } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění');
    70123    } else $Output = USER_BAD_ROLE;
    71124    return($Output);
    72   } 
     125  }
    73126}
    74127
  • trunk/www/view/realm.php

    r58 r62  
    157157        $Output .= ' <a href="?Action=RealmEditDetailed&amp;Id='.$Realm->Id.'">Upravit podrobné nastavení</a>';
    158158      }
     159      $Output .= ' <a href="?Action=DebugList&amp;Id='.$Realm->Id.'">Ladící informace</a>';
    159160      //$Output .= ' <a href="?Action=ServerDatabaseImport&amp;Id='.$Server->Id.'">Načtení čisté databáze</a>';
    160161    }
Note: See TracChangeset for help on using the changeset viewer.