<?php
/*********************/
/*                   */
/*  Dezend for PHP5  */
/*         NWS       */
/*      Nulled.WS    */
/*                   */
/*********************/

include_once( "./include/main.inc.php" );

@define( "IN_SUPESITE_SPACECP", @TRUE );
define( "IMG_DIR", S_URL."/admin/spacecp" );
define( "CPURL", S_URL."/spacecp.php" );

$action = empty( $_GET['action'] ) ? "" : $_GET['action'];

getcookie(2);

if ( !empty( $_SCONFIG['closesite'] ) && ( empty( $_SGLOBAL['group']['groupid'] ) || $_SGLOBAL['group']['groupid'] != 1 ) ){
	if ( empty($_SCONFIG['closemessage']) ){
		$_SCONFIG['closemessage'] = $lang['site_close'];
	}
	messagebox( "error", $_SCONFIG['closemessage']."<p style=\"font-size:12px;\"><a href=\"".geturl( "action/login")."\">".$lang['admin_login']."</a></p>" );
}

if ( empty($_SGLOBAL['supe_uid']) ) {
	setcookie( "_refer", rawurlencode( S_URL_ALL."/spacecp.php?".$_SERVER['QUERY_STRING'] ) );
	messagebox( "error", "after_the_first_entry_management", geturl( "action/login" ) );
}

$space = getuserspace( $_SGLOBAL['supe_uid'] );
if ( empty($space) ) {
	if ( empty($_SGLOBAL['group']['allowspace'])) {
		messagebox( "error", space_no_popedom, geturl( "uid/{$_SGLOBAL['supe_uid']}" ) );
	} else {
		messagebox( "error", "no_personal_space", geturl( "action/register" ) );
	}
}

include_once( S_ROOT."./include/common.inc.php" );
include_once( S_ROOT."./language/spacecp.lang.php" );
include_once( S_ROOT."./function/spacecp.func.php" );

if ($space['islock']) {
	if ( $_SGLOBAL['group']['groupid'] == 1 ) {
		updatetable( "userspaces", array( "islock" => 0 ), array( "uid" => $_SGLOBAL['supe_uid'] ) );
	} else {
		messagebox( "error", "space_lock" );
	}
}

if ( isset( $channels['menus']['news'] ) ) {
	unset( $channels['menus']['news'] );
}

if ( isset( $channels['types']['news'] ) ) {
	unset( $channels['types']['news'] );
}

if ( isset( $channels['menus']['topic'] ) ) {
	unset( $channels['menus']['topic'] );
}

if ( isset( $channels['types']['topic'] ) ) {
	unset( $channels['types']['topic'] );
}

$menuarr = array( 
	array( "action" => "", "name" => $slang['shortcut'] ), 
	array( "action" => "userspaces", "name" => $slang['space_manage'] ) 
);

foreach ( $channels['types'] as $nameid => $value ) {
	$menuarr[] = array( 
		"action" => gettypetablename( $nameid ), 
		"name" => $value['name'] 
	);
}

if ( !empty( $channels['menus']['group'] ) ){
	$menuarr[] = array( "action" => "groups", "name" => $lang['group'] );
}

$menuarr[] = array( "action" => "friends", "name" => $lang['friend'] );
$menuarr[] = array( "action" => "manage", "name" => $slang['comprehensive'] );
$menuarr[] = array( "action" => "usertemplates", "name" => $slang['template'] );

if ( $_SGLOBAL['group']['allownews'] || $_SGLOBAL['group']['allowcheckitem'] ) {
	$menuarr[] = array( "action" => "admincp", "name" => $slang['news_grading_review'] );
}

$menustr = $popupmenustr = "";
foreach ( $menuarr as $value ) {
	$class = "";
	if ( $action == "mybbs" || $action == "blogimport" || $action == "corpus" || $action == "bloginput" ) {
		if ( $value['action'] == "spaceblogs" ) {
			$class = " class=\"current\"";
		}
	} else if ( $action == "linkmove" ) {
		if ( $value['action'] == "spacelinks" ) {
			$class = " class=\"current\"";
		}
	} else if ( $action == "mygroups" ) {
		if ( $value['action'] == "groups" ) {
			$class = " class=\"current\"";
		}
	} else if ( $action == "itemtypes" || $action == "customfields" ) {
		if ( !empty( $_GET['type'] ) && $value['action'] == gettypetablename( $_GET['type'] ) ) {
			$class = " class=\"current\"";
		}
	} else if ( $action == $value['action'] ) {
		$class = " class=\"current\"";
	}
	// modified by lwx at 2010-4-13 9:07
	if ($value['action'] == 'friends') {
		$menustr .= "<li{$class}><a href=\"http://i.igrow.cn/space.php?do=friend\" target=\"_blank\">{$value['name']}</a></li>";
	} else {
		$menustr .= "<li{$class}><a href=\"".CPURL."?action={$value['action']}\">{$value['name']}</a></li>";	
	}
	// end of hook
}

include_once( S_ROOT."./function/model.func.php" );

$midarr = getuserspacemid();
$class = $action == "spacemodels" ? " class=\"current\"" : "";

if ( !empty( $midarr ) ) {
	$menustr .= "<li{$class}><a href=\"#\" onmouseover=\"showMenu(this.id)\" id=\"spacemodels\">{$slang['models_menu']}</a></li>";
	$popupmenustr .= "<div class=\"popupmenu\" id=\"spacemodels_menu\" style=\"display: none;\">";

	foreach ( $midarr as $tmpkey => $tmpvalue ) {
		$popupmenustr .= "<p><a href=\"".CPURL."?action=spacemodels&mid=".$tmpvalue['mid']."\">".$tmpvalue['modelalias']."</a></p>";
	}

	$popupmenustr .= "</div>";
}

$guidestr = "{$slang['positions']}: <a href=\"".geturl( "uid/{$_SGLOBAL['supe_uid']}" )."\">{$slang['my_space']}</a> <span>&gt</span> <a href=\"{$siteurl}/spacecp.php\">{$slang['space_manage']}</a>";

$guide = "<a href=\"".CPURL."?action=userspaces&amp;op=spacemode\">".$slang['change_spacemode']."</a> (".$slang['current_spacemode'].":".$slang["spacemode_".$space['spacemode']].")";

$videomode = empty( $_SCONFIG['videomode'] ) ? 0 : $_SCONFIG['videomode'];

if ( !empty( $_GET['openwindow'] ) ) {
	$sidetitle = $slang['open_side'];
	$sidedisplay = "none";
} else {
	$sidetitle = $slang['close_side'];
	$sidedisplay = "";
}

$newsiteurl = S_URL_ALL;
$theurl = CPURL."?action=".$action;
$credits = array( "credit" => 0, "abs" => 0, "sql" => "", "html" => "" );

// added by lwx at 2010-4-19 15:20
$refer = rawurlencode('http://blog.igrow.cn/'.$_SGLOBAL['supe_uid']);
// end of hook

if ( $action ) {
	switch ( $action ) {
		case "spacenews" :
			sheader( "admincp.php?".$_SERVER['QUERY_STRING'] );
			break;
		case "spaceblogs" :
		case "spaceimages" :
		case "spacevideos" :
		case "spacegoods" :
		case "spacefiles" :
		case "spacelinks" :
			include_once( S_ROOT."./function/item.func.php" );
			break;
		case "userspaces" :
			// added by lwx at 2010-4-13 9:14
			if (isset($_REQUEST['op']) && $_REQUEST['op'] == 'userfield') {
				messagebox( "error", "function_has_been_disabled" );
			}
			// end of hook
			break;
		case "mybbs" :
			break;
		case "bloginput" :
			break;
		case "blogimport" :
			break;
		case "corpus" :
			break;
		case "itemtypes" :
			break;
		case "customfields" :
			break;
		case "linkmove" :
			break;
		case "mygroups" :
			break;
		case "groups" :
			break;
		case "friends" :
			// added by lwx at 2010-4-13 9:12
			messagebox( "error", "function_has_been_disabled" );
			// end of hook
			break;
		case "manage" :
			break;
		case "usertemplates" :
			break;
		case "admincp" :
			break;
		case "spacemodels" :
			break;
		default :
			$action = "userspaces";
			break;
	}

	include_once( S_ROOT."./admin/spacecp_".$action.".php" );

} else {
	include_once( S_ROOT."./admin/tpl/spacecp_header.php" );
	include_once( S_ROOT."./admin/tpl/spacecp_home.php" );
}

include_once( S_ROOT."./admin/tpl/spacecp_footer.php" );

?>