2009-10-26 17:35:34 +01:00
|
|
|
<?php
|
|
|
|
//Pandora FMS- http://pandorafms.com
|
|
|
|
// ==================================================
|
2011-03-02 22:56:48 +01:00
|
|
|
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
2009-10-26 17:35:34 +01:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
require_once ("config.php");
|
|
|
|
require_once("functions_api.php");
|
2009-12-21 18:11:31 +01:00
|
|
|
enterprise_include_once ('include/functions_enterprise_api.php');
|
2009-10-26 17:35:34 +01:00
|
|
|
|
|
|
|
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
2010-05-27 17:23:46 +02:00
|
|
|
|
|
|
|
//Get the parameters and parse if necesary.
|
2009-10-26 17:35:34 +01:00
|
|
|
$op = get_parameter('op');
|
|
|
|
$op2 = get_parameter('op2');
|
|
|
|
$id = get_parameter('id');
|
|
|
|
$id2 = get_parameter('id2');
|
2010-05-27 17:23:46 +02:00
|
|
|
$otherSerialize = get_parameter('other');
|
|
|
|
$otherMode = get_parameter('other_mode', 'url_encode');
|
2009-10-26 17:35:34 +01:00
|
|
|
$returnType = get_parameter('return_type', 'string');
|
2011-02-14 17:56:17 +01:00
|
|
|
$password = get_parameter('pass', '');
|
2009-10-26 17:35:34 +01:00
|
|
|
|
2010-05-27 17:23:46 +02:00
|
|
|
$other = parseOtherParameter($otherSerialize, $otherMode);
|
|
|
|
|
2011-02-14 17:56:17 +01:00
|
|
|
$apiPassword = get_db_value_filter('value', 'tconfig', array('token' => 'api_password'));
|
|
|
|
|
|
|
|
$correctLogin = false;
|
|
|
|
if (!empty($apiPassword)) {
|
|
|
|
if ($password === $apiPassword) {
|
|
|
|
$correctLogin = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (isInACL($ipOrigin)) {
|
|
|
|
$correctLogin = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($correctLogin) {
|
2009-10-26 17:35:34 +01:00
|
|
|
if (($op !== 'get') && ($op !== 'set') && ($op !== 'help'))
|
|
|
|
returnError('no_set_no_get_no_help', $returnType);
|
|
|
|
else {
|
|
|
|
if (!function_exists($op.'_'.$op2))
|
|
|
|
returnError('no_exist_operation', $returnType);
|
|
|
|
else {
|
|
|
|
call_user_func($op.'_'.$op2, $id, $id2, $other, $returnType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo 'ERROR: Your IP (' . $ipOrigin . ') is not in ACL IP list.';
|
|
|
|
}
|
2009-11-02 17:07:05 +01:00
|
|
|
?>
|