<?
############################################################
# \-\-\-\-\-\-\     AzDG  - S C R I P T S    /-/-/-/-/-/-/ #
############################################################
# AzDGDatingMedium        Version 1.9.3                    #
# Written by              AzDG (support@azdg.com)          #
# Created 24/10/02        Last Modified 22/03/06           #
# Scripts Home:           http://www.azdg.com              #
############################################################
# File name               login.php                        #
# File purpose            Login users to members area      #
# File created by         AzDG <support@azdg.com>          #
############################################################
include_once 'include/config.inc.php';
include_once 'include/options.inc.php';
include_once 'include/security.inc.php';
include_once 'include/functions.inc.php';
include_once 'templates/'.C_TEMP.'/config.php';

if(!isset($p)) $p='';
if ($p == "s") {
	if(C_VERIFY_IMAGE_LOGIN) {
		$verifyimage = cb($verifyimage);
		if(strtoupper($verifyimage) != strtoupper(@$_SESSION['vc']))
		{
			include_once C_PATH.'/header.php';
			printm($w[497]);
		}
	}
	@MakeExit();
	$inquiry='';$usr='';

	if(isset($id)) $id=trim($id);
	switch (C_ID) {
		case '0':
		if (!ereg("^[".C_LOGIN_CHARS."]{3,16}$", $id) || empty($id)) {
			include_once C_PATH.'/header.php';
			printm($w[266]);
		}
		$inquiry=" t1.username='".cb($id)."'";
		$usr="t1.username,";
		break;
		case '2':
		if (c_email($id) == 0) {
			include_once C_PATH.'/header.php';
			printm($w[11]);
		}
		$inquiry=" t3.email='".cbmail($id)."'";
		break;
		default: // default by ID
		if (!is_numeric($id) || empty($id)) {
			include_once C_PATH.'/header.php';
			printm($w[185]);
		}
		$inquiry=" t1.id='".$id."'";
		break;
	}
	$tmp=mysql_query("SELECT t1.*, t2.*, ".$usr."t3.password, t3.wantpriv FROM ".C_MYSQL_MEMBERS_MAIN." as t1, ".C_MYSQL_MEMBERS_EXT." as t2, ".C_MYSQL_MEMBERS_SEC." as t3 WHERE".$inquiry." AND t1.id = t3.id AND t1.id = t2.id LIMIT 1");
	$count=mysql_num_rows($tmp);
	if($count == '0') {
		include_once C_PATH.'/header.php';
		printm($w[186]);
	}

	while($i=mysql_fetch_array($tmp)) {

		if($i['status'] < 7){
			include_once C_PATH.'/header.php';
			switch($i['status']) {
				case '0':
				printm($w[499]);
				break;
				case '1':
				printm($w[500]);
				break;
				case '2':
				printm($w[501]);
				break;
				case '3':
				printm($w[502]);
				break;
				case '4':
				printm($w[503]);
				break;
				default:
				printm($w[504]);
				break;
			}
		}


		if($password == $i['password'])
		{
			if(!isset($i['username'])) $i['username']='';
			$arr1=array($i['fname'],$i['lname'],$i['birthday'],$i['purposes'],$i['orientation'],$i['bodytype'],$i['country'],$i['url'],$i['icq'],$i['aim'],$i['phone'],$i['state'],$i['zip'],$i['city'],$i['address'],$i['marstat'],$i['child'],$i['height'],$i['weight'],$i['hcolor'],$i['ecolor'],$i['etnicity'],$i['religion'],$i['smoke'],$i['drink'],$i['education'],$i['languages'],$i['mylang'],$i['job'],$i['hobby'],$i['interests']);
			$arr2=array($i['descr'],$i['sgender'],$i['scountry'],$i['smarstat'],$i['schild'],$i['shcolor'],$i['secolor'],$i['ssmoke'],$i['sdrink'],$i['seducation'],$i['setnicity'],$i['sreligion'],$i['files'],$i['audio'],$i['hdyfu']);
			$notices=CheckNotices($arr1,$arr2);
			define('ID',$i['id']);
			MakeLogin($i['id'], $i['username'], $i['fname'], $i['lname'], $i['gender'], $i['req'], $i['points'], $i['hide'],$notices);
		}
		else
		{
			unset($s);unset($m);unset($g);unset($o);
			include_once C_PATH.'/header.php';
			printm($w[186]);
		}
	}

	$gturl = array('LANGUAGE'=>LANGUAGE,'URL'=>C_URL,'ID'=>ID);
	if(C_LOGIN_URL == '') $goto = (isset($goto) && !empty($goto)) ? $goto : C_URL.'/members/index.php?l='.$l.'&a=v';
	else $goto = (isset($goto) && !empty($goto)) ? $goto : template(C_LOGIN_URL,$gturl);

	GoToURL(urldecode(cb($goto)));
}
else {
	include_once C_PATH.'/header.php';
	if (C_VERIFY_IMAGE_LOGIN)
	{
		define('VERIFY_ALLOW', '1');
		define('VERIFY_ERROR', $w[497]);
	}
	else
	{
		define('VERIFY_ALLOW', '0');
		define('VERIFY_ERROR', '');
	}

	define('VERIFICATION', $w[498]);
	define('LOGIN_NAME',login(C_ID));
	define('PASSWORD',$w[54]);
	define('ENTER',$w[263]);
	define('FORGOT_PASSWORD',$w[173]);
	$goto = (isset($goto)) ? $goto : '';
	define('GOTO',cb($goto));

	include_once C_PATH.'/templates/'.C_TEMP.'/login.php';
	include_once C_PATH.'/footer.php';
}
?>