<?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 39 2011-03-25 02:48:43Z along $
#
#	Copyright (C) 2008-2011 PHPDisk Team. All Rights Reserved.
#
*/

include "includes/commons.inc.php";

phpdisk_core::admin_login();

define('IN_ADMINCP' ,true);

lang('admincp');

if(!$app && (empty($item) || $item == '')){
	require_once template_echo("admincp",$admin_tpl_dir,'',1);
	exit();
}
$op = trim(gpc('op','G',''));

if($item == "menu"){
	if($op =='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($item,$admin_tpl_dir,'',1);
}else{
	$admin_log_dir = PHPDISK_ROOT.'system/logs/admincp/';
	$log_file = $admin_log_dir.date('Ymd').'_'.random(8).'.log';

	$uri = $_SERVER['REQUEST_URI'];
	$op_subject = $L['log_'.$item.'_'.$app.'_'.$action] ? $L['log_'.$item.'_'.$app.'_'.$action] : $L['log_unknown'];
	$str = "$op_subject|$pd_username|$uri|".date('Y-m-d H:i:s')."|$onlineip".LF;

	$log_arr = glob($admin_log_dir.date("Ymd")."_*.log");
	foreach($log_arr as $log){
	}
	$log_file = $log ? $log : $log_file;
	write_file($log_file,$str,'ab+');

	require_once template_echo('adm_header',$admin_tpl_dir,'',1);
	if($app && $item =='plugins'){
		require_once PHPDISK_ROOT."plugins/".$app."/admin.inc.php";
	}else{
		$items = array('templates','database','main','settings','groups','users','files','cache','lang','version','plugins','email','advertisement','link','announce','navigation','public','tag','credit','seo','comment','report','verycode','union','gallery','sitemap','datacall');
		if(in_array($item,$items)){
			require_once PHPDISK_ROOT."admin/".$item.".inc.php";
		}else{
			echo "Error operation, system halt!";
		}
	}
	$pageinfo = page_end_time();

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

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

function sitemap_tag($str){
	global $L;
	$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="'.$L['add_sitemap_tips'].'">[+]</a>';
	echo $rtn;
}
?>


