Ejemplo n.º 1
0
 /**
  * Decrypt a string from the encryption string
  * 
  * @param string $encrypted_string
  * @return string
  */
 public static function decrypt($encrypted_string)
 {
     if (!Application\Config::get('runtime', 'encryption_key')) {
         self::generate_key();
     }
     $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
     $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
     $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, Application\Config::get('runtime', 'encryption_key'), $encrypted_string, MCRYPT_MODE_ECB, $iv);
     return $decrypted_string;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
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;
 }