From 5ca959fa688255a8de61f89fe2751eb4d24a6912 Mon Sep 17 00:00:00 2001 From: Florian Schaal <florian@schaal-24.de> Date: Tue, 22 Mar 2016 09:22:07 -0400 Subject: [PATCH] fixed typo --- server/lib/classes/monitor_tools.inc.php | 103 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 93 insertions(+), 10 deletions(-) diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php index d754097..9493dc6 100644 --- a/server/lib/classes/monitor_tools.inc.php +++ b/server/lib/classes/monitor_tools.inc.php @@ -62,6 +62,24 @@ $mainver = array_filter($mainver); $mainver = current($mainver).'.'.next($mainver); switch ($mainver){ + case "15.10": + $relname = "(Wily Werewolf)"; + break; + case "15.04": + $relname = "(Vivid Vervet)"; + break; + case "14.10": + $relname = "(Utopic Unicorn)"; + break; + case "14.04": + $relname = "(Trusty Tahr)"; + break; + case "13.10": + $relname = "(Saucy Salamander)"; + break; + case "13.04": + $relname = "(Raring Ringtail)"; + break; case "12.10": $relname = "(Quantal Quetzal)"; break; @@ -137,6 +155,11 @@ $distver = 'Wheezy/Sid'; $distid = 'debian60'; $distbaseid = 'debian'; + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')),0,1) == '8') { + $distname = 'Debian'; + $distver = 'Jessie'; + $distid = 'debian60'; + $distbaseid = 'debian'; } else { $distname = 'Debian'; $distver = 'Unknown'; @@ -201,6 +224,16 @@ $distver = '5.3'; $distid = 'centos53'; $distbaseid = 'fedora'; + } elseif(stristr($content, 'CentOS Linux release 6')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos53'; + $distbaseid = 'fedora'; + } elseif(stristr($content, 'CentOS Linux release 7')) { + $distname = 'CentOS'; + $distver = 'Unknown'; + $distid = 'centos53'; + $distbaseid = 'fedora'; } else { $distname = 'Redhat'; $distver = 'Unknown'; @@ -237,7 +270,7 @@ $server_id = intval($conf['server_id']); /** get the "active" Services of the server from the DB */ - $services = $app->db->queryOneRecord('SELECT * FROM server WHERE server_id = ' . $server_id); + $services = $app->db->queryOneRecord('SELECT * FROM server WHERE server_id = ?', $server_id); /* * If the DB is down, we have to set the db to "yes". * If we don't do this, then the monitor will NOT monitor, that the db is down and so the @@ -636,7 +669,7 @@ // $now = time(); // $old = $now - (4 * 60); // 4 minutes - $old = 'UNIX_TIMESTAMP() - 240'; + $old = 240; //seconds /* * ATTENTION if i do NOT pay attention of the server id, i delete all data (of the type) @@ -646,16 +679,66 @@ * even though it is the NEWEST data of this server. To avoid this i HAVE to include * the server-id! */ - $sql = 'DELETE FROM monitor_data ' . - 'WHERE ' . - ' type =' . "'" . $app->dbmaster->quote($type) . "' " . - 'AND ' . - ' created < ' . $old . ' ' . - 'AND ' . - ' server_id = ' . $serverId; - $app->dbmaster->query($sql); + $sql = 'DELETE FROM `monitor_data` WHERE `type` = ? AND `created` < UNIX_TIMESTAMP() - ? AND `server_id` = ?'; + $app->dbmaster->query($sql, $type, $old, $serverId); } + public function send_notification_email($template, $placeholders, $recipients) { + global $conf; + + if(!is_array($recipients) || count($recipients) < 1) return false; + if(!is_array($placeholders)) $placeholders = array(); + + if(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_'.$conf['language'].'.txt'); + } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/' . $template . '_en.txt'); + } elseif(file_exists($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt')) { + $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_'.$conf['language'].'.txt'); + } else { + $lines = file($conf['rootpath'].'/conf/mail/' . $template . '_en.txt'); + } + + //* get mail headers, subject and body + $mailHeaders = ''; + $mailBody = ''; + $mailSubject = ''; + $inHeader = true; + for($l = 0; $l < count($lines); $l++) { + if(trim($lines[$l]) == '') { + $inHeader = false; + continue; + } + if($inHeader == true) { + $parts = explode(':', $lines[$l], 2); + if(strtolower($parts[0]) == 'subject') { + $mailSubject = trim($parts[1]); + continue; + } + unset($parts); + $mailHeaders .= trim($lines[$l]) . "\n"; + } else { + $mailBody .= trim($lines[$l]) . "\n"; + } + } + $mailBody = trim($mailBody); + + //* Replace placeholders + $mailHeaders = strtr($mailHeaders, $placeholders); + $mailSubject = strtr($mailSubject, $placeholders); + $mailBody = strtr($mailBody, $placeholders); + + for($r = 0; $r < count($recipients); $r++) { + mail($recipients[$r], $mailSubject, $mailBody, $mailHeaders); + } + + unset($mailSubject); + unset($mailHeaders); + unset($mailBody); + unset($lines); + + return true; + } } -- Gitblit v1.9.1