diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-01-16 14:28:28 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-01-16 14:28:28 +0000 |
| commit | 819114c84816786fa5bd16c933e0ea8d6d09f9d9 (patch) | |
| tree | 6f5188b3404ffafd72c5aaee61386c285f692771 /frontends/php/include | |
| parent | 32e5c61ed67fadf2cf7670a1f5bfa55bf4831c9c (diff) | |
| download | zabbix-819114c84816786fa5bd16c933e0ea8d6d09f9d9.tar.gz zabbix-819114c84816786fa5bd16c933e0ea8d6d09f9d9.tar.xz zabbix-819114c84816786fa5bd16c933e0ea8d6d09f9d9.zip | |
- [ZBX-253] fixes problem in frontend with long int values (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5259 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/actions.inc.php | 16 | ||||
| -rw-r--r-- | frontends/php/include/classes/ccombobox.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 29 | ||||
| -rw-r--r-- | frontends/php/include/copt.lib.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 36 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/hosts.inc.php | 22 | ||||
| -rw-r--r-- | frontends/php/include/import.inc.php | 8 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/maps.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/perm.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/scripts.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/validate.inc.php | 5 |
16 files changed, 87 insertions, 69 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 70d3b5d4..4875ba9a 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -44,13 +44,13 @@ include_once 'include/discovery.inc.php'; switch($ac_data['conditiontype']) { case CONDITION_TYPE_HOST_GROUP: - if(in_array($ac_data['value'],explode(',',$denyed_groups))) + if(uint_in_array($ac_data['value'],explode(',',$denyed_groups))) { $result = false; } break; case CONDITION_TYPE_HOST: - if(in_array($ac_data['value'],explode(',',$denyed_hosts))) + if(uint_in_array($ac_data['value'],explode(',',$denyed_hosts))) { $result = false; } @@ -86,14 +86,14 @@ include_once 'include/discovery.inc.php'; switch($ac_data['type']) { case CONDITION_TYPE_HOST_GROUP: - if(in_array($ac_data['value'],explode(',',$denyed_groups))) + if(uint_in_array($ac_data['value'],explode(',',$denyed_groups))) { error(S_INCORRECT_GROUP); $result = false; } break; case CONDITION_TYPE_HOST: - if(in_array($ac_data['value'],explode(',',$denyed_hosts))) + if(uint_in_array($ac_data['value'],explode(',',$denyed_hosts))) { error(S_INCORRECT_HOST); $result = false; @@ -612,7 +612,7 @@ include_once 'include/discovery.inc.php'; switch($conditiontype) { case CONDITION_TYPE_HOST_GROUP: - if(!in_array($value, + if(!uint_in_array($value, get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null, PERM_RES_IDS_ARRAY))) { @@ -629,7 +629,7 @@ include_once 'include/discovery.inc.php'; } break; case CONDITION_TYPE_HOST: - if(!in_array($value, + if(!uint_in_array($value, get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null, PERM_RES_IDS_ARRAY))) { @@ -721,7 +721,7 @@ include_once 'include/discovery.inc.php'; break; case OPERATION_TYPE_GROUP_ADD: case OPERATION_TYPE_GROUP_REMOVE: - if(!in_array($operation['objectid'], + if(!uint_in_array($operation['objectid'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null, PERM_RES_IDS_ARRAY))) { @@ -731,7 +731,7 @@ include_once 'include/discovery.inc.php'; break; case OPERATION_TYPE_TEMPLATE_ADD: case OPERATION_TYPE_TEMPLATE_REMOVE: - if(!in_array($operation['objectid'], + if(!uint_in_array($operation['objectid'], get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null, PERM_RES_IDS_ARRAY))) { diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php index 08f426a3..e0a7775c 100644 --- a/frontends/php/include/classes/ccombobox.inc.php +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -87,7 +87,7 @@ // if($enabled=='no') return; /* disable item method 1 */ if(is_null($selected)){ $selected = 'no'; - if((strcmp($value,$this->value) == 0) || (is_array($this->value) && in_array($value, $this->value))) + if((strcmp($value,$this->value) == 0) || (is_array($this->value) && str_in_array($value, $this->value))) $selected = 'yes'; } @@ -183,7 +183,7 @@ { if(is_null($selected)) { - if((strcmp($value,$this->value) == 0) || (is_array($this->value) && in_array($value, $this->value))) + if((strcmp($value,$this->value) == 0) || (is_array($this->value) && str_in_array($value, $this->value))) $this->value_exist = 1; } diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 3071b048..fdf6e4ac 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -296,6 +296,27 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! include_once "include/page_footer.php"; } + function uint_in_array($needle,$haystack){ + foreach($haystack as $id => $value) + if(bccomp($needle,$value) == 0) return true; + return false; + } + + function str_in_array($needle,$haystack,$strict=false){ + if(is_array($needle)){ + return in_array($needle,$haystack,$strict); + } + else if($strict){ + foreach($haystack as $id => $value) + if($needle === $value) return true; + } + else{ + foreach($haystack as $id => $value) + if(strcmp($needle,$value) == 0) return true; + } + return false; + } + function zbx_stripslashes($value){ if(is_array($value)){ foreach($value as $id => $data) @@ -346,7 +367,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! $key = htmlspecialchars($key); uasort($array, create_function('$a,$b', 'return $a[\''.$key.'\'] - $b[\''.$key.'\'];')); - return $array; + return $array; } function fatal_error($msg){ @@ -1006,7 +1027,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! } } else if(is_object($obj)){ - if(in_array(strtolower(get_class($obj)),array('cform','ccheckbox','cselect','cbutton','cbuttonqmessage','cbuttondelete','cbuttoncancel'))){ + if(str_in_array(strtolower(get_class($obj)),array('cform','ccheckbox','cselect','cbutton','cbuttonqmessage','cbuttondelete','cbuttoncancel'))){ $obj=SPACE; } if(isset($obj->items) && !empty($obj->items)){ @@ -1748,7 +1769,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! update_profile('web.'.$page["file"].'.sort', $_REQUEST['sort']); } - if(!in_array($_REQUEST['sortorder'],array(ZBX_SORT_DOWN,ZBX_SORT_UP))) + if(!str_in_array($_REQUEST['sortorder'],array(ZBX_SORT_DOWN,ZBX_SORT_UP))) $_REQUEST['sortorder'] = ZBX_SORT_UP; update_profile('web.'.$page["file"].'.sortorder', $_REQUEST['sortorder']); @@ -1808,7 +1829,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! $tabfield = get_request('sort',get_profile('web.'.$page["file"].'.sort',null)); if(is_null($tabfield)) return ' ORDER BY '.$def.$allways; - if(!in_array($tabfield,$sortable)) return ' ORDER BY '.$def.$allways; + if(!str_in_array($tabfield,$sortable)) return ' ORDER BY '.$def.$allways; $sortorder = get_request('sortorder',get_profile('web.'.$page["file"].'.sortorder',ZBX_SORT_UP)); diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php index 0cb65aad..a9e67217 100644 --- a/frontends/php/include/copt.lib.php +++ b/frontends/php/include/copt.lib.php @@ -268,13 +268,13 @@ if(defined('USE_PROFILING')){ if($sub_pages['url'] == $file){ array_push($list, $menu_path); } - if(!in_array($sub_pages['url'], $files_list)) + if(!str_in_array($sub_pages['url'], $files_list)) $result['error'][$sub_pages['url']] = array($menu_path); if(isset($sub_pages['sub_pages'])) foreach($sub_pages['sub_pages'] as $page){ $menu_path = $sub['label'].'->'.$sub_pages['label'].'->sub_pages'; - if(!in_array($page, $files_list)) + if(!str_in_array($page, $files_list)) $result['error'][$page] = array($menu_path); if($page != $file) continue; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 86e76167..201f951b 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -550,7 +550,7 @@ else { fatal_error('Incorrect type of "nodes" for "in_node". Passed ['.gettype($nodes).']'); } - return in_array(id2nodeid($id_var), $nodes); + return uint_in_array(id2nodeid($id_var), $nodes); } function get_dbid($table,$field) diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 6306ad2e..a6794f1a 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -2213,7 +2213,7 @@ { array_push($target_list,array( new CCheckBox('copy_targetid[]', - in_array($target['target_id'], $copy_targetid), + uint_in_array($target['target_id'], $copy_targetid), null, $target['target_id']), SPACE, @@ -2308,7 +2308,7 @@ " WHERE t.triggerid=d.triggerid_up AND d.triggerid_down=".$_REQUEST["triggerid"]); while($trig=DBfetch($trigs)) { - if(in_array($trig["triggerid"],$dependences)) continue; + if(uint_in_array($trig["triggerid"],$dependences)) continue; array_push($dependences,$trig["triggerid"]); } } @@ -2906,7 +2906,7 @@ include_once 'include/discovery.inc.php'; 'operator' => $condition_data['operator'], 'value' => $condition_data['value']); - if(in_array($condition_data, $conditions)) continue; + if(str_in_array($condition_data, $conditions)) continue; array_push($conditions, $condition_data); } unset($condition_data, $db_conditions); @@ -2924,7 +2924,7 @@ include_once 'include/discovery.inc.php'; 'shortdata' => $operation_data['shortdata'], 'longdata' => $operation_data['longdata']); - if(in_array($operation_data, $operations)) continue; + if(str_in_array($operation_data, $operations)) continue; array_push($operations, $operation_data); } unset($db_operations, $operation_data); @@ -2948,7 +2948,7 @@ include_once 'include/discovery.inc.php'; if( !isset($new_condition['operator'])) $new_condition['operator'] = CONDITION_OPERATOR_LIKE; if( !isset($new_condition['value']) ) $new_condition['value'] = ''; - if( !in_array($new_condition['type'], $allowed_conditions) ) + if( !str_in_array($new_condition['type'], $allowed_conditions) ) $new_condition['type'] = $allowed_conditions[0]; /* init new_operation variable */ @@ -2982,7 +2982,7 @@ include_once 'include/discovery.inc.php'; if( !isset($val['operator']) ) $val['operator'] = 0; if( !isset($val['value']) ) $val['value'] = 0; - if( !in_array($val["type"], $allowed_conditions) ) continue; + if( !str_in_array($val["type"], $allowed_conditions) ) continue; $label = chr(ord('A') + $i); $cond_el->AddRow(array('('.$label.')',array( @@ -3173,7 +3173,7 @@ include_once 'include/discovery.inc.php'; $oper_el = new CTable(S_NO_OPERATIONS_DEFINED); foreach($operations as $id => $val) { - if( !in_array($val['operationtype'], $allowed_operations) ) continue; + if( !str_in_array($val['operationtype'], $allowed_operations) ) continue; $oper_details = new CSpan(get_operation_desc(SHORT_DESCRITION, $val)); $oper_details->SetHint(nl2br(get_operation_desc(LONG_DESCRITION, $val))); @@ -3806,7 +3806,7 @@ include_once 'include/discovery.inc.php'; $form->AddRow(S_SHOW_LINES, new CNumericBox('elements',$elements,2)); $form->AddVar('resourceid',0); } - elseif(in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW))){ + elseif(uint_in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW))){ // Overiews $caption = ''; $id=0; @@ -3909,14 +3909,14 @@ include_once 'include/discovery.inc.php'; $form->AddVar("resourceid",0); } - if(in_array($resourcetype,array(SCREEN_RESOURCE_HOSTS_INFO,SCREEN_RESOURCE_TRIGGERS_INFO))) + if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_HOSTS_INFO,SCREEN_RESOURCE_TRIGGERS_INFO))) { $cmbStyle = new CComboBox("style", $style); $cmbStyle->AddItem(STYLE_HORISONTAL, S_HORISONTAL); $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL); $form->AddRow(S_STYLE, $cmbStyle); } - else if(in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW))) + else if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW,SCREEN_RESOURCE_DATA_OVERVIEW))) { $cmbStyle = new CComboBox('style', $style); $cmbStyle->AddItem(STYLE_LEFT, S_LEFT); @@ -3935,7 +3935,7 @@ include_once 'include/discovery.inc.php'; $form->AddVar("style", 0); } - if(in_array($resourcetype,array(SCREEN_RESOURCE_URL))) + if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_URL))) { $form->AddRow(S_URL, new CTextBox("url",$url,60)); } @@ -3944,7 +3944,7 @@ include_once 'include/discovery.inc.php'; $form->AddVar("url", ""); } - if(in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_CLOCK,SCREEN_RESOURCE_URL))) + if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_CLOCK,SCREEN_RESOURCE_URL))) { $form->AddRow(S_WIDTH, new CNumericBox("width",$width,5)); $form->AddRow(S_HEIGHT, new CNumericBox("height",$height,5)); @@ -3955,7 +3955,7 @@ include_once 'include/discovery.inc.php'; $form->AddVar("height", 0); } - if(in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_MAP, + if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK,SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox("halign",$halign); @@ -3979,7 +3979,7 @@ include_once 'include/discovery.inc.php'; $form->AddRow(S_ROW_SPAN, new CNumericBox("rowspan",$rowspan,2)); // dynamic AddOn - if(in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_PLAIN_TEXT))){ + if(uint_in_array($resourcetype,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_PLAIN_TEXT))){ $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox("dynamic",$dynamic,null,1)); } @@ -4031,7 +4031,7 @@ include_once 'include/discovery.inc.php'; array( new CCheckBox( "severity[]", - in_array($i,$severity)?'yes':'no', + str_in_array($i,$severity)?'yes':'no', null, /* action */ $i), /* value */ get_severity_description($i) @@ -4199,7 +4199,7 @@ include_once 'include/discovery.inc.php'; get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid()). ") "); while($db_group=DBfetch($db_groups)){ - if(in_array($db_group["groupid"],$groups)) continue; + if(uint_in_array($db_group["groupid"],$groups)) continue; array_push($groups, $db_group["groupid"]); } // read profile @@ -4253,7 +4253,7 @@ include_once 'include/discovery.inc.php'; array_push($frm_row, array( new CCheckBox("groups[]", - in_array($db_group["groupid"],$groups) ? 'yes' : 'no', + uint_in_array($db_group["groupid"],$groups) ? 'yes' : 'no', null, $db_group["groupid"] ), @@ -4424,7 +4424,7 @@ include_once 'include/discovery.inc.php'; " order by host"); while($db_host=DBfetch($db_hosts)) { - if(in_array($db_host["hostid"],$hosts)) continue; + if(uint_in_array($db_host["hostid"],$hosts)) continue; array_push($hosts, $db_host["hostid"]); } } diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index 98255cfb..c348b59c 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -654,7 +654,7 @@ $tmp_host = DBfetch(get_hosts_by_graphid($db_graph['templateid'])); - if( !in_array($tmp_host['hostid'], $templateid)) + if( !uint_in_array($tmp_host['hostid'], $templateid)) continue; } @@ -844,7 +844,7 @@ $period = get_request('period',ZBX_PERIOD_DEFAULT); - if(in_array($period,array(3600,2*3600,4*3600,8*3600,12*3600,24*3600,7*24*3600,31*24*3600,365*24*3600))) + if(uint_in_array($period,array(3600,2*3600,4*3600,8*3600,12*3600,24*3600,7*24*3600,31*24*3600,365*24*3600))) $custom_per = ZBX_MIN_PERIOD; else $custom_per = $period; diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index fd6c30c9..0c8b47d8 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -603,7 +603,7 @@ require_once "include/items.inc.php"; } } - if(in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0) + if(str_in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0) $_REQUEST["hostid"] = -1; $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options); @@ -638,22 +638,22 @@ require_once "include/items.inc.php"; $first_hostid_in_group = 0; - $allow_all_hosts = (in_array("allow_all_hosts",$options)) ? 1 : 0; - $always_select_first_host = in_array("always_select_first_host",$options) ? 1 : 0; - $only_current_node = in_array("only_current_node",$options) ? 1 : 0; + $allow_all_hosts = (str_in_array("allow_all_hosts",$options)) ? 1 : 0; + $always_select_first_host = str_in_array("always_select_first_host",$options) ? 1 : 0; + $only_current_node = str_in_array("only_current_node",$options) ? 1 : 0; - if(in_array("monitored_hosts",$options)) + if(str_in_array("monitored_hosts",$options)) $with_host_status = " and h.status=".HOST_STATUS_MONITORED; - elseif(in_array('real_hosts',$options)) + elseif(str_in_array('real_hosts',$options)) $with_host_status = " and h.status<>".HOST_STATUS_TEMPLATE; - elseif(in_array('templated_hosts',$options)) + elseif(str_in_array('templated_hosts',$options)) $with_host_status = " and h.status=".HOST_STATUS_TEMPLATE; else $with_host_status = ""; - if(in_array("with_monitored_items",$options)){ + if(str_in_array("with_monitored_items",$options)){ $item_table = ",items i"; $with_items = " and h.hostid=i.hostid and i.status=".ITEM_STATUS_ACTIVE; - }else if(in_array("with_items",$options)){ + }else if(str_in_array("with_items",$options)){ $item_table = ",items i"; $with_items = " and h.hostid=i.hostid"; } else { $item_table = ""; @@ -791,7 +791,7 @@ require_once "include/items.inc.php"; } } - if(in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0) + if(uint_in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0) $_REQUEST["hostid"] = -1; $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options); @@ -1081,7 +1081,7 @@ require_once "include/items.inc.php"; unset($skip); if( ($tmp_app_data = get_application_by_applicationid($db_app["templateid"])) ) { - if( !in_array($tmp_app_data["hostid"], $templateid) ) + if( !uint_in_array($tmp_app_data["hostid"], $templateid) ) { $skip = true; break; diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php index d3d6a3c3..ce47a503 100644 --- a/frontends/php/include/import.inc.php +++ b/frontends/php/include/import.inc.php @@ -100,7 +100,7 @@ info('Host ['.$data['name'].'] skipped - user rule'); break; // case } - if(!in_array($host_data['hostid'], $this->accessible_hosts)){ + if(!uint_in_array($host_data['hostid'], $this->accessible_hosts)){ error('Host ['.$data['name'].'] skipped - Access deny.'); break; // case } @@ -118,7 +118,7 @@ } // if( count($this->accessible_nodes) > 0 ){ - if(!in_array(get_current_nodeid(),$this->accessible_nodes)){ + if(!uint_in_array(get_current_nodeid(),$this->accessible_nodes)){ error('Host ['.$data['name'].'] skipped - Access deny.'); break; // case } @@ -213,7 +213,7 @@ break; // case } - if(!in_array($group["groupid"], $this->accessible_groups)) + if(!uint_in_array($group["groupid"], $this->accessible_groups)) { error('Group ['.$this->element_data.'] skipped - Access deny.'); break; // case @@ -257,7 +257,7 @@ break; // case } - if(!in_array($template["hostid"], $this->accessible_hosts)) + if(!uint_in_array($template["hostid"], $this->accessible_hosts)) { error('Template ['.$this->element_data.'] skipped - Access deny.'); break; // case diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index e1da2c2e..260df4ff 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -232,7 +232,7 @@ if(eregi('^((.)*)(\[\"((.)*)\"\,\"((.)*)\"\,\"((.)*)\"\,\"([0-9]+)\"\])$', $key, $arr)) { $g=$arr[1]; - if(!in_array($g,array("grpmax","grpmin","grpsum","grpavg"))) + if(!str_in_array($g,array("grpmax","grpmin","grpsum","grpavg"))) { error("Group function [$g] is not one of [grpmax,grpmin,grpsum,grpavg]"); return FALSE; @@ -243,7 +243,7 @@ $g=$arr[6]; // Item function $g=$arr[8]; - if(!in_array($g,array("last", "min", "max", "avg", "sum","count"))) + if(!str_in_array($g,array("last", "min", "max", "avg", "sum","count"))) { error("Item function [$g] is not one of [last, min, max, avg, sum,count]"); return FALSE; @@ -553,7 +553,7 @@ $db_tmp_item = get_item_by_itemid($db_item["templateid"]); - if ( !in_array($db_tmp_item["hostid"], $templateid) ) + if ( !uint_in_array($db_tmp_item["hostid"], $templateid) ) continue; } diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php index a3db20bb..dc1874e4 100644 --- a/frontends/php/include/maps.inc.php +++ b/frontends/php/include/maps.inc.php @@ -95,7 +95,7 @@ switch($se_data['elementtype']) { case SYSMAP_ELEMENT_TYPE_HOST: - if(in_array($se_data['elementid'],explode(',',$denyed_hosts))) + if(uint_in_array($se_data['elementid'],explode(',',$denyed_hosts))) { $result = false; } @@ -115,7 +115,7 @@ break; case SYSMAP_ELEMENT_TYPE_HOST_GROUP: if( DBfetch(DBselect('select groupid from groups where groupid='.$se_data['elementid'])) && - in_array($se_data['elementid'], + uint_in_array($se_data['elementid'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT, PERM_RES_IDS_ARRAY))) { $result = false; diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index a2e3e640..993091f6 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -282,7 +282,7 @@ COpt::profiling_start("page"); $sub['pages'][$id]['active'] = true; /* mark as active */ } else if(isset($sub_pages['sub_pages'])){ - if(in_array($page['file'], $sub_pages['sub_pages'])){ + if(str_in_array($page['file'], $sub_pages['sub_pages'])){ if(isset($sub_pages['label'])){ $menu_url = $sub_pages['url']; } diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index df137f8b..d1fd3212 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -352,7 +352,7 @@ COpt::counter_up('perm'); $do_break = true; - if(is_array($nodeid) && !in_array($node_data['nodeid'],$nodeid)) continue; + if(is_array($nodeid) && !uint_in_array($node_data['nodeid'],$nodeid)) continue; else if(!is_array($nodeid) && (bccomp($node_data['nodeid'] ,$nodeid) != 0)) continue; } else @@ -614,7 +614,7 @@ COpt::counter_up('perm'); $do_break = true; - if(is_array($nodeid) && !in_array($node_data['nodeid'],$nodeid)) continue; + if(is_array($nodeid) && !uint_in_array($node_data['nodeid'],$nodeid)) continue; else if(isset($nodeid) and (bccomp($node_data['nodeid'] ,$nodeid) != 0)) continue; } else diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php index c5ab93ff..3b53b932 100644 --- a/frontends/php/include/scripts.inc.php +++ b/frontends/php/include/scripts.inc.php @@ -129,12 +129,12 @@ function get_accessible_scripts_by_hosts($hosts){ while($script = DBfetch($res)){ foreach($hosts as $id => $hostid){ if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){ - if(in_array($hostid,$hosts_read_write)){ + if(uint_in_array($hostid,$hosts_read_write)){ $scripts_by_host[$hostid][] = $script; } } else{ - if(in_array($hostid,$hosts_read_only)){ + if(uint_in_array($hostid,$hosts_read_only)){ $scripts_by_host[$hostid][] = $script; } } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 65b26696..f9cfb630 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -593,7 +593,7 @@ $fnc_valid = &$ZBX_TR_EXPR_ALLOWED_FUNCTIONS[$function]; if ( is_array($fnc_valid['item_types']) && - !in_array($item['value_type'], $fnc_valid['item_types'])) + !uint_in_array($item['value_type'], $fnc_valid['item_types'])) { $allowed_types = array(); foreach($fnc_valid['item_types'] as $type) @@ -1531,7 +1531,7 @@ $db_hosts = get_hosts_by_expression($expression); while($host_data = DBfetch($db_hosts)) { - if(!in_array($host_data['hostid'], $accessible_hosts)) return false; + if(!uint_in_array($host_data['hostid'], $accessible_hosts)) return false; } return true; @@ -1707,7 +1707,7 @@ $db_tmp_hosts = get_hosts_by_triggerid($trigger["templateid"]); $tmp_host = DBfetch($db_tmp_hosts); - if( !in_array($tmp_host["hostid"], $templateid) ) + if( !uint_in_array($tmp_host["hostid"], $templateid) ) continue; } diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index 80a923ef..740974d0 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -60,7 +60,7 @@ { if(is_array($array)) $array = implode(',', $array); - return "in_array({".$var."},array(".$array."))&&"; + return "str_in_array({".$var."},array(".$array."))&&"; } function HEX($var=NULL) { @@ -222,7 +222,6 @@ } $expression = trim($expression,"& "); $exec = "return (".$expression.") ? 1 : 0;"; - $ret = eval($exec); //echo $debug; //echo "$field - result: ".$ret." exec: $exec".SBR.SBR; @@ -232,8 +231,6 @@ function calc_exp($fields,$field,$expression) { - global $_REQUEST; - //SDI("$field - expression: ".$expression); if(strstr($expression,"{}") && !isset($_REQUEST[$field])) |
