Changeset 46 for trunk/www/server.php


Ignore:
Timestamp:
Jun 19, 2009, 9:41:07 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Zobrazit chybu při pokusu o zobrazení neexistujícího serveru.
  • Opraveno: Při inicializace databáze použij verzi s celou databází a následně proveď aktualizaci na požadovanou verzi.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/server.php

    r45 r46  
    6969      ));
    7070    }
     71    // Lookup nearest database with full import
     72    $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Server['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC');
     73    $Database = $DbResult->fetch_assoc();
     74   
    7175    $CommandList = array_merge($CommandList, array(
    72       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < database/'.$this->Server['Database']['Id'].'/'.$this->Server['Database']['SourceFileName'],
    73       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emulator/'.$this->Server['Database']['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql',
    74       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emulator/'.$this->Server['Database']['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql',
    75       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < emulator/'.$this->Server['Database']['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql',
    76       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$this->Server['Database']['Emulator']['Id'].'/share/mangos/sql/realmd.sql',
    77       'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emulator/'.$this->Server['Database']['Emulator']['Id'].'/share/mangos/sql/characters.sql',
    78       'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$this->Server['Database']['Id'],
     76      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < database/'.$Database['Id'].'/'.$Database['SourceFileName'],
     77      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_create_structure.sql',
     78      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_scriptdev2 < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/scriptdev2_script_full.sql',
     79      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < emulator/'.$Database['Emulator']['Id'].'/source/src/bindings/ScriptDev2/sql/mangos_scriptname_full.sql',
     80      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_realmd < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/realmd.sql',
     81      'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_characters < emulator/'.$Database['Emulator']['Id'].'/share/mangos/sql/characters.sql',
     82      'php www/shell.php ServerDatabaseChange '.$this->Id.' '.$Database['Id'],
    7983      'php www/shell.php ServerUnLock '.$this->Id,
    8084    ));   
    8185    $this->Task->Add('Inicializace databáze', $CommandList);
     86   
     87    if($Database['Id'] != $this->Server['Database']['Id'])
     88    {
     89      $NewDatabaseId = $this->Server['Database']['Id'];
     90      $this->Server['Database']['Id'] = $Database['Id'];
     91      $this->Update($NewDatabaseId, false, false);
     92    }
    8293    return('Úloha načtení nové databáze zařazena do fronty.');
    8394  }
     
    297308  }
    298309 
    299   function Update($DatabaseId)
     310  function Update($DatabaseId, $DoBackup = true, $DoStop = true)
    300311  {
    301312    $this->Lock();
     313    $Output = '';
    302314   
    303315    // Stop server before update
    304     $Output = $this->Stop();
     316    if($DoStop)
     317    {
     318      $Output .= $this->Stop();
     319    }
    305320   
    306321    // Backup current
    307     $Backup = new Backup($this->Database, 0);
    308     $Output .= '<br />'.$Backup->Create($this->Id);
     322    if($DoBackup)
     323    {
     324      $Backup = new Backup($this->Database, 0);
     325      $Output .= '<br />'.$Backup->Create($this->Id);
     326    }
    309327   
    310328    // Do update
     
    326344      {
    327345        $Parts = explode('|', $Update);
    328         $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Database'].'/update/'.$Parts[1];
     346        $Command = 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_'.$Parts[0].' < database/'.$DbRow['Id'].'/'.$Parts[1];
    329347        $Commands[] = $Command;
    330348      }     
Note: See TracChangeset for help on using the changeset viewer.