Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

all MDL-20821 Removed ereg related deprecated functions

  • Loading branch information...
commit 76561f1e4e2c0cfa181804344b501b4e6d56d270 1 parent 4dadad0
Andrew Davis authored

Showing 70 changed files with 1,393 additions and 310 deletions. Show diff stats Hide diff stats

  1. +2 2 admin/fixuserpix.php
  2. +5 5 admin/mnet/MethodTable.php
  3. +1 1  admin/uploaduser.php
  4. +1 1  auth/shibboleth/auth.php
  5. +1 1  auth/shibboleth/logout.php
  6. +2 2 calendar/lib.php
  7. +11 11 enrol/authorize/enrol_form.php
  8. +1 1  filter/tex/filter.php
  9. +2 2 lib/adodb/drivers/adodb-sybase.inc.php
  10. +46 0 lib/adodb/readme_moodle.txt
  11. +1 1  lib/adodb/session/old/adodb-session-clob.php
  12. +3 3 lib/bennu/iCalendar_rfc2445.php
  13. +27 0 lib/bennu/readme_moodle.txt
  14. +2 2 lib/blocklib.php
  15. +1 1  lib/deprecatedlib.php
  16. +12 12 lib/excel/Parser.php
  17. +2 2 lib/excel/Worksheet.php
  18. +104 0 lib/excel/readme_moodle.txt
  19. +1 1  lib/filelib.php
  20. +1 1  lib/fpdf/font/makefont/makefont.php
  21. +19 0 lib/fpdf/readme_moodle.txt
  22. +1 1  lib/geoip/geoip.inc
  23. +19 0 lib/geoip/readme_moodle.txt
  24. +1 1  lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php
  25. +21 0 lib/htmlpurifier/readme_moodle.txt
  26. +18 18 lib/moodlelib.php
  27. +7 3 lib/pclzip/pclzip.lib.php
  28. +51 1 lib/pclzip/readme_moodle.txt
  29. +100 0 lib/pear/README_MOODLE.txt
  30. +11 11 lib/pear/Spreadsheet/Excel/Writer/Parser.php
  31. +11 0 lib/simpletest/testmoodlelib.php
  32. +273 0 lib/soap/README_MOODLE.txt
  33. +34 30 lib/soap/nusoap.php
  34. +26 0 lib/tcpdf/README_MOODLE.txt
  35. +2 2 lib/tcpdf/html2pdf.php
  36. +359 0 lib/typo3/README_MOODLE.txt
  37. +7 7 lib/typo3/class.t3lib_cs.php
  38. +35 35 lib/typo3/class.t3lib_div.php
  39. +7 6 lib/validateurlsyntax.php
  40. +13 13 lib/weblib.php
  41. +29 29 lib/wiki_to_markdown.php
  42. +19 0 lib/xmldb/README_MOODLE.txt
  43. +1 1  lib/xmldb/classes/XMLDBObject.class.php
  44. +1 1  login/index.php
  45. +1 1  login/signup_form.php
  46. +1 1  mnet/lib.php
  47. +1 1  mnet/xmlrpc/server.php
  48. +3 3 mod/chat/chatd.php
  49. +1 1  mod/lesson/format.php
  50. +1 1  mod/lesson/reformat.php
  51. +1 1  mod/scorm/datamodels/aicclib.php
  52. +1 1  mod/scorm/locallib.php
  53. +1 1  mod/scorm/player.php
  54. +1 1  mod/wiki/ewiki/fragments/nuke_mod_wiki_index
  55. +2 2 mod/wiki/lib.php
  56. +4 4 pix/smartpix.php
  57. +2 2 question/format.php
  58. +1 1  question/format/blackboard_6/format.php
  59. +5 5 question/format/gift/format.php
  60. +2 2 question/format/qti2/format.php
  61. +49 49 question/format/webct/format.php
  62. +2 2 question/format/xml/format.php
  63. +1 1  question/type/calculated/edit_calculated_form.php
  64. +11 11 question/type/calculated/questiontype.php
  65. +3 3 question/type/datasetdependent/abstractqtype.php
  66. +2 2 question/type/multianswer/questiontype.php
  67. +1 1  question/type/numerical/questiontype.php
  68. +3 3 question/type/random/questiontype.php
  69. +1 1  search/documents/assignment_document.php
  70. +1 1  user/editadvanced_form.php
4 admin/fixuserpix.php
@@ -252,9 +252,9 @@ function definition_after_data() {
252 252 function arguments($argv) {
253 253 $_ARG = array();
254 254 foreach ($argv as $arg) {
255   - if (ereg('--?([^=]+)=(.*)',$arg,$reg)) {
  255 + if (preg_match('/--?([^=]+)=(.*)/',$arg,$reg)) {
256 256 $_ARG[$reg[1]] = $reg[2];
257   - } elseif(ereg('-([a-zA-Z0-9]+)',$arg,$reg)) {
  257 + } elseif(preg_match('/-([a-zA-Z0-9]+)/',$arg,$reg)) {
258 258 $_ARG[$reg[1]] = 'true';
259 259 }
260 260 }
10 admin/mnet/MethodTable.php
@@ -465,15 +465,15 @@ function cleanArguments($args, $commentParams){
465 465 $word0 = strtolower($word0);
466 466 $word1 = strtolower($word1);
467 467
468   - $wordBase0 = ereg_replace('^[&$]+','',$word0);
469   - $wordBase1 = ereg_replace('^[&$]+','',$word1);
470   - $startBase = strtolower(ereg_replace('^[&$]+','',$start));
  468 + $wordBase0 = preg_replace('/^[&$]+/','',$word0);
  469 + $wordBase1 = preg_replace('/^[&$]+/','',$word1);
  470 + $startBase = strtolower(preg_replace('/^[&$]+/','',$start));
471 471
472 472 if ($wordBase0 == $startBase) {
473 473 $type = str_replace(array('(',')'),'', $word1);
474 474 } elseif($wordBase1 == $startBase) {
475 475 $type = str_replace(array('(',')'),'', $word0);
476   - } elseif( ereg('(^[&$]+)|(\()([a-z0-9]+)(\)$)', $word0, $regs) ) {
  476 + } elseif( preg_match('/(^[&$]+)|(\()([a-z0-9]+)(\)$)/', $word0, $regs) ) {
477 477 $tail = str_ireplace($word0, '', $end);
478 478 $type = $regs[3];
479 479 } else {
@@ -535,7 +535,7 @@ function cleanComment($comment){
535 535 $comment = str_replace("*/", "", $comment);
536 536 $comment = str_replace("*", "", $comment);
537 537 $comment = str_replace("\n", "\\n", trim($comment));
538   - $comment = eregi_replace("[\r\t\n ]+", " ", trim($comment));
  538 + $comment = preg_replace("/[\r\t\n ]+/i", " ", trim($comment));
539 539 $comment = str_replace("\"", "\\\"", $comment);
540 540 return $comment;
541 541 }
2  admin/uploaduser.php
@@ -260,7 +260,7 @@
260 260 // normalize username
261 261 $user->username = $textlib->strtolower($user->username);
262 262 if (empty($CFG->extendedusernamechars)) {
263   - $user->username = eregi_replace('[^(-\.[:alnum:])]', '', $user->username);
  263 + $user->username = preg_replace('/[^(-\.[:alnum:])]/i', '', $user->username);
264 264 }
265 265 if (empty($user->username)) {
266 266 $upt->track('status', get_string('missingfield', 'error', 'username'), 'error');
2  auth/shibboleth/auth.php
@@ -63,7 +63,7 @@ function user_login($username, $password) {
63 63 } else {
64 64 // Try to find out using the user's cookie
65 65 foreach ($_COOKIE as $name => $value){
66   - if (eregi('_shibsession_', $name)){
  66 + if (preg_match('/_shibsession_/i', $name)){
67 67 $sessionkey = $value;
68 68 }
69 69 }
2  auth/shibboleth/logout.php
@@ -139,7 +139,7 @@ function LogoutNotification($SessionID){
139 139 while (($file = readdir($dh)) !== false) {
140 140 // Check if it is a file
141 141 if (is_file($dir.'/'.$file)){
142   - $session_key = ereg_replace('sess_', '', $file);
  142 + $session_key = preg_replace('/sess_/', '', $file);
143 143
144 144 // Read session file data
145 145 $data = file($dir.'/'.$file);
4 calendar/lib.php
@@ -766,8 +766,8 @@ function calendar_top_controls($type, $data) {
766 766 $text = get_string('strftimedaydate');
767 767 /*
768 768 // Regexp hackery to make a link out of the month/year part
769   - $text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
770   - $text = ereg_replace('(F.+Y|Y.+F|Y.+m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
  769 + $text = preg_replace('/(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
  770 + $text = preg_replace('/(F.+Y|Y.+F|Y.+m[^ ]+)/', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
771 771 */
772 772 // Replace with actual values and lose any day leading zero
773 773 $text = userdate($time, $text);
22 enrol/authorize/enrol_form.php
@@ -246,7 +246,7 @@ function other_method_available($currentmethod)
246 246
247 247 function validate_aba($aba)
248 248 {
249   - if (ereg("^[0-9]{9}$", $aba)) {
  249 + if (preg_match("/^[0-9]{9}$/", $aba)) {
250 250 $n = 0;
251 251 for($i = 0; $i < 9; $i += 3) {
252 252 $n += (substr($aba, $i, 1) * 3) + (substr($aba, $i + 1, 1) * 7) + (substr($aba, $i + 2, 1));
@@ -276,45 +276,45 @@ function validate_cc($Num, $Name = "n/a", $Exp = "")
276 276 $GoodCard = true;
277 277
278 278 // Get rid of any non-digits
279   - $Num = ereg_replace("[^0-9]", "", $Num);
  279 + $Num = preg_replace("/[^0-9]/", "", $Num);
280 280
281 281 // Perform card-specific checks, if applicable
282 282 switch ($Name)
283 283 {
284 284 case "mcd" :
285   - $GoodCard = ereg("^5[1-5].{14}$", $Num);
  285 + $GoodCard = preg_match("/^5[1-5].{14}$/", $Num);
286 286 break;
287 287
288 288 case "vis" :
289   - $GoodCard = ereg("^4.{15}$|^4.{12}$", $Num);
  289 + $GoodCard = preg_match("/^4.{15}$|^4.{12}$/", $Num);
290 290 break;
291 291
292 292 case "amx" :
293   - $GoodCard = ereg("^3[47].{13}$", $Num);
  293 + $GoodCard = preg_match("/^3[47].{13}$/", $Num);
294 294 break;
295 295
296 296 case "dsc" :
297   - $GoodCard = ereg("^6011.{12}$", $Num);
  297 + $GoodCard = preg_match("/^6011.{12}$/", $Num);
298 298 break;
299 299
300 300 case "dnc" :
301   - $GoodCard = ereg("^30[0-5].{11}$|^3[68].{12}$", $Num);
  301 + $GoodCard = preg_match("/^30[0-5].{11}$|^3[68].{12}$/", $Num);
302 302 break;
303 303
304 304 case "jcb" :
305   - $GoodCard = ereg("^3.{15}$|^2131|1800.{11}$", $Num);
  305 + $GoodCard = preg_match("/^3.{15}$|^2131|1800.{11}$/", $Num);
306 306 break;
307 307
308 308 case "dlt" :
309   - $GoodCard = ereg("^4.{15}$", $Num);
  309 + $GoodCard = preg_match("/^4.{15}$/", $Num);
310 310 break;
311 311
312 312 case "swi" :
313   - $GoodCard = ereg("^[456].{15}$|^[456].{17,18}$", $Num);
  313 + $GoodCard = preg_match("/^[456].{15}$|^[456].{17,18}$/", $Num);
314 314 break;
315 315
316 316 case "enr" :
317   - $GoodCard = ereg("^2014.{11}$|^2149.{11}$", $Num);
  317 + $GoodCard = preg_match("/^2014.{11}$|^2149.{11}$/", $Num);
318 318 break;
319 319 }
320 320
2  filter/tex/filter.php
@@ -146,7 +146,7 @@ function tex_filter ($courseid, $text) {
146 146 $texexp = str_replace('</nolink>','',$texexp);
147 147 $texexp = str_replace('<span class="nolink">','',$texexp);
148 148 $texexp = str_replace('</span>','',$texexp);
149   - $texexp = eregi_replace("<br[[:space:]]*\/?>", '', $texexp); //dlnsk
  149 + $texexp = preg_replace("#<br[[:space:]]*\/?>#i", '', $texexp); //dlnsk
150 150 $align = "middle";
151 151 if (preg_match('/^align=bottom /',$texexp)) {
152 152 $align = "text-bottom";
4 lib/adodb/drivers/adodb-sybase.inc.php
@@ -376,7 +376,7 @@ function UnixDate($v)
376 376 global $ADODB_sybase_mths;
377 377
378 378 //Dec 30 2000 12:00AM
379   - if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
  379 + if (!preg_match( "#([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})#"
380 380 ,$v, $rr)) return parent::UnixDate($v);
381 381
382 382 if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
@@ -393,7 +393,7 @@ function UnixTimeStamp($v)
393 393 global $ADODB_sybase_mths;
394 394 //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
395 395 //Changed [0-9] to [0-9 ] in day conversion
396   - if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
  396 + 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})#"
397 397 ,$v, $rr)) return parent::UnixTimeStamp($v);
398 398 if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
399 399
46 lib/adodb/readme_moodle.txt
@@ -30,3 +30,49 @@ Our changes:
30 30 skodak, iarenaza, moodler, stronk7
31 31
32 32 $Id$
  33 +
  34 +
  35 +18 Nov 2009
  36 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  37 +
  38 +Index: drivers/adodb-sybase.inc.php
  39 +===================================================================
  40 +RCS file: /cvsroot/moodle/moodle/lib/adodb/drivers/adodb-sybase.inc.php,v
  41 +retrieving revision 1.21.6.2
  42 +diff -u -r1.21.6.2 adodb-sybase.inc.php
  43 +--- drivers/adodb-sybase.inc.php 15 Feb 2008 06:04:06 -0000 1.21.6.2
  44 ++++ drivers/adodb-sybase.inc.php 18 Nov 2009 06:15:43 -0000
  45 +@@ -376,7 +376,7 @@
  46 + global $ADODB_sybase_mths;
  47 +
  48 + //Dec 30 2000 12:00AM
  49 +- if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
  50 ++ if (!preg_match( "#([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})#"
  51 + ,$v, $rr)) return parent::UnixDate($v);
  52 +
  53 + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
  54 +@@ -393,7 +393,7 @@
  55 + global $ADODB_sybase_mths;
  56 + //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
  57 + //Changed [0-9] to [0-9 ] in day conversion
  58 +- if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
  59 ++ 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})#"
  60 + ,$v, $rr)) return parent::UnixTimeStamp($v);
  61 + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
  62 +
  63 +Index: session/old/adodb-session-clob.php
  64 +===================================================================
  65 +RCS file: /cvsroot/moodle/moodle/lib/adodb/session/old/Attic/adodb-session-clob.php,v
  66 +retrieving revision 1.5.6.1
  67 +diff -u -r1.5.6.1 adodb-session-clob.php
  68 +--- session/old/adodb-session-clob.php 15 Feb 2008 06:04:08 -0000 1.5.6.1
  69 ++++ session/old/adodb-session-clob.php 18 Nov 2009 06:15:43 -0000
  70 +@@ -439,7 +439,7 @@
  71 + if (0) {
  72 +
  73 + session_start();
  74 +- session_register('AVAR');
  75 ++ session_register('AVAR');//this is deprecated in php 5.3
  76 + $_SESSION['AVAR'] += 1;
  77 + ADOConnection::outp( "
  78 + -- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
2  lib/adodb/session/old/adodb-session-clob.php
@@ -439,7 +439,7 @@ function adodb_sess_gc($maxlifetime)
439 439 if (0) {
440 440
441 441 session_start();
442   - session_register('AVAR');
  442 + session_register('AVAR');//this is deprecated in php 5.3
443 443 $_SESSION['AVAR'] += 1;
444 444 ADOConnection::outp( "
445 445 -- \$_SESSION['AVAR']={$_SESSION['AVAR']}</p>",false);
6 lib/bennu/iCalendar_rfc2445.php
@@ -139,13 +139,13 @@ function rfc2445_is_valid_value($value, $type) {
139 139 }
140 140
141 141 if($scheme === 'mailto') {
142   - $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})$';
  142 + $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})$#';
143 143 }
144 144 else {
145   - $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})?(/.*)?$';
  145 + $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})?(/.*)?$#';
146 146 }
147 147
148   - return ereg($regexp, $remain);
  148 + return preg_match($regexp, $remain);
149 149 break;
150 150
151 151 case RFC2445_TYPE_BINARY:
27 lib/bennu/readme_moodle.txt
... ... @@ -0,0 +1,27 @@
  1 +18 Nov 2009
  2 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  3 +
  4 +Index: iCalendar_rfc2445.php
  5 +===================================================================
  6 +RCS file: /cvsroot/moodle/moodle/lib/bennu/iCalendar_rfc2445.php,v
  7 +retrieving revision 1.2.10.1
  8 +diff -u -r1.2.10.1 iCalendar_rfc2445.php
  9 +--- iCalendar_rfc2445.php 12 Oct 2009 05:08:02 -0000 1.2.10.1
  10 ++++ iCalendar_rfc2445.php 18 Nov 2009 06:19:31 -0000
  11 +@@ -139,13 +139,13 @@
  12 + }
  13 +
  14 + if($scheme === 'mailto') {
  15 +- $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})$';
  16 ++ $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})$#';
  17 + }
  18 + else {
  19 +- $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})?(/.*)?$';
  20 ++ $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})?(/.*)?$#';
  21 + }
  22 +
  23 +- return ereg($regexp, $remain);
  24 ++ return preg_match($regexp, $remain);
  25 + break;
  26 +
  27 + case RFC2445_TYPE_BINARY:
4 lib/blocklib.php
@@ -173,8 +173,8 @@ function blocks_name_allowed_in_format($name, $pageformat) {
173 173 $depth = -1;
174 174 if ($formats = block_method_result($name, 'applicable_formats')) {
175 175 foreach($formats as $format => $allowed) {
176   - $thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$';
177   - if(ereg($thisformat, $pageformat)) {
  176 + $thisformat = '/^'.str_replace('*', '[^-]*', $format).'.*$/';
  177 + if(preg_match($thisformat, $pageformat)) {
178 178 if(($scount = substr_count($format, '-')) > $depth) {
179 179 $depth = $scount;
180 180 $accept = $allowed;
2  lib/deprecatedlib.php
@@ -1001,7 +1001,7 @@ function detect_munged_arguments($string, $allowdots=1) {
1001 1001 if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
1002 1002 return true;
1003 1003 }
1004   - if (ereg('[\|\`]', $string)) { // check for other bad characters
  1004 + if (preg_match('/[\|\`]/i', $string)) { // check for other bad characters
1005 1005 return true;
1006 1006 }
1007 1007 if (empty($string) or $string == '/') {
24 lib/excel/Parser.php
@@ -466,7 +466,7 @@ function _convert($token)
466 466 {
467 467 return(pack("C", $this->ptg[$token]));
468 468 }
469   - elseif(preg_match("/[A-Z0-9�-�\.]+/",$token))
  469 + elseif(preg_match("/[A-Z0-9�-�\.]+/",$token))
470 470 {
471 471 return($this->_convert_function($token,$this->_func_args));
472 472 }
@@ -723,21 +723,21 @@ function _match($token)
723 723 break;
724 724 default:
725 725 // if it's a reference
726   - if(eregi("^[A-I]?[A-Z][0-9]+$",$token) and
727   - !ereg("[0-9]",$this->_lookahead) and
  726 + if(preg_match("/^[A-I]?[A-Z][0-9]+$/i",$token) and
  727 + !preg_match("/[0-9]/",$this->_lookahead) and
728 728 ($this->_lookahead != ':') and ($this->_lookahead != '.'))
729 729 {
730 730 return($token);
731 731 }
732 732 // if it's a range (A1:A2)
733   - elseif(eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$token) and
734   - !ereg("[0-9]",$this->_lookahead))
  733 + elseif(preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$token) and
  734 + !preg_match("/[0-9]/",$this->_lookahead))
735 735 {
736 736 return($token);
737 737 }
738 738 // if it's a range (A1..A2)
739   - elseif(eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$token) and
740   - !ereg("[0-9]",$this->_lookahead))
  739 + elseif(preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$token) and
  740 + !preg_match("/[0-9]/",$this->_lookahead))
741 741 {
742 742 return($token);
743 743 }
@@ -746,7 +746,7 @@ function _match($token)
746 746 return($token);
747 747 }
748 748 // if it's a function call
749   - elseif(eregi("^[A-Z0-9�-�\.]+$",$token) and ($this->_lookahead == "("))
  749 + elseif(preg_match("/^[A-Z0-9�-�\.]+$/i",$token) and ($this->_lookahead == "("))
750 750
751 751 {
752 752 return($token);
@@ -857,15 +857,15 @@ function _fact()
857 857 return($result);
858 858 }
859 859 // if it's a reference
860   - if (eregi("^[A-I]?[A-Z][0-9]+$",$this->_current_token))
  860 + if (preg_match("/^[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
861 861 {
862 862 $result = $this->_create_tree($this->_current_token, '', '');
863 863 $this->_advance();
864 864 return($result);
865 865 }
866 866 // if it's a range
867   - elseif (eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$this->_current_token) or
868   - eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$this->_current_token))
  867 + elseif (preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$this->_current_token) or
  868 + preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
869 869 {
870 870 $result = $this->_current_token;
871 871 $this->_advance();
@@ -878,7 +878,7 @@ function _fact()
878 878 return($result);
879 879 }
880 880 // if it's a function call
881   - elseif (eregi("^[A-Z0-9�-�\.]+$",$this->_current_token))
  881 + elseif (preg_match("/^[A-Z0-9�-�\.]+$/i",$this->_current_token))
882 882 {
883 883 $result = $this->_func();
884 884 return($result);
4 lib/excel/Worksheet.php
@@ -1264,10 +1264,10 @@ function write_formula($row, $col, $formula, $format = 0)
1264 1264 }
1265 1265
1266 1266 // Strip the '=' or '@' sign at the beginning of the formula string
1267   - if (ereg("^=",$formula)) {
  1267 + if (preg_match("/^=/",$formula)) {
1268 1268 $formula = preg_replace("/(^=)/","",$formula);
1269 1269 }
1270   - elseif(ereg("^@",$formula)) {
  1270 + elseif(preg_match("/^@/",$formula)) {
1271 1271 $formula = preg_replace("/(^@)/","",$formula);
1272 1272 }
1273 1273 else {
104 lib/excel/readme_moodle.txt
... ... @@ -0,0 +1,104 @@
  1 +18 Nov 2009
  2 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  3 +
  4 +Index: Parser.php
  5 +===================================================================
  6 +RCS file: /cvsroot/moodle/moodle/lib/excel/Parser.php,v
  7 +retrieving revision 1.1
  8 +diff -u -r1.1 Parser.php
  9 +--- Parser.php 26 Sep 2003 04:18:02 -0000 1.1
  10 ++++ Parser.php 18 Nov 2009 06:27:54 -0000
  11 +@@ -466,7 +466,7 @@
  12 + {
  13 + return(pack("C", $this->ptg[$token]));
  14 + }
  15 +- elseif(preg_match("/[A-Z0-9À-Ü\.]+/",$token))
  16 ++ elseif(preg_match("/[A-Z0-9ï¿œ-ï¿œ\.]+/",$token))
  17 + {
  18 + return($this->_convert_function($token,$this->_func_args));
  19 + }
  20 +@@ -723,21 +723,21 @@
  21 + break;
  22 + default:
  23 + // if it's a reference
  24 +- if(eregi("^[A-I]?[A-Z][0-9]+$",$token) and
  25 +- !ereg("[0-9]",$this->_lookahead) and
  26 ++ if(preg_match("/^[A-I]?[A-Z][0-9]+$/i",$token) and
  27 ++ !preg_match("/[0-9]/",$this->_lookahead) and
  28 + ($this->_lookahead != ':') and ($this->_lookahead != '.'))
  29 + {
  30 + return($token);
  31 + }
  32 + // if it's a range (A1:A2)
  33 +- elseif(eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$token) and
  34 +- !ereg("[0-9]",$this->_lookahead))
  35 ++ elseif(preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$token) and
  36 ++ !preg_match("/[0-9]/",$this->_lookahead))
  37 + {
  38 + return($token);
  39 + }
  40 + // if it's a range (A1..A2)
  41 +- elseif(eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$token) and
  42 +- !ereg("[0-9]",$this->_lookahead))
  43 ++ elseif(preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$token) and
  44 ++ !preg_match("/[0-9]/",$this->_lookahead))
  45 + {
  46 + return($token);
  47 + }
  48 +@@ -746,7 +746,7 @@
  49 + return($token);
  50 + }
  51 + // if it's a function call
  52 +- elseif(eregi("^[A-Z0-9À-Ü\.]+$",$token) and ($this->_lookahead == "("))
  53 ++ elseif(preg_match("/^[A-Z0-9ï¿œ-ï¿œ\.]+$/i",$token) and ($this->_lookahead == "("))
  54 +
  55 + {
  56 + return($token);
  57 +@@ -857,15 +857,15 @@
  58 + return($result);
  59 + }
  60 + // if it's a reference
  61 +- if (eregi("^[A-I]?[A-Z][0-9]+$",$this->_current_token))
  62 ++ if (preg_match("/^[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
  63 + {
  64 + $result = $this->_create_tree($this->_current_token, '', '');
  65 + $this->_advance();
  66 + return($result);
  67 + }
  68 + // if it's a range
  69 +- elseif (eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$this->_current_token) or
  70 +- eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$this->_current_token))
  71 ++ elseif (preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$this->_current_token) or
  72 ++ preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$this->_current_token))
  73 + {
  74 + $result = $this->_current_token;
  75 + $this->_advance();
  76 +@@ -878,7 +878,7 @@
  77 + return($result);
  78 + }
  79 + // if it's a function call
  80 +- elseif (eregi("^[A-Z0-9À-Ü\.]+$",$this->_current_token))
  81 ++ elseif (preg_match("/^[A-Z0-9ï¿œ-ï¿œ\.]+$/i",$this->_current_token))
  82 + {
  83 + $result = $this->_func();
  84 + return($result);
  85 +Index: Worksheet.php
  86 +===================================================================
  87 +RCS file: /cvsroot/moodle/moodle/lib/excel/Worksheet.php,v
  88 +retrieving revision 1.1
  89 +diff -u -r1.1 Worksheet.php
  90 +--- Worksheet.php 26 Sep 2003 04:18:02 -0000 1.1
  91 ++++ Worksheet.php 18 Nov 2009 06:27:55 -0000
  92 +@@ -1264,10 +1264,10 @@
  93 + }
  94 +
  95 + // Strip the '=' or '@' sign at the beginning of the formula string
  96 +- if (ereg("^=",$formula)) {
  97 ++ if (preg_match("/^=/",$formula)) {
  98 + $formula = preg_replace("/(^=)/","",$formula);
  99 + }
  100 +- elseif(ereg("^@",$formula)) {
  101 ++ elseif(preg_match("/^@/",$formula)) {
  102 + $formula = preg_replace("/(^@)/","",$formula);
  103 + }
  104 + else {
2  lib/filelib.php
@@ -496,7 +496,7 @@ function mimeinfo($element, $filename) {
496 496 $mimeinfo = get_mimetypes_array();
497 497 }
498 498
499   - if (eregi('\.([a-z0-9]+)$', $filename, $match)) {
  499 + if (preg_match('/\.([a-z0-9]+)$/i', $filename, $match)) {
500 500 if (isset($mimeinfo[strtolower($match[1])][$element])) {
501 501 return $mimeinfo[strtolower($match[1])][$element];
502 502 } else {
2  lib/fpdf/font/makefont/makefont.php
@@ -171,7 +171,7 @@ function MakeFontDescriptor($fm,$symbolic)
171 171 //StemV
172 172 if(isset($fm['StdVW']))
173 173 $stemv=$fm['StdVW'];
174   - elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight']))
  174 + elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight']))
175 175 $stemv=120;
176 176 else
177 177 $stemv=70;
19 lib/fpdf/readme_moodle.txt
... ... @@ -0,0 +1,19 @@
  1 +18 Nov 2009
  2 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  3 +
  4 +Index: font/makefont/makefont.php
  5 +===================================================================
  6 +RCS file: /cvsroot/moodle/moodle/lib/fpdf/font/makefont/Attic/makefont.php,v
  7 +retrieving revision 1.2
  8 +diff -u -r1.2 makefont.php
  9 +--- font/makefont/makefont.php 16 May 2006 06:45:14 -0000 1.2
  10 ++++ font/makefont/makefont.php 18 Nov 2009 06:32:46 -0000
  11 +@@ -171,7 +171,7 @@
  12 + //StemV
  13 + if(isset($fm['StdVW']))
  14 + $stemv=$fm['StdVW'];
  15 +- elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight']))
  16 ++ elseif(isset($fm['Weight']) and preg_match('/(bold|black)/i',$fm['Weight']))
  17 + $stemv=120;
  18 + else
  19 + $stemv=70;
2  lib/geoip/geoip.inc
@@ -490,7 +490,7 @@ function getdnsattributes ($l,$ip){
490 490 $r->nameservers = array("ws1.maxmind.com");
491 491 $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
492 492 $str = is_object($p->answer[0])?$p->answer[0]->string():'';
493   - ereg("\"(.*)\"",$str,$regs);
  493 + preg_match("/\"(.*)\"/",$str,$regs);
494 494 $str = $regs[1];
495 495 return $str;
496 496 }
19 lib/geoip/readme_moodle.txt
... ... @@ -0,0 +1,19 @@
  1 +18 Nov 2009
  2 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  3 +
  4 +Index: geoip.inc
  5 +===================================================================
  6 +RCS file: /cvsroot/moodle/moodle/lib/geoip/geoip.inc,v
  7 +retrieving revision 1.1.2.2
  8 +diff -u -r1.1.2.2 geoip.inc
  9 +--- geoip.inc 2 Jan 2008 16:49:05 -0000 1.1.2.2
  10 ++++ geoip.inc 18 Nov 2009 06:34:59 -0000
  11 +@@ -490,7 +490,7 @@
  12 + $r->nameservers = array("ws1.maxmind.com");
  13 + $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
  14 + $str = is_object($p->answer[0])?$p->answer[0]->string():'';
  15 +- ereg("\"(.*)\"",$str,$regs);
  16 ++ preg_match("/\"(.*)\"/",$str,$regs);
  17 + $str = $regs[1];
  18 + return $str;
  19 + }
2  lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php
@@ -12,7 +12,7 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef
12 12 function validate($string, $config, &$context) {
13 13
14 14 // moodle change - we use special lang strings unfortunatelly
15   - return ereg_replace('[^0-9a-zA-Z_-]', '', $string);
  15 + return preg_replace('/[^0-9a-zA-Z_-]/', '', $string);
16 16 // moodle change end
17 17
18 18 $string = trim($string);
21 lib/htmlpurifier/readme_moodle.txt
@@ -8,3 +8,24 @@ Changes:
8 8 skodak
9 9
10 10 $Id$
  11 +
  12 +
  13 +18 Nov 2009
  14 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  15 +
  16 +Index: HTMLPurifier/AttrDef/Lang.php
  17 +===================================================================
  18 +RCS file: /cvsroot/moodle/moodle/lib/htmlpurifier/HTMLPurifier/AttrDef/Lang.php,v
  19 +retrieving revision 1.3
  20 +diff -u -r1.3 Lang.php
  21 +--- HTMLPurifier/AttrDef/Lang.php 25 Sep 2007 14:34:13 -0000 1.3
  22 ++++ HTMLPurifier/AttrDef/Lang.php 18 Nov 2009 06:37:14 -0000
  23 +@@ -12,7 +12,7 @@
  24 + function validate($string, $config, &$context) {
  25 +
  26 + // moodle change - we use special lang strings unfortunatelly
  27 +- return ereg_replace('[^0-9a-zA-Z_-]', '', $string);
  28 ++ return preg_replace('/[^0-9a-zA-Z_-]/', '', $string);
  29 + // moodle change end
  30 +
  31 + $string = trim($string);
36 lib/moodlelib.php
@@ -418,16 +418,16 @@ function clean_param($param, $type) {
418 418 return (float)$param; // Convert to integer
419 419
420 420 case PARAM_ALPHA: // Remove everything not a-z
421   - return eregi_replace('[^a-zA-Z]', '', $param);
  421 + return preg_replace('/[^a-zA-Z]/i', '', $param);
422 422
423 423 case PARAM_ALPHANUM: // Remove everything not a-zA-Z0-9
424   - return eregi_replace('[^A-Za-z0-9]', '', $param);
  424 + return preg_replace('/[^A-Za-z0-9]/i', '', $param);
425 425
426 426 case PARAM_ALPHAEXT: // Remove everything not a-zA-Z/_-
427   - return eregi_replace('[^a-zA-Z/_-]', '', $param);
  427 + return preg_replace('/[^a-zA-Z/_-]/i', '', $param);
428 428
429 429 case PARAM_SEQUENCE: // Remove everything not 0-9,
430   - return eregi_replace('[^0-9,]', '', $param);
  430 + return preg_replace('/[^0-9,]/i', '', $param);
431 431
432 432 case PARAM_BOOL: // Convert to 1 or 0
433 433 $tempstr = strtolower($param);
@@ -447,14 +447,14 @@ function clean_param($param, $type) {
447 447 return clean_param(strip_tags($param, '<lang><span>'), PARAM_CLEAN);
448 448
449 449 case PARAM_SAFEDIR: // Remove everything not a-zA-Z0-9_-
450   - return eregi_replace('[^a-zA-Z0-9_-]', '', $param);
  450 + return preg_replace('/[^a-zA-Z0-9_-]/i', '', $param);
451 451
452 452 case PARAM_CLEANFILE: // allow only safe characters
453 453 return clean_filename($param);
454 454
455 455 case PARAM_FILE: // Strip all suspicious characters from filename
456   - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':\\/]', '', $param);
457   - $param = ereg_replace('\.\.+', '', $param);
  456 + $param = preg_replace('/[[:cntrl:]]|[\/<>\"`|\':\\\\]/', '', $param);
  457 + $param = preg_replace('/\.\./', '', $param);//remove double full stops
458 458 if($param == '.') {
459 459 $param = '';
460 460 }
@@ -464,10 +464,10 @@ function clean_param($param, $type) {
464 464 $param = str_replace('\\\'', '\'', $param);
465 465 $param = str_replace('\\"', '"', $param);
466 466 $param = str_replace('\\', '/', $param);
467   - $param = ereg_replace('[[:cntrl:]]|[<>"`\|\':]', '', $param);
468   - $param = ereg_replace('\.\.+', '', $param);
469   - $param = ereg_replace('//+', '/', $param);
470   - return ereg_replace('/(\./)+', '/', $param);
  467 + $param = preg_replace('#[[:cntrl:]]|[<>"`\|\':]#', '', $param);
  468 + $param = preg_replace('#\.\.+#', '', $param);
  469 + $param = preg_replace('#//+#', '/', $param);
  470 + return preg_replace('#/(\./)+#', '/', $param);
471 471
472 472 case PARAM_HOST: // allow FQDN or IPv4 dotted quad
473 473 $param = preg_replace('/[^\.\d\w-]/','', $param ); // only allowed chars
@@ -4310,7 +4310,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a
4310 4310 }
4311 4311
4312 4312 if ($attachment && $attachname) {
4313   - if (ereg( "\\.\\." ,$attachment )) { // Security check for ".." in dir path
  4313 + if (preg_match( "/\\.\\./" ,$attachment )) { // Security check for ".." in dir path
4314 4314 $mail->AddAddress($supportuser->email, fullname($supportuser, true) );
4315 4315 $mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
4316 4316 } else {
@@ -4734,7 +4734,7 @@ function make_mod_upload_directory($courseid) {
4734 4734 function make_user_directory($userid, $test=false) {
4735 4735 global $CFG;
4736 4736
4737   - if (is_bool($userid) || $userid < 0 || !ereg('^[0-9]{1,10}$', $userid) || $userid > 2147483647) {
  4737 + if (is_bool($userid) || $userid < 0 || !preg_match('/^[0-9]{1,10}$/', $userid) || $userid > 2147483647) {
4738 4738 if (!$test) {
4739 4739 notify("Given userid was not a valid integer! (" . gettype($userid) . " $userid)");
4740 4740 }
@@ -6823,7 +6823,7 @@ function count_letters($string) {
6823 6823 $textlib = textlib_get_instance();
6824 6824
6825 6825 $string = strip_tags($string); // Tags are out now
6826   - $string = ereg_replace('[[:space:]]*','',$string); //Whitespace are out now
  6826 + $string = preg_replace('/[[:space:]]*/','',$string); //Whitespace are out now
6827 6827
6828 6828 return $textlib->strlen($string);
6829 6829 }
@@ -7736,11 +7736,11 @@ function unzip_cleanfilename ($p_event, &$p_header) {
7736 7736 //This function is used as callback in unzip_file() function
7737 7737 //to clean illegal characters for given platform and to prevent directory traversal.
7738 7738 //Produces the same result as info-zip unzip.
7739   - $p_header['filename'] = ereg_replace('[[:cntrl:]]', '', $p_header['filename']); //strip control chars first!
7740   - $p_header['filename'] = ereg_replace('\.\.+', '', $p_header['filename']); //directory traversal protection
  7739 + $p_header['filename'] = preg_replace('/[[:cntrl:]]/', '', $p_header['filename']); //strip control chars first!
  7740 + $p_header['filename'] = preg_replace('#\.\.+#', '', $p_header['filename']); //directory traversal protection
7741 7741 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
7742   - $p_header['filename'] = ereg_replace('[:*"?<>|]', '_', $p_header['filename']); //replace illegal chars
7743   - $p_header['filename'] = ereg_replace('^([a-zA-Z])_', '\1:', $p_header['filename']); //repair drive letter
  7742 + $p_header['filename'] = preg_replace('/[:*"?<>|]/', '_', $p_header['filename']); //replace illegal chars
  7743 + $p_header['filename'] = preg_replace('/^([a-zA-Z])_/', '\1:', $p_header['filename']); //repair drive letter
7744 7744 } else {
7745 7745 //Add filtering for other systems here
7746 7746 // BSD: none (tested)
10 lib/pclzip/pclzip.lib.php
@@ -3245,7 +3245,9 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all
3245 3245 }
3246 3246
3247 3247 // ----- Look for extract by ereg rule
3248   - else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
  3248 + /*
  3249 + * MDL-20821 ereg is now deprecated
  3250 + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
3249 3251 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3250 3252 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
3251 3253
@@ -3253,7 +3255,7 @@ function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all
3253 3255 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
3254 3256 $v_extract = true;
3255 3257 }
3256   - }
  3258 + }*/
3257 3259
3258 3260 // ----- Look for extract by preg rule
3259 3261 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
@@ -4684,6 +4686,8 @@ function privDeleteByRule(&$p_result_list, &$p_options)
4684 4686 }
4685 4687
4686 4688 // ----- Look for extract by ereg rule
  4689 + /*
  4690 + * MDL-20821 ereg is now deprecated
4687 4691 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4688 4692 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4689 4693 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
@@ -4692,7 +4696,7 @@ function privDeleteByRule(&$p_result_list, &$p_options)
4692 4696 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
4693 4697 $v_found = true;
4694 4698 }
4695   - }
  4699 + }*/
4696 4700
4697 4701 // ----- Look for extract by preg rule
4698 4702 else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
52 lib/pclzip/readme_moodle.txt
@@ -5,4 +5,54 @@ Changes:
5 5 * removed PclZipUtilTranslateWinPath from line 1958 - see MDL-7828
6 6
7 7 skodak
8   -$Id$
  8 +$Id$
  9 +
  10 +
  11 +18 Nov 2009
  12 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  13 +
  14 +Index: pclzip.lib.php
  15 +===================================================================
  16 +RCS file: /cvsroot/moodle/moodle/lib/pclzip/Attic/pclzip.lib.php,v
  17 +retrieving revision 1.15
  18 +diff -u -r1.15 pclzip.lib.php
  19 +--- pclzip.lib.php 28 Mar 2007 07:17:26 -0000 1.15
  20 ++++ pclzip.lib.php 18 Nov 2009 06:40:48 -0000
  21 +@@ -3245,7 +3245,9 @@
  22 + }
  23 +
  24 + // ----- Look for extract by ereg rule
  25 +- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
  26 ++ /*
  27 ++ * MDL-20821 ereg is now deprecated
  28 ++ else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
  29 + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
  30 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
  31 +
  32 +@@ -3253,7 +3255,7 @@
  33 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  34 + $v_extract = true;
  35 + }
  36 +- }
  37 ++ }*/
  38 +
  39 + // ----- Look for extract by preg rule
  40 + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
  41 +@@ -4684,6 +4686,8 @@
  42 + }
  43 +
  44 + // ----- Look for extract by ereg rule
  45 ++ /*
  46 ++ * MDL-20821 ereg is now deprecated
  47 + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
  48 + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
  49 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
  50 +@@ -4692,7 +4696,7 @@
  51 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
  52 + $v_found = true;
  53 + }
  54 +- }
  55 ++ }*/
  56 +
  57 + // ----- Look for extract by preg rule
  58 + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
100 lib/pear/README_MOODLE.txt
@@ -12,3 +12,103 @@ to a new release within Moodle.
12 12
13 13 stronk7
14 14 $Id$
  15 +
  16 +
  17 +18 Nov 2009
  18 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  19 +
  20 +Index: Spreadsheet/Excel/Writer/Parser.php
  21 +===================================================================
  22 +RCS file: /cvsroot/moodle/moodle/lib/pear/Spreadsheet/Excel/Writer/Parser.php,v
  23 +retrieving revision 1.2
  24 +diff -u -r1.2 Parser.php
  25 +--- Spreadsheet/Excel/Writer/Parser.php 4 Jan 2006 08:23:42 -0000 1.2
  26 ++++ Spreadsheet/Excel/Writer/Parser.php 18 Nov 2009 06:42:45 -0000
  27 +@@ -1206,7 +1206,7 @@
  28 + default:
  29 + // if it's a reference
  30 + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
  31 +- !ereg("[0-9]",$this->_lookahead) and
  32 ++ !preg_match("/[0-9]/",$this->_lookahead) and
  33 + ($this->_lookahead != ':') and ($this->_lookahead != '.') and
  34 + ($this->_lookahead != '!'))
  35 + {
  36 +@@ -1214,39 +1214,39 @@
  37 + }
  38 + // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
  39 + elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
  40 +- !ereg("[0-9]",$this->_lookahead) and
  41 ++ !preg_match("/[0-9]/",$this->_lookahead) and
  42 + ($this->_lookahead != ':') and ($this->_lookahead != '.'))
  43 + {
  44 + return $token;
  45 + }
  46 + // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
  47 + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
  48 +- !ereg("[0-9]",$this->_lookahead) and
  49 ++ !preg_match("/[0-9]/",$this->_lookahead) and
  50 + ($this->_lookahead != ':') and ($this->_lookahead != '.'))
  51 + {
  52 + return $token;
  53 + }
  54 + // if it's a range (A1:A2)
  55 + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
  56 +- !ereg("[0-9]",$this->_lookahead))
  57 ++ !preg_match("/[0-9]/",$this->_lookahead))
  58 + {
  59 + return $token;
  60 + }
  61 + // if it's a range (A1..A2)
  62 + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
  63 +- !ereg("[0-9]",$this->_lookahead))
  64 ++ !preg_match("/[0-9]/",$this->_lookahead))
  65 + {
  66 + return $token;
  67 + }
  68 + // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2
  69 + elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
  70 +- !ereg("[0-9]",$this->_lookahead))
  71 ++ !preg_match("/[0-9]/",$this->_lookahead))
  72 + {
  73 + return $token;
  74 + }
  75 + // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
  76 + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
  77 +- !ereg("[0-9]",$this->_lookahead))
  78 ++ !preg_match("/[0-9]/",$this->_lookahead))
  79 + {
  80 + return $token;
  81 + }
  82 +@@ -1258,12 +1258,12 @@
  83 + return $token;
  84 + }
  85 + // If it's a string (of maximum 255 characters)
  86 +- elseif (ereg("^\"[^\"]{0,255}\"$",$token))
  87 ++ elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token))
  88 + {
  89 + return $token;
  90 + }
  91 + // if it's a function call
  92 +- elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
  93 ++ elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
  94 + {
  95 + return $token;
  96 + }
  97 +@@ -1363,7 +1363,7 @@
  98 + function _expression()
  99 + {
  100 + // If it's a string return a string node
  101 +- if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) {
  102 ++ if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) {
  103 + $result = $this->_createTree($this->_current_token, '', '');
  104 + $this->_advance();
  105 + return $result;
  106 +@@ -1521,7 +1521,7 @@
  107 + return $result;
  108 + }
  109 + // if it's a function call
  110 +- elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
  111 ++ elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
  112 + {
  113 + $result = $this->_func();
  114 + return $result;
22 lib/pear/Spreadsheet/Excel/Writer/Parser.php
@@ -1206,7 +1206,7 @@ function _match($token)
1206 1206 default:
1207 1207 // if it's a reference
1208 1208 if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
1209   - !ereg("[0-9]",$this->_lookahead) and
  1209 + !preg_match("/[0-9]/",$this->_lookahead) and
1210 1210 ($this->_lookahead != ':') and ($this->_lookahead != '.') and
1211 1211 ($this->_lookahead != '!'))
1212 1212 {
@@ -1214,39 +1214,39 @@ function _match($token)
1214 1214 }
1215 1215 // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1)
1216 1216 elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
1217   - !ereg("[0-9]",$this->_lookahead) and
  1217 + !preg_match("/[0-9]/",$this->_lookahead) and
1218 1218 ($this->_lookahead != ':') and ($this->_lookahead != '.'))
1219 1219 {
1220 1220 return $token;
1221 1221 }
1222 1222 // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
1223 1223 elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and
1224   - !ereg("[0-9]",$this->_lookahead) and
  1224 + !preg_match("/[0-9]/",$this->_lookahead) and
1225 1225 ($this->_lookahead != ':') and ($this->_lookahead != '.'))
1226 1226 {
1227 1227 return $token;
1228 1228 }
1229 1229 // if it's a range (A1:A2)
1230 1230 elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
1231   - !ereg("[0-9]",$this->_lookahead))
  1231 + !preg_match("/[0-9]/",$this->_lookahead))
1232 1232 {
1233 1233 return $token;
1234 1234 }
1235 1235 // if it's a range (A1..A2)
1236 1236 elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
1237   - !ereg("[0-9]",$this->_lookahead))
  1237 + !preg_match("/[0-9]/",$this->_lookahead))
1238 1238 {
1239 1239 return $token;
1240 1240 }
1241 1241 // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2
1242 1242 elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
1243   - !ereg("[0-9]",$this->_lookahead))
  1243 + !preg_match("/[0-9]/",$this->_lookahead))
1244 1244 {
1245 1245 return $token;
1246 1246 }
1247 1247 // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2
1248 1248 elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and
1249   - !ereg("[0-9]",$this->_lookahead))
  1249 + !preg_match("/[0-9]/",$this->_lookahead))
1250 1250 {
1251 1251 return $token;
1252 1252 }
@@ -1258,12 +1258,12 @@ function _match($token)
1258 1258 return $token;
1259 1259 }
1260 1260 // If it's a string (of maximum 255 characters)
1261   - elseif (ereg("^\"[^\"]{0,255}\"$",$token))
  1261 + elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token))
1262 1262 {
1263 1263 return $token;
1264 1264 }
1265 1265 // if it's a function call
1266   - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "("))
  1266 + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "("))
1267 1267 {
1268 1268 return $token;
1269 1269 }
@@ -1363,7 +1363,7 @@ function _condition()
1363 1363 function _expression()
1364 1364 {
1365 1365 // If it's a string return a string node
1366   - if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) {
  1366 + if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) {
1367 1367 $result = $this->_createTree($this->_current_token, '', '');
1368 1368 $this->_advance();
1369 1369 return $result;
@@ -1521,7 +1521,7 @@ function _fact()
1521 1521 return $result;
1522 1522 }
1523 1523 // if it's a function call
1524   - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token))
  1524 + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token))
1525 1525 {
1526 1526 $result = $this->_func();
1527 1527 return $result;
11 lib/simpletest/testmoodlelib.php
@@ -199,6 +199,17 @@ function test_clean_param()
199 199 $this->assertEqual(clean_param($CFG->wwwroot, PARAM_LOCALURL), $CFG->wwwroot);
200 200 $this->assertEqual(clean_param('/just/a/path', PARAM_LOCALURL), '/just/a/path');
201 201 $this->assertEqual(clean_param('funny:thing', PARAM_LOCALURL), '');
  202 +
  203 + //test filename param
  204 + $this->assertEqual(clean_param('correctfile.txt', PARAM_FILE), 'correctfile.txt');
  205 + $this->assertEqual(clean_param('b\'a<d`\\/fi:l>e.t"x|t', PARAM_FILE), 'badfile.txt');
  206 + $this->assertEqual(clean_param('../parentdirfile.txt', PARAM_FILE), 'parentdirfile.txt');
  207 + //The following behaviours have been maintained although they seem a little odd
  208 + $this->assertEqual(clean_param('funny:thing', PARAM_FILE), 'funnything');
  209 + $this->assertEqual(clean_param('./currentdirfile.txt', PARAM_FILE), '.currentdirfile.txt');
  210 + $this->assertEqual(clean_param('c:\temp\windowsfile.txt', PARAM_FILE), 'ctempwindowsfile.txt');
  211 + $this->assertEqual(clean_param('/home/user/linuxfile.txt', PARAM_FILE), 'homeuserlinuxfile.txt');
  212 + $this->assertEqual(clean_param('~/myfile.txt', PARAM_FILE), '~myfile.txt');
202 213 }
203 214
204 215 function test_make_user_directory() {
273 lib/soap/README_MOODLE.txt
... ... @@ -0,0 +1,273 @@
  1 +18 Nov 2009
  2 +Description of modifications to remove ereg related functions deprecated as of php 5.3. Patch below.
  3 +
  4 +Index: nusoap.php
  5 +===================================================================
  6 +RCS file: /cvsroot/moodle/moodle/lib/soap/nusoap.php,v
  7 +retrieving revision 1.2
  8 +diff -u -r1.2 nusoap.php
  9 +--- nusoap.php 3 Jan 2007 14:44:42 -0000 1.2
  10 ++++ nusoap.php 18 Nov 2009 06:48:29 -0000
  11 +@@ -503,7 +503,7 @@
  12 + case (is_array($val) || $type):
  13 + // detect if struct or array
  14 + $valueType = $this->isArraySimpleOrStruct($val);
  15 +- if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){
  16 ++ if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
  17 + $i = 0;
  18 + if(is_array($val) && count($val)> 0){
  19 + foreach($val as $v){
  20 +@@ -698,7 +698,7 @@
  21 + */
  22 + function expandQname($qname){
  23 + // get element prefix
  24 +- if(strpos($qname,':') && !ereg('^http://',$qname)){
  25 ++ if(strpos($qname,':') && !preg_match('#^http://#',$qname)){
  26 + // get unqualified name
  27 + $name = substr(strstr($qname,':'),1);
  28 + // get ns prefix
  29 +@@ -827,6 +827,7 @@
  30 + $datestr = date('Y-m-d\TH:i:sO',$timestamp);
  31 + if($utc){
  32 + $eregStr =
  33 ++ '/'.
  34 + '([0-9]{4})-'. // centuries & years CCYY-
  35 + '([0-9]{2})-'. // months MM-
  36 + '([0-9]{2})'. // days DD
  37 +@@ -834,9 +835,10 @@
  38 + '([0-9]{2}):'. // hours hh:
  39 + '([0-9]{2}):'. // minutes mm:
  40 + '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
  41 +- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
  42 ++ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
  43 ++ '/';
  44 +
  45 +- if(ereg($eregStr,$datestr,$regs)){
  46 ++ if(preg_match($eregStr,$datestr,$regs)){
  47 + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
  48 + }
  49 + return false;
  50 +@@ -853,6 +855,7 @@
  51 + */
  52 + function iso8601_to_timestamp($datestr){
  53 + $eregStr =
  54 ++ '/'.
  55 + '([0-9]{4})-'. // centuries & years CCYY-
  56 + '([0-9]{2})-'. // months MM-
  57 + '([0-9]{2})'. // days DD
  58 +@@ -860,8 +863,9 @@
  59 + '([0-9]{2}):'. // hours hh:
  60 + '([0-9]{2}):'. // minutes mm:
  61 + '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
  62 +- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
  63 +- if(ereg($eregStr,$d