// For re-usability, moved http-headers and stylesheets
// to a seperate file. It can now be included by libraries/header.inc.php,
// querywindow.php.

require_once './libraries/header_http.inc.php';
// [MIME]
if (isset($ct) && !empty($ct)) {
    $mime_type = $ct;
} else {
    $mime_type = (isset($mime_map[$transform_key]['mimetype'])
        ? str_replace('_', '/', $mime_map[$transform_key]['mimetype'])
        : $default_ct)
    . (isset($mime_options['charset']) ? $mime_options['charset'] : '');
}

PMA_download_header($cn, $mime_type);

if (! isset($resize)) {
    echo $row[$transform_key];
} else {
    // if image_*__inline.inc.php finds that we can resize,
    // it sets $resize 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 then the $newWidth and $newHeight
예제 #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_sanitize_filename($filename);
        PMA_download_header($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.'));
                include_once 'libraries/header.inc.php';
                $active_page = 'db_export.php';
                include 'db_export.php';
                exit;
            }
        }
        $backup_cfgServer = $cfg['Server'];
        include_once 'libraries/header.inc.php';
        $cfg['Server'] = $backup_cfgServer;
예제 #3
0
 /**
  * Sends file as a download to user.
  */
 function Download($filename)
 {
     $pdfData = $this->getPDFData();
     PMA_download_header($filename, 'application/pdf', strlen($pdfData));
     echo $pdfData;
 }
예제 #4
0
 /**
  * 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 nothing
  */
 private function _toFile($file_name, $type, $ext)
 {
     $file_name = $this->_sanitizeName($file_name, $ext);
     ob_clean();
     PMA_download_header($file_name, $type);
 }
예제 #5
0
}

if (PMA_ifSetOr($_POST['submit_clear'], '')) {
    //
    // Clear current config and return to main page
    //
    ConfigFile::getInstance()->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_download_header('config.inc.php', 'text/plain');
    echo ConfigGenerator::getConfigFile();
    exit;
} elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
    //
    // Save generated config file on the server
    //
    file_put_contents($config_file_path, ConfigGenerator::getConfigFile());
    header('HTTP/1.1 303 See Other');
    header('Location: index.php?action_done=config_saved');
    exit;
} elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
    //
    // Load config file from the server
    //
    $cfg = array();
 /**
  * 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_download_header($fileName . '.eps', 'image/x-eps', strlen($output));
     print $output;
 }
예제 #7
0
    '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_download_header($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();
?>
예제 #8
0
    } else {
        /* Filename from request should be safe here */
        $filename = $_REQUEST['filename'];
    }
    /* Decode data */
    if ($extension != 'svg') {
        $data = substr($_REQUEST['image'], strpos($_REQUEST['image'], ',') + 1);
        $data = base64_decode($data);
    } else {
        $data = $_REQUEST['image'];
    }
    /* Send download header */
    PMA_download_header($filename, $_REQUEST['type'], strlen($data));
    /* Send data */
    echo $data;
    /* For monitor chart config export */
} else {
    if (isset($_REQUEST['monitorconfig'])) {
        PMA_download_header('monitor.cfg', 'application/force-download');
        echo urldecode($_REQUEST['monitorconfig']);
        /* For monitor chart config import */
    } else {
        if (isset($_REQUEST['import'])) {
            header('Content-type: text/plain');
            if (!file_exists($_FILES['file']['tmp_name'])) {
                exit;
            }
            echo file_get_contents($_FILES['file']['tmp_name']);
        }
    }
}
 /**
  * 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_download_header($fileName . '.vdx', 'application/visio', strlen($output));
     print $output;
 }
예제 #10
0
 * 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_once './libraries/config/ConfigFile.class.php';
require_once './libraries/config/Form.class.php';
require_once './libraries/config/FormDisplay.class.php';
require './libraries/config/user_preferences.forms.php';
PMA_userprefs_pageinit();
$error = '';
if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == 'text_file') {
    // export to JSON file
    $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json';
    PMA_download_header($filename, 'application/json');
    $settings = PMA_load_userprefs();
    echo json_encode($settings['config_data']);
    return;
} else {
    if (isset($_POST['submit_get_json'])) {
        $settings = PMA_load_userprefs();
        header('Content-Type: application/json');
        echo json_encode(array('prefs' => json_encode($settings['config_data']), 'mtime' => $settings['mtime']));
        return;
    } else {
        if (isset($_POST['submit_import'])) {
            // load from JSON file
            $json = '';
            if (filter_input(INPUT_POST, 'import_type') == 'text_file' && isset($_FILES['import_file']) && $_FILES['import_file']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['import_file']['tmp_name'])) {
                // read JSON from uploaded file
예제 #11
0
    PMA_mysqlDie(
        sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)),
        '', ''
    );
}

/* Check if table exists */
if (!PMA_DBI_get_columns($db, $table)) {
    PMA_mysqlDie(__('Invalid table name'));
}

/* Grab data */
$sql = 'SELECT ' . PMA_backquote($transform_key) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
$result = PMA_DBI_fetch_value($sql);

/* Check return code */
if ($result === false) {
    PMA_mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
}

/* Avoid corrupting data */
@ini_set('url_rewriter.tags', '');

PMA_download_header(
    $table . '-' .  $transform_key . '.bin',
    PMA_detectMIME($result),
    strlen($result)
);
echo $result;
?>
 /**
  * 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_download_header($fileName . '.svg', 'image/svg+xml', strlen($output));
     print $output;
 }
예제 #13
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_download_header($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()
  */
 function showOutput($fileName)
 {
     if (ob_get_clean()) {
         ob_end_clean();
     }
     $output = $this->flush();
     PMA_download_header($fileName . '.dia', 'application/x-dia-diagram', strlen($output));
     print $output;
 }
예제 #15
0
 * this code sems to support only few MIME types (check
 * function PMA_BS_CreateReferenceLink in libraries/blobstreaming.lib.php).
 */
$c_type = preg_replace('/[^A-Za-z0-9/_-]/', '_', $_REQUEST['c_type']);
// Get the blob streaming URL
$filename = PMA_BS_getURL($reference);
if (empty($filename)) {
    die(__('No blob streaming server configured!'));
}
$hdrs = get_headers($filename, 1);
if ($hdrs === false) {
    die(__('Failed to fetch headers'));
}
$fHnd = fopen($filename, "rb");
if ($fHnd === false) {
    die(__('Failed to open remote URL'));
}
$f_size = $hdrs['Content-Length'];
PMA_download_header(basename($filename), $c_type, $f_size);
$pos = 0;
$content = "";
while (!feof($fHnd)) {
    $content .= fread($fHnd, $f_size);
    $pos = strlen($content);
    if ($pos >= $f_size) {
        break;
    }
}
echo $content;
flush();
fclose($fHnd);