Changeset 64


Ignore:
Timestamp:
Aug 5, 2009, 2:44:29 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Odkaz na inicializaci čisté databáze.
Location:
trunk/www
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/index.php

    r62 r64  
    261261        $RealmView = new RealmView($this->Database, $this->System);
    262262        $Output .= $RealmView->Create();
     263      } else
     264      if($_GET['Action'] == 'RealmInitDatabase')
     265      {
     266        $RealmView = new RealmView($this->Database, $this->System);
     267        $Output .= $RealmView->InitDatabase();
    263268      } else
    264269      if($_GET['Action'] == 'RealmEdit')
  • trunk/www/model/realm.php

    r63 r64  
    7676      'php www/shell.php RealmLock '.$this->Id,
    7777    );
     78   
     79    // Empty all tables
    7880    if($Delete == true)
    7981    {
     
    8486      ));
    8587    }
     88   
    8689    // Lookup nearest database with full import
    8790    $DbResult = $this->Database->query('SELECT * FROM `Database` WHERE (`Emulator` <> 0) AND (`Revision` <= '.$this->Data['Database']['Revision'].') AND (`SourceFileName` <> "") ORDER BY `Revision` DESC');
     
    9396      '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',
    9497      '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',
    96       'php www/shell.php RealmDatabaseChange '.$this->Id.' '.$Database['Id'],
    97       'php www/shell.php RealmUnLock '.$this->Id,
    98     ));   
     98      'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_characters < emulator/'.$Database['Emulator'].'/share/mangos/sql/characters.sql'));
     99    if($Database['ACIDSourceFileName'] != '')
     100      $CommandList[] = 'mysql --user=server'.$this->Data['Server'].' --password=server'.$this->Data['Server'].' realm'.$this->Id.'_mangos < database/'.$Database['Id'].'/'.$Database['ACIDSourceFileName'];
     101    $CommandList[] = 'php www/shell.php RealmDatabaseChange '.$this->Id.' '.$Database['Id'];
     102    $commandList[] = 'php www/shell.php RealmUnLock '.$this->Id;
    99103    $this->Task->Add('Inicializace databáze', $CommandList);
    100104   
  • trunk/www/sql/full.sql

    r49 r64  
    11-- phpMyAdmin SQL Dump
    2 -- version 3.1.5
     2-- version 3.2.0.1
    33-- http://www.phpmyadmin.net
    44--
    55-- Počítač: localhost
    6 -- Vygenerováno: Sobota 20. června 2009, 13:49
     6-- Vygenerováno: Středa 05. srpna 2009, 08:37
    77-- Verze MySQL: 5.0.77
    88-- Verze PHP: 5.2.9
     
    2020--
    2121
    22 DROP TABLE IF EXISTS `Backup`;
    2322CREATE TABLE IF NOT EXISTS `Backup` (
    2423  `Id` int(11) NOT NULL auto_increment,
     
    3938--
    4039
    41 DROP TABLE IF EXISTS `Client`;
    4240CREATE TABLE IF NOT EXISTS `Client` (
    4341  `Id` int(11) NOT NULL auto_increment,
     
    4644  `ReleaseDate` date NOT NULL,
    4745  `Title` varchar(255) NOT NULL,
     46  `Patch` varchar(255) NOT NULL,
    4847  PRIMARY KEY  (`Id`)
    49 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=74 ;
     48) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=75 ;
    5049
    5150-- --------------------------------------------------------
     
    5554--
    5655
    57 DROP TABLE IF EXISTS `Database`;
    5856CREATE TABLE IF NOT EXISTS `Database` (
    5957  `Id` int(11) NOT NULL auto_increment,
     
    6765  `Emulator` int(11) default NULL,
    6866  `Update` text NOT NULL,
     67  `ACIDSourceFileName` varchar(255) NOT NULL,
    6968  PRIMARY KEY  (`Id`),
    7069  KEY `Emulator` (`Emulator`)
    71 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
     70) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
    7271
    7372-- --------------------------------------------------------
     
    7776--
    7877
    79 DROP TABLE IF EXISTS `Debug`;
    8078CREATE TABLE IF NOT EXISTS `Debug` (
    8179  `Id` int(11) NOT NULL auto_increment,
    8280  `Time` datetime NOT NULL,
    83   `Server` int(11) NOT NULL,
     81  `Realm` int(11) NOT NULL,
    8482  `Backtrace` mediumtext NOT NULL,
    8583  `Log` text NOT NULL,
     
    9290  `Configuration` text NOT NULL,
    9391  PRIMARY KEY  (`Id`),
    94   KEY `Server` (`Server`)
     92  KEY `Server` (`Realm`)
    9593) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
    9694
     
    10199--
    102100
    103 DROP TABLE IF EXISTS `Emulator`;
    104101CREATE TABLE IF NOT EXISTS `Emulator` (
    105102  `Id` int(11) NOT NULL auto_increment,
     
    115112  PRIMARY KEY  (`Id`),
    116113  KEY `Client` (`Client`)
    117 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
     114) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
    118115
    119116-- --------------------------------------------------------
     
    123120--
    124121
    125 DROP TABLE IF EXISTS `History`;
    126122CREATE TABLE IF NOT EXISTS `History` (
    127123  `Time` int(11) NOT NULL,
     
    145141--
    146142
    147 DROP TABLE IF EXISTS `Log`;
    148143CREATE TABLE IF NOT EXISTS `Log` (
    149144  `Time` datetime NOT NULL default '0000-00-00 00:00:00',
     
    162157--
    163158
    164 DROP TABLE IF EXISTS `News`;
    165159CREATE TABLE IF NOT EXISTS `News` (
    166160  `Id` int(11) NOT NULL auto_increment,
     
    171165  PRIMARY KEY  (`Id`),
    172166  KEY `User` (`User`)
    173 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
    174 
    175 -- --------------------------------------------------------
    176 
    177 --
    178 -- Struktura tabulky `Server`
    179 --
    180 
    181 DROP TABLE IF EXISTS `Server`;
    182 CREATE TABLE IF NOT EXISTS `Server` (
    183   `Id` int(11) NOT NULL auto_increment,
    184   `Name` varchar(255) NOT NULL,
    185   `NetworkPortRealmd` int(11) NOT NULL,
     167) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
     168
     169-- --------------------------------------------------------
     170
     171--
     172-- Struktura tabulky `Realm`
     173--
     174
     175CREATE TABLE IF NOT EXISTS `Realm` (
     176  `Id` int(11) NOT NULL auto_increment,
     177  `Name` varchar(255) NOT NULL,
     178  `Server` int(11) NOT NULL,
    186179  `NetworkPortWorldd` int(11) NOT NULL,
    187   `User` int(11) NOT NULL,
    188180  `Database` int(11) NOT NULL,
    189181  `Motd` varchar(255) NOT NULL,
     
    198190  `Lock` int(11) NOT NULL,
    199191  PRIMARY KEY  (`Id`),
     192  KEY `Database` (`Database`),
     193  KEY `Server` (`Server`)
     194) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
     195
     196-- --------------------------------------------------------
     197
     198--
     199-- Struktura tabulky `RealmLog`
     200--
     201
     202CREATE TABLE IF NOT EXISTS `RealmLog` (
     203  `Id` int(11) NOT NULL auto_increment,
     204  `Realm` int(11) NOT NULL,
     205  `Time` datetime NOT NULL,
     206  `Text` text NOT NULL,
     207  PRIMARY KEY  (`Id`),
     208  KEY `Server` (`Realm`),
     209  KEY `Time` (`Time`)
     210) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
     211
     212-- --------------------------------------------------------
     213
     214--
     215-- Struktura tabulky `Server`
     216--
     217
     218CREATE TABLE IF NOT EXISTS `Server` (
     219  `Id` int(11) NOT NULL auto_increment,
     220  `Name` varchar(255) NOT NULL,
     221  `NetworkPortRealmd` int(11) NOT NULL,
     222  `User` int(11) NOT NULL,
     223  `Database` int(11) NOT NULL,
     224  `Description` text NOT NULL,
     225  `Homepage` varchar(255) NOT NULL,
     226  `TimeCreate` datetime NOT NULL,
     227  `Online` int(11) NOT NULL,
     228  `CharacterOnlineCount` int(11) NOT NULL,
     229  `CharacterCount` int(11) NOT NULL,
     230  `AccountCount` int(11) NOT NULL,
     231  `Lock` int(11) NOT NULL,
     232  `Started` int(11) NOT NULL,
     233  PRIMARY KEY  (`Id`),
    200234  KEY `User` (`User`),
    201235  KEY `Database` (`Database`)
    202 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
     236) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
    203237
    204238-- --------------------------------------------------------
     
    208242--
    209243
    210 DROP TABLE IF EXISTS `Task`;
    211244CREATE TABLE IF NOT EXISTS `Task` (
    212245  `Id` int(11) NOT NULL auto_increment,
     
    222255  PRIMARY KEY  (`Id`),
    223256  KEY `User` (`User`)
    224 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
     257) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
    225258
    226259-- --------------------------------------------------------
     
    230263--
    231264
    232 DROP TABLE IF EXISTS `User`;
    233265CREATE TABLE IF NOT EXISTS `User` (
    234266  `Id` int(11) NOT NULL auto_increment,
     
    251283--
    252284
    253 DROP TABLE IF EXISTS `UserOnline`;
    254285CREATE TABLE IF NOT EXISTS `UserOnline` (
    255286  `Id` int(11) NOT NULL auto_increment,
     
    263294  PRIMARY KEY  (`Id`),
    264295  KEY `User` (`User`)
    265 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
     296) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=27 ;
    266297
    267298--
     
    279310--
    280311ALTER TABLE `Debug`
    281   ADD CONSTRAINT `Debug_ibfk_2` FOREIGN KEY (`Server`) REFERENCES `Server` (`Id`),
    282   ADD CONSTRAINT `Debug_ibfk_1` FOREIGN KEY (`Server`) REFERENCES `Server` (`Id`);
     312  ADD CONSTRAINT `Debug_ibfk_1` FOREIGN KEY (`Realm`) REFERENCES `Realm` (`Id`);
    283313
    284314--
     
    307337
    308338--
     339-- Omezení pro tabulku `Realm`
     340--
     341ALTER TABLE `Realm`
     342  ADD CONSTRAINT `Realm_ibfk_1` FOREIGN KEY (`Server`) REFERENCES `Server` (`Id`),
     343  ADD CONSTRAINT `Realm_ibfk_2` FOREIGN KEY (`Database`) REFERENCES `Database` (`Id`);
     344
     345--
     346-- Omezení pro tabulku `RealmLog`
     347--
     348ALTER TABLE `RealmLog`
     349  ADD CONSTRAINT `RealmLog_ibfk_1` FOREIGN KEY (`Realm`) REFERENCES `Realm` (`Id`);
     350
     351--
    309352-- Omezení pro tabulku `Server`
    310353--
    311354ALTER TABLE `Server`
    312   ADD CONSTRAINT `Server_ibfk_2` FOREIGN KEY (`Database`) REFERENCES `Database` (`Id`),
    313   ADD CONSTRAINT `Server_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);
     355  ADD CONSTRAINT `Server_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`),
     356  ADD CONSTRAINT `Server_ibfk_2` FOREIGN KEY (`Database`) REFERENCES `Database` (`Id`);
    314357
    315358--
  • trunk/www/view/base.php

    r57 r64  
    1212    '<li><a href="http://www.udbforums.org/">UDB</a> - databáze pro MaNGOS</li>'.
    1313    '<li><a href="http://www.scriptdev2.com/">ScriptDev2</a> - doplňkový skriptovací systém pro MaNGOS</li>'.
     14    '<li><a href="http://cia.vc/stats/project/ACID"> ACID</a> - databáze pro skriptování NPC</li>'.
    1415    '</ul>';
    1516    return($Output);
  • trunk/www/view/realm.php

    r62 r64  
    156156        $Output .= ' <a href="?Action=RealmEdit&amp;Id='.$Realm->Id.'">Upravit základní nastavení</a>';
    157157        $Output .= ' <a href="?Action=RealmEditDetailed&amp;Id='.$Realm->Id.'">Upravit podrobné nastavení</a>';
     158        $Output .= ' <a href="?Action=RealmInitDatabase&amp;Id='.$Realm->Id.'">Vynulovat databázi</a>';
    158159      }
    159160      $Output .= ' <a href="?Action=DebugList&amp;Id='.$Realm->Id.'">Ladící informace</a>';
     
    342343    return($Output);
    343344  }
     345 
     346  function InitDatabase()
     347  {
     348    global $Config;   
     349     
     350    if(array_key_exists('Id', $_GET))
     351    {
     352      $RealmId = $_GET['Id'];
     353      if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     354      {
     355        $Realm = new Realm($this->Database, $RealmId);
     356        if($Realm->GetUser() == $this->System->Modules['User']->User['Id'])
     357        {
     358          $Output = $this->System->SystemMessage('Vynulování databáze', $Realm->ImportDatabase(true));
     359          $TaskView = new TaskView($this->Database, $this->System);
     360          $Output .= $TaskView->ItemList();
     361          //$UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
     362          //$Form->OnSubmit = '?Action=ServerCreate';
     363          //$Output .= $Form->ShowEditForm();
     364        } else $Output = $this->System->SystemMessage('Vynulování databáze', 'Nemáte oprávnění');
     365      } else $Output = USER_BAD_ROLE;
     366    } else $Output = $this->System->SystemMessage('Vynulování databáze', 'Nezadáno Id serveru');
     367    return($Output);
     368  }
    344369}
    345370
  • trunk/www/view/task.php

    r59 r64  
    4848  function ErrorLog()
    4949  {
    50     $DbResult = $this->Database->select('Task', 'Title, Error', 'Id='.$_GET['Id']);
    51     $DbRow = $DbResult->fetch_assoc();
     50    $DbResult = $this->Database->select('Task', 'Title, Error, State', 'Id='.$_GET['Id']);
     51    $DbRow = $DbResult->fetch_assoc();   
    5252    $Output = '<h4>Chybový výpis úlohy: '.$DbRow['Title'].'</h4>';
    53     $Output .= '<pre>'.$DbRow['Error'].'</pre>';
     53    if($DbRow['State'] == 1) $Output .= '<pre>'.file_get_contents('../temp/wowhosting_script.sh.err').'</pre>';
     54      else $Output .= '<pre>'.$DbRow['Error'].'</pre>';
    5455    return($Output);
    5556  }
     
    5758  function StandardLog()
    5859  {
    59     $DbResult = $this->Database->select('Task', 'Title, Output', 'Id='.$_GET['Id']);
     60    $DbResult = $this->Database->select('Task', 'Title, Output, State', 'Id='.$_GET['Id']);
    6061    $DbRow = $DbResult->fetch_assoc();
    6162    $Output = '<h4>Výpis výstupu úlohy: '.$DbRow['Title'].'</h4>';
     63    if($DbRow['State'] == 1) $Output .= '<pre>'.file_get_contents('../temp/wowhosting_script.sh.log').'</pre>';
    6264    $Output .= '<pre>'.$DbRow['Output'].'</pre>';
    6365    return($Output);
Note: See TracChangeset for help on using the changeset viewer.