ASNMTAP
view release on metacpan or search on metacpan
applications/htmlroot/snmptraps/include/classes/class.frontend.php view on Meta::CPAN
<?
#########################################################
# SNMPTraps-Frontend for Nagios & ASNMTAP #
# #
# by Michael Lübben #
# --- Lizenz GPL --- #
#########################################################
/**
* This Class creates the Web-Frontend for the SNMP-Trap Frontend
*/
class frontend {
var $site;
/**
* Constructor
*
* @param config $configINI
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function frontend(&$configINI) {
$this->configINI = &$configINI;
}
// ==================================== Functions to create the page ====================================
/**
* Open a Web-Site in a Array site[].
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function openSite() {
$this->site[] = '<HTML>';
$this->site[] = '<HEAD>';
$this->site[] = '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"/>';
$this->site[] = '<TITLE>'.$this->configINI['internal']['title'].' '.$this->configINI['internal']['version'].'</TITLE>';
$this->site[] = '<SCRIPT TYPE="text/javascript" SRC="./include/js/nagtrap.js"></SCRIPT>';
$this->site[] = '<SCRIPT TYPE="text/javascript" SRC="./include/js/overlib.js"></SCRIPT>';
$this->site[] = '<LINK HREF="'.$this->configINI['nagios']['prefix'].'/include/css/nagtrap.css" REL="stylesheet" TYPE="text/css">';
$this->site[] = '<LINK HREF="'.$this->configINI['nagios']['prefix'].'/include/css/status.css" REL="stylesheet" TYPE="text/css">';
$this->site[] = '<LINK HREF="'.$this->configINI['nagios']['prefix'].'/include/css/showlog.css" REL="stylesheet" TYPE="text/css">';
$this->site[] = '<LINK HREF="'.$this->configINI['nagios']['prefix'].'/include/css/common.css" REL="stylesheet" TYPE="text/css">';
$this->site[] = '</HEAD>';
$this->site[] = '<BODY CLASS="status">';
}
/**
* Closed a Web-Site in the Array site[]
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function closeSite() {
$this->site[] = '</BODY>';
$this->site[] = '</HTML>';
}
/**
* Create a Web-Side from the Array site[].
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function printSite() {
foreach ($this->site as $row) {
echo $row."\n";
}
}
// ======================= Contructor and functions for the header of the frontend ======================
/**
* Constructor for the header
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function constructorHeader() {
global $table;
$this->site[] = '<TABLE BORDER="0" WIDTH="100%" CELLPADDING="0" CELLSPACING="0">';
$this->site[] = ' <TR>';
$this->site[] = ' <TD ALIGN="left" VALIGN="top" WIDTH="33%">';
$this->createInfoBox();
$this->site[] = ' <BR>';
$this->createFilter();
$this->site[] = ' </TD>';
$this->site[] = ' <TD ALIGN="center" VALIGN="top" WIDTH="33%">';
$this->createNavBox();
$this->site[] = ' <BR>';
$this->createDBInfo($table);
$this->site[] = ' </TD>';
$this->site[] = ' <TD ALIGN="right" VALIGN="top" WIDTH="33%">';
$this->createOptBox();
$this->site[] = ' </TD>';
$this->site[] = ' </TR>';
$this->site[] = '</TABLE>';
$this->site[] = '<BR><BR>';
}
/**
* Create a Info-Box
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function createInfoBox() {
applications/htmlroot/snmptraps/include/classes/class.frontend.php view on Meta::CPAN
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function printError($error,$systemError) {
global $errorXML;
$this->site[] = '<HR>';
$this->site[] = ' <DIV CLASS="errorMessage">'.$errorXML['ERROR'][$error]['MESSAGE'].'</DIV>';
common::printErrorLines($errorXML['ERROR'][$error]['DESCRIPTION'],$systemError);
$this->site[] = '</HR>';
}
// ======================== Contructor and functions for the main of the frontend =======================
/**
* Constructor for the main
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function constructorMain() {
global $languageXML, $traps, $MAIN;
// Check database connacetion and read traps from database
$traps = common::readTraps();
$this->site[] = '<FORM NAME="form1" ACTION="./index.php" METHOD="POST">';
$this->site[] = '<TABLE WIDTH="100%" BORDER="0">';
$this->site[] = ' <TR>';
/**
* @author Alex Peeters [alex.peeters@citap.be]
*/
if ($MAIN->checkAction() == "1") {
$this->site[] = ' <TH CLASS="status" WIDTH="30">'.$languageXML['LANG']['MAIN']['TRAPTABLEHEADER']['OPTION'].'</TH>';
}
$this->site[] = ' <TH CLASS="status">'.$languageXML['LANG']['MAIN']['TRAPTABLEHEADER']['HOST'].'</TH>';
$this->site[] = ' <TH CLASS="status" WIDTH="30">'.$languageXML['LANG']['MAIN']['TRAPTABLEHEADER']['TRAPOID'].'</TH>';
$this->site[] = ' <TH CLASS="status">'.$languageXML['LANG']['MAIN']['TRAPTABLEHEADER']['TRAPTIME'].'</TH>';
common::showTrapFields("field",NULL,NULL,NULL);
$this->site[] = ' <TH CLASS="status">'.$languageXML['LANG']['MAIN']['TRAPTABLEHEADER']['MESSAGE'].'</TH>';
$this->site[] = ' </TR>';
common::createTrapPage($traps);
$this->site[] = '</TABLE>';
}
/**
* Create a Java Infobox
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function javaInfoBox($formatline) {
$infoBox = 'onmouseover="return overlib(\'';
$infoBox .= $formatline;
$infoBox .= '\', CAPTION, \'Trap-Message\', VAUTO);" onmouseout="return nd();" ';
return($infoBox);
}
/**
* Show traps
*
* @author Michael Luebben <michael_luebben@web.de>
*/
function showTrap($trap,$rowColor,$styleLine) {
global $configINI, $languageXML, $MAIN;
$this->site[] = ' <TR>';
/**
* @author Alex Peeters [alex.peeters@citap.be]
*/
if ($MAIN->checkAction() == "1") {
// Checkbox
$this->site[] = ' <TD CLASS="'.$rowColor.'"><INPUT TYPE="checkbox" NAME="trapIDs[]" VALUE="'.$trap['id'].'" '.$_GET['sel'].'>';
// Mark a trap
$this->site[] = ' <A HREF="./index.php?action=mark&trapID='.$trap['id'].'&severity='.$_REQUEST['severity'].'&category='.rawurlencode($_REQUEST['category']).'&hostname='.$_REQUEST['hostname'].'&trapOID='.$_REQUEST['t...
// Delete a trap
$this->site[] = ' <A HREF="./index.php?action=delete&trapID='.$trap['id'].'&severity='.$_REQUEST['severity'].'&category='.rawurlencode($_REQUEST['category']).'&hostname='.$_REQUEST['hostname'].'&trapOID='.$_REQUEST[...
$this->site[] = ' </TD>';
}
// Select host
$this->site[] = ' <TD CLASS="'.$rowColor.'"><P '.$styleLine.'><A HREF="./index.php?severity='.$_REQUEST['severity'].'&category='.rawurlencode($_REQUEST['category']).'&hostname='.$trap['hostname'].'&FQDN=T">'.$trap['hostname'].'</...
// Select trapOID
$this->site[] = ' <TD CLASS="'.$rowColor.'"><P '.$styleLine.'><A HREF="./index.php?severity='.$_REQUEST['severity'].'&category='.rawurlencode($_REQUEST['category']).'&hostname='.$trap['hostname'].'&trapOID='.$trap['trapoid'].'&am...
$this->site[] = ' <TD CLASS="'.$rowColor.'"><P '.$styleLine.'>'.$trap['traptime'].'</P></TD>';
common::showTrapFields("entry",$trap,$rowColor,$styleLine);
$this->site[] = ' <TD CLASS="'.$rowColor.'"><P '.$styleLine.' '.$this->javaInfoBox($trap['orgFormatline']).'CLASS="formatline">'.htmlentities($trap['formatline']).'</P></TD>';
$this->site[] = ' </TR>';
}
// ======================= Contructor and functions for the footer of the frontend ======================
/**
* Constructor for the main
*
* @author Michael Luebben <michael_luebben@web.de>
*/
//FIXME !!!
function constructorFooter() {
global $configINI, $languageXML, $MAIN;
$this->site[] = '<TABLE WIDTH="100%" BORDER="0">';
$this->site[] = ' <TR>';
$this->site[] = ' <TD CLASS="linkBox">';
/**
* @author Alex Peeters [alex.peeters@citap.be]
*/
if ($MAIN->checkAction() == "1") {
$this->site[] = ' <IMG SRC="'.$configINI['global']['images'].$configINI['global']['iconStyle'].'/arrow.png" ALT="" BORDER="0">';
$this->site[] = ' <INPUT TYPE="checkbox" NAME="checkbox" VALUE="checkbox" onClick="checkAll(\'yes\'); return true;">(Mark all)';
$this->site[] = ' <INPUT TYPE="image" SRC="'.$configINI['global']['images'].$configINI['global']['iconStyle'].'/mark.png" NAME="markTraps[0]" TITLE="'.$languageXML['LANG']['MAIN']['TRAPTABLEENTRY']['OPTIONREAD'].'">';
$this->site[] = ' <INPUT TYPE="image" SRC="'.$configINI['global']['images'].$configINI['global']['iconStyle'].'/delete.png" NAME="deleteTraps[0]" TITLE="'.$languageXML['LANG']['MAIN']['TRAPTABLEENTRY']['OPTIONDELETE'].'">';
}
$this->site[] = ' <INPUT TYPE="hidden" NAME="oldestfirst" VALUE="'.$_REQUEST['oldestfirst'].'">';
$this->site[] = ' <INPUT TYPE="hidden" NAME="severity" VALUE="'.$_REQUEST['severity'].'">';
$this->site[] = ' <INPUT TYPE="hidden" NAME="category" VALUE="'.$_REQUEST['category'].'">';
$this->site[] = ' <INPUT TYPE="hidden" NAME="hostname" VALUE="'.$_REQUEST['hostname'].'">';
$this->site[] = ' <INPUT TYPE="hidden" NAME="trapOID" VALUE="'.$_REQUEST['trapOID'].'">';
$this->site[] = ' <INPUT TYPE="hidden" NAME="FQDN" VALUE="'.$_REQUEST['FQDN'].'">';
$this->site[] = ' </TD>';
$this->site[] = ' </TR>';
$this->site[] = '</TABLE>';
$this->site[] = '</FORM>';
}
}
?>
( run in 1.399 second using v1.01-cache-2.11-cpan-d8267643d1d )