Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Deprecated notice: Function eregi() is deprecated

Links for php scripts

Moderators: macek, egami, gesf

Deprecated notice: Function eregi() is deprecated

Postby frick » Fri Aug 31, 2012 1:46 am

Hi everybody

I'm using a mobile detect php-file to forward the mobile devices to the mobile website.

Here ist the Code:
Code: Select all
<?
   class rbc_BrowserInfo {
   
      public $browser = "";
      public $os = "";
      public $lang = "";
      public $mobile = 0;
      
      public function getBrowserInfo() {
         if (preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'ie';
          if (preg_match('/Firefox/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'firefox';
          if (preg_match('/Mozilla/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'firefox';
          if (preg_match('/Opera/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'opera';
          if (preg_match('/Safari/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'safari';
          if (preg_match('/Chrome/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'chrome';
          if (preg_match('/Camino/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'camino';
          if (preg_match('/Konqueror/i',$_SERVER['HTTP_USER_AGENT'])) $this->browser = 'konqueror';
          

         if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT'])) || (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
             $this->mobile = 1;
         }


         $os_arr = array ( 'windows' => '(Windows)|(Win)', 'linux'=>'(linux)|(X11)', 'mac'=>'(Mac_PowerPC)|(Macintosh)|(Mac)');
         $this->os = 'other';
          foreach($os_arr as $os=>$ospattern) {
               if (eregi($ospattern, $_SERVER['HTTP_USER_AGENT']))
              $this->os = $os;
           }
           
         $this->lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
      }
   }

   $browserinfo = new rbc_BrowserInfo();
   $browserinfo -> getBrowserInfo();
   
   // or
   if ($browserinfo->mobile==1) {
      header("Location: http://m.frick-solutions.ch"); /* Browser umleiten */
      exit;
   }
?>


Full Error:
Deprecated notice: Function eregi() is deprecated in /home/httpd/vhosts/frick-solutions.ch/httpdocs/templates/mobile_device_detect.php on line 28

I tried to replace the eregi with "preg_match" but it didn't work.
On the Server is PHP 5.3

Thanks for your help!
Greets
Christian
frick
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Aug 31, 2012 1:42 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.