Пример #1
0
 /**
  * Function will determine which language should be used
  *
  * Allows comparing available languages with client languages, will use fallback if necessary.
  *
  * @return string Returns country code of language to use.
  */
 static function IdentifyLanguage()
 {
     self::$languages = Cache::Read('languages');
     if (!self::$languages) {
         if (Database::Fetch(LWC::QUERY_LANGUAGES)) {
             foreach (Database::Data() as $language) {
                 self::$languages[] = $language['code'];
             }
             Cache::Write('languages', self::$languages);
         } else {
             self::$languages = array(LANGUAGE);
         }
     }
     if (isset($_GET['lang'])) {
         if (in_array($_GET['lang'], self::$languages)) {
             cookie('language', $_GET['lang']);
             return $_GET['lang'];
         }
     } else {
         if (!cookieexists('language')) {
             $requested = self::ParseLanguages();
             foreach ($requested as $language) {
                 if (in_array($language, self::$languages)) {
                     cookie('language', $language);
                     return $language;
                 }
             }
         } else {
             if (in_array(cookie('language'), self::$languages)) {
                 return cookie('language');
             }
         }
     }
     return LANGUAGE;
 }
Пример #2
0
if (METHOD != 'CLI') {
    session_name('session');
    // Prevent exposing PHP by renaming its session
    session_set_save_handler(new SessionHandler(), true);
    // Set the session handler to a Lightwork session handler
    session_set_cookie_params(2147483647 - time(), WEB_ROOT, DOMAIN, COOKIE_SSL, true);
    // Set cookie parameters for sessions
    ini_set('session.gc_maxlifetime', SESSION_TIMEOUT);
    // Set the session timeout
    ini_set('session.hash_function', 'sha512');
    // Increase session security by using a longer hash (SHA-512 vs MD5)
    session_start();
    // Start this session
}
if (METHOD != 'CLI') {
    if (cookieexists('session')) {
        // Check if user already has a session
        define('FIRSTVISIT', false);
    } else {
        define('FIRSTVISIT', true);
    }
    // Otherwise this is a new visitor
    if (sessionexists('loggedin')) {
        define('LOGGEDIN', true);
        Lightwork::Log('User is logged in.', Lightwork::LOG_DEBUG);
    } else {
        define('LOGGEDIN', false);
        Lightwork::Log('User is not logged in.', Lightwork::LOG_DEBUG);
    }
}
if (!MULTILANGUAGE) {