コード例 #1
0
 /**
  * test of generating user dir, globals are defined
  *
  * @param string $a String
  * @param string $e Expected output
  *
  * @return void
  *
  * @dataProvider userDirDataProvider
  */
 public function testUserDirString($a, $e)
 {
     $GLOBALS['cfg']['Server']['user'] = '******';
     $this->assertEquals($e, PMA\libraries\Util::userDir($a));
 }
コード例 #2
0
/**
 * Get HTML select option for upload
 *
 * @param string $vkey   [multi_edit]['row_id']
 * @param array  $column description of column in given table
 *
 * @return string|void an html snippet
 */
function PMA_getSelectOptionForUpload($vkey, $column)
{
    $files = PMA_getFileSelectOptions(PMA\libraries\Util::userDir($GLOBALS['cfg']['UploadDir']));
    if ($files === false) {
        return '<font color="red">' . __('Error') . '</font><br />' . "\n" . __('The directory you set for upload work cannot be reached.') . "\n";
    } elseif (!empty($files)) {
        return "<br />\n" . '<i>' . __('Or') . '</i>' . ' ' . __('web server upload directory:') . '<br />' . "\n" . '<select size="1" name="fields_uploadlocal' . $vkey . '[' . $column['Field_md5'] . ']">' . "\n" . '<option value="" selected="selected"></option>' . "\n" . $files . '</select>' . "\n";
    }
    return null;
}
コード例 #3
0
/**
 * Prints Html For Export Options Save Dir
 *
 * @return string
 */
function PMA_getHtmlForExportOptionsOutputSaveDir()
{
    global $cfg;
    $html = '<li>';
    $html .= '<input type="checkbox" name="onserver" value="saveit" ';
    $html .= 'id="checkbox_dump_onserver" ';
    $html .= PMA_exportCheckboxCheck('onserver');
    $html .= '/>';
    $html .= '<label for="checkbox_dump_onserver">';
    $html .= sprintf(__('Save on server in the directory <b>%s</b>'), htmlspecialchars(PMA\libraries\Util::userDir($cfg['SaveDir'])));
    $html .= '</label>';
    $html .= '</li>';
    $html .= '<li>';
    $html .= '<input type="checkbox" name="onserver_overwrite" value="saveitover"';
    $html .= ' id="checkbox_dump_onserver_overwrite" ';
    $html .= PMA_exportCheckboxCheck('onserver_overwrite');
    $html .= '/>';
    $html .= '<label for="checkbox_dump_onserver_overwrite">';
    $html .= __('Overwrite existing file(s)');
    $html .= '</label>';
    $html .= '</li>';
    return $html;
}
コード例 #4
0
ファイル: import.php プロジェクト: rclakmal/phpmyadmin
    $memory_limit = (int) substr($memory_limit, 0, -1) * 1024;
} elseif ('g' == $memoryUnit) {
    $memory_limit = (int) substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
} else {
    $memory_limit = (int) $memory_limit;
}
// Just to be sure, there might be lot of memory needed for uncompression
$read_limit = $memory_limit / 8;
// handle filenames
if (isset($_FILES['import_file'])) {
    $import_file = $_FILES['import_file']['tmp_name'];
}
if (!empty($local_import_file) && !empty($cfg['UploadDir'])) {
    // sanitize $local_import_file as it comes from a POST
    $local_import_file = PMA_securePath($local_import_file);
    $import_file = PMA\libraries\Util::userDir($cfg['UploadDir']) . $local_import_file;
} elseif (empty($import_file) || !is_uploaded_file($import_file)) {
    $import_file = 'none';
}
// Do we have file to import?
if ($import_file != 'none' && !$error) {
    // work around open_basedir and other limitations
    $open_basedir = @ini_get('open_basedir');
    // If we are on a server with open_basedir, we must move the file
    // before opening it.
    if (!empty($open_basedir)) {
        $tmp_subdir = ini_get('upload_tmp_dir');
        if (empty($tmp_subdir)) {
            $tmp_subdir = sys_get_temp_dir();
        }
        $tmp_subdir = rtrim($tmp_subdir, DIRECTORY_SEPARATOR);
コード例 #5
0
ファイル: export.lib.php プロジェクト: wp-cloud/phpmyadmin
/**
 * Open the export file
 *
 * @param string  $filename     the export filename
 * @param boolean $quick_export whether it's a quick export or not
 *
 * @return array the full save filename, possible message and the file handle
 */
function PMA_openExportFile($filename, $quick_export)
{
    $file_handle = null;
    $message = '';
    $save_filename = PMA\libraries\Util::userDir($GLOBALS['cfg']['SaveDir']) . preg_replace('@[/\\\\]@', '_', $filename);
    if (file_exists($save_filename) && (!$quick_export && empty($_REQUEST['onserver_overwrite']) || $quick_export && $_REQUEST['quick_export_onserver_overwrite'] != 'saveitover')) {
        $message = Message::error(__('File %s already exists on server, ' . 'change filename or check overwrite option.'));
        $message->addParam($save_filename);
    } elseif (@is_file($save_filename) && !@is_writable($save_filename)) {
        $message = Message::error(__('The web server does not have permission ' . 'to save the file %s.'));
        $message->addParam($save_filename);
    } elseif (!($file_handle = @fopen($save_filename, 'w'))) {
        $message = Message::error(__('The web server does not have permission ' . 'to save the file %s.'));
        $message->addParam($save_filename);
    }
    return array($save_filename, $message, $file_handle);
}
コード例 #6
0
 /**
  * Test for PMA_getHtmlForExportOptions
  *
  * @return void
  */
 public function testPMAGetHtmlForExportOptions()
 {
     global $cfg;
     $cfg['Export']['method'] = "XML";
     $cfg['SaveDir'] = "/tmp";
     $export_type = "server";
     $db = "PMA";
     $table = "PMA_test";
     $multi_values_str = "multi_values_str";
     $num_tables_str = "10";
     $unlim_num_rows_str = "unlim_num_rows_str";
     $single_table = "single_table";
     $GLOBALS['dbi']->cacheTableContent(array($db, $table, 'ENGINE'), 'MERGE');
     $columns_info = array('test_column1' => array('COLUMN_NAME' => 'test_column1'), 'test_column2' => array('COLUMN_NAME' => 'test_column2'));
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $dbi->expects($this->any())->method('getColumnsFull')->will($this->returnValue($columns_info));
     $GLOBALS['dbi'] = $dbi;
     /* Scan for plugins */
     $export_list = PMA_getPlugins("export", 'libraries/plugins/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
     //Call the test function
     $html = PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values_str, $num_tables_str, $export_list, $unlim_num_rows_str);
     //validate 2: PMA_getHtmlForExportOptionsMethod
     $this->assertContains($cfg['Export']['method'], $html);
     $this->assertContains('<div class="exportoptions" id="quick_or_custom">', $html);
     $this->assertContains(__('Export method:'), $html);
     $this->assertContains(__('Custom - display all possible options'), $html);
     //validate 3: PMA_getHtmlForExportOptionsSelection
     $this->assertContains('<div class="exportoptions" id="databases_and_tables">', $html);
     $this->assertContains('<h3>' . __('Databases:') . '</h3>', $html);
     $this->assertContains($multi_values_str, $html);
     //validate 4: PMA_getHtmlForExportOptionsQuickExport
     $this->assertContains('<input type="checkbox" name="onserver" value="saveit" ', $html);
     $dir = htmlspecialchars(PMA\libraries\Util::userDir($cfg['SaveDir']));
     $this->assertContains('Save on server in the directory <b>' . $dir . '</b>', $html);
     //validate 5: PMA_getHtmlForAliasModalDialog
     $this->assertContains('<div id="alias_modal" class="hide" title="' . 'Rename exported databases/tables/columns">', $html);
     $this->assertContains('Select database', $html);
     $this->assertContains('Select table', $html);
     $this->assertContains('New database name', $html);
     $this->assertContains('New table name', $html);
     $this->assertContains('test_column', $html);
     //validate 6: PMA_getHtmlForExportOptionsOutput
     $this->assertContains('<div class="exportoptions" id="output">', $html);
     $this->assertContains('user value for test', $html);
     //validate 7: PMA_getHtmlForExportOptionsFormat
     $this->assertContains('<div class="exportoptions" id="format">', $html);
     $this->assertContains('<h3>' . __('Format:') . '</h3>', $html);
 }