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.");
		}
	}
 /**
  * Returns the singleton instance of the Osimo object.  
  * If it hasn't been instantiated yet, it is first created 
  * then returned.
  */
 public static function instance()
 {
     if (is_null(self::$INSTANCE)) {
         self::$INSTANCE = new Osimo();
     }
     return self::$INSTANCE;
 }
예제 #3
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"));
?>
	public function load_post_list($args=false,$page=false){
		if(!$args){
			if(get('theme')->is_thread()){
				$args = 'thread='.get('osimo')->GET['id'];
			}
			else{
				get('debug')->error("OsimoData: unable to automatically determine parameter",__LINE__,__FUNCTION__,__FILE__,true);
			}
		}

		$allowed = array(
			'thread'=>'numeric'
		);
		
		$args = Osimo::validateOQLArgs($args,$allowed,true);

		isset(get('config')->post_num_per_page) ? $num = get('config')->post_num_per_page : $num = 10;
		if(!$page){
			isset(get('osimo')->GET['page']) ? $page = get('osimo')->GET['page'] : $page = 1;
		}
		
		$limit = get('osimo')->getPageLimits($page,$num);
		$result = get('db')->select('*')->from('posts')->where(implode(' AND ',$args))->order_by('id','ASC')->limit($limit['start'],$limit['num'])->rows();
		if($result){
			foreach($result as $data){
				$this->post_tree[$data['id']] = $data;
			}
			
			$result = get('db')->select('*')->from('threads')->where('id=%d',get('osimo')->GET['id'])->limit(1)->row();
			if($result){
				$this->the_thread = get('osimo')->thread($result);
			}
		}
		elseif(get('theme')->page_type != 'index'){
			header('Location: index.php'); exit;
		}
	}