-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature where you can download list of servers in each section …
…as a CSV
- Loading branch information
Peter Malaty
committed
Feb 22, 2017
1 parent
f1234c9
commit 08717c4
Showing
15 changed files
with
864 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^(.*)$ ./index.php? [QSA,L,E=PATH_INFO:/$1] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
require_once './inc/db.php'; | ||
// header("Content-type: image/png"); | ||
//$output_file='/tmp/myimage.png'; | ||
$dblink = db_connect(); | ||
|
||
// Packages with updates | ||
// $dbquery2 = "select packagename,count(*) as cunt from packages WHERE packtype='bug' group by packagename order by cunt DESC, packagename ASC;"; | ||
$dbquery2 = "select hostname, sum(if (packtype='bug',1,0)) as bug, sum(if (packtype='sec',1,0)) as sec from packages group by hostname;"; | ||
$dbresult2 = mysqli_query($dblink, $dbquery2); | ||
// echo "<table>\n"; | ||
// echo "<tr><td>Package</td><td>Short Desc</td><td>Num of Affected servers</td></tr><br/>\n"; | ||
$data=array(); | ||
if ($dbresult2 && mysqli_num_rows($dbresult2)) { | ||
while ($row2 = mysqli_fetch_object($dbresult2)) { | ||
$arr_t=array(); | ||
|
||
$host_t=$row2->hostname; | ||
$bug_t=$row2->bug; | ||
$sec_t=$row2->sec; | ||
$url_t="https://man.pmalaty.com/view_page.php?action=viewallpkgs&servername=$host_t"; | ||
$arr_t['hostname']=$host_t; | ||
$arr_t['bug']=$bug_t; | ||
$arr_t['sec']=$sec_t; | ||
$arr_t['url']=$url_t; | ||
|
||
//print_r($row2); | ||
$data[] = $arr_t; | ||
} | ||
} | ||
|
||
|
||
//print_r($data); | ||
$json_dataset = json_encode($data); | ||
|
||
echo $json_dataset; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,3 @@ function db_connect() { | |
return $dblink; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fhsdjvhjksdfhjks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
|
||
ignore_user_abort(true); | ||
set_time_limit(0); // disable the time limit for this script | ||
|
||
$_GET['download_file']='test.txt'; | ||
$File='test.txt'; | ||
|
||
$path = $_SERVER["DOCUMENT_ROOT"] . "/inc/pages/Downloads/"; // change the path to fit your websites document structure | ||
|
||
$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})", '', $File); // simple file name validation | ||
$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters | ||
$fullPath = $path.$dl_file; | ||
|
||
if ($fd = fopen ($fullPath, "r")) { | ||
$fsize = filesize($fullPath); | ||
$path_parts = pathinfo($fullPath); | ||
$ext = strtolower($path_parts["extension"]); | ||
switch ($ext) { | ||
case "txt": | ||
header("Content-type: application/txt"); | ||
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a file download | ||
break; | ||
// add more headers for other content types here | ||
default: | ||
header("Content-type: application/octet-stream"); | ||
header("Content-Disposition: filename=\"".$path_parts["basename"]."\""); | ||
break; | ||
} | ||
header("Content-length: $fsize"); | ||
header("Cache-control: private"); //use this to open files directly | ||
while(!feof($fd)) { | ||
$buffer = fread($fd, 2048); | ||
echo $buffer; | ||
} | ||
} | ||
fclose ($fd); | ||
exit; | ||
|
||
|
||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
// Project SyPUM - Systems Package Update Management | ||
// | ||
// | ||
// Author: Peter Malaty - 12/20/2016 All Rights Reserved | ||
// | ||
// Copyright 2016 Peter G.F Malaty - [email protected] | ||
// This file is part of MAN Spider is distributed under the terms of the GNU General Public License | ||
/* | ||
SyPUM - Systems Package Update Management is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
SyPUM - Systems Package Update Management is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Foobar. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
|
||
|
||
require_once 'inc/stdhead.php'; | ||
|
||
|
||
require_once('inc/db.php'); | ||
|
||
$dblink=db_connect(); | ||
|
||
$servername=mysqli_real_escape_string($dblink,$_GET['servername']); | ||
$Action=mysqli_real_escape_string($dblink,$_GET['action']); | ||
$Ubureleasever=mysqli_real_escape_string($dblink,$_GET['ubureleasever']); | ||
|
||
|
||
switch ($page) { | ||
case 'bugspacks': | ||
$title = "List of Bug fix Packs on All Servers"; | ||
$serversqlcond = "WHERE packtype='bug'"; | ||
break; | ||
|
||
|
||
case 'secupdates': | ||
$title = "List of Security Packages on All Servers"; | ||
$serversqlcond = "WHERE packtype='sec'"; | ||
break; | ||
|
||
// default: | ||
// $title = "Nothing's here"; | ||
// $serversqlcond = ""; | ||
// break; | ||
} | ||
|
||
//echo "<h1>Host $servername</h1>"; | ||
echo "<div class='contentbox'>\n"; | ||
echo "<h2>$title</h2>"; | ||
echo "<div class='content'>\n"; | ||
// $dbquery = "SELECT distinct packagename,shortdesc FROM packages $serversqlcond;"; | ||
// $dbresult = mysqli_query($dblink, $dbquery); | ||
$dbquery2 = "select packagename,shortdesc,count(*) as cunt from packages $serversqlcond group by packagename order by cunt DESC, packagename ASC;"; | ||
$dbresult2 = mysqli_query($dblink, $dbquery2); | ||
if($serversqlcond == "WHERE packtype='bug'") $pkgtype='bug'; elseif ($serversqlcond == "WHERE packtype='sec'") $pkgtype='sec'; | ||
echo "<table>\n"; | ||
echo "<tr><td>Package</td><td>Short Desc</td><td>Num of Affected servers</td></tr><br/>\n"; | ||
if ($dbresult2 && mysqli_num_rows($dbresult2)) { | ||
while ($row2 = mysqli_fetch_object($dbresult2)) { | ||
$Packname=$row2->packagename; | ||
$Shortdesc=$row2->shortdesc; | ||
$count=$row2->cunt; | ||
echo "<tr><td>$Packname</td><td>$Shortdesc</td><td><a href='/view_page.php?action=viewsrvspkg&packagename=$Packname&pktype=$pkgtype'>$count</td></tr>\n"; | ||
|
||
} | ||
} | ||
else { | ||
echo "No Packages here to display\n"; | ||
} | ||
|
||
echo"</table>"; | ||
echo "</div>\n"; | ||
echo "</div>\n"; | ||
|
||
|
||
require_once 'inc/stdfoot.php'; | ||
|
||
?> |
Oops, something went wrong.