예제 #1
0
 function do_upload($_FILES = '', $field = 'userfile')
 {
     if (empty($_FILES[$field])) {
         $this->set_error('upload_no_file_selected');
         return FALSE;
     } else {
         if (count($_FILES[$field]['name']) > 1) {
             foreach ($_FILES[$field]['name'] as $index => $name) {
                 if (!empty($name)) {
                     $this->do_xupload($_FILES, $field, $index);
                     $temp = parent::data();
                     $this->set_dataArray($temp, $index);
                 }
             }
             return true;
         } else {
             if ($field == 'proimg') {
                 $this->do_xupload($_FILES, $field);
                 $temp = parent::data();
                 $this->set_dataArray($temp, 0);
                 return true;
             } else {
                 parent::do_upload($_FILES, $field);
                 return parent::data();
             }
         }
     }
 }
예제 #2
0
 /**
  * Verify that the filetype is allowed
  *
  * @access	public
  * @return	bool
  */
 function is_allowed_filetype()
 {
     if (count($this->allowed_types) == 0 or !is_array($this->allowed_types)) {
         $this->set_error('upload_no_file_types');
         return FALSE;
     }
     // Fix for 'application/octet-stream' problem in SWFUpload
     if ($this->file_type == 'application/octet-stream') {
         $mime = $this->mimes_types(trim($this->file_ext, '.'));
         $this->file_type = is_array($mime) ? $mime[0] : $mime;
     }
     // Match the mime with the actual extension
     $this->file_ext = strtolower($this->file_ext);
     if (CI()->CONF['match_mime_to_ext']) {
         // This will require that the extension of the file uploaded matches against only the extention's mimes
         if (in_array(trim($this->file_ext, '.'), $this->allowed_types)) {
             $mime = $this->mimes_types(trim($this->file_ext, '.'));
             if (is_array($mime) && in_array($this->file_type, $mime, TRUE)) {
                 return TRUE;
             } else {
                 if ($mime == $this->file_type) {
                     return TRUE;
                 }
             }
         }
         return FALSE;
     } else {
         return parent::is_allowed_filetype();
     }
 }
예제 #3
0
 function MY_Upload($props = array())
 {
     parent::CI_Upload();
     if (count($props) > 0) {
         $this->initialize($props);
     }
 }
예제 #4
0
 public function __construct($props = array())
 {
     parent::__construct();
     if (count($props) > 0) {
         $this->initialize($props);
     }
     log_message('debug', "Upload Class Initialized");
 }
예제 #5
0
 function initialize($params = array())
 {
     $CI =& get_instance();
     if (!empty($params['field'])) {
         $this->field = $params['field'];
     }
     parent::initialize($params);
 }
 /**
  * @param string $file_name
  * @return boolean
  */
 public function upload($file_name)
 {
     $path = $this->_nuevoDirectorio();
     $config = array('upload_path' => $path, 'allowed_types' => 'gif|jpg|png|bmp|doc|docx|pdf|xls|xlsx|txt|ppt|pptx|csv', 'max_size' => '0', 'max_width' => '0', 'max_height' => '0');
     $this->upload = new CI_Upload($config);
     if (!$this->upload->do_upload($file_name)) {
         rmdir($path);
         $this->_error = $this->upload->display_errors();
         return false;
     } else {
         $data = $this->upload->data();
         $relative_path = str_replace(realpath(BASEPATH . "../"), "", realpath($data["full_path"]));
         $relative_path = substr($relative_path, 1, strlen($relative_path));
         $insert = array("arch_c_tamano" => $data["file_size"], "arch_c_nombre" => $relative_path, "arch_c_mime" => $data["file_type"], "arch_c_hash" => $this->_fileHash(), "arch_f_fecha" => DATE("Y-m-d H:i:s"), "usu_ia_id" => $this->session->userdata('session_idUsuario'));
         $this->_archivo_model->query()->insert($insert);
         return true;
     }
 }
예제 #7
0
 public function do_upload($field = 'userfile')
 {
     $ret = parent::do_upload($field);
     if ($ret) {
         $this->site_path = $this->system_upload_path . '/tmp/' . $this->file_name;
         $this->relative_path = 'tmp/' . $this->file_name;
     }
     return $ret;
 }
예제 #8
0
 /**
  * Constructor
  */
 function __construct($props = array())
 {
     parent::__construct();
     // Make a local reference to the ExpressionEngine super object
     $this->EE =& get_instance();
     $this->EE->load->helper('xss');
     $props['xss_clean'] = xss_check();
     $this->initialize($props);
     log_message('debug', "Upload Class Initialized");
 }
예제 #9
0
파일: EE_Upload.php 프로젝트: rmdort/adiee
 /**
  * Constructor
  */
 function __construct($props = array())
 {
     parent::__construct();
     // Make a local reference to the ExpressionEngine super object
     $this->EE =& get_instance();
     if (count($props) > 0) {
         $this->initialize($props);
     }
     log_message('debug', "Upload Class Initialized");
 }
 /**
  * Constructor
  *
  * @access	public
  */
 public function __construct($props = array())
 {
     parent::__construct();
     $this->CI =& get_instance();
     $this->CI->config->load('uploads_manager');
     if (count($props) > 0) {
         $this->initialize($props);
     }
     log_message('debug', "Upload Class Extension Initialized");
 }
예제 #11
0
파일: My_Upload.php 프로젝트: Orann/infiut
 public function __construct($config = array())
 {
     parent::__construct($config);
 }
 /**
  * Constructor
  *
  * @access	public
  */
 public function __construct($props = array())
 {
     parent::__construct($props);
     $this->ci =& get_instance();
 }
예제 #13
0
파일: File.php 프로젝트: ramadhanl/sia
 public static function upload($field, $id, $path, $config = array())
 {
     $CI =& get_instance();
     $ciConfig = $CI->config->item('utils');
     $config['upload_path'] = $ciConfig['file_dir'] . $path . '/';
     $config['allowed_types'] = '*';
     $config['file_name'] = self::getFileName($id, $path) . '.backup';
     $CI->load->library('upload');
     $upload = new CI_Upload($config);
     if (!$upload->do_upload($field)) {
         return $upload->display_errors('', '');
     } else {
         return TRUE;
     }
 }
예제 #14
0
 /**
  * Keep the file in the temp directory?
  *
  * @access	public
  */
 public function initialize($config = array())
 {
     if (isset($config['use_temp_dir']) && $config['use_temp_dir'] === TRUE) {
         $this->use_temp_dir = TRUE;
     } else {
         $this->use_temp_dir = FALSE;
     }
     parent::initialize($config);
 }
예제 #15
0
 function submit($submit)
 {
     try {
         if ($submit == 'generate_express') {
             $article_ids = preg_split('/,[\\s]*/', $this->input->post('articles'));
             if (!is_array($article_ids)) {
                 $this->output->message('文章id解析错误');
                 throw new Exception();
             }
             $config['upload_path'] = './images/mail/express';
             $config['encrypt_name'] = true;
             $config['allowed_types'] = 'jpg';
             $this->load->library('upload', $config);
             if (!$this->upload->do_upload('header')) {
                 $this->output->message($this->upload->display_errors(), 'warning');
                 throw new Exception();
             }
             $header = $this->upload->data();
             $config['allowed_types'] = 'pdf';
             $config['encrypt_name'] = false;
             $Attachment = new CI_Upload($config);
             if (!$Attachment->do_upload('attachment')) {
                 $this->output->message($Attachment->display_errors(), 'warning');
                 //throw new Exception;
             }
             //$attachment=$Attachment->data();
             $articles = $this->mail->getArticles('star', $article_ids);
             $this->load->addViewData('title', $this->input->post('title'));
             $this->load->addViewData('articles', $articles);
             $this->load->addViewData('header_img', $header['file_name']);
             $mail_html = $this->load->view('mail/express_template', true);
             $this->user->setConfig('mail/express/mail_html', $mail_html);
             $this->user->setConfig('mail/express/title', '星瀚律师 - ' . $this->input->post('title'));
             //$this->session->set_userdata('mail/express/attachment','./images/mail/express/'.$attachment['file_name']);
             $this->output->setData($mail_html, 'preview', 'html', '#express-preview');
         }
         if ($submit == 'send_express') {
             if (!$this->config->user_item('mail/express/mail_html')) {
                 $this->output->message('还没有生成期刊');
                 throw new Exception();
             }
             if (!$this->input->post('client-emails')) {
                 $client_emails = $this->config->user_item('mail/express/receivers');
             } else {
                 $client_emails = preg_split('/,[\\s]*/', $this->input->post('client-emails'));
                 $this->user->setConfig('mail/express/receivers', json_encode($client_emails));
             }
             $this->load->library('email');
             $config = array('protocol' => 'smtp', 'smtp_host' => 'smtp.exmail.qq.com', 'smtp_user' => '*****@*****.**', 'smtp_pass' => '1218xinghan', 'mailtype' => 'html', 'crlf' => "\r\n", 'newline' => "\r\n");
             $this->email->initialize($config);
             $this->email->from('*****@*****.**', '星瀚律师');
             $this->email->subject($this->config->user_item('mail/express/title'));
             $this->email->message($this->config->user_item('mail/express/mail_html'));
             //$this->email->attach($this->session->userdata('mail/express/attachment'));
             if ($this->config->user_item('mail/express/send_progress') < count($this->config->user_item('mail/express/receivers'))) {
                 $receivers = $this->config->user_item('mail/express/receivers');
                 $receiver = $receivers[$this->config->user_item('mail/express/send_progress')];
                 if ($this->email->to($receiver)) {
                     $delivery_status = '';
                 } else {
                     $delivery_status = '(x)';
                 }
                 $this->output->setData($receiver . ' ', 'receiver', 'html', '#delivery-status', 'append');
                 $this->email->send();
                 sleep(3);
                 $this->user->setConfig('mail/express/send_progress', $this->config->user_item('mail/express/send_progress') + 1);
                 $this->output->setData('$(\'[name="submit[send_express]"]:first\').trigger(\'click\')', 'script', 'script');
             } else {
                 $this->output->message('发送完毕');
             }
         }
         if ($submit == 'download') {
             $this->output->as_ajax = false;
             $this->load->model('document_model', 'document');
             $this->document->exportHead('express.html');
             $this->output->set_output($this->config->user_item('mail/express/mail_html'));
         }
         $this->output->status = 'success';
     } catch (Exception $e) {
         $this->output->status = 'fail';
     }
 }
예제 #16
0
 public function is_allowed_filetype($ignore_mime = FALSE)
 {
     $restricted = array('.php', '.php5', '.php4', '.php3', '.phtml', '.pl', '.py');
     if ($this->allowed_types == '*' && in_array($this->file_ext, $restricted)) {
         return FALSE;
     }
     return parent::is_allowed_filetype($ignore_mime);
 }
 public function __construct()
 {
     parent::__construct();
 }
예제 #18
0
 /**
  * do xss clean
  * this plugin makes sure that images do not get xss unless under very certain criteria
  * borrowed from CI 2.x mecurial repo
  *
  * @access	public
  * @return	bool
  */
 public function do_xss_clean()
 {
     $file = $this->upload_path . $this->file_name;
     if (filesize($file) == 0) {
         return FALSE;
     }
     if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '') {
         $current = ini_get('memory_limit') * 1024 * 1024;
         $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');
         ini_set('memory_limit', $new_memory);
         // When an integer is used, the value is measured in bytes. - PHP.net
     }
     if (function_exists('getimagesize') && @getimagesize($file) !== FALSE) {
         if (($file = @fopen($file, 'rb')) === FALSE) {
             return FALSE;
             // Couldn't open the file, return FALSE
         }
         $opening_bytes = fread($file, 256);
         fclose($file);
         if (!preg_match('/<(a|body|head|html|img|plaintext|pre|script|table|title)[\\s>]/i', $opening_bytes)) {
             return TRUE;
             // its an image, no "triggers" detected in the first 256 bytes, we're good
         }
     }
     //do default
     parent::do_xss_clean($types);
 }
예제 #19
0
 function __construct($props = array())
 {
     parent::__construct($props);
 }
예제 #20
0
 function MY_Upload()
 {
     parent::CI_Upload();
 }
예제 #21
0
파일: MY_Upload.php 프로젝트: trk/ionize
 /**
  * Cleans the file name
  *
  * @param $filename
  *
  * @return string
  */
 public function clean_file_name($filename)
 {
     // Remove bad chars
     $filename = parent::clean_file_name($filename);
     // Spaces
     if ($this->remove_spaces == TRUE) {
         $filename = preg_replace("/\\s+/", "_", $filename);
     }
     // Foreign chars
     if ($this->clean_foreign_chars) {
         $filename = convert_accented_characters($filename);
     }
     $filename = preg_replace('/[^a-zA-Z0-9\\/_.|+ -]/', "_", $filename);
     $filename = preg_replace("/[\\/_|+ -]+/", "_", $filename);
     // Remove first and last not wanted chars
     $filename = trim($filename, '_-. ');
     return $filename;
 }
예제 #22
0
 function do_upload($field = 'userfile')
 {
     $CI =& get_instance();
     if (!parent::do_upload($field)) {
         return FALSE;
     }
     $uploaded = $this->data();
     $_POST[$field] = $this->data_dir . '/' . $uploaded['file_name'];
     // copy original
     $dirname = 'data/' . $this->data_dir . '/original/';
     if (!file_exists($dirname)) {
         mkdir($dirname, 0777, true);
     }
     copy($uploaded['full_path'], 'data/' . $this->data_dir . '/original/' . $uploaded['file_name']);
     if ($this->is_watermarked) {
         $this->watermark($_POST);
     }
     foreach ($this->presets as $key => $preset) {
         $this->resize($_POST, $key);
     }
     unlink($this->data_dir . '/' . $uploaded['file_name']);
     return TRUE;
 }
예제 #23
0
파일: Image.php 프로젝트: ramadhanl/sia
 /**
  * 
  * @param string|integer $id (Primary Key)
  * @param string $name
  * @param string $folder (posts/images)
  * @return boolean
  */
 public static function upload($field, $id, $name, $folder, $config = array())
 {
     $CI =& get_instance();
     $ciConfig = $CI->config->item('utils');
     $config['upload_path'] = $path = $ciConfig['upload_dir'] . $folder . '/';
     $config['allowed_types'] = 'gif|jpg|png';
     $config['file_name'] = $fileName = self::getFileName($id, self::IMAGE_ORIGINAL, $name);
     $CI->load->library('upload');
     $CI->load->library('image_lib');
     $upload = new CI_Upload($config);
     if (!$upload->do_upload($field)) {
         return $upload->display_errors('', '');
     } else {
         $imageConfig = array('source_image' => $path . $fileName);
         foreach (array(self::IMAGE_LARGE, self::IMAGE_MEDIUM, self::IMAGE_SMALL) as $size) {
             $imageConfig['new_image'] = $path . self::getFileName($id, $size, $name);
             //                list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower($size)]);
             list($imageConfig['width']) = explode('x', $ciConfig['image'][strtolower($size)]);
             $image = new CI_Image_lib();
             $image->initialize($imageConfig);
             $image->resize();
             $image->clear();
         }
         $imageConfig['new_image'] = $path . self::getFileName($id, self::IMAGE_THUMB, $name);
         list($imageConfig['width'], $imageConfig['height']) = explode('x', $ciConfig['image'][strtolower(self::IMAGE_THUMB)]);
         $imageConfig['maintain_ratio'] = FALSE;
         $image = new CI_Image_lib();
         $image->initialize($imageConfig);
         $image->resize();
         $image->clear();
         return TRUE;
     }
 }
예제 #24
0
 public function do_upload($field = 'userfile')
 {
     if (!isset($_FILES[$field])) {
         return false;
     }
     // check if it's a multiple upload. if not then fall back to CI do_upload()
     if (!is_array($_FILES[$field]['name'])) {
         return parent::do_upload($field);
     } elseif (sizeof($_FILES[$field]['name']) == 1) {
         $files = $_FILES[$field];
         $_FILES[$field]['name'] = $files['name'][0];
         $_FILES[$field]['type'] = $files['type'][0];
         $_FILES[$field]['tmp_name'] = $files['tmp_name'][0];
         $_FILES[$field]['error'] = $files['error'][0];
         $_FILES[$field]['size'] = $files['size'][0];
         return $this->do_upload($field);
     } else {
         $files = $_FILES[$field];
         foreach ($files['name'] as $key => $value) {
             $_FILES[$field]['name'] = $files['name'][$key];
             $_FILES[$field]['type'] = $files['type'][$key];
             $_FILES[$field]['tmp_name'] = $files['tmp_name'][$key];
             $_FILES[$field]['error'] = $files['error'][$key];
             $_FILES[$field]['size'] = $files['size'][$key];
             if ($this->do_upload($field)) {
                 // if the upload was successfull add an element to the uploadedFiles array that contains the data regarding the uploaded file
                 $this->uploadedFiles[] = $this->data();
             } else {
                 // if the upload was unsuccessfull, set a temporary string that will contain the name of the file in question. The string will later be used by the modified display_errors() method
                 $this->tempString = 'File: ' . $_FILES[$field]['name'] . ' - Error: ';
                 // keep the errors in the multi_errors array
                 $this->multi_errors[] = $this->display_errors('', '');
             }
             // now we decide if we continue uploading depending on the "multi" key inside the configuration
             switch ($this->multi) {
                 case 'all':
                     if (sizeof($this->multi_errors) > 0 && sizeof($this->uploadedFiles > 0)) {
                         foreach ($this->uploadedFiles as $dataFile) {
                             if (file_exists($dataFile['full_path'])) {
                                 unlink($dataFile['full_path']);
                             }
                         }
                         break 2;
                     }
                     break;
                 case 'halt':
                     if (sizeof($this->multi_errors) > 0) {
                         break 2;
                     }
                     break;
                     //case 'ignore':
                 //case 'ignore':
                 default:
                     break;
             }
         }
         if (sizeof($this->multi_errors) > 0 && $this->multi == 'all') {
             return FALSE;
         }
         // at the end of the uploads, change the finished variable to true so that the class will know it finished it's main job
         $this->finished = TRUE;
         return TRUE;
     }
 }
예제 #25
0
 function __construct($props)
 {
     parent::CI_Upload($props);
 }