<?php 

	define('IN_HUGLO', true);
	require_once('./includes/constants.php');
	require_once(ROOT_PATH . 'includes/db.php');

	if(isset($_POST['login']) and isset($_POST['password'])) {
		require_once(ROOT_PATH . 'common.php');
		
		$login = $db->_sql_valide_value($_POST['login']);
		$password = $db->_sql_valide_value($_POST['password']);
		
		$sql = 'SELECT * FROM ' . CLIENTS_TABLE . ' WHERE clients_login = ' . $login . ' AND clients_passwd = ' . $password . 'LIMIT 1';
		$result = mysql_query($sql);

		if(mysql_num_rows($result) == 1) {
			$row = mysql_fetch_assoc($result);
			if(eregi('MSIE', $_SERVER["HTTP_USER_AGENT"])) {
				header('Location: ' . $row['clients_url']);

			} else {
				header('Location: http://' . $row['clients_login'] . ':' . $row['clients_passwd'] . '@' . substr($row['clients_url'], 7));
			}
		} else {
			header('Location: ' . BASE_PATH .'/');
		}
		
		$db->sql_close();
	}


?>