Skip to content

Commit

Permalink
Replace ereg functions with preg functions for OSC-999
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Evans authored and haraldpdl committed Sep 10, 2009
1 parent 5988880 commit 79c601a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions catalog/admin/backup.php
Expand Up @@ -63,7 +63,7 @@
$schema .= ',' . "\n";
}

$schema = ereg_replace(",\n$", '', $schema);
$schema = preg_replace("/,\n$/", '', $schema);

// add the keys
$index = array();
Expand Down Expand Up @@ -111,15 +111,15 @@
$schema .= 'NULL, ';
} elseif (tep_not_null($rows[$i])) {
$row = addslashes($rows[$i]);
$row = ereg_replace("\n#", "\n".'\#', $row);
$row = preg_replace("/\n#/", "\n".'\#', $row);

$schema .= '\'' . $row . '\', ';
} else {
$schema .= '\'\', ';
}
}

$schema = ereg_replace(', $', '', $schema) . ');' . "\n";
$schema = preg_replace('/, $/', '', $schema) . ');' . "\n";
fputs($fp, $schema);
}
}
Expand Down
4 changes: 2 additions & 2 deletions catalog/admin/cache.php
Expand Up @@ -80,7 +80,7 @@
}

for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {
$cached_file = ereg_replace('-language', '-' . $language, $cache_blocks[$i]['file']);
$cached_file = preg_replace('/-language/', '-' . $language, $cache_blocks[$i]['file']);

if (file_exists(DIR_FS_CACHE . $cached_file)) {
$cache_mtime = strftime(DATE_TIME_FORMAT, filemtime(DIR_FS_CACHE . $cached_file));
Expand All @@ -89,7 +89,7 @@
$dir = dir(DIR_FS_CACHE);

while ($cache_file = $dir->read()) {
$cached_file = ereg_replace('-language', '-' . $language, $cache_blocks[$i]['file']);
$cached_file = preg_replace('/-language/', '-' . $language, $cache_blocks[$i]['file']);

if (ereg('^' . $cached_file, $cache_file)) {
$cache_mtime = strftime(DATE_TIME_FORMAT, filemtime(DIR_FS_CACHE . $cache_file));
Expand Down
2 changes: 1 addition & 1 deletion catalog/admin/includes/classes/phplot.php
Expand Up @@ -674,7 +674,7 @@ function DrawText($which_font,$which_angle,$which_xpos,$which_ypos,$which_color,
if ($which_valign == 'top') {
$which_ypos = $which_ypos - ImageFontHeight($which_font);
}
$which_text = ereg_replace("\r","",$which_text);
$which_text = preg_replace("/\r/","",$which_text);
$str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
$height = ImageFontHeight($which_font);
$width = ImageFontWidth($which_font);
Expand Down
14 changes: 7 additions & 7 deletions catalog/admin/includes/functions/general.php
Expand Up @@ -52,9 +52,9 @@ function tep_output_string_protected($string) {
}

function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', $string);

return preg_replace("/[<>]/", '_', $string);
$patterns = array ('/ +/','/[<>]/');
$replace = array (' ', '_');
return preg_replace($patterns, $replace, trim($string));
}

function tep_customers_name($customers_id) {
Expand Down Expand Up @@ -146,7 +146,7 @@ function tep_date_short($raw_date) {
if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
} else {
return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
return preg_replace('/2037/' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
}

}
Expand Down Expand Up @@ -938,7 +938,7 @@ function tep_reset_cache_block($cache_block) {
$cached_file = $cache_blocks[$i]['file'];
$languages = tep_get_languages();
for ($j=0, $k=sizeof($languages); $j<$k; $j++) {
$cached_file_unlink = ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file);
$cached_file_unlink = preg_replace('/-language/', '-' . $languages[$j]['directory'], $cached_file);
if (ereg('^' . $cached_file_unlink, $cache_file)) {
@unlink(DIR_FS_CACHE . $cache_file);
}
Expand All @@ -950,7 +950,7 @@ function tep_reset_cache_block($cache_block) {
$cached_file = $cache_blocks[$i]['file'];
$languages = tep_get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
$cached_file = ereg_replace('-language', '-' . $languages[$i]['directory'], $cached_file);
$cached_file = preg_replace('/-language/', '-' . $languages[$i]['directory'], $cached_file);
@unlink(DIR_FS_CACHE . $cached_file);
}
}
Expand Down Expand Up @@ -1276,7 +1276,7 @@ function tep_rand($min = null, $max = null) {
// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)
function tep_convert_linefeeds($from, $to, $string) {
if ((PHP_VERSION < "4.0.5") && is_array($from)) {
return ereg_replace('(' . implode('|', $from) . ')', $to, $string);
return preg_replace('/(' . implode('|', $from) . ')/', $to, $string);
} else {
return str_replace($from, $to, $string);
}
Expand Down
2 changes: 1 addition & 1 deletion catalog/includes/classes/cc_validation.php
Expand Up @@ -14,7 +14,7 @@ class cc_validation {
var $cc_type, $cc_number, $cc_expiry_month, $cc_expiry_year;

function validate($number, $expiry_m, $expiry_y) {
$this->cc_number = ereg_replace('[^0-9]', '', $number);
$this->cc_number = preg_replace('/[^0-9]/', '', $number);

if (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number)) {
$this->cc_type = 'Visa';
Expand Down
14 changes: 7 additions & 7 deletions catalog/includes/functions/general.php
Expand Up @@ -58,9 +58,9 @@ function tep_output_string_protected($string) {
}

function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);
$patterns = array ('/ +/','/[<>]/');
$replace = array (' ', '_');
return preg_replace($patterns, $replace, trim($string));
}

////
Expand Down Expand Up @@ -584,7 +584,7 @@ function tep_date_short($raw_date) {
if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
} else {
return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
return preg_replace('/2037/' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
}
}

Expand Down Expand Up @@ -635,7 +635,7 @@ function tep_parse_search_string($search_str = '', &$objects) {
*/

// Add this word to the $tmpstring, starting the $tmpstring
$tmpstring = trim(ereg_replace('"', ' ', $pieces[$k]));
$tmpstring = trim(preg_replace('/"/', ' ', $pieces[$k]));

// Check for one possible exception to the rule. That there is a single quoted word.
if (substr($pieces[$k], -1 ) == '"') {
Expand Down Expand Up @@ -685,7 +685,7 @@ function tep_parse_search_string($search_str = '', &$objects) {
$piece onto the tail of the string, push the $tmpstring onto the $haves,
kill the $tmpstring, turn the $flag "off", and return.
*/
$tmpstring .= ' ' . trim(ereg_replace('"', ' ', $pieces[$k]));
$tmpstring .= ' ' . trim(preg_replace('/"/', ' ', $pieces[$k]));

// Push the $tmpstring onto the array of stuff to search for
$objects[] = trim($tmpstring);
Expand Down Expand Up @@ -1300,7 +1300,7 @@ function tep_count_customer_address_book_entries($id = '', $check_session = true
// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)
function tep_convert_linefeeds($from, $to, $string) {
if ((PHP_VERSION < "4.0.5") && is_array($from)) {
return ereg_replace('(' . implode('|', $from) . ')', $to, $string);
return preg_replace('/(' . implode('|', $from) . ')/', $to, $string);
} else {
return str_replace($from, $to, $string);
}
Expand Down
2 changes: 1 addition & 1 deletion catalog/includes/modules/payment/sage_pay_direct.php
Expand Up @@ -157,7 +157,7 @@ function before_process() {
} else {
$cc_type = substr($HTTP_POST_VARS['cc_type'], 0, 15);
$cc_owner = substr($HTTP_POST_VARS['cc_owner'], 0, 50);
$cc_number = substr(ereg_replace('[^0-9]', '', $HTTP_POST_VARS['cc_number_nh-dns']), 0, 20);
$cc_number = substr(preg_replace('/[^0-9]/', '', $HTTP_POST_VARS['cc_number_nh-dns']), 0, 20);
$cc_start = null;
$cc_expires = null;
$cc_issue = null;
Expand Down

0 comments on commit 79c601a

Please sign in to comment.