コード例 #1
0
ファイル: Mime.php プロジェクト: ircoco/BlackCatCMS
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
コード例 #2
0
ファイル: Upload.php プロジェクト: ircoco/BlackCatCMS
 /**
  * Init or re-init all the processing variables to their default values
  *
  * This function is called in the constructor, and after each call of {@link process}
  *
  * @access private
  */
 function init()
 {
     // overiddable variables
     $this->file_new_name_body = null;
     // replace the name body
     $this->file_name_body_add = null;
     // append to the name body
     $this->file_name_body_pre = null;
     // prepend to the name body
     $this->file_new_name_ext = null;
     // replace the file extension
     $this->file_safe_name = true;
     // format safely the filename
     $this->file_force_extension = true;
     // forces extension if there isn't one
     $this->file_overwrite = false;
     // allows overwritting if the file already exists
     $this->file_auto_rename = true;
     // auto-rename if the file already exists
     $this->dir_auto_create = true;
     // auto-creates directory if missing
     $this->dir_auto_chmod = true;
     // auto-chmod directory if not writeable
     $this->dir_chmod = 0777;
     // default chmod to use
     $this->no_script = true;
     // turns scripts into test files
     $this->mime_check = true;
     // checks the mime type against the allowed list
     // these are the different MIME detection methods. if one of these method doesn't work on your
     // system, you can deactivate it here; just set it to false
     $this->mime_fileinfo = true;
     // MIME detection with Fileinfo PECL extension
     $this->mime_file = true;
     // MIME detection with UNIX file() command
     $this->mime_magic = false;
     // MIME detection with mime_magic (mime_content_type())
     // get the default max size from php.ini
     $this->file_max_size_raw = trim(ini_get('upload_max_filesize'));
     $this->file_max_size = $this->getsize($this->file_max_size_raw);
     $this->forbidden = array();
     $this->allowed = array();
     $this->mime_types = array();
     $this->mime_default_type = 'application/octet-stream';
     $this->mime_types = CAT_Helper_Mime::getMimeTypes();
     $this->log()->LogDebug('registered mime types', $this->mime_types);
     // allow to override default settings
     if (CAT_Registry::get('UPLOAD_ENABLE_MIMECHECK') == 'false') {
         $this->mime_check = false;
     }
     if (CAT_Registry::get('UPLOAD_MIME_DEFAULT_TYPE') == 'false') {
         $this->mime_default_type = false;
     }
     $this->allowed = CAT_Helper_Mime::getAllowedMimeTypes();
 }