Changeset 867
- Timestamp:
- Jan 13, 2020, 12:26:00 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UpdateTrace.php
r862 r867 2063 2063 $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD INDEX ( `Previous` )'); 2064 2064 $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS T1, `NetworkInterfaceUpDown` AS T2 SET T1.Previous = T2.Id WHERE (T1.Previous IS NULL) AND (T2.Interface=T1.Interface) AND (T1.Time = DATE_ADD(T2.Time, INTERVAL T2.Duration SECOND))'); 2065 } 2066 2067 function UpdateTo867($Manager) 2068 { 2069 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NotifyLog` ( 2070 `Id` int(11) NOT NULL AUTO_INCREMENT, 2071 `Time` datetime NOT NULL, 2072 `Title` varchar(255) NOT NULL DEFAULT "", 2073 `Content` mediumtext NOT NULL DEFAULT "", 2074 PRIMARY KEY (`Id`), 2075 KEY `Time` (`Time`) 2076 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); 2077 2065 2078 } 2066 2079 … … 2162 2175 844 => array('Revision' => 855, 'Function' => 'UpdateTo855'), 2163 2176 855 => array('Revision' => 862, 'Function' => 'UpdateTo862'), 2177 862 => array('Revision' => 867, 'Function' => 'UpdateTo867'), 2164 2178 )); 2165 2179 } -
trunk/Application/Version.php
r866 r867 1 1 <?php 2 2 3 $Revision = 86 6; // Subversion revision4 $DatabaseRevision = 86 2; // SQL structure revision5 $ReleaseTime = strtotime('20 19-12-23');3 $Revision = 867; // Subversion revision 4 $DatabaseRevision = 867; // SQL structure revision 5 $ReleaseTime = strtotime('2020-01-13'); -
trunk/Modules/Network/Network.php
r865 r867 132 132 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort', 133 133 array($this, 'PortCheck')); 134 135 134 136 135 $this->System->RegisterPage('network', 'PageNetwork'); … … 816 815 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>'); 817 816 $Output = ''; 818 $Condition = 'WHERE (`NetworkInterface`.`Online` = '.$OnlineNow.') AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.') '. 819 'AND (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")'; 817 $Condition = 'WHERE (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")'; 818 if ($OnlineNow != null) $Condition .= ' AND (`NetworkInterface`.`Online` = '.$OnlineNow.')'; 819 if ($OnlinePrevious != null) $Condition .= ' AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.')'; 820 820 $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '. 821 821 '`NetworkInterface`.`Online`, `NetworkInterface`.`LastOnline` FROM `NetworkInterface` '. … … 845 845 $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '. 846 846 $Condition); 847 return $Output;847 return array('Report' => $Output, 'Count' => $DbResult3->num_rows); 848 848 } 849 849 850 850 function ReachabilityCheck() 851 851 { 852 $Output = ''; 853 $Output = $this->OnlineList('Nově online', 1, 0, 0); 854 $Output .= $this->OnlineList('Nově offline', 0, 1, $this->MinNotifyTime); 855 if($Output != '') $Output .= $this->OnlineList('Stále offline', 0, 0, 0); 856 return($Output); 852 $NewOnline = $this->OnlineList('Nově online', 1, 0, 0); 853 $Output = $NewOnline['Report']; 854 $NewOffline = $this->OnlineList('Nově offline', 0, 1, $this->MinNotifyTime); 855 $Output .= $NewOffline['Report']; 856 if ($Output != '') 857 { 858 $StillOffline = $this->OnlineList('Stále offline', 0, 0, 0); 859 $Output .= $StillOffline['Report']; 860 } 861 $Offline = $this->OnlineList('Offline', 0, null, 0); 862 return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva')); 857 863 } 858 864 … … 862 868 $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>'); 863 869 $Output = ''; 864 $Condition = 'WHERE (`NetworkPort`.`Online` = '.$OnlineNow.') AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.') '. 865 'AND (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")'; 870 $Condition = 'WHERE (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")'; 871 if ($OnlineNow != null) $Condition .= ' AND (`NetworkPort`.`Online` = '.$OnlineNow.')'; 872 if ($OnlinePrevious != null) $Condition .= ' AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.')'; 866 873 $DbResult3 = $this->Database->query('SELECT CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`, "(", `NetworkPort`.`Name`, ")") AS `Name`, '. 867 874 '`NetworkPort`.`Online`, `NetworkPort`.`LastOnline` FROM `NetworkPort` '. … … 871 878 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkPort`.`Enabled` = 1)'. 872 879 'ORDER BY `Name` ASC'); 873 if ($DbResult3->num_rows > 0)880 if ($DbResult3->num_rows > 0) 874 881 { 875 882 $Output .= $Title.'<br/>'; … … 892 899 $this->Database->query('UPDATE `NetworkPort` SET `OnlineNotify` = `Online` '. 893 900 $Condition); 894 return $Output;901 return array('Report' => $Output, 'Count' => $DbResult3->num_rows); 895 902 } 896 903 … … 898 905 { 899 906 $Output = ''; 900 $Output = $this->PortCheckList('Nově online', 1, 0, 0); 901 $Output .= $this->PortCheckList('Nově offline', 0, 1, $this->MinNotifyTime); 902 if($Output != '') $Output .= $this->PortCheckList('Stále offline', 0, 0, 0); 903 return($Output); 907 $NewOnline = $this->PortCheckList('Nově online', 1, 0, 0); 908 $Output .= $NewOnline['Report']; 909 $NewOffline = $this->PortCheckList('Nově offline', 0, 1, $this->MinNotifyTime); 910 $Output .= $NewOffline['Report']; 911 if ($Output != '') 912 { 913 $StillOffline = $this->PortCheckList('Stále offline', 0, 0, 0); 914 $Output .= $StillOffline['Report']; 915 } 916 $Offline = $this->PortCheckList('Offline', 0, null, 0); 917 return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port')); 904 918 } 905 919 } -
trunk/Modules/Notify/Notify.php
r830 r867 15 15 $this->License = 'GNU/GPL'; 16 16 $this->Description = 'Send notification messages to selected users'; 17 $this->Dependencies = array('User' );17 $this->Dependencies = array('User', 'RSS'); 18 18 $this->Checks = array(); 19 19 } … … 39 39 )); 40 40 $this->System->RegisterCommandLine('notify', array($this, 'RunCheck')); 41 $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log', 42 'Channel' => 'notifylog', 'Callback' => array('ModuleNotify', 'ShowLogRSS'), 43 'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS'))); 41 44 } 42 45 … … 59 62 $Output = ''; 60 63 $Content = ''; 64 $Title = ''; 61 65 62 66 // Get output from checks 63 67 $DbResult2 = $this->Database->query('SELECT `Id`, `Name`, `SysName` FROM `NotifyCategory`'); 64 while ($Category = $DbResult2->fetch_assoc())68 while ($Category = $DbResult2->fetch_assoc()) 65 69 { 66 if (array_key_exists($Category['SysName'], $this->Checks))70 if (array_key_exists($Category['SysName'], $this->Checks)) 67 71 { 68 $List = call_user_func($this->Checks[$Category['SysName']]['Callback']); 69 if($List != '') { 72 $Status = call_user_func($this->Checks[$Category['SysName']]['Callback']); 73 if ($Status['Report'] != '') 74 { 70 75 $Output .= 'Kategorie: '.$Category['Name'].":\n"; 71 76 $Content .= 'Kategorie: '.$Category['Name']."<br>\n"; 72 $Content .= $ List;77 $Content .= $Status['Report']; 73 78 } 79 if (strlen($Title) > 0) $Title .= ', '; 80 $Title .= $Status['ShortTitle'].':'.$Status['Count']; 74 81 } 75 82 } 83 84 $Time = time(); 76 85 77 86 // Send content to users … … 81 90 while($User = $DbResult->fetch_assoc()) 82 91 { 83 $Time = time();84 92 $Output .= 'User '.$User['Name'].'<br/>'; 85 93 86 94 $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time))); 87 95 88 if(($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content !='')) { 96 if(($User['Category'] == CONTACT_CATEGORY_EMAIL) and ($Content != '')) 97 { 89 98 $Mail = new Mail(); 90 99 $Mail->Subject = 'Notification'; … … 102 111 103 112 return($Output); 113 } 114 115 if ($Content != '') 116 { 117 $this->Database->insert('NotifyLog', array( 118 'Time' => TimeToMysqlDateTime($Time), 119 'Title' => $Title, 120 'Content' => $Content) 121 ); 104 122 } 105 123 } … … 147 165 $this->Database->query('DROP TABLE `NotifyCategory`'); 148 166 } 167 168 function ShowLogRSS() 169 { 170 $this->ClearPage = true; 171 $this->FormatHTML = false; 172 Header('Content-Type: text/xml'); 173 $Count = 100; 174 175 $Output = ''; 176 $Items = array(); 177 $sql = 'SELECT Title,Content, UNIX_TIMESTAMP(`Time`) AS `Time` FROM `NotifyLog`'. 178 ' ORDER BY `Time` DESC LIMIT '.$Count; 179 $DbResult = $this->System->Database->query($sql); 180 while($Line = $DbResult->fetch_assoc()) 181 { 182 $Items[] = array 183 ( 184 'Title' => $Line['Title'], 185 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/Notify.php'), 186 'Description' => $Line['Content'], 187 'Time' => $Line['Time'], 188 ); 189 } 190 191 $RSS = new RSS(); 192 $RSS->Title = $this->System->Config['Web']['Title'].' - Záznamy upozornění'; 193 $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 194 $RSS->Description = 'Záznam upozornění '.$this->System->Config['Web']['Description']; 195 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 196 $RSS->Items = $Items; 197 return($RSS->Generate()); 198 } 149 199 }
Note:
See TracChangeset
for help on using the changeset viewer.