1 | <?php
|
---|
2 |
|
---|
3 | class ServiceRestartPage extends Page
|
---|
4 | {
|
---|
5 | var $FullTitle = 'Restart služeb';
|
---|
6 | var $ShortTitle = 'Restart služeb';
|
---|
7 | var $State = array('Neplánováno', 'V plánu', 'Provádí se');
|
---|
8 |
|
---|
9 | function ShowLog($Id)
|
---|
10 | {
|
---|
11 | $DbResult = $this->Database->select('NetworkConfiguration', 'Caption, Log', 'Id='.$Id);
|
---|
12 | $DbRow = $DbResult->fetch_assoc();
|
---|
13 | $Output = '<div>Chybový záznam pro '.$DbRow['Caption'].':</div><pre>';
|
---|
14 | $Output .= $DbRow['Log'];
|
---|
15 | $Output .= '</pre>';
|
---|
16 | return($Output);
|
---|
17 | }
|
---|
18 |
|
---|
19 | function ShowConfiguration()
|
---|
20 | {
|
---|
21 | if(array_key_exists('set', $_POST))
|
---|
22 | {
|
---|
23 | foreach($_POST as $Index => $Item)
|
---|
24 | {
|
---|
25 | if(is_numeric($Index))
|
---|
26 | {
|
---|
27 | $Id = addslashes($Index);
|
---|
28 | $this->Database->update('NetworkConfiguration', 'Id='.$Id, array('Changed' => 1));
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
32 | $Output = 'Vyberte konfigurace, které chcete restartovat:<br><form method="post">';
|
---|
33 | $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>';
|
---|
34 | $DbResult = $this->Database->select('NetworkConfiguration', '*, UNIX_TIMESTAMP(LastTime)', 'Enabled = 1');
|
---|
35 | while($Service = $DbResult->fetch_array())
|
---|
36 | {
|
---|
37 | if($Service['Changed'] == 1)
|
---|
38 | {
|
---|
39 | $RemainingTime = $Service['Period'] - (time() - $Service['UNIX_TIMESTAMP(LastTime)']);
|
---|
40 | if($RemainingTime < 0) $RemainingTime = 0;
|
---|
41 | $Schedule = date('i:s', $RemainingTime);
|
---|
42 | } else $Schedule = ' ';
|
---|
43 | $Output .= '<tr><td style="text-align: left;"><input type="checkbox" name="'.$Service['Id'].'"><a href="?Action=Log&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>';
|
---|
44 | }
|
---|
45 | $Output .= '</table><input type="submit" name="set" value="Naplánovat restart vybraných"></form>';
|
---|
46 | return($Output);
|
---|
47 | }
|
---|
48 |
|
---|
49 | function Show()
|
---|
50 | {
|
---|
51 | if(!$this->System->Models['User']->CheckPermission('Network', 'Administration')) return('Nemáte oprávnění');
|
---|
52 |
|
---|
53 | if(array_key_exists('Action', $_GET))
|
---|
54 | {
|
---|
55 | if($_GET['Action'] == 'Log') $Output = $this->ShowLog($_GET['Id']);
|
---|
56 | else $Output = $this->ShowConfiguration();
|
---|
57 | } else $Output = $this->ShowConfiguration();
|
---|
58 | return($Output);
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | ?>
|
---|