public function __construct() { $this->config = \Clansuite\Application::getInjector()->instantiate('Koch\\Config\\Config'); /* * Fill $_SESSION[user] with Guest-User-infos */ $_SESSION['user']['authed'] = 0; // a guest is not authed $_SESSION['user']['user_id'] = 0; // a guest has the user_id 0 $_SESSION['user']['nick'] = _('Guest'); // a guest has the nickname "Guest" $_SESSION['user']['passwordhash'] = ''; $_SESSION['user']['email'] = ''; $_SESSION['user']['disabled'] = 0; $_SESSION['user']['activated'] = 0; /* * Language for Guests * * This sets the default locale as defined by the main configuration value ([language][locale]). * The value is set as session value [user][language] for the user, * if another language was not set via the GET request (URL), * and processed in the filter (like "index.php?lang=fr"). */ if (!isset($_SESSION['user']['language_via_url']) and isset($this->config['locale']['locale'])) { $_SESSION['user']['language'] = $this->config['locale']['locale']; } /* * Theme for Guests * * Sets the Default Theme for all Guest Visitors, if not already set via a GET request. * Theme for Guest Users as defined by config['template']['frontend_theme'] */ if (empty($_SESSION['user']['frontend_theme']) and isset($this->config['template']['frontend_theme']) === true) { $_SESSION['user']['frontend_theme'] = $this->config['template']['frontend_theme']; } // @todo remove this line, when user login is reactivated $_SESSION['user']['backend_theme'] = 'admin'; /* * Permissions for Guests */ $_SESSION['user']['group'] = 1; // @todo hardcoded for now $_SESSION['user']['role'] = 3; #$_SESSION['user']['rights'] = \Koch\Permissions\Acl::fetchPermissions($_SESSION['user']['role']); #\Koch\Debug\Debug::printR($_SESSION); #\Koch\Debug\Debug::firebug($_SESSION); }
/** * Get the dependency injector. * * @return Returns a static reference to the Dependency Injector */ public static function getInjector() { return \Clansuite\Application::getInjector(); }
/** * Session Garbage Collector. * * Removes the current session, if: * a) gc probability is reached (ini_set) * b) time() is reached (DB has timestamp stored, that is time() + expiration ) * * @see session.gc_divisor 100 * @see session.gc_maxlifetime 1800 = 30*60 * @see session.gc_probability 1 * @usage execution rate 1/100 (session.gc_probability/session.gc_divisor) * * @param int session life time (mins) * * @return null|bool */ public function gc($maxlifetime = 30) { if ($maxlifetime === 0) { return; } /* * Determine expiration time of the session * * $maxlifetime is a minute time value * its fetched from $config['session']['session_expire_time'] * $sessionLifetime is in seconds */ $sessionlifetime = $maxlifetime * 60; $expire_time = time() + $sessionlifetime; $em = \Clansuite\Application::getEntityManager(); $query = $em->createQuery('DELETE \\Entity\\Session s WHERE s.session_name = :name AND s.session_starttime < :time'); $query->setParameters(['name' => self::SESSION_NAME, 'time' => (int) $expire_time]); $query->execute(); return true; }