//用于身份验证,但可以利用 X-Forwarded-For 伪造IP,以绕过此验证 if (!remote_client_authorized()) { print'FATAL: You are not authorized to use this service'; exit; } set_default_action();
//action 源于request传参,用户可控,可直接导向到 pool_for_data 代码执行函数 switch (get_request_var('action')) { case'polldata': // Only let realtime polling run for a short time ini_set('max_execution_time', read_config_option('script_timeout'));
debug('Start: Poling Data for Realtime'); poll_for_data(); debug('End: Poling Data for Realtime');
if (cacti_sizeof($local_data_ids)) { foreach($local_data_idsas$local_data_id) { //检查 data_id 是否为数字,表明local_data_id参数需上传为数组 input_validate_input_number($local_data_id); // select * from poller_item where host_id = 1 and local_data_id = 6; $items = db_fetch_assoc_prepared('SELECT * FROM poller_item WHERE host_id = ? AND local_data_id = ?', array($host_id, $local_data_id)); 。。。。。。
if (cacti_sizeof($items)) { // 循环 item 取出 mysql 查询到的 action foreach($itemsas$item) { switch ($item['action']) { 。。。。。。 case POLLER_ACTION_SCRIPT_PHP: /* script (php script server) */ $cactides = array( 0 => array('pipe', 'r'), // stdin is a pipe that the child will read from 1 => array('pipe', 'w'), // stdout is a pipe that the child will write to 2 => array('pipe', 'w') // stderr is a pipe to write to );