Changeset 46


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.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/backup.sh

    r43 r46  
    11#!/bin/sh
    2 cd /a
    32php www/shell.php BackupCreateAll
    43
  • trunk/bin/start.sh

    r43 r46  
    11#!/bin/sh
    2 cd /a
    32php www/shell.php ServerStartAll
    43bin/task_process.sh&
  • trunk/bin/task_process.sh

    r43 r46  
    11#!/bin/sh
    2 cd /a
    32php www/shell.php TaskProcess
    43
  • trunk/www/error.php

    r12 r46  
    2828    $Backtrace[0]['function'] = '';
    2929    $Backtrace[0]['args'] = '';
     30    if(!array_key_exists('line', $Backtrace[0])) $Backtrace[0]['line'] = '';
     31    if(!array_key_exists('file', $Backtrace[0])) $Backtrace[0]['file'] = '';
    3032    //$First = array_shift($Backtrace);
    3133    //print_r($First);
  • trunk/www/form_classes.php

    r45 r46  
    248248RegisterType('ServerType', 'Enumeration', array('Normální', 'PvP', 'RP', 'RPPvP'));
    249249RegisterType('OnlineState', 'Enumeration', array('Neaktivní', 'Aktivní'));
    250 RegisterType('Database', 'PointerOneToOne', array('Table' => 'Database', 'Id' => 'Id', 'Name' => 'CONCAT(Name, " ", Version, " r", Revision)'));
     250RegisterType('Database', 'PointerOneToOne', array('Table' => 'Database', 'Id' => 'Id', 'Name' => 'CONCAT(Name, " ", Version, " r", Revision)', 'Condition' => 'Emulator <> 0'));
    251251RegisterType('Client', 'PointerOneToOne', array('Table' => 'Client', 'Id' => 'Id', 'Name' => 'Version'));
    252252
  • trunk/www/index.php

    r45 r46  
    5252   
    5353    $Server = new Server($this->Database, $Id);
     54    if(isset($Server->Server))
     55    {
    5456    $Output = '<h4>Podrobnosti serveru</h4>';
    5557    $Form = new Form('ServerView');
     
    8890    $Output .= ' <a href="?Action=GameAccountRegister&amp;Id='.$Server->Id.'">Vytvoření herního účtu</a>';
    8991    $Output .= '</div>';
     92    } else $Output = $this->SystemMessage('Zobrazení serveru', 'Server se zadaným id nenalezen.');
    9093    return($Output);
    9194  }
     
    482485              $Output .= $Form->ShowEditForm();
    483486            }
    484           } else $Output .= $this->SystemMessage('Nový serve', 'Nelze vytvářet další servery');
     487          } else $Output .= $this->SystemMessage('Nový server', 'Nelze vytvářet další servery');
    485488        } else $Output .= USER_BAD_ROLE;
    486489      } else
     
    503506            $Form = new Form('ServerCreate', array());
    504507            $Form->LoadValuesFromForm();
    505             $this->Database->insert('Server', array('Name' => $Form->Values['Name'], 'Description' => $Form->Values['Description'], 'User' => $this->System->Modules['User']->User['Id'], 'Motd' => $Form->Values['Motd'], 'Homepage' => $Form->Values['Homepage'], 'Type' => $Form->Values['Type'], 'Database' => 1, 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
     508            $this->Database->insert('Server', array('Name' => $Form->Values['Name'], 'Description' => $Form->Values['Description'], 'User' => $this->System->Modules['User']->User['Id'], 'Motd' => $Form->Values['Motd'], 'Homepage' => $Form->Values['Homepage'], 'Type' => $Form->Values['Type'], 'Database' => $Form->Values['Database'], 'NetworkPortWorldd' => $NewPortWorldd, 'NetworkPortRealmd' => $NewPortRealmd, 'Lock' => 1, 'TimeCreate' => 'NOW()'));
    506509            $LastInsertId = $this->Database->insert_id;
    507510            $Server = new Server($this->Database, $LastInsertId);
  • 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      }     
  • trunk/www/types/PointerOneToOne.php

    r22 r46  
    2828    $Output = '<select name="'.$Item['Name'].'">';
    2929    $Type = $TypeDefinitionList[$Item['Type']];
    30     $DbResult = $Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`');
     30    if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition'];
     31      else $Where = '';
     32    $DbResult = $Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC');
    3133    while($DbRow = $DbResult->fetch_assoc())
    3234    {
  • trunk/www/user.php

    r45 r46  
    4444  {
    4545    $SID = session_id();
     46
     47    // Check login
     48    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
     49    $Row = $Query->fetch_assoc();
     50    if($Row['User'] != $this->AnonymousUserId)
     51    {
     52      $Query = $this->Database->select('User', '*', 'Id='.$Row['User']);
     53      $this->User = $Query->fetch_assoc();
     54      $Result = USER_LOGGED;
     55    } else
     56    {
     57      $Query = $this->Database->select('User', '*', 'Id='.$this->AnonymousUserId);
     58      $this->User = $Query->fetch_assoc();
     59      $Result = USER_NOT_LOGGED;
     60    }
    4661
    4762    // Remove nonactive users
Note: See TracChangeset for help on using the changeset viewer.