コード例 #1
0
ファイル: SessionManager.php プロジェクト: sintattica/atk
 /**
  * Initializes the sessionmanager.
  *
  * @return bool
  */
 public function start()
 {
     global $ATK_VARS;
     if (php_sapi_name() == 'cli') {
         return false;
         // command-line
     }
     if (isset($_REQUEST['atklevel'])) {
         $this->atklevel = trim($_REQUEST['atklevel']);
     }
     if (isset($_REQUEST['atkprevlevel'])) {
         $this->atkprevlevel = trim($_REQUEST['atkprevlevel']);
     }
     if (isset($_REQUEST['atkstackid'])) {
         $this->atkstackid = trim($_REQUEST['atkstackid']);
     }
     //session init
     $cookie_params = session_get_cookie_params();
     $cookiepath = Config::getGlobal('cookie_path');
     $cookiedomain = Config::getGlobal('cookiedomain') != '' ? Config::getGlobal('cookiedomain') : null;
     session_set_cookie_params($cookie_params['lifetime'], $cookiepath, $cookiedomain);
     // set cache expire (if function exists, or show upgrade hint if not)
     if (function_exists('session_cache_expire')) {
         session_cache_expire(Config::getGlobal('session_cache_expire'));
     } else {
         Tools::atkdebug('session_cache_expire function does not exist, please upgrade to the latest stable php version (at least 4.2.x)', Tools::DEBUG_WARNING);
     }
     // set the cache limiter (used for caching)
     session_cache_limiter(Config::getGlobal('session_cache_limiter'));
     // If somehow the sessionid is unclean (searchengine bots have been known to mangle sessionids)
     // we don't have a session...
     if (self::isValidSessionId()) {
         $sessionname = Config::getGlobal('session_name');
         if (!$sessionname) {
             $sessionname = Config::getGlobal('identifier');
         }
         session_name($sessionname);
         session_start();
     } else {
         Tools::atkwarning('Not a valid session!');
         return false;
     }
     //decode data
     Tools::atkDataDecode($_REQUEST);
     $ATK_VARS = array_merge($_GET, $_POST);
     Tools::atkDataDecode($ATK_VARS);
     if (array_key_exists('atkfieldprefix', $ATK_VARS) && $ATK_VARS['atkfieldprefix'] != '') {
         $ATK_VARS = $ATK_VARS[$ATK_VARS['atkfieldprefix']];
     }
     $this->session_read($ATK_VARS);
     // Escape check
     if (isset($_REQUEST['atkescape']) && $_REQUEST['atkescape'] != '') {
         Tools::redirect(Tools::atkurldecode($_REQUEST['atkescape']));
     } else {
         if (isset($_REQUEST['atknested']) && $_REQUEST['atknested'] != '') {
             Tools::redirect($this->sessionUrl($_REQUEST['atknested'], self::SESSION_NESTED));
         } else {
             if (isset($ATK_VARS['atkback']) && $ATK_VARS['atkback'] != '') {
                 // When we go back, we go one level deeper than the level we came from.
                 Tools::redirect($this->sessionUrl(Config::getGlobal('dispatcher') . '?atklevel=' . ($this->atkprevlevel - 1)));
             }
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Selector.php プロジェクト: sintattica/atk
 /**
  * Transform raw database row to node compatible row.
  *
  * @param array $row raw database row
  * @param Query $query query object
  * @param array $attrsByLoadType attributes by load type
  *
  * @return array node compatible row
  */
 protected function _transformRow($row, Query $query, array $attrsByLoadType)
 {
     $query->deAlias($row);
     Tools::atkDataDecode($row);
     $result = [];
     foreach ($attrsByLoadType[Attribute::ADDTOQUERY] as $attr) {
         $result[$attr->fieldName()] = $attr->db2value($row);
     }
     if (!$this->m_ignorePrimaryKey) {
         $result['atkprimkey'] = $this->_getNode()->primaryKey($result);
     }
     foreach ($attrsByLoadType[Attribute::POSTLOAD] as $attr) {
         $result[$attr->fieldName()] = $attr->load($this->_getDb(), $result, $this->m_mode);
     }
     return $result;
 }
コード例 #3
0
ファイル: DataGrid.php プロジェクト: sintattica/atk
 /**
  * It's allowed to use the request variables atkstartat, atklimit, atksearch,
  * atksmartsearch, atksearchmode, atkorderby, atkindex and atkcolcmd directly. If they
  * are used directly we need to store their values in the datagrid session
  * entry and override existing values if needed.
  */
 protected function registerGlobalOverrides()
 {
     if ($this->isEmbedded()) {
         return;
     }
     $request = array_merge($_GET, $_POST);
     Tools::atkDataDecode($request);
     $vars = array('atkstartat', 'atklimit', 'atksearch', 'atksmartsearch', 'atksearchmode', 'atkorderby', 'atkindex', 'atkcolcmd');
     $sessions =& $GLOBALS['ATK_VARS']['atkdg'];
     if ($sessions == null) {
         $sessions = [];
     }
     foreach ($vars as $var) {
         if (isset($request[$var])) {
             $sessions[$this->getName()][$var] = $request[$var];
         } else {
             if (isset($request['atkdg'][$this->getName()][$var])) {
                 $sessions[$this->getName()][$var] = $request['atkdg'][$this->getName()][$var];
             }
         }
     }
     $this->getNode()->m_postvars['atkdg'] = $sessions;
     if ($this->m_useSession) {
         $this->m_sessionMgr->pageVar('atkdg', $sessions);
     }
 }