Changeset 16


Ignore:
Timestamp:
Jun 12, 2009, 8:47:16 AM (15 years ago)
Author:
george
Message:
  • Přidáno: Funkce pro vytvoření zálohy a obnovení databáze ze zálohy.
  • Upraveno: Funkce přidávání úloh do fronty přesunuta do samostatné třídy Task.
Location:
trunk/www
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/backup.php

    r15 r16  
    44{
    55  var $Id;
     6  var $Tash;
    67 
    78  function __construct($Database, $Id)
    89  {
    910    $this->Database = $Database;
     11    $this->Task = new Task($Database);
    1012    $this->Id = $Id;
    1113    $DbResult = $this->Database->query('SELECT * FROM `Backup` WHERE `Id`='.$Id);
     
    1315  }
    1416 
    15   function Restore($Id)
     17  function Restore()
    1618  {
    17    
     19    $this->Task->Add('Obnovení databáze', array(
     20      'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_mangos',
     21      'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_characters',
     22      'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_realmd',
     23      'mysql --silent --skip-column-names -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$ServerId.' -pserver'.$ServerId.' server'.$ServerId.'_scriptdev2',
     24      'mkdir /tmp/wowhosting',
     25      'tar -xjf backup/'.$ServerId.'/backup.tar.bz2 -C /tmp/wowhosting',
     26      'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_characters < /tmp/wowhosting/characters.sql',
     27      'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_realmd < /tmp/wowhosting/realmd.sql',
     28      'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_mangos < /tmp/wowhosting/mangos.sql',
     29      'mysql --user server'.$ServerId.' --password server'.$ServerId.' server'.$ServerId.'_scriptdev2 < /tmp/wowhosting/scriptdev2.sql',
     30      'rm -f /tmp/wowhosting',
     31    ));
    1832  }
    1933 
    20   function Save($Id)
     34  function Create($ServerId)
    2135  {
    22    
     36    $this->Task->Add('Záloha databáze serveru', array(
     37      'mkdir /tmp/wowhosting',
     38      'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_characters > /tmp/wowhosting/characters.sql',
     39      'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_realmd > /tmp/wowhosting/realmd.sql',
     40      'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_mangos > /tmp/wowhosting/mangos.sql',
     41      'mysqldump --user server'.$ServerId.' --password server'.$ServerId.' --opt server'.$ServerId.'_scriptdev2 > /tmp/wowhosting/scriptdev2.sql',
     42      'tar -c -j /tmp/wowhosting > backup/'.$ServerId.'/backup.tar.bz2',
     43      'rm -f /tmp/wowhosting',
     44    ));
    2345  } 
    2446}
  • trunk/www/emulator.php

    r15 r16  
    55  var $Id;
    66  var $Emulator;
     7  var $Task;
    78 
    89  function __construct($Database, $Id)
    910  {
    1011    $this->Database = $Database;
     12    $this->Task = new Task(&$Database);
    1113    $this->Id = $Id;
    1214    $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$Id);
     
    1416    $DbResult = $this->Database->query('SELECT * FROM `ClientVersion` WHERE `Id`='.$this->Emulator['ClientVersion']);
    1517    $this->Emulator['ClientVersion'] = $DbResult->fetch_assoc();
    16   }
    17  
    18   function AddTask($Title, $Task)
    19   {
    20     global $System;
    21    
    22     $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task)."\n"));
    2318  }
    2419 
     
    4035    global $Config;
    4136   
    42     $this->AddTask('Stažení emulátoru', array(
     37    $this->Task->Add('Stažení emulátoru', array(
    4338      'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/',
    4439      'git clone git://github.com/mangos/mangos.git source',
     
    5550    global $Config;
    5651   
    57     $this->AddTask('Překlad emulátoru', array(
     52    $this->Task->Add('Překlad emulátoru', array(
    5853      'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/source',
    5954      'autoreconf -ifv',
  • trunk/www/form.php

    r15 r16  
    7878    foreach($this->Definition['Items'] as $Index => $Item)
    7979    {
    80       $this->Values[$Item['Name']] = $DbRow[$Item['Name']];
     80      $this->Values[$Index] = $DbRow[$Index];
    8181    }
    8282  }
  • trunk/www/form_classes.php

    r14 r16  
    7676  'ServerList' => array(
    7777    'Title' => 'Server',
    78     'Table' => '(SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.`Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName` FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`) AS T',
     78    'Table' => '(SELECT `ClientVersion`.`Version`, `Server`.`Name`, `Server`.`Id`, `Server`.`NetworkPortRealmd`, `User`.`Name` AS `UserName`, Server.Online, Server.CharacterOnlineCount, Server.CharacterCount, Server.AccountCount FROM `Server` JOIN `User` ON `User`.`Id` = `Server`.`User` JOIN `Database` ON `Database`.`Id` = `Server`.`Database` JOIN `Emulator` ON `Emulator`.`Id` = `Database`.`Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`) AS T',
    7979    'Items' => array(
    8080      'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
     
    8383      'Version' => array('Type' => 'Integer', 'Caption' => 'Verze', 'Default' => 0),
    8484      'Online' => array('Type' => 'OnlineState', 'Caption' => 'Stav', 'Default' => 0),
    85       'CharacterCount' => array('Type' => 'Integer', 'Caption' => 'Hráčů online', 'Default' => 0),
     85      'CharacterOnlineCount' => array('Type' => 'Integer', 'Caption' => 'Hráčů online', 'Default' => 0),
    8686      'AccountCount' => array('Type' => 'Integer', 'Caption' => 'Účtů', 'Default' => 0),
    8787      'CharacterCount' => array('Type' => 'Integer', 'Caption' => 'Postav', 0),
  • trunk/www/server.php

    r15 r16  
    99  var $Id;
    1010  var $Server;
     11  var $Task;
    1112  var $WorlddBaseNetworkPort = 8085;
    1213  var $RealmdBaseNetworkPort = 3724;
     
    1617  {
    1718    $this->Database = $Database;
     19    $this->Task = new Task(&$Database);
    1820    $this->Id = $Id;
    1921    $DbResult = $this->Database->query('SELECT * FROM `Server` WHERE `Id`='.$Id);
     
    3133        else $this->Server['Database']['Emulator']['ClientVersion'] = array();
    3234    }
    33   }
    34  
    35   function AddTask($Title, $Task)
    36   {
    37     global $System;
    38    
    39     $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task)."\n"));
    40   }
     35  }
    4136 
    4237  function CreateDatabase()
     
    7974      array_unshift($CommandList, 'mysql --silent --skip-column-names -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2 -e "show tables" | gawk \'{print "drop table " $1 ";"}\' | mysql -u server'.$this->Id.' -pserver'.$this->Id.' server'.$this->Id.'_scriptdev2');
    8075    }
    81     $this->AddTask('Inicializace databáze', $CommandList);
    82   }
     76    $this->Task->Add('Inicializace databáze', $CommandList);
     77  } 
    8378 
    8479  function AddServer($Version)
     
    8984  function Start()
    9085  {
    91     $this->AddTask('Start emulátoru', array(
     86    $this->Task->Add('Start emulátoru', array(
    9287      'screen -A -m -d -S server'.$this->Id.'-realmd emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-realmd -c server/'.$this->Id.'/etc/realmd.conf',
    9388      'screen -A -m -d -S server'.$this->Id.'-worldd server/'.$this->Id.'/bin/start.sh',
     
    9893  function Stop()
    9994  {
    100     $this->AddTask('Zastavení emulátoru', array(
     95    $this->Task->Add('Zastavení emulátoru', array(
    10196      'server/'.$this->Id.'/bin/stop.sh',
    10297    ));
  • trunk/www/table.php

    r15 r16  
    2626    foreach($QueryParts as $Part)
    2727    {
    28       $Part2 = explode('=', $Part);
    29       $QueryItems[$Part2[0]] = $Part2[1];
     28      if($Part != '')
     29      {
     30        $Part2 = explode('=', $Part);
     31        $QueryItems[$Part2[0]] = $Part2[1];
     32      }
    3033    }
    3134    $QueryItems['Order'] = $_GET['Order'];
  • trunk/www/task.php

    r11 r16  
    88  {
    99    $this->Database = $Database;
    10   } 
     10  }
     11 
     12  function Add($Title, $Task)
     13  {
     14    global $System;
     15   
     16    $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task)."\n"));
     17  }
    1118
    1219  function ProcessAll()
Note: See TracChangeset for help on using the changeset viewer.