[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-11674-g84c6bd7

Michal Čihař nijel at users.sourceforge.net
Fri Jul 22 09:05:55 CEST 2011


The branch, master has been updated
       via  84c6bd7284968789548b6ac53441774307ab13eb (commit)
       via  12a31298bde7487b6306c87a737f32d8f715f4d2 (commit)
       via  297bd675cc24299a0ea782829a54f3bdde60b92b (commit)
       via  7b17fca511b15e59cc6bce44c349909a358b813c (commit)
       via  ea918f98ffa7c7d8e0a78897e6b105c5bba5aa80 (commit)
      from  e501b557de386e6bc1e789126285452a1725bf20 (commit)


- Log -----------------------------------------------------------------
commit 84c6bd7284968789548b6ac53441774307ab13eb
Author: Michal Čihař <mcihar at suse.cz>
Date:   Fri Jul 22 09:06:37 2011 +0200

    Fix indentation

commit 12a31298bde7487b6306c87a737f32d8f715f4d2
Author: Michal Čihař <mcihar at suse.cz>
Date:   Fri Jul 22 09:05:25 2011 +0200

    Spacing around if

commit 297bd675cc24299a0ea782829a54f3bdde60b92b
Author: Michal Čihař <mcihar at suse.cz>
Date:   Fri Jul 22 09:02:04 2011 +0200

    Wrap long line

commit 7b17fca511b15e59cc6bce44c349909a358b813c
Author: Michal Čihař <mcihar at suse.cz>
Date:   Fri Jul 22 09:01:40 2011 +0200

    Add die() calls are on places which should not happen

commit ea918f98ffa7c7d8e0a78897e6b105c5bba5aa80
Author: Michal Čihař <mcihar at suse.cz>
Date:   Fri Jul 22 08:59:07 2011 +0200

    Add file comment

-----------------------------------------------------------------------

Summary of changes:
 export.php |  332 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 168 insertions(+), 164 deletions(-)

diff --git a/export.php b/export.php
index f5a985a..36c1d58 100644
--- a/export.php
+++ b/export.php
@@ -1,7 +1,7 @@
 <?php
 /* vim: set expandtab sw=4 ts=4 sts=4: */
 /**
- * @todo    too much die here, or?
+ * Main export hanling code
  * @package phpMyAdmin
  */
 
@@ -15,7 +15,11 @@ require_once './libraries/plugin_interface.lib.php';
 PMA_checkParameters(array('what', 'export_type'));
 
 // Scan plugins
-$export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
+$export_list = PMA_getPlugins(
+    './libraries/export/',
+    array(
+        'export_type' => $export_type,
+        'single_table' => isset($single_table)));
 
 // Backward compatbility
 $type = $what;
@@ -43,7 +47,7 @@ $save_on_server = false;
 $buffer_needed = false;
 
 // Is it a quick or custom export?
-if($_REQUEST['quick_or_custom'] == 'quick') {
+if ($_REQUEST['quick_or_custom'] == 'quick') {
     $quick_export = true;
 } else {
     $quick_export = false;
@@ -58,7 +62,7 @@ if ($_REQUEST['output_format'] == 'astext') {
         $buffer_needed = true;
     }
     if (($quick_export && !empty($_REQUEST['quick_export_onserver'])) || (!$quick_export && !empty($_REQUEST['onserver']))) {
-        if($quick_export) {
+        if ($quick_export) {
             $onserver = $_REQUEST['quick_export_onserver'];
         } else {
             $onserver = $_REQUEST['onserver'];
@@ -279,7 +283,7 @@ if ($asfile) {
     $extension_start_pos = strlen($filename) - strlen($export_list[$type]['extension']) - 1;
     $user_extension = substr($filename, $extension_start_pos, strlen($filename));
     $required_extension = "." . $export_list[$type]['extension'];
-    if(strtolower($user_extension) != $required_extension) {
+    if (strtolower($user_extension) != $required_extension) {
         $filename  .= $required_extension;
     }
     $mime_type  = $export_list[$type]['mime_type'];
@@ -394,9 +398,9 @@ if (!$save_on_server) {
         }
 
         // Convert the multiple select elements from an array to a string
-        if($export_type == 'server' && isset($_REQUEST['db_select'])) {
+        if ($export_type == 'server' && isset($_REQUEST['db_select'])) {
             $_REQUEST['db_select'] = implode(",", $_REQUEST['db_select']);
-        } elseif($export_type == 'database' && isset($_REQUEST['table_select'])) {
+        } elseif ($export_type == 'database' && isset($_REQUEST['table_select'])) {
             $_REQUEST['table_select'] = implode(",", $_REQUEST['table_select']);
         }
 
@@ -419,123 +423,182 @@ if (!$save_on_server) {
 // need exceptions here :-)
 do {
 
-// Add possibly some comments to export
-if (!PMA_exportHeader()) {
-    break;
-}
-
-// Will we need relation & co. setup?
-$do_relation = isset($GLOBALS[$what . '_relation']);
-$do_comments = isset($GLOBALS[$what . '_include_comments']);
-$do_mime     = isset($GLOBALS[$what . '_mime']);
-if ($do_relation || $do_comments || $do_mime) {
-    $cfgRelation = PMA_getRelationsParam();
-}
-if ($do_mime) {
-    require_once './libraries/transformations.lib.php';
-}
-
-// Include dates in export?
-$do_dates   = isset($GLOBALS[$what . '_dates']);
+    // Add possibly some comments to export
+    if (!PMA_exportHeader()) {
+        break;
+    }
 
-/**
- * Builds the dump
- */
-// Gets the number of tables if a dump of a database has been required
-if ($export_type == 'server') {
-    if (isset($db_select)) {
-        $tmp_select = implode($db_select, '|');
-        $tmp_select = '|' . $tmp_select . '|';
+    // Will we need relation & co. setup?
+    $do_relation = isset($GLOBALS[$what . '_relation']);
+    $do_comments = isset($GLOBALS[$what . '_include_comments']);
+    $do_mime     = isset($GLOBALS[$what . '_mime']);
+    if ($do_relation || $do_comments || $do_mime) {
+        $cfgRelation = PMA_getRelationsParam();
     }
-    // Walk over databases
-    foreach ($GLOBALS['pma']->databases as $current_db) {
-        if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
-            || ! isset($tmp_select)) {
-            if (!PMA_exportDBHeader($current_db)) {
-                break 2;
-            }
-            if (!PMA_exportDBCreate($current_db)) {
-                break 2;
-            }
-            if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
-                PMA_exportRoutines($current_db);
-            }
+    if ($do_mime) {
+        require_once './libraries/transformations.lib.php';
+    }
+
+    // Include dates in export?
+    $do_dates   = isset($GLOBALS[$what . '_dates']);
 
-            $tables = PMA_DBI_get_tables($current_db);
-            $views = array();
-            foreach ($tables as $table) {
-                // if this is a view, collect it for later; views must be exported
-                // after the tables
-                $is_view = PMA_Table::isView($current_db, $table);
-                if ($is_view) {
-                    $views[] = $table;
+    /**
+     * Builds the dump
+     */
+    // Gets the number of tables if a dump of a database has been required
+    if ($export_type == 'server') {
+        if (isset($db_select)) {
+            $tmp_select = implode($db_select, '|');
+            $tmp_select = '|' . $tmp_select . '|';
+        }
+        // Walk over databases
+        foreach ($GLOBALS['pma']->databases as $current_db) {
+            if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))
+                || ! isset($tmp_select)) {
+                if (!PMA_exportDBHeader($current_db)) {
+                    break 2;
                 }
-                if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-                    // for a view, export a stand-in definition of the table
-                    // to resolve view dependencies
-                    if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
-                        break 3;
-                    }
+                if (!PMA_exportDBCreate($current_db)) {
+                    break 2;
                 }
-                // if this is a view or a merge table, don't export data
-                if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($current_db, $table))) {
-                    $local_query  = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
-                    if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
-                        break 3;
+                if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
+                    PMA_exportRoutines($current_db);
+                }
+
+                $tables = PMA_DBI_get_tables($current_db);
+                $views = array();
+                foreach ($tables as $table) {
+                    // if this is a view, collect it for later; views must be exported
+                    // after the tables
+                    $is_view = PMA_Table::isView($current_db, $table);
+                    if ($is_view) {
+                        $views[] = $table;
+                    }
+                    if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                        // for a view, export a stand-in definition of the table
+                        // to resolve view dependencies
+                        if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
+                            break 3;
+                        }
+                    }
+                    // if this is a view or a merge table, don't export data
+                    if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($current_db, $table))) {
+                        $local_query  = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
+                        if (!PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
+                            break 3;
+                        }
+                    }
+                    // now export the triggers (needs to be done after the data because
+                    // triggers can modify already imported tables)
+                    if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                        if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
+                            break 2;
+                        }
                     }
                 }
-                // now export the triggers (needs to be done after the data because
-                // triggers can modify already imported tables)
-                if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-                    if (!PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
-                        break 2;
+                foreach ($views as $view) {
+                    // no data export for a view
+                    if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                        if (!PMA_exportStructure($current_db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
+                            break 3;
+                        }
                     }
                 }
+                if (!PMA_exportDBFooter($current_db)) {
+                    break 2;
+                }
             }
-            foreach ($views as $view) {
-                // no data export for a view
-                if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-                    if (!PMA_exportStructure($current_db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
-                        break 3;
-                    }
+        }
+    } elseif ($export_type == 'database') {
+        if (!PMA_exportDBHeader($db)) {
+            break;
+        }
+
+        if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
+            PMA_exportRoutines($db);
+        }
+
+        $i = 0;
+        $views = array();
+        // $tables contains the choices from the user (via $table_select)
+        foreach ($tables as $table) {
+            // if this is a view, collect it for later; views must be exported after
+            // the tables
+            $is_view = PMA_Table::isView($db, $table);
+            if ($is_view) {
+                $views[] = $table;
+            }
+            if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                // for a view, export a stand-in definition of the table
+                // to resolve view dependencies
+                if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
+                    break 2;
                 }
             }
-            if (!PMA_exportDBFooter($current_db)) {
-                break 2;
+            // if this is a view or a merge table, don't export data
+            if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($db, $table))) {
+                $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
+                if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
+                    break 2;
+                }
+            }
+            // now export the triggers (needs to be done after the data because
+            // triggers can modify already imported tables)
+            if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
+                    break 2;
+                }
+            }
+        }
+        foreach ($views as $view) {
+            // no data export for a view
+            if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
+                if (!PMA_exportStructure($db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
+                    break 2;
+                }
             }
         }
-    }
-} elseif ($export_type == 'database') {
-    if (!PMA_exportDBHeader($db)) {
-        break;
-    }
 
-    if (function_exists('PMA_exportRoutines') && strpos($GLOBALS['sql_structure_or_data'], 'structure') !== false && isset($GLOBALS['sql_procedure_function'])) {
-        PMA_exportRoutines($db);
-    }
+        if (!PMA_exportDBFooter($db)) {
+            break;
+        }
+    } else {
+        if (!PMA_exportDBHeader($db)) {
+            break;
+        }
+        // We export just one table
+        // $allrows comes from the form when "Dump all rows" has been selected
+        if ($allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
+            $add_query  = ' LIMIT '
+                        . (($limit_from > 0) ? $limit_from . ', ' : '')
+                        . $limit_to;
+        } else {
+            $add_query  = '';
+        }
 
-    $i = 0;
-    $views = array();
-    // $tables contains the choices from the user (via $table_select)
-    foreach ($tables as $table) {
-        // if this is a view, collect it for later; views must be exported after
-        // the tables
         $is_view = PMA_Table::isView($db, $table);
-        if ($is_view) {
-            $views[] = $table;
-        }
         if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-            // for a view, export a stand-in definition of the table
-            // to resolve view dependencies
-            if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'stand_in' : 'create_table', $export_type)) {
-                break 2;
+            if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'create_view' : 'create_table', $export_type)) {
+                break;
             }
         }
-        // if this is a view or a merge table, don't export data
-        if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && !($is_view || PMA_Table::isMerge($db, $table))) {
-            $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
+        // If this is an export of a single view, we have to export data;
+        // for example, a PDF report
+        // if it is a merge table, no data is exported
+        if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && ! PMA_Table::isMerge($db, $table)) {
+            if (!empty($sql_query)) {
+                // only preg_replace if needed
+                if (!empty($add_query)) {
+                    // remove trailing semicolon before adding a LIMIT
+                    $sql_query = preg_replace('%;\s*$%', '', $sql_query);
+                }
+                $local_query = $sql_query . $add_query;
+                PMA_DBI_select_db($db);
+            } else {
+                $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
+            }
             if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
-                break 2;
+                break;
             }
         }
         // now export the triggers (needs to be done after the data because
@@ -545,72 +608,13 @@ if ($export_type == 'server') {
                 break 2;
             }
         }
-    }
-    foreach ($views as $view) {
-        // no data export for a view
-        if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-            if (!PMA_exportStructure($db, $view, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'create_view', $export_type)) {
-                break 2;
-            }
-        }
-    }
-
-    if (!PMA_exportDBFooter($db)) {
-        break;
-    }
-} else {
-    if (!PMA_exportDBHeader($db)) {
-        break;
-    }
-    // We export just one table
-    // $allrows comes from the form when "Dump all rows" has been selected
-    if ($allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
-        $add_query  = ' LIMIT '
-                    . (($limit_from > 0) ? $limit_from . ', ' : '')
-                    . $limit_to;
-    } else {
-        $add_query  = '';
-    }
-
-    $is_view = PMA_Table::isView($db, $table);
-    if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-        if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, $is_view ? 'create_view' : 'create_table', $export_type)) {
+        if (!PMA_exportDBFooter($db)) {
             break;
         }
     }
-    // If this is an export of a single view, we have to export data;
-    // for example, a PDF report
-    // if it is a merge table, no data is exported
-    if (($GLOBALS[$what . '_structure_or_data'] == 'data' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') && ! PMA_Table::isMerge($db, $table)) {
-        if (!empty($sql_query)) {
-            // only preg_replace if needed
-            if (!empty($add_query)) {
-                // remove trailing semicolon before adding a LIMIT
-                $sql_query = preg_replace('%;\s*$%', '', $sql_query);
-            }
-            $local_query = $sql_query . $add_query;
-            PMA_DBI_select_db($db);
-        } else {
-            $local_query  = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
-        }
-        if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
-            break;
-        }
-    }
-    // now export the triggers (needs to be done after the data because
-    // triggers can modify already imported tables)
-    if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') {
-        if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates, 'triggers', $export_type)) {
-            break 2;
-        }
-    }
-    if (!PMA_exportDBFooter($db)) {
+    if (!PMA_exportFooter()) {
         break;
     }
-}
-if (!PMA_exportFooter()) {
-    break;
-}
 
 } while (false);
 // End of fake loop


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list