Beispiel #1
0
 public function index()
 {
     $type = Param::get('type', self::TYPE_THREAD);
     $query = trim_collapse(Param::get('query'));
     $page = Param::get('page', 1);
     $pagination = new SimplePagination($page, self::RESULTS_PERPAGE);
     if (!$query) {
         redirect(APP_URL);
     }
     $results = new stdClass();
     switch ($type) {
         case self::TYPE_THREAD:
             $results = Thread::search($query, $pagination->start_index - 1, $pagination->count + 1);
             // Get other info for each thread
             foreach ($results->result as $thread) {
                 $thread->creator = User::getByID($thread->user_id);
                 $thread->category = Category::getName($thread->category_id);
                 $thread->replies_count = Comment::countAll($thread->id);
             }
             break;
         case self::TYPE_COMMENT:
             $results = Comment::search($query, $pagination->start_index - 1, $pagination->count + 1);
             break;
         case self::TYPE_USER:
             $results = User::search($query, $pagination->start_index - 1, $pagination->count + 1);
             break;
         default:
             throw new PageNotFoundException();
             break;
     }
     $pagination->checkLastPage($results->result);
     $pages = ceil($results->total_result / self::RESULTS_PERPAGE);
     $title = "Search: '{$query}'";
     $this->set(get_defined_vars());
 }
Beispiel #2
0
 function findOne($f3)
 {
     $users = new User();
     $result = $users->getByID($f3->get('PARAMS.id'));
     if ($users->error) {
         $this->httpResponse($users->error[code], $users->error);
     } else {
         $this->httpResponse("200", $result);
     }
 }
 public static function respond($responseID, $data = array())
 {
     if (static::$responseMode == 'rss') {
         static::$responseMode = 'xml';
         if (static::$browseConditions['AuthorID']) {
             $User = User::getByID(static::$browseConditions['AuthorID']);
             $data['Author'] = $User;
             $data['Link'] = 'http://' . $_SERVER['HTTP_HOST'] . '/people/' . $User->Username;
         }
         return parent::respond('rss', $data);
     } else {
         return parent::respond($responseID, $data);
     }
 }
Beispiel #4
0
	public function __get($var)
	{
		if( $var == 'fname' || $var == 'lname' )
		{
			$usr = User::getByID($this->userid);
			return $usr->$var;
		}
		elseif( $var == 'tables' )
		{
			return Table::getByServer($this->serverid);
		}
		else
		{
			return $this->$var;
		}
	}
	public static function validate($identity, $password)
	{
		global $db;
		
		$identSQL = "SELECT salt FROM authenticate WHERE identity=?";
		$values = array($identity);
		$res = $db->qwv($identSQL, $values);
		
		$saltPass = hash('whirlpool', $res[0]['salt'].$password);
		$authSQL = "SELECT * FROM authenticate WHERE identity=? AND password=?";
		$values = array($identity, $saltPass);
		$res = $db->qwv($authSQL, $values);
		
		if( count($res) != 1 )
		{
			return false;
		}
		else
		{
			return User::getByID($res[0]['userid']);
		}
	}
Beispiel #6
0
 public function index()
 {
     $page = Param::get('page', 1);
     $filter = Param::get('filter');
     // pagination
     $pagination = new SimplePagination($page, self::THREADS_PERPAGE);
     $threads = Thread::getAll($pagination->start_index - 1, $pagination->count + 1, $filter);
     $pagination->checkLastPage($threads);
     $total = Thread::countAll($filter);
     $pages = ceil($total / self::THREADS_PERPAGE);
     // Get other info for each thread
     foreach ($threads as $thread) {
         $thread->creator = User::getByID($thread->user_id);
         $thread->category = Category::getName($thread->category_id);
         $thread->replies_count = Comment::countAll($thread->id);
     }
     // get other variables needed by the view
     $title = 'All Threads';
     $auth_user = User::getAuthenticated();
     $categories = Category::getAll();
     $trending = Thread::getTrending(self::TRENDING_LIMIT);
     $this->set(get_defined_vars());
 }
Beispiel #7
0
	$includePath = implode( PATH_SEPARATOR . $home, $paths );
	set_include_path( get_include_path() . PATH_SEPARATOR . $includePath );

	require_once('RedirectBrowserException.php');
	require_once('User.php');
	require_once('Session.php');
	require_once('Quick_Login.php');
	setSession(0, '/');

	$code = isset($_GET['code']) ? $_GET['code'] : null;

	if( $code ){
		$ql = Quick_Login::getByHash($code);
		if( $ql ){
			$user = User::getByID($ql->userid);
			$user->disabled = 0;
			$user->save();

			setSessionVar('active', true);
			setSessionVar('roleid', $user->authentication->role->roleid);
			setSessionVar('userid', $user->userid);

			$ql->used = 1;
			$ql->save();

			throw new RedirectBrowserException("/home.php?code=0");
		}
		else{
			throw new RedirectBrowserException('/index.php?code=9');
		}
Beispiel #8
0
<?php

if (system\Helper::arcIsAjaxRequest()) {
    $user = User::getByID($_POST["id"]);
    $data = "";
    foreach ($user->getGroups() as $group) {
        $data .= "<li class=\"list-group-item\"><a class=\"btn btn-danger btn-xs\" onclick=\"removeFromGroupBtn('{$group->name}')\"><i class=\"fa fa-close\"></i></a> {$group->name}</li>";
    }
    $companies = $user->getCompanies();
    $company = "";
    foreach ($companies as $comp) {
        $company .= "<li class=\"list-group-item\"><a class=\"btn btn-danger btn-xs\" onclick=\"removeCompanyUser({$comp->id})\"><i class=\"fa fa-close\"></i></a> {$comp->name}</li>";
    }
    system\Helper::arcReturnJSON(["firstname" => $user->firstname, "lastname" => $user->lastname, "email" => $user->email, "group" => $data, "enabled" => boolval($user->enabled), "company" => $company]);
}
Beispiel #9
0
 /**
  * Send e-mail notifications to local @-reply targets.
  *
  * Replies must already have been saved; this is expected to be run
  * from the distrib queue handler.
  */
 function sendReplyNotifications()
 {
     // Don't send reply notifications for repeats
     if ($this->isRepeat()) {
         return array();
     }
     $recipientIds = $this->getReplies();
     if (Event::handle('StartNotifyMentioned', array($this, &$recipientIds))) {
         require_once INSTALLDIR . '/lib/mail.php';
         foreach ($recipientIds as $recipientId) {
             try {
                 $user = User::getByID($recipientId);
                 mail_notify_attn($user, $this);
             } catch (NoResultException $e) {
                 // No such user
             }
         }
         Event::handle('EndNotifyMentioned', array($this, $recipientIds));
     }
 }
Beispiel #10
0
		
	}
	
	if( !$tmpl->item )
	{
		if( $tmpl->code == -1 && $tmpl->action == null )
		{
			$tmpl->code = 0;
		}
		unset($tmpl->item);
	}
	else
	{
		$tmpl->breadcrumb = new Breadcrumb('item', $tmpl->item->itemid);
		View::add($_SESSION['userid'], $tmpl->item->itemid);
		$usr = User::getByID($_SESSION['userid']);
		$tmp = array_slice($usr->Predict->recommend($tmpl->item), 0, 6);
		$tmpl->recommendations = array();
		foreach( $tmp as $rec )
		{
			array_push($tmpl->recommendations, Item::getByID($rec['itemid']));
		}
	}
	
	switch( $tmpl->code )
	{
		case 0:
			$tmpl->message = "Could not find item.";
			$tmpl->css = "error";
			break;
		case 10:
	$self = User::getByID($_SESSION['userid']);
	$uid = isset($_GET['uid']) ? $_GET['uid'] : null;
	$tb = isset($_GET['tb']) ? $_GET['tb'] : null;

	//determine return script
	switch( $tb ){
		case 'u':
			$return = 'users';
			break;
		default:
			$return = 'home';
			break;
	}

	if( $uid ){
		$user = User::getByID($uid);
	}
	else{
		$user = false;
	}

	if( $self == $user || $_SESSION['roleid'] < 3 ){
		if( $user->authentication->disabled ){
			if( enable($user->userid) ){
				header('Location: /' . $return . '.php?code=6');
			}
			else{
				header('Location: /' . $return . '.php?code=8');
			}
		}
		else{
	public function __get($var){
		if( strtolower($var) == 'role' ){
			return Role::getByID($this->roleid);
		}
		elseif( strtolower($var) == 'user' ){
			return User::getByID($this->userid);
		}
		else{
			return $this->$var;
		}
	}
Beispiel #13
0
	public static function deleteByID($userid){
		$base = new Base();
		
		//save everything in case we need to put them back in.
		$contact = Contact::toArray(Contact::getByUserID($userid));
		$auth = Authentication::toArray(Authentication::getByUserID($userid));
		
		//get the user object
		$user = User::getByID($userid);
		
		//Delete user
		$sql = "DELETE FROM users WHERE userid=?";
		$values = array($userid);
		$base->db->qwv($sql, $values);
		
		if( $base->db->stat() ){
			return $base->db->stat();
		}
		else{
			foreach( $contact as $con ){
				$con->contactid = null;
				$con->save();
			}
			
			$auth->authenticationid = null;
			$auth->save();
			
			return false;
		}
	}
Beispiel #14
0
	public function __get($var){
		if( strtolower($var) == 'user' ){
			return User::getByID($this->userid);
		}
		return $this->$var;
	}
Beispiel #15
0
	$includePath = implode( PATH_SEPARATOR . $home, $paths );
	set_include_path( get_include_path() . PATH_SEPARATOR . $includePath );

	require_once('RedirectBrowserException.php');
	require_once('Authentication.php');
	require_once('User.php');
	require_once('Session.php');
	setSession(0, '/');

	if( !$_SESSION['active'] ){
		header('Location: /index.php?code=2');
	}

	$userid = isset($_GET['uid']) ? $_GET['uid'] : $_SESSION['userid'];
	$self = User::getByID($_SESSION['userid']);
	$attempt = User::getByID($userid);

	if( $userid != $_SESSION['userid'] && $_SESSION['roleid'] == 3 ){
		header('Location: /index.php?code=2');
	}

	if( $userid != $_SESSION['userid'] ){
		$addon = "&uid=" . $userid;
	}

	$cont = $attempt->contact;
	$auth = $attempt->authentication;

	$data['fname'] = isset($_POST['fname']) ? $_POST['fname'] : null;
	$data['lname'] = isset($_POST['lname']) ? $_POST['lname'] : null;
	$data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : null;
Beispiel #16
0
	public function __get($var)
	{
		if( $var == 'table' )
		{
			return Table::getByID($this->tableid);
		}
		elseif( $var == 'user' )
		{
			return User::getByID($this->userid);
		}
		elseif( $var == 'status' )
		{
			return Status::getByID($this->statusid);
		}
		elseif( $var == 'items' )
		{
			return Order_Item::getByOrder($this->orderid);
		}
		else
		{
			return $this->$var;
		}
	}
Beispiel #17
0
		public function generate(){
			$tmpl = new Template();

			$tmpl->active = $active = isset($_SESSION['active']);
			$rp = 1;

			if( $active ){
				$tmpl->user = User::getByID($_SESSION['userid']);

				switch( strtolower($tmpl->user->gender) ){
					case 'm':
						$tmpl->icon = 'user';
						break;
					case 'f':
						$tmpl->icon = 'user-female';
						break;
					default:
						$tmpl->icon = 'user-silhouette';
						break;
				}

				$rp = $user->authentication->resetPassword;
			}

			$css = $tmpl->build('header.css');
			$html = $tmpl->build('header.html');
			$js = $tmpl->build('header.js');

			/*
			 * force SSL
			 *
			 * if($_SERVER["HTTPS"] != "on")
			 * {
			 * 	header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
			 * 	exit();
			 * }
			 *
			 * /force SSL
			 */

			$uri = $_SERVER['REQUEST_URI'];
			$script = preg_replace('#[/\\\]#', DIRECTORY_SEPARATOR, $_SERVER['SCRIPT_NAME']);

			if( $rp && $active ){
				if( $uri != $this->root . 'account.php?a=login&code=5' ){
					header('Location: account.php?a=login&code=5');
				}
			}
			else{
				if( $script != $this->root . 'errors.php' ){
					if( $script != $this->root . 'index.php' && !$active ){
						header('Location: index.php?code=2');
					}
					elseif( $script == $this->root . 'index.php' && $active ){
						header('Location: home.php');
					}
					elseif( $script == $this->root . 'index.php' && !$active ){
						//allow to go to login or error handler page
					}
				}
			}

			$content = array(
								'html' => $html,
								'css' => array(	'code' => $css,
												'link' => 'header'),
								'js' => array(	'code' => $js,
												'link' => 'header')
							);
			return $content;
		}