Changeset 34
- Timestamp:
- Jun 15, 2009, 9:09:30 AM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 2 added
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/emulator.php
r31 r34 35 35 global $Config; 36 36 37 $this->Lock(); 37 38 $this->Task->Add('Stažení emulátoru', array( 38 39 'mkdir '.$Config['BaseDir'].'emulator/'.$this->Id.'/', … … 51 52 global $Config; 52 53 54 $this->Lock(); 53 55 $this->Task->Add('Překlad emulátoru', array( 54 56 'cd '.$Config['BaseDir'].'emulator/'.$this->Id.'/source', … … 66 68 function ExtractMaps() 67 69 { 70 $this->Lock(); 68 71 $this->Task->Add('Vygenerování souborů map', array( 69 72 'cd wowclient/'.$this->Emulator['Client']['Version'].'/client', … … 74 77 return('Požadavek na vygenerování map zařazen.'); 75 78 } 79 80 81 function Lock() 82 { 83 $this->Database->update('Emulator', 'Id='.$this->Id, array('Lock' => 1)); 84 } 85 86 function UnLock() 87 { 88 $this->Database->update('Emulator', 'Id='.$this->Id, array('Lock' => 0)); 89 } 76 90 } 77 91 -
trunk/www/form_classes.php
r33 r34 174 174 'Title' => 'Seznam úloh', 175 175 'Table' => 'Task', 176 'DefaultOrderColumn' => 'Time ',176 'DefaultOrderColumn' => 'TimeCreate', 177 177 'DefaultOrderDirection' => 1, 178 178 'Items' => array( 179 'Time ' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),179 'TimeCreate' => array('Type' => 'DateTime', 'Caption' => 'Čas vytvoření', 'Default' => ''), 180 180 'Title' => array('Type' => 'String', 'Caption' => 'Akce', 'Default' => ''), 181 181 'State' => array('Type' => 'TaskState', 'Caption' => 'Stav', 'Default' => ''), 182 'Duration' => array('Type' => 'String', 'Caption' => 'Trvání', 'Default' => ''), 182 183 ), 183 184 ), -
trunk/www/global.php
r32 r34 73 73 'Time' => array 74 74 ( 75 'BaseIndex' => 0,75 'BaseIndex' => 8, 76 76 'Definition' => array 77 77 ( … … 167 167 global $PrefixMultipliers; 168 168 169 if(($Unit == '') and ($PrefixType != 'Time')) return($this->TruncateDigits($Value, $Digits)); 169 $Negative = ($Value < 0); 170 $Value = abs($Value); 171 if(($Unit == '') and ($PrefixType != 'Time')) 172 return($this->TruncateDigits($Value, $Digits)); 173 170 174 $I = $PrefixMultipliers[$PrefixType]['BaseIndex']; 171 if($Value > 0) $II = 1; 172 else if($Value < 0) $II = -1; 173 else $II = 0; 174 while((($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + $II][2]) > $II) and (($I + $II) >= 0) and (($I + $II) <= count($PrefixMultipliers[$PrefixType]['Definition']))) $I = $I + $II; 175 if($Value == 0) return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit); 176 177 if($Value > 1) 178 { 179 while((($I + 1) <= count($PrefixMultipliers[$PrefixType]['Definition'])) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I + 1][2]) > 1)) 180 $I = $I + 1; 181 } else 182 if($Value < 1) 183 { 184 while((($I - 1) >= 0) and (($Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]) < 1)) 185 $I = $I - 1; 186 } 175 187 $Value = $Value / $PrefixMultipliers[$PrefixType]['Definition'][$I][2]; 176 188 177 189 // Truncate digits count 178 190 $Value = $this->TruncateDigits($Value, $Digits); 179 191 if($Negative) $Value = -$Value; 180 192 return($Value.' '.$PrefixMultipliers[$PrefixType]['Definition'][$I][0].$Unit); 181 193 } -
trunk/www/index.php
r33 r34 58 58 { 59 59 $Output .= '<br /><a href="http://'.$this->System->Config['Web']['Host'].'/mysql/">Správa databáze</a> '; 60 if(array_key_exists('Id', $Server->Server['Database']) )60 if(array_key_exists('Id', $Server->Server['Database']) and ($Server->Server['Lock'] == 0)) 61 61 { 62 62 $ServerStatus = $Server->GetState(); … … 64 64 else $Output .= ' <a href="?Action=ServerStart&Id='.$Server->Id.'">Spustit</a>'; 65 65 } 66 $Output .= ' <a href="?Action=ServerEdit&Id='.$Server->Id.'">Upravit</a>';67 $Output .= ' <a href="?Action=ServerDatabaseImport&Id='.$Server->Id.'">Načtení čisté databáze</a>';66 if($Server->Server['Lock'] == 0) $Output .= ' <a href="?Action=ServerEdit&Id='.$Server->Id.'">Upravit</a>'; 67 //$Output .= ' <a href="?Action=ServerDatabaseImport&Id='.$Server->Id.'">Načtení čisté databáze</a>'; 68 68 } 69 69 $Output .= ' <a href="?Action=GameAccountRegister&Id='.$Server->Id.'">Vytvoření herního účtu</a>'; … … 114 114 { 115 115 $Table->Values[$Index]['Actions'] = '<a href="?Action=EmulatorShow&Id='.$Item['Id'].'">Podprobnosti</a>'; 116 $Table->Values[$Index]['Actions'] .= ' <a href="?Action=Update&Server='.$ServerId.'&Update='.$Item['Id'].'">Aktualizovat</a>';116 if($Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=Update&Server='.$ServerId.'&Update='.$Item['Id'].'">Aktualizovat</a>'; 117 117 unset($Table->Values[$Index]['Id']); 118 118 } … … 131 131 $Output .= $Form->ShowTable(); 132 132 $Output .= '<div style="text-align: center">'; 133 $Emulator = new Emulator($this->Database, $Id); 133 134 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 134 135 { 135 $Output .= ' <a href="?Action=EmulatorDownload&Id='.$Id.'">Stáhnout</a>';136 $Output .= ' <a href="?Action=EmulatorCompile&Id='.$Id.'">Přeložit</a>';136 if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Action=EmulatorDownload&Id='.$Id.'">Stáhnout</a>'; 137 if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Action=EmulatorCompile&Id='.$Id.'">Přeložit</a>'; 137 138 } 138 139 $Output .= '</div>'; … … 165 166 { 166 167 $Table->Values[$Index]['Actions'] = '<a href="?Action=BackupDownload&Id='.$Value['Id'].'">Stáhnout</a>'; 167 $Table->Values[$Index]['Actions'] .= ' <a href="?Action=BackupRestore&Id='.$Value['Id'].'">Obnovit</a>';168 if($Server->Server['Lock'] == 0) $Table->Values[$Index]['Actions'] .= ' <a href="?Action=BackupRestore&Id='.$Value['Id'].'">Obnovit</a>'; 168 169 unset($Table->Values[$Index]['Id']); 169 170 } … … 171 172 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 172 173 { 173 $Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd&Id='.$ServerId.'">Zálohovat</a></dev>';174 if($Server->Server['Lock'] == 0) $Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd&Id='.$ServerId.'">Zálohovat</a></dev>'; 174 175 } 175 176 } else $this->SystemMessage('Zastavení serveru', 'Nemáte oprávnění'); … … 200 201 } 201 202 203 function ShowTaskListOnRow($Row) 204 { 205 $Row['Duration'] = $this->System->AddPrefixMultipliers($Row['Duration'], '', 4, 'Time'); 206 return($Row); 207 } 208 202 209 function ShowTaskList() 203 210 { … … 208 215 $Output = '<h4>Fronta úloh</h4>'; 209 216 $Table = new Table('TaskList'); 210 $Table->Definition['Table'] = '(SELECT Time, Title, State FROM Task WHERE User='.$this->System->Modules['User']->User['Id'].' ORDER BY Id DESC)'; 217 $Table->OnRow = array($this, 'ShowTaskListOnRow'); 218 $Table->Definition['Table'] = '(SELECT (UNIX_TIMESTAMP(TimeEnd) - UNIX_TIMESTAMP(TimeStart)) AS Duration, TimeCreate, Title, State FROM Task WHERE User='.$this->System->Modules['User']->User['Id'].' ORDER BY Id DESC)'; 211 219 $Table->LoadValuesFromDatabase($this->Database); 212 220 $Output .= $Table->Show(); … … 729 737 '</table>'; 730 738 } else 739 if($_GET['Action'] == 'ServerList') 740 { 741 $Output .= $this->ShowServerList(); 742 } else 731 743 if($_GET['Action'] == 'Test') 732 744 { -
trunk/www/mangos_debug.php
r24 r34 70 70 } 71 71 72 function ProcessLog( )72 function ProcessLog($ServerId) 73 73 { 74 74 global $Config; … … 76 76 $Output = ''; 77 77 // Read server Id from first parameter 78 if((count($_SERVER['argv']) > 1) and is_numeric($_SERVER['argv'][1]))79 {80 78 $ServerId = $_SERVER['argv'][1]; 81 79 $LogDir = '../server/'.$ServerId.'/log/'; … … 105 103 //$Log = array_slice($Lines, 0, $Line); 106 104 //$Log = addslashes(implode("\n", $Log)); 107 105 108 106 // Get used database version from database 109 107 $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_mangos`.`db_version`'); … … 131 129 $this->Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId); 132 130 unlink($MangosLogFile); 131 } 133 132 134 }135 133 if(file_exists($MangosDbErrorsLogFile)) 136 134 { … … 159 157 } 160 158 unlink($StdOutLogFile); 161 } else $Output = 'Je nutno zadat číslo serveru jako parameter';162 159 return($Output); 163 160 } -
trunk/www/page.php
r32 r34 28 28 '<a href="?Action=Info">Informace</a>'. 29 29 ' <a href="?Action=State">Stav systému</a>'. 30 ' <a href="? ">Seznam serverů</a>'.30 ' <a href="?Action=ServerList">Seznam serverů</a>'. 31 31 ' <a href="?Action=ClientList">Verze klienta</a>'. 32 32 ' <a href="?Action=EmulatorList">Verze emulátoru</a>'; -
trunk/www/server.php
r31 r34 56 56 function ImportDatabase($Delete = false) 57 57 { 58 $this->Lock(); 58 59 $CommandList = array( 59 60 'mysql --user=server'.$this->Id.' --password=server'.$this->Id.' server'.$this->Id.'_mangos < database/'.$this->Server['Database']['Id'].'/'.$this->Server['Database']['SourceFileName'], … … 74 75 } 75 76 76 function AddServer($Version)77 {78 79 }80 81 77 function Start() 82 78 { 79 $this->Lock(); 83 80 $this->Task->Add('Start emulátoru', array( 84 81 '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', … … 90 87 function Stop() 91 88 { 89 $this->Lock(); 92 90 $this->Task->Add('Zastavení emulátoru', array( 93 91 'server/'.$this->Id.'/bin/stop.sh', … … 177 175 'gdb emulator/'.$this->Server['Database']['Emulator']['Id'].'/bin/mangos-worldd -x server/'.$this->Id.'/bin/mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err', 178 176 'cd www', 179 'php mangos_debug_process.php'.$this->Id.' >>server/'.$this->Id.'/log/mangos_debug.log 2>>server/'.$this->Id.'/log/mangos_debug.err',177 'php shell.php ServerProcessLog '.$this->Id.' >>server/'.$this->Id.'/log/mangos_debug.log 2>>server/'.$this->Id.'/log/mangos_debug.err', 180 178 'cd ..', 181 179 'sleep 3', … … 275 273 function Update($DatabaseId) 276 274 { 275 $this->Lock(); 276 277 277 // Stop server before update 278 278 $Output = $this->Stop(); … … 306 306 return($Output); 307 307 } 308 309 function Lock() 310 { 311 $this->Database->update('Server', 'Id='.$this->Id, array('Lock' => 1)); 312 } 313 314 function UnLock() 315 { 316 $this->Database->update('Server', 'Id='.$this->Id, array('Lock' => 0)); 317 } 308 318 } 309 319 -
trunk/www/task.php
r31 r34 15 15 16 16 $CommandList = implode("\n", $Task)."\n"; 17 $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time ' => 'NOW()', 'CommandList' => $CommandList));17 $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'TimeCreate' => 'NOW()', 'CommandList' => $CommandList)); 18 18 } 19 19 … … 23 23 24 24 chdir($Config['BaseDir']); 25 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = 0 ORDER BY Id,Time ASC');25 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = 0 ORDER BY Id,TimeCreate ASC'); 26 26 $this->Database->query('UPDATE Task SET State=2 WHERE State=1'); // Change not finished running tasks to finished 27 27 while($Task = $DbResult->fetch_assoc()) 28 28 { 29 $this->Database->query('UPDATE Task SET State=1 WHERE Id='.$Task['Id']);29 $this->Database->query('UPDATE Task SET TimeStart=NOW(), State=1 WHERE Id='.$Task['Id']); 30 30 echo('Provádím úlohu '.$Task['Id'].': '.$Task['Title']."...\n"); 31 31 $Task['CommandList'] = "#!/bin/sh\n".str_replace("\r", '', $Task['CommandList']); … … 37 37 echo($Output); 38 38 echo("Hotovo\n"); 39 $this->Database->query('UPDATE Task SET State=2, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']);39 $this->Database->query('UPDATE Task SET TimeEnd=NOW(), State=2, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']); 40 40 } 41 41 } … … 44 44 { 45 45 $this->Database->query('DELETE FROM Task WHERE Id='.$Id); 46 } 46 } 47 47 } 48 48 -
trunk/www/types/DateTime.php
r24 r34 15 15 $TimeParts = explode(':', $ValueParts[1]); 16 16 17 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2].' '.($DateParts[2] * 1).'. '.$MonthNames[$DateParts[1] * 1].' '.$DateParts[0];17 $Output = ($DateParts[2] * 1).'.'.($DateParts[1] * 1).'.'.$DateParts[0].' '.$TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2]; 18 18 } else $Output = ''; 19 19 return($Output);
Note:
See TracChangeset
for help on using the changeset viewer.