Skip to content

Commit

Permalink
all MDL-20821 Removed more deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Davis committed Nov 18, 2009
1 parent e998eff commit 6959330
Show file tree
Hide file tree
Showing 25 changed files with 794 additions and 96 deletions.
7 changes: 3 additions & 4 deletions lib/bennu/iCalendar_rfc2445.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
* @version $Id$
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

Expand Down Expand Up @@ -139,13 +138,13 @@ function rfc2445_is_valid_value($value, $type) {
}

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

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

case RFC2445_TYPE_BINARY:
Expand Down
27 changes: 27 additions & 0 deletions lib/bennu/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
18 Nov 2009
Description of Bennu modifications to remove functions deprecated as of php 5.3

Index: iCalendar_rfc2445.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/bennu/iCalendar_rfc2445.php,v
retrieving revision 1.5
diff -u -r1.5 iCalendar_rfc2445.php
--- iCalendar_rfc2445.php 4 Nov 2009 20:06:40 -0000 1.5
+++ iCalendar_rfc2445.php 18 Nov 2009 03:50:16 -0000
@@ -138,13 +138,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:
2 changes: 1 addition & 1 deletion lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,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('/[\|\`]/', $string)) { // check for other bad characters
return true;
}
if (empty($string) or $string == '/') {
Expand Down
24 changes: 12 additions & 12 deletions lib/excel/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ function _convert($token)
{
return(pack("C", $this->ptg[$token]));
}
elseif(preg_match("/[A-Z0-9À-Ü\.]+/",$token))
elseif(preg_match("/[A-Z0-9�-�\.]+/",$token))
{
return($this->_convert_function($token,$this->_func_args));
}
Expand Down Expand Up @@ -723,21 +723,21 @@ function _match($token)
break;
default:
// if it's a reference
if(eregi("^[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead) and
if(preg_match("/^[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return($token);
}
// if it's a range (A1:A2)
elseif(eregi("^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead))
elseif(preg_match("/^[A-I]?[A-Z][0-9]+:[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return($token);
}
// if it's a range (A1..A2)
elseif(eregi("^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$",$token) and
!ereg("[0-9]",$this->_lookahead))
elseif(preg_match("/^[A-I]?[A-Z][0-9]+\.\.[A-I]?[A-Z][0-9]+$/i",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return($token);
}
Expand All @@ -746,7 +746,7 @@ function _match($token)
return($token);
}
// if it's a function call
elseif(eregi("^[A-Z0-9À-Ü\.]+$",$token) and ($this->_lookahead == "("))
elseif(preg_match("/^[A-Z0-9�-�\.]+$/i",$token) and ($this->_lookahead == "("))

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

// Strip the '=' or '@' sign at the beginning of the formula string
if (ereg("^=",$formula)) {
if (preg_match("/^=/",$formula)) {
$formula = preg_replace("/(^=)/","",$formula);
}
elseif(ereg("^@",$formula)) {
elseif(preg_match("/^@/",$formula)) {
$formula = preg_replace("/(^@)/","",$formula);
}
else {
Expand Down
104 changes: 104 additions & 0 deletions lib/excel/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
18 Nov 2009
Description of WriteExcel modifications to remove functions deprecated as of php 5.3

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 03:58:49 -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 03:58:50 -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 {
2 changes: 1 addition & 1 deletion lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ function mimeinfo($element, $filename) {
global $CFG;
$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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/geoip/geoip.inc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,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;
}
Expand Down
20 changes: 20 additions & 0 deletions lib/geoip/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
18 Nov 2009
Description of geoip 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.2
diff -u -r1.2 geoip.inc
--- geoip.inc 19 Jul 2009 13:54:11 -0000 1.2
+++ geoip.inc 18 Nov 2009 04:03:48 -0000
@@ -493,7 +493,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;
}

Loading

0 comments on commit 6959330

Please sign in to comment.