Ejemplo n.º 1
0
	if (!$apassword) {
		throw new Exception('No Activation password specified');
	}
	
	if (!$password1 or $password1 != $password2) {
		throw new Exception('The new passwords you entered do not match');
	}
	
	$apassword = md5($apassword);
	$password1 = md5($password1);

	if ($filtered['activation-id']) {
		$aAccount->get($filtered['activation-id']);	
	}
	else {
		$aAccount = Activation::getByUsernamePassword($username, $apassword);
	}
	
	if (!$aAccount->id) {
		throw new Exception('That account does not exist');
	}
	
	if ($aAccount->success) {
		header('Location: index.php?e=2');
		exit;
	}
	
	// If we get this far, the account needs to be activated, 
	// and the user provided everything we need.
	$user = new User();
	$user->username = $aAccount->username;
Ejemplo n.º 2
0
	public static function
	login($username, $password) {
		$ret->id = false;
		$password = md5($password);
		$ori_username = $username;

		if (strlen($username) <= 25 and strlen($username) >= 3) {

			$username = mysql_real_escape_string($username);
			$r = mysql_query("select * from User where username LIKE \"$username\" and password =\"$password\";") or die(mysql_error());
			$ret = mysql_fetch_object($r, 'User');
			if (!$ret) {
				require_once('Activation.php');
				
				// check activations				
				$a = Activation::getByUsernamePassword($ori_username, $password);
				if ($a->id and $a->success == 0) {
					header('Location: activate.php?activation-id=' . $a->id);
					exit;
				}
				
				$ret->id = false;
			}
			return $ret;
		}
		return $ret;
	}