ID ) { //Error or Not logged in. return TRUE; } if( !empty($opt_by_id) ){ $arr = array(); foreach( $opt_by_id as $k=>$v ) $arr[$v]=1; if( isset($arr[$current_user->user_email]) || isset($arr[$current_user->user_login]) || isset($arr[$current_user->ID]) ){ unset($arr); return FALSE; }else{ unset($arr); } } $result = TRUE; if( !empty($opt_by_role) ){ $role_arr = array( array(0,0), array(1,1), array(2,4), array(5,7), array(8,10), ); $x = $current_user->user_level; foreach( $opt_by_role as $k=>$v ){ $role_id = $role_arr[$v-1]; if( $x >= $role_id[0] && $x <= $role_id[1] ){ $result = FALSE; break; } } unset($role_arr); } return $result; } /* Utilities */ function print_gzipped_page($custom_header=array()) { $encoding = false; if( !headers_sent() && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ){ if( strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false ){ $encoding = 'x-gzip'; }elseif( strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false ){ $encoding = 'gzip'; } } if( $encoding ){ $contents = ob_get_contents(); ob_end_clean(); if( !empty($custom_header) ){ foreach($custom_header as $k=>$v){ header($k.': '.$v); } } header('Content-Encoding: '.$encoding); print("\x1f\x8b\x08\x00\x00\x00\x00\x00"); $size = strlen($contents); $contents = gzcompress($contents, 9); $contents = substr($contents, 0, $size); print($contents); exit(); }else{ if( !empty($custom_header) ){ foreach($custom_header as $k=>$v){ header($k.': '.$v); } } ob_end_flush(); exit(); } } function normalize_array_val($str='', $sep=','){ $result = array(); if( empty($str) ) return FALSE; $dummy = explode($sep, $str); foreach($dummy as $i){ $i = trim($i); if( !empty($i) && is_numeric($i) && intval($i)>0 ){ $i = intval($i); if( !in_array($i, $result) ) $result[] = $i; }elseif( !empty($i) && !in_array($i, $result) ){ $result[] = $i; } } unset($dummy); if( empty($result) ){ return FALSE; }else{ return $result; } } function get_array_checkbox_el($name, $opt=array(), $selected=array()){ $result = ''; if( empty($name) || empty($opt) || !is_array($opt) ) return $result; $count = 0; foreach($opt as $k=>$item){ $count++; } $count_per = round($count/3); $i = 0; $ended = false; foreach($opt as $k=>$item){ if( $i == 0 ){ $result .= '