= 10){ return ''; } // failure on empty $menu if(count($menu)<1){ return ''; } // Get the levels that *are* in the menu array $current_level_rows = array(); foreach($menu as $id => $menu_item){ if($menu_item['cnt_parent'] == $current_level){ $current_level_rows[$id] = $menu_item; } } // failure on no current row elements if(count($current_level_rows) == 0){ return ''; } // get the code-view display tabs $tabs = ''; for($i = 1; $i <= $display_level; $i++){ $tabs .= "\t"; } // make the html $html = "{$tabs}"; return $html; } function child_exists($menu=array(), $parent_id=0){ foreach($menu as $item){ if($item['cnt_parent']==$parent_id){ return true; } } return false; } function child_selected($menu=array(), $parent_id=0){ $children = array(); foreach($menu as $id => $item){ if($item['cnt_parent'] == $parent_id){ if($item['selected']) { return true; } $children[$id] = $item; } } $sub_child_selected = false; foreach($children as $child_id => $child_item){ if(child_exists($menu, $child_id)){ $sub_child_selected = ($sub_child_selected || child_selected($menu, $child_id)); } } return $sub_child_selected; } /* Check for these vars, and obtain them if they dne. */ if(!$db || !$clsLogin){ require_once($_SERVER['APPLICATION_ROOT']."common/classes/CDatabase.php"); require_once($_SERVER['APPLICATION_ROOT']."common/classes/CLogin.php"); $db = new CDatabase(); $clsLogin = new CLogin(); } $selects = 'cnt_id,cnt_file,cnt_title,cnt_order,cnt_parent,cnt_visible,cnt_access'; $menu_sql = "SELECT {$selects} FROM cms_content ORDER BY cnt_order"; $db -> Query($menu_sql); $menu = array(); while($row = $db -> GetRowAssociative()){ if($row['cnt_visible'] == 'N') continue; //if($row['cnt_access'] != "WORLD") // if(!$clsLogin->IsUserTypeOrGreaterLoggedIn($row['cnt_access'])) continue; if(!$clsLogin->AuthorizePage($row['cnt_file'])) continue; $expire_timestamp = strtotime($clsLogin->GetUserExpiration()); $days_left = ceil(($expire_timestamp - time())/(3600 * 24)); //if($days_left < DAYS_GRACE_PERIOD) continue; $row['cnt_title'] = stripslashes($row['cnt_title']); $row['cnt_parent'] = (($row['cnt_parent']!='')&&($row['cnt_parent']>0)) ?$row['cnt_parent']: intval('-1'); $row['selected'] = ($row['cnt_id'] == $_GET['show_content']); $menu[$row['cnt_id']] = $row; } //get the levels foreach($menu as $id => $menu_item){ $first_level = (($first_level!='') && ($first_level<$menu_item['cnt_parent'])) ?$first_level :$menu_item['cnt_parent']; } //sort through everything to get the proper level and current sublevel $menu_html = sub_menu_to_html($menu, $first_level); $menu_html = "{$menu_html}"; print $menu_html; ?>