Skip to content

Commit

Permalink
all MDL-20821 Removed ereg related deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Davis committed Nov 18, 2009
1 parent 4dadad0 commit 76561f1
Show file tree
Hide file tree
Showing 70 changed files with 1,393 additions and 310 deletions.
4 changes: 2 additions & 2 deletions admin/fixuserpix.php
Expand Up @@ -252,9 +252,9 @@ function definition_after_data() {
function arguments($argv) {
$_ARG = array();
foreach ($argv as $arg) {
if (ereg('--?([^=]+)=(.*)',$arg,$reg)) {
if (preg_match('/--?([^=]+)=(.*)/',$arg,$reg)) {
$_ARG[$reg[1]] = $reg[2];
} elseif(ereg('-([a-zA-Z0-9]+)',$arg,$reg)) {
} elseif(preg_match('/-([a-zA-Z0-9]+)/',$arg,$reg)) {
$_ARG[$reg[1]] = 'true';
}
}
Expand Down
10 changes: 5 additions & 5 deletions admin/mnet/MethodTable.php
Expand Up @@ -465,15 +465,15 @@ function cleanArguments($args, $commentParams){
$word0 = strtolower($word0);
$word1 = strtolower($word1);

$wordBase0 = ereg_replace('^[&$]+','',$word0);
$wordBase1 = ereg_replace('^[&$]+','',$word1);
$startBase = strtolower(ereg_replace('^[&$]+','',$start));
$wordBase0 = preg_replace('/^[&$]+/','',$word0);
$wordBase1 = preg_replace('/^[&$]+/','',$word1);
$startBase = strtolower(preg_replace('/^[&$]+/','',$start));

if ($wordBase0 == $startBase) {
$type = str_replace(array('(',')'),'', $word1);
} elseif($wordBase1 == $startBase) {
$type = str_replace(array('(',')'),'', $word0);
} elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
} elseif( preg_match('/(^[&$]+)|(\()([a-z0-9]+)(\)$)/', $word0, $regs) ) {
$tail = str_ireplace($word0, '', $end);
$type = $regs[3];
} else {
Expand Down Expand Up @@ -535,7 +535,7 @@ function cleanComment($comment){
$comment = str_replace("*/", "", $comment);
$comment = str_replace("*", "", $comment);
$comment = str_replace("\n", "\\n", trim($comment));
$comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
$comment = preg_replace("/[\r\t\n ]+/i", " ", trim($comment));
$comment = str_replace("\"", "\\\"", $comment);
return $comment;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/uploaduser.php
Expand Up @@ -260,7 +260,7 @@
// normalize username
$user->username = $textlib->strtolower($user->username);
if (empty($CFG->extendedusernamechars)) {
$user->username = eregi_replace('[^(-\.[:alnum:])]', '', $user->username);
$user->username = preg_replace('/[^(-\.[:alnum:])]/i', '', $user->username);
}
if (empty($user->username)) {
$upt->track('status', get_string('missingfield', 'error', 'username'), 'error');
Expand Down
2 changes: 1 addition & 1 deletion auth/shibboleth/auth.php
Expand Up @@ -63,7 +63,7 @@ function user_login($username, $password) {
} else {
// Try to find out using the user's cookie
foreach ($_COOKIE as $name => $value){
if (eregi('_shibsession_', $name)){
if (preg_match('/_shibsession_/i', $name)){
$sessionkey = $value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion auth/shibboleth/logout.php
Expand Up @@ -139,7 +139,7 @@ function LogoutNotification($SessionID){
while (($file = readdir($dh)) !== false) {
// Check if it is a file
if (is_file($dir.'/'.$file)){
$session_key = ereg_replace('sess_', '', $file);
$session_key = preg_replace('/sess_/', '', $file);

// Read session file data
$data = file($dir.'/'.$file);
Expand Down
4 changes: 2 additions & 2 deletions calendar/lib.php
Expand Up @@ -766,8 +766,8 @@ function calendar_top_controls($type, $data) {
$text = get_string('strftimedaydate');
/*
// Regexp hackery to make a link out of the month/year part
$text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = preg_replace('/(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
$text = preg_replace('/(F.+Y|Y.+F|Y.+m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
*/
// Replace with actual values and lose any day leading zero
$text = userdate($time, $text);
Expand Down
22 changes: 11 additions & 11 deletions enrol/authorize/enrol_form.php
Expand Up @@ -246,7 +246,7 @@ function other_method_available($currentmethod)

function validate_aba($aba)
{
if (ereg("^[0-9]{9}$", $aba)) {
if (preg_match("/^[0-9]{9}$/", $aba)) {
$n = 0;
for($i = 0; $i < 9; $i += 3) {
$n += (substr($aba, $i, 1) * 3) + (substr($aba, $i + 1, 1) * 7) + (substr($aba, $i + 2, 1));
Expand Down Expand Up @@ -276,45 +276,45 @@ function validate_cc($Num, $Name = "n/a", $Exp = "")
$GoodCard = true;

// Get rid of any non-digits
$Num = ereg_replace("[^0-9]", "", $Num);
$Num = preg_replace("/[^0-9]/", "", $Num);

// Perform card-specific checks, if applicable
switch ($Name)
{
case "mcd" :
$GoodCard = ereg("^5[1-5].{14}$", $Num);
$GoodCard = preg_match("/^5[1-5].{14}$/", $Num);
break;

case "vis" :
$GoodCard = ereg("^4.{15}$|^4.{12}$", $Num);
$GoodCard = preg_match("/^4.{15}$|^4.{12}$/", $Num);
break;

case "amx" :
$GoodCard = ereg("^3[47].{13}$", $Num);
$GoodCard = preg_match("/^3[47].{13}$/", $Num);
break;

case "dsc" :
$GoodCard = ereg("^6011.{12}$", $Num);
$GoodCard = preg_match("/^6011.{12}$/", $Num);
break;

case "dnc" :
$GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num);
$GoodCard = preg_match("/^30[0-5].{11}$|^3[68].{12}$/", $Num);
break;

case "jcb" :
$GoodCard = ereg("^3.{15}$|^2131|1800.{11}$", $Num);
$GoodCard = preg_match("/^3.{15}$|^2131|1800.{11}$/", $Num);
break;

case "dlt" :
$GoodCard = ereg("^4.{15}$", $Num);
$GoodCard = preg_match("/^4.{15}$/", $Num);
break;

case "swi" :
$GoodCard = ereg("^[456].{15}$|^[456].{17,18}$", $Num);
$GoodCard = preg_match("/^[456].{15}$|^[456].{17,18}$/", $Num);
break;

case "enr" :
$GoodCard = ereg("^2014.{11}$|^2149.{11}$", $Num);
$GoodCard = preg_match("/^2014.{11}$|^2149.{11}$/", $Num);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion filter/tex/filter.php
Expand Up @@ -146,7 +146,7 @@ function tex_filter ($courseid, $text) {
$texexp = str_replace('</nolink>','',$texexp);
$texexp = str_replace('<span class="nolink">','',$texexp);
$texexp = str_replace('</span>','',$texexp);
$texexp = eregi_replace("<br[[:space:]]*\/?>", '', $texexp); //dlnsk
$texexp = preg_replace("#<br[[:space:]]*\/?>#i", '', $texexp); //dlnsk
$align = "middle";
if (preg_match('/^align=bottom /',$texexp)) {
$align = "text-bottom";
Expand Down
4 changes: 2 additions & 2 deletions lib/adodb/drivers/adodb-sybase.inc.php
Expand Up @@ -376,7 +376,7 @@ function UnixDate($v)
global $ADODB_sybase_mths;

//Dec 30 2000 12:00AM
if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
if (!preg_match( "#([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})#"
,$v, $rr)) return parent::UnixDate($v);

if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
Expand All @@ -393,7 +393,7 @@ function UnixTimeStamp($v)
global $ADODB_sybase_mths;
//11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
//Changed [0-9] to [0-9 ] in day conversion
if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
if (!preg_match( "#([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})#"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;

Expand Down
46 changes: 46 additions & 0 deletions lib/adodb/readme_moodle.txt
Expand Up @@ -30,3 +30,49 @@ Our changes:
skodak, iarenaza, moodler, stronk7

$Id$


18 Nov 2009
Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.

Index: drivers/adodb-sybase.inc.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/adodb/drivers/adodb-sybase.inc.php,v
retrieving revision 1.21.6.2
diff -u -r1.21.6.2 adodb-sybase.inc.php
--- drivers/adodb-sybase.inc.php 15 Feb 2008 06:04:06 -0000 1.21.6.2
+++ drivers/adodb-sybase.inc.php 18 Nov 2009 06:15:43 -0000
@@ -376,7 +376,7 @@
global $ADODB_sybase_mths;

//Dec 30 2000 12:00AM
- if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
+ if (!preg_match( "#([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})#"
,$v, $rr)) return parent::UnixDate($v);

if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
@@ -393,7 +393,7 @@
global $ADODB_sybase_mths;
//11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
//Changed [0-9] to [0-9 ] in day conversion
- if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
+ if (!preg_match( "#([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})#"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;

Index: session/old/adodb-session-clob.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/adodb/session/old/Attic/adodb-session-clob.php,v
retrieving revision 1.5.6.1
diff -u -r1.5.6.1 adodb-session-clob.php
--- session/old/adodb-session-clob.php 15 Feb 2008 06:04:08 -0000 1.5.6.1
+++ session/old/adodb-session-clob.php 18 Nov 2009 06:15:43 -0000
@@ -439,7 +439,7 @@
if (0) {

session_start();
- session_register('AVAR');
+ session_register('AVAR');//this is deprecated in php 5.3
$_SESSION['AVAR'] += 1;
ADOConnection::outp( "
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
2 changes: 1 addition & 1 deletion lib/adodb/session/old/adodb-session-clob.php
Expand Up @@ -439,7 +439,7 @@ function adodb_sess_gc($maxlifetime)
if (0) {

session_start();
session_register('AVAR');
session_register('AVAR');//this is deprecated in php 5.3
$_SESSION['AVAR'] += 1;
ADOConnection::outp( "
-- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
Expand Down
6 changes: 3 additions & 3 deletions lib/bennu/iCalendar_rfc2445.php
Expand Up @@ -139,13 +139,13 @@ function rfc2445_is_valid_value($value, $type) {
}

if($scheme === 'mailto') {
$regexp = '^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$';
$regexp = '#^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$#';
}
else {
$regexp = '^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$';
$regexp = '#^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$#';
}

return ereg($regexp, $remain);
return preg_match($regexp, $remain);
break;

case RFC2445_TYPE_BINARY:
Expand Down
27 changes: 27 additions & 0 deletions lib/bennu/readme_moodle.txt
@@ -0,0 +1,27 @@
18 Nov 2009
Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.

Index: iCalendar_rfc2445.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/bennu/iCalendar_rfc2445.php,v
retrieving revision 1.2.10.1
diff -u -r1.2.10.1 iCalendar_rfc2445.php
--- iCalendar_rfc2445.php 12 Oct 2009 05:08:02 -0000 1.2.10.1
+++ iCalendar_rfc2445.php 18 Nov 2009 06:19:31 -0000
@@ -139,13 +139,13 @@
}

if($scheme === 'mailto') {
- $regexp = '^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$';
+ $regexp = '#^[a-zA-Z0-9]+[_a-zA-Z0-9\-]*(\.[_a-z0-9\-]+)*@(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})$#';
}
else {
- $regexp = '^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$';
+ $regexp = '#^//(.+(:.*)?@)?(([0-9a-zA-Z\-]+\.)+[a-zA-Z][0-9a-zA-Z\-]+|([0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]{1,5})?(/.*)?$#';
}

- return ereg($regexp, $remain);
+ return preg_match($regexp, $remain);
break;

case RFC2445_TYPE_BINARY:
4 changes: 2 additions & 2 deletions lib/blocklib.php
Expand Up @@ -173,8 +173,8 @@ function blocks_name_allowed_in_format($name, $pageformat) {
$depth = -1;
if ($formats = block_method_result($name, 'applicable_formats')) {
foreach($formats as $format => $allowed) {
$thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$';
if(ereg($thisformat, $pageformat)) {
$thisformat = '/^'.str_replace('*', '[^-]*', $format).'.*$/';
if(preg_match($thisformat, $pageformat)) {
if(($scount = substr_count($format, '-')) > $depth) {
$depth = $scount;
$accept = $allowed;
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecatedlib.php
Expand Up @@ -1001,7 +1001,7 @@ function detect_munged_arguments($string, $allowdots=1) {
if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
return true;
}
if (ereg('[\|\`]', $string)) { // check for other bad characters
if (preg_match('/[\|\`]/i', $string)) { // check for other bad characters
return true;
}
if (empty($string) or $string == '/') {
Expand Down
24 changes: 12 additions & 12 deletions lib/excel/Parser.php
Expand Up @@ -466,7 +466,7 @@ function _convert($token)
{
return(pack("C", $this->ptg[$token]));
}
elseif(preg_match("/[A-Z0-9À-Ü\.]+/",$token))
elseif(preg_match("/[A-Z0-9�-�\.]+/",$token))
{
return($this->_convert_function($token,$this->_func_args));
}
Expand Down Expand Up @@ -723,21 +723,21 @@ function _match($token)
break;
default:
// if it's a reference
if(eregi("^[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead) and
if(preg_match("/^[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return($token);
}
// if it's a range (A1:A2)
elseif(eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead))
elseif(preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return($token);
}
// if it's a range (A1..A2)
elseif(eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead))
elseif(preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return($token);
}
Expand All @@ -746,7 +746,7 @@ function _match($token)
return($token);
}
// if it's a function call
elseif(eregi("^[A-Z0-9À-Ü\.]+$",$token) and ($this->_lookahead == "("))
elseif(preg_match("/^[A-Z0-9�-�\.]+$/i",$token) and ($this->_lookahead == "("))

{
return($token);
Expand Down Expand Up @@ -857,15 +857,15 @@ function _fact()
return($result);
}
// if it's a reference
if (eregi("^[A-I]?[A-Z][0-9]+$",$this->_current_token))
if (preg_match("/^[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
{
$result = $this->_create_tree($this->_current_token, '', '');
$this->_advance();
return($result);
}
// if it's a range
elseif (eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$this->_current_token) or
eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$this->_current_token))
elseif (preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$this->_current_token) or
preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
{
$result = $this->_current_token;
$this->_advance();
Expand All @@ -878,7 +878,7 @@ function _fact()
return($result);
}
// if it's a function call
elseif (eregi("^[A-Z0-9À-Ü\.]+$",$this->_current_token))
elseif (preg_match("/^[A-Z0-9�-�\.]+$/i",$this->_current_token))
{
$result = $this->_func();
return($result);
Expand Down
4 changes: 2 additions & 2 deletions lib/excel/Worksheet.php
Expand Up @@ -1264,10 +1264,10 @@ function write_formula($row, $col, $formula, $format = 0)
}

// Strip the '=' or '@' sign at the beginning of the formula string
if (ereg("^=",$formula)) {
if (preg_match("/^=/",$formula)) {
$formula = preg_replace("/(^=)/","",$formula);
}
elseif(ereg("^@",$formula)) {
elseif(preg_match("/^@/",$formula)) {
$formula = preg_replace("/(^@)/","",$formula);
}
else {
Expand Down

0 comments on commit 76561f1

Please sign in to comment.