<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.5 www.exoops.info 2006/05
// $Id: admin.php,v 1.4 2003/03/19 07:03:20 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
$fct = !empty($_POST['fct']) ? $_POST['fct'] : $_GET['fct'];
if ($fct == "users") {
	$xoopsOption['pagetype'] = "user";
}
include_once("../../mainfile.php");
include_once(XOOPS_ROOT_PATH."/include/cp_functions.php");
if ( @file_exists(XOOPS_ROOT_PATH."/modules/system/language/".$bcoosConfig['language']."/language.php") ) {
	include(XOOPS_ROOT_PATH."/modules/system/language/".$bcoosConfig['language']."/language.php");
	} else {
		include(XOOPS_ROOT_PATH."/modules/system/language/english/language.php");
	}
/*********************************************************/
/* Admin Authentication                                  */
/*********************************************************/
$admintest = 0;
if ($xoopsUser) {
	$xoopsModule = XoopsModule::getByDirname("system");
	if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
		redirect_header(XOOPS_URL."/", 3, _NOPERM);
		exit();
	}
	$admintest = 1;
	} else {
		redirect_header(XOOPS_URL."/", 3, _NOPERM);
		exit();
	}
if ($admintest == 1) {
	if ( !empty($fct) ) {
		if ( @file_exists(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/main.php") ) {
			if ( @file_exists(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/language/".$bcoosConfig['language']."/".$fct.".php") ) {
				include(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/language/".$bcoosConfig['language']."/".$fct.".php");
			} elseif ( @file_exists(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/language/english/".$fct.".php") ) {
				include(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/language/english/".$fct.".php");
			}
			include(XOOPS_ROOT_PATH."/modules/system/admin/".$fct."/main.php");
		} else {
			xoops_cp_header();
			system_menu();
			xoops_cp_footer();
		}
		} else {
			xoops_cp_header();
			system_menu();
			xoops_cp_footer();
		}
}
/*********************************************************/
/* Core Menu Functions                                   */
/*********************************************************/
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function system_menu_item($folder, $modversion) {
global $bcoosConfig;
echo "<a href='".XOOPS_URL."/modules/system/admin.php?fct=".$folder."'><b>".trim($modversion['name'])."</b></a>";
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function system_menu() {
global $bcoosConfig, $xoopsUser, $xoopsModule;
OpenTable();
echo "<table border='0' cellpadding='1' align='center'><tr>";
$admin_dir = XOOPS_ROOT_PATH."/modules/system/admin";
$handle    = @opendir($admin_dir);
$counter   = 0;
while (false !== ($file = readdir($handle))) {
	if ( $file != '.' && $file != '..' && @file_exists($admin_dir."/".$file."/xoops_version.php") ) {
		include_once($admin_dir."/".$file."/xoops_version.php");
		if ( $modversion['hasAdmin'] ) {
			echo "<td align='center' valign='bottom' width='19%'>";
			system_menu_item($file, $modversion);
			echo "</td>";
			$counter++;
		}
		if ( $counter > 4 ) {
			$counter = 0;
			echo "</tr><tr>";
		}
	}
unset($modversion);
}
echo "</tr></table>";
CloseTable();
}
?>
