<?php
// $Id: admin_header.php,v 1.5 2005/10/28 11:56:02 ohwada Exp $

// 2005-10-14 K.OHWADA
// BUG 3095: the number of links does not change, if delete link
// include admin_functions.php

// 2005-09-04 K.OHWADA
// BUG 2932: dont work correctly when register_long_arrays = off

// 2005-01-20 K.OHWADA
// use snoopy.php
// add $weblinksConfig

// 2004-11-28 K.OHWADA
// use file_include.php

//=========================================================
// admin header
// 2004-10-13 K.OHWADA
//=========================================================

// system files
include '../../../include/cp_header.php';
include_once XOOPS_ROOT_PATH.'/class/xoopstree.php';
include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
include_once XOOPS_ROOT_PATH.'/class/module.errorhandler.php';
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
include_once XOOPS_ROOT_PATH."/class/snoopy.php";
include_once XOOPS_ROOT_PATH."/include/xoopscodes.php";

// enable to install this module two or more.
// dir name
$MODULE_DIRNAME = $xoopsModule->dirname();
$MODULE_ROOT    = XOOPS_ROOT_PATH."/modules/".$MODULE_DIRNAME;
$MODULE_URL     = XOOPS_URL."/modules/".$MODULE_DIRNAME;
$XOOPS_LANGUAGE = $xoopsConfig['language'];

// system parameter

// BUG 2932: dont work correctly when register_long_arrays = off
$server_remote_addr = getenv("REMOTE_ADDR");

$xoops_site_url    = XOOPS_URL.'/';
$xoops_site_name   = $xoopsConfig['sitename'];
$xoops_site_email  = $xoopsConfig['adminmail'];


$config_handler =& xoops_gethandler('config');
$xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER);
$xoops_site_author      = $xoopsConfigMetaFooter['meta_author'];
$xoops_site_description = $xoopsConfigMetaFooter['meta_description'];


$xoops_user_uid      = 0;
$xoops_user_uname    = '';
$xoops_user_email    = '';
$xoops_user_groups   = '';
$is_xoops_user_admin = false;

if ( is_object($xoopsUser) )
{
	$xoops_user_uid    = $xoopsUser->getVar('uid');
	$xoops_user_uname  = $xoopsUser->getVar('uname');
	$xoops_user_email  = $xoopsUser->getVar('email');
	$xoops_user_groups = $xoopsUser->getGroups();

	if ( $xoopsUser->isAdmin( $xoopsModule->mid() )) 
	{
		$is_xoops_user_admin = true;
	}

}

$xoops_module_mid  = $xoopsModule->getVar('mid');
$xoops_module_name = $xoopsModule->getVar('name');

// admin check
if ( !$is_xoops_user_admin )
{
	redirect_header(XOOPS_URL , 1, _NOPERM);
	exit();
}

// include files
include_once $MODULE_ROOT."/include/file_include.php";
file_include_weblinks( $MODULE_DIRNAME, $XOOPS_LANGUAGE );
file_include_module_lang( 'main.php', $MODULE_DIRNAME, $XOOPS_LANGUAGE );

include_once $MODULE_ROOT."/admin/admin_functions.php";
include_once $MODULE_ROOT."/admin/broken.php";
include_once $MODULE_ROOT."/admin/votedata.php";

// config
$tbl_config     =& table_config::getInstance();
$weblinksConfig = $tbl_config->get_config();

// class
$tbl_link     =& table_link::getInstance();
$tbl_category =& table_category::getInstance();
$tbl_catlink  =& table_catlink::getInstance();
$tbl_modify   =& table_modify::getInstance();
$tbl_broken   =& table_broken::getInstance();
$tbl_votedata =& table_votedata::getInstance();
$tbl_atomfeed =& table_atomfeed::getInstance();

$lang =& language_convert::getInstance();

$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
$eh   = new ErrorHandler;

?>
