/** * This object is injected via DI. * The depending object needs a version of the config. * We fetch it from Clansuite_CMS. */ public function __construct() { // if empty get from Clansuite_CMS if (empty($this->config)) { $this->config = \Clansuite\CMS::getClansuiteConfig(); } }
public function __construct() { $this->config = \Clansuite\CMS::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']) === true) { $_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']['backendend_theme'] = 'admin'; /** * Permissions for Guests */ $_SESSION['user']['group'] = 1; // @todo hardcoded for now $_SESSION['user']['role'] = 3; #$_SESSION['user']['rights'] = Koch_ACL::createRightSession( $_SESSION['user']['role'] ); #Koch_Debug::printR($_SESSION); #Koch_Debug::firebug($_SESSION); }
/** * Get the dependency injector * * @return Returns a static reference to the Dependency Injector */ public static function getInjector() { return \Clansuite\CMS::getInjector(); }
unset($REQUIRED_PHP_VERSION); // well this should be defined in PHP.ini.. fallback, if you are lazy. date_default_timezone_set('Europe/Berlin'); $paths = array(realpath(dirname(__DIR__) . '/framework'), realpath(dirname(__DIR__) . '/application'), realpath(dirname(__DIR__)), realpath(__DIR__), realpath(__DIR__ . '/unittests')); #var_dump($paths); // attach original include paths set_include_path(implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR . get_include_path()); unset($paths); // needed if, run from CLI if (empty($_SERVER['SERVER_NAME'])) { $_SERVER['SERVER_NAME'] = gethostname(); } // acquire clansuite path constants include dirname(__DIR__) . '/application/bootstrap.php'; \Clansuite\CMS::define_ConstantsAndPaths(); \Clansuite\CMS::initialize_Loader(); \Koch\Localization\Utf8::initialize(); /** * Constants * * Constants must be defined, after initialize_paths(), * because of the automatic apc constants cache in * define_ConstantsAndPaths(). */ define('REWRITE_ENGINE_ON', 1); define('TESTSUBJECT_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR); // /../tests (trunk) /** * We might need some debug utils, * when we are not in CLI mode. */
/** * This flushes the headers and bodydata to the client. */ public static function sendResponse() { // save session before exit if ((bool) session_id()) { session_write_close(); } // activateOutputCompression when not in debugging mode if (XDEBUG === false and DEBUG === false) { Koch_ResponseEncode::start_outputbuffering('7'); } // Send the status line self::addHeader('HTTP/1.1', self::$statusCode . ' ' . self::getStatusCodeDescription(self::$statusCode)); // Set X-Powered-By Header to Clansuite Signature self::addHeader('X-Powered-By', '[ Clansuite - just an eSport CMS ][ Version : ' . CLANSUITE_VERSION . ' ][ http://clansuite.com ]'); // Suppress Framesets self::addHeader('X-Frame-Options', 'deny'); // not SAMEORIGIN // Send our Content-Type with UTF-8 encoding self::addHeader('Content-Type', self::getContentType() . '; charset=UTF-8'); // Send user specificed headers from self::$headers array if (false === headers_sent()) { foreach (self::$headers as $name => $value) { $header = $name . ': ' . $value; $header = str_replace(array("\n", "\r"), '', $header); // header injection header($header, false); } } // make it possible to attach HTML content to the body directly before flushing the response \Clansuite\CMS::triggerEvent('onBeforeResponse', array('content' => self::$content)); // Finally echo the response body echo self::getContent(); // Flush Compressed Buffer if (XDEBUG === false and DEBUG === false) { \Koch\Mvc\ResponseEncode::end_outputbuffering(); // send response and do some more php processing afterwards if (is_callable('fastcgi_finish_request') === true) { fastcgi_finish_request(); } } // OK, Reset -> Package delivered! Return to Base! self::clearHeaders(); }
/** * 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 boolean */ public function session_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\CMS::getEntityManager(); $query = $em->createQuery('DELETE \\Entities\\Session s WHERE s.session_name = :name AND s.session_starttime < :time'); $query->setParameters(array('name' => self::SESSION_NAME, 'time' => (int) $expire_time)); $query->execute(); return true; }
/** * Clansuite - just an eSports CMS * Jens-André Koch © 2005 - onwards * http://www.clansuite.com/ * * _\|/_ * (o o) +-----oOO-{_}-OOo------------------------------------------------------------------+ | | | LICENSE | | | | This program is free software; you can redistribute it and/or modify | | it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 2 of the License, or | | (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU Lesser General Public | | License along with this program. If not, please visit the Free | | Software Foundation website at <http://www.gnu.org/licenses/>. | | | +----------------------------------------------------------------------------------+ */ require 'application/bootstrap.php'; \Clansuite\CMS::run();