From 76561f1e4e2c0cfa181804344b501b4e6d56d270 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 18 Nov 2009 07:36:20 +0000 Subject: [PATCH] all MDL-20821 Removed ereg related deprecated functions --- admin/fixuserpix.php | 4 +- admin/mnet/MethodTable.php | 10 +- admin/uploaduser.php | 2 +- auth/shibboleth/auth.php | 2 +- auth/shibboleth/logout.php | 2 +- calendar/lib.php | 4 +- enrol/authorize/enrol_form.php | 22 +- filter/tex/filter.php | 2 +- lib/adodb/drivers/adodb-sybase.inc.php | 4 +- lib/adodb/readme_moodle.txt | 46 +++ lib/adodb/session/old/adodb-session-clob.php | 2 +- lib/bennu/iCalendar_rfc2445.php | 6 +- lib/bennu/readme_moodle.txt | 27 ++ lib/blocklib.php | 4 +- lib/deprecatedlib.php | 2 +- lib/excel/Parser.php | 24 +- lib/excel/Worksheet.php | 4 +- lib/excel/readme_moodle.txt | 104 +++++ lib/filelib.php | 2 +- lib/fpdf/font/makefont/makefont.php | 2 +- lib/fpdf/readme_moodle.txt | 19 + lib/geoip/geoip.inc | 2 +- lib/geoip/readme_moodle.txt | 19 + .../HTMLPurifier/AttrDef/Lang.php | 2 +- lib/htmlpurifier/readme_moodle.txt | 21 + lib/moodlelib.php | 36 +- lib/pclzip/pclzip.lib.php | 10 +- lib/pclzip/readme_moodle.txt | 52 ++- lib/pear/README_MOODLE.txt | 100 +++++ lib/pear/Spreadsheet/Excel/Writer/Parser.php | 22 +- lib/simpletest/testmoodlelib.php | 11 + lib/soap/README_MOODLE.txt | 273 +++++++++++++ lib/soap/nusoap.php | 64 ++-- lib/tcpdf/README_MOODLE.txt | 26 ++ lib/tcpdf/html2pdf.php | 4 +- lib/typo3/README_MOODLE.txt | 359 ++++++++++++++++++ lib/typo3/class.t3lib_cs.php | 14 +- lib/typo3/class.t3lib_div.php | 70 ++-- lib/validateurlsyntax.php | 13 +- lib/weblib.php | 26 +- lib/wiki_to_markdown.php | 58 +-- lib/xmldb/README_MOODLE.txt | 19 + lib/xmldb/classes/XMLDBObject.class.php | 2 +- login/index.php | 2 +- login/signup_form.php | 2 +- mnet/lib.php | 2 +- mnet/xmlrpc/server.php | 2 +- mod/chat/chatd.php | 6 +- mod/lesson/format.php | 2 +- mod/lesson/reformat.php | 2 +- mod/scorm/datamodels/aicclib.php | 2 +- mod/scorm/locallib.php | 2 +- mod/scorm/player.php | 2 +- mod/wiki/ewiki/fragments/nuke_mod_wiki_index | 2 +- mod/wiki/lib.php | 4 +- pix/smartpix.php | 8 +- question/format.php | 4 +- question/format/blackboard_6/format.php | 2 +- question/format/gift/format.php | 10 +- question/format/qti2/format.php | 4 +- question/format/webct/format.php | 98 ++--- question/format/xml/format.php | 4 +- .../type/calculated/edit_calculated_form.php | 2 +- question/type/calculated/questiontype.php | 22 +- .../type/datasetdependent/abstractqtype.php | 6 +- question/type/multianswer/questiontype.php | 4 +- question/type/numerical/questiontype.php | 2 +- question/type/random/questiontype.php | 6 +- search/documents/assignment_document.php | 2 +- user/editadvanced_form.php | 2 +- 70 files changed, 1393 insertions(+), 310 deletions(-) create mode 100644 lib/bennu/readme_moodle.txt create mode 100644 lib/excel/readme_moodle.txt create mode 100644 lib/fpdf/readme_moodle.txt create mode 100644 lib/geoip/readme_moodle.txt create mode 100644 lib/soap/README_MOODLE.txt create mode 100644 lib/tcpdf/README_MOODLE.txt create mode 100644 lib/typo3/README_MOODLE.txt create mode 100644 lib/xmldb/README_MOODLE.txt diff --git a/admin/fixuserpix.php b/admin/fixuserpix.php index e556023190f..b21f55b043a 100755 --- a/admin/fixuserpix.php +++ b/admin/fixuserpix.php @@ -252,9 +252,9 @@ if ($settings['eolchar'] == '
') { 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'; } } diff --git a/admin/mnet/MethodTable.php b/admin/mnet/MethodTable.php index e5e4b390f82..6bd0bd6260d 100644 --- a/admin/mnet/MethodTable.php +++ b/admin/mnet/MethodTable.php @@ -465,15 +465,15 @@ class MethodTable $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 { @@ -535,7 +535,7 @@ class MethodTable $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; } diff --git a/admin/uploaduser.php b/admin/uploaduser.php index 9781ccdec14..3d8ba3d7e4a 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -260,7 +260,7 @@ if ($formdata = $mform->is_cancelled()) { // 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'); diff --git a/auth/shibboleth/auth.php b/auth/shibboleth/auth.php index 9fcfdbf7807..213278c447a 100644 --- a/auth/shibboleth/auth.php +++ b/auth/shibboleth/auth.php @@ -63,7 +63,7 @@ class auth_plugin_shibboleth extends auth_plugin_base { } 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; } } diff --git a/auth/shibboleth/logout.php b/auth/shibboleth/logout.php index 24ab73a7b79..f9f06bbf267 100644 --- a/auth/shibboleth/logout.php +++ b/auth/shibboleth/logout.php @@ -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); diff --git a/calendar/lib.php b/calendar/lib.php index 7c575d41a78..40eb7397b1c 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -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[^ ]+)', '\\1', $text); - $text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '\\1', $text); + $text = preg_replace('/(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)/', '\\1', $text); + $text = preg_replace('/(F.+Y|Y.+F|Y.+m[^ ]+)/', '\\1', $text); */ // Replace with actual values and lose any day leading zero $text = userdate($time, $text); diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 0182076fccc..716e45f5b3e 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -246,7 +246,7 @@ class enrol_authorize_form extends moodleform 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)); @@ -276,45 +276,45 @@ class enrol_authorize_form extends moodleform $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; } diff --git a/filter/tex/filter.php b/filter/tex/filter.php index d067fbc7fe7..deb52eca44b 100644 --- a/filter/tex/filter.php +++ b/filter/tex/filter.php @@ -146,7 +146,7 @@ function tex_filter ($courseid, $text) { $texexp = str_replace('','',$texexp); $texexp = str_replace('','',$texexp); $texexp = str_replace('','',$texexp); - $texexp = eregi_replace("", '', $texexp); //dlnsk + $texexp = preg_replace("##i", '', $texexp); //dlnsk $align = "middle"; if (preg_match('/^align=bottom /',$texexp)) { $align = "text-bottom"; diff --git a/lib/adodb/drivers/adodb-sybase.inc.php b/lib/adodb/drivers/adodb-sybase.inc.php index ef6df6be6dc..16cca091e8f 100644 --- a/lib/adodb/drivers/adodb-sybase.inc.php +++ b/lib/adodb/drivers/adodb-sybase.inc.php @@ -376,7 +376,7 @@ class ADORecordSet_array_sybase extends ADORecordSet_array { 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 @@ class ADORecordSet_array_sybase extends ADORecordSet_array { 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; diff --git a/lib/adodb/readme_moodle.txt b/lib/adodb/readme_moodle.txt index 521ab8ce6af..5504f7881a0 100644 --- a/lib/adodb/readme_moodle.txt +++ b/lib/adodb/readme_moodle.txt @@ -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']}

",false); diff --git a/lib/adodb/session/old/adodb-session-clob.php b/lib/adodb/session/old/adodb-session-clob.php index fd760441d00..fb83a4573ed 100644 --- a/lib/adodb/session/old/adodb-session-clob.php +++ b/lib/adodb/session/old/adodb-session-clob.php @@ -439,7 +439,7 @@ session_set_save_handler( 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']}

",false); diff --git a/lib/bennu/iCalendar_rfc2445.php b/lib/bennu/iCalendar_rfc2445.php index 053adcc9374..410f55000bc 100644 --- a/lib/bennu/iCalendar_rfc2445.php +++ b/lib/bennu/iCalendar_rfc2445.php @@ -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: diff --git a/lib/bennu/readme_moodle.txt b/lib/bennu/readme_moodle.txt new file mode 100644 index 00000000000..ab351e4ea98 --- /dev/null +++ b/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: diff --git a/lib/blocklib.php b/lib/blocklib.php index 34c27856552..404859b56cd 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -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; diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 708c596ac98..8de43b9205e 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -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 == '/') { diff --git a/lib/excel/Parser.php b/lib/excel/Parser.php index e1882e725d0..3d3e92e7da8 100644 --- a/lib/excel/Parser.php +++ b/lib/excel/Parser.php @@ -466,7 +466,7 @@ class Parser { 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)); } @@ -723,21 +723,21 @@ class Parser 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); } @@ -746,7 +746,7 @@ class Parser 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); @@ -857,15 +857,15 @@ class Parser 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(); @@ -878,7 +878,7 @@ class Parser 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); diff --git a/lib/excel/Worksheet.php b/lib/excel/Worksheet.php index f512fb88fce..d3faf06db14 100644 --- a/lib/excel/Worksheet.php +++ b/lib/excel/Worksheet.php @@ -1264,10 +1264,10 @@ class Worksheet extends BIFFwriter } // 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 { diff --git a/lib/excel/readme_moodle.txt b/lib/excel/readme_moodle.txt new file mode 100644 index 00000000000..f33b3cdc2c3 --- /dev/null +++ b/lib/excel/readme_moodle.txt @@ -0,0 +1,104 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: Parser.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/excel/Parser.php,v +retrieving revision 1.1 +diff -u -r1.1 Parser.php +--- Parser.php 26 Sep 2003 04:18:02 -0000 1.1 ++++ Parser.php 18 Nov 2009 06:27:54 -0000 +@@ -466,7 +466,7 @@ + { + 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)); + } +@@ -723,21 +723,21 @@ + 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); + } +@@ -746,7 +746,7 @@ + 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); +@@ -857,15 +857,15 @@ + 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(); +@@ -878,7 +878,7 @@ + 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); +Index: Worksheet.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/excel/Worksheet.php,v +retrieving revision 1.1 +diff -u -r1.1 Worksheet.php +--- Worksheet.php 26 Sep 2003 04:18:02 -0000 1.1 ++++ Worksheet.php 18 Nov 2009 06:27:55 -0000 +@@ -1264,10 +1264,10 @@ + } + + // 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 { diff --git a/lib/filelib.php b/lib/filelib.php index 098c3e39093..b5a1d848a79 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -496,7 +496,7 @@ function mimeinfo($element, $filename) { $mimeinfo = get_mimetypes_array(); } - if (eregi('\.([a-z0-9]+)$', $filename, $match)) { + if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) { if (isset($mimeinfo[strtolower($match[1])][$element])) { return $mimeinfo[strtolower($match[1])][$element]; } else { diff --git a/lib/fpdf/font/makefont/makefont.php b/lib/fpdf/font/makefont/makefont.php index 17348ab4ae7..35c2be6bd71 100755 --- a/lib/fpdf/font/makefont/makefont.php +++ b/lib/fpdf/font/makefont/makefont.php @@ -171,7 +171,7 @@ function MakeFontDescriptor($fm,$symbolic) //StemV if(isset($fm['StdVW'])) $stemv=$fm['StdVW']; - elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight'])) + elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight'])) $stemv=120; else $stemv=70; diff --git a/lib/fpdf/readme_moodle.txt b/lib/fpdf/readme_moodle.txt new file mode 100644 index 00000000000..000cf325d7c --- /dev/null +++ b/lib/fpdf/readme_moodle.txt @@ -0,0 +1,19 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: font/makefont/makefont.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/fpdf/font/makefont/Attic/makefont.php,v +retrieving revision 1.2 +diff -u -r1.2 makefont.php +--- font/makefont/makefont.php 16 May 2006 06:45:14 -0000 1.2 ++++ font/makefont/makefont.php 18 Nov 2009 06:32:46 -0000 +@@ -171,7 +171,7 @@ + //StemV + if(isset($fm['StdVW'])) + $stemv=$fm['StdVW']; +- elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight'])) ++ elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight'])) + $stemv=120; + else + $stemv=70; diff --git a/lib/geoip/geoip.inc b/lib/geoip/geoip.inc index a0954699575..42517db9103 100644 --- a/lib/geoip/geoip.inc +++ b/lib/geoip/geoip.inc @@ -490,7 +490,7 @@ function getdnsattributes ($l,$ip){ $r->nameservers = array("ws1.maxmind.com"); $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); $str = is_object($p->answer[0])?$p->answer[0]->string():''; - ereg("\"(.*)\"",$str,$regs); + preg_match("/\"(.*)\"/",$str,$regs); $str = $regs[1]; return $str; } diff --git a/lib/geoip/readme_moodle.txt b/lib/geoip/readme_moodle.txt new file mode 100644 index 00000000000..96b352cb509 --- /dev/null +++ b/lib/geoip/readme_moodle.txt @@ -0,0 +1,19 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: geoip.inc +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/geoip/geoip.inc,v +retrieving revision 1.1.2.2 +diff -u -r1.1.2.2 geoip.inc +--- geoip.inc 2 Jan 2008 16:49:05 -0000 1.1.2.2 ++++ geoip.inc 18 Nov 2009 06:34:59 -0000 +@@ -490,7 +490,7 @@ + $r->nameservers = array("ws1.maxmind.com"); + $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); + $str = is_object($p->answer[0])?$p->answer[0]->string():''; +- ereg("\"(.*)\"",$str,$regs); ++ preg_match("/\"(.*)\"/",$str,$regs); + $str = $regs[1]; + return $str; + } diff --git a/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php b/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php index e9cdda7adf9..4e2b6820cbb 100644 --- a/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php +++ b/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php @@ -12,7 +12,7 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef function validate($string, $config, &$context) { // moodle change - we use special lang strings unfortunatelly - return ereg_replace('[^0-9a-zA-Z_-]', '', $string); + return preg_replace('/[^0-9a-zA-Z_-]/', '', $string); // moodle change end $string = trim($string); diff --git a/lib/htmlpurifier/readme_moodle.txt b/lib/htmlpurifier/readme_moodle.txt index 40e2b3deae3..d456361f604 100644 --- a/lib/htmlpurifier/readme_moodle.txt +++ b/lib/htmlpurifier/readme_moodle.txt @@ -8,3 +8,24 @@ Changes: skodak $Id$ + + +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: HTMLPurifier/AttrDef/Lang.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php,v +retrieving revision 1.3 +diff -u -r1.3 Lang.php +--- HTMLPurifier/AttrDef/Lang.php 25 Sep 2007 14:34:13 -0000 1.3 ++++ HTMLPurifier/AttrDef/Lang.php 18 Nov 2009 06:37:14 -0000 +@@ -12,7 +12,7 @@ + function validate($string, $config, &$context) { + + // moodle change - we use special lang strings unfortunatelly +- return ereg_replace('[^0-9a-zA-Z_-]', '', $string); ++ return preg_replace('/[^0-9a-zA-Z_-]/', '', $string); + // moodle change end + + $string = trim($string); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c0c9139547b..d2a3fcd461c 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -418,16 +418,16 @@ function clean_param($param, $type) { return (float)$param; // Convert to integer case PARAM_ALPHA: // Remove everything not a-z - return eregi_replace('[^a-zA-Z]', '', $param); + return preg_replace('/[^a-zA-Z]/i', '', $param); case PARAM_ALPHANUM: // Remove everything not a-zA-Z0-9 - return eregi_replace('[^A-Za-z0-9]', '', $param); + return preg_replace('/[^A-Za-z0-9]/i', '', $param); case PARAM_ALPHAEXT: // Remove everything not a-zA-Z/_- - return eregi_replace('[^a-zA-Z/_-]', '', $param); + return preg_replace('/[^a-zA-Z/_-]/i', '', $param); case PARAM_SEQUENCE: // Remove everything not 0-9, - return eregi_replace('[^0-9,]', '', $param); + return preg_replace('/[^0-9,]/i', '', $param); case PARAM_BOOL: // Convert to 1 or 0 $tempstr = strtolower($param); @@ -447,14 +447,14 @@ function clean_param($param, $type) { return clean_param(strip_tags($param, ''), PARAM_CLEAN); case PARAM_SAFEDIR: // Remove everything not a-zA-Z0-9_- - return eregi_replace('[^a-zA-Z0-9_-]', '', $param); + return preg_replace('/[^a-zA-Z0-9_-]/i', '', $param); case PARAM_CLEANFILE: // allow only safe characters return clean_filename($param); case PARAM_FILE: // Strip all suspicious characters from filename - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':\\/]', '', $param); - $param = ereg_replace('\.\.+', '', $param); + $param = preg_replace('/[[:cntrl:]]|[\/<>\"`|\':\\\\]/', '', $param); + $param = preg_replace('/\.\./', '', $param);//remove double full stops if($param == '.') { $param = ''; } @@ -464,10 +464,10 @@ function clean_param($param, $type) { $param = str_replace('\\\'', '\'', $param); $param = str_replace('\\"', '"', $param); $param = str_replace('\\', '/', $param); - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param); - $param = ereg_replace('\.\.+', '', $param); - $param = ereg_replace('//+', '/', $param); - return ereg_replace('/(\./)+', '/', $param); + $param = preg_replace('#[[:cntrl:]]|[<>"`\|\':]#', '', $param); + $param = preg_replace('#\.\.+#', '', $param); + $param = preg_replace('#//+#', '/', $param); + return preg_replace('#/(\./)+#', '/', $param); case PARAM_HOST: // allow FQDN or IPv4 dotted quad $param = preg_replace('/[^\.\d\w-]/','', $param ); // only allowed chars @@ -4310,7 +4310,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a } if ($attachment && $attachname) { - if (ereg( "\\.\\." ,$attachment )) { // Security check for ".." in dir path + if (preg_match( "/\\.\\./" ,$attachment )) { // Security check for ".." in dir path $mail->AddAddress($supportuser->email, fullname($supportuser, true) ); $mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain'); } else { @@ -4734,7 +4734,7 @@ function make_mod_upload_directory($courseid) { function make_user_directory($userid, $test=false) { global $CFG; - if (is_bool($userid) || $userid < 0 || !ereg('^[0-9]{1,10}$', $userid) || $userid > 2147483647) { + if (is_bool($userid) || $userid < 0 || !preg_match('/^[0-9]{1,10}$/', $userid) || $userid > 2147483647) { if (!$test) { notify("Given userid was not a valid integer! (" . gettype($userid) . " $userid)"); } @@ -6823,7 +6823,7 @@ function count_letters($string) { $textlib = textlib_get_instance(); $string = strip_tags($string); // Tags are out now - $string = ereg_replace('[[:space:]]*','',$string); //Whitespace are out now + $string = preg_replace('/[[:space:]]*/','',$string); //Whitespace are out now return $textlib->strlen($string); } @@ -7736,11 +7736,11 @@ function unzip_cleanfilename ($p_event, &$p_header) { //This function is used as callback in unzip_file() function //to clean illegal characters for given platform and to prevent directory traversal. //Produces the same result as info-zip unzip. - $p_header['filename'] = ereg_replace('[[:cntrl:]]', '', $p_header['filename']); //strip control chars first! - $p_header['filename'] = ereg_replace('\.\.+', '', $p_header['filename']); //directory traversal protection + $p_header['filename'] = preg_replace('/[[:cntrl:]]/', '', $p_header['filename']); //strip control chars first! + $p_header['filename'] = preg_replace('#\.\.+#', '', $p_header['filename']); //directory traversal protection if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $p_header['filename'] = ereg_replace('[:*"?<>|]', '_', $p_header['filename']); //replace illegal chars - $p_header['filename'] = ereg_replace('^([a-zA-Z])_', '\1:', $p_header['filename']); //repair drive letter + $p_header['filename'] = preg_replace('/[:*"?<>|]/', '_', $p_header['filename']); //replace illegal chars + $p_header['filename'] = preg_replace('/^([a-zA-Z])_/', '\1:', $p_header['filename']); //repair drive letter } else { //Add filtering for other systems here // BSD: none (tested) diff --git a/lib/pclzip/pclzip.lib.php b/lib/pclzip/pclzip.lib.php index e72737b7aa2..f469325bae6 100644 --- a/lib/pclzip/pclzip.lib.php +++ b/lib/pclzip/pclzip.lib.php @@ -3245,7 +3245,9 @@ } // ----- Look for extract by ereg rule - else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + /* + * MDL-20821 ereg is now deprecated + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); @@ -3253,7 +3255,7 @@ //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_extract = true; } - } + }*/ // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) @@ -4684,6 +4686,8 @@ } // ----- Look for extract by ereg rule + /* + * MDL-20821 ereg is now deprecated else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); @@ -4692,7 +4696,7 @@ //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); $v_found = true; } - } + }*/ // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) diff --git a/lib/pclzip/readme_moodle.txt b/lib/pclzip/readme_moodle.txt index b12050e23fd..27cdb831123 100644 --- a/lib/pclzip/readme_moodle.txt +++ b/lib/pclzip/readme_moodle.txt @@ -5,4 +5,54 @@ Changes: * removed PclZipUtilTranslateWinPath from line 1958 - see MDL-7828 skodak -$Id$ \ No newline at end of file +$Id$ + + +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: pclzip.lib.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/pclzip/Attic/pclzip.lib.php,v +retrieving revision 1.15 +diff -u -r1.15 pclzip.lib.php +--- pclzip.lib.php 28 Mar 2007 07:17:26 -0000 1.15 ++++ pclzip.lib.php 18 Nov 2009 06:40:48 -0000 +@@ -3245,7 +3245,9 @@ + } + + // ----- Look for extract by ereg rule +- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) ++ /* ++ * MDL-20821 ereg is now deprecated ++ else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + +@@ -3253,7 +3255,7 @@ + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } +- } ++ }*/ + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) +@@ -4684,6 +4686,8 @@ + } + + // ----- Look for extract by ereg rule ++ /* ++ * MDL-20821 ereg is now deprecated + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); +@@ -4692,7 +4696,7 @@ + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } +- } ++ }*/ + + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) diff --git a/lib/pear/README_MOODLE.txt b/lib/pear/README_MOODLE.txt index b9b23672098..747b2beca38 100644 --- a/lib/pear/README_MOODLE.txt +++ b/lib/pear/README_MOODLE.txt @@ -12,3 +12,103 @@ to a new release within Moodle. stronk7 $Id$ + + +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: Spreadsheet/Excel/Writer/Parser.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/pear/Spreadsheet/Excel/Writer/Parser.php,v +retrieving revision 1.2 +diff -u -r1.2 Parser.php +--- Spreadsheet/Excel/Writer/Parser.php 4 Jan 2006 08:23:42 -0000 1.2 ++++ Spreadsheet/Excel/Writer/Parser.php 18 Nov 2009 06:42:45 -0000 +@@ -1206,7 +1206,7 @@ + default: + // if it's a reference + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and +- !ereg("[0-9]",$this->_lookahead) and ++ !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.') and + ($this->_lookahead != '!')) + { +@@ -1214,39 +1214,39 @@ + } + // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) + elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and +- !ereg("[0-9]",$this->_lookahead) and ++ !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) + { + return $token; + } + // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and +- !ereg("[0-9]",$this->_lookahead) and ++ !preg_match("/[0-9]/",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) + { + return $token; + } + // if it's a range (A1:A2) + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and +- !ereg("[0-9]",$this->_lookahead)) ++ !preg_match("/[0-9]/",$this->_lookahead)) + { + return $token; + } + // if it's a range (A1..A2) + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and +- !ereg("[0-9]",$this->_lookahead)) ++ !preg_match("/[0-9]/",$this->_lookahead)) + { + return $token; + } + // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2 + elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and +- !ereg("[0-9]",$this->_lookahead)) ++ !preg_match("/[0-9]/",$this->_lookahead)) + { + return $token; + } + // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and +- !ereg("[0-9]",$this->_lookahead)) ++ !preg_match("/[0-9]/",$this->_lookahead)) + { + return $token; + } +@@ -1258,12 +1258,12 @@ + return $token; + } + // If it's a string (of maximum 255 characters) +- elseif (ereg("^\"[^\"]{0,255}\"$",$token)) ++ elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token)) + { + return $token; + } + // if it's a function call +- elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) ++ elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) + { + return $token; + } +@@ -1363,7 +1363,7 @@ + function _expression() + { + // If it's a string return a string node +- if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) { ++ if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; +@@ -1521,7 +1521,7 @@ + return $result; + } + // if it's a function call +- elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token)) ++ elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) + { + $result = $this->_func(); + return $result; diff --git a/lib/pear/Spreadsheet/Excel/Writer/Parser.php b/lib/pear/Spreadsheet/Excel/Writer/Parser.php index a8730343fd0..c34453687a3 100644 --- a/lib/pear/Spreadsheet/Excel/Writer/Parser.php +++ b/lib/pear/Spreadsheet/Excel/Writer/Parser.php @@ -1206,7 +1206,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR default: // if it's a reference if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) { @@ -1214,39 +1214,39 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR } // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // if it's a range (A1:A2) elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // if it's a range (A1..A2) elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2 elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } @@ -1258,12 +1258,12 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $token; } // If it's a string (of maximum 255 characters) - elseif (ereg("^\"[^\"]{0,255}\"$",$token)) + elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token)) { return $token; } // if it's a function call - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) { return $token; } @@ -1363,7 +1363,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR function _expression() { // If it's a string return a string node - if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) { + if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { $result = $this->_createTree($this->_current_token, '', ''); $this->_advance(); return $result; @@ -1521,7 +1521,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR return $result; } // if it's a function call - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token)) + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) { $result = $this->_func(); return $result; diff --git a/lib/simpletest/testmoodlelib.php b/lib/simpletest/testmoodlelib.php index 5aea975543d..a03106b4b3e 100644 --- a/lib/simpletest/testmoodlelib.php +++ b/lib/simpletest/testmoodlelib.php @@ -199,6 +199,17 @@ class moodlelib_test extends UnitTestCase { $this->assertEqual(clean_param($CFG->wwwroot, PARAM_LOCALURL), $CFG->wwwroot); $this->assertEqual(clean_param('/just/a/path', PARAM_LOCALURL), '/just/a/path'); $this->assertEqual(clean_param('funny:thing', PARAM_LOCALURL), ''); + + //test filename param + $this->assertEqual(clean_param('correctfile.txt', PARAM_FILE), 'correctfile.txt'); + $this->assertEqual(clean_param('b\'ae.t"x|t', PARAM_FILE), 'badfile.txt'); + $this->assertEqual(clean_param('../parentdirfile.txt', PARAM_FILE), 'parentdirfile.txt'); + //The following behaviours have been maintained although they seem a little odd + $this->assertEqual(clean_param('funny:thing', PARAM_FILE), 'funnything'); + $this->assertEqual(clean_param('./currentdirfile.txt', PARAM_FILE), '.currentdirfile.txt'); + $this->assertEqual(clean_param('c:\temp\windowsfile.txt', PARAM_FILE), 'ctempwindowsfile.txt'); + $this->assertEqual(clean_param('/home/user/linuxfile.txt', PARAM_FILE), 'homeuserlinuxfile.txt'); + $this->assertEqual(clean_param('~/myfile.txt', PARAM_FILE), '~myfile.txt'); } function test_make_user_directory() { diff --git a/lib/soap/README_MOODLE.txt b/lib/soap/README_MOODLE.txt new file mode 100644 index 00000000000..a1fd9c0a313 --- /dev/null +++ b/lib/soap/README_MOODLE.txt @@ -0,0 +1,273 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: nusoap.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/soap/nusoap.php,v +retrieving revision 1.2 +diff -u -r1.2 nusoap.php +--- nusoap.php 3 Jan 2007 14:44:42 -0000 1.2 ++++ nusoap.php 18 Nov 2009 06:48:29 -0000 +@@ -503,7 +503,7 @@ + case (is_array($val) || $type): + // detect if struct or array + $valueType = $this->isArraySimpleOrStruct($val); +- if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ ++ if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ + $i = 0; + if(is_array($val) && count($val)> 0){ + foreach($val as $v){ +@@ -698,7 +698,7 @@ + */ + function expandQname($qname){ + // get element prefix +- if(strpos($qname,':') && !ereg('^http://',$qname)){ ++ if(strpos($qname,':') && !preg_match('#^http://#',$qname)){ + // get unqualified name + $name = substr(strstr($qname,':'),1); + // get ns prefix +@@ -827,6 +827,7 @@ + $datestr = date('Y-m-d\TH:i:sO',$timestamp); + if($utc){ + $eregStr = ++ '/'. + '([0-9]{4})-'. // centuries & years CCYY- + '([0-9]{2})-'. // months MM- + '([0-9]{2})'. // days DD +@@ -834,9 +835,10 @@ + '([0-9]{2}):'. // hours hh: + '([0-9]{2}):'. // minutes mm: + '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... +- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's ++ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's ++ '/'; + +- if(ereg($eregStr,$datestr,$regs)){ ++ if(preg_match($eregStr,$datestr,$regs)){ + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); + } + return false; +@@ -853,6 +855,7 @@ + */ + function iso8601_to_timestamp($datestr){ + $eregStr = ++ '/'. + '([0-9]{4})-'. // centuries & years CCYY- + '([0-9]{2})-'. // months MM- + '([0-9]{2})'. // days DD +@@ -860,8 +863,9 @@ + '([0-9]{2}):'. // hours hh: + '([0-9]{2}):'. // minutes mm: + '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... +- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's +- if(ereg($eregStr,$datestr,$regs)){ ++ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's ++ '/'; ++ if(preg_match($eregStr,$datestr,$regs)){ + // not utc + if($regs[8] != 'Z'){ + $op = substr($regs[8],0,1); +@@ -1171,7 +1175,7 @@ + if(count($attrs) > 0){ + foreach($attrs as $k => $v){ + // if ns declarations, add to class level array of valid namespaces +- if(ereg("^xmlns",$k)){ ++ if(preg_match("/^xmlns/",$k)){ + //$this->xdebug("$k: $v"); + //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); + if($ns_prefix = substr(strrchr($k,':'),1)){ +@@ -1281,7 +1285,7 @@ + // minOccurs="0" maxOccurs="unbounded" /> + // + // +- if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ ++ if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ + $this->xdebug('complexType is unusual array'); + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } else { +@@ -1300,7 +1304,7 @@ + // minOccurs="0" maxOccurs="unbounded" /> + // + // +- if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ ++ if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ + $this->xdebug('complexType is unusual array'); + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; + } else { +@@ -1698,7 +1702,7 @@ + } elseif(isset($this->attributes[$type])){ + $this->xdebug("in getTypeDef, found attribute $type"); + return $this->attributes[$type]; +- } elseif (ereg('_ContainedType$', $type)) { ++ } elseif (preg_match('/_ContainedType$/', $type)) { + $this->xdebug("in getTypeDef, have an untyped element $type"); + $typeDef['typeClass'] = 'simpleType'; + $typeDef['phpType'] = 'scalar'; +@@ -2041,7 +2045,7 @@ + function soap_transport_http($url){ + parent::nusoap_base(); + $this->setURL($url); +- ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); ++ preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); + $this->outgoing_headers['User-Agent'] = $this->title.'/'.$this->version.' ('.$rev[1].')'; + $this->debug('set User-Agent: ' . $this->outgoing_headers['User-Agent']); + } +@@ -2580,7 +2584,7 @@ + } + } + // remove 100 header +- if(isset($lb) && ereg('^HTTP/1.1 100',$data)){ ++ if(isset($lb) && preg_match('/^HTTP/1.1 100/',$data)){ + unset($lb); + $data = ''; + }// +@@ -2733,7 +2737,7 @@ + curl_close($this->ch); + + // remove 100 header(s) +- while (ereg('^HTTP/1.1 100',$data)) { ++ while (preg_match('#^HTTP/1.1 100#',$data)) { + if ($pos = strpos($data,"\r\n\r\n")) { + $data = ltrim(substr($data,$pos)); + } elseif($pos = strpos($data,"\n\n") ) { +@@ -3267,7 +3271,7 @@ + } + $this->debug("In service, query string=$qs"); + +- if (ereg('wsdl', $qs) ){ ++ if (preg_match('/wsdl/', $qs) ){ + $this->debug("In service, this is a request for WSDL"); + if($this->externalWSDLURL){ + if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL +@@ -3338,7 +3342,7 @@ + // get the character encoding of the incoming request + if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ + $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); +- if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ ++ if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; +@@ -3367,7 +3371,7 @@ + $enc = substr(strstr($v, '='), 1); + $enc = str_replace('"', '', $enc); + $enc = str_replace('\\', '', $enc); +- if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { ++ if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; +@@ -3401,7 +3405,7 @@ + $enc = substr(strstr($v, '='), 1); + $enc = str_replace('"', '', $enc); + $enc = str_replace('\\', '', $enc); +- if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { ++ if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; +@@ -3730,7 +3734,7 @@ + $payload .= $this->getDebugAsXMLComment(); + } + $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; +- ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); ++ preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); + $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; + // Let the Web server decide about this + //$this->outgoing_headers[] = "Connection: Close\r\n"; +@@ -3818,7 +3822,7 @@ + if (strpos($headers['content-type'], '=')) { + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); + $this->debug('Got response encoding: ' . $enc); +- if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ ++ if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; +@@ -4336,7 +4340,7 @@ + $this->currentSchema->schemaStartElement($parser, $name, $attrs); + $this->appendDebug($this->currentSchema->getDebug()); + $this->currentSchema->clearDebug(); +- } elseif (ereg('schema$', $name)) { ++ } elseif (preg_match('/schema$/', $name)) { + $this->debug('Parsing WSDL schema'); + // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); + $this->status = 'schema'; +@@ -4355,7 +4359,7 @@ + if (count($attrs) > 0) { + // register namespace declarations + foreach($attrs as $k => $v) { +- if (ereg("^xmlns", $k)) { ++ if (preg_match("/^xmlns/", $k)) { + if ($ns_prefix = substr(strrchr($k, ':'), 1)) { + $this->namespaces[$ns_prefix] = $v; + } else { +@@ -4380,7 +4384,7 @@ + $attrs = array(); + } + // get element prefix, namespace and name +- if (ereg(':', $name)) { ++ if (preg_match('/:/', $name)) { + // get ns prefix + $prefix = substr($name, 0, strpos($name, ':')); + // get ns +@@ -4545,7 +4549,7 @@ + */ + function end_element($parser, $name){ + // unset schema status +- if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { ++ if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { + $this->status = ""; + $this->appendDebug($this->currentSchema->getDebug()); + $this->currentSchema->clearDebug(); +@@ -5995,7 +5999,7 @@ + $key_localpart = $this->getLocalPart($key); + // if ns declarations, add to class level array of valid namespaces + if($key_prefix == 'xmlns'){ +- if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ ++ if(preg_match('#^http://www.w3.org/[0-9]{4}/XMLSchema$#',$value)){ + $this->XMLSchemaVersion = $value; + $this->namespaces['xsd'] = $this->XMLSchemaVersion; + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; +@@ -6031,8 +6035,8 @@ + [5] length ::= nextDimension* Digit+ + [6] nextDimension ::= Digit+ ',' + */ +- $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; +- if(ereg($expr,$value,$regs)){ ++ $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; ++ if(preg_match($expr,$value,$regs)){ + $this->message[$pos]['typePrefix'] = $regs[1]; + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; + if (isset($this->namespaces[$regs[1]])) { +@@ -6758,7 +6762,7 @@ + // detect transport + switch(true){ + // http(s) +- case ereg('^http',$this->endpoint): ++ case preg_match('/^http/',$this->endpoint): + $this->debug('transporting via HTTP'); + if($this->persistentConnection == true && is_object($this->persistentConnection)){ + $http =& $this->persistentConnection; +@@ -6780,10 +6784,10 @@ + $http->setEncoding($this->http_encoding); + } + $this->debug('sending message, length='.strlen($msg)); +- if(ereg('^http:',$this->endpoint)){ ++ if(preg_match('/^http:/',$this->endpoint)){ + //if(strpos($this->endpoint,'http:')){ + $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); +- } elseif(ereg('^https',$this->endpoint)){ ++ } elseif(preg_match('/^https/',$this->endpoint)){ + //} elseif(strpos($this->endpoint,'https:')){ + //if(phpversion() == '4.3.0-dev'){ + //$response = $http->send($msg,$timeout,$response_timeout); +@@ -6841,7 +6845,7 @@ + if (strpos($headers['content-type'], '=')) { + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); + $this->debug('Got response encoding: ' . $enc); +- if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ ++ if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ + $this->xml_encoding = strtoupper($enc); + } else { + $this->xml_encoding = 'US-ASCII'; diff --git a/lib/soap/nusoap.php b/lib/soap/nusoap.php index d7ad5d71425..68b184b5689 100644 --- a/lib/soap/nusoap.php +++ b/lib/soap/nusoap.php @@ -503,7 +503,7 @@ class nusoap_base { case (is_array($val) || $type): // detect if struct or array $valueType = $this->isArraySimpleOrStruct($val); - if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){ + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ $i = 0; if(is_array($val) && count($val)> 0){ foreach($val as $v){ @@ -698,7 +698,7 @@ class nusoap_base { */ function expandQname($qname){ // get element prefix - if(strpos($qname,':') && !ereg('^http://',$qname)){ + if(strpos($qname,':') && !preg_match('#^http://#',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix @@ -827,6 +827,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ $datestr = date('Y-m-d\TH:i:sO',$timestamp); if($utc){ $eregStr = + '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -834,9 +835,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; - if(ereg($eregStr,$datestr,$regs)){ + if(preg_match($eregStr,$datestr,$regs)){ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); } return false; @@ -853,6 +855,7 @@ function timestamp_to_iso8601($timestamp,$utc=true){ */ function iso8601_to_timestamp($datestr){ $eregStr = + '/'. '([0-9]{4})-'. // centuries & years CCYY- '([0-9]{2})-'. // months MM- '([0-9]{2})'. // days DD @@ -860,8 +863,9 @@ function iso8601_to_timestamp($datestr){ '([0-9]{2}):'. // hours hh: '([0-9]{2}):'. // minutes mm: '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's - if(ereg($eregStr,$datestr,$regs)){ + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's + '/'; + if(preg_match($eregStr,$datestr,$regs)){ // not utc if($regs[8] != 'Z'){ $op = substr($regs[8],0,1); @@ -1171,7 +1175,7 @@ class XMLSchema extends nusoap_base { if(count($attrs) > 0){ foreach($attrs as $k => $v){ // if ns declarations, add to class level array of valid namespaces - if(ereg("^xmlns",$k)){ + if(preg_match("/^xmlns/",$k)){ //$this->xdebug("$k: $v"); //$this->xdebug('ns_prefix: '.$this->getPrefix($k)); if($ns_prefix = substr(strrchr($k,':'),1)){ @@ -1281,7 +1285,7 @@ class XMLSchema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // // - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1300,7 +1304,7 @@ class XMLSchema extends nusoap_base { // minOccurs="0" maxOccurs="unbounded" /> // // - if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){ + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){ $this->xdebug('complexType is unusual array'); $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; } else { @@ -1698,7 +1702,7 @@ class XMLSchema extends nusoap_base { } elseif(isset($this->attributes[$type])){ $this->xdebug("in getTypeDef, found attribute $type"); return $this->attributes[$type]; - } elseif (ereg('_ContainedType$', $type)) { + } elseif (preg_match('/_ContainedType$/', $type)) { $this->xdebug("in getTypeDef, have an untyped element $type"); $typeDef['typeClass'] = 'simpleType'; $typeDef['phpType'] = 'scalar'; @@ -2041,7 +2045,7 @@ class soap_transport_http extends nusoap_base { function soap_transport_http($url){ parent::nusoap_base(); $this->setURL($url); - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers['User-Agent'] = $this->title.'/'.$this->version.' ('.$rev[1].')'; $this->debug('set User-Agent: ' . $this->outgoing_headers['User-Agent']); } @@ -2580,7 +2584,7 @@ class soap_transport_http extends nusoap_base { } } // remove 100 header - if(isset($lb) && ereg('^HTTP/1.1 100',$data)){ + if(isset($lb) && preg_match('/^HTTP/1.1 100/',$data)){ unset($lb); $data = ''; }// @@ -2733,7 +2737,7 @@ class soap_transport_http extends nusoap_base { curl_close($this->ch); // remove 100 header(s) - while (ereg('^HTTP/1.1 100',$data)) { + while (preg_match('#^HTTP/1.1 100#',$data)) { if ($pos = strpos($data,"\r\n\r\n")) { $data = ltrim(substr($data,$pos)); } elseif($pos = strpos($data,"\n\n") ) { @@ -3267,7 +3271,7 @@ class soap_server extends nusoap_base { } $this->debug("In service, query string=$qs"); - if (ereg('wsdl', $qs) ){ + if (preg_match('/wsdl/', $qs) ){ $this->debug("In service, this is a request for WSDL"); if($this->externalWSDLURL){ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL @@ -3338,7 +3342,7 @@ class soap_server extends nusoap_base { // get the character encoding of the incoming request if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){ $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1)); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3367,7 +3371,7 @@ class soap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3401,7 +3405,7 @@ class soap_server extends nusoap_base { $enc = substr(strstr($v, '='), 1); $enc = str_replace('"', '', $enc); $enc = str_replace('\\', '', $enc); - if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) { + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) { $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -3730,7 +3734,7 @@ class soap_server extends nusoap_base { $payload .= $this->getDebugAsXMLComment(); } $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; - ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev); + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")"; // Let the Web server decide about this //$this->outgoing_headers[] = "Connection: Close\r\n"; @@ -3818,7 +3822,7 @@ class soap_server extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; @@ -4336,7 +4340,7 @@ class wsdl extends nusoap_base { $this->currentSchema->schemaStartElement($parser, $name, $attrs); $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); - } elseif (ereg('schema$', $name)) { + } elseif (preg_match('/schema$/', $name)) { $this->debug('Parsing WSDL schema'); // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")"); $this->status = 'schema'; @@ -4355,7 +4359,7 @@ class wsdl extends nusoap_base { if (count($attrs) > 0) { // register namespace declarations foreach($attrs as $k => $v) { - if (ereg("^xmlns", $k)) { + if (preg_match("/^xmlns/", $k)) { if ($ns_prefix = substr(strrchr($k, ':'), 1)) { $this->namespaces[$ns_prefix] = $v; } else { @@ -4380,7 +4384,7 @@ class wsdl extends nusoap_base { $attrs = array(); } // get element prefix, namespace and name - if (ereg(':', $name)) { + if (preg_match('/:/', $name)) { // get ns prefix $prefix = substr($name, 0, strpos($name, ':')); // get ns @@ -4545,7 +4549,7 @@ class wsdl extends nusoap_base { */ function end_element($parser, $name){ // unset schema status - if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) { + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; $this->appendDebug($this->currentSchema->getDebug()); $this->currentSchema->clearDebug(); @@ -5995,7 +5999,7 @@ class soap_parser extends nusoap_base { $key_localpart = $this->getLocalPart($key); // if ns declarations, add to class level array of valid namespaces if($key_prefix == 'xmlns'){ - if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){ + if(preg_match('#^http://www.w3.org/[0-9]{4}/XMLSchema$#',$value)){ $this->XMLSchemaVersion = $value; $this->namespaces['xsd'] = $this->XMLSchemaVersion; $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; @@ -6031,8 +6035,8 @@ class soap_parser extends nusoap_base { [5] length ::= nextDimension* Digit+ [6] nextDimension ::= Digit+ ',' */ - $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; - if(ereg($expr,$value,$regs)){ + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]'; + if(preg_match($expr,$value,$regs)){ $this->message[$pos]['typePrefix'] = $regs[1]; $this->message[$pos]['arrayTypePrefix'] = $regs[1]; if (isset($this->namespaces[$regs[1]])) { @@ -6758,7 +6762,7 @@ class soap_client extends nusoap_base { // detect transport switch(true){ // http(s) - case ereg('^http',$this->endpoint): + case preg_match('/^http/',$this->endpoint): $this->debug('transporting via HTTP'); if($this->persistentConnection == true && is_object($this->persistentConnection)){ $http =& $this->persistentConnection; @@ -6780,10 +6784,10 @@ class soap_client extends nusoap_base { $http->setEncoding($this->http_encoding); } $this->debug('sending message, length='.strlen($msg)); - if(ereg('^http:',$this->endpoint)){ + if(preg_match('/^http:/',$this->endpoint)){ //if(strpos($this->endpoint,'http:')){ $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); - } elseif(ereg('^https',$this->endpoint)){ + } elseif(preg_match('/^https/',$this->endpoint)){ //} elseif(strpos($this->endpoint,'https:')){ //if(phpversion() == '4.3.0-dev'){ //$response = $http->send($msg,$timeout,$response_timeout); @@ -6841,7 +6845,7 @@ class soap_client extends nusoap_base { if (strpos($headers['content-type'], '=')) { $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1)); $this->debug('Got response encoding: ' . $enc); - if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){ + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){ $this->xml_encoding = strtoupper($enc); } else { $this->xml_encoding = 'US-ASCII'; diff --git a/lib/tcpdf/README_MOODLE.txt b/lib/tcpdf/README_MOODLE.txt new file mode 100644 index 00000000000..883654c5272 --- /dev/null +++ b/lib/tcpdf/README_MOODLE.txt @@ -0,0 +1,26 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: html2pdf.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/tcpdf/Attic/html2pdf.php,v +retrieving revision 1.1 +diff -u -r1.1 html2pdf.php +--- html2pdf.php 2 Feb 2007 18:38:05 -0000 1.1 ++++ html2pdf.php 18 Nov 2009 06:51:34 -0000 +@@ -1,5 +1,5 @@ + OpenTag($tag,$attr); + } diff --git a/lib/tcpdf/html2pdf.php b/lib/tcpdf/html2pdf.php index acfecb11c4f..385fe2ed3c1 100644 --- a/lib/tcpdf/html2pdf.php +++ b/lib/tcpdf/html2pdf.php @@ -1,5 +1,5 @@ OpenTag($tag,$attr); } diff --git a/lib/typo3/README_MOODLE.txt b/lib/typo3/README_MOODLE.txt new file mode 100644 index 00000000000..80461d7f9d7 --- /dev/null +++ b/lib/typo3/README_MOODLE.txt @@ -0,0 +1,359 @@ +18 Nov 2009 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below. + +Index: class.t3lib_cs.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/typo3/class.t3lib_cs.php,v +retrieving revision 1.7 +diff -u -r1.7 class.t3lib_cs.php +--- class.t3lib_cs.php 11 Aug 2006 09:48:35 -0000 1.7 ++++ class.t3lib_cs.php 18 Nov 2009 06:53:50 -0000 +@@ -781,8 +781,8 @@ + $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES)); // Getting them in iso-8859-1 - but thats ok since this is observed below. + } + +- $token = md5(microtime()); +- $parts = explode($token,ereg_replace('(&([#[:alnum:]]*);)',$token.'\2'.$token,$str)); ++ $token = 'a'.md5(microtime());//token must start with a letter or preg_replace substitution won't work ++ $parts = explode($token,preg_replace('/(&([#[:alnum:]]*);)/',$token.'\2'.$token,$str)); + foreach($parts as $k => $v) { + if ($k%2) { + if (substr($v,0,1)=='#') { // Dec or hex entities: +@@ -974,13 +974,13 @@ + + // Detect type if not done yet: (Done on first real line) + // The "whitespaced" type is on the syntax "0x0A 0x000A #LINE FEED" while "ms-token" is like "B9 = U+00B9 : SUPERSCRIPT ONE" +- if (!$detectedType) $detectedType = ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value) ? 'whitespaced' : 'ms-token'; ++ if (!$detectedType) $detectedType = preg_match('/[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+/',$value) ? 'whitespaced' : 'ms-token'; + + if ($detectedType=='ms-token') { + list($hexbyte,$utf8) = split('=|:',$value,3); + } elseif ($detectedType=='whitespaced') { + $regA=array(); +- ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value,$regA); ++ preg_match('/[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+/',$value,$regA); + $hexbyte = $regA[1]; + $utf8 = 'U+'.$regA[2]; + } +@@ -1084,7 +1084,7 @@ + + // accented Latin letters without "official" decomposition + $match = array(); +- if (ereg('^LATIN (SMALL|CAPITAL) LETTER ([A-Z]) WITH',$name,$match) && !$decomp) { ++ if (preg_match('/^LATIN (SMALL|CAPITAL) LETTER ([A-Z]) WITH/',$name,$match) && !$decomp) { + $c = ord($match[2]); + if ($match[1] == 'SMALL') $c += 32; + +@@ -1093,7 +1093,7 @@ + } + + $match = array(); +- if (ereg('(<.*>)? *(.+)',$decomp,$match)) { ++ if (preg_match('/(<.*>)? *(.+)/',$decomp,$match)) { + switch($match[1]) { + case '': // add parenthesis as circle replacement, eg (1) + $match[2] = '0028 '.$match[2].' 0029'; +@@ -1104,7 +1104,7 @@ + break; + + case '': // ignore multi char decompositions that start with a space +- if (ereg('^0020 ',$match[2])) continue 2; ++ if (preg_match('/^0020 /',$match[2])) continue 2; + break; + + // ignore Arabic and vertical layout presentation decomposition +Index: class.t3lib_div.php +=================================================================== +RCS file: /cvsroot/moodle/moodle/lib/typo3/class.t3lib_div.php,v +retrieving revision 1.2 +diff -u -r1.2 class.t3lib_div.php +--- class.t3lib_div.php 17 Oct 2005 15:48:29 -0000 1.2 ++++ class.t3lib_div.php 18 Nov 2009 06:53:51 -0000 +@@ -798,7 +798,7 @@ + * @return array Contains keys [path], [file], [filebody], [fileext], [realFileext] + */ + function split_fileref($fileref) { +- if ( ereg('(.*/)(.*)$',$fileref,$reg) ) { ++ if ( preg_match('#(.*/)(.*)$#',$fileref,$reg) ) { + $info['path'] = $reg[1]; + $info['file'] = $reg[2]; + } else { +@@ -806,7 +806,7 @@ + $info['file'] = $fileref; + } + $reg=''; +- if ( ereg('(.*)\.([^\.]*$)',$info['file'],$reg) ) { ++ if ( preg_match('/(.*)\.([^\.]*$)/',$info['file'],$reg) ) { + $info['filebody'] = $reg[1]; + $info['fileext'] = strtolower($reg[2]); + $info['realFileext'] = $reg[2]; +@@ -882,7 +882,7 @@ + * @return string + */ + function rm_endcomma($string) { +- return ereg_replace(',$','',$string); ++ return preg_replace('/,$/','',$string); + } + + /** +@@ -896,7 +896,7 @@ + */ + function danish_strtoupper($string) { + $value = strtoupper($string); +- return strtr($value, 'áéúíâêûôîæøåäöü', 'ÃÉÚÃÄËÜÖÃÆØÅÄÖÜ'); ++ return strtr($value, 'ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ', 'ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ'); + } + + /** +@@ -904,13 +904,13 @@ + * Only known characters will be converted, so don't expect a result for any character. + * (DEPRECIATED: Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!) + * +- * ä => ae, Ö => Oe ++ * ᅵ => ae, ᅵ => Oe + * + * @param string String to convert. + * @return string + */ + function convUmlauts($str) { +- $pat = array ( '/ä/', '/Ä/', '/ö/', '/Ö/', '/ü/', '/Ü/', '/ß/', '/Ã¥/', '/Ã…/', '/ø/', '/Ø/', '/æ/', '/Æ/' ); ++ $pat = array ( '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/', '/ᅵ/' ); + $repl = array ( 'ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'aa', 'AA', 'oe', 'OE', 'ae', 'AE' ); + return preg_replace($pat,$repl,$str); + } +@@ -1022,7 +1022,7 @@ + * @see calcParenthesis() + */ + function calcPriority($string) { +- $string=ereg_replace('[[:space:]]*','',$string); // removing all whitespace ++ $string=preg_replace('/[ ]*/','',$string); // removing all whitespace + $string='+'.$string; // Ensuring an operator for the first entrance + $qm='\*\/\+-^%'; + $regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)'; +@@ -1103,7 +1103,7 @@ + * @return string Converted result. + */ + function deHSCentities($str) { +- return ereg_replace('&([#[:alnum:]]*;)','&\1',$str); ++ return preg_replace('/&([#A-Za-z0-9]*;)/','&\1',$str); + } + + /** +@@ -1154,7 +1154,7 @@ + function validEmail($email) { + $email = trim ($email); + if (strstr($email,' ')) return FALSE; +- return ereg('^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$',$email) ? TRUE : FALSE; ++ return preg_match('/^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$/',$email) ? TRUE : FALSE; + } + + /** +@@ -1555,7 +1555,7 @@ + $name = ''; + } + } else { +- if ($key = strtolower(ereg_replace('[^a-zA-Z0-9]','',$val))) { ++ if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/','',$val))) { + $attributes[$key] = ''; + $name = $key; + } +@@ -1580,9 +1580,9 @@ + * @internal + */ + function split_tag_attributes($tag) { +- $tag_tmp = trim(eregi_replace ('^<[^[:space:]]*','',trim($tag))); ++ $tag_tmp = trim(preg_replace ('/^<[^[:space:]]*/i','',trim($tag))); + // Removes any > in the end of the string +- $tag_tmp = trim(eregi_replace ('>$','',$tag_tmp)); ++ $tag_tmp = trim(preg_replace ('/>$/i','',$tag_tmp)); + + while (strcmp($tag_tmp,'')) { // Compared with empty string instead , 030102 + $firstChar=substr($tag_tmp,0,1); +@@ -1653,7 +1653,7 @@ + * @param boolean Wrap script element in linebreaks? Default is TRUE. + * @return string The wrapped JS code, ready to put into a XHTML page + * @author Ingmar Schlecht +- * @author René Fritz ++ * @author Renᅵ Fritz + */ + function wrapJS($string, $linebreak=TRUE) { + if(trim($string)) { +@@ -1813,7 +1813,7 @@ + } + + // The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either. +- $tagName = substr(ereg_replace('[^[:alnum:]_-]','',$tagName),0,100); ++ $tagName = substr(preg_replace('/[^[:alnum:]_-]/','',$tagName),0,100); + + // If the value is an array then we will call this function recursively: + if (is_array($v)) { +@@ -1902,7 +1902,7 @@ + // What we do here fixes the problem but ONLY if the charset is utf-8, iso-8859-1 or us-ascii. That should work for most TYPO3 installations, in particular if people use utf-8 which we highly recommend. + if ((double)phpversion()>=5) { + unset($ereg_result); +- ereg('^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"',substr($string,0,200),$ereg_result); ++ preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$ereg_result); + $theCharset = $ereg_result[1] ? $ereg_result[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1'); + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1 + } +@@ -2042,7 +2042,7 @@ + function xmlGetHeaderAttribs($xmlData) { + $xmlHeader = substr(trim($xmlData),0,200); + $reg=array(); +- if (eregi('^<\?xml([^>]*)\?\>',$xmlHeader,$reg)) { ++ if (preg_match('/^<\?xml([^>]*)\?\>/i',$xmlHeader,$reg)) { + return t3lib_div::get_tag_attributes($reg[1]); + } + } +@@ -2163,7 +2163,7 @@ + // Checking if the "subdir" is found: + $subdir = substr($fI['dirname'],strlen($dirName)); + if ($subdir) { +- if (ereg('^[[:alnum:]_]+\/$',$subdir)) { ++ if (preg_match('#^[[:alnum:]_]+\/$#',$subdir)) { + $dirName.= $subdir; + if (!@is_dir($dirName)) { + t3lib_div::mkdir($dirName); +@@ -2191,7 +2191,7 @@ + * @return boolean TRUE if @mkdir went well! + */ + function mkdir($theNewFolder) { +- $theNewFolder = ereg_replace('\/$','',$theNewFolder); ++ $theNewFolder = preg_replace('#\/$#','',$theNewFolder); + if (mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){ + chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes + +@@ -2240,7 +2240,7 @@ + // Initialize variabels: + $filearray = array(); + $sortarray = array(); +- $path = ereg_replace('\/$','',$path); ++ $path = preg_replace('#\/$#','',$path); + + // Find files+directories: + if (@is_dir($path)) { +@@ -2564,7 +2564,7 @@ + + $pString = t3lib_div::implodeArrayForUrl('',$params); + +- return $pString ? $parts.'?'.ereg_replace('^&','',$pString) : $parts; ++ return $pString ? $parts.'?'.preg_replace('/^&/','',$pString) : $parts; + } + + /** +@@ -2673,7 +2673,7 @@ + case 'REQUEST_URI': + // Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) + if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available. +- return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')). ++ return '/'.preg_replace('#^/#','',t3lib_div::getIndpEnv('SCRIPT_NAME')). + ($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:''); + } else return $_SERVER['REQUEST_URI']; + break; +@@ -2826,11 +2826,11 @@ + break; + case 'msie': + $tmp = strstr($useragent,'MSIE'); +- $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4))); ++ $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,4))); + break; + case 'opera': + $tmp = strstr($useragent,'Opera'); +- $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5))); ++ $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,5))); + break; + case 'konqu': + $tmp = strstr($useragent,'Konqueror/'); +@@ -2966,7 +2966,7 @@ + */ + function verifyFilenameAgainstDenyPattern($filename) { + if (strcmp($filename,'') && strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],'')) { +- $result = eregi($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],$filename); ++ $result = preg_match('/'.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'].'/i',$filename); + if ($result) return false; // so if a matching filename is found, return false; + } + return true; +@@ -3126,7 +3126,7 @@ + function readLLfile($fileRef,$langKey) { + $file = t3lib_div::getFileAbsFileName($fileRef); + if ($file) { +- $baseFile = ereg_replace('\.(php|xml)$', '', $file); ++ $baseFile = preg_replace('#\.(php|xml)$#', '', $file); + + if (@is_file($baseFile.'.xml')) { + $LOCAL_LANG = t3lib_div::readLLXMLfile($baseFile.'.xml', $langKey); +@@ -3162,7 +3162,7 @@ + // Cache file name: + $hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)); + $cacheFileName = PATH_site.'typo3temp/llxml/'. +- #str_replace('_','',ereg_replace('^.*\/','',dirname($fileRef))). ++ #str_replace('_','',preg_replace('#^.*\/#','',dirname($fileRef))). + #'_'.basename($fileRef). + substr(basename($fileRef),10,15). + '_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$origCharset.'.cache'; +@@ -3344,7 +3344,7 @@ + + // Check persistent object and if found, call directly and exit. + if (is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName])) { +- return call_user_method( ++ return call_user_func( + $GLOBALS['T3_VAR']['callUserFunction'][$funcName]['method'], + $GLOBALS['T3_VAR']['callUserFunction'][$funcName]['obj'], + $params, +@@ -3405,7 +3405,7 @@ + ); + } + // Call method: +- $content = call_user_method( ++ $content = call_user_func( + $parts[1], + $classObj, + $params, +@@ -3520,7 +3520,7 @@ + * @param string Sub type like file extensions or similar. Defined by the service. + * @param mixed List of service keys which should be exluded in the search for a service. Array or comma list. + * @return object The service object or an array with error info's. +- * @author René Fritz ++ * @author Renᅵ Fritz + */ + function &makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) { + global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS; +@@ -3606,7 +3606,7 @@ + + $message=t3lib_div::quoted_printable($message); + +- if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(ereg_replace('[[:space:]]','_',$subject),1000)).'?='; ++ if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(preg_replace('#/[[:space:]]/#','_',$subject),1000)).'?='; + break; + case '8bit': + $headers=trim($headers).chr(10). +@@ -3657,11 +3657,11 @@ + $len+=3; + } + } +- $newVal = ereg_replace(chr(32).'$','=20',$newVal); // Replaces a possible SPACE-character at the end of a line +- $newVal = ereg_replace(chr(9).'$','=09',$newVal); // Replaces a possible TAB-character at the end of a line ++ $newVal = preg_replace('/'.chr(32).'$/','=20',$newVal); // Replaces a possible SPACE-character at the end of a line ++ $newVal = preg_replace('/'.chr(9).'$/','=09',$newVal); // Replaces a possible TAB-character at the end of a line + $newString.=$newVal.chr(13).chr(10); + } +- return ereg_replace(chr(13).chr(10).'$','',$newString); ++ return preg_replace('/'.chr(13).chr(10).'$/','',$newString); + } + + /** +@@ -3853,12 +3853,12 @@ + if($quoteActive > -1) { + $paramsArr[$quoteActive] .= ' '.$v; + unset($paramsArr[$k]); +- if(ereg('"$', $v)) { $quoteActive = -1; } ++ if(preg_match('/"$/', $v)) { $quoteActive = -1; } + + } elseif(!trim($v)) { + unset($paramsArr[$k]); // Remove empty elements + +- } elseif(ereg('^"', $v)) { ++ } elseif(preg_match('/^"/', $v)) { + $quoteActive = $k; + } + } diff --git a/lib/typo3/class.t3lib_cs.php b/lib/typo3/class.t3lib_cs.php index 28f7b1f7026..2f34caf0c88 100644 --- a/lib/typo3/class.t3lib_cs.php +++ b/lib/typo3/class.t3lib_cs.php @@ -781,8 +781,8 @@ class t3lib_cs { $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES)); // Getting them in iso-8859-1 - but thats ok since this is observed below. } - $token = md5(microtime()); - $parts = explode($token,ereg_replace('(&([#[:alnum:]]*);)',$token.'\2'.$token,$str)); + $token = 'a'.md5(microtime());//token must start with a letter or preg_replace substitution won't work + $parts = explode($token,preg_replace('/(&([#[:alnum:]]*);)/',$token.'\2'.$token,$str)); foreach($parts as $k => $v) { if ($k%2) { if (substr($v,0,1)=='#') { // Dec or hex entities: @@ -974,13 +974,13 @@ class t3lib_cs { // Detect type if not done yet: (Done on first real line) // The "whitespaced" type is on the syntax "0x0A 0x000A #LINE FEED" while "ms-token" is like "B9 = U+00B9 : SUPERSCRIPT ONE" - if (!$detectedType) $detectedType = ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value) ? 'whitespaced' : 'ms-token'; + if (!$detectedType) $detectedType = preg_match('/[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+/',$value) ? 'whitespaced' : 'ms-token'; if ($detectedType=='ms-token') { list($hexbyte,$utf8) = split('=|:',$value,3); } elseif ($detectedType=='whitespaced') { $regA=array(); - ereg('[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+',$value,$regA); + preg_match('/[[:space:]]*0x([[:alnum:]]*)[[:space:]]+0x([[:alnum:]]*)[[:space:]]+/',$value,$regA); $hexbyte = $regA[1]; $utf8 = 'U+'.$regA[2]; } @@ -1084,7 +1084,7 @@ class t3lib_cs { // accented Latin letters without "official" decomposition $match = array(); - if (ereg('^LATIN (SMALL|CAPITAL) LETTER ([A-Z]) WITH',$name,$match) && !$decomp) { + if (preg_match('/^LATIN (SMALL|CAPITAL) LETTER ([A-Z]) WITH/',$name,$match) && !$decomp) { $c = ord($match[2]); if ($match[1] == 'SMALL') $c += 32; @@ -1093,7 +1093,7 @@ class t3lib_cs { } $match = array(); - if (ereg('(<.*>)? *(.+)',$decomp,$match)) { + if (preg_match('/(<.*>)? *(.+)/',$decomp,$match)) { switch($match[1]) { case '': // add parenthesis as circle replacement, eg (1) $match[2] = '0028 '.$match[2].' 0029'; @@ -1104,7 +1104,7 @@ class t3lib_cs { break; case '': // ignore multi char decompositions that start with a space - if (ereg('^0020 ',$match[2])) continue 2; + if (preg_match('/^0020 /',$match[2])) continue 2; break; // ignore Arabic and vertical layout presentation decomposition diff --git a/lib/typo3/class.t3lib_div.php b/lib/typo3/class.t3lib_div.php index cc2c69e0d02..8bafb6e1627 100644 --- a/lib/typo3/class.t3lib_div.php +++ b/lib/typo3/class.t3lib_div.php @@ -798,7 +798,7 @@ class t3lib_div { * @return array Contains keys [path], [file], [filebody], [fileext], [realFileext] */ function split_fileref($fileref) { - if ( ereg('(.*/)(.*)$',$fileref,$reg) ) { + if ( preg_match('#(.*/)(.*)$#',$fileref,$reg) ) { $info['path'] = $reg[1]; $info['file'] = $reg[2]; } else { @@ -806,7 +806,7 @@ class t3lib_div { $info['file'] = $fileref; } $reg=''; - if ( ereg('(.*)\.([^\.]*$)',$info['file'],$reg) ) { + if ( preg_match('/(.*)\.([^\.]*$)/',$info['file'],$reg) ) { $info['filebody'] = $reg[1]; $info['fileext'] = strtolower($reg[2]); $info['realFileext'] = $reg[2]; @@ -882,7 +882,7 @@ class t3lib_div { * @return string */ function rm_endcomma($string) { - return ereg_replace(',$','',$string); + return preg_replace('/,$/','',$string); } /** @@ -896,7 +896,7 @@ class t3lib_div { */ function danish_strtoupper($string) { $value = strtoupper($string); - return strtr($value, 'áéúíâêûôîæøåäöü', 'ÁÉÚÍÄËÜÖÏÆØÅÄÖÜ'); + return strtr($value, '���������������', '���������������'); } /** @@ -904,13 +904,13 @@ class t3lib_div { * Only known characters will be converted, so don't expect a result for any character. * (DEPRECIATED: Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!) * - * ä => ae, Ö => Oe + * � => ae, � => Oe * * @param string String to convert. * @return string */ function convUmlauts($str) { - $pat = array ( '/ä/', '/Ä/', '/ö/', '/Ö/', '/ü/', '/Ü/', '/ß/', '/å/', '/Å/', '/ø/', '/Ø/', '/æ/', '/Æ/' ); + $pat = array ( '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/', '/�/' ); $repl = array ( 'ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'aa', 'AA', 'oe', 'OE', 'ae', 'AE' ); return preg_replace($pat,$repl,$str); } @@ -1022,7 +1022,7 @@ class t3lib_div { * @see calcParenthesis() */ function calcPriority($string) { - $string=ereg_replace('[[:space:]]*','',$string); // removing all whitespace + $string=preg_replace('/[ ]*/','',$string); // removing all whitespace $string='+'.$string; // Ensuring an operator for the first entrance $qm='\*\/\+-^%'; $regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)'; @@ -1103,7 +1103,7 @@ class t3lib_div { * @return string Converted result. */ function deHSCentities($str) { - return ereg_replace('&([#[:alnum:]]*;)','&\1',$str); + return preg_replace('/&([#A-Za-z0-9]*;)/','&\1',$str); } /** @@ -1154,7 +1154,7 @@ class t3lib_div { function validEmail($email) { $email = trim ($email); if (strstr($email,' ')) return FALSE; - return ereg('^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$',$email) ? TRUE : FALSE; + return preg_match('/^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$/',$email) ? TRUE : FALSE; } /** @@ -1555,7 +1555,7 @@ class t3lib_div { $name = ''; } } else { - if ($key = strtolower(ereg_replace('[^a-zA-Z0-9]','',$val))) { + if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/','',$val))) { $attributes[$key] = ''; $name = $key; } @@ -1580,9 +1580,9 @@ class t3lib_div { * @internal */ function split_tag_attributes($tag) { - $tag_tmp = trim(eregi_replace ('^<[^[:space:]]*','',trim($tag))); + $tag_tmp = trim(preg_replace ('/^<[^[:space:]]*/i','',trim($tag))); // Removes any > in the end of the string - $tag_tmp = trim(eregi_replace ('>$','',$tag_tmp)); + $tag_tmp = trim(preg_replace ('/>$/i','',$tag_tmp)); while (strcmp($tag_tmp,'')) { // Compared with empty string instead , 030102 $firstChar=substr($tag_tmp,0,1); @@ -1653,7 +1653,7 @@ class t3lib_div { * @param boolean Wrap script element in linebreaks? Default is TRUE. * @return string The wrapped JS code, ready to put into a XHTML page * @author Ingmar Schlecht - * @author René Fritz + * @author Ren� Fritz */ function wrapJS($string, $linebreak=TRUE) { if(trim($string)) { @@ -1813,7 +1813,7 @@ class t3lib_div { } // The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either. - $tagName = substr(ereg_replace('[^[:alnum:]_-]','',$tagName),0,100); + $tagName = substr(preg_replace('/[^[:alnum:]_-]/','',$tagName),0,100); // If the value is an array then we will call this function recursively: if (is_array($v)) { @@ -1902,7 +1902,7 @@ class t3lib_div { // What we do here fixes the problem but ONLY if the charset is utf-8, iso-8859-1 or us-ascii. That should work for most TYPO3 installations, in particular if people use utf-8 which we highly recommend. if ((double)phpversion()>=5) { unset($ereg_result); - ereg('^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"',substr($string,0,200),$ereg_result); + preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$ereg_result); $theCharset = $ereg_result[1] ? $ereg_result[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1'); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1 } @@ -2042,7 +2042,7 @@ class t3lib_div { function xmlGetHeaderAttribs($xmlData) { $xmlHeader = substr(trim($xmlData),0,200); $reg=array(); - if (eregi('^<\?xml([^>]*)\?\>',$xmlHeader,$reg)) { + if (preg_match('/^<\?xml([^>]*)\?\>/i',$xmlHeader,$reg)) { return t3lib_div::get_tag_attributes($reg[1]); } } @@ -2163,7 +2163,7 @@ class t3lib_div { // Checking if the "subdir" is found: $subdir = substr($fI['dirname'],strlen($dirName)); if ($subdir) { - if (ereg('^[[:alnum:]_]+\/$',$subdir)) { + if (preg_match('#^[[:alnum:]_]+\/$#',$subdir)) { $dirName.= $subdir; if (!@is_dir($dirName)) { t3lib_div::mkdir($dirName); @@ -2191,7 +2191,7 @@ class t3lib_div { * @return boolean TRUE if @mkdir went well! */ function mkdir($theNewFolder) { - $theNewFolder = ereg_replace('\/$','',$theNewFolder); + $theNewFolder = preg_replace('#\/$#','',$theNewFolder); if (mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){ chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes @@ -2240,7 +2240,7 @@ class t3lib_div { // Initialize variabels: $filearray = array(); $sortarray = array(); - $path = ereg_replace('\/$','',$path); + $path = preg_replace('#\/$#','',$path); // Find files+directories: if (@is_dir($path)) { @@ -2564,7 +2564,7 @@ class t3lib_div { $pString = t3lib_div::implodeArrayForUrl('',$params); - return $pString ? $parts.'?'.ereg_replace('^&','',$pString) : $parts; + return $pString ? $parts.'?'.preg_replace('/^&/','',$pString) : $parts; } /** @@ -2673,7 +2673,7 @@ class t3lib_div { case 'REQUEST_URI': // Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available. - return '/'.ereg_replace('^/','',t3lib_div::getIndpEnv('SCRIPT_NAME')). + return '/'.preg_replace('#^/#','',t3lib_div::getIndpEnv('SCRIPT_NAME')). ($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:''); } else return $_SERVER['REQUEST_URI']; break; @@ -2826,11 +2826,11 @@ class t3lib_div { break; case 'msie': $tmp = strstr($useragent,'MSIE'); - $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,4))); + $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,4))); break; case 'opera': $tmp = strstr($useragent,'Opera'); - $bInfo['VERSION'] = doubleval(ereg_replace('^[^0-9]*','',substr($tmp,5))); + $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,5))); break; case 'konqu': $tmp = strstr($useragent,'Konqueror/'); @@ -2966,7 +2966,7 @@ class t3lib_div { */ function verifyFilenameAgainstDenyPattern($filename) { if (strcmp($filename,'') && strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],'')) { - $result = eregi($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],$filename); + $result = preg_match('/'.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'].'/i',$filename); if ($result) return false; // so if a matching filename is found, return false; } return true; @@ -3126,7 +3126,7 @@ class t3lib_div { function readLLfile($fileRef,$langKey) { $file = t3lib_div::getFileAbsFileName($fileRef); if ($file) { - $baseFile = ereg_replace('\.(php|xml)$', '', $file); + $baseFile = preg_replace('#\.(php|xml)$#', '', $file); if (@is_file($baseFile.'.xml')) { $LOCAL_LANG = t3lib_div::readLLXMLfile($baseFile.'.xml', $langKey); @@ -3162,7 +3162,7 @@ class t3lib_div { // Cache file name: $hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)); $cacheFileName = PATH_site.'typo3temp/llxml/'. - #str_replace('_','',ereg_replace('^.*\/','',dirname($fileRef))). + #str_replace('_','',preg_replace('#^.*\/#','',dirname($fileRef))). #'_'.basename($fileRef). substr(basename($fileRef),10,15). '_'.t3lib_div::shortMD5($hashSource).'.'.$langKey.'.'.$origCharset.'.cache'; @@ -3344,7 +3344,7 @@ class t3lib_div { // Check persistent object and if found, call directly and exit. if (is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName])) { - return call_user_method( + return call_user_func( $GLOBALS['T3_VAR']['callUserFunction'][$funcName]['method'], $GLOBALS['T3_VAR']['callUserFunction'][$funcName]['obj'], $params, @@ -3405,7 +3405,7 @@ class t3lib_div { ); } // Call method: - $content = call_user_method( + $content = call_user_func( $parts[1], $classObj, $params, @@ -3520,7 +3520,7 @@ class t3lib_div { * @param string Sub type like file extensions or similar. Defined by the service. * @param mixed List of service keys which should be exluded in the search for a service. Array or comma list. * @return object The service object or an array with error info's. - * @author René Fritz + * @author Ren� Fritz */ function &makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) { global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS; @@ -3606,7 +3606,7 @@ class t3lib_div { $message=t3lib_div::quoted_printable($message); - if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(ereg_replace('[[:space:]]','_',$subject),1000)).'?='; + if (!$dontEncodeSubject) $subject='=?'.$charset.'?Q?'.trim(t3lib_div::quoted_printable(preg_replace('#/[[:space:]]/#','_',$subject),1000)).'?='; break; case '8bit': $headers=trim($headers).chr(10). @@ -3657,11 +3657,11 @@ class t3lib_div { $len+=3; } } - $newVal = ereg_replace(chr(32).'$','=20',$newVal); // Replaces a possible SPACE-character at the end of a line - $newVal = ereg_replace(chr(9).'$','=09',$newVal); // Replaces a possible TAB-character at the end of a line + $newVal = preg_replace('/'.chr(32).'$/','=20',$newVal); // Replaces a possible SPACE-character at the end of a line + $newVal = preg_replace('/'.chr(9).'$/','=09',$newVal); // Replaces a possible TAB-character at the end of a line $newString.=$newVal.chr(13).chr(10); } - return ereg_replace(chr(13).chr(10).'$','',$newString); + return preg_replace('/'.chr(13).chr(10).'$/','',$newString); } /** @@ -3853,12 +3853,12 @@ class t3lib_div { if($quoteActive > -1) { $paramsArr[$quoteActive] .= ' '.$v; unset($paramsArr[$k]); - if(ereg('"$', $v)) { $quoteActive = -1; } + if(preg_match('/"$/', $v)) { $quoteActive = -1; } } elseif(!trim($v)) { unset($paramsArr[$k]); // Remove empty elements - } elseif(ereg('^"', $v)) { + } elseif(preg_match('/^"/', $v)) { $quoteActive = $k; } } diff --git a/lib/validateurlsyntax.php b/lib/validateurlsyntax.php index f42e2914cd4..9e22eff335e 100755 --- a/lib/validateurlsyntax.php +++ b/lib/validateurlsyntax.php @@ -174,7 +174,7 @@ function validateUrlSyntax( $urladdr, $options="" ){ // $options = strtolower($options); // Check Options Parameter - if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) + if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options )) { trigger_error("Options attribute malformed", E_USER_ERROR); } @@ -305,17 +305,18 @@ function validateUrlSyntax( $urladdr, $options="" ){ $querystring = '(\?(' . $reserved . '|' . $unreserved . '|' . $escaped . ')*)' . $aOptions['q']; // Fragment Section - Accepts anchors such as #top - $fragment = '(#(' . $reserved . '|' . $unreserved . '|' . $escaped . ')*)' . $aOptions['r']; + $fragment = '(\#(' . $reserved . '|' . $unreserved . '|' . $escaped . ')*)' . $aOptions['r']; // Building Regular Expression - $regexp = '^' . $scheme . $userinfo . $address . $port_number . $path . $querystring . $fragment . '$'; + $regexp = '#^' . $scheme . $userinfo . $address . $port_number . $path . $querystring . $fragment . '$' . '#i'; + //die($regexp); // DEBUGGING - Uncomment Line Below To Display The Regular Expression Built // echo '
' . htmlentities(wordwrap($regexp,70,"\n",1)) . '
'; // Running the regular expression - if (eregi( $regexp, $urladdr )) + if (preg_match( $regexp, $urladdr )) { return true; // The domain passed } @@ -377,7 +378,7 @@ License: function validateEmailSyntax( $emailaddr, $options="" ){ // Check Options Parameter - if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) + if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options )) { trigger_error("Options attribute malformed", E_USER_ERROR); } @@ -483,7 +484,7 @@ License: function validateFtpSyntax( $ftpaddr, $options="" ){ // Check Options Parameter - if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) + if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options )) { trigger_error("Options attribute malformed", E_USER_ERROR); } diff --git a/lib/weblib.php b/lib/weblib.php index b849be30685..5a9082c2c86 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1355,11 +1355,11 @@ function formerr($error) { */ function validate_email($address) { - return (ereg('^[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'. - '(\.[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'. + return (validate_email('#^[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+'. + '(\.[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+)*'. '@'. - '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. - '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', + '[-!\#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. + '[-!\#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$#', $address)); } @@ -1791,7 +1791,7 @@ function format_text_email($text, $format) { $text = wiki_to_html($text); /// This expression turns links into something nice in a text format. (Russell Jungwirth) /// From: http://php.net/manual/en/function.eregi-replace.php and simplified - $text = eregi_replace('(]*>([^<]*))','\\3 [ \\2 ]', $text); + $text = preg_replace('/(]*>([^<]*))/i','\\3 [ \\2 ]', $text); return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); break; @@ -1802,7 +1802,7 @@ function format_text_email($text, $format) { case FORMAT_MOODLE: case FORMAT_MARKDOWN: default: - $text = eregi_replace('(]*>([^<]*))','\\3 [ \\2 ]', $text); + $text = preg_replace('/(]*>([^<]*))/i','\\3 [ \\2 ]', $text); return strtr(strip_tags($text), array_flip(get_html_translation_table(HTML_ENTITIES))); break; } @@ -2038,8 +2038,8 @@ function clean_text($text, $format=FORMAT_MOODLE) { } /// Remove potential script events - some extra protection for undiscovered bugs in our code - $text = eregi_replace("([^a-z])language([[:space:]]*)=", "\\1Xlanguage=", $text); - $text = eregi_replace("([^a-z])on([a-z]+)([[:space:]]*)=", "\\1Xon\\2=", $text); + $text = preg_replace("/([^a-z])language([[:space:]]*)=/i", "\\1Xlanguage=", $text); + $text = preg_replace("/([^a-z])on([a-z]+)([[:space:]]*)=/i", "\\1Xon\\2=", $text); return $text; } @@ -2238,11 +2238,11 @@ function text_to_html($text, $smiley=true, $para=true, $newlines=true) { global $CFG; /// Remove any whitespace that may be between HTML tags - $text = eregi_replace(">([[:space:]]+)<", "><", $text); + $text = preg_replace("/>([[:space:]]+)<", $text); /// Remove any returns that precede or follow HTML tags - $text = eregi_replace("([\n\r])<", " <", $text); - $text = eregi_replace(">([\n\r])", "> ", $text); + $text = preg_replace("/([\n\r])([\n\r])/i", "> ", $text); convert_urls_into_links($text); @@ -2305,11 +2305,11 @@ function html_to_text($html) { */ function convert_urls_into_links(&$text) { /// Make lone URLs into links. eg http://moodle.com/ - $text = eregi_replace("([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", + $text = preg_replace("#([[:space:]]|^|\(|\[)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1\\2://\\3\\4", $text); /// eg www.moodle.com - $text = eregi_replace("([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]#?/&=])", + $text = preg_replace("#([[:space:]]|^|\(|\[)www\.([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1www.\\2\\3", $text); } diff --git a/lib/wiki_to_markdown.php b/lib/wiki_to_markdown.php index f1ad19a503e..883c62e3144 100644 --- a/lib/wiki_to_markdown.php +++ b/lib/wiki_to_markdown.php @@ -59,14 +59,14 @@ class WikiToMarkdown { // BODGE: replace inline $mark characters in places where we want them ignored // they will be put back after main substitutue, stops problems with eg, and/or $bodge = chr(1); - $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line ); + $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line ); - $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)'; + $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i'; $replace = '\\1<'.$tag.'>\\2\\3'; - $line = eregi_replace( $regex, $replace, $line ); + $line = preg_replace( $regex, $replace, $line ); // BODGE: back we go - $line = eregi_replace( $bodge, $mark, $line ); + $line = preg_replace( '/'.$bodge.'/i', $mark, $line ); return $line; } @@ -80,14 +80,14 @@ class WikiToMarkdown { // BODGE: replace inline $mark characters in places where we want them ignored // they will be put back after main substitutue, stops problems with eg, and/or $bodge = chr(1); - $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line ); + $line = preg_replace( '/([[:alnum:]])'.$mark.'([[:alnum:]])/i', '\\1'.$bodge.'\\2',$line ); - $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)'; + $regex = '/(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]]|$)/i'; $replace = '\\1'.$tag.'\\2'.$tag.'\\3'; - $line = eregi_replace( $regex, $replace, $line ); + $line = preg_replace( $regex, $replace, $line ); // BODGE: back we go - $line = eregi_replace( $bodge, $mark, $line ); + $line = preg_replace( '/'.$bodge.'/i', $mark, $line ); return $line; } @@ -97,10 +97,10 @@ class WikiToMarkdown { // do regex for subscript and superscript (slightly different) // $mark is the magic character and $tag the HTML tag to insert - $regex = $mark.'([^'.$mark.']*)'.$mark; + $regex = '/'.$mark.'([^'.$mark.']*)'.$mark.'/i'; $replace = '<'.$tag.'>\\1'; - return eregi_replace( $regex, $replace, $line ); + return preg_replace( $regex, $replace, $line ); } function do_list( $line, $blank=false ) { @@ -115,7 +115,7 @@ class WikiToMarkdown { else { $listchar = $line{0}; $count = strspn( $line, $listchar ); - $line = eregi_replace( "^[".$listchar."]+ ", "", $line ); + $line = preg_replace( "/^[".$listchar."]+ /i", "", $line ); } // find what sort of list this character represents @@ -198,7 +198,7 @@ class WikiToMarkdown { // MARKDOWN: no change so leave // is this a list line (starts with * # ; :) - if (eregi( "^([*]+|[#]+|[;]+|[:]+) ", $line )) { + if (preg_match( "/^([*]+|[#]+|[;]+|[:]+) /i", $line )) { $line = $this->do_list( $line ); } @@ -215,7 +215,7 @@ class WikiToMarkdown { $line = str_replace( "1/4", "¼", $line ); $line = str_replace( "1/2", "½", $line ); $line = str_replace( "3/4", "¾", $line ); - $line = eregi_replace( "([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)", "\\1×\\2", $line ); // (digits) x (digits) - multiply + $line = preg_replace( "/([[:digit:]]+[[:space:]]*)x([[:space:]]*[[:digit:]]+)/i", "\\1×\\2", $line ); // (digits) x (digits) - multiply // do formatting tags // NOTE: The / replacement *has* to be first, or it will screw the // HTML tags that are added by the other ones @@ -231,48 +231,48 @@ class WikiToMarkdown { // convert urls into proper link with optional link text URL(text) // MARDOWN: HTML conversion should work fine - $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)", + $line = preg_replace("#([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])\(([^)]+)\)#i", "\\1[\\5](\\2://\\3\\4)", $line); - $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])\(([^)]+)\)", + $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?\/&=])\(([^)]+)\)/i", "\\1[\\5](http://www.\\2\\3)", $line); // make urls (with and without httpd) into proper links - $line = eregi_replace("([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", + $line = preg_replace("#([[:space:]]|^)([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]\#?/&=])#i", "\\1<\\2://\\3\\4>", $line); - $line = eregi_replace("([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])", + $line = preg_replace("/([[:space:]])www\.([^[:space:]]*)([[:alnum:]#?/&=])/i", "\\1", $line); // make email addresses into mailtos.... // MARKDOWN doesn't quite support this, so do as html - $line = eregi_replace("([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)", + $line = preg_replace("/([[:space:]]|^)([[:alnum:]._-]+@[[:alnum:]._-]+)\(([^)]+)\)/i", "\\1\\3", $line); // !# at the beginning of any lines means a heading // MARKDOWN: value (1-6) becomes number of hashes - if (eregi( "^!([1-6]) (.*)$", $line, $regs )) { + if (preg( "/^!([1-6]) (.*)$/i", $line, $regs )) { $depth = substr( $line, 1, 1 ); $out = substr( '##########', 0, $depth); - $line = eregi_replace( "^!([1-6]) (.*)$", "$out \\2", $line ); + $line = preg_replace( "/^!([1-6]) (.*)$/i", "$out \\2", $line ); } // acronym handing, example HTML(Hypertext Markyp Language) // MARKDOWN: no equiv. so just leave as HTML - $line = ereg_replace( "([A-Z]+)\(([^)]+)\)", "\\1", $line ); + $line = preg_replace( "/([A-Z]+)\(([^)]+)\)/", "\\1", $line ); // Replace resource link >>##(Description Text) // MARKDOWN: change to MD web link style - $line = eregi_replace( " ([a-zA-Z]+):([0-9]+)\(([^)]+)\)", + $line = preg_replace( "/ ([a-zA-Z]+):([0-9]+)\(([^)]+)\)/i", " [\\3](".$CFG->wwwroot."/mod/\\1/view.php?id=\\2) ", $line ); require_once($CFG->libdir.'/filelib.php'); $coursefileurl = get_file_url($this->courseid); // Replace picture resource link - $line = eregi_replace( "/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)", + $line = preg_replace( "#/([a-zA-Z0-9./_-]+)(png|gif|jpg)\(([^)]+)\)#i", "![\\3](".$coursefileurl."/\\1\\2)", $line ); // Replace file resource link - $line = eregi_replace( "file:/([[:alnum:]/._-]+)\(([^)]+)\)", + $line = preg_replace( "#file:/([[:alnum:]/._-]+)\(([^)]+)\)#i", "[\\2](".$coursefileurl."/\\1)", $line ); return $line; @@ -300,7 +300,7 @@ class WikiToMarkdown { // run through lines foreach( $lines as $line ) { // is this a blank line? - $blank_line = eregi( "^[[:blank:]\r]*$", $line ); + $blank_line = preg_match( "/^[[:blank:]\r]*$/i", $line ); if ($blank_line) { // first end current block according to state $buffer = $buffer . $this->close_block( $this->block_state ); @@ -311,13 +311,13 @@ class WikiToMarkdown { // act now depending on current block state if ($this->block_state == STATE_NONE) { // first character of line defines block type - if (eregi( "^> ",$line )) { + if (preg_match( "/^> /i",$line )) { // blockquote $buffer = $buffer . $this->line_replace( $line ). "\n"; $this->block_state = STATE_BLOCKQUOTE; } else - if (eregi( "^ ",$line) ) { + if (preg_match( "/^ /i",$line) ) { // preformatted text // MARKDOWN: no real equiv. so just use
           $buffer = $buffer . "
\n";
@@ -325,10 +325,10 @@ class WikiToMarkdown {
           $this->block_state = STATE_PREFORM;
         }
         else 
-        if (eregi("^\% ",$line) ) {
+        if (preg_match("/^\% /i",$line) ) {
                 // preformatted text - no processing
                 // MARKDOWN: this is MD code form of a paragraph
-                $buffer = $buffer . "    " . eregi_replace( "^\%","",$line) . "\n";
+                $buffer = $buffer . "    " . preg_replace( "/^\%/i","",$line) . "\n";
                 $this->block_state = STATE_NOTIKI;
         }
         else {
diff --git a/lib/xmldb/README_MOODLE.txt b/lib/xmldb/README_MOODLE.txt
new file mode 100644
index 00000000000..bcbbf84648e
--- /dev/null
+++ b/lib/xmldb/README_MOODLE.txt
@@ -0,0 +1,19 @@
+18 Nov 2009
+Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
+
+Index: classes/XMLDBObject.class.php
+===================================================================
+RCS file: /cvsroot/moodle/moodle/lib/xmldb/classes/Attic/XMLDBObject.class.php,v
+retrieving revision 1.7.2.1
+diff -u -r1.7.2.1 XMLDBObject.class.php
+--- classes/XMLDBObject.class.php	15 Aug 2008 11:09:51 -0000	1.7.2.1
++++ classes/XMLDBObject.class.php	18 Nov 2009 06:55:49 -0000
+@@ -164,7 +164,7 @@
+     function checkName () {
+         $result = true;
+ 
+-        if ($this->name != eregi_replace('[^a-z0-9_ -]', '', $this->name)) {
++        if ($this->name != preg_replace('/[^a-z0-9_ -]/i', '', $this->name)) {
+             $result = false;
+         }
+         return $result;
diff --git a/lib/xmldb/classes/XMLDBObject.class.php b/lib/xmldb/classes/XMLDBObject.class.php
index 914b34dc521..dfa66680fb5 100644
--- a/lib/xmldb/classes/XMLDBObject.class.php
+++ b/lib/xmldb/classes/XMLDBObject.class.php
@@ -164,7 +164,7 @@ class XMLDBObject {
     function checkName () {
         $result = true;
 
-        if ($this->name != eregi_replace('[^a-z0-9_ -]', '', $this->name)) {
+        if ($this->name != preg_replace('/[^a-z0-9_ -]/i', '', $this->name)) {
             $result = false;
         }
         return $result;
diff --git a/login/index.php b/login/index.php
index 72a36b9f424..e6dbf8114b7 100644
--- a/login/index.php
+++ b/login/index.php
@@ -109,7 +109,7 @@ httpsrequired();
         $frm->username = trim(moodle_strtolower($frm->username));
 
         if (is_enabled_auth('none') && empty($CFG->extendedusernamechars)) {
-            $string = eregi_replace("[^(-\.[:alnum:])]", "", $frm->username);
+            $string = preg_replace("/[^(-\.[:alnum:])]/i", "", $frm->username);
             if (strcmp($frm->username, $string)) {
                 $errormsg = get_string('username').': '.get_string("alphanumerical");
                 $errorcode = 2;
diff --git a/login/signup_form.php b/login/signup_form.php
index 9abc3f8ec4f..0e172515d6f 100644
--- a/login/signup_form.php
+++ b/login/signup_form.php
@@ -99,7 +99,7 @@ class login_signup_form extends moodleform {
             $errors['username'] = get_string('usernameexists');
         } else {
             if (empty($CFG->extendedusernamechars)) {
-                $string = eregi_replace("[^(-\.[:alnum:])]", '', $data['username']);
+                $string = preg_replace("/[^(-\.[:alnum:])]/i", '', $data['username']);
                 if (strcmp($data['username'], $string)) {
                     $errors['username'] = get_string('alphanumerical');
                 }
diff --git a/mnet/lib.php b/mnet/lib.php
index 7a0478eef0e..e6fc7f4d1a9 100644
--- a/mnet/lib.php
+++ b/mnet/lib.php
@@ -314,7 +314,7 @@ function mnet_generate_keypair($dn = null, $days=28) {
     }
 
     $host = strtolower($CFG->wwwroot);
-    $host = ereg_replace("^http(s)?://",'',$host);
+    $host = preg_replace("#^http(s)?://#",'',$host);
     $break = strpos($host.'/' , '/');
     $host   = substr($host, 0, $break);
 
diff --git a/mnet/xmlrpc/server.php b/mnet/xmlrpc/server.php
index a7cce24e644..c07d7714c96 100644
--- a/mnet/xmlrpc/server.php
+++ b/mnet/xmlrpc/server.php
@@ -321,7 +321,7 @@ function mnet_server_dummy_method($methodname, $argsarray, $functionname) {
     if (!is_object($MNET_REMOTE_CLIENT->object_to_call)) {
         return @call_user_func_array($functionname, $argsarray);
     } else {
-        return @call_user_method_array($functionname, $MNET_REMOTE_CLIENT->object_to_call, $argsarray);
+        return @call_user_func_array( array($MNET_REMOTE_CLIENT->object_to_call,$functionname), $argsarray);
     }
 }
 
diff --git a/mod/chat/chatd.php b/mod/chat/chatd.php
index ebd14a6523b..52630590b91 100755
--- a/mod/chat/chatd.php
+++ b/mod/chat/chatd.php
@@ -985,7 +985,7 @@ while(true) {
                     continue;
                 }
 
-                if(!ereg('win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*) HTTP', $data, $info)) {
+                if(!preg_match('/win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*) HTTP/', $data, $info)) {
                     // Malformed data
                     $DAEMON->trace('UFO with '.$handle.': Request with malformed data; connection closed', E_USER_WARNING);
                     $DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed');
@@ -1011,7 +1011,7 @@ while(true) {
                     break;
                     case 'beep':
                         $type = CHAT_SIDEKICK_BEEP;
-                        if(!ereg('beep=([^&]*)[& ]', $data, $info)) {
+                        if(!preg_match('/beep=([^&]*)[& ]/', $data, $info)) {
                             $DAEMON->trace('Beep sidekick did not contain a valid userid', E_USER_WARNING);
                             $DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed');
                             continue;
@@ -1022,7 +1022,7 @@ while(true) {
                     break;
                     case 'message':
                         $type = CHAT_SIDEKICK_MESSAGE;
-                        if(!ereg('chat_message=([^&]*)[& ]chat_msgidnr=([^&]*)[& ]', $data, $info)) {
+                        if(!preg_match('/chat_message=([^&]*)[& ]chat_msgidnr=([^&]*)[& ]/', $data, $info)) {
                             $DAEMON->trace('Message sidekick did not contain a valid message', E_USER_WARNING);
                             $DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed');
                             continue;
diff --git a/mod/lesson/format.php b/mod/lesson/format.php
index cc9abe48f01..1804ab98aaf 100644
--- a/mod/lesson/format.php
+++ b/mod/lesson/format.php
@@ -163,7 +163,7 @@ class qformat_default {
             $filearray = file($filename);
 
             /// Check for Macintosh OS line returns (ie file on one line), and fix
-            if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+            if (preg_match("/\r/", $filearray[0]) AND !preg_match("/\n/", $filearray[0])) {
                 return explode("\r", $filearray[0]);
             } else {
                 return $filearray;
diff --git a/mod/lesson/reformat.php b/mod/lesson/reformat.php
index e13bc762078..f4f5279f7d2 100644
--- a/mod/lesson/reformat.php
+++ b/mod/lesson/reformat.php
@@ -13,7 +13,7 @@ function removedoublecr($filename) {
     
     $filearray = file($filename);
     /// Check for Macintosh OS line returns (ie file on one line), and fix
-    if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+    if (preg_match("#\r#", $filearray[0]) AND !preg_match("#\n#", $filearray[0])) {
         $outfile = explode("\r", $filearray[0]);
     } else {
         $outfile = $filearray;
diff --git a/mod/scorm/datamodels/aicclib.php b/mod/scorm/datamodels/aicclib.php
index 64649883df5..7e5ff2a9a1e 100644
--- a/mod/scorm/datamodels/aicclib.php
+++ b/mod/scorm/datamodels/aicclib.php
@@ -281,7 +281,7 @@ function scorm_parse_aicc($pkgdir,$scormid) {
                             }
                             if (isset($element->core_vendor)) {
                                 $scodata->name = 'datafromlms';
-                                $scodata->value = eregi_replace('', "\r\n", $element->core_vendor);
+                                $scodata->value = preg_replace('//i', "\r\n", $element->core_vendor);
                                 $dataid = insert_record('scorm_scoes_data',$scodata);
                             }
                         }
diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php
index ea7085b34fc..bca5cac03cf 100755
--- a/mod/scorm/locallib.php
+++ b/mod/scorm/locallib.php
@@ -185,7 +185,7 @@ function scorm_tempdir($strPath)
             $len = 8;
             for ($i=0; $i<$len; $i++) {
                 $char = chr(rand(48,122));
-                while (!ereg('[a-zA-Z0-9]', $char)){
+                while (!preg_match('/[a-zA-Z0-9]/', $char)){
                     if ($char == $lchar) continue;
                         $char = chr(rand(48,90));
                     }
diff --git a/mod/scorm/player.php b/mod/scorm/player.php
index 8fa96ad61ae..c22ac0b0bad 100755
--- a/mod/scorm/player.php
+++ b/mod/scorm/player.php
@@ -281,7 +281,7 @@
             echo "                \n";   
         } else {
             // Clean the name for the window as IE is fussy
-            $name = ereg_replace("[^A-Za-z0-9]", "", $scorm->name);
+            $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
             if (!$name) {
                 $name = 'DefaultPlayerWindow';
             }
diff --git a/mod/wiki/ewiki/fragments/nuke_mod_wiki_index b/mod/wiki/ewiki/fragments/nuke_mod_wiki_index
index 56ffa243976..ab247ab931d 100644
--- a/mod/wiki/ewiki/fragments/nuke_mod_wiki_index
+++ b/mod/wiki/ewiki/fragments/nuke_mod_wiki_index
@@ -15,7 +15,7 @@
 
 
 #-- stupid legacy code
-if (!eregi("modules.php", $PHP_SELF)) {
+if (!preg_match("/modules.php/i", $PHP_SELF)) {
     die ("You can't access this file directly...");
 }
 
diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php
index 4b340637e75..77e6f82818c 100644
--- a/mod/wiki/lib.php
+++ b/mod/wiki/lib.php
@@ -1569,11 +1569,11 @@ function wiki_admin_checklinks($pagetocheck) {
      }
 
      /// Remove old Notices
-     $content = eregi_replace(' µµ__~\['.get_string("offline","wiki").'\]__µµ ','', $content);
+     $content = preg_replace('/ µµ__~\['.get_string("offline","wiki").'\]__µµ /i','', $content);
 
      #-- replace dead links
      foreach ($badlinks as $href) {
-        $content = preg_replace("\377^(.*)($href)\377m", '$1 µµ__~['.get_string("offline","wiki").']__µµ $2', $content);
+        $content = preg_replace("/\377^(.*)($href)\377m", '$1 µµ__~['.get_string("offline","wiki").']__µµ $2/', $content);
      }
 
      #-- compare against db content
diff --git a/pix/smartpix.php b/pix/smartpix.php
index 7deb186dcdd..3a7b1a2e815 100644
--- a/pix/smartpix.php
+++ b/pix/smartpix.php
@@ -21,10 +21,10 @@ function makesafe($param) {
     $param = str_replace('\\\'', '\'', $param);
     $param = str_replace('\\"', '"', $param);
     $param = str_replace('\\', '/', $param);
-    $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param);
-    $param = ereg_replace('\.\.+', '', $param);
-    $param = ereg_replace('//+', '/', $param);
-    return ereg_replace('/(\./)+', '/', $param);
+    $param = preg_replace('/[[:cntrl:]]|[<>"`\|\':]/', '', $param);
+    $param = preg_replace('/\.\.+/', '', $param);
+    $param = preg_replace('#//+#', '/', $param);
+    return preg_replace('#/(\./)+#', '/', $param);
 }
 
 // Nicked from weblib
diff --git a/question/format.php b/question/format.php
index 5b3bc959da7..70b1cda21c5 100644
--- a/question/format.php
+++ b/question/format.php
@@ -438,7 +438,7 @@ class qformat_default {
             $filearray = file($filename);
 
             /// Check for Macintosh OS line returns (ie file on one line), and fix
-            if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+            if (preg_match("/\r/", $filearray[0]) AND !preg_match("/\n/", $filearray[0])) {
                 return explode("\r", $filearray[0]);
             } else {
                 return $filearray;
@@ -583,7 +583,7 @@ class qformat_default {
         fclose( $fh );
 
         // return the (possibly) new filename
-        $newfile = ereg_replace("{$CFG->dataroot}/{$this->course->id}/", '',$newfullpath);
+        $newfile = preg_replace("#{$CFG->dataroot}/{$this->course->id}/#", '',$newfullpath);
         return $newfile;
     }
 
diff --git a/question/format/blackboard_6/format.php b/question/format/blackboard_6/format.php
index 69d0c19d9f7..ca3181a9e15 100644
--- a/question/format/blackboard_6/format.php
+++ b/question/format/blackboard_6/format.php
@@ -180,7 +180,7 @@ class qformat_blackboard_6 extends qformat_default {
                         if (is_readable($q_file)) {
                             $filearray = file($q_file);
                             /// Check for Macintosh OS line returns (ie file on one line), and fix
-                            if (ereg("\r", $filearray[0]) AND !ereg("\n", $filearray[0])) {
+                            if (preg_match("/\r/", $filearray[0]) AND !preg_match("/\n/", $filearray[0])) {
                                 return explode("\r", $filearray[0]);
                             } else {
                                 return $filearray;
diff --git a/question/format/gift/format.php b/question/format/gift/format.php
index ce7a9a412a4..a32749a0679 100755
--- a/question/format/gift/format.php
+++ b/question/format/gift/format.php
@@ -119,7 +119,7 @@ class qformat_gift extends qformat_default {
         $question = $this->defaultquestion();
         $comment = NULL;
         // define replaced by simple assignment, stop redefine notices
-        $gift_answerweight_regex = "^%\-*([0-9]{1,2})\.?([0-9]*)%";        
+        $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/";
 
         // REMOVED COMMENTED LINES and IMPLODE
         foreach ($lines as $key => $line) {
@@ -139,7 +139,7 @@ class qformat_gift extends qformat_default {
         $text = $this->escapedchar_pre($text);
 
         // Look for category modifier
-        if (ereg( '^\$CATEGORY:', $text)) {
+        if (preg_match( '/^\$CATEGORY:/', $text)) {
             // $newcategory = $matches[1];
             $newcategory = trim(substr( $text, 10 ));
 
@@ -317,7 +317,7 @@ class qformat_gift extends qformat_default {
                         $answer_weight = 1;
                         $answer = substr($answer, 1);
     
-                    } elseif (ereg($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
+                    } elseif (preg_match($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
                         $answer_weight = $this->answerweightparser($answer);
                     
                     } else {     //default, i.e., wrong anwer
@@ -408,7 +408,7 @@ class qformat_gift extends qformat_default {
                     $answer = trim($answer);
 
                     // Answer Weight
-                    if (ereg($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
+                    if (preg_match($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
                         $answer_weight = $this->answerweightparser($answer);
                     } else {     //default, i.e., full-credit anwer
                         $answer_weight = 1;
@@ -456,7 +456,7 @@ class qformat_gift extends qformat_default {
                     $answer = trim($answer);
 
                     // Answer weight
-                    if (ereg($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
+                    if (preg_match($gift_answerweight_regex, $answer)) {    // check for properly formatted answer weight
                         $answer_weight = $this->answerweightparser($answer);
                     } else {     //default, i.e., full-credit anwer
                         $answer_weight = 1;
diff --git a/question/format/qti2/format.php b/question/format/qti2/format.php
index e6a9dc6f4ee..7131ea17467 100644
--- a/question/format/qti2/format.php
+++ b/question/format/qti2/format.php
@@ -33,8 +33,8 @@ class qformat_qti2 extends qformat_default {
         // Remove all tabs.
         $source = str_replace("\t", '', $source);
         // Remove all space after ">" and before "<".
-        $source = ereg_replace(">( )*", ">", $source);
-        $source = ereg_replace("( )*<", "<", $source);
+        $source = preg_replace("/>( )*/", ">", $source);
+        $source = preg_replace("/( )*questiontext = addslashes(trim($questiontext));
                     unset($questiontext);
                 }
@@ -201,7 +201,7 @@ class qformat_webct extends qformat_default {
             }
 
             if (isset($answertext) and is_string($answertext)) {
-                if (ereg("^:",$line)) {
+                if (preg_match("/^:/",$line)) {
                     $answertext = addslashes(trim($answertext));
                     $question->answer[$currentchoice] = $answertext;
                     $question->subanswers[$currentchoice] = $answertext;
@@ -214,7 +214,7 @@ class qformat_webct extends qformat_default {
             }
 
             if (isset($responsetext) and is_string($responsetext)) {
-                if (ereg("^:",$line)) {
+                if (preg_match("/^:/",$line)) {
                     $question->subquestions[$currentchoice] = addslashes(trim($responsetext));
                     unset($responsetext);
                 }
@@ -225,7 +225,7 @@ class qformat_webct extends qformat_default {
             }
 
             if (isset($feedbacktext) and is_string($feedbacktext)) {
-                if (ereg("^:",$line)) {
+                if (preg_match("/^:/",$line)) {
                    $question->feedback[$currentchoice] = addslashes(trim($feedbacktext));
                     unset($feedbacktext);
                 }
@@ -236,7 +236,7 @@ class qformat_webct extends qformat_default {
             }
 
             if (isset($generalfeedbacktext) and is_string($generalfeedbacktext)) {
-                if (ereg("^:",$line)) {
+                if (preg_match("/^:/",$line)) {
                    $question->tempgeneralfeedback= addslashes(trim($generalfeedbacktext));
                     unset($generalfeedbacktext);
                 }
@@ -248,7 +248,7 @@ class qformat_webct extends qformat_default {
 
             $line = trim($line);
 
-            if (eregi("^:(TYPE|EOF):",$line)) {
+            if (preg_match("/^:(TYPE|EOF):/i",$line)) {
                 // New Question or End of File
                 if (isset($question)) {            // if previous question exists, complete, check and save it
 
@@ -382,7 +382,7 @@ class qformat_webct extends qformat_default {
 
             // Processing Question Header
 
-            if (eregi("^:TYPE:MC:1(.*)",$line,$webct_options)) {
+            if (preg_match("/^:TYPE:MC:1(.*)/i",$line,$webct_options)) {
                 // Multiple Choice Question with only one good answer
                 $question = $this->defaultquestion();
                 $question->feedback = array();
@@ -392,7 +392,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:MC:N(.*)",$line,$webct_options)) {
+            if (preg_match("/^:TYPE:MC:N(.*)/i",$line,$webct_options)) {
                 // Multiple Choice Question with several good answers
                 $question = $this->defaultquestion();
                 $question->feedback = array();
@@ -402,7 +402,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:S",$line)) {
+            if (preg_match("/^:TYPE:S/i",$line)) {
                 // Short Answer Question
                 $question = $this->defaultquestion();
                 $question->feedback = array();
@@ -412,7 +412,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:C",$line)) {
+            if (preg_match("/^:TYPE:C/i",$line)) {
                 // Calculated Question
            /*     $warnings[] = get_string("calculatedquestion", "quiz", $nLineCounter);
                 unset($question);
@@ -434,7 +434,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:M",$line)) {
+            if (preg_match("/^:TYPE:M/i",$line)) {
                 // Match Question
                 $question = $this->defaultquestion();
                 $question->qtype = MATCH;
@@ -443,7 +443,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:P",$line)) {
+            if (preg_match("/^:TYPE:P/i",$line)) {
                 // Paragraph Question
                 $warnings[] = get_string("paragraphquestion", "quiz", $nLineCounter);
                 unset($question);
@@ -451,7 +451,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TYPE:",$line)) {
+            if (preg_match("/^:TYPE:/i",$line)) {
                 // Unknow Question
                 $warnings[] = get_string("unknowntype", "quiz", $nLineCounter);
                 unset($question);
@@ -463,7 +463,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:TITLE:(.*)",$line,$webct_options)) {
+            if (preg_match("/^:TITLE:(.*)/i",$line,$webct_options)) {
                 $name = trim($webct_options[1]);
                 if (strlen($name) > 255) {
                     $name = substr($name,0,250)."...";
@@ -473,9 +473,9 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:IMAGE:(.*)",$line,$webct_options)) {
+            if (preg_match("/^:IMAGE:(.*)/",$line,$webct_options)) {
                 $filename = trim($webct_options[1]);
-                if (eregi("^http://",$filename)) {
+                if (preg_match("#^http://#",$filename)) {
                     $question->image = $filename;
                 }
                 continue;
@@ -486,9 +486,9 @@ class qformat_webct extends qformat_default {
             if (!isset($question)) {
                 continue;
             } 
-            if (isset($question->qtype ) && CALCULATED == $question->qtype && ereg(
-                    "^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)", $line, $webct_options)) {
-                $datasetname = ereg_replace('^::', '', $webct_options[1]);
+            if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match(
+                    "/^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)/", $line, $webct_options)) {
+                $datasetname = preg_replace('/^::/', '', $webct_options[1]);
                 $datasetvalue = qformat_webct_convert_formula($webct_options[4]);
                 switch ($webct_options[2]) {
                     case 'MIN':
@@ -512,27 +512,27 @@ class qformat_webct extends qformat_default {
             }
 
 
-            $bIsHTMLText = eregi(":H$",$line);  // True if next lines are coded in HTML
-            if (eregi("^:QUESTION",$line)) {
+            $bIsHTMLText = preg_match("/:H$/",$line);  // True if next lines are coded in HTML
+            if (preg_match("/^:QUESTION/",$line)) {
                 $questiontext="";               // Start gathering next lines
                 continue;
             }
 
-            if (eregi("^:ANSWER([0-9]+):([^:]+):([0-9\.\-]+):(.*)",$line,$webct_options)) {      /// SHORTANSWER
+            if (preg_match("/^:ANSWER([0-9]+):([^:]+):([0-9\.\-]+):(.*)/i",$line,$webct_options)) {      /// SHORTANSWER
                 $currentchoice=$webct_options[1];
                 $answertext=$webct_options[2];            // Start gathering next lines
                 $question->fraction[$currentchoice]=($webct_options[3]/100);
                 continue;
             }
 
-            if (eregi("^:ANSWER([0-9]+):([0-9\.\-]+)",$line,$webct_options)) {
+            if (preg_match("/^:ANSWER([0-9]+):([0-9\.\-]+)/i",$line,$webct_options)) {
                 $answertext="";                 // Start gathering next lines
                 $currentchoice=$webct_options[1];
                 $question->fraction[$currentchoice]=($webct_options[2]/100);
                 continue;
             }
 
-            if (eregi('^:FORMULA:(.*)', $line, $webct_options)) {
+            if (preg_match('/^:FORMULA:(.*)/i', $line, $webct_options)) {
                 // Answer for a CALCULATED question
                 ++$currentchoice;
                 $question->answers[$currentchoice] =
@@ -556,60 +556,60 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (eregi("^:L([0-9]+)",$line,$webct_options)) {
+            if (preg_match("/^:L([0-9]+)/i",$line,$webct_options)) {
                 $answertext="";                 // Start gathering next lines
                 $currentchoice=$webct_options[1];
                 $question->fraction[$currentchoice]=1; 
                 continue;
             }
 
-            if (eregi("^:R([0-9]+)",$line,$webct_options)) {
+            if (preg_match("/^:R([0-9]+)/i",$line,$webct_options)) {
                 $responsetext="";                // Start gathering next lines
                 $currentchoice=$webct_options[1];
                 continue;
             }
 
-            if (eregi("^:REASON([0-9]+):?",$line,$webct_options)) {
+            if (preg_match("/^:REASON([0-9]+):?/i",$line,$webct_options)) {
                 $feedbacktext="";               // Start gathering next lines
                 $currentchoice=$webct_options[1];
                 continue;
             }
-            if (eregi("^:FEEDBACK([0-9]+):?",$line,$webct_options)) {
+            if (preg_match("/^:FEEDBACK([0-9]+):?/i",$line,$webct_options)) {
                 $generalfeedbacktext="";               // Start gathering next lines
                 $currentchoice=$webct_options[1];
                 continue;
             }
-            if (eregi('^:FEEDBACK:(.*)',$line,$webct_options)) {
+            if (preg_match('/^:FEEDBACK:(.*)/i',$line,$webct_options)) {
                 $generalfeedbacktext="";               // Start gathering next lines
                 continue;
             }
-            if (eregi('^:LAYOUT:(.*)',$line,$webct_options)) {
+            if (preg_match('/^:LAYOUT:(.*)/i',$line,$webct_options)) {
             //    ignore  since layout in question_multichoice  is no more used in moodle       
             //    $webct_options[1] contains either vertical or horizontal ;
                 continue;
             }
 
-            if (isset($question->qtype ) && CALCULATED == $question->qtype && eregi('^:ANS-DEC:([1-9][0-9]*)', $line, $webct_options)) {
+            if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match('/^:ANS-DEC:([1-9][0-9]*)/i', $line, $webct_options)) {
                 // We can but hope that this always appear before the ANSTYPE property
                 $question->correctanswerlength[$currentchoice] = $webct_options[1];
                 continue;
             }
 
-            if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi("^:TOL:($webctnumberregex)", $line, $webct_options)) {
+            if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match("/^:TOL:($webctnumberregex)/i", $line, $webct_options)) {
                 // We can but hope that this always appear before the TOL property
                 $question->tolerance[$currentchoice] =
                         qformat_webct_convert_formula($webct_options[1]);
                 continue;
             }
 
-            if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:TOLTYPE:percent', $line)) {
+            if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('/^:TOLTYPE:percent/', $line)) {
                 // Percentage case is handled as relative in Moodle:
                 $question->tolerance[$currentchoice]  /= 100;
                 $question->tolerancetype[$currentchoice] = 1; // Relative
                 continue;
             }
 
-            if (eregi('^:UNITS:(.+)', $line, $webct_options)
+            if (preg_match('/^:UNITS:(.+)/', $line, $webct_options)
                     and $webctunits = trim($webct_options[1])) {
                 // This is a guess - I really do not know how different webct units are separated...
                 $webctunits = explode(':', $webctunits);
@@ -621,7 +621,7 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (!empty($question->units) && eregi('^:UNITREQ:(.*)', $line, $webct_options)
+            if (!empty($question->units) && preg_match('/^:UNITREQ:(.*)/', $line, $webct_options)
                     && !$webct_options[1]) {
                 // There are units but units are not required so add the no unit alternative
                 // We can but hope that the UNITS property always appear before this property
@@ -631,17 +631,17 @@ class qformat_webct extends qformat_default {
                 continue;
             }
 
-            if (!empty($question->units) && eregi('^:UNITCASE:', $line)) {
+            if (!empty($question->units) && preg_match('/^:UNITCASE:/', $line)) {
                 // This could be important but I was not able to figure out how
                 // it works so I ignore it for now
                 continue;
             }
 
-            if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:ANSTYPE:dec', $line)) {
+            if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('/^:ANSTYPE:dec/', $line)) {
                 $question->correctanswerformat[$currentchoice]='1';
                 continue;
             }
-            if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:ANSTYPE:sig', $line)) {
+            if (isset($question->qtype )&& CALCULATED == $question->qtype && preg_match('/^:ANSTYPE:sig/', $line)) {
                 $question->correctanswerformat[$currentchoice]='2';
                 continue;
             }
diff --git a/question/format/xml/format.php b/question/format/xml/format.php
index b6f4b79c519..4a1590c51fe 100755
--- a/question/format/xml/format.php
+++ b/question/format/xml/format.php
@@ -921,9 +921,9 @@ class qformat_xml extends qformat_default {
         case MULTIANSWER:
             $a_count=1;
             foreach($question->options->questions as $question) {
-                $thispattern = addslashes("{#".$a_count."}");
+                $thispattern = '/'.addslashes("{#".$a_count."}").'/';
                 $thisreplace = $question->questiontext;
-                $expout=ereg_replace($thispattern, $thisreplace, $expout );
+                $expout=preg_replace($thispattern, $thisreplace, $expout );
                 $a_count++;
             }
         break;
diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php
index a8cb8332df1..bb667befcae 100644
--- a/question/type/calculated/edit_calculated_form.php
+++ b/question/type/calculated/edit_calculated_form.php
@@ -170,7 +170,7 @@ class question_edit_calculated_form extends question_edit_form {
             $qtextremaining = str_replace('{'.$name.'}', '1', $qtextremaining);
         }
     //     echo "numericalquestion qtextremaining 
";print_r($possibledatasets);
-        while  (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
+        while  (preg_match('/\{=([^[:space:]}]*)}/', $qtextremaining, $regs1)) {
             $qtextsplits = explode($regs1[0], $qtextremaining, 2);
             $qtext =$qtext.$qtextsplits[0];
             $qtextremaining = $qtextsplits[1];
diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php
index cbe0545320b..10b69f6b1d1 100644
--- a/question/type/calculated/questiontype.php
+++ b/question/type/calculated/questiontype.php
@@ -382,7 +382,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
         //evaluate the equations i.e {=5+4)
         $qtext = "";
         $qtextremaining = $numericalquestion->questiontext ;
-        while  (ereg('\{=([^[:space:]}]*)}', $qtextremaining, $regs1)) {
+        while  (preg_match('/\{=([^[:space:]}]*)}/', $qtextremaining, $regs1)) {
             $qtextsplits = explode($regs1[0], $qtextremaining, 2);
             $qtext =$qtext.$qtextsplits[0];
             $qtextremaining = $qtextsplits[1];
@@ -501,7 +501,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
     function custom_generator_set_data($datasetdefs, $formdata){
         $idx = 1;
         foreach ($datasetdefs as $datasetdef){
-            if (ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$', $datasetdef->options, $regs)) {
+            if (preg_match('/^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$/', $datasetdef->options, $regs)) {
                 $defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name";
                 $formdata["calcdistribution[$idx]"] = $regs[1];
                 $formdata["calcmin[$idx]"] = $regs[2];
@@ -514,7 +514,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
     }
 
     function custom_generator_tools($datasetdef) {
-        if (ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$',
+        if (preg_match('/^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$/',
                 $datasetdef->options, $regs)) {
             $defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name";
             for ($i = 0 ; $i<10 ; ++$i) {
@@ -723,7 +723,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
     }
     function generate_dataset_item($options) {
 
-        if (!ereg('^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$',
+        if (!preg_match('/^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$/',
                 $options, $regs)) {
             // Unknown options...
             return false;
@@ -825,7 +825,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
   //  list($options, $selected) = $this->dataset_optionsa($form, $name);
 
         foreach ($options as $key => $whatever) {
-            if (!ereg('^'.LITERAL.'-', $key) && $key != '0') {
+            if (!preg_match('/^'.LITERAL.'-/', $key) && $key != '0') {
                 unset($options[$key]);
             }
         }
@@ -1173,7 +1173,7 @@ function qtype_calculated_calculate_answer($formula, $individualdata,
         if ($answerlength) {
             /* Try to include missing zeros at the end */
 
-            if (ereg('^(.*\\.)(.*)$', $calculated->answer, $regs)) {
+            if (preg_match('/^(.*\\.)(.*)$/', $calculated->answer, $regs)) {
                 $calculated->answer = $regs[1] . substr(
                         $regs[2] . '00000000000000000000000000000000000000000x',
                         0, $answerlength)
@@ -1233,7 +1233,7 @@ function qtype_calculated_calculate_answer($formula, $individualdata,
                 $calculated->answer = $sign.$answer.$unit;
             } else {
                 // Could be an idea to add some zeros here
-                $answer .= (ereg('^[0-9]*$', $answer) ? '.' : '')
+                $answer .= (preg_match('/^[0-9]*$/', $answer) ? '.' : '')
                         . '00000000000000000000000000000000000000000x';
                 $oklen = $answerlength + ($p10 < 1 ? 2-$p10 : 1);
                 $calculated->answer = $sign.substr($answer, 0, $oklen).$unit;
@@ -1254,7 +1254,7 @@ function qtype_calculated_find_formula_errors($formula) {
 /// Returns false if everything is alright.
 /// Otherwise it constructs an error message
     // Strip away dataset names
-    while (ereg('\\{[[:alpha:]][^>} <{"\']*\\}', $formula, $regs)) {
+    while (preg_match('/\\{[[:alpha:]][^>} <{"\']*\\}/', $formula, $regs)) {
         $formula = str_replace($regs[0], '1', $formula);
     }
 
@@ -1265,7 +1265,7 @@ function qtype_calculated_find_formula_errors($formula) {
     $operatorornumber = "[$safeoperatorchar.0-9eE]";
 
 
-    while (ereg("(^|[$safeoperatorchar,(])([a-z0-9_]*)\\(($operatorornumber+(,$operatorornumber+((,$operatorornumber+)+)?)?)?\\)",
+    while (preg_match("/(^|[$safeoperatorchar,(])([a-z0-9_]*)\\(($operatorornumber+(,$operatorornumber+((,$operatorornumber+)+)?)?)?\\)/",
             $formula, $regs)) {
 
         switch ($regs[2]) {
@@ -1328,11 +1328,11 @@ function qtype_calculated_find_formula_errors($formula) {
             $formula = str_replace($regs[0], $regs[1] . '1', $formula);
         } else {
             // The function call starts the formula
-            $formula = ereg_replace("^$regs[2]\\([^)]*\\)", '1', $formula);
+            $formula = preg_replace("/^$regs[2]\\([^)]*\\)/", '1', $formula);
         }
     }
 
-    if (ereg("[^$safeoperatorchar.0-9eE]+", $formula, $regs)) {
+    if (preg_match("/[^$safeoperatorchar.0-9eE]+/", $formula, $regs)) {
         return get_string('illegalformulasyntax', 'quiz', $regs[0]);
     } else {
         // Formula just might be valid
diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php
index c43eaeebfbf..f35fac618bd 100644
--- a/question/type/datasetdependent/abstractqtype.php
+++ b/question/type/datasetdependent/abstractqtype.php
@@ -49,7 +49,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
     }
 
     function restore_session_and_responses(&$question, &$state) {
-        if (!ereg('^dataset([0-9]+)[^-]*-(.*)$',
+        if (!preg_match('/^dataset([0-9]+)[^-]*-(.*)$/',
                 $state->responses[''], $regs)) {
             notify ("Wrongly formatted raw response answer " .
                    "{$state->responses['']}! Could not restore session for " .
@@ -732,7 +732,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
     /// Returns the possible dataset names found in the text as an array
     /// The array has the dataset name for both key and value
         $datasetnames = array();
-        while (ereg('\\{([[:alpha:]][^>} <{"\']*)\\}', $text, $regs)) {
+        while (preg_match('/\\{([[:alpha:]][^>} <{"\']*)\\}/', $text, $regs)) {
             $datasetnames[$regs[1]] = $regs[1];
             $text = str_replace($regs[0], '', $text);
         }
@@ -740,7 +740,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
     }
 
     function create_virtual_nameprefix($nameprefix, $datasetinput) {
-        if (!ereg('([0-9]+)' . $this->name() . '$', $nameprefix, $regs)) {
+        if (!preg_match('/([0-9]+)/' . $this->name() . '$', $nameprefix, $regs)) {
             error("Wrongly formatted nameprefix $nameprefix");
         }
         $virtualqtype = $this->get_virtual_qtype();
diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php
index eb97766feb5..90ac1c578f3 100644
--- a/question/type/multianswer/questiontype.php
+++ b/question/type/multianswer/questiontype.php
@@ -266,7 +266,7 @@ class embedded_cloze_qtype extends default_questiontype {
         // The regex will recognize text snippets of type {#X}
         // where the X can be any text not containg } or white-space characters.
 
-        while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
+        while (preg_match('/\{#([^[:space:]}]*)}/', $qtextremaining, $regs)) {
             $qtextsplits = explode($regs[0], $qtextremaining, 2);
             echo $qtextsplits[0];
             echo "