deal with Gecko identifiers that include the build hour and add parsing of Gecko...
authorRobert Kaiser <kairo@kairo.at>
Mon, 1 Oct 2007 15:53:46 +0000 (17:53 +0200)
committerRobert Kaiser <kairo@kairo.at>
Mon, 1 Oct 2007 15:53:46 +0000 (17:53 +0200)
include/classes/useragent.php-class
testbed/ua_test.php

index eba3ed2a308a5c1a3329dce344edf70b18cb962e..dbcad2737e6d74de9a860a577208cc155c722f07 100755 (executable)
@@ -97,6 +97,9 @@ class userAgent {
   // public function getGeckoDate()
   //   returns the Gecko date for Gecko-based browsers, null for others
   //
   // public function getGeckoDate()
   //   returns the Gecko date for Gecko-based browsers, null for others
   //
+  // public function getGeckoTime()
+  //   returns the Gecko build date/time as a unix epoch time number for Gecko-based browsers, null for others
+  //
   // *** functions for compat to older versions of this class ***
   //
   // public function isns()
   // *** functions for compat to older versions of this class ***
   //
   // public function isns()
@@ -1099,6 +1102,24 @@ class userAgent {
   return $this->uadata['geckodate'];
   }
 
   return $this->uadata['geckodate'];
   }
 
+  public function getGeckoTime() {
+    if (!isset($this->uadata['geckotime'])) {
+      $this->uadata['geckotime'] = null;
+      if (!is_null($this->getGeckoDate())) {
+        $use_time = (strlen($this->getGeckoDate()) > 8);
+        $gd_str = substr($this->getGeckoDate(),0,4).'-'.substr($this->getGeckoDate(),4,2).'-'.substr($this->getGeckoDate(),6,2);
+        if ($use_time) {
+          $gd_str .= substr($this->getGeckoDate(),8,2).':00';
+          $old_tz = date_default_timezone_get();
+          date_default_timezone_set("America/Los_Angeles");
+        }
+        $this->uadata['geckotime'] = strtotime($gd_str);
+        if ($use_time) { date_default_timezone_set($old_tz); }
+      }
+    }
+  return $this->uadata['geckotime'];
+  }
+
   public function isBot() { return $this->bot; }
 
   public function isns() {
   public function isBot() { return $this->bot; }
 
   public function isns() {
index 30b485a3d57fe98fcb5a164fb2e237fab9bf4816..4bcbd052528be05276d1a0b3f1202608f591161d 100644 (file)
@@ -25,7 +25,10 @@ print("<br>The engine version is reported as &quot;<b>".$ua->getEngineVersion().
 print("<br>The operating system is reported as &quot;<b>".$ua->getOS()."</b>&quot;\n");
 print("<br>The system platform is reported as &quot;<b>".$ua->getPlatform()."</b>&quot;\n");
 print("<br>The browser language is reported as &quot;<b>".$ua->getLanguage()."</b>&quot;\n");
 print("<br>The operating system is reported as &quot;<b>".$ua->getOS()."</b>&quot;\n");
 print("<br>The system platform is reported as &quot;<b>".$ua->getPlatform()."</b>&quot;\n");
 print("<br>The browser language is reported as &quot;<b>".$ua->getLanguage()."</b>&quot;\n");
-if ($ua->hasEngine('gecko')) { print("<br>The Gecko date is reported as &quot;<b>".$ua->getGeckoDate()."</b>&quot;\n"); }
+if ($ua->hasEngine('gecko')) {
+  print("<br>The Gecko date is reported as &quot;<b>".$ua->getGeckoDate()."</b>&quot;\n");
+  print("<br>The full Gecko date/time is reported as &quot;<b>".date('r',$ua->getGeckoTime())."</b>&quot;\n");
+}
 print("<br><br>I conclude this must be <b>".$ua->getBrand()." ".$ua->getVersion()."</b>\n");
 print("<br>This is <b>".($ua->isBot()?"an":"no")."</b> automated robot.\n");
 
 print("<br><br>I conclude this must be <b>".$ua->getBrand()." ".$ua->getVersion()."</b>\n");
 print("<br>This is <b>".($ua->isBot()?"an":"no")."</b> automated robot.\n");