From a30554b1e4e5a0b6a048b4dfe12dfbeb45321c37 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Tue, 6 Sep 2011 21:48:05 +0200 Subject: [PATCH 1/2] use require() instead of include() when including file unconditionally --- index.php | 2 +- libraries/engines/berkeleydb.lib.php | 2 +- libraries/engines/innobase.lib.php | 2 +- libraries/engines/mrg_myisam.lib.php | 2 +- libraries/schema/Dia_Relation_Schema.class.php | 2 +- libraries/schema/Eps_Relation_Schema.class.php | 2 +- pmd_display_field.php | 2 +- pmd_pdf.php | 2 +- pmd_relation_new.php | 4 ++-- pmd_relation_upd.php | 4 ++-- pmd_save_pos.php | 2 +- schema_export.php | 4 ++-- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/index.php b/index.php index 9add876131..c8c7756b49 100644 --- a/index.php +++ b/index.php @@ -69,7 +69,7 @@ $lang_iso_code = $GLOBALS['available_languages'][$GLOBALS['lang']][1]; // start output -include './libraries/header_http.inc.php'; +require './libraries/header_http.inc.php'; ?> diff --git a/libraries/engines/berkeleydb.lib.php b/libraries/engines/berkeleydb.lib.php index 48b2ae8896..b112e2999b 100644 --- a/libraries/engines/berkeleydb.lib.php +++ b/libraries/engines/berkeleydb.lib.php @@ -7,7 +7,7 @@ /** * Load BDB class. */ -include_once './libraries/engines/bdb.lib.php'; +require_once './libraries/engines/bdb.lib.php'; /** * This is same as BDB. diff --git a/libraries/engines/innobase.lib.php b/libraries/engines/innobase.lib.php index e1262b9c92..f6269757b2 100644 --- a/libraries/engines/innobase.lib.php +++ b/libraries/engines/innobase.lib.php @@ -8,7 +8,7 @@ /** * */ -include_once './libraries/engines/innodb.lib.php'; +require_once './libraries/engines/innodb.lib.php'; /** * diff --git a/libraries/engines/mrg_myisam.lib.php b/libraries/engines/mrg_myisam.lib.php index fd25178bae..808f33a4b2 100644 --- a/libraries/engines/mrg_myisam.lib.php +++ b/libraries/engines/mrg_myisam.lib.php @@ -7,7 +7,7 @@ /** * */ -include_once './libraries/engines/merge.lib.php'; +require_once './libraries/engines/merge.lib.php'; /** * diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index 11c03ec5bb..bf34de0554 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -5,7 +5,7 @@ * @package phpMyAdmin */ -include_once "Export_Relation_Schema.class.php"; +require_once "Export_Relation_Schema.class.php"; /** * This Class inherits the XMLwriter class and diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index ffb117efff..983879f429 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -5,7 +5,7 @@ * @package phpMyAdmin */ -include_once "Export_Relation_Schema.class.php"; +require_once "Export_Relation_Schema.class.php"; /** * This Class is EPS Library and diff --git a/pmd_display_field.php b/pmd_display_field.php index 9f8291200e..f7665b89c8 100644 --- a/pmd_display_field.php +++ b/pmd_display_field.php @@ -7,7 +7,7 @@ /** * */ -include_once './libraries/pmd_common.php'; +require_once './libraries/pmd_common.php'; $table = $T; diff --git a/pmd_pdf.php b/pmd_pdf.php index 2afe131a66..f8102dae1d 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -5,7 +5,7 @@ * @package phpMyAdmin-Designer */ -include_once './libraries/pmd_common.php'; +require_once './libraries/pmd_common.php'; /** * If called directly from the designer, first save the positions diff --git a/pmd_relation_new.php b/pmd_relation_new.php index 8566d2dac4..a171658661 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -8,9 +8,9 @@ /** * */ -include_once './libraries/pmd_common.php'; +require_once './libraries/pmd_common.php'; $die_save_pos = 0; -include_once 'pmd_save_pos.php'; +require_once 'pmd_save_pos.php'; extract($_POST, EXTR_SKIP); $tables = PMA_DBI_get_tables_full($db, $T1); diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php index 7151cf7563..29bc68832b 100644 --- a/pmd_relation_upd.php +++ b/pmd_relation_upd.php @@ -8,11 +8,11 @@ /** * */ -include_once './libraries/pmd_common.php'; +require_once './libraries/pmd_common.php'; extract($_POST, EXTR_SKIP); extract($_GET, EXTR_SKIP); $die_save_pos = 0; -include_once 'pmd_save_pos.php'; +require_once 'pmd_save_pos.php'; list($DB1,$T1) = explode(".",$T1); list($DB2,$T2) = explode(".",$T2); diff --git a/pmd_save_pos.php b/pmd_save_pos.php index 1a071aff8c..ac7d53366a 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -8,7 +8,7 @@ /** * */ -include_once './libraries/pmd_common.php'; +require_once './libraries/pmd_common.php'; $cfgRelation = PMA_getRelationsParam(); diff --git a/schema_export.php b/schema_export.php index 30384e861e..e566c7c416 100644 --- a/schema_export.php +++ b/schema_export.php @@ -21,7 +21,7 @@ $cfgRelation = PMA_getRelationsParam(); require_once './libraries/transformations.lib.php'; require_once './libraries/Index.class.php'; -include_once "./libraries/schema/Export_Relation_Schema.class.php"; +require_once "./libraries/schema/Export_Relation_Schema.class.php"; /** * get all the export options and verify @@ -38,5 +38,5 @@ $path = PMA_securePath(ucfirst($export_type)); if (!file_exists('./libraries/schema/' . $path . '_Relation_Schema.class.php')) { PMA_Export_Relation_Schema::dieSchema($_POST['chpage'],$export_type,__('File doesn\'t exist')); } -include "./libraries/schema/".$path."_Relation_Schema.class.php"; +require "./libraries/schema/".$path."_Relation_Schema.class.php"; $obj_schema = eval("new PMA_".$path."_Relation_Schema();"); From 87459a5cf6b7c640c8a19cbd70575424420850f7 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Tue, 6 Sep 2011 22:04:51 +0200 Subject: [PATCH 2/2] use include() instead of require() when including file conditionally --- export.php | 42 +++++++++++------------ gis_data_editor.php | 4 +-- import.php | 16 ++++----- libraries/Advisor.class.php | 2 +- libraries/auth/config.auth.lib.php | 6 ++-- libraries/auth/cookie.auth.lib.php | 14 ++++---- libraries/auth/http.auth.lib.php | 6 ++-- libraries/auth/signon.auth.lib.php | 2 +- libraries/auth/swekey/swekey.auth.lib.php | 4 +-- libraries/charset_conversion.lib.php | 2 +- libraries/common.inc.php | 34 +++++++++--------- libraries/config/ConfigFile.class.php | 8 ++--- libraries/core.lib.php | 4 +-- 13 files changed, 72 insertions(+), 72 deletions(-) diff --git a/export.php b/export.php index e26427d536..b82ef99233 100644 --- a/export.php +++ b/export.php @@ -75,16 +75,16 @@ if ($_REQUEST['output_format'] == 'astext') { // Does export require to be into file? if (isset($export_list[$type]['force_file']) && ! $asfile) { $message = PMA_Message::error(__('Selected export type has to be saved in file!')); - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; - require './server_export.php'; + include './server_export.php'; } elseif ($export_type == 'database') { $active_page = 'db_export.php'; - require './db_export.php'; + include './db_export.php'; } else { $active_page = 'tbl_export.php'; - require './tbl_export.php'; + include './tbl_export.php'; } exit(); } @@ -318,16 +318,16 @@ if ($save_on_server) { } } if (isset($message)) { - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; - require './server_export.php'; + include './server_export.php'; } elseif ($export_type == 'database') { $active_page = 'db_export.php'; - require './db_export.php'; + include './db_export.php'; } else { $active_page = 'tbl_export.php'; - require './tbl_export.php'; + include './tbl_export.php'; } exit(); } @@ -352,14 +352,14 @@ if (!$save_on_server) { $num_tables = count($tables); if ($num_tables == 0) { $message = PMA_Message::error(__('No tables found in database.')); - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; $active_page = 'db_export.php'; - require './db_export.php'; + include './db_export.php'; exit(); } } $backup_cfgServer = $cfg['Server']; - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; $cfg['Server'] = $backup_cfgServer; unset($backup_cfgServer); echo "\n" . '
' . "\n"; @@ -416,7 +416,7 @@ do { $cfgRelation = PMA_getRelationsParam(); } if ($do_mime) { - require_once './libraries/transformations.lib.php'; + include_once './libraries/transformations.lib.php'; } // Include dates in export? @@ -600,16 +600,16 @@ do { // End of fake loop if ($save_on_server && isset($message)) { - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; - require './server_export.php'; + include './server_export.php'; } elseif ($export_type == 'database') { $active_page = 'db_export.php'; - require './db_export.php'; + include './db_export.php'; } else { $active_page = 'tbl_export.php'; - require './tbl_export.php'; + include './tbl_export.php'; } exit(); } @@ -654,16 +654,16 @@ if (!empty($asfile)) { $message = new PMA_Message(__('Dump has been saved to file %s.'), PMA_Message::SUCCESS, $save_filename); } - require_once './libraries/header.inc.php'; + include_once './libraries/header.inc.php'; if ($export_type == 'server') { $active_page = 'server_export.php'; - require_once './server_export.php'; + include_once './server_export.php'; } elseif ($export_type == 'database') { $active_page = 'db_export.php'; - require_once './db_export.php'; + include_once './db_export.php'; } else { $active_page = 'tbl_export.php'; - require_once './tbl_export.php'; + include_once './tbl_export.php'; } exit(); } else { @@ -704,6 +704,6 @@ if (!empty($asfile)) { //]]> diff --git a/gis_data_editor.php b/gis_data_editor.php index fde183d997..d9db06f004 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -1,8 +1,8 @@ addParam('[a@./Documentation.html#faq1_16@_blank]'); $message->addParam('[/a]'); @@ -63,7 +63,7 @@ if ($_POST == array() && $_GET == array()) { $_SESSION['Import_message']['go_back_url'] = $goto; $message->display(); - require './libraries/footer.inc.php'; + include './libraries/footer.inc.php'; } // Check needed parameters @@ -148,7 +148,7 @@ $bookmark_created = false; // Bookmark Support: get a query back from bookmark if required if (!empty($id_bookmark)) { $id_bookmark = (int)$id_bookmark; - require_once './libraries/bookmark.lib.php'; + include_once './libraries/bookmark.lib.php'; switch ($action_bookmark) { case 0: // bookmarked query that have to be run $import_text = PMA_Bookmark_get($db, $id_bookmark, 'id', isset($action_bookmark_all)); @@ -183,7 +183,7 @@ if (isset($GLOBALS['show_as_php'])) { // Store the query as a bookmark before executing it if bookmarklabel was given if (!empty($bkm_label) && !empty($import_text)) { - require_once './libraries/bookmark.lib.php'; + include_once './libraries/bookmark.lib.php'; $bfields = array( 'dbase' => $db, 'user' => $cfg['Bookmark']['user'], @@ -377,7 +377,7 @@ if (!$error) { } else { // Do the real import $plugin_param = $import_type; - require './libraries/import/' . $format . '.php'; + include './libraries/import/' . $format . '.php'; } } @@ -441,7 +441,7 @@ if (isset($message)) { // (but if the query is too large, in case of an imported file, the parser // can choke on it so avoid parsing) if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { - require_once './libraries/parse_analyze.lib.php'; + include_once './libraries/parse_analyze.lib.php'; } // There was an error? @@ -461,10 +461,10 @@ if (! empty($last_query_with_results)) { } if ($go_sql) { - require './sql.php'; + include './sql.php'; } else { $active_page = $goto; - require './' . $goto; + include './' . $goto; } exit(); ?> diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index bf4e404e51..533fe8811b 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -28,7 +28,7 @@ class Advisor FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1)); } // Add total memory to variables as well - require_once 'libraries/sysinfo.lib.php'; + include_once 'libraries/sysinfo.lib.php'; $sysinfo = getSysInfo(); $memory = $sysinfo->memory(); $this->variables['system_memory'] = $memory['MemTotal']; diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index e90e0bf795..573bede0df 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -75,7 +75,7 @@ function PMA_auth_fails() header('Content-Type: text/html; charset=utf-8'); /* HTML header */ $page_title = __('Access denied'); - require './libraries/header_meta_style.inc.php'; + include './libraries/header_meta_style.inc.php'; ?> @@ -117,7 +117,7 @@ function PMA_auth_fails() 1) { // offer a chance to login to other servers if the current one failed - require_once './libraries/select_server.lib.php'; + include_once './libraries/select_server.lib.php'; echo '' . "\n"; echo ' ' . "\n"; PMA_select_server(true, true); @@ -125,7 +125,7 @@ function PMA_auth_fails() echo '' . "\n"; } echo '' . "\n"; - require './libraries/footer.inc.php'; + include './libraries/footer.inc.php'; return true; } // end of the 'PMA_auth_fails()' function diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 2a3f7c1ff7..b19646154c 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -73,7 +73,7 @@ if (function_exists('mcrypt_encrypt')) { } } else { - require_once './libraries/blowfish.php'; + include_once './libraries/blowfish.php'; } /** @@ -137,9 +137,9 @@ function PMA_auth() /* HTML header; do not show here the PMA version to improve security */ $page_title = 'phpMyAdmin '; - require './libraries/header_meta_style.inc.php'; + include './libraries/header_meta_style.inc.php'; // if $page_title is set, this script uses it as the title: - require './libraries/header_scripts.inc.php'; + include './libraries/header_scripts.inc.php'; ?>