/**
  * lazy loads the person's go object
  */
 public function _load_go()
 {
     require_once 'go.class.php';
     $go = new go($this->person->wp_id);
     $this->person->go = $go;
     $this->person->go_states = $go->getStates();
 }
Exemplo n.º 2
0
Arquivo: go.php Projeto: Borvik/Munla
 /**
  * Attempts to redirect the user to the last page they
  * were on. If there is no history, then processing continues.
  * 
  * @return bool FALSE on failure.
  */
 public static function back()
 {
     if (is::existset(munla::$session, 'lastpage') && strlen(munla::$session['lastpage']) > 0) {
         return go::url(munla::$session['lastpage']);
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * __construct
  *
  * Initial object setup.
  *
  * @param	string|boolean $uid_or_auto indicates how cache and template directories should be set. uid specifies a unique id to build names, true generates paths automatically. leave blank or false to specify these paths yourself.
  */
 function __construct($params = null, $fluid = false, $uid_or_auto = true)
 {
     static::$GLOBAL_STYLE = PSU_BASE_DIR . '/app/core/templates';
     parent::__construct($uid_or_auto);
     if ($_SESSION['impersonate']) {
         \PSU::get('log/impersonate')->write('Impersonation' . (\PSU::isDev() ? ' on dev server' : '') . ': accessing ' . $_SERVER['REQUEST_URI'] . ($_SERVER['HTTP_REFERER'] ? ' via ' . $_SERVER['HTTP_REFERER'] : ''), $_SESSION['username'], serialize($_REQUEST));
     }
     //end if
     if ($GLOBALS['TEMPLATES']) {
         $this->template_dir = $GLOBALS['TEMPLATES'];
     }
     if (!isset($GLOBALS['USE_APPLICATION_STYLE'])) {
         $GLOBALS['USE_APPLICATION_STYLE'] = true;
     }
     if ($params) {
         parse_str($params, $params);
         $key = key($params);
         if (!$params[$key]) {
             $params['page_title'] = str_replace('_', ' ', $key);
         }
         //end if
     }
     //end if
     $this->page_title = $params['page_title'];
     $this->app_title = $params['app_title'] ? $params['app_title'] : ($GLOBALS['TITLE'] ? $GLOBALS['TITLE'] : 'PSU Webapp');
     $this->fluid = $params['fluid'] ? $params['fluid'] : $fluid;
     // register any custom functions
     $this->register_block('box', array($this, 'psu_box'));
     $this->register_block('col', array($this, 'psu_col'));
     $this->register_block('message', array($this, 'psu_message'));
     $this->register_modifier('yesno', array($this, 'yesno'));
     $this->register_modifier('pluralize', array($this, 'pluralize'));
     $this->register_modifier('query_string', 'http_build_query');
     $this->register_function('myrel_access', array($this, 'myrel_access'));
     $this->register_function('myrel_list', array($this, 'myrel_list'));
     $this->register_function('randomid', array($this, 'randomid'));
     $this->register_function('nav', array($this, 'nav'));
     $this->register_function('navselect', array($this, 'navselect'));
     $this->register_modifier('bool2str', array($this, 'bool2str'));
     $this->content_classes = array(\PSU::isDev() ? 'webapp-dev' : 'webapp-prod');
     $this->body_style_classes = array();
     $this->body_style_classes[] = strtolower('month-' . date('F'));
     $this->body_style_classes[] = strtolower('weekday-' . date('l'));
     $this->body_style_classes[] = 'week-' . date('W');
     $this->body_style_classes[] = 'day-of-year-' . date('z');
     $this->body_style_classes[] = 'day-of-month-' . date('j');
     $this->body_style_classes[] = 'hour-' . date('H');
     $this->body_style_classes[] = 'minute-' . date('i');
     if ($_SESSION['username']) {
         $this->body_style_classes[] = 'user-' . $_SESSION['username'];
     }
     //end if
     if ($_SESSION['wp_id']) {
         $this->body_style_classes[] = 'user-' . $_SESSION['wp_id'];
     }
     //end if
     if ($GLOBALS['FANCY_TPL']) {
         $this->body_style_classes[] = 'extra-tag-styles';
     }
     $this->assign('facebook_api', \PSU::fbAPI());
     $this->assign('facebook_enable', $GLOBALS['FACEBOOK_ENABLE'] == true);
     $go = new \go($_SESSION['wp_id'] ? $_SESSION['wp_id'] : $_SESSION['username']);
     $hot_links = $go->cacheGetSites($_SESSION['wp_id'] || $_SESSION['username'] ? 'popular-me' : 'popular-everyone');
     if (sizeof($hot_links) < 5 && $_SESSION['username']) {
         $everyone_links = $go->cacheGetSites('popular-everyone');
         $hot_links = array_merge($hot_links, $everyone_links);
         $hot_links = array_unique($hot_links);
     }
     //end if
     $this->assign('webapp_hot_links', $hot_links);
     // cdn base url; omit trailing slash
     $this->assign('cdn', substr(\PSU::cdn(), 0, -1));
     if (\PSU::mobile() && $_COOKIE['psumobile'] != 'disable' || $_COOKIE['psumobile'] == 'force') {
         $this->mobile = true;
     }
     //end if
 }
Exemplo n.º 4
0
 /**
  * Starts the application.
  * 
  * @return void
  */
 public static function run()
 {
     self::$starttime = microtime(true);
     error_reporting(config::ERROR_LEVEL);
     if (isset(config::$session_cookie_domain)) {
         ini_set('session.cookie_domain', config::$session_cookie_domain);
     }
     if (class_exists('formHelper')) {
         formHelper::fixArrays();
     }
     if (class_exists('csrfHelper')) {
         injector::register(array('csrfHelper', 'injector'));
     }
     if (is::ssl() && isset(config::$https_domain) && !isset(config::$http_domain)) {
         if (is::existset($_GET, 'r_domain')) {
             config::$http_domain = get::fulldomain($_GET['r_domain']);
         } else {
             config::$http_domain = get::fulldomain('www');
         }
     }
     session_start();
     if (config::$isolated_subdomains) {
         // find the domain
         $domain = isset(config::$http_domain) ? config::$http_domain : get::fulldomain();
         // kill any subdomain sessions that have been transfered to another subdomain
         $existing = array_keys($_SESSION);
         foreach ($existing as $d) {
             if (!is_array($_SESSION[$d])) {
                 continue;
             }
             if (array_key_exists('kill_munla_session', $_SESSION[$d]) && $_SESSION[$d]['kill_munla_session']) {
                 unset($_SESSION[$d]);
             }
         }
         // initialize and setup the session for this subdomain
         if (!array_key_exists($domain, $_SESSION)) {
             $_SESSION[$domain] = array();
         }
         munla::$session =& $_SESSION[$domain];
     } else {
         munla::$session =& $_SESSION;
     }
     if (class_exists('singleUseArray')) {
         if (!is::existset(munla::$session, 'MUNLA_SINGLE_USE')) {
             munla::$singleUse = new singleUseArray();
         } else {
             munla::$singleUse = unserialize(munla::$session['MUNLA_SINGLE_USE']);
         }
     }
     $route = get::route();
     if (is_array($route) && $route['controller'] == 'csrf' && $route['action'] == 'keepalive' && class_exists('csrfHelper') && is::existset($route, 'params') && count($route['params']) > 0) {
         if (isset($_POST['token'])) {
             echo csrfHelper::keepAlive($route['params'][0], $_POST['token']);
         }
         exit;
     }
     if (class_exists('user') && is_subclass_of('user', 'userBase')) {
         if (!is::existset(munla::$session, 'MUNLA_USER')) {
             munla::$session['MUNLA_USER'] = new userWrapper(new user());
         }
     }
     injector::start();
     if (class_exists('app') && is_callable(array('app', 'setup'))) {
         app::setup();
     }
     if (!isset(munla::$user) && is::existset(munla::$session, 'MUNLA_USER')) {
         munla::$user =& munla::$session['MUNLA_USER'];
     }
     if (!is::ajax()) {
         $submittedForm = formHelper::process();
         if (isset($submittedForm)) {
             formHelper::process($submittedForm);
         }
     }
     if (class_exists('app') && is_callable(array('app', 'start'))) {
         $route = app::start($route);
     }
     if ($route === null) {
         $route = array('controller' => 'index', 'action' => 'index', 'params' => null);
     }
     $controller = get::controller($route['controller']);
     if (!isset($controller) && $route['controller'] != 'index') {
         //push action to params, controller to action, and set controller to index and try again.
         if ($route['action'] != 'index') {
             if (!isset($route['params'])) {
                 $route['params'] = array();
             }
             array_unshift($route['params'], $route['action']);
         }
         $route['action'] = $route['controller'];
         $route['controller'] = 'index';
         $controller = get::controller('index');
     }
     $view = null;
     if (isset($controller)) {
         $action = $controller->getAction(array($route['action'], $route['params']));
         if (isset($action)) {
             try {
                 $viewParams = call_user_func_array(array($controller, $action['action']), $action['params']);
                 //various things could happen here...
                 if (!isset($viewParams)) {
                     $viewParams = array();
                 } elseif (!is_array($viewParams)) {
                     $viewParams = array($viewParams);
                 }
                 $view = get::view($route, $controller, $viewParams);
             } catch (SSLException $e) {
                 go::ssl(!is::ssl());
             } catch (PermissionException $e) {
                 munla::$nohistory = true;
                 if (isset(munla::$user) && !munla::$user->is_logged_in() && munla::$user->getLoginView()) {
                     $view = munla::$user->getLoginView();
                 } else {
                     $view = get::view('errors/generic', 'default', array('error_msg' => $e->getMessage()));
                 }
             } catch (Exception $e) {
                 munla::$nohistory = true;
                 $view = get::view('errors/generic', 'default', array('error_msg' => $e->getMessage()));
             }
         } else {
             $view = get::view($route, $controller);
         }
     } else {
         $view = get::view($route);
     }
     if ($view != null) {
         $view->render();
     } else {
         throw new Exception('View not found!');
     }
     if (class_exists('app', false)) {
         munla::$nohistory = app::finish(munla::$nohistory);
     }
     if (munla::$nohistory === false) {
         munla::$session['lastpage'] = get::url();
     }
     if (isset(munla::$singleUse)) {
         munla::$session['MUNLA_SINGLE_USE'] = serialize(munla::$singleUse);
     }
 }