Rupzz
Rupzz

Reputation: 146

Deprecated: Function ereg() is deprecated in Joomla

I am facing a problem . In front page of my website i got following warning: Deprecated: Function ereg() is deprecated. Yesterday it was working right. I have searched in google and got that we have to substitue with "preg_match". I did it but problem is same.

Here is the code:

<?php
/*CSS fixed for some browser*/

$browser=$_SERVER['HTTP_USER_AGENT'];


if(ereg('MSIE 6', $browser)) {
    // hack IE here
    ?>
    <link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie6.css" rel="stylesheet" type="text/css" />
    <?
} else if(ereg('MSIE 7', $browser)) {
    // hack IE here
    ?>
    <link href="<?php echo JURI::base();?>/templates/crnatoday/templates/template_ie7.css" rel="stylesheet" type="text/css" />
    <?
} else if(ereg('Safari/([0-9].[0-9]{1,2})', $browser)){
    // hack safari here
    ?>
    <link href="<?php echo JURI::base();?>/templates/crnatoday/templates/safari.css" rel="stylesheet" type="text/css" />
    <?
} else if(ereg('Firefox/2', $browser) && ereg('Windows', $browser)) {   
    // hack firefox2
    ?>
    <link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox2_win.css" rel="stylesheet" type="text/css" />
    <?php
} else if(ereg('Firefox', $browser) && ereg('Mac', $browser)) { 
    // hack firefox2
    ?>
    <link href="<?php echo JURI::base();?>/templates/crnatoday/templates/firefox_mac.css" rel="stylesheet" type="text/css" />
    <?php
} else if(ereg('Mozilla/([0-9].[0-9]{1,2})', $browser)) {
    // hack mozilla here
} else {
    // hack other here
}


?>

Please help to sought it out.

Upvotes: 0

Views: 804

Answers (1)

Lodder
Lodder

Reputation: 19733

Your template was developed for Joomla 1.5 which supports PHP 4.3.10+. You host, has most likely upgraded the server PHP version from 5.2 or lower, to 5.3 or above.

If your template has to have separate custom CSS files for each browser, then it is a poorly made template. My suggestion would simply be to remove all that code and simply load 1 single CSS file.

If you really need to keeps these hacks (hopefully not), then have a look at the following which gives a little insight on how to convert ereg to preg_match:

http://www.devthought.com/2009/06/09/fix-ereg-is-deprecated-errors-in-php-53/

Upvotes: 1

Related Questions