<?php 
/**
#	Project: PHPDISK File Storage Solution
#	This is NOT a freeware, use is subject to license terms.
#
#	Site: http://www.phpdisk.com
#
#	$Id: admincp.php 64 2016-07-30 14:01:18Z along $
#
#	Copyright (C) 2008-2016 PHPDisk Team. All Rights Reserved.
#
*/

include "includes/commons.inc.php";

phpdisk_core::admin_login();

define('IN_ADMINCP' ,true);

$menu = trim(gpc('menu','G',''));
$job = trim(gpc('job','G',''));
$menu = $menu ? $menu : '';
$item = $item ? $item : 'main';

if($job=='auth'){
	check_auth_domain('includes/core/core.post.php',1);
	exit;
}

if($menu =='plugin'){
	if($settings['open_plugins_last']){
		$q = $db->query("select * from {$tpf}plugins where actived=1 and action_time>0 order by action_time desc, plugin_name asc limit 10");
		while($rs = $db->fetch_array($q)){
			if(check_plugin($rs['plugin_name'])){
				$plugins_arr[] = get_plugin_info($rs['plugin_name']);
			}
		}
		$db->free($q);
		unset($rs);
	}
	if($settings['open_plugins_cp']){
		$q = $db->query("select * from {$tpf}plugins where actived=1 and in_shortcut=1 order by plugin_name asc");
		while($rs = $db->fetch_array($q)){
			if(check_plugin($rs['plugin_name'])){
				$s_plugins_arr[] = get_plugin_info($rs['plugin_name']);
			}
		}
		$db->free($q);
		unset($rs);
	}
}else{
	$q = $db->query("select * from {$tpf}cp_shortcut");
	$cs_menus = array();
	while($rs = $db->fetch_array($q)){
		$cs_menus[] = $rs;
	}
	$db->free($q);
	unset($rs);
}

require_once template_echo('adm_header',$admin_tpl_dir,'',1);
if($app && $item =='plugins'){
	$action_module = PHPDISK_ROOT."plugins/".$app."/admin.inc.php";
}else{
	$items = array('templates','database','main','settings','groups','users','files','cache','lang','plugins','email','advertisement','link','announce','navigation','seo','report','verycode','sitemap','depart','public');
	if(in_array($item,$items)){
		$action_module = PHPDISK_ROOT.'admin/'.$item.'.inc.php';
	}else{
		echo "<p align='center'>Error operation, system halt!</p>";
		exit;
	}
}
$pageinfo = page_end_time();

require_once template_echo('admincp',$admin_tpl_dir,'',1);
require_once template_echo('adm_footer',$admin_tpl_dir,'',1);


include PHPDISK_ROOT."./includes/footer.inc.php";

function sitemap_tag($str){
	$str = rawurlencode($str);
	$url = base64_encode($_SERVER['QUERY_STRING']);
	$rtn = '&nbsp;<a href="'.urr(ADMINCP,"item=sitemap&action=add_shortcut&title=$str&url=$url").'" title="'.__('add_sitemap_tips').'">[+]</a>';
	echo $rtn;
}
?>


