<?php
session_start();
/* All Right Reserved (C) 2010;
  MyTickets;
  Writed By Fahad S. Al-ghudaier;
  faha1ad2@hotmail.com;
  www.phpx3.com;
*/
	include('start.php');
	include('include/system/arrays.php');
	

	
	if($member['member'] == 2){
		header("Location: index.php");
		die();
	}
	
	$page['title']			= $language['lang_15'];
	$page['allow_metas']	= 2;
	$page['other_tags']		= '<script type="text/javascript" language="javascript" src="'.$options['site_url'].'/include/js/tooltip.js"></script>';
	$page['show_header']	= 1;
	include('content_head.php');

	$dos	= array('information','update');
	$do		= $_GET['do'];
	if(! in_array($do,$dos)){
		$do	= 'information';
	}
	
	switch($do){
	case 'information':
		if($language['menus'] == 1){
			countrys_menu($member['country'],1);
		}else{
			countrys_menu($member['country'],2);
		}
		$smarty->assign('countrys',$array['country']);
		$smarty->display('information.htm');
	break;
	case 'update':
		
	$posted['password']			= input_handler($_POST['password']);
	$posted['new_password']		= input_handler($_POST['new_password']);
	$posted['new_password2']	= input_handler($_POST['new_password2']);
	$posted['email']			= $_POST['email'];
	$posted['country']			= input_handler($_POST['country']);
	$posted['website']			= input_handler($_POST['website']);
	
	if($language['menus'] == 1){
		countrys_menu($posted['country'],1);
	}else{
		countrys_menu($posted['country'],2);
	}

	if(empty($posted['email'])){
		$error['error']	= 1;
		$error['msg']	= $language['lang_3'];
		$smarty->assign('error',$error);
		$smarty->assign('countrys',$array['country']);
		$smarty->assign('posted',$posted);
		$smarty->display('information.htm');
		include('content_foot.php');
		die();
	}
	
	if(check($posted['email'],'email') == false){
		$error['error']	= 1;
		$error['msg']	= $language['lang_4'];
		$smarty->assign('error',$error);
		$smarty->assign('countrys',$array['country']);
		$smarty->assign('posted',$posted);
		$smarty->display('information.htm');
		include('content_foot.php');
		die();
	}
	if(mysql_num_rows(mysql_query("SELECT `id` FROM `members` WHERE `email`='".$posted['email']."' AND `id`!='".$member['id']."'")) > 0){
		$error['error']	= 1;
		$error['msg']	= $language['lang_7'];
		$smarty->assign('error',$error);
		$smarty->assign('countrys',$array['country']);
		$smarty->assign('posted',$posted);
		$smarty->display('information.htm');
		include('content_foot.php');
		die();
	}
	if(! $posted['website'] == '' AND check($posted['website'],'url') == false){
		$error['error']	= 1;
		$error['msg']	= $language['lang_5'];
		$smarty->assign('error',$error);
		$smarty->assign('countrys',$array['country']);
		$smarty->assign('posted',$posted);
		$smarty->display('information.htm');
		include('content_foot.php');
		die();
	}
	
	if(! empty($posted['password'])){
	$posted['password']	= md5($posted['password']);
		if($posted['password'] != $member['password']){
			$error['error']	= 1;
			$error['msg']	= $language['lang_17'];
			$smarty->assign('error',$error);
			$smarty->assign('countrys',$array['country']);
			$smarty->assign('posted',$posted);
			$smarty->display('information.htm');
			include('content_foot.php');
			die();
		}
		if($posted['new_password'] == $posted['new_password2'] AND ! empty($posted['new_password'])){
			$ChangePassword	= 1;
		}else{
			$error['error']	= 1;
			$error['msg']	= $language['lang_18'];
			$smarty->assign('error',$error);
			$smarty->assign('countrys',$array['country']);
			$smarty->assign('posted',$posted);
			$smarty->display('information.htm');
			include('content_foot.php');
			die();
		}
	}
	
	$update	= mysql_query("UPDATE `members` SET `email`='".$posted['email']."',`website`='".$posted['website']."',`country`='".$posted['country']."' WHERE `id`='".$member['id']."'");
	
	if($ChangePassword	== 1){
		$update	= mysql_query("UPDATE `members` SET `password`='".md5($posted['new_password'])."'");
	}
	$smarty->assign('msg',$language['lang_16']);
	$smarty->display('ok_msg.htm');
	redirect('control.php?do=information');
	break;
	}
	
	include('content_foot.php');
?>