Don P: Bekloppte User Agents zuordnen (RegExp)

Beitrag lesen

Hallo Patrick,

Grund sind folgende UA-Strings (nach den besuchten Seiten zu urteilen, handelt es sich um Spammer):

Typ 1: Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1)
Typ 2: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 7.0; Win32; 1&1); .NET CLR 2.0.50727; IEMB3; IEMB3)
Typ 3: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 1.1.4322)
Typ 4: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com)
Typ 5: User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)

Wie man sieht, steht immer eine Klammer "(" vor "compatible".

Ich möchte nun diese beknackten UAs immer der im UA-String zuerst vorkommenden Browserversion zuordnen, beim oben genannten Typ 1 soll ein MSIE 6 gezählt werden, bei Typ 3 ein MSIE 7.

Die zuerst vorkommende Browserversion steht immer direkt nach der ersten Klammer "(".

Also muss man eigentlich nur sicherstellen, dass immer die erste Klammer im RegExp matcht, gefolgt von dem, was man sonst noch matchen will.

Also:
             $allIE++ if (/[^(]+?(compatible; MSIE / && !/Opera/);
             $anzahlIE3++ if (/[^(]+?(compatible; MSIE 3/ && !/Opera/);
             $anzahlIE4++ if (/[^(]+?(compatible; MSIE 4/ && !/Opera/);
             $anzahlIE5++ if (/[^(]+?(compatible; MSIE 5/ && !/Opera/);
             $anzahlIE6++ if (/[^(]+?(compatible; MSIE 6/ && !/Opera/);
             $anzahlIE7++ if (/[^(]+?(compatible; MSIE 7/ && !/Opera/);

Das sollte m.E. den Anforderungen genügen.

Gruß, Don P

0 79

Bekloppte User Agents zuordnen (RegExp)

Patrick Andrieu
  • programmiertechnik
  1. 0
    Cheatah
    1. 2

      UA-Statistiken fälschen

      Siechfred
      • perl
      1. 0
        Patrick Andrieu
        1. 1
          Siechfred
          1. 0

            Die erfolgreiche Fälschung

            Patrick Andrieu
            1. 1

              Das Modul zur erfolgreichen Fälschung?

              Siechfred
              1. 0
                Patrick Andrieu
                1. 0
                  Siechfred
              2. 0
                Siechfred
              3. 0
                Patrick Andrieu
                1. 0
                  Siechfred
                  1. 0
                    Patrick Andrieu
                    1. 0
                      Siechfred
                      1. 0
                        Patrick Andrieu
                        1. 0
                          Siechfred
                          1. 0
                            Patrick Andrieu
                            1. 0
                              Siechfred
                              1. 0
                                Patrick Andrieu
                                1. 0
                                  Patrick Andrieu
                                  1. 0
                                    Siechfred
                                    1. 0
                                      Patrick Andrieu
                                      1. 0
                                        Siechfred
                                        1. 0
                                          Patrick Andrieu
                                          1. 0
                                            Patrick Andrieu
                                          2. 0
                                            Siechfred
                                2. 0
                                  Siechfred
            2. 0

              Die erfolgreichen Statmaker- und -fälscher-Skripts für 1&1-User!

              Patrick Andrieu
              1. 0
                Patrick Andrieu
                1. 0
                  Struppi
                  1. 0
                    Patrick Andrieu
    2. 0
      Patrick Andrieu
      1. 0
        Cheatah
        1. 0
          Patrick Andrieu
  2. 0
    Don P
    1. 0
      Don P
    2. 0
      Patrick Andrieu
      1. 0
        Don P
        1. 0
          Patrick Andrieu
          1. 0
            Don P
            1. 0
              Patrick Andrieu
      2. 0

        Logline splitter (RegExp)

        Patrick Andrieu
  3. 2
    Struppi
    1. 0
      Patrick Andrieu
      1. 0
        Patrick Andrieu
  4. 0
    Der Martin
    1. 0
      Alexander (HH)
    2. 0
      Patrick Andrieu
      1. 0
        Der Martin
        1. 0
          Cheatah
          1. 0
            Patrick Andrieu
            1. 0
              Cheatah
        2. 0
          Patrick Andrieu
          1. 0
            Der Martin
            1. 0

              RegExp'sch ist gar nicht so schwer :)

              Siechfred
              • menschelei
    3. 0
      Patrick Andrieu
      1. 0
        Der Martin
        1. 0
          Patrick Andrieu
          1. 0
            Patrick Andrieu
            1. 0
              Struppi
      2. 0
        Ingo Turski
        1. 0
          Patrick Andrieu
          1. 0
            Ingo Turski
            1. 0
              Patrick Andrieu
              1. 0
                Ingo Turski
                1. 0
                  Patrick Andrieu
                  1. 0
                    Engin
                  2. 0
                    Engin
                    1. 0
                      Patrick Andrieu
                      1. 0
                        Engin
                        1. 0
                          Patrick Andrieu
                          1. 0
                            Engin
                            1. 0
                              Patrick Andrieu
                              1. 0
                                Engin
                                1. 0
                                  Patrick Andrieu
                                  1. 0
                                    Engin
                  3. 0
                    Ingo Turski
                    1. 0
                      Patrick Andrieu
        2. 0
          Patrick Andrieu