<?php
/**
 *      [Dzz!] (C)2010-2011 dzz.cc
 *      This is NOT a freeware, use is subject to license terms
 *
 * ============================================================================
 * 版权所有 2010-2011 Dzz!Desktop，并保留所有权利。
 * 网站地址: http://dzz.cc；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式、任何目的的再发布。
 * ============================================================================
 */
define('IN_ADMINCP', TRUE);
define('NOROBOT', TRUE);
define('ADMINSCRIPT', basename(__FILE__));
define('CURSCRIPT', 'admin');
define('APPTYPEID', 0);
$adminscript=ADMINSCRIPT;

require './source/class/class_core.php';
require './dzz/class/class_admincp.php';
require './source/function/function_misc.php';
require './source/function/function_forum.php';
require './source/function/function_admincp.php';
require './source/function/function_cache.php';
require './source/function/function_home.php';
require './dzz/function/dzz_core.php';
require './dzz/function/dzz_admincp.php';
require './dzz/dzz_version.php';
$discuz = & discuz_core::instance();
if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) {
	$_GET = array_merge($_GET, $_POST);
}
$discuz->init();

$admincp = new discuz_admincp();
$admincp->core  = & $discuz;
$admincp->init();
 $admincp_actions_normal = array('index','apps','widgets','setting', 'thame','update','announce','manyou','huandeng','zhuda','icons','feature','comment','image','video','music','link','attach','widget','members','usergroup');
$admincp_actions_founder = array('install','market','plugins','spacemanage');
$action = getgpc('action');
$operation = getgpc('operation');
$do = getgpc('do');
$frames = getgpc('frames');

$lang=& dzzlang('admin/template');


$page = max(1, intval(getgpc('page')));
$isfounder = $admincp->isfounder;

$lock_install = DISCUZ_ROOT.'./data/dzzinstall.lock';
if(!file_exists($lock_install)){// && !DB::result_first("select COUNT(*) from ".DB::table('dzz_config')."  ")){
	$action='install';
	if($operation!='license' && $operation!='install' && $operation!='finish' ) $operation='license';
	require_once DISCUZ_ROOT.'dzz/admin/admincp/admincp_'.$action.'.php';
	exit();
}
if(empty($action) || $frames != null) {
	lang('admincp_menu');
	$extra = cpurl('url');
	$extra = $extra && getgpc('action') ? $extra : 'action=index';
	$charset = CHARSET;
	$title = cplang('admincp_title');
	$header_welcome = cplang('header_welcome');
	$header_logout = cplang('header_logout');
	$header_bbs = cplang('header_bbs');
	$cpadmingroup = isfounder() ? cplang('founder_admin') : ($GLOBALS['admincp']->adminsession['cpgroupid'] ? DB::result_first("SELECT cpgroupname FROM ".DB::table('common_admincp_group')." WHERE cpgroupid='".$GLOBALS['admincp']->adminsession['cpgroupid']."'") : cplang('founder_master'));
	//获取有管理的插件
	include dzztemplate('admin/dzzadmin');
	
}elseif($action == 'logout') {
		$admincp->do_admin_logout();
		dheader("Location: ./".ADMINSCRIPT);
}elseif(strpos(strtolower($action),'plugin:')!==false){
		list($folder,$identifier) = explode(':', $action);
		$adminfile=DB::result_first("select adminfile from ".DB::table('dzz_plugin')." where identifier='{$identifier}'");
		$modfile='./dzz/'.$folder.'/'.$identifier.'/'.($adminfile?$adminfile:'admin.php');
		if(@!file_exists(DISCUZ_ROOT.$modfile)){
			showmessage($lang('plugin_adminfile_nonexistence'));
		}
		require_once DISCUZ_ROOT.$modfile;
}elseif(in_array($action, $admincp_actions_normal) || ($admincp->isfounder && in_array($action, $admincp_actions_founder))) {
		require_once DISCUZ_ROOT.'dzz/admin/admincp/admincp_'.$action.'.php';
} else{
	
		cpheader();
		cpmsg('action_noaccess', '', 'error');
}
?>