~ubuntu-branches/ubuntu/saucy/phpmyadmin/saucy-proposed

« back to all changes in this revision

Viewing changes to libraries/plugins/export/ExportSql.class.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-08-04 13:24:37 UTC
  • mfrom: (1.2.44)
  • Revision ID: package-import@ubuntu.com-20130804132437-jznw8efwy4hr1nms
Tags: 4:4.0.5-1
* New upstream release.
  - Fixes security issue PMASA-2013-10.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
                $leaf->setName('add_statements');
220
220
                $leaf->setText(__('Add statements:'));
221
221
                $subgroup->setSubgroupHeader($leaf);
 
222
 
 
223
                if ($plugin_param['export_type'] != 'table') {
 
224
                    $leaf = new BoolPropertyItem();
 
225
                    $leaf->setName('create_database');
 
226
                    $create_clause = '<code>CREATE DATABASE / USE</code>';
 
227
                    $leaf->setText(sprintf(__('Add %s statement'), $create_clause));
 
228
                    $subgroup->addProperty($leaf);
 
229
                }
 
230
 
222
231
                if ($plugin_param['export_type'] == 'table') {
223
232
                    if (PMA_Table::isView($GLOBALS['db'], $GLOBALS['table'])) {
224
233
                        $drop_clause = '<code>DROP VIEW</code>';
706
715
                return false;
707
716
            }
708
717
        }
709
 
        $create_query = 'CREATE DATABASE IF NOT EXISTS '
710
 
            . (isset($GLOBALS['sql_backquotes'])
711
 
            ? PMA_Util::backquoteCompat($db, $compat) : $db);
712
 
        $collation = PMA_getDbCollation($db);
713
 
        if (PMA_DRIZZLE) {
714
 
            $create_query .= ' COLLATE ' . $collation;
715
 
        } else {
716
 
            if (strpos($collation, '_')) {
717
 
                $create_query .= ' DEFAULT CHARACTER SET '
718
 
                    . substr($collation, 0, strpos($collation, '_'))
719
 
                    . ' COLLATE ' . $collation;
720
 
            } else {
721
 
                $create_query .= ' DEFAULT CHARACTER SET ' . $collation;
722
 
            }
723
 
        }
724
 
        $create_query .= ';' . $crlf;
725
 
        if (! PMA_exportOutputHandler($create_query)) {
726
 
            return false;
727
 
        }
728
 
        if (isset($GLOBALS['sql_backquotes'])
729
 
            && ((isset($GLOBALS['sql_compatibility'])
730
 
            && $GLOBALS['sql_compatibility'] == 'NONE')
731
 
            || PMA_DRIZZLE)
732
 
        ) {
733
 
            $result = PMA_exportOutputHandler(
734
 
                'USE ' . PMA_Util::backquoteCompat($db, $compat)
735
 
                . ';' . $crlf
736
 
            );
737
 
        } else {
738
 
            $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
739
 
        }
740
 
 
741
 
        return $result;
 
718
        if (isset($GLOBALS['sql_create_database'])) {
 
719
            $create_query = 'CREATE DATABASE IF NOT EXISTS '
 
720
                . (isset($GLOBALS['sql_backquotes'])
 
721
                ? PMA_Util::backquoteCompat($db, $compat) : $db);
 
722
            $collation = PMA_getDbCollation($db);
 
723
            if (PMA_DRIZZLE) {
 
724
                $create_query .= ' COLLATE ' . $collation;
 
725
            } else {
 
726
                if (strpos($collation, '_')) {
 
727
                    $create_query .= ' DEFAULT CHARACTER SET '
 
728
                        . substr($collation, 0, strpos($collation, '_'))
 
729
                        . ' COLLATE ' . $collation;
 
730
                } else {
 
731
                    $create_query .= ' DEFAULT CHARACTER SET ' . $collation;
 
732
                }
 
733
            }
 
734
            $create_query .= ';' . $crlf;
 
735
            if (! PMA_exportOutputHandler($create_query)) {
 
736
                return false;
 
737
            }
 
738
            if (isset($GLOBALS['sql_backquotes'])
 
739
                && ((isset($GLOBALS['sql_compatibility'])
 
740
                && $GLOBALS['sql_compatibility'] == 'NONE')
 
741
                || PMA_DRIZZLE)
 
742
            ) {
 
743
                $result = PMA_exportOutputHandler(
 
744
                    'USE ' . PMA_Util::backquoteCompat($db, $compat)
 
745
                    . ';' . $crlf
 
746
                );
 
747
            } else {
 
748
                $result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
 
749
            }
 
750
            return $result;
 
751
        } else {
 
752
            return true;
 
753
        }
742
754
    }
743
755
 
744
756
    /**