Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some performance improvement

  • Loading branch information...
commit 92600b51c65709c29a904ab45d3feb33360d34c7 1 parent 9afe4c6
@acidvertigo acidvertigo authored
View
8 catalog/admin/includes/classes/language.php
@@ -79,11 +79,11 @@ function set_language($language) {
}
function get_browser_language() {
- $this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));
+ $this->browser_languages = explode(',', $_ENV['HTTP_ACCEPT_LANGUAGE']);
- for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {
- reset($this->languages);
- while (list($key, $value) = each($this->languages)) {
+ $n=sizeof($this->browser_languages);
+ for ($i=0; $i<$n; $i++) {
+ foreach ($this->languages as $key => $value) {
if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
$this->language = $this->catalog_languages[$key];
break 2;
View
3  catalog/admin/includes/classes/message_stack.php
@@ -26,7 +26,8 @@ function messageStack() {
$this->errors = array();
if (tep_session_is_registered('messageToStack')) {
- for ($i = 0, $n = sizeof($messageToStack); $i < $n; $i++) {
+ $n = sizeof($messageToStack);
+ for ($i = 0; $i < $n; $i++) {
$this->add($messageToStack[$i]['text'], $messageToStack[$i]['type']);
}
tep_session_unregister('messageToStack');
View
9 catalog/admin/includes/classes/mime.php
@@ -48,8 +48,7 @@ function mime($body, $params = '') {
$this->lf = "\n";
}
- reset($params);
- while (list($key, $value) = each($params)) {
+ foreach ($params as $key => $value) {
switch ($key) {
case 'content_type':
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
@@ -119,15 +118,15 @@ function encode() {
$this->_headers['Content-Type'] .= ';' . $this->lf . chr(9) . 'boundary="' . $boundary . '"';
// Add body parts to $subparts
- for ($i=0; $i<count($this->_subparts); $i++) {
+ $n2=count($this->_subparts);
+ for ($i=0; $i<$n2; $i++) {
$headers = array();
/* HPDL PHP3 */
// $tmp = $this->_subparts[$i]->encode();
$_subparts = $this->_subparts[$i];
$tmp = $_subparts->encode();
- reset($tmp['headers']);
- while (list($key, $value) = each($tmp['headers'])) {
+ foreach ($tmp['headers'] as $key => $value) {
$headers[] = $key . ': ' . $value;
}
View
3  catalog/admin/includes/classes/object_info.php
@@ -14,8 +14,7 @@ class objectInfo {
// class constructor
function objectInfo($object_array) {
- reset($object_array);
- while (list($key, $value) = each($object_array)) {
+ foreach ($object_array as $key => $value) {
$this->$key = tep_db_prepare_input($value);
}
}
View
3  catalog/admin/includes/classes/payment_module_info.php
@@ -6,7 +6,8 @@ class paymentModuleInfo {
function paymentModuleInfo($pmInfo_array) {
$this->payment_code = $pmInfo_array['payment_code'];
- for ($i = 0, $n = sizeof($pmInfo_array) - 1; $i < $n; $i++) {
+ $n = sizeof($pmInfo_array) - 1;
+ for ($i = 0; $i < $n; $i++) {
$key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description from " . TABLE_CONFIGURATION . " where configuration_key = '" . $pmInfo_array[$i] . "'");
$key_value = tep_db_fetch_array($key_value_query);
View
17 catalog/admin/includes/classes/shopping_cart.php
@@ -31,8 +31,7 @@ function restore_contents() {
if (!tep_db_num_rows($product_query)) {
tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')");
if ($this->contents[$products_id]['attributes']) {
- reset($this->contents[$products_id]['attributes']);
- while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
+ foreach ($this->contents[$products_id]['attributes'] as $option => $value ) {
tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
}
}
@@ -86,8 +85,7 @@ function add_cart($products_id, $qty = '', $attributes = '') {
if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')");
if (is_array($attributes)) {
- reset($attributes);
- while (list($option, $value) = each($attributes)) {
+ foreach ($attributes as $option => $value) {
$this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
@@ -109,8 +107,7 @@ function update_quantity($products_id, $quantity = '', $attributes = '') {
if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($quantity) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
if (is_array($attributes)) {
- reset($attributes);
- while (list($option, $value) = each($attributes)) {
+ foreach ($attributes as $option => $value) {
$this->contents[$products_id]['attributes'][$option] = $value;
// update database
if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
@@ -217,9 +214,8 @@ function calculate() {
// attributes price
if (isset($this->contents[$products_id]['attributes'])) {
- reset($this->contents[$products_id]['attributes']);
- while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
- $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
+ foreach ($this->contents[$products_id]['attributes'] as $option => $value) {
+ $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
@@ -235,8 +231,7 @@ function attributes_price($products_id) {
$attributes_price = 0;
if (isset($this->contents[$products_id]['attributes'])) {
- reset($this->contents[$products_id]['attributes']);
- while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
+ foreach ($this->contents[$products_id]['attributes'] as $option => $value) {
$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
$attribute_price = tep_db_fetch_array($attribute_price_query);
if ($attribute_price['price_prefix'] == '+') {
View
7 catalog/admin/includes/classes/split_page_results.php
@@ -39,7 +39,6 @@ function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query
}
function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '', $page_name = 'page') {
- global $PHP_SELF;
if ( tep_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&';
@@ -52,10 +51,10 @@ function display_links($query_numrows, $max_rows_per_page, $max_page_links, $cur
}
if ($num_pages > 1) {
- $display_links = tep_draw_form('pages', basename($PHP_SELF), '', 'get');
+ $display_links = tep_draw_form('pages', basename($_SERVER['PHP_SELF']), '', 'get');
if ($current_page_number > 1) {
- $display_links .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $page_name . '=' . ($current_page_number - 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_PREV . '</a>&nbsp;&nbsp;';
+ $display_links .= '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page_name . '=' . ($current_page_number - 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_PREV . '</a>&nbsp;&nbsp;';
} else {
$display_links .= PREVNEXT_BUTTON_PREV . '&nbsp;&nbsp;';
}
@@ -63,7 +62,7 @@ function display_links($query_numrows, $max_rows_per_page, $max_page_links, $cur
$display_links .= sprintf(TEXT_RESULT_PAGE, tep_draw_pull_down_menu($page_name, $pages_array, $current_page_number, 'onchange="this.form.submit();"'), $num_pages);
if (($current_page_number < $num_pages) && ($num_pages != 1)) {
- $display_links .= '&nbsp;&nbsp;<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $page_name . '=' . ($current_page_number + 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_NEXT . '</a>';
+ $display_links .= '&nbsp;&nbsp;<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page_name . '=' . ($current_page_number + 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_NEXT . '</a>';
} else {
$display_links .= '&nbsp;&nbsp;' . PREVNEXT_BUTTON_NEXT;
}
View
6 catalog/admin/includes/classes/table_block.php
@@ -33,14 +33,16 @@ function tableBlock($contents) {
if (tep_not_null($this->table_parameters)) $tableBox_string .= ' ' . $this->table_parameters;
$tableBox_string .= '>' . "\n";
- for ($i=0, $n=sizeof($contents); $i<$n; $i++) {
+ $n=sizeof($contents);
+ for ($i=0; $i<$n; $i++) {
$tableBox_string .= ' <tr';
if (tep_not_null($this->table_row_parameters)) $tableBox_string .= ' ' . $this->table_row_parameters;
if (isset($contents[$i]['params']) && tep_not_null($contents[$i]['params'])) $tableBox_string .= ' ' . $contents[$i]['params'];
$tableBox_string .= '>' . "\n";
if (isset($contents[$i][0]) && is_array($contents[$i][0])) {
- for ($x=0, $y=sizeof($contents[$i]); $x<$y; $x++) {
+ $y=sizeof($contents[$i]);
+ for ($x=0; $x<$y; $x++) {
if (isset($contents[$i][$x]['text']) && tep_not_null($contents[$i][$x]['text'])) {
$tableBox_string .= ' <td';
if (isset($contents[$i][$x]['align']) && tep_not_null($contents[$i][$x]['align'])) $tableBox_string .= ' align="' . $contents[$i][$x]['align'] . '"';
View
12 catalog/admin/includes/classes/upload.php
@@ -33,7 +33,7 @@ function upload($file = '', $destination = '', $permissions = '777', $extensions
}
function parse() {
- global $HTTP_POST_FILES, $messageStack;
+ global $messageStack;
$file = array();
@@ -42,11 +42,11 @@ function parse() {
'type' => $_FILES[$this->file]['type'],
'size' => $_FILES[$this->file]['size'],
'tmp_name' => $_FILES[$this->file]['tmp_name']);
- } elseif (isset($HTTP_POST_FILES[$this->file])) {
- $file = array('name' => $HTTP_POST_FILES[$this->file]['name'],
- 'type' => $HTTP_POST_FILES[$this->file]['type'],
- 'size' => $HTTP_POST_FILES[$this->file]['size'],
- 'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']);
+ } elseif (isset($_POST[$this->file])) {
+ $file = array('name' => $_POST[$this->file]['name'],
+ 'type' => $_POST[$this->file]['type'],
+ 'size' => $_POST[$this->file]['size'],
+ 'tmp_name' => $_POST[$this->file]['tmp_name']);
}
if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) {
View
2  catalog/includes/application_bottom.php
@@ -17,7 +17,7 @@
$time_start = explode(' ', PAGE_PARSE_START_TIME);
$time_end = explode(' ', microtime());
$parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
- error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . getenv('REQUEST_URI') . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
+ error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . $_ENV['REQUEST_URI'] . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
if (DISPLAY_PAGE_PARSE_TIME == 'true') {
echo '<span class="smallText">Parse Time: ' . $parse_time . 's</span>';
Please sign in to comment.
Something went wrong with that request. Please try again.