<?php
/************************************************
 * Powered with qEngine v9 (c) C97.net
 * All rights reserved
 ************************************************/
 
// check install/
if (file_exists ('./install/'))
{
	die ('If you have just installed Cart Engine, please delete the <b>"install/"</b> directory on your server before using Cart Engine v5.1 (build 2015.03.03). Or <a href="install/index.php">'
	    .'click here</a> to install Cart Engine for the first time.');
}

// very important file
require_once "./includes/user_init.php";

// get param?
$cmd = get_param ('cmd');

switch ($cmd)
{
	case 'skin':
		$skin = get_param ('skin');
		if (file_exists ('./skins/'.$skin.'/outline.tpl')) $_SESSION[$db_prefix.'override_skin'] = $skin;
		redir ();
	break;


	case 'viewmode':
		$view_mode = get_param ('mode');
		if ($view_mode == 'desktop') $_SESSION[$db_prefix.'view_mode'] = 'desktop';
		else $_SESSION[$db_prefix.'view_mode'] = 'mobile';
		redir ();
	break;


	case 'xe':
		$xe = get_param ('xe');
		if (!is_numeric ($xe) || ($xe > 5) || ($xe < 0)) redir ();
		if ($xe) if (!$config['cart']['curr_name_'.$xe]) redir ();
		$_SESSION[$db_prefix.'currency'] = $xe;
		redir ();
	break;
	
	
	case 'lang':
		$l = get_param ('lang');
		$foo = sql_qquery ("SELECT * FROM ".$db_prefix."language WHERE lang_id='$l' LIMIT 1");
		if ($foo) $_SESSION[$db_prefix.'language'] = $l;
		redir ();
	break;
}

// demo mode? -- if it is, check if it needs content reset
if (($config['demo_mode']) && ($config['last_autoexec'] != $sql_today))
{
	require './includes/admin_func.php';
	require $config['demo_path'].'/reset.php';
}

// auto exec (this block will be executed daily)
if ($config['last_autoexec'] != $sql_today)
{
	$d2 = convert_date ($sql_today, 'sql', -1);
	sql_query ("DELETE FROM ".$db_prefix."user WHERE (user_id LIKE 'guest*%') AND (user_passwd='++XPRESS++') AND (user_since < '$d2')");
	sql_query ("UPDATE ".$db_prefix."config SET config_value='$sql_today' WHERE config_id='last_autoexec' LIMIT 1");
}

// load tpl
$tpl = load_tpl ('welcome.tpl');

//
$txt['main_body'] = quick_tpl ($tpl, $txt);
$outline_tpl_mode = 'welcome';
flush_tpl ();
?>