public function getRawContent() { if (null === $this->_content) { if ($this->isUploaded() && !$this->checkUploadedFile()) { return false; } if (!$this->isReadable()) { return false; } if (function_exists('file_get_contents')) { $this->_content = file_get_contents($this->getName()); } elseif ($size = filesize($this->getName())) { $handle = fopen($this->getName(), 'rb'); $this->_content = fread($handle, $size); fclose($handle); } } return $this->_content; }
$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; if (!is_array($config)) { if (!isset($error)) { $error = __('Could not import configuration'); } } else { // sanitize input values: treat them as though