$val){ $result&=insert_profile($idx,$val,$type); // recursion!!! } } else{ $profileid = get_dbid('profiles', 'profileid'); $sql='INSERT INTO profiles (profileid,userid,idx,value,valuetype)'. ' VALUES ('.$profileid.','.$USER_DETAILS["userid"].','.zbx_dbstr($idx).','.zbx_dbstr($value).','.$type.')'; $result = DBexecute($sql); } return $result; } /***********************************/ /************ HISTORY **************/ // Author: Aly function get_user_history(){ $history=array(); $delimiter = new CSpan('»','delimiter'); for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ if($rows = get_profile('web.history.'.$i,false)){ if($i>0){ array_push($history,$delimiter); } $url = new CLink($rows[0],$rows[1],'history'); array_push($history,array(SPACE,$url,SPACE)); } } return $history; } // Author: Aly function add_user_history($page){ $title = explode('[',$page['title']); $title = $title[0]; if(!(isset($page['hist_arg']) && is_array($page['hist_arg']))){ return FALSE; } $url = ''; foreach($page['hist_arg'] as $key => $arg){ if(isset($_REQUEST[$arg]) && !empty($_REQUEST[$arg])){ $url.=((empty($url))?('?'):('&')).$arg.'='.$_REQUEST[$arg]; } } $url = $page['file'].$url; $curr = 0; $profile = array(); for($i = 0; $i < ZBX_HISTORY_COUNT; $i++){ $history = get_profile('web.history.'.$i,false); if($history = get_profile('web.history.'.$i,false)){ if($history[0] != $title){ $profile[$curr] = $history; $curr++; } } } $history = array($title,$url); if($curr < ZBX_HISTORY_COUNT){ for($i = 0; $i < $curr; $i++){ update_profile('web.history.'.$i,$profile[$i],PROFILE_TYPE_ARRAY); } $result = update_profile('web.history.'.$curr,$history,PROFILE_TYPE_ARRAY); } else { for($i = 1; $i < ZBX_HISTORY_COUNT; $i++){ update_profile('web.history.'.($i-1),$profile[$i],PROFILE_TYPE_ARRAY); } $result = update_profile('web.history.'.(ZBX_HISTORY_COUNT-1),$history,PROFILE_TYPE_ARRAY); } return $result; } /********* END USER HISTORY **********/ /********** USER FAVORITES ***********/ // Author: Aly function add2favorites($favobj,$favid,$resource=null){ $favrsrc = $favobj.'_rsrc'; $favorites = get_profile($favobj,array()); $fav_rsrc = get_profile($favrsrc,array()); $favorites[] = $favid; $fav_rsrc[] = (is_null($resource))?0:$resource; $result = update_profile($favobj,$favorites); $result &= update_profile($favrsrc,$fav_rsrc); return $result; } // Author: Aly function rm4favorites($favobj,$favid,$favcnt=null,$resource=null){ $favrsrc = $favobj.'_rsrc'; $favorites = get_profile($favobj,array()); $fav_rsrc = get_profile($favrsrc,array()); $resource = (is_null($resource))?0:$resource; $favcnt = (is_null($favcnt))?0:$favcnt; if($favid == 0) $favcnt = ZBX_FAVORITES_ALL; foreach($favorites as $key => $value){ if(((bccomp($favid,$value) == 0) || ($favid == 0)) && ($fav_rsrc[$key] == $resource)){ if($favcnt < 1){ unset($favorites[$key]); unset($fav_rsrc[$key]); if($favcnt > ZBX_FAVORITES_ALL) break; // foreach } } $favcnt--; } $result = update_profile($favobj,$favorites); $result &= update_profile($favrsrc,$fav_rsrc); return $result; } // Author: Aly function get4favorites($favobj){ $favrsrc = $favobj.'_rsrc'; $fav = array(); $fav['id'] = get_profile($favobj,array()); $fav['resource'] = get_profile($favrsrc,array()); return $fav; } // Author: Aly function infavorites($favobj,$favid,$resource=null){ $fav = get4favorites($favobj); if(!empty($fav)){ foreach($fav['id'] as $id => $resourceid){ if(bccomp($favid,$resourceid) == 0){ if(is_null($resource) || ($fav['resource'][$id] == $resource)) return true; } } } return false; } /********** END USER FAVORITES ***********/ ?>