arraypos=-1; $MenuEntry->menuitem=null; $pos=0; foreach($menuList as $menuItem){ if($option==$menuItem->id){ $MenuEntry->arraypos=$pos; $MenuEntry->menuitem=$menuItem; //echo ("_pos_".$pos."\n"); } $pos=$pos+1; } return $MenuEntry; } // Is there any specific boot for MAC? $specificBoot=getClientSpecificBoot($MAC); if ($specificBoot==null) error_log("Mac param not registered, specific boot not applied"); else error_log($specificBoot); // Write Menu $timeout=getBootTimeOut(); if ($specificBoot!=null) $timeout="1"; // Set to minimum write_header($timeout); // Getting boot order $bootorder=getBootOrder(); // Setting bootlist $bootlist=array(); // Setting menu entries $menuList=array(); // Setting rescue menu entries $rescueMenu=array(); // Include all files in pxemenu.d menu to $menulist foreach (glob("/var/www/ipxeboot/pxemenu.d/*.php") as $filename) { $MenuEntryListObject=null; // $ filename should define $MenuEntryListObject include $filename; if($MenuEntryListObject!=null){ foreach($MenuEntryListObject as $entry){ $current_label=explode("\n", str_replace("label ", "",$entry->menuString))[0]; // If there's not default boot or it exists and is current, let's add. error_log("specific boot:".$specificBoot."*"." Current Label:".$current_label."*"); array_push($rescueMenu, $entry); // Filling rescue menu if (($specificBoot==null)||($specificBoot==$current_label)) array_push($menuList, $entry); } // If menulist is empty, overwrite by rescuemenu if (count($menuList)==0) { error_log("[LLXBootmanager Warning] Entry ".$specificBoot." does not exists."); $menuList=$rescueMenu; } } } // Ordering menu list foreach ($bootorder as $option){ $entry=findMenuEntry($menuList, $option); // find option in menu list if ($entry->menuitem!=null){ //echo "Adding: ".$entry->menuitem->id." Removing: ".$entry->arraypos."\n"; array_push($bootlist, $entry->menuitem); // Adding menu entry to boot list unset($menuList[$entry->arraypos]); $menuList=array_values($menuList); } } /* REMOVED: * If menu entries are not in list them won't be shown. * // Adding options that are not in the list foreach ($menuList as $entry) array_push($bootlist, $entry); // Adding menu entry to boot list */ foreach ($bootlist as $opt){ //echo $opt->id; $regex=array('/( |,)(pxe|pxe-ltsp|opensysclone-system|netinstall)(.*)/iU','/(initrd=)(pxe|pxe-ltsp|opensysclone-system|netinstall)(\/.*)/i'); $subs=array('\1../../\2\3','\1../../\2\3'); echo preg_replace($regex,$subs,$opt->menuString)."\n"; } ?>