pandorafms/pandora_console/include/functions_snmp.php
alexhigh baf5cedde8 2014-05-28 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_snmp.php: Improved the security
	on the function "snmp_generate_trap" by escaping the
	command arguments.
	
	* include/functions_snmp_browser.php: Improved the
	Windows compatibility of some commands.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10030 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2014-05-28 15:53:03 +00:00

43 lines
1.4 KiB
PHP

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program 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.
/**
* Generates a trap
*
* @param string Destiny host address.
* @param string Snmp community.
* @param string Snmp OID.
* @param string Snmp agent.
* @param string Data of the trap.
* @param string Snmp especific OID.
*/
function snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_data, $snmp_type) {
$command = "snmptrap -v 1 -c " . escapeshellarg($snmp_community) . " " . escapeshellarg($snmp_host_address) . " " . escapeshellarg($snmp_oid) . " "
. escapeshellarg($snmp_agent) . " " . escapeshellarg($snmp_type) . " " . escapeshellarg($snmp_data) . " 0 2>&1";
$output = null;
exec($command, $output, $return);
if ($return == 0) {
return true;
}
else {
return implode(' ', $output);
}
}
?>