Beispiel #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 = 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']);
         case 4:
             //UPLOAD_ERR_NO_FILE:
             break;
         case 1:
             //UPLOAD_ERR_INI_SIZE:
             $this->_error_message = Message::error(__('The uploaded file exceeds the upload_max_filesize directive in ' . 'php.ini.'));
             break;
         case 2:
             //UPLOAD_ERR_FORM_SIZE:
             $this->_error_message = Message::error(__('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 = Message::error(__('The uploaded file was only partially uploaded.'));
             break;
         case 6:
             //UPLOAD_ERR_NO_TMP_DIR:
             $this->_error_message = Message::error(__('Missing a temporary folder.'));
             break;
         case 7:
             //UPLOAD_ERR_CANT_WRITE:
             $this->_error_message = Message::error(__('Failed to write file to disk.'));
             break;
         case 8:
             //UPLOAD_ERR_EXTENSION:
             $this->_error_message = Message::error(__('File upload stopped by extension.'));
             break;
         default:
             $this->_error_message = Message::error(__('Unknown error in file upload.'));
     }
     // end switch
     return false;
 }
Beispiel #2
0
        echo var_export($val, true) . ";\n";
    }
    exit;
} else {
    if (isset($_POST['submit_get_json'])) {
        $settings = PMA_loadUserprefs();
        $response = PMA\libraries\Response::getInstance();
        $response->addJSON('prefs', json_encode($settings['config_data']));
        $response->addJSON('mtime', $settings['mtime']);
        exit;
    } else {
        if (isset($_POST['submit_import'])) {
            // load from JSON file
            $json = '';
            if (isset($_POST['import_type']) && $_POST['import_type'] == 'text_file' && isset($_FILES['import_file']) && $_FILES['import_file']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['import_file']['tmp_name'])) {
                $import_handle = new File($_FILES['import_file']['tmp_name']);
                $import_handle->checkUploadedFile();
                if ($import_handle->isError()) {
                    $error = $import_handle->getError();
                } else {
                    // read JSON from uploaded file
                    $json = $import_handle->getRawContent();
                }
            } else {
                // read from POST value (json)
                $json = isset($_POST['json']) ? $_POST['json'] : null;
            }
            // hide header message
            $_SESSION['userprefs_autoload'] = true;
            $config = json_decode($json, true);
            $return_url = isset($_POST['return_url']) ? $_POST['return_url'] : null;
Beispiel #3
0
     * Do not allow symlinks to avoid security issues
     * (user can create symlink to file he can not access,
     * but phpMyAdmin can).
     */
    if (@is_link($import_file)) {
        $import_file = 'none';
    }
} elseif (empty($import_file) || !is_uploaded_file($import_file)) {
    $import_file = 'none';
}
// Do we have file to import?
if ($import_file != 'none' && !$error) {
    /**
     *  Handle file compression
     */
    $import_handle = new File($import_file);
    $import_handle->checkUploadedFile();
    if ($import_handle->isError()) {
        PMA_stopImport($import_handle->getError());
    }
    $import_handle->setDecompressContent(true);
    $import_handle->open();
    if ($import_handle->isError()) {
        PMA_stopImport($import_handle->getError());
    }
} elseif (!$error) {
    if (!isset($import_text) || empty($import_text)) {
        $message = PMA\libraries\Message::error(__('No data was received to import. Either no file name was ' . 'submitted, or the file size exceeded the maximum size permitted ' . 'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'));
        PMA_stopImport($message);
    }
}