コード例 #1
0
ファイル: facebook.php プロジェクト: dgw/ThinkUp
 /**
  * Identical to the parent constructor, except that
  * we start a PHP session to store the user ID and
  * access token if during the course of execution
  * we discover them.
  *
  * @param Array $config the application configuration.
  * @see BaseFacebook::__construct in facebook.php
  */
 public function __construct($config)
 {
     if (!session_id()) {
         SessionCache::init();
     }
     parent::__construct($config);
 }
コード例 #2
0
ファイル: TestOfSessionCache.php プロジェクト: dgw/ThinkUp
 public function testVerifyDBness()
 {
     $config = Config::getInstance();
     $config->setValue('use_db_sessions', true);
     session_id(md5(time()));
     SessionCache::init();
     SessionCache::put('my_key', 'my_value2');
     $dao = DAOFactory::getDAO('SessionDAO');
     $data = $dao->read(session_id());
     $this->assertEqual('', $data);
     session_write_close();
     $data = $dao->read(session_id());
     $this->assertPattern('/my_key/', $data);
     $this->assertPattern('/my_value2/', $data);
     $this->assertNotEqual('', $data);
     // Retrieve it manually just to make sure
     $sql = "SELECT * FROM tu_sessions";
     $stmt = SessionMySQLDAO::$PDO->query($sql);
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $this->assertPattern('/my_key/', $row['data']);
     $this->assertPattern('/my_value2/', $row['data']);
 }
コード例 #3
0
 /**
  * Constructs ThinkUpController
  *
  *  Adds email address of currently logged in ThinkUp user, '' if not logged in, to view
  *  {$logged_in_user}
  *  @return ThinkUpController
  */
 public function __construct($session_started = false)
 {
     try {
         $config = Config::getInstance();
         $this->profiler_enabled = Profiler::isEnabled();
         if ($this->profiler_enabled) {
             $this->start_time = microtime(true);
         }
         if ($config->getValue('timezone')) {
             date_default_timezone_set($config->getValue('timezone'));
         }
         if (!$session_started) {
             SessionCache::init();
         }
         $this->view_mgr = new ViewManager();
         if (SessionCache::isKeySet('selected_instance_network') && SessionCache::isKeySet('selected_instance_username')) {
             $this->addToView('selected_instance_network', SessionCache::get('selected_instance_network'));
             $this->addToView('selected_instance_username', SessionCache::get('selected_instance_username'));
         }
         if ($this->isLoggedIn()) {
             $this->addToView('logged_in_user', $this->getLoggedInUser());
         }
         if ($this->isAdmin()) {
             $this->addToView('user_is_admin', true);
         }
         $THINKUP_VERSION = $config->getValue('THINKUP_VERSION');
         $this->addToView('thinkup_version', $THINKUP_VERSION);
     } catch (Exception $e) {
         Loader::definePathConstants();
         //echo 'sending this to Smarty:'.THINKUP_WEBAPP_PATH.'data/';
         $cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => THINKUP_ROOT_PATH, 'datadir_path' => THINKUP_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
         $this->view_mgr = new ViewManager($cfg_array);
     }
 }
コード例 #4
0
 /**
  * Constructs ThinkUpController
  *
  *  Adds email address of currently logged in ThinkUp user, '' if not logged in, to view
  *  {$logged_in_user}
  *  @return ThinkUpController
  */
 public function __construct($session_started = false)
 {
     try {
         $config = Config::getInstance();
         $this->profiler_enabled = Profiler::isEnabled();
         if ($this->profiler_enabled) {
             $this->start_time = microtime(true);
         }
         if ($config->getValue('timezone')) {
             date_default_timezone_set($config->getValue('timezone'));
         }
         if (!$session_started) {
             SessionCache::init();
         }
         $this->view_mgr = new ViewManager();
         if (SessionCache::isKeySet('selected_instance_network') && SessionCache::isKeySet('selected_instance_username')) {
             $this->addToView('selected_instance_network', SessionCache::get('selected_instance_network'));
             $this->addToView('selected_instance_username', SessionCache::get('selected_instance_username'));
         }
         if ($this->isLoggedIn()) {
             $this->addToView('logged_in_user', $this->getLoggedInUser());
         }
         if ($this->isAdmin()) {
             $this->addToView('user_is_admin', true);
         }
         $THINKUP_VERSION = $config->getValue('THINKUP_VERSION');
         $this->addToView('thinkup_version', $THINKUP_VERSION);
         if (Utils::isThinkUpLLC()) {
             $thinkupllc_endpoint = $config->getValue('thinkupllc_endpoint');
             $this->addToView('thinkupllc_endpoint', $thinkupllc_endpoint);
         }
         if (SessionCache::isKeySet('selected_instance_network') && SessionCache::isKeySet('selected_instance_username')) {
             $this->addToView('selected_instance_network', SessionCache::get('selected_instance_network'));
             $this->addToView('selected_instance_username', SessionCache::get('selected_instance_username'));
         }
     } catch (Exception $e) {
         Loader::definePathConstants();
         //echo 'sending this to Smarty:'.THINKUP_WEBAPP_PATH.'data/';
         $cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => THINKUP_ROOT_PATH, 'datadir_path' => THINKUP_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
         $this->view_mgr = new ViewManager($cfg_array);
         $this->setErrorTemplateState();
         $this->addToView('error_type', get_class($e));
         $disable_xss = false;
         // if we are an installer exception, don't filter XSS, we have markup, and we trust this content
         if (get_class($e) == 'InstallerException') {
             $disable_xss = true;
         }
         $this->addErrorMessage($e->getMessage(), null, $disable_xss);
     }
 }
コード例 #5
0
 /**
  * Constructs EFCController
  *
  *  Adds email address of currently logged in EFC user, '' if not logged in, to view
  *  {$logged_in_user}
  *  @return EFCController
  */
 public function __construct($session_started = false)
 {
     try {
         //$this->baseMem = memory_get_usage(true);
         $this->redis = new Redis();
         $this->redis->connect('127.0.0.1', 6379);
         $this->memcache = new Memcache();
         $this->memcache->connect('127.0.0.1', 11211);
         $config = Config::getInstance();
         $this->profiler_enabled = Profiler::isEnabled();
         if ($this->profiler_enabled) {
             $this->start_time = microtime(true);
         }
         if ($config->getValue('timezone')) {
             date_default_timezone_set($config->getValue('timezone'));
         }
         if (!$session_started) {
             SessionCache::init();
         }
         $this->view_mgr = new ViewManager();
         $this->facebook = new Facebook\Facebook(['app_id' => $config->getValue('fb_app_id'), 'app_secret' => $config->getValue('fb_app_secret'), 'default_graph_version' => 'v2.2']);
         if ($this->isLoggedIn()) {
             $this->addToView('logged_in_user', $this->getLoggedInUser());
         }
         if ($this->isSuperAdmin()) {
             $this->addToView('user_is_admin', true);
         }
         $EFC_VERSION = $config->getValue('EFC_VERSION');
         $this->addToView('EFC_VERSION', $EFC_VERSION);
         if (Utils::isEmpoddyLabs()) {
             $empoddy_endpoint = $config->getValue('empoddy_endpoint');
             $this->addToView('empoddy_endpoint', $empoddy_endpoint);
         }
         if (SessionCache::isKeySet('selected_instance_network') && SessionCache::isKeySet('selected_instance_username')) {
             $this->addToView('selected_instance_network', SessionCache::get('selected_instance_network'));
             $this->addToView('selected_instance_username', SessionCache::get('selected_instance_username'));
         }
     } catch (Exception $e) {
         Loader::definePathConstants();
         //echo 'sending this to Smarty:'.EFC_WEBAPP_PATH.'data/';
         $cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => EFC_ROOT_PATH, 'datadir_path' => EFC_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
         $this->view_mgr = new ViewManager($cfg_array);
         $this->setErrorTemplateState();
         $this->addToView('error_type', get_class($e));
         $disable_xss = false;
         // if we are an installer exception, don't filter XSS, we have markup, and we trust this content
         if (get_class($e) == 'InstallerException') {
             $disable_xss = true;
         }
         $this->addErrorMessage($e->getMessage(), null, $disable_xss);
     }
 }