Exemple #1
0
/**
 * Function to export as entries
 *
 * @param array $entries entries
 *
 * @return void
 */
function PMA_exportAsFileDownload($entries)
{
    @ini_set('url_rewriter.tags', '');
    $dump = "# " . sprintf(__('Tracking report for table `%s`'), htmlspecialchars($_REQUEST['table'])) . "\n" . "# " . date('Y-m-d H:i:s') . "\n";
    foreach ($entries as $entry) {
        $dump .= $entry['statement'];
    }
    $filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
    PMA_Response::getInstance()->disable();
    PMA_downloadHeader($filename, 'text/x-sql', mb_strlen($dump));
    echo $dump;
    exit;
}
Exemple #2
0
         }
         exit;
     }
 }
 /**
  * Send headers depending on whether the user chose to download a dump file
  * or not
  */
 if (!$save_on_server) {
     if ($asfile) {
         // Download
         // (avoid rewriting data containing HTML with anchors and forms;
         // this was reported to happen under Plesk)
         @ini_set('url_rewriter.tags', '');
         $filename = PMA_sanitizeFilename($filename);
         PMA_downloadHeader($filename, $mime_type);
     } else {
         // HTML
         if ($export_type == 'database') {
             $num_tables = count($tables);
             if ($num_tables == 0) {
                 $message = PMA_Message::error(__('No tables found in database.'));
                 $active_page = 'db_export.php';
                 include 'db_export.php';
                 exit;
             }
         }
         list($html, $back_button) = PMA_getHtmlForDisplayedExportHeader($export_type, $db, $table);
         echo $html;
         unset($html);
     }
 /**
  * Output EPS Document for download
  *
  * @param string $fileName name of the eps document
  *
  * @return void
  *
  * @access public
  */
 function showOutput($fileName)
 {
     // if(ob_get_clean()){
     //ob_end_clean();
     //}
     $output = $this->stringCommands;
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($fileName, 'image/x-eps', mb_strlen($output));
     print $output;
 }
 /**
  * output Svg Document
  *
  * svg document prompted to the user for download
  * Svg document saved in .svg extension and can be
  * easily changeable by using any svg IDE
  *
  * @param string $fileName file name
  *
  * @return void
  * @access public
  * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
  */
 function showOutput($fileName)
 {
     //ob_get_clean();
     $output = $this->flush();
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($fileName . '.svg', 'image/svg+xml', $GLOBALS['PMA_String']->strlen($output));
     print $output;
 }
 /**
  * output Svg Document
  *
  * svg document prompted to the user for download
  * Svg document saved in .svg extension and can be
  * easily changeable by using any svg IDE
  *
  * @param string $fileName file name
  *
  * @return void
  * @see XMLWriter::startElement(),XMLWriter::writeAttribute()
  */
 public function showOutput($fileName)
 {
     //ob_get_clean();
     $output = $this->flush();
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($fileName, 'image/svg+xml', mb_strlen($output));
     print $output;
 }
Exemple #6
0
 * @package PhpMyAdmin
 */
/**
 * Common functions.
 */
// we don't want the usual PMA\libraries\Response-generated HTML above the column's
// data
define('PMA_BYPASS_GET_INSTANCE', 1);
require_once 'libraries/common.inc.php';
require_once 'libraries/mime.lib.php';
/* Check parameters */
PMA\libraries\Util::checkParameters(array('db', 'table'));
/* Select database */
if (!$GLOBALS['dbi']->selectDb($db)) {
    PMA\libraries\Util::mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', false);
}
/* Check if table exists */
if (!$GLOBALS['dbi']->getColumns($db, $table)) {
    PMA\libraries\Util::mysqlDie(__('Invalid table name'));
}
/* Grab data */
$sql = 'SELECT ' . PMA\libraries\Util::backquote($_GET['transform_key']) . ' FROM ' . PMA\libraries\Util::backquote($table) . ' WHERE ' . $_GET['where_clause'] . ';';
$result = $GLOBALS['dbi']->fetchValue($sql);
/* Check return code */
if ($result === false) {
    PMA\libraries\Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
}
/* Avoid corrupting data */
@ini_set('url_rewriter.tags', '');
PMA_downloadHeader($table . '-' . $_GET['transform_key'] . '.bin', PMA_detectMIME($result), mb_strlen($result, '8bit'));
echo $result;
 /**
  * Handles common tasks of writing the visualization to file for various formats.
  *
  * @param string $file_name file name
  * @param string $type      mime type
  * @param string $ext       extension of the file
  *
  * @return void
  * @access private
  */
 private function _toFile($file_name, $type, $ext)
 {
     $file_name = $this->_sanitizeName($file_name, $ext);
     PMA_downloadHeader($file_name, $type);
 }
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
PMA_userprefsPageInit($cf);
$error = '';
if (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'text_file') {
    // export to JSON file
    PMA\libraries\Response::getInstance()->disable();
    $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json';
    PMA_downloadHeader($filename, 'application/json');
    $settings = PMA_loadUserprefs();
    echo json_encode($settings['config_data'], JSON_PRETTY_PRINT);
    exit;
} elseif (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'php_file') {
    // export to JSON file
    PMA\libraries\Response::getInstance()->disable();
    $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.php';
    PMA_downloadHeader($filename, 'application/php');
    $settings = PMA_loadUserprefs();
    echo '/* ' . _('phpMyAdmin configuration snippet') . " */\n\n";
    echo '/* ' . _('Paste it to your config.inc.php') . " */\n\n";
    foreach ($settings['config_data'] as $key => $val) {
        echo '$cfg[\'' . str_replace('/', '\'][\'', $key) . '\'] = ';
        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;
Exemple #9
0
 /**
  * Sends file as a download to user.
  *
  * @param string $filename file name
  *
  * @return void
  */
 function Download($filename)
 {
     $pdfData = $this->getPDFData();
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($filename, 'application/pdf', strlen($pdfData));
     echo $pdfData;
 }
    /** @var PMA_String $pmaString */
    $pmaString = $GLOBALS['PMA_String'];
    /* Decode data */
    if ($extension != 'svg') {
        $data = mb_substr($_REQUEST['image'], mb_strpos($_REQUEST['image'], ',') + 1);
        $data = base64_decode($data);
    } else {
        $data = $_REQUEST['image'];
    }
    /* Send download header */
    PMA_downloadHeader($filename, $_REQUEST['type'], mb_strlen($data));
    /* Send data */
    echo $data;
} else {
    if (isset($_REQUEST['monitorconfig'])) {
        /* For monitor chart config export */
        PMA_downloadHeader('monitor.cfg', 'application/json; charset=UTF-8');
        header('X-Content-Type-Options: nosniff');
        echo urldecode($_REQUEST['monitorconfig']);
    } else {
        if (isset($_REQUEST['import'])) {
            /* For monitor chart config import */
            header('Content-Type: application/json; charset=UTF-8');
            header('X-Content-Type-Options: nosniff');
            if (!file_exists($_FILES['file']['tmp_name'])) {
                exit;
            }
            echo file_get_contents($_FILES['file']['tmp_name']);
        }
    }
}
require_once 'libraries/mime.lib.php';
/**
 * Sets globals from $_GET
 */
$get_params = array('where_clause', 'transform_key');
foreach ($get_params as $one_get_param) {
    if (isset($_GET[$one_get_param])) {
        $GLOBALS[$one_get_param] = $_GET[$one_get_param];
    }
}
/* Check parameters */
PMA_Util::checkParameters(array('db', 'table', 'where_clause', 'transform_key'));
/* Select database */
if (!PMA_DBI_select_db($db)) {
    PMA_Util::mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', '');
}
/* Check if table exists */
if (!PMA_DBI_get_columns($db, $table)) {
    PMA_Util::mysqlDie(__('Invalid table name'));
}
/* Grab data */
$sql = 'SELECT ' . PMA_Util::backquote($transform_key) . ' FROM ' . PMA_Util::backquote($table) . ' WHERE ' . $where_clause . ';';
$result = PMA_DBI_fetch_value($sql);
/* Check return code */
if ($result === false) {
    PMA_Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
}
/* Avoid corrupting data */
@ini_set('url_rewriter.tags', '');
PMA_downloadHeader($table . '-' . $transform_key . '.bin', PMA_detectMIME($result), strlen($result));
echo $result;
 /**
  * Output Dia Document for download
  *
  * @param string $fileName name of the dia document
  *
  * @return void
  * @access public
  * @see XMLWriter::flush()
  */
 function showOutput($fileName)
 {
     if (ob_get_clean()) {
         ob_end_clean();
     }
     $output = $this->flush();
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($fileName . '.dia', 'application/x-dia-diagram', $GLOBALS['PMA_String']->strlen($output));
     print $output;
 }
 /**
  * Output Visio XML .VDX Document for download
  *
  * @param string $fileName name of the Visio XML document
  *
  * @return void
  * @access public
  * @see XMLWriter::flush()
  */
 function showOutput($fileName)
 {
      //if(ob_get_clean()){
         //ob_end_clean();
     //}
     $output = $this->flush();
     PMA_Response::getInstance()->disable();
     PMA_downloadHeader($fileName . '.vdx', 'application/visio', strlen($output));
     print $output;
 }
Exemple #14
0
/**
 * Function to export as entries
 *
 * @param array $entries entries
 *
 * @return void
 */
function PMA_exportAsFileDownload($entries)
{
    @ini_set('url_rewriter.tags', '');
    // Replace all multiple whitespaces by a single space
    $table = htmlspecialchars(preg_replace('/\\s+/', ' ', $_REQUEST['table']));
    $dump = "# " . sprintf(__('Tracking report for table `%s`'), $table) . "\n" . "# " . date('Y-m-d H:i:s') . "\n";
    foreach ($entries as $entry) {
        $dump .= $entry['statement'];
    }
    $filename = 'log_' . $table . '.sql';
    PMA\libraries\Response::getInstance()->disable();
    PMA_downloadHeader($filename, 'text/x-sql', strlen($dump));
    echo $dump;
    exit;
}
        $filename = $_REQUEST['filename'];
    }
    /** @var String $pmaString */
    $pmaString = $GLOBALS['PMA_String'];
    /* Decode data */
    if ($extension != 'svg') {
        $data = mb_substr($_REQUEST['image'], mb_strpos($_REQUEST['image'], ',') + 1);
        $data = base64_decode($data);
    } else {
        $data = $_REQUEST['image'];
    }
    /* Send download header */
    PMA_downloadHeader($filename, $_REQUEST['type'], mb_strlen($data));
    /* Send data */
    echo $data;
} else {
    if (isset($_REQUEST['monitorconfig'])) {
        /* For monitor chart config export */
        PMA_downloadHeader('monitor.cfg', 'application/force-download');
        echo urldecode($_REQUEST['monitorconfig']);
    } else {
        if (isset($_REQUEST['import'])) {
            /* For monitor chart config import */
            header('Content-type: text/plain');
            if (!file_exists($_FILES['file']['tmp_name'])) {
                exit;
            }
            echo file_get_contents($_FILES['file']['tmp_name']);
        }
    }
}
Exemple #16
0
// Export as file download
if (isset($_REQUEST['report_export'])
    && $_REQUEST['export_type'] == 'sqldumpfile'
) {
    @ini_set('url_rewriter.tags', '');

    $dump = "# " . sprintf(
        __('Tracking report for table `%s`'), htmlspecialchars($_REQUEST['table'])
    )
    . "\n" . "# " . date('Y-m-d H:i:s') . "\n";
    foreach ($entries as $entry) {
        $dump .= $entry['statement'];
    }
    $filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
    PMA_downloadHeader($filename, 'text/x-sql', strlen($dump));

    echo $dump;
    exit();
}


/**
 * Gets tables informations
 */

echo '<br />';

/**
 * Actions
 */
 /**
  * Output Dia Document for download
  *
  * @param string $fileName name of the dia document
  *
  * @return void
  * @access public
  * @see    XMLWriter::flush()
  */
 public function showOutput($fileName)
 {
     if (ob_get_clean()) {
         ob_end_clean();
     }
     $output = $this->flush();
     PMA\libraries\Response::getInstance()->disable();
     PMA_downloadHeader($fileName, 'application/x-dia-diagram', mb_strlen($output));
     print $output;
 }
    foreach ($mime_options as $key => $option) {
        if (substr($option, 0, 10) == '; charset=') {
            $mime_options['charset'] = $option;
        }
    }
}
// Only output the http headers
$response = PMA\libraries\Response::getInstance();
$response->getHeader()->sendHttpHeaders();
// [MIME]
if (isset($ct) && !empty($ct)) {
    $mime_type = $ct;
} else {
    $mime_type = (!empty($mime_map[$transform_key]['mimetype']) ? str_replace('_', '/', $mime_map[$transform_key]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : '');
}
PMA_downloadHeader($cn, $mime_type);
if (!isset($_REQUEST['resize'])) {
    if (stripos($mime_type, 'html') === false) {
        echo $row[$transform_key];
    } else {
        echo htmlspecialchars($row[$transform_key]);
    }
} else {
    // if image_*__inline.inc.php finds that we can resize,
    // it sets the resize parameter to jpeg or png
    $srcImage = imagecreatefromstring($row[$transform_key]);
    $srcWidth = ImageSX($srcImage);
    $srcHeight = ImageSY($srcImage);
    // Check to see if the width > height or if width < height
    // if so adjust accordingly to make sure the image
    // stays smaller than the new width and new height
/**
 * Gets some core libraries and displays a top message if required
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/user_preferences.lib.php';
require_once 'libraries/config/config_functions.lib.php';
require_once 'libraries/config/messages.inc.php';
require 'libraries/config/user_preferences.forms.php';
$cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
PMA_userprefsPageInit($cf);
$error = '';
if (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'text_file') {
    // export to JSON file
    PMA\libraries\Response::getInstance()->disable();
    $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json';
    PMA_downloadHeader($filename, 'application/json');
    $settings = PMA_loadUserprefs();
    echo json_encode($settings['config_data'], JSON_PRETTY_PRINT);
    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'])) {
Exemple #20
0
 */
/**
 * @ignore
 */
define('PMA_MINIMUM_COMMON', true);
/**
 * Gets core libraries and defines some variables
 */
require './libraries/common.inc.php';
/**
 * ZIP file handler.
 */
require './libraries/zip.lib.php';
// ini file
$parameters = array('id' => 'phpMyAdmin@' . $_SERVER['HTTP_HOST'], 'uri' => $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'), 'status' => 'yes', 'location' => 'no', 'sidebar' => 'no', 'navigation' => 'no', 'icon' => 'phpMyAdmin');
// dom sript file
// none need yet
// icon
$icon = 'favicon.ico';
// name
$name = 'phpMyAdmin.webapp';
$ini_file = "[Parameters]\n";
foreach ($parameters as $key => $value) {
    $ini_file .= $key . '=' . $value . "\n";
}
PMA_downloadHeader($name, 'application/webapp', 0, false);
$zip = new ZipFile();
$zip->setDoWrite();
$zip->addFile($ini_file, 'webapp.ini');
$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico');
$zip->file();
Exemple #21
0
    $_SESSION['eol'] = $_POST['eol'] == 'unix' ? 'unix' : 'win';
}
if (PMA_ifSetOr($_POST['submit_clear'], '')) {
    //
    // Clear current config and return to main page
    //
    $GLOBALS['ConfigFile']->resetConfigData();
    // drop post data
    header('HTTP/1.1 303 See Other');
    header('Location: index.php');
    exit;
} elseif (PMA_ifSetOr($_POST['submit_download'], '')) {
    //
    // Output generated config file
    //
    PMA_downloadHeader('config.inc.php', 'text/plain');
    echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
    exit;
} elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
    //
    // Save generated config file on the server
    //
    file_put_contents($config_file_path, ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
    header('HTTP/1.1 303 See Other');
    header('Location: index.php' . PMA_URL_getCommon() . '&action_done=config_saved');
    exit;
} elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
    //
    // Load config file from the server
    //
    $cfg = array();
 *
 * @package PhpMyAdmin
 */
/**
 * Common functions.
 */
// we don't want the usual PMA_Response-generated HTML above the column's data
define('PMA_BYPASS_GET_INSTANCE', 1);
require_once 'libraries/common.inc.php';
require_once 'libraries/mime.lib.php';
/* Check parameters */
PMA_Util::checkParameters(array('db', 'table'));
/* Select database */
if (!$GLOBALS['dbi']->selectDb($db)) {
    PMA_Util::mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', false);
}
/* Check if table exists */
if (!$GLOBALS['dbi']->getColumns($db, $table)) {
    PMA_Util::mysqlDie(__('Invalid table name'));
}
/* Grab data */
$sql = 'SELECT ' . PMA_Util::backquote($_GET['transform_key']) . ' FROM ' . PMA_Util::backquote($table) . ' WHERE ' . $_GET['where_clause'] . ';';
$result = $GLOBALS['dbi']->fetchValue($sql);
/* Check return code */
if ($result === false) {
    PMA_Util::mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
}
/* Avoid corrupting data */
@ini_set('url_rewriter.tags', '');
PMA_downloadHeader($table . '-' . $_GET['transform_key'] . '.bin', PMA_detectMIME($result), $GLOBALS['PMA_String']->strlen($result));
echo $result;