public static function login_user($username, $password) {
		$mgr = self::instance();
		$osimo = Osimo::instance();
		
		if(strlen($username)<3||strlen($username)>24||preg_match('/[^\w]/', $username)){
			throw new OsimoException("invalid_username", "The username entered is invalid, please try again.");
		}
		
		if(strlen($password) < 3) {
			throw new OsimoException("invalid_password", "The password entered is invalid, please try again.");
		}
		
		$password = self::hash_password($password);
		
		$user = get('db')->
			select('id,password')->
			from('users')->
			where('username=%s',$username,$password)->
			row();
		
		if($user) {
			if($user['password'] == $password) {
				self::set_logged_in_user(new OsimoUser($user['id']));
			}
			else {
				throw new OsimoException("wrong_password", "The password entered is incorrect, please try again.");
			}
		} else {
			throw new OsimoException("user_not_found", "The username entered could not be found.");
		}
	}
예제 #2
0
	'db_user'=>$dbUser,
	'db_pass'=>$dbPass,
	'db_name'=>$dbName
);

/* Set cache options */
if(CACHE_TYPE=='memcache'){
	$cacheOptions = array(
		'prefix'=>$memcachePrefix,
		'cache_addr'=>$memcacheAddr,
		'cache_port'=>$memcachePort,
		'debug'=>true
	);
	
	$session_save_path = "tcp://{$memcacheAddr[0]}:$memcachePort?persistent=1&weight=2&timeout=2&retry_interval=10,  ,tcp://{$memcacheAddr[0]}:$memcachePort  ";
	ini_set('session.save_handler', 'memcache');
	ini_set('session.save_path', $session_save_path);
}
else{
	$cacheOptions = array(
		'enabled'=>false
	);
}

session_start();

$osimo = Osimo::instance();
$osimo->init($config);

set_exception_handler(array("OsimoDebug", "exception_handler"));
?>