From 1d7ed9a5a7e51d77bed2ebb3a8f27ad31860c444 Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 10 Jul 2017 15:09:41 +0200 Subject: [PATCH 01/15] v2.0 --- config.php | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/config.php b/config.php index a32c8ed..22f1998 100644 --- a/config.php +++ b/config.php @@ -1,26 +1,29 @@ of your page and also the h1 header at the top of the page. -$hostname = "localhost"; //Change this to IP or hostname of your database server. Probably localhost. -$username = "root"; //This is a MySQL user that has access to the Syslog database. -$password = "password"; //Password for above user. -$database_name = "Syslog"; //The name of the database for the Syslog events. -$search_limit = 300; - -# COLORS -$background_color = "rgb(17,17,17)"; -$header_color = "rgb(17,17,17)"; -$date_color = "#009E52"; -$host_color = "#FFFA9E"; -$tag_color = "#0081C2"; - -# DO NOT EDIT BELOW THIS LINE - -$con = mysql_connect($hostname,$username,$password); -if (!$con) - { - die('Could not connect: ' . mysql_error()); - } - -mysql_select_db($database_name, $con); + $title = "Syslog WebViewer"; //This appears as the of your page and also the h1 header at the top of the page. + $hostname = "localhost"; //Change this to IP or hostname of your database server. Probably localhost. + $username = "user"; //This is a MySQL user that has access to the Syslog database. + $password = "pass"; //Password for above user. + $database_name = "syslog"; //The name of the database for the Syslog events. + $search_limit = 200; + + # COLORS + $background_color = "#111111"; + $header_color = "#111111"; + $date_color = "#009E52"; + $host_color = "#FFFA9E"; + $tag_color = "#0081C2"; + $msg_color = "#ffffff"; + $warning_color = "#AA0000"; + + + + # ---DO NOT EDIT BELOW THIS LINE--- + + $con = mysql_connect($hostname,$username,$password); + if (!$con) { + die('Could not connect: ' . mysql_error()); + } + + set_time_limit(300); + mysql_select_db($database_name, $con); ?> From bdae9b4be5af16553aa11118d2f7ef1ae9ed282e Mon Sep 17 00:00:00 2001 From: Ken <ken.joss1@gmail.com> Date: Mon, 10 Jul 2017 15:10:07 +0200 Subject: [PATCH 02/15] v2.0 --- distinct.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/distinct.php b/distinct.php index b05154f..a7e523a 100644 --- a/distinct.php +++ b/distinct.php @@ -1,14 +1,15 @@ <?php -require_once("config.php"); -$sql="SELECT DISTINCT FromHost FROM SystemEvents ORDER BY FromHost DESC"; -$result = mysql_query($sql); -$arr = array(); -while($row = mysql_fetch_array($result)) -{ - //if (strpos($row['FromHost'],$_GET['term']) !== false) { - $arr[] = $row['FromHost']; - //} -} -echo json_encode($arr); -mysql_close($con); + require_once("config.php"); + $sql="SELECT DISTINCT host FROM syslog.syslog ORDER BY host DESC"; + $result = mysql_query($sql); + $arr = array(); + + while($row = mysql_fetch_array($result)) { + //if (strpos($row['FromHost'],$_GET['term']) !== false) { + $arr[] = $row['host']; + //} + } + + echo json_encode($arr); + mysql_close($con); ?> From 8afe27e86caf5e2e0f7446838721e531cc4da4dd Mon Sep 17 00:00:00 2001 From: Ken <ken.joss1@gmail.com> Date: Mon, 10 Jul 2017 15:10:49 +0200 Subject: [PATCH 03/15] v2.0 --- function.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 function.php diff --git a/function.php b/function.php new file mode 100644 index 0000000..622a1ae --- /dev/null +++ b/function.php @@ -0,0 +1,32 @@ +<?php + //Include + require_once("config.php"); + + //Function for no results found + function noResFound() { + echo "<span class=\"warning\">No results found! ¯\_(ツ)_/¯</span><br>"; + } + + //Function for SELECT in search.php, 4 Days Archive + function selectFromArchive4DaysDBM($db, $date, $query, $limit) { + $sql="SELECT * FROM ( + SELECT * FROM ".$db." WHERE timestamp LIKE '".$date."%' AND (timestamp LIKE '%".$query."%' OR host LIKE '%".$query."%' OR msg LIKE '%".$query."%') + ORDER BY id DESC + ) + sub + ORDER BY timestamp DESC LIMIT 500"; + $result = mysql_query($sql); + + return $result; + } + + //Function for SELECT in search.php + function selectFromArchiveDBM($db, $date, $query, $limit) { + $sql="SELECT id,timestamp,host,facility,level,tag,msg FROM ".$db." WHERE timestamp LIKE '".$date."%' AND (timestamp LIKE '%".$query."%' OR host LIKE '%".$query."%' + OR msg LIKE '%".$query."%') + ORDER BY timestamp DESC LIMIT 500"; + $result = mysql_query($sql); + + return $result; + } +?> From 15be8993a0431a97a24218dad70f95b6653fc142 Mon Sep 17 00:00:00 2001 From: Ken <ken.joss1@gmail.com> Date: Mon, 10 Jul 2017 15:11:27 +0200 Subject: [PATCH 04/15] v2.0 --- get_mysql_query.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 get_mysql_query.php diff --git a/get_mysql_query.php b/get_mysql_query.php new file mode 100644 index 0000000..ca4b53e --- /dev/null +++ b/get_mysql_query.php @@ -0,0 +1,20 @@ +<?php + require_once("config.php"); + + //Get Proc list + $sql="SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER LIKE 'web' AND COMMAND LIKE 'Query' AND TIME > 600"; + $result = mysql_query($sql); + + while($row = mysql_fetch_array($result)) { + $id = $row['ID']; + $rtime = $row['TIME']; + + echo $id ." ". $rtime ."<br>"; + + //Kill + $kill_proc = "KILL $id"; + mysql_query($kill_proc); + } + + mysql_close($con); +?> From 0260364988a5a796e8a18a89bf73a2812c7c9af3 Mon Sep 17 00:00:00 2001 From: Ken <ken.joss1@gmail.com> Date: Mon, 10 Jul 2017 15:11:53 +0200 Subject: [PATCH 05/15] v2.0 --- index.php | 760 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 469 insertions(+), 291 deletions(-) diff --git a/index.php b/index.php index fbf2f80..b81da06 100644 --- a/index.php +++ b/index.php @@ -1,300 +1,478 @@ -<?php require_once("config.php"); ?> +<?php + require_once("config.php"); + + //Get Var + $searchtext = $_GET['search']; + $date = $_GET['date']; +?> + <html> <head> -<title><?=$title; ?> - - - - - + <?=$title; ?> + + + + + + + + -