Skip to content

Instantly share code, notes, and snippets.

@manoot
Created January 18, 2012 18:18
Show Gist options
  • Select an option

  • Save manoot/1634629 to your computer and use it in GitHub Desktop.

Select an option

Save manoot/1634629 to your computer and use it in GitHub Desktop.
<?php
///////////
//
// PHP DYNAMIC DROP-DOWN BOX FOR ZABBIX PDF GENERATION
// THE IDEA BEHIND THIS IS TO CREATE A VERSION INDEPENDENT
// ADDON THAT CAN BE ADDED THROUGH SCREENS TO PREVENT BREAKAGE
// v0.1 - 1/14/12 - (c) Travis Mathis - travisdmathis@gmail.com
// Change Log: Added Dropdown Box
//
//
//
// ERROR REPORTING
error_reporting(E_ALL);
set_time_limit(1800);
// CONFIGURATION
$dbserver="127.0.0.1";
$user="";
$pass="";
$blacklist = array("APC_NetBotz","Avaya_S8300D_G450","NTMS Monitoring Server","Discovered hosts","NTMS Servers","Templates");
// MySQL Connection
$con = mysql_connect($dbserver,$user,$pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("zabbix", $con);
// FORM DROPDOWN BOX W/ MYSQL QUERY DATA
echo "<center>";
echo "<b>SELECT SITE:</b> ";
echo "<select name=\"siteList\">\n";
echo "<option value=\"all\">All</option>\n";
$queryhost = "select host FROM hosts ORDER BY 'asc'";
$resulthost = mysql_query($queryhost);
$queryhostgroups = "select name FROM groups ORDER BY 'asc'";
$resulthostgroups = mysql_query($queryhostgroups);
while($array = mysql_fetch_assoc($resulthostgroups)) {
$hostgroups = $array["name"];
if(in_array($hostgroups, $blacklist, true)) {
// do nothing
} else {
echo "<option value=\"$hostgroups\">$hostgroups</option>\n";
}
}
while($array = mysql_fetch_assoc($resulthost)) {
$host = $array["host"];
if(in_array($host, $blacklist, true)) {
// do nothing
} else {
echo "<option value=\"$host\">$host</option>\n";
}
}
echo "</select>\n";
echo "</center>\n";
// SUBMIT SELECTION
echo "</br>";
echo "<form action='pdf.php' method='POST'>";
// dump data to data file
echo "<center><input type='submit' value='Generate'></center>";
echo "</form>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment