PHP code broken

My Joomla web server company, Rochen, just upgraded to the latest version of PHP and the template script for mobil devices is broken. The error message is:

Deprecated: Function eregi() is deprecated in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 52

There were several error statements such as this.

Also, the administrator control panel no longer shows the items to change/edit templates, show plugin list, and take Joomla offline, add remove components/plugins.

I do not know how to edit PHP. Is there some way to solve this?

Hi,

Obviously you’re using a function eregi() which is no longer supported in your newer version of PHP. Try to replace that with preg_match() function.

I tried that, but there needs to be a /i placed somewhere in the code that I can’t figure out.

This is part of the code:

case (eregi('ipod',$user_agent)||eregi('iphone',$user_agent)); // we find the words iphone or ipod in the user agent
  $mobile_browser = $iphone; // mobile browser is either true or false depending on the setting of iphone when calling the function
  if(substr($iphone,0,4)=='http'){ // does the value of iphone resemble a url
    $mobileredirect = $iphone; // set the mobile redirect url to the url value stored in the iphone value
  } // ends the if for iphone being a url
break; // break out and skip the rest if we've had a match on the iphone or ipod

case (eregi('android',$user_agent));  // we find android in the user agent
  $mobile_browser = $android; // mobile browser is either true or false depending on the setting of android when calling the function
  if(substr($android,0,4)=='http'){ // does the value of android resemble a url
    $mobileredirect = $android; // set the mobile redirect url to the url value stored in the android value
  } // ends the if for android being a url
break; // break out and skip the rest if we've had a match on android

case (eregi('opera mini',$user_agent)); // we find opera mini in the user agent
  $mobile_browser = $opera; // mobile browser is either true or false depending on the setting of opera when calling the function
  if(substr($opera,0,4)=='http'){ // does the value of opera resemble a rul
    $mobileredirect = $opera; // set the mobile redirect url to the url value stored in the opera value
  } // ends the if for opera being a url 
break; // break out and skip the rest if we've had a match on opera

case (eregi('blackberry',$user_agent)); // we find blackberry in the user agent
  $mobile_browser = $blackberry; // mobile browser is either true or false depending on the setting of blackberry when calling the function
  if(substr($blackberry,0,4)=='http'){ // does the value of blackberry resemble a rul
    $mobileredirect = $blackberry; // set the mobile redirect url to the url value stored in the blackberry value
  } // ends the if for blackberry being a url 
break; // break out and skip the rest if we've had a match on blackberry

case (preg_match('/(palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent)); // we find palm os in the user agent - the i at the end makes it case insensitive
  $mobile_browser = $palm; // mobile browser is either true or false depending on the setting of palm when calling the function
  if(substr($palm,0,4)=='http'){ // does the value of palm resemble a rul
    $mobileredirect = $palm; // set the mobile redirect url to the url value stored in the palm value
  } // ends the if for palm being a url 
break; // break out and skip the rest if we've had a match on palm os

case (preg_match('/(windows ce; ppc;|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)); // we find windows mobile in the user agent - the i at the end makes it case insensitive
  $mobile_browser = $windows; // mobile browser is either true or false depending on the setting of windows when calling the function
  if(substr($windows,0,4)=='http'){ // does the value of windows resemble a rul
    $mobileredirect = $windows; // set the mobile redirect url to the url value stored in the windows value
  } // ends the if for windows being a url 
break; // break out and skip the rest if we've had a match on windows

case (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive
  $mobile_browser = true; // set mobile browser to true
break; // break out and skip the rest if we've preg_match on the user agent returned true 

Any suggestions?

[php]case (preg_match(‘ipod’,$user_agent)||preg_match(‘iphone’,$user_agent)); // we find the words iphone or ipod in the user agent
$mobile_browser = $iphone; // mobile browser is either true or false depending on the setting of iphone when calling the function
if(substr($iphone,0,4)==‘http’){ // does the value of iphone resemble a url
$mobileredirect = $iphone; // set the mobile redirect url to the url value stored in the iphone value
} // ends the if for iphone being a url
break; // break out and skip the rest if we’ve had a match on the iphone or ipod

case (preg_match('android',$user_agent));  // we find android in the user agent
  $mobile_browser = $android; // mobile browser is either true or false depending on the setting of android when calling the function
  if(substr($android,0,4)=='http'){ // does the value of android resemble a url
    $mobileredirect = $android; // set the mobile redirect url to the url value stored in the android value
  } // ends the if for android being a url
break; // break out and skip the rest if we've had a match on android

case (preg_match('opera mini',$user_agent)); // we find opera mini in the user agent
  $mobile_browser = $opera; // mobile browser is either true or false depending on the setting of opera when calling the function
  if(substr($opera,0,4)=='http'){ // does the value of opera resemble a rul
    $mobileredirect = $opera; // set the mobile redirect url to the url value stored in the opera value
  } // ends the if for opera being a url 
break; // break out and skip the rest if we've had a match on opera

case (preg_match('blackberry',$user_agent)); // we find blackberry in the user agent
  $mobile_browser = $blackberry; // mobile browser is either true or false depending on the setting of blackberry when calling the function
  if(substr($blackberry,0,4)=='http'){ // does the value of blackberry resemble a rul
    $mobileredirect = $blackberry; // set the mobile redirect url to the url value stored in the blackberry value
  } // ends the if for blackberry being a url 
break; // break out and skip the rest if we've had a match on blackberry

case (preg_match('/(palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent)); // we find palm os in the user agent - the i at the end makes it case insensitive
  $mobile_browser = $palm; // mobile browser is either true or false depending on the setting of palm when calling the function
  if(substr($palm,0,4)=='http'){ // does the value of palm resemble a rul
    $mobileredirect = $palm; // set the mobile redirect url to the url value stored in the palm value
  } // ends the if for palm being a url 
break; // break out and skip the rest if we've had a match on palm os

case (preg_match('/(windows ce; ppc;|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)); // we find windows mobile in the user agent - the i at the end makes it case insensitive
  $mobile_browser = $windows; // mobile browser is either true or false depending on the setting of windows when calling the function
  if(substr($windows,0,4)=='http'){ // does the value of windows resemble a rul
    $mobileredirect = $windows; // set the mobile redirect url to the url value stored in the windows value
  } // ends the if for windows being a url 
break; // break out and skip the rest if we've had a match on windows

case (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|pda|psp|treo)/i',$user_agent)); // check if any of the values listed create a match on the user agent - these are some of the most common terms used in agents to identify them as being mobile devices - the i at the end makes it case insensitive
  $mobile_browser = true; // set mobile browser to true
break; // break out and skip the rest if we've preg_match on the user agent returned true[/php]

Thanks for the help.

The website now returns the following error messages:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 52

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 52

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 59

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 66

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 73

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 52

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 52

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 59

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 66

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/drillcom/public_html/templates/ja_purity_ii/libs/mobile_device_detect.php on line 73

By trial and errpr I got the /i in the right places:

case (preg_match(’/(ipod)/i’,$user_agent)||preg_match(’/(iphone)/i’,$user_agent)); // we find the words iphone or ipod in the user agent
$mobile_browser = $iphone; // mobile browser is either true or false depending on the setting of iphone when calling the function
if(substr($iphone,0,4)==‘http’){ // does the value of iphone resemble a url
$mobileredirect = $iphone; // set the mobile redirect url to the url value stored in the iphone value
} // ends the if for iphone being a url
break; // break out and skip the rest if we’ve had a match on the iphone or ipod

Thank you.

Glad you got it sorted. Mine was a bit of a stab in the dark :-X

Sponsor our Newsletter | Privacy Policy | Terms of Service