Example #1
0
 /**
  * Create and return an instance
  * 
  * @param string $language
  * 
  * @return PMF_String_Basic
  */
 public static function getInstance($encoding = null, $language = 'en')
 {
     if (!self::$instance) {
         self::$instance = new self();
         self::$instance->encoding = self::DEFAULT_ENCODING;
         self::$instance->language = PMF_Language::isASupportedLanguage($language) ? $language : self::DEFAULT_LANGUAGE;
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Clean up a filename: if anything goes wrong, an empty string will be returned
  *
  * @param string $filename Filename
  * 
  * @return string
  */
 private static function _basicFilenameClean($filename)
 {
     global $denyUploadExts;
     // Remove the magic quotes if enabled
     $filename = ini_get('magic_quotes_gpc') ? stripslashes($filename) : $filename;
     $path_parts = pathinfo($filename);
     // We need a filename without any path info
     if ($path_parts['basename'] !== $filename) {
         return '';
     }
     //  We need a filename with at least 1 chars plus the optional extension
     if (isset($path_parts['extension']) && $path_parts['basename'] == '.' . $path_parts['extension']) {
         return '';
     }
     if (!isset($path_parts['extension']) && PMF_String_Basic::strlen($path_parts['basename']) == 0) {
         return '';
     }
     // Deny some extensions (see inc/constants.php), if any
     if (!isset($path_parts['extension'])) {
         $path_parts['extension'] = '';
     }
     if (count($denyUploadExts) > 0) {
         if (in_array(strtolower($path_parts['extension']), $denyUploadExts)) {
             return '';
         }
     }
     // Clean the file to remove some chars depending on the server OS
     // 0. main/rfc1867.c: rfc1867_post_handler removes any char before the last occurence of \/
     // 1. Besides \/ on Windows: :*?"<>|
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $reservedChars = array(':', '*', '?', '"', '<', '>', "'", '|');
         $filename = str_replace($reservedChars, '_', $filename);
     }
     return $filename;
 }
Example #3
0
 /**
  * Check if the string is a unicode string
  * 
  * @param string $str String
  * 
  * @return boolean
  */
 public static function isUTF8($str)
 {
     return PMF_String_Basic::isUTF8($str);
 }