Changeset 11
- Timestamp:
- Jun 11, 2009, 8:28:50 PM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 19 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/emulator.php
r6 r11 18 18 function AddTask($Title, $Task) 19 19 { 20 $this->Database->insert('Task', array('Server' => 0, 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task))); 20 global $System; 21 22 $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task))); 21 23 } 22 24 -
trunk/www/error.php
r3 r11 42 42 { 43 43 if(is_array($Item)) $Arguments .= "'".serialize($Item)."',"; 44 else $Arguments .= "'". $Item."',";44 else $Arguments .= "'".serialize($Item)."',"; 45 45 } 46 46 if(strlen($Arguments) > 0) $Error .= '('.substr($Arguments, 0, -1).')'; -
trunk/www/form.php
r10 r11 9 9 var $OnSubmit = ''; 10 10 11 function Form($ClassName)11 function __construct($ClassName) 12 12 { 13 13 global $FormClasses; … … 36 36 $Edit = ExecuteTypeEvent($Item['Type'], 'OnView', 37 37 array('Name' => $Index, 'Value' => $this->Values[$Index], 'Type' => $Item['Type'])); 38 /*39 switch($Item['Type'])40 {41 case 'Boolean':42 if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';43 $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.' />';44 break;45 case 'String':46 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';47 break;48 case 'Text':49 $Edit = '<textarea style="width: 100%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>';50 break;51 case 'Password':52 $Edit = '<input style="width: 100%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';53 break;54 case 'Integer':55 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';56 break;57 case 'Float':58 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';59 break;60 case 'Time':61 if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y');62 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';63 break;64 case 'Array':65 $Form = new Form($Item['ItemClass']);66 $Edit = '<script type="text/javascript" id="syndication">'.67 "var Count = 0;".68 "function AddItem() {".69 "Count = Count + 1;".70 "var newcontent = document.createElement('div');".71 "newcontent.id = '".$Context.$Item['ItemClass']."-' + Count;".72 "newcontent.innerHTML = '<input type=\"hidden\" name=\"".$Context.$Item['ItemClass']."-' + Count + '\">".$Form->ShowEditBlock($Context.$Item['ItemClass']."-' + Count + '")."';".73 "var scr = document.getElementById('syndication');".74 "scr.parentNode.insertBefore(newcontent, scr); }".75 '</script>';76 $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku" /></form>';77 break;78 default:79 if(array_key_exists($Item['Type'], $FormTypes))80 {81 // Custom types82 switch($FormTypes[$Item['Type']]['Type'])83 {84 case 'Enumeration':85 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';86 foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName)87 {88 if($this->Values[$Index] == $StateIndex) $Selected = 'selected="selected"';89 else $Selected = '';90 $Edit .= '<option value="'.$StateIndex.'"'.$Selected.'>'.$StateName.'</option>';91 }92 $Edit .= '</select>';93 break;94 case 'Reference':95 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';96 $DbResult = $Database->select($FormTypes[$Item['Type']]['Table'], $FormTypes[$Item['Type']]['Id'].' as Id, '.$FormTypes[$Item['Type']]['Name'].' as Name', $FormTypes[$Item['Type']]['Filter'].' ORDER BY Name');97 while($Row = $DbResult->fetch_assoc())98 {99 if($Row['Id'] == $this->Values[$Index]) $Selected = ' selected="selected"';100 else $Selected = '';101 $Edit .= '<option value="'.$Row['Id'].'"'.$Selected.'>'.$Row['Name'].'</option>';102 }103 $Edit .= '</select>';104 break;105 default:106 $Edit = 'Neznámý typ';107 }108 } else $Edit = 'Neznámý typ';109 }110 */111 38 array_push($Table['Rows'], array($Item['Caption'], $Edit)); 112 39 } … … 136 63 $Edit = ExecuteTypeEvent($Item['Type'], 'OnEdit', 137 64 array('Name' => $Index, 'Value' => $this->Values[$Index], 'Type' => $Item['Type'])); 138 /*139 switch($Item['Type'])140 {141 case 'Boolean':142 if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED';143 $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.' />';144 break;145 case 'String':146 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';147 break;148 case 'Text':149 $Edit = '<textarea style="width: 100%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>';150 break;151 case 'Password':152 $Edit = '<input style="width: 100%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';153 break;154 case 'Integer':155 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';156 break;157 case 'Float':158 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';159 break;160 case 'Time':161 if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y');162 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';163 break;164 case 'Array':165 $Form = new Form($Item['ItemClass']);166 $Edit = '<script type="text/javascript" id="syndication">'.167 "var Count = 0;".168 "function AddItem() {".169 "Count = Count + 1;".170 "var newcontent = document.createElement('div');".171 "newcontent.id = '".$Context.$Item['ItemClass']."-' + Count;".172 "newcontent.innerHTML = '<input type=\"hidden\" name=\"".$Context.$Item['ItemClass']."-' + Count + '\">".$Form->ShowEditBlock($Context.$Item['ItemClass']."-' + Count + '")."';".173 "var scr = document.getElementById('syndication');".174 "scr.parentNode.insertBefore(newcontent, scr); }".175 '</script>';176 $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku" /></form>';177 break;178 default:179 if(array_key_exists($Item['Type'], $FormTypes))180 {181 // Custom types182 switch($FormTypes[$Item['Type']]['Type'])183 {184 case 'Enumeration':185 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';186 foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName)187 {188 if($this->Values[$Index] == $StateIndex) $Selected = 'selected="selected"';189 else $Selected = '';190 $Edit .= '<option value="'.$StateIndex.'"'.$Selected.'>'.$StateName.'</option>';191 }192 $Edit .= '</select>';193 break;194 case 'Reference':195 $Edit = '<select style="width: 100%;" name="'.$Context.$Index.'">';196 $DbResult = $Database->select($FormTypes[$Item['Type']]['Table'], $FormTypes[$Item['Type']]['Id'].' as Id, '.$FormTypes[$Item['Type']]['Name'].' as Name', $FormTypes[$Item['Type']]['Filter'].' ORDER BY Name');197 while($Row = $DbResult->fetch_assoc())198 {199 if($Row['Id'] == $this->Values[$Index]) $Selected = ' selected="selected"';200 else $Selected = '';201 $Edit .= '<option value="'.$Row['Id'].'"'.$Selected.'>'.$Row['Name'].'</option>';202 }203 $Edit .= '</select>';204 break;205 default:206 $Edit = 'Neznámý typ';207 }208 } else $Edit = 'Neznámý typ';209 }210 */211 65 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 212 66 } … … 225 79 { 226 80 $this->Values[$Index] = $DbRow[$Index]; 227 switch($Item['Type'])228 {229 case 'Password':230 if($Item['Type'] == 'Password') $this->Values[$Index] = ''; // Dont show password231 break;232 case 'Time':233 $this->Values[$Index] == MysqlDateTimeToTime($this->Values[$Index]);234 break;235 }236 81 } 237 82 } … … 241 86 global $Database; 242 87 243 foreach($this->Definition['Items'] as $Index => $Item)244 {245 switch($Item['Type'])246 {247 case 'Password':248 if($this->Values[$Index] == '') unset($this->Values[$Index]); // Do not modify empty passwords249 else $this->Values[$Index] = sha1($this->Values[$Index]);250 break;251 case 'Time':252 $this->Values[$Index] = TimeToMysqlDateTime($this->Values[$Index]);253 break;254 }255 }256 88 if($Id == 0) 257 89 { … … 260 92 } else 261 93 $DbResult = $Database->update($this->Definition['Table'], 'Id='.$Id, $this->Values); 262 //echo($Database->LastQuery);263 94 } 264 95 … … 279 110 $Values[$Index] = ExecuteTypeEvent($Item['Type'], 'OnLoad', 280 111 array('Name' => $Index, 'Type' => $Item['Type'])); 281 /*282 switch($Item['Type'])283 {284 case 'Boolean':285 if(array_key_exists($Context.$Index, $_POST)) $Values[$Index] = 1;286 else $Values[$Index] = 0;287 break;288 case 'String':289 $Values[$Index] = $_POST[$Context.$Index];290 break;291 case 'Text':292 $Values[$Index] = $_POST[$Context.$Index];293 break;294 case 'Password':295 $Values[$Index] = $_POST[$Context.$Index];296 break;297 case 'Integer':298 $Values[$Index] = $_POST[$Context.$Index];299 break;300 case 'Float':301 $Values[$Index] = $_POST[$Context.$Index];302 break;303 case 'Time':304 $Values[$Index] = explode('.', $_POST[$Context.$Index]);305 $Values[$Index] = mktime(0, 0, 0, $Values[$Index][1], $Values[$Index][0], $Values[$Index][2]);306 break;307 case 'Array':308 $I = 1;309 //echo('Expect: '.$Context.$Item['ItemClass'].'-'.$I.'<br />');310 while(isset($_POST[$Context.$Item['ItemClass'].'-'.$I]))311 {312 $Form = new Form($Item['ItemClass']);313 $Values[$Index][] = $Form->LoadValuesFromFormBlock($Context.$Item['ItemClass'].'-'.$I);314 $I++;315 }316 break;317 default:318 if(array_key_exists($Item['Type'], $FormTypes))319 {320 // Custom types321 switch($FormTypes[$Item['Type']]['Type'])322 {323 case 'Enumeration':324 $Values[$Index] = $_POST[$Context.$Index];325 break;326 case 'Reference':327 $Values[$Index] = $_POST[$Context.$Index];328 break;329 default:330 }331 }332 }333 */334 112 } 335 113 return($Values); … … 337 115 } 338 116 339 function MakeLink($Target, $Title)340 {341 return('<a href="'.$Target.'">'.$Title.'</a>');342 }343 344 function Table($Table, $Class)345 {346 $Result = '<table class="'.$Class.'">';347 if(array_key_exists('Header', $Table))348 {349 $Result .= '<tr>';350 foreach($Table['Header'] as $Item)351 $Result .= '<th>'.$Item.'</th>';352 $Result .= '</tr>';353 }354 foreach($Table['Rows'] as $Row)355 {356 $Result .= '<tr>';357 foreach($Row as $Index => $Item)358 {359 if($Index == 0) $Class = ' class="Header"'; else $Class = '';360 $Result .= '<td'.$Class.'>'.$Item.'</td>';361 }362 $Result .= '</tr>';363 }364 $Result .= '</table>';365 return($Result);366 }367 368 function ShowEditTable($ClassName, $Values)369 {370 }371 372 117 ?> -
trunk/www/form_classes.php
r10 r11 62 62 'Database' => array('Type' => 'Database', 'Caption' => 'Databáze', 'Default' => 0), 63 63 'Motd' => array('Type' => 'String', 'Caption' => 'Zpráva dne', 'Default' => 'Vítejte na free WoW serveru'), 64 //'TimeCreation' => array('Type' => 'DateTime', 'Caption' => 'Datum založení', 'Default' => 'NOW()'), 65 ), 66 ), 67 'ServerList' => array( 68 'Title' => 'Server', 69 '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', 70 'Items' => array( 71 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 72 'UserName' => array('Type' => 'String', 'Caption' => 'Správce', 'Default' => ''), 73 'NetworkPortRealmd' => array('Type' => 'Integer', 'Caption' => 'Realmd port', 'Default' => ''), 74 'Version' => array('Type' => 'Integer', 'Caption' => 'Verze', 'Default' => 0), 75 'Online' => array('Type' => 'OnlineState', 'Caption' => 'Stav', 'Default' => 0), 76 'CharacterCount' => array('Type' => 'Integer', 'Caption' => 'Hráčů online', 'Default' => 0), 77 'AccountCount' => array('Type' => 'Integer', 'Caption' => 'Účtů', 'Default' => 0), 78 'CharacterCount' => array('Type' => 'Integer', 'Caption' => 'Postav', 0), 79 ), 80 ), 81 'EmulatorList' => array( 82 'Title' => 'Emulátor', 83 'Table' => '(SELECT `Emulator`.`Name`, `ClientVersion`.`Version` AS `ClientVersion`, `Emulator`.`Revision`, `Emulator`.`ScriptDev2Revision`, `Emulator`.`ScriptDev2PatchFileName`, `Emulator`.`CommitHash` FROM `Emulator` JOIN `ClientVersion` ON `ClientVersion`.`Id` = `Emulator`.`ClientVersion`) AS T', 84 'Items' => array( 85 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 86 'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0), 87 'ClientVersion' => array('Type' => 'Integer', 'Caption' => 'Verze klienta', 'Default' => 0), 88 'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0), 89 'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''), 90 'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''), 91 ), 92 ), 93 'EmulatorItem' => array( 94 'Title' => 'Emulátor', 95 'Table' => 'Emulator', 96 'Items' => array( 97 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 98 'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0), 99 //'ClientVersion' => array('Type' => 'PointerOneToOne', 'Caption' => 'Verze klienta', 'Default' => 0), 100 'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0), 101 'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''), 102 'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''), 64 103 ), 65 104 ), … … 67 106 68 107 RegisterType('ServerType', 'Enumeration', array('Normální', 'PvP', 'RP', 'RPPvP')); 108 RegisterType('OnlineState', 'Enumeration', array('Neaktivní', 'Aktivní')); 109 69 110 //RegisterType('Database', 'PointerOneToOne', array('Table' => 'Database', 'Id' => 'Id', 'Name' => 'CONCAT(Name, " ", Version, " r", Revision)')); 70 111 -
trunk/www/global.php
r9 r11 314 314 } 315 315 316 function MakeLink($Target, $Title) 317 { 318 return('<a href="'.$Target.'">'.$Title.'</a>'); 319 } 320 321 function Table($Table, $Class) 322 { 323 $Result = '<table class="'.$Class.'">'; 324 if(array_key_exists('Header', $Table)) 325 { 326 $Result .= '<tr>'; 327 foreach($Table['Header'] as $Item) 328 $Result .= '<th>'.$Item.'</th>'; 329 $Result .= '</tr>'; 330 } 331 foreach($Table['Rows'] as $Row) 332 { 333 $Result .= '<tr>'; 334 foreach($Row as $Index => $Item) 335 { 336 if($Index == 0) $Class = ' class="Header"'; else $Class = ''; 337 $Result .= '<td'.$Class.'>'.$Item.'</td>'; 338 } 339 $Result .= '</tr>'; 340 } 341 $Result .= '</table>'; 342 return($Result); 343 } 344 316 345 ?> -
trunk/www/index.php
r10 r11 8 8 var $ShortTitle = 'Seznam serverů'; 9 9 10 function ShowServerListOnRow($Row) 11 { 12 $Server = new Server($this->Database, $Row['Id']); 13 $ServerState = $Server->GetState(); 14 $Row['Online'] = $ServerState['Online'] * 1; 15 $Row['NetworkPortRealmd'] = $this->System->Config['Web']['Host'].':'.$Row['NetworkPortRealmd']; 16 $Row['Name'] = '<a href="?Action=ServerShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 17 $Row['AccountCount'] = $ServerState['AccountCount']; 18 $Row['CharacterCount'] = $ServerState['CharacterCount']; 19 $Row['OnlinePlayerCount'] = $ServerState['OnlinePlayerCount']; 20 return($Row); 21 } 22 10 23 function ShowServerList() 11 24 { 12 25 global $Config; 13 26 14 $OnlineState = array(false => 'Neaktivní', true => 'Aktivní');15 27 $Output = '<h4>Seznam serverů</h4>'; 16 $Output .= '<table class="WideTable"><tr><th>Název</th><th>Uživatel</th><th>Realmd</th><th>Verze hry</th><th>Stav</th><th>Hráčů online</th><th>Účtů</th><th>Postav</th></tr>'; 17 $DbResult = $this->Database->query('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`'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Server = new Server($this->Database, $DbRow['Id']); 21 $ServerState = $Server->GetState(); 22 $Output .= '<tr><td><a href="?Action=ServerShow&Id='.$DbRow['Id'].'">'.$DbRow['Name'].'</a></td><td>'.$DbRow['UserName'].'</td><td>'.$this->System->Config['Web']['Host'].':'.$DbRow['NetworkPortRealmd'].'</td><td>'.$DbRow['Version'].'</td><td>'.$OnlineState[$ServerState['Online']].'</td><td>'.$ServerState['OnlinePlayerCount'].'</td><td>'.$ServerState['AccountCount'].'</td><td>'.$ServerState['CharacterCount'].'</td></tr>'; 23 } 24 $Output .= '</table>'; 28 $Table = new Table('ServerList'); 29 $Table->OnRow = array($this, 'ShowServerListOnRow'); 30 $Table->LoadValuesFromDatabase($this->Database); 31 $Output .= $Table->Show(); 25 32 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) 26 33 { … … 28 35 $DbRow = $DbResult->fetch_row(); 29 36 $ServerCount = $DbRow[0]; 30 if($ServerCount < $Config['MaxServerCount']) 37 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->System->Modules['User']->User['Id']); 38 $DbRow = $DbResult->fetch_row(); 39 if(($ServerCount < $Config['MaxServerCount']) and ($DbRow[0] == 0)) 31 40 $Output .= '<br /><div style="text-align: center;"><a href="?Action=ServerAdd">Vytvořit nový server</a></dev>'; 32 41 } … … 41 50 $Form->LoadValuesFromDatabase($Id); 42 51 $Output .= $Form->ShowTable(); 43 /*44 $Output .= '<table class="WideTable"><tr><th>Položka</th><th>Hodnota</th></tr>';45 $Output .= '<tr><td>Jméno</td><td>'.$Server->Server['Name'].'</td></tr>'.46 '<tr><td>Webové stránky</td><td><a href="'.$Server->Server['Homepage'].'">'.$Server->Server['Homepage'].'</a></td></tr>'.47 '<tr><td>Popis</td><td>'.$Server->Server['Description'].'</td></tr>'.48 '<tr><td>Zpráva dne</td><td>'.$Server->Server['Motd'].'</td></tr>'.49 '<tr><td>Síťový port realmd</td><td>'.($Server->RealmdBaseNetworkPort + $Server->Id).'</td></tr>'.50 '<tr><td>Síťový port mangosd</td><td>'.($Server->WorlddBaseNetworkPort + $Server->Id).'</td></tr>';51 $Output .= '</table>52 */53 52 $Output .= '<div style="text-align: center">'; 54 53 if(($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER) and ($this->System->Modules['User']->User['Id'] == $Server->Server['User'])) … … 58 57 { 59 58 $ServerStatus = $Server->GetState(); 60 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit server</a> <a href="?Action=ServerRestart">RestartovatServer</a>';61 else $Output .= ' <a href="?Action=ServerStart">Spustit server</a>';59 if($ServerStatus['RealmdPortState'] == true) $Output .= ' <a href="?Action=ServerStop">Zastavit</a> <a href="?Action=ServerRestart">Restartovat</a>'; 60 else $Output .= ' <a href="?Action=ServerStart">Spustit</a>'; 62 61 } 63 $Output .= ' <a href="?Action=ServerEdit">Upravit server</a>';62 $Output .= ' <a href="?Action=ServerEdit">Upravit</a>'; 64 63 $Output .= ' <a href="?Action=ServerDatabaseImport">Načtení čisté databáze</a>'; 65 64 } … … 68 67 } 69 68 69 function ShowEmulatorListOnRow($Row) 70 { 71 $Row['Name'] = '<a href="?Action=EmulatorShow&Id='.$Row['Id'].'">'.$Row['Name'].'</a>'; 72 return($Row); 73 } 74 75 function ShowEmulatorList() 76 { 77 global $Config; 78 79 $Output = '<h4>Seznam verzí emulátoru</h4>'; 80 $Table = new Table('EmulatorList'); 81 $Table->OnRow = array($this, 'ShowEmulatorListOnRow'); 82 $Table->LoadValuesFromDatabase($this->Database); 83 $Output .= $Table->Show(); 84 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 85 { 86 $Output .= '<br /><div style="text-align: center;"><a href="?Action=EmulatorAdd">Přidat emulátor</a></dev>'; 87 } 88 return($Output); 89 } 90 91 function EmulatorShow($Id) 92 { 93 //$Server = new Server($this->Database, $Id); 94 $Output = '<h4>Podrobnosti emulátoru</h4>'; 95 $Form = new Form('EmulatorItem'); 96 $Form->LoadValuesFromDatabase($Id); 97 $Output .= $Form->ShowTable(); 98 $Output .= '<div style="text-align: center">'; 99 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR) 100 { 101 $Output .= ' <a href="?Action=EmulatorCompile&Id='.$Id.'">Přeložit</a>'; 102 $Output .= ' <a href="?Action=EmulatorDownloadAndCompile&Id='.$Id.'">Stáhnout a přeložit</a>'; 103 } 104 $Output .= '</div>'; 105 return($Output); 106 } 107 70 108 function Show() 71 109 { 110 global $Config; 111 72 112 $Output = ''; 73 113 if(array_key_exists('Action', $_GET)) … … 278 318 } else $Output .= USER_BAD_ROLE; 279 319 } else 320 if($_GET['Action'] == 'EmulatorShow') 321 { 322 if(array_key_exists('Id', $_GET)) 323 { 324 $Output .= $this->EmulatorShow($_GET['Id']); 325 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 326 } else 327 if($_GET['Action'] == 'EmulatorList') 328 { 329 $Output .= $this->ShowEmulatorList(); 330 } else 331 if($_GET['Action'] == 'EmulatorCompile') 332 { 333 if(array_key_exists('Id', $_GET)) 334 { 335 $Emulator = new Emulator($this->Database, $_GET['Id']); 336 $Emulator->Compile(); 337 $Output .= $this->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty'); 338 } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id'); 339 } else 280 340 if($_GET['Action'] == 'Test') 281 341 { 282 $Emulator = new Emulator($this->Database, 2);283 $Emulator->Compile();342 //$Emulator = new Emulator($this->Database, 2); 343 // $Emulator->Compile(); 284 344 //$Server = new Server($this->Database, 1); 285 345 //$Output .= $Server->ImportDatabase(); -
trunk/www/process_tasks.php
r9 r11 3 3 include('global.php'); 4 4 5 $Task = new Task( );5 $Task = new Task($Database); 6 6 $Task->ProcessAll(); 7 7 -
trunk/www/server.php
r9 r11 31 31 function AddTask($Title, $Task) 32 32 { 33 $this->Database->insert('Task', array('User' => $this->System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task))); 33 global $System; 34 35 $this->Database->insert('Task', array('User' => $System->Modules['User']->User['Id'], 'Title' => $Title, 'Time' => 'NOW()', 'CommandList' => implode("\n", $Task))); 34 36 } 35 37 -
trunk/www/sql/updates/9.sql
r10 r11 1 ALTER TABLE `Task` CHANGE `Executed` ` Executed` ENUM( 'Waiting', 'Running', 'Finished' ) NOT NULL ;1 ALTER TABLE `Task` CHANGE `Executed` `State` ENUM( 'Waiting', 'Running', 'Finished' ) NOT NULL ; 2 2 3 3 ALTER TABLE `Task` CHANGE `Server` `User` INT( 11 ) NOT NULL ; -
trunk/www/table.php
r10 r11 5 5 var $Id; 6 6 var $Definition; 7 var $Values; 8 var $Header; 9 var $OnRow; 10 11 function __construct($ClassName) 12 { 13 global $FormClasses; 14 15 $this->Definition = &$FormClasses[$ClassName]; 16 } 7 17 8 18 function Show() 9 19 { 20 $Table = array( 21 'Header' => $this->Header, 22 'Rows' => $this->Values, 23 ); 24 $Output = Table($Table, 'WideTable'); 25 return($Output); 10 26 } 27 28 function LoadValuesFromDatabase($Database) 29 { 30 $this->Header = array(); 31 foreach($this->Definition['Items'] as $Index => $Item) 32 { 33 $this->Header[] = $Item['Caption']; 34 35 } 36 $this->Values = array(); 37 $DbResult = $Database->query('SELECT * FROM '.$this->Definition['Table']); 38 while($DbRow = $DbResult->fetch_assoc()) 39 { 40 if(method_exists($this->OnRow[0], $this->OnRow[1])) 41 { 42 $Object = $this->OnRow[0]; 43 $Method = $this->OnRow[1]; 44 $DbRow = $Object->$Method($DbRow); 45 } 46 $Row = array(); 47 foreach($this->Definition['Items'] as $Index => $Item) 48 { 49 $Row[] = $DbRow[$Index]; 50 } 51 $this->Values[] = $Row; 52 } 53 } 11 54 } 12 55 -
trunk/www/task.php
r10 r11 15 15 16 16 chdir($Config['BaseDir']); 17 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = WaitingORDER BY Id,Time ASC');17 $DbResult = $this->Database->query('SELECT * FROM Task WHERE State = "Waiting" ORDER BY Id,Time ASC'); 18 18 while($Task = $DbResult->fetch_assoc()) 19 19 { 20 $this->Database->query('UPDATE Task SET State= RunningWHERE Id='.$Task['Id']);20 $this->Database->query('UPDATE Task SET State="Running" WHERE Id='.$Task['Id']); 21 21 echo('Provádím '.$Task['Title']."...\n"); 22 22 $Task['CommandList'] = "#!/bin/sh\n".$Task['CommandList']; … … 27 27 $Output = ''; //implode("\n", $Output); 28 28 //echo($Output); 29 $this->Database->query('UPDATE Task SET State= Finished, Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']);29 $this->Database->query('UPDATE Task SET State="Finished", Output="'.addslashes($Output).'" WHERE Id='.$Task['Id']); 30 30 } 31 31 return($Output); … … 35 35 { 36 36 $Output = ''; 37 $DbResult = $this->Database->query('SELECT * FROM Task WHERE (State IN ( Waiting, Running)) AND (User='.$UserId.') ORDER BY Id,Time ASC');37 $DbResult = $this->Database->query('SELECT * FROM Task WHERE (State IN ("Waiting", "Running")) AND (User='.$UserId.') ORDER BY Id,Time ASC'); 38 38 while($DbRow = $DbResult->fetch_assoc()) 39 39 {
Note:
See TracChangeset
for help on using the changeset viewer.