0

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.

andy
  • 2,002
  • 1
  • 12
  • 21
Rupzz
  • 136
  • 1
  • 3
  • 16
  • So, which joomla version are you using? Where did you replace `ereg()` it is still in your code? – andy Oct 14 '14 at 11:02
  • @andy i am using Joomla 3.3.3. I replaced in template.php where error is occurig. – Rupzz Oct 14 '14 at 11:05
  • 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 – Lodder Oct 14 '14 at 11:06
  • @bcmcfc i have upgraded Joomla 1.5 to Joomla 3.3.3 before one month. – Rupzz Oct 14 '14 at 11:06
  • possible duplicate of [How can I convert ereg expressions to preg in PHP?](http://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php) – andy Oct 14 '14 at 11:08
  • I cannot do it. It was already made in Joomla 1.5. i have upgrade it to Joomla 3.3.3. Can you give any alternate solution? – Rupzz Oct 14 '14 at 11:10
  • Set error reporting to none in configuration panel in administrator.... – Rahul Kaushik Oct 14 '14 at 11:11
  • @andy i have already substitute ereg with preg_match. – Rupzz Oct 14 '14 at 11:11
  • @Rahul K It will hide error message. But changes which were occured is still there. – Rupzz Oct 14 '14 at 11:14
  • @Rahul K Thanku Rahul. Your suggestion is helpful. – Rupzz Oct 14 '14 at 11:21

1 Answers1

1

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/

Lodder
  • 19,758
  • 10
  • 59
  • 100
  • "If your template has to have separate custom CSS files for each browser, then it is a poorly made template." — is not a valid conclusion. It's true that targeting specific versions of browsers broadly like this case isn't good, but adaptive web design uses browser and device attribute detection all the time, just look at the way any major website is built. Our largest clients sites use adaptive and responsive attributes to be tailor the experience for the end user. – Craig Oct 15 '14 at 09:57
  • @cppl - maybe my statement was a bit OTT or even worded incorrectly, but with web standards and technologies moving forward to rapidly, there should not really be separate styling for the likes of FF, Chrome, Opera. I'm a person that believes keeping things up to date (as you may have noticed from many of my rants about old Joomla versions), so the only time I believe a fallback stylesheet should be used is if required for much older IE versions. The fact that the template is still using `ereg` just goes to show how old it is when separate CSS files for different browser may have been the norm – Lodder Oct 15 '14 at 10:06