Commit d206bb4e authored by H Klocker's avatar H Klocker Committed by Robert Lyon

Bug 1588599: Fixing up Mahara for php7

Changing deprecated join() and ereg() eregi() functions to their more
robust equivalents

behatnotneeded

Change-Id: I76e928a945a0f4b0a2b7b2a3096200c2f8df9db9
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit e7d540e5)
(cherry picked from commit 4c6573b9)
parent aeb91f9e
...@@ -65,7 +65,7 @@ if ($type == '') { ...@@ -65,7 +65,7 @@ if ($type == '') {
if (!isset($options[$type])) { if (!isset($options[$type])) {
// Comma-separated list; filter out anything that's not an installed type // Comma-separated list; filter out anything that's not an installed type
$type = join(',', array_unique(array_filter( $type = join(',', array_unique(array_filter(
split(',', $type), explode(',', $type),
function ($a) {global $installedtypes; return isset($installedtypes[$a]);} function ($a) {global $installedtypes; return isset($installedtypes[$a]);}
))); )));
} }
...@@ -267,7 +267,7 @@ function delete_all_notifications_submit() { ...@@ -267,7 +267,7 @@ function delete_all_notifications_submit() {
$typesql = ''; $typesql = '';
if ($type != 'all') { if ($type != 'all') {
// Treat as comma-separated list of activity type names // Treat as comma-separated list of activity type names
$types = split(',', preg_replace('/[^a-z,]+/', '', $type)); $types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) { if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')'; $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) { if (in_array('adminmessages', $types)) {
......
...@@ -31,7 +31,7 @@ function activitylistin($type='all', $limit=10, $offset=0) { ...@@ -31,7 +31,7 @@ function activitylistin($type='all', $limit=10, $offset=0) {
$typesql = ''; $typesql = '';
if ($type != 'all') { if ($type != 'all') {
// Treat as comma-separated list of activity type names // Treat as comma-separated list of activity type names
$types = split(',', preg_replace('/[^a-z,]+/', '', $type)); $types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) { if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')'; $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) { if (in_array('adminmessages', $types)) {
...@@ -415,7 +415,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) { ...@@ -415,7 +415,7 @@ function activitylistout_html($type='all', $limit=10, $offset=0) {
$typesql = ''; $typesql = '';
if ($type != 'all') { if ($type != 'all') {
// Treat as comma-separated list of activity type names // Treat as comma-separated list of activity type names
$types = split(',', preg_replace('/[^a-z,]+/', '', $type)); $types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) { if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')'; $typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) { if (in_array('adminmessages', $types)) {
......
...@@ -59,7 +59,7 @@ if ($type == '') { ...@@ -59,7 +59,7 @@ if ($type == '') {
if (!isset($options[$type])) { if (!isset($options[$type])) {
// Comma-separated list; filter out anything that's not an installed type // Comma-separated list; filter out anything that's not an installed type
$type = join(',', array_unique(array_filter( $type = join(',', array_unique(array_filter(
split(',', $type), explode(',', $type),
function ($a) {global $installedtypes; return isset($installedtypes[$a]);} function ($a) {global $installedtypes; return isset($installedtypes[$a]);}
))); )));
} }
......
...@@ -174,7 +174,7 @@ function validateUrlSyntax( $urladdr, $options="" ){ ...@@ -174,7 +174,7 @@ function validateUrlSyntax( $urladdr, $options="" ){
// $options = strtolower($options); // $options = strtolower($options);
// Check Options Parameter // Check Options Parameter
if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options ))
{ {
trigger_error("Options attribute malformed", E_USER_ERROR); trigger_error("Options attribute malformed", E_USER_ERROR);
} }
...@@ -309,13 +309,13 @@ function validateUrlSyntax( $urladdr, $options="" ){ ...@@ -309,13 +309,13 @@ function validateUrlSyntax( $urladdr, $options="" ){
// Building Regular Expression // Building Regular Expression
$regexp = '^' . $scheme . $userinfo . $address . $port_number . $path . $querystring . $fragment . '$'; $regexp = '/^' . $scheme . $userinfo . $address . $port_number . $path . $querystring . $fragment . '$/i';
// DEBUGGING - Uncomment Line Below To Display The Regular Expression Built // DEBUGGING - Uncomment Line Below To Display The Regular Expression Built
// echo '<pre>' . htmlentities(wordwrap($regexp,70,"\n",1)) . '</pre>'; // echo '<pre>' . htmlentities(wordwrap($regexp,70,"\n",1)) . '</pre>';
// Running the regular expression // Running the regular expression
if (eregi( $regexp, $urladdr )) if (preg_match( $regexp, $urladdr ))
{ {
return true; // The domain passed return true; // The domain passed
} }
...@@ -377,7 +377,7 @@ License: ...@@ -377,7 +377,7 @@ License:
function validateEmailSyntax( $emailaddr, $options="" ){ function validateEmailSyntax( $emailaddr, $options="" ){
// Check Options Parameter // Check Options Parameter
if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options ))
{ {
trigger_error("Options attribute malformed", E_USER_ERROR); trigger_error("Options attribute malformed", E_USER_ERROR);
} }
...@@ -483,7 +483,7 @@ License: ...@@ -483,7 +483,7 @@ License:
function validateFtpSyntax( $ftpaddr, $options="" ){ function validateFtpSyntax( $ftpaddr, $options="" ){
// Check Options Parameter // Check Options Parameter
if (!ereg( '^([sHSEFuPaIpfqr][+?-])*$', $options )) if (!preg_match( '/^([sHSEFuPaIpfqr][+?-])*$/', $options ))
{ {
trigger_error("Options attribute malformed", E_USER_ERROR); trigger_error("Options attribute malformed", E_USER_ERROR);
} }
......
...@@ -22,7 +22,7 @@ class SimpleSpamTrap extends NoneSpamTrap { ...@@ -22,7 +22,7 @@ class SimpleSpamTrap extends NoneSpamTrap {
protected function email_form($email) { protected function email_form($email) {
// pieforms does some email validation, but it's somewhat imperfect. // pieforms does some email validation, but it's somewhat imperfect.
// it allows multiple @ characters, for example // it allows multiple @ characters, for example
if (eregi("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", $email)) { if (preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i", $email)) {
return true; return true;
} }
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment