예제 #1
0
 /**
  * Detect the best language according to language headers
  *
  * @return Translation
  */
 private static function user_agent_best()
 {
     $directory = new Apine\Translation\TranslationDirectory();
     $return = null;
     if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $return = $directory->get_translation(Config::get('localization', 'locale_default'))->get_language()->code;
     } else {
         $user_languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         $found_language = null;
         foreach ($user_languages as $lang) {
             $break = explode(';', $lang);
             $lang = $break[0];
             $best = $directory->is_exist_language($lang);
             if ($best) {
                 $found_language = $best;
                 break;
             }
         }
         if (isset($found_language)) {
             $return = $found_language;
         }
     }
     return $return;
 }
예제 #2
0
 /**
  * Get name of the user class to use
  * 
  * @return string
  */
 public static function get_user_class()
 {
     static $class;
     if (is_null($class)) {
         if (Apine\Application\Config::get('runtime', 'user_class')) {
             $pos_slash = strpos(Apine\Application\Config::get('runtime', 'user_class'), '/');
             $class = substr(Apine\Application\Config::get('runtime', 'user_class'), $pos_slash + 1);
             if (!is_a($class, 'Apine\\User\\User', true)) {
                 $class = 'Apine\\User\\User';
             }
         } else {
             $class = "Apine\\User\\User";
         }
     }
     return $class;
 }
예제 #3
0
 private static function generate_key()
 {
     $hash = hash('md5', rand(1, 100000) . '_' . rand(100001, 200000));
     Application\Config::set('runtime', 'encryption_key', $hash);
 }