Loading ...
Sorry, an error occurred while loading the content.

Re: [php-objects] Request for a BitMask function/class.

Expand Messages
  • plumber
    Input: $CollectedSettingsString = 13 ; Call: getIndividualVars($CollectedSettings); Output: $SetArgumentsArray : 1 = set, 2 = unset, 4 = set, 8 = set
    Message 1 of 14 , May 13 10:30 AM
    • 0 Attachment
      Input:
      $CollectedSettingsString = "13";

      Call:
      getIndividualVars($CollectedSettings);

      Output:
      $SetArgumentsArray : 1 = set, 2 = unset, 4 = set, 8 = set


      $CollectedSettingsString = "13"; //good string :D
    • Jason C
      Probably not the most efficient way, but this seems to do what you asked... $input = 13; $str = strrev( (string)decbin( $input ) ); for( $i = 0; $i
      Message 2 of 14 , May 14 10:12 AM
      • 0 Attachment
        Probably not the most efficient way, but this seems to do what you
        asked...

        $input = 13;

        $str = strrev( (string)decbin( $input ) );

        for( $i = 0; $i < strlen( $str ); $i++ )
        {
        $var = pow( 2, $i );
        $output[$var] = ( $str[$i] == 1 ) ? 'set' : 'unset';
        }

        print_r( $output );

        Produces:
        Array
        (
        [1] => set
        [2] => unset
        [4] => set
        [8] => set
        )

        Jason.

        On Tue, 2003-05-13 at 10:11, sfpk wrote:
        > I am looking for a function that can handle a variable
        > and extract (via a bitmask, as an array) the seperate
        > flags (and put them in an array, or each in their own
        > variable). Something like:
        >
        > Input:
        > $CollectedSettingsString = "13";
        >
        > Call:
        > getIndividualVars($CollectedSettings);
        >
        > Output:
        > $SetArgumentsArray : 1 = set, 2 = unset, 4 = set, 8 = set
        >
        >
        >
        >
        > Look here for Free PHP Classes of objects:
        > http://phpclasses.UpperDesign.com/
        > To unsubscribe from this group, send an email to:
        > php-objects-unsubscribe@egroups.com
        >
        >
        >
        > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        --
        Jason C <jasonconrads@...>
      • Jeff Bennett
        another solution $input = 13; $bits = 4; for ($i=0; $i
        Message 3 of 14 , May 14 11:31 AM
        • 0 Attachment
          another solution

          $input = 13;
          $bits = 4;

          for ($i=0; $i<$bits; $i++)
          echo pow(2,$i) . ' - ' . ((pow(2,$i) & $input) ? 'set' : 'unset') .
          '<BR>';

          -Jeff Bennett

          ----- Original Message -----
          From: "Jason C" <jasonconrads@...>
          To: <php-objects@yahoogroups.com>
          Sent: Wednesday, May 14, 2003 10:12 AM
          Subject: Re: [php-objects] Request for a BitMask function/class.


          > Probably not the most efficient way, but this seems to do what you
          > asked...
          >
          > $input = 13;
          >
          > $str = strrev( (string)decbin( $input ) );
          >
          > for( $i = 0; $i < strlen( $str ); $i++ )
          > {
          > $var = pow( 2, $i );
          > $output[$var] = ( $str[$i] == 1 ) ? 'set' : 'unset';
          > }
          >
          > print_r( $output );
          >
          > Produces:
          > Array
          > (
          > [1] => set
          > [2] => unset
          > [4] => set
          > [8] => set
          > )
          >
          > Jason.
          >
          > On Tue, 2003-05-13 at 10:11, sfpk wrote:
          > > I am looking for a function that can handle a variable
          > > and extract (via a bitmask, as an array) the seperate
          > > flags (and put them in an array, or each in their own
          > > variable). Something like:
          > >
          > > Input:
          > > $CollectedSettingsString = "13";
          > >
          > > Call:
          > > getIndividualVars($CollectedSettings);
          > >
          > > Output:
          > > $SetArgumentsArray : 1 = set, 2 = unset, 4 = set, 8 = set
          > >
          > >
          > >
          > >
          > > Look here for Free PHP Classes of objects:
          > > http://phpclasses.UpperDesign.com/
          > > To unsubscribe from this group, send an email to:
          > > php-objects-unsubscribe@egroups.com
          > >
          > >
          > >
          > > Your use of Yahoo! Groups is subject to
          http://docs.yahoo.com/info/terms/
          > --
          > Jason C <jasonconrads@...>
          >
          >
          >
          >
          > Look here for Free PHP Classes of objects:
          > http://phpclasses.UpperDesign.com/
          > To unsubscribe from this group, send an email to:
          > php-objects-unsubscribe@egroups.com
          >
          >
          >
          > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          >
          >
        • plumber
          while bits ?
          Message 4 of 14 , May 14 11:45 AM
          • 0 Attachment
            while bits ?
          • Pallieter Koopmans
            Thanks to those who submitted a possible solution. To give back something, I have made a speedtest of the various implementations.
            Message 5 of 14 , May 14 1:54 PM
            • 0 Attachment
              Thanks to those who submitted a possible solution. To give back
              something, I have made a speedtest of the various implementations.

              http://www.OnePay.nl/Scripts/getBits_SpeedTest/

              Note that getBits.php contains the results at my local machine (with
              various bits, to be honest to the script, as a random 300 can generate
              up to 8 bits).

              Greatz, PK.
            • Derek Scruggs
              Hi All, I m looking for a class to help me log data about user agents and search engine spiders. I came across PHPClientSniffer
              Message 6 of 14 , Dec 4, 2003
              • 0 Attachment
                Hi All,

                I'm looking for a class to help me log data about user agents and search
                engine spiders. I came across PHPClientSniffer
                (http://www.phpclasses.org/browse.html/package/81.html), which looks good
                for things like detecting Javascript support. I'll probably incorporate some
                of this, but my primary concern at the moment is detecting wheter a user
                agent is probably a spider.

                There are dozens of known spiders. Ideally the class works against a csv or,
                even better, an XML file of known spiders that I can update as new ones
                become known. In a perfect world, someone (me?) hosts this XML file on a
                public web server so users of this class can refresh it once a week or so.

                On a related note, I'm looking for a class that parses the referer string
                for common search engines. For example, Google referer strings usually look
                something like this (in English):

                http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=some+search+term

                It would be awesome if there were a class that allowed me to do something
                like this:

                $referer=&new Referer($_SERVER['HTTP_REFERER']);

                If($referer->is_search_engine()) {
                //return array of search words
                $searchPhrase=($referer->get_searchTerms());

                //return language of search engine
                $lang=$refer->get_language();
                }

                And on the spider side:

                $spider=&new Spider($_SERVER['HTTP_USER_AGENT']);
                If($spider->is_known_spider()) {
                //return common name of spider (e.g. "Google" or "Yahoo")
                $name=$spider->get_commonName();
                //return whether this spider is known to be a spambot
                $evil=$spider->is_spambot();

                }

                I'd write this myself, but the need isn't critical at this point. A "nice to
                have" instead of a "nead to have."

                Thanks!

                -Derek
              • Michael Rudel
                Hi Derek, have a look: http://fantomaster.com/fasvsspy01.html Perhaps it fits your needs. Greetinx, Mike __________________________________________ Suchtreffer
                Message 7 of 14 , Dec 5, 2003
                • 0 Attachment
                  Hi Derek,

                  have a look:

                  http://fantomaster.com/fasvsspy01.html

                  Perhaps it fits your needs.

                  Greetinx,
                  Mike

                  __________________________________________

                  Suchtreffer AG
                  Bleicherstr. 20
                  D-78467 Konstanz
                  Germany

                  fon: +49-(0)7133-205551
                  fax: +49-(0)7531-89207-13

                  e-mail: mru@...
                  internet: http://www.suchtreffer.de/
                  __________________________________________

                  ----- Original Message -----
                  From: "Derek Scruggs" <derek@...>
                  To: <php-objects@yahoogroups.com>
                  Sent: Friday, December 05, 2003 6:25 AM
                  Subject: [php-objects] User-agent/search engine spider class


                  > Hi All,
                  >
                  > I'm looking for a class to help me log data about user agents and search
                  > engine spiders. I came across PHPClientSniffer
                  > (http://www.phpclasses.org/browse.html/package/81.html), which looks good
                  > for things like detecting Javascript support. I'll probably incorporate some
                  > of this, but my primary concern at the moment is detecting wheter a user
                  > agent is probably a spider.
                  >
                  > There are dozens of known spiders. Ideally the class works against a csv or,
                  > even better, an XML file of known spiders that I can update as new ones
                  > become known. In a perfect world, someone (me?) hosts this XML file on a
                  > public web server so users of this class can refresh it once a week or so.
                  >
                  > On a related note, I'm looking for a class that parses the referer string
                  > for common search engines. For example, Google referer strings usually look
                  > something like this (in English):
                  >
                  > http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=some+search+term
                  >
                  > It would be awesome if there were a class that allowed me to do something
                  > like this:
                  >
                  > $referer=&new Referer($_SERVER['HTTP_REFERER']);
                  >
                  > If($referer->is_search_engine()) {
                  > //return array of search words
                  > $searchPhrase=($referer->get_searchTerms());
                  >
                  > //return language of search engine
                  > $lang=$refer->get_language();
                  > }
                  >
                  > And on the spider side:
                  >
                  > $spider=&new Spider($_SERVER['HTTP_USER_AGENT']);
                  > If($spider->is_known_spider()) {
                  > //return common name of spider (e.g. "Google" or "Yahoo")
                  > $name=$spider->get_commonName();
                  > //return whether this spider is known to be a spambot
                  > $evil=$spider->is_spambot();
                  >
                  > }
                  >
                  > I'd write this myself, but the need isn't critical at this point. A "nice to
                  > have" instead of a "nead to have."
                  >
                  > Thanks!
                  >
                  > -Derek
                  >
                  >
                  >
                  > Look here for Free PHP Classes of objects:
                  > http://phpclasses.UpperDesign.com/
                  > To unsubscribe from this group, send an email to:
                  > php-objects-unsubscribe@egroups.com
                  >
                  >
                  >
                  > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
                  >
                  >
                • Manuel Lemos
                  Hello, ... I have this partly implemented in a class of the PHP Classes site code itself. Once I have more time I will isolate the relevant parts to make it
                  Message 8 of 14 , Dec 17, 2003
                  • 0 Attachment
                    Hello,

                    On 12/05/2003 03:25 AM, Derek Scruggs wrote:
                    > I'm looking for a class to help me log data about user agents and search
                    > engine spiders. I came across PHPClientSniffer
                    > (http://www.phpclasses.org/browse.html/package/81.html), which looks good
                    > for things like detecting Javascript support. I'll probably incorporate some
                    > of this, but my primary concern at the moment is detecting wheter a user
                    > agent is probably a spider.
                    >
                    > There are dozens of known spiders. Ideally the class works against a csv or,
                    > even better, an XML file of known spiders that I can update as new ones
                    > become known. In a perfect world, someone (me?) hosts this XML file on a
                    > public web server so users of this class can refresh it once a week or so.
                    >
                    > On a related note, I'm looking for a class that parses the referer string
                    > for common search engines. For example, Google referer strings usually look
                    > something like this (in English):
                    >
                    > http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=some+search+term
                    >
                    > It would be awesome if there were a class that allowed me to do something
                    > like this:
                    >
                    > $referer=&new Referer($_SERVER['HTTP_REFERER']);
                    >
                    > If($referer->is_search_engine()) {
                    > //return array of search words
                    > $searchPhrase=($referer->get_searchTerms());
                    >
                    > //return language of search engine
                    > $lang=$refer->get_language();
                    > }
                    >
                    > And on the spider side:
                    >
                    > $spider=&new Spider($_SERVER['HTTP_USER_AGENT']);
                    > If($spider->is_known_spider()) {
                    > //return common name of spider (e.g. "Google" or "Yahoo")
                    > $name=$spider->get_commonName();
                    > //return whether this spider is known to be a spambot
                    > $evil=$spider->is_spambot();
                    >
                    > }
                    >
                    > I'd write this myself, but the need isn't critical at this point. A "nice to
                    > have" instead of a "nead to have."

                    I have this partly implemented in a class of the PHP Classes site code
                    itself. Once I have more time I will isolate the relevant parts to make
                    it useful to others.


                    --

                    Regards,
                    Manuel Lemos

                    Free ready to use OOP components written in PHP
                    http://www.phpclasses.org/
                  • Derek Scruggs
                    ... That would be great. I hacked something together that uses get_browser(), but the SE regexes I wrote are limited in number and thoroughness. Right now I
                    Message 9 of 14 , Dec 17, 2003
                    • 0 Attachment
                      > I have this partly implemented in a class of the PHP Classes
                      > site code
                      > itself.

                      That would be great. I hacked something together that uses get_browser(),
                      but the SE regexes I wrote are limited in number and thoroughness. Right now
                      I can tell if the referrer is Google, Yahoo and a handful of others, and I
                      can pull out their search terms, but a more comprehensive list would be
                      useful (and ideal for a web service).

                      -Derek
                    • Radi Shourbaji
                      Interesting, I have recently finished some code that uses the signatures (some regex, some not) of the SE referrer strings to extract the engine s identity &
                      Message 10 of 14 , Dec 17, 2003
                      • 0 Attachment
                        Interesting, I have recently finished some code that uses the "signatures"
                        (some regex, some not) of the SE referrer strings to extract the engine's
                        identity & the keywords. Building on bits and pieces I collected from around
                        the web, it has the ability to identify about 150 different engines. It
                        wouldn't take much to package it as a web service but is there sufficient
                        interest?

                        Radi Shourbaji
                        http://radi-shourbaji@...

                        -----Original Message-----
                        From: Derek Scruggs [mailto:derek@...]
                        Sent: Wednesday, December 17, 2003 8:37 AM
                        To: php-objects@yahoogroups.com
                        Subject: RE: [php-objects] User-agent/search engine spider class




                        > I have this partly implemented in a class of the PHP Classes
                        > site code
                        > itself.

                        That would be great. I hacked something together that uses get_browser(),
                        but the SE regexes I wrote are limited in number and thoroughness. Right now
                        I can tell if the referrer is Google, Yahoo and a handful of others, and I
                        can pull out their search terms, but a more comprehensive list would be
                        useful (and ideal for a web service).

                        -Derek



                        Look here for Free PHP Classes of objects:
                        http://phpclasses.UpperDesign.com/
                        To unsubscribe from this group, send an email to:
                        php-objects-unsubscribe@egroups.com





                        _____

                        Yahoo! Groups Links


                        * To visit your group on the web, go to:
                        http://groups.yahoo.com/group/php-objects/


                        * To unsubscribe from this group, send an email to:
                        php-objects-unsubscribe@yahoogroups.com
                        <mailto:php-objects-unsubscribe@yahoogroups.com?subject=Unsubscribe>


                        * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
                        <http://docs.yahoo.com/info/terms/> .




                        [Non-text portions of this message have been removed]
                      • plumber
                        we don t care i ve wrote this 3 years ago stop to make your add function is_HTTPBot(){ for($i=0;$i
                        Message 11 of 14 , Dec 17, 2003
                        • 0 Attachment
                          we don't care i ve wrote this 3 years ago

                          stop to make your add

                          function is_HTTPBot(){

                          for($i=0;$i<func_num_args();$i++){
                          $arg[]=@func_get_arg($i);
                          }
                          $Bots=array(
                          '/AmfibiBOT/ie',
                          '/LinkChecker/ie',
                          '/A-Online/ie',
                          '/Aladin/ie',
                          '/AnnoMille spider/ie',
                          '/AnzwersCrawl/ie',
                          '/antibot/ie',
                          '/Atomz/ie',
                          '/augurfind/ie',
                          '/AVSearch/ie',
                          '/BanBots/ie',
                          '/bdcindexer/ie',
                          '/Digger/ie',
                          '/DigOut4U/ie',
                          '/DittoSpyder/ie',
                          '/dloader(NaverRobot)/ie',
                          '/DoCoMo/ie',
                          '/dCSbot/ie',
                          '/DeepIndex/ie',
                          '/Demo Bot/ie',
                          '/BDFetch/ie',
                          '/BDNcentral/ie',
                          '/BlitzBOT/ie',
                          '/BlogBot/ie',
                          '/boitho.com-robot/ie',
                          '/BullsEye/ie',
                          '/bumblebee@.../ie',
                          '/BunnySlippers/ie',
                          '/Carnegie_Mellon_University_WebCrawler/ie',
                          '/Carnegie_Mellon_University_Research_WebBOT/ie',
                          '/Ceramic/ie',
                          '/Claymont.com/ie',
                          '/CJ Spider/ie',
                          '/appie/ie',
                          '/Aport/ie',
                          '/Arachnoidea/ie',
                          '/ArchitextSpider/ie',
                          '/ask.24x.info/ie',
                          '/asterias/ie',
                          '/AltaVista/ie',
                          '/Allesklar/ie',
                          '/AlkalineBOT/ie',
                          '/AESOP/ie',
                          '/Acoon/ie',
                          '/AcoiRobot/ie',
                          '/AbachoBOT/ie',
                          '/Custom Spider/ie',
                          '/CurryGuide SiteScan/ie',
                          '/cosmos/ie',
                          '/Crawler/ie',
                          '/Gulliver/ie',
                          '/teomaagent/ie',
                          '/Robozilla/ie',
                          '/moget\/2.0 (moget@...)/ie',
                          '/crawler@.../ie',
                          '/ArchitextSpider Gulliver\/1.3/ie',
                          '/InfoNaviRobot/ie',
                          '/msnbot/ie',
                          '/Zao/ie',
                          '/googlebot/ie',
                          '/Test/ie',
                          '/ia_archiver/ie',
                          '/Pompos/ie',
                          '/FAST-WebCrawler/ie',
                          '/Mercator/ie',
                          '/Slurp/ie',
                          '/Openfind/ie',
                          '/Scooter/ie',
                          '/SlySearch\/1.2/ie',
                          '/ASPseek\/1/ie',
                          '/almaden.ibm.com\/cs\/crawler/ie',
                          '/Mozilla\/2.0 (compatible; Ask Jeeves)/ie',
                          '/TurnitinBot/ie',
                          '/VoilaBot/ie',
                          '/DeepIndex/ie',
                          '/exabot/ie',
                          '/MicrosoftPrototypeCrawler/ie',
                          '/Surfnomore Spider/ie',
                          '/WISEnutbot/ie',
                          '/ZyBorg/ie'
                          );

                          for($i=0;$i<count($Bots);$i++){
                          if(preg_match($Bots[$i],$arg[0])){
                          return true;
                          }
                          }

                          return false;
                          }
                        • Derek Scruggs
                          ... This code doesn t include a spider (Baidu spider) that s been hitting my server rather frequently over the last few months. Also, this code does not
                          Message 12 of 14 , Dec 18, 2003
                          • 0 Attachment
                            > we don't care i ve wrote this 3 years ago

                            This code doesn't include a spider (Baidu spider) that's been hitting my
                            server rather frequently over the last few months.

                            Also, this code does not extract search terms. It only identifies whether
                            the user agent is a spider.

                            > It wouldn't take much to package it as a web service but is
                            > there sufficient interest?

                            Since the list of spiders grows every day, a web service or some other
                            mechanism for updating the list automatically would be ideal. The search
                            string regex for all known searh engines would be very useful too.

                            -Derek
                          • Manuel Lemos
                            Hello, ... I think a Web service (an HTTP based request to a remote server) would probably be too slow. I think that even a local database query could be
                            Message 13 of 14 , Dec 23, 2003
                            • 0 Attachment
                              Hello,

                              On 12/17/2003 02:37 PM, Derek Scruggs wrote:
                              >>I have this partly implemented in a class of the PHP Classes
                              >>site code
                              >>itself.
                              >
                              > That would be great. I hacked something together that uses get_browser(),
                              > but the SE regexes I wrote are limited in number and thoroughness. Right now
                              > I can tell if the referrer is Google, Yahoo and a handful of others, and I
                              > can pull out their search terms, but a more comprehensive list would be
                              > useful (and ideal for a web service).

                              I think a Web service (an HTTP based request to a remote server) would
                              probably be too slow. I think that even a local database query could be
                              faster.

                              --

                              Regards,
                              Manuel Lemos

                              Free ready to use OOP components written in PHP
                              http://www.phpclasses.org/
                            Your message has been successfully submitted and would be delivered to recipients shortly.