From d3f84bca94839922bf31ac6d2294243fb27a4558 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Thu, 20 Nov 2003 10:34:35 +0000 Subject: [PATCH] First batch of PHP4/MySQL compatibility/performance changes. Everything should be non-intrusive for installations meeting our new 4.1.0/3.23.32 specs. I will commit my files every now and then for easier code review and to let you see which constructs I replace. Jump in if there are any objections. The basic thing I'm doing is documented in the changelog. I'll continue with files in the libraries/ subdirectory and will move to the root-level files in last instance. --- ChangeLog | 14 ++ libraries/auth/cookie.auth.lib.php | 92 +++----- libraries/auth/http.auth.lib.php | 24 --- libraries/dbg/profiling.php | 9 +- libraries/dbg/setup.php | 18 +- libraries/export/latex.php | 7 +- libraries/export/sql.php | 336 +++++++---------------------- 7 files changed, 132 insertions(+), 368 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08502a35c..50dca3fb4 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,20 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-11-20 Garvin Hicking + * libraries/auth/*, libraries/dbg/*, libraries/export/* + (work in progress) + + Lots of PHP < 4.1.0 / MySQL < 3.23.32 compatibility/performance changes: + - Replaced "while (list() = each())" calls by foreach loops. + - Removed PHP3-compatibility code + - Removed calls to $HTTP_*_VARS (using $_* now). + - Replaced some TAB-characters with whitespace + - Removed PHP4 < 4.1.0 compatibility code + - Replaced "for ($i=0; $i <= count(); $i++)" loops to + "$cnt = count(); for ($i=0; $i <= $cnt; $i++)" structures for better + performance + 2003-11-19 Marc Delisle * libraries/display_tbl.lib.php: first group of headers was offset by one column to the left diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 83a82ea7f..7fb715fb7 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -16,17 +16,6 @@ if (!defined('PMA_COOKIE_AUTH_INCLUDED')) { if (!isset($coming_from_common)) { exit(); } - // emulate array_values() for PHP 3 -// if (PMA_PHP_INT_VERSION < 40000) { - if (!@function_exists('array_values')) { - function array_values ($arr) { - $t = array(); - while (list($k, $v) = each ($arr)) { - $t[] = $v; - } - return $t; - } // end function - } // end if include('./libraries/blowfish.php'); @@ -40,7 +29,7 @@ if (!defined('PMA_COOKIE_AUTH_INCLUDED')) { /** * String padding * - * @param string input string + * @param string input string * @param integer length of the result * @param string the filling string * @param integer padding mode @@ -80,18 +69,18 @@ if (!defined('PMA_COOKIE_AUTH_INCLUDED')) { * * @author lem9 */ -function PMA_blowfish_encrypt($data, $secret) { - $pma_cipher = new Horde_Cipher_blowfish; - $encrypt = ''; - for ($i=0; $iencryptBlock($block, $secret); } - $encrypt .= $pma_cipher->encryptBlock($block, $secret); - } - return $encrypt; -} + return $encrypt; + } /** * Decryption using blowfish algorithm @@ -105,14 +94,14 @@ function PMA_blowfish_encrypt($data, $secret) { * * @author lem9 */ -function PMA_blowfish_decrypt($data, $secret) { - $pma_cipher = new Horde_Cipher_blowfish; - $decrypt = ''; - for ($i=0; $idecryptBlock(substr($data, $i, 8), $secret); - } - return trim($decrypt); -} + function PMA_blowfish_decrypt($data, $secret) { + $pma_cipher = new Horde_Cipher_blowfish; + $decrypt = ''; + for ($i=0; $idecryptBlock(substr($data, $i, 8), $secret); + } + return trim($decrypt); + } /** * Sorts available languages by their true names @@ -154,7 +143,6 @@ function PMA_blowfish_decrypt($data, $secret) { global $cfg, $available_languages; global $lang, $server, $convcharset; global $conn_error; - global $HTTP_COOKIE_VARS; // Tries to get the username from cookie whatever are the values of the // 'register_globals' and the 'variables_order' directives if last login @@ -167,13 +155,11 @@ function PMA_blowfish_decrypt($data, $secret) { else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_username'])) { $default_user = $_COOKIE['pma_cookie_username']; } - else if (!empty($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS['pma_cookie_username'])) { - $default_user = $HTTP_COOKIE_VARS['pma_cookie_username']; - } + if (isset($default_user) && get_magic_quotes_gpc()) { $default_user = stripslashes($default_user); } - + // server name if (!empty($GLOBALS['pma_cookie_servername'])) { $default_server = $GLOBALS['pma_cookie_servername']; @@ -181,9 +167,6 @@ function PMA_blowfish_decrypt($data, $secret) { else if (!empty($_COOKIE) && isset($_COOKIE['pma_cookie_servername'])) { $default_server = $_COOKIE['pma_cookie_servername']; } - else if (!empty($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS['pma_cookie_servername'])) { - $default_server = $HTTP_COOKIE_VARS['pma_cookie_servername']; - } if (isset($default_server) && get_magic_quotes_gpc()) { $default_server = stripslashes($default_server); } @@ -242,8 +225,7 @@ input.textfield {font-family: ; font-size: $tmplang) { $lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1)); if ($lang == $id) { $selected = ' selected="selected"'; @@ -317,8 +299,7 @@ input.textfield {font-family: ; font-size: $val) { if (!empty($val['host']) || $val['auth_type'] == 'arbitrary') { echo '