please help with EREG() arguments

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    please help with EREG() arguments

    Hey guys i activated the jcow mobile view and now on a desktop site i get an error

    Code:
    Warning: eregi() [function.eregi]: REG_EMPTY in /home/*****/.../on mobile.hook.php in line 18
    And here is the source mobile.hook.php

    PHP Code:
    <?php
    /* ############################################################ *\
     ----------------------------------------------------------------
    @package    Jcow Social Networking Script.
    @copyright    Copyright (C) 2009 - 2010 jcow.net.  All Rights Reserved.
    @license    see http://jcow.net/license
     ----------------------------------------------------------------
    \* ############################################################ */
    function mobile_boot() {
        global 
    $parr;
        if (
    $parr[0] == 'home' || !$parr[0]) {
            if (!
    $mobile_ids get_text('mobile_ids')) {
                
    $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,Nokia,Samsung';
            }
            
    $ids explode(',',$mobile_ids);
            if (
    is_array($ids)) {
                foreach (
    $ids as $id) {
                if (
    eregi(trim($id),$_SERVER['HTTP_USER_AGENT'])) { //This is line 18 
                        
    redirect('mobile');
                    }
                }
            }
        }
    }
    libra.wen.ru

    #2
    This function has been deprecated and no longer available to use in any php applications. anyway, seems like the application is passing an empty variable to the eregi function. contact the script developer.

    Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
    PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
    Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.

    Comment


      #3
      ereg to preg

      Easy lol
      Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
      Visit: WapMasterz Coming Back Soon!
      _______
      SCRIPTS FOR SALE BY SUBZERO
      Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
      FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
      _______
      Info & Tips
      php.net
      w3schools.com

      Comment


        #4
        Don't use ereg, use preg
        Did I help you?
        You can help me too
        Your donations will help me finance my studies.

        Comment


          #5
          add "@" before eregi mean @eregi it may work ! And remember eregi() is not case sensitive
          PHP Code:
          /* I don't know everything hehe */ 
          Find me on facebook

          Comment


            #6
            Try:
            PHP Code:
            /* ############################################################ *\
             ----------------------------------------------------------------
            @package    Jcow Social Networking Script.
            @copyright    Copyright (C) 2009 - 2010 jcow.net.  All Rights Reserved.
            @license    see http://jcow.net/license
             ----------------------------------------------------------------
            \* ############################################################ */
            function mobile_boot() {
                global 
            $parr;
                if (
            $parr[0] == 'home' || !$parr[0]) {
                    if (!
            $mobile_ids get_text('mobile_ids')) {
                        
            $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,Nokia,Samsung';
                    }
                    
            $ids explode(',',$mobile_ids);
                    if (
            is_array($ids)) {
                        foreach (
            $ids as $id) {
                        if (
            preg_match("/$id/i",$_SERVER['HTTP_USER_AGENT'])) { //This is line 18 
                                
            redirect('mobile');
                            }
                        }
                    }
                }

            It should work but if no:
            PHP Code:
            /* ############################################################ *\
             ----------------------------------------------------------------
            @package    Jcow Social Networking Script.
            @copyright    Copyright (C) 2009 - 2010 jcow.net.  All Rights Reserved.
            @license    see http://jcow.net/license
             ----------------------------------------------------------------
            \* ############################################################ */
            function mobile_boot() {
                global 
            $parr;
                if (
            $parr[0] == 'home' || !$parr[0]) {
                    if (!
            $mobile_ids get_text('mobile_ids')) {
                        
            $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,Nokia,Samsung';
                    }
                    
            $ids explode(',',$mobile_ids);
                    if (
            is_array($ids)) {
                        foreach (
            $ids as $id) {
                        if(
            stristr($_SERVER['HTTP_USER_AGENT'], $id) === true) { //This is line 18 
                                
            redirect('mobile');
                            }
                        }
                    }
                }

            Its just from head and if doesn't work tell, gonna test it.
            Last edited by arnage; 16.05.11, 21:24.
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment


              #7
              Originally posted by Ponick View Post
              add "@" before eregi mean @eregi it may work ! And remember eregi() is not case sensitive
              Thanks ponick it worked and thanks to everyone else for helping
              libra.wen.ru

              Comment


                #8
                It doesn't work, u just killed the error with @. I mean, script now works but this function don't and same result u could achieve if just delete whole function and it call. Plus, i think the problem is in loop and not ereg because its still in the sistem even if its depreced, for now. Anyway, as u wish.
                Last edited by arnage; 17.05.11, 10:38.
                <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                Comment


                  #9
                  Originally posted by arnage View Post
                  It doesn't work, u just killed the error with @. I mean, script now works but this function don't and same result u could achieve if just delete whole function and it call. Plus, i think the problem is in loop and not ereg because its still in the sistem even if its depreced, for now. Anyway, as u wish.
                  dude, i know its not so good to ignore error using "@" but when things come to hurry people want the most short-cut way lolz
                  PHP Code:
                  /* I don't know everything hehe */ 
                  Find me on facebook

                  Comment


                    #10
                    Originally posted by Ponick View Post
                    dude, i know its not so good to ignore error using "@" but when things come to hurry people want the most short-cut way lolz
                    using @ to suppress errors suck. Find a better way to fix it without @.

                    Added after 5 minutes:

                    Originally posted by s3nzo View Post
                    Hey guys i activated the jcow mobile view and now on a desktop site i get an error

                    Code:
                    Warning: eregi() [function.eregi]: REG_EMPTY in /home/*****/.../on mobile.hook.php in line 18
                    try this mobile.hook.php

                    PHP Code:
                    <?php
                    /* ############################################################ *\
                     ----------------------------------------------------------------
                    @package    Jcow Social Networking Script.
                    @copyright    Copyright (C) 2009 - 2010 jcow.net.  All Rights Reserved.
                    @license    see http://jcow.net/license
                     ----------------------------------------------------------------
                    \* ############################################################ */
                    function mobile_boot() {
                        global 
                    $parr;
                        if (
                    $parr[0] == 'home' || !$parr[0]) {
                            if (!
                    $mobile_ids get_text('mobile_ids')) {
                                
                    $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,opera mini,Samsung';
                            }
                            
                    $ids explode(',',strtolower($mobile_ids));
                            if (
                    is_array($ids)) {
                                foreach (
                    $ids as $id) {
                                if (
                    stristr(strtolower($_SERVER['HTTP_USER_AGENT']), trim($id))) { //This is line 18 
                                        
                    redirect('mobile');
                                    }
                                }
                            }
                        }
                    }
                    Last edited by CreativityKills; 17.05.11, 12:37.

                    Comment


                      #11
                      I'd prefer to fix the error rather than to kill an entire function.
                      The @ sign is to prevent error, not fix it, and this is the same as that he deleted the entire function, as it does not exist it does not redirecting anything.
                      Lets see step by step.
                      Problem is in loop actualy, when creating an array with explode() and do loop like foreach($ids as $id), the array looks like this:
                      Code:
                      Array(
                      	$id[0] = null;
                      	$id[1] = null;
                      	$id[2] = null;
                      	$id[3] = null;
                      // and so on...
                      )
                      ... because it gets only the var, not its value, which ofcourse issued a:
                      Code:
                      Warning: eregi() [function.eregi]: REG_EMPTY in /home/*****/.../on mobile.hook.php in line 18
                      A quick fix wuld bee adding the key var in loop to read the value of that var, just to add foreach($ids as $key => $id).
                      So, the correct way allong with upgrade to preg_match (where matching pattern must be in double quotes) looks like:
                      PHP Code:
                      function mobile_boot() {
                          global 
                      $parr;
                          if (
                      $parr[0] == 'home' || !$parr[0]) {
                              if (!
                      $mobile_ids get_text('mobile_ids')) {
                                  
                      $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,Nokia,Samsung';
                              }
                              
                      $ids explode(',',$mobile_ids);
                              if (
                      is_array($ids)) {
                                  foreach(
                      $ids as $key => $id) {
                                  if (
                      preg_match("/$id/i"$_SERVER['HTTP_USER_AGENT'])) { //This is line 18 
                                          
                      redirect('mobile');
                                      }
                                  }
                              }
                          }

                      Simple as that.

                      Another a little more elegant way would be to take out explode() and create the array right there and simple loop thru it.
                      Note that user agent is actualy a user input so that im adding urlencode() to the $_SERVER var.
                      PHP Code:
                      function mobile_boot() {
                          global 
                      $parr;
                          if (
                      $parr[0] == 'home' || !$parr[0]) {
                              if (!
                      $mobile_ids get_text('mobile_ids')) {
                                  
                      $mobile_ids = array('iphone''nokia''BlackBerry''HTC''Motorola''Nokia''Samsung');
                              }
                              
                      // it is an array
                                  
                      foreach($mobile_ids as $id) {
                                  if (
                      preg_match("/$id/i"urlencode($_SERVER['HTTP_USER_AGENT']))) { //This is line 18 
                                          
                      redirect('mobile');
                                      }
                                  }
                          }

                      Last edited by arnage; 17.05.11, 19:49.
                      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                      Comment


                        #12
                        Originally posted by arnage View Post
                        the correct way allong with upgrade to preg_match (where matching pattern must be in double quotes) looks like:
                        PHP Code:
                        function mobile_boot() {
                            global 
                        $parr;
                            if (
                        $parr[0] == 'home' || !$parr[0]) {
                                if (!
                        $mobile_ids get_text('mobile_ids')) {
                                    
                        $mobile_ids 'iphone,nokia,BlackBerry,HTC,Motorola,Nokia,Samsung';
                                }
                                
                        $ids explode(',',$mobile_ids);
                                if (
                        is_array($ids)) {
                                    foreach(
                        $ids as $key => $id) {
                                    if (
                        preg_match("/$id/i"$_SERVER['HTTP_USER_AGENT'])) { //This is line 18 
                                            
                        redirect('mobile');
                                        }
                                    }
                                }
                            }

                        I'm using fedora and this code redirects me to a mobile version
                        libra.wen.ru

                        Comment


                          #13
                          Fedora is operating system, not browser so it doesn't matter.
                          Last edited by arnage; 19.05.11, 17:51. Reason: changed my mind.
                          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                          Comment

                          Working...
                          X