示例#1
0
 /**
  * Loads uploaded file from table change request.
  *
  * @param string $key       the md5 hash of the column name
  * @param string $rownumber number of row to process
  *
  * @return boolean success
  * @access  public
  */
 public function setUploadedFromTblChangeRequest($key, $rownumber)
 {
     if (!isset($_FILES['fields_upload']) || empty($_FILES['fields_upload']['name']['multi_edit'][$rownumber][$key])) {
         return false;
     }
     $file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'], $rownumber, $key);
     // check for file upload errors
     switch ($file['error']) {
         // we do not use the PHP constants here cause not all constants
         // are defined in all versions of PHP - but the correct constants names
         // are given as comment
         case 0:
             //UPLOAD_ERR_OK:
             return $this->setUploadedFile($file['tmp_name']);
             break;
         case 4:
             //UPLOAD_ERR_NO_FILE:
             break;
         case 1:
             //UPLOAD_ERR_INI_SIZE:
             $this->_error_message = __('The uploaded file exceeds the upload_max_filesize directive in php.ini.');
             break;
         case 2:
             //UPLOAD_ERR_FORM_SIZE:
             $this->_error_message = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.');
             break;
         case 3:
             //UPLOAD_ERR_PARTIAL:
             $this->_error_message = __('The uploaded file was only partially uploaded.');
             break;
         case 6:
             //UPLOAD_ERR_NO_TMP_DIR:
             $this->_error_message = __('Missing a temporary folder.');
             break;
         case 7:
             //UPLOAD_ERR_CANT_WRITE:
             $this->_error_message = __('Failed to write file to disk.');
             break;
         case 8:
             //UPLOAD_ERR_EXTENSION:
             $this->_error_message = __('File upload stopped by extension.');
             break;
         default:
             $this->_error_message = __('Unknown error in file upload.');
     }
     // end switch
     return false;
 }
示例#2
0
 // When a select field is nullified, it's not present in $_REQUEST
 // so initialize it; this way, the foreach($multi_edit_columns) will process it
 foreach ($multi_edit_columns_name as $key => $val) {
     if (!isset($multi_edit_columns[$key])) {
         $multi_edit_columns[$key] = '';
     }
 }
 // Iterate in the order of $multi_edit_columns_name,
 // not $multi_edit_columns, to avoid problems
 // when inserting multiple entries
 $insert_fail = false;
 foreach ($multi_edit_columns_name as $key => $column_name) {
     $current_value = $multi_edit_columns[$key];
     // Note: $key is an md5 of the fieldname. The actual fieldname is
     // available in $multi_edit_columns_name[$key]
     $file_to_insert = new PMA_File();
     $file_to_insert->checkTblChangeForm($key, $rownumber);
     $possibly_uploaded_val = $file_to_insert->getContent();
     if ($possibly_uploaded_val !== false) {
         $current_value = $possibly_uploaded_val;
     }
     // Apply Input Transformation if defined
     if (!empty($mime_map[$column_name]) && !empty($mime_map[$column_name]['input_transformation'])) {
         $filename = 'libraries/plugins/transformations/' . $mime_map[$column_name]['input_transformation'];
         if (is_file($filename)) {
             include_once $filename;
             $classname = PMA_getTransformationClassName($mime_map[$column_name]['input_transformation']);
             /** @var IOTransformationsPlugin $transformation_plugin */
             $transformation_plugin = new $classname();
             $transformation_options = PMA_Transformation_getOptions($mime_map[$column_name]['input_transformation_options']);
             $current_value = $transformation_plugin->applyTransformation($current_value, $transformation_options);
    /**
     * retrieves reference to most recent BLOB repository reference
     *
     * @access  public
     * @return  string - most recent BLOB repository reference
    */
    static function getRecentBLOBReference()
    {
        $ref = PMA_File::$_recent_bs_reference;
        PMA_File::$_recent_bs_reference = NULL;

        return $ref;
    }
示例#4
0
 // rajk - for blobstreaming
 if (NULL != $primary_field || strlen($primary_field) > 0) {
     $remove_blob_repo = isset($_REQUEST['remove_blob_repo_' . $key]) ? $_REQUEST['remove_blob_repo_' . $key] : NULL;
     $upload_blob_repo = isset($_REQUEST['upload_blob_repo_' . $key]) ? $_REQUEST['upload_blob_repo_' . $key] : NULL;
     // checks if an existing blob repository reference should be removed
     if (isset($remove_blob_repo) && !isset($upload_blob_repo)) {
         $remove_blob_reference = $_REQUEST['remove_blob_ref_' . $key];
         if (isset($remove_blob_reference)) {
             $val = "''";
         }
     }
     // checks if this field requires a bs reference attached to it
     $requires_bs_reference = isset($upload_blob_repo);
     if ($requires_bs_reference) {
         // get the most recent BLOB reference
         $bs_reference = PMA_File::getRecentBLOBReference();
         // if the most recent BLOB reference exists, set it as a field value
         if (!is_null($bs_reference)) {
             $val = "'" . PMA_sqlAddslashes($bs_reference) . "'";
         }
     }
 }
 if (empty($me_funcs[$key])) {
     $cur_value = $val;
 } elseif ('UNIX_TIMESTAMP' === $me_funcs[$key] && $val != "''") {
     $cur_value = $me_funcs[$key] . '(' . $val . ')';
 } elseif (in_array($me_funcs[$key], $func_no_param)) {
     $cur_value = $me_funcs[$key] . '()';
 } else {
     $cur_value = $me_funcs[$key] . '(' . $val . ')';
 }
示例#5
0
 /**
  * @dataProvider compressedFiles
  */
 public function testBinaryContent($file, $mime)
 {
     $data = '0x' . bin2hex(file_get_contents($file));
     $file = new PMA_File($file);
     $this->assertEquals($data, $file->getContent());
 }
示例#6
0
 /**
  * @access  public
  * @uses    PMA_File::fetchUploadedFromTblChangeRequestMultiple()
  * @uses    PMA_File::setUploadedFile()
  * @uses    PMA_File::$_error_message
  * @uses    $GLOBALS['strUploadErrorIniSize']
  * @uses    $GLOBALS['strUploadErrorFormSize']
  * @uses    $GLOBALS['strUploadErrorPartial']
  * @uses    $GLOBALS['strUploadErrorNoTempDir']
  * @uses    $GLOBALS['strUploadErrorCantWrite']
  * @uses    $GLOBALS['strUploadErrorExtension']
  * @uses    $GLOBALS['strUploadErrorUnknown']
  * @uses    $_FILES
  * @param   string  $key    a numeric key used to identify the different rows
  * @param   string  $primary_key
  * @return  boolean success
  */
 function setUploadedFromTblChangeRequest($key, $primary = null)
 {
     if (!isset($_FILES['fields_upload_' . $key])) {
         return false;
     }
     $file = $_FILES['fields_upload_' . $key];
     if (null !== $primary) {
         $file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($file, $primary);
     }
     // check for file upload errors
     switch ($file['error']) {
         // cybot_tm: we do not use the PHP constants here cause not all constants
         // are defined in all versions of PHP - but the correct constants names
         // are given as comment
         case 0:
             //UPLOAD_ERR_OK:
             return $this->setUploadedFile($file['tmp_name']);
             break;
         case 4:
             //UPLOAD_ERR_NO_FILE:
             break;
         case 1:
             //UPLOAD_ERR_INI_SIZE:
             $this->_error_message = $GLOBALS['strUploadErrorIniSize'];
             break;
         case 2:
             //UPLOAD_ERR_FORM_SIZE:
             $this->_error_message = $GLOBALS['strUploadErrorFormSize'];
             break;
         case 3:
             //UPLOAD_ERR_PARTIAL:
             $this->_error_message = $GLOBALS['strUploadErrorPartial'];
             break;
         case 6:
             //UPLOAD_ERR_NO_TMP_DIR:
             $this->_error_message = $GLOBALS['strUploadErrorNoTempDir'];
             break;
         case 7:
             //UPLOAD_ERR_CANT_WRITE:
             $this->_error_message = $GLOBALS['strUploadErrorCantWrite'];
             break;
         case 8:
             //UPLOAD_ERR_EXTENSION:
             $this->_error_message = $GLOBALS['strUploadErrorExtension'];
             break;
         default:
             $this->_error_message = $GLOBALS['strUploadErrorUnknown'];
     }
     // end switch
     return false;
 }