source: trunk/network/restart.php@ 441

Last change on this file since 441 was 438, checked in by chronos, 13 years ago
  • Přesunuto: Soubory s třídamy přesunuty do podsložky Common. Aktualizovány odkazy mezi soubory.
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1<?php
2
3include_once('../Common/Global.php');
4
5class ServiceRestartPage extends Page
6{
7 var $FullTitle = 'Restart služeb';
8 var $ShortTitle = 'Restart služeb';
9 var $State = array('Neplánováno', 'V plánu', 'Provádí se');
10
11 function ShowLog($Id)
12 {
13 $DbResult = $this->Database->select('NetworkConfiguration', 'Caption, Log', 'Id='.$Id);
14 $DbRow = $DbResult->fetch_assoc();
15 $Output = '<div>Chybový záznam pro '.$DbRow['Caption'].':</div><pre>';
16 $Output .= $DbRow['Log'];
17 $Output .= '</pre>';
18 return($Output);
19 }
20
21 function ShowConfiguration()
22 {
23 if(array_key_exists('set', $_POST))
24 {
25 foreach($_POST as $Index => $Item)
26 {
27 if(is_numeric($Index))
28 {
29 $Id = addslashes($Index);
30 $this->Database->update('NetworkConfiguration', 'Id='.$Id, array('Changed' => 1));
31 }
32 }
33 }
34 $Output = 'Vyberte konfigurace, které chcete restartovat:<br><form method="post">';
35 $Output .= '<table class="WideTable"><tr><th>Služba</th><th>Restart</th><th>Zbývající čas</th><th>Poslední délka [s]</th><th>Perioda [s]</th></tr>';
36 $DbResult = $this->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(LastTime)', 'Enabled = 1');
37 while($Service = $DbResult->fetch_array())
38 {
39 if($Service['Changed'] == 1)
40 {
41 $RemainingTime = $Service['Period'] - (time() - $Service['UNIX_TIMESTAMP(LastTime)']);
42 if($RemainingTime < 0) $RemainingTime = 0;
43 $Schedule = date('i:s', $RemainingTime);
44 } else $Schedule = '&nbsp;';
45 $Output .= '<tr><td style="text-align: left;"><input type="checkbox" name="'.$Service['Id'].'"><a href="?Action=Log&amp;Id='.$Service['Id'].'">'.$Service['Caption'].'</a></td><td>'.$this->State[$Service['Changed']].'</td><td>'.$Schedule.'</td><td>'.$Service['ExecutionTime'].'</td><td>'.$Service['Period'].'</td></tr>';
46 }
47 $Output .= '</table><input type="submit" name="set" value="Naplánovat restart vybraných"></form>';
48 return($Output);
49 }
50
51 function Show()
52 {
53 if(!$this->System->Modules['User']->CheckPermission('Network', 'Administration')) return('Nemáte oprávnění');
54
55 if(array_key_exists('Action', $_GET))
56 {
57 if($_GET['Action'] == 'Log') $Output = $this->ShowLog($_GET['Id']);
58 else $Output = $this->ShowConfiguration();
59 } else $Output = $this->ShowConfiguration();
60 return($Output);
61 }
62}
63
64$System->AddModule(new ServiceRestartPage());
65$System->Modules['ServiceRestartPage']->GetOutput();
66
67?>
Note: See TracBrowser for help on using the repository browser.