- <?php
- /*
- * Lokorin.com
- * Copyright 2004-2006
- * Licensed under the GNU LGPL. See COPYING for full terms.
- */
- /**
- * A library that contains functions that are not used except when the viewer
- * has admin privileges.
- * @author Andreas Launila
- * @version $Revision: 1.5 $
- * @package com.lokorin.lokorin.lib
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- */
-
- /**
- * For access to common constants and functions.
- */
- require_once('common.php');
-
- /**
- * Gets an menu listing all available admin panels.
- * @return string XHTML compliant code describing the admin panels as a list.
- * @access public
- */
- function getAdminMenu() {
- /**
- * Strips any file extendsion from a file name.
- * @param string $fileName The name of the file from which the extensions
- * should be stripped.
- * @return The file name without any file extension.
- * @access private
- */
- function stripFileExtension($fileName) {
- return(preg_replace('/(.*?)\..*/', '$1', $fileName));
- }
-
- //Get a list of all interesting files in the admin directory.
- $fileList = array();
- if($dir = @opendir(ROOT.FOLDER_ADMIN)) {
- while(($file = readdir($dir)) !== false) {
- if(($file != '..') && ($file != '.') && ($file != 'login.php')) {
- $filelist[]=$file;
- }
- }
- closedir($dir);
- }
- if(sizeof($filelist) == 0) {
- return;
- }
-
- //Build the menu based on the files.
- sort($filelist);
- $output = '';
- foreach($filelist as $file) {
- $file = stripFileExtension($file);
- $display = str_replace('_', ' ', $file);
- $output .= '<li><a href="'.PAGE_ROOT.FOLDER_ADMIN.$file.'">'.
- strtoupper($display[0]).substr($display,1).'</a></li>'."\n";
- }
- return($output);
- }
-
- ?>