<?php
//+-----------------------------------------------+//
//+ Copyright Floopo.com
//+ myaccount.php
//+ Manage user account
//+-----------------------------------------------+//

defined('BASEPATH') or die('You can not directly access this file');//check its within this framework

//____GENERAL SETTINGS____
$template = BASEPATH.'/com/com_myaccount/assets/theme/tpl_template.htm';
$show_menu = 1;


//____MYSQL CONNECTION____
//$quickmysql_debug = 1;
$dbase = new QuickMysql(DB_NAME,DB_USER,DB_PASS,DB_HOST);


//____CHECK IF LOGGED IN or ADMIN____

//store new user in sessions
if($env_admin == 1 && $_GET['member'] != ''){
$_SESSION['temp_member'] = mysql_real_escape_string($_GET['member']);
}

//check if resting from member view
if($_GET['reset'] == 1){
$_SESSION['temp_member'] = '';
}

//__RESET PASSWORD____
if($_GET['load'] == 99 || $_POST['load'] ==99){
$type = (($_GET['load'])? Sanatize($_GET['load']) : Sanatize($_POST['load'])); //what are we doing
$show_menu = '';
include_once(BASEPATH.'/com/com_myaccount/helper.forgotpassword.php');

}else{


//set new user or login check
if($env_admin == 1 && $_SESSION['temp_member'] != ''){
$env_user_name = $_SESSION['temp_member'];  //temp set the env user to one in GET
}else{
loggedin_check();
}

//__CHECK ACCOUNT IS ACTIVE____
$account_status = $dbase->SelectRecord("SELECT user_name FROM member_profile WHERE user_name = '$env_user_name' AND account_status = 'active'");
if(!$account_status){
$show_notification = 1;
$message = $lang['generic_error']; //suspended/disabled account
$show_menu = ''; //disable top menu

}else{

//____LOAD CORRECT HELPER____
$type = (($_GET['load'])? Sanatize($_GET['load']) : Sanatize($_POST['load'])); //what are we doing

switch($type){

//edit profile
case 1:
include_once(BASEPATH.'/com/com_myaccount/helper.profile.php');
break;

//chnage passowrd
case 2:
include_once(BASEPATH.'/com/com_myaccount/helper.password.php');
break;

//preferences
case 3:
include_once(BASEPATH.'/com/com_myaccount/helper.preferences.php');
break;

//manage avatar
case 4:
include_once(BASEPATH.'/com/com_myaccount/helper.avatar.php');
break;

//web profiles
case 5:
include_once(BASEPATH.'/com/com_myaccount/helper.webprofiles.php');
break;

//direct messages
case 6:
include_once(BASEPATH.'/com/com_myaccount/helper.messages.php');
break;

//direct messages
case 7:
include_once(BASEPATH.'/com/com_myaccount/helper.customprofile.php');
break;

//defaule welcome
default:
$show_welcome = 1;
break;

}

}
}
//____Display any output_________________________
$TBS = new clsTinyButStrong;
$TBS->NoErr = true;
$TBS->LoadTemplate($template);
$TBS->MergeField('config',$config);
$TBS->MergeField('lang',$lang);
//messages merge
$TBS->MergeBlock('blk1',$result);
$TBS->Render = TBS_OUTPUT;
$TBS->Show();
@mysql_close(); 

?>