add handling for mails that have no valid recipient when we try to send them
[php-utility-classes.git] / include / classes / useragent.php-class
index e71505a73c533c8e6a5693dbade5cc7370230597..dbcad2737e6d74de9a860a577208cc155c722f07 100755 (executable)
@@ -16,7 +16,7 @@
  *
  * The Initial Developer of the Original Code is
  * KaiRo - Robert Kaiser.
- * Portions created by the Initial Developer are Copyright (C) 2003
+ * Portions created by the Initial Developer are Copyright (C) 2003-2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s): Robert Kaiser <kairo@kairo.at>
@@ -97,6 +97,9 @@ class userAgent {
   // 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()
@@ -746,7 +749,7 @@ class userAgent {
     if (!isset($this->uadata['engine'])) {
       $this->uadata['engine'] = 'unknown';
       $this->uadata['geckodate'] = null;
-      if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) {
+      if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs) && (strpos($this->brand, 'Opera') === false)) {
         $this->uadata['engine'] = 'gecko';
         $this->uadata['geckodate'] = $regs[1];
       }
@@ -956,6 +959,12 @@ class userAgent {
           $this->uadata['os'] = $regs[1];
           $this->uadata['lang'] = $regs[2];
         }
+        // Opera 9 Firefox-spoofing
+        elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-Z\.+]+ Opera [^ ]+/i', $this->uastring, $regs)) {
+          $this->uadata['eng_version'] = $this->getVersion();
+          $this->uadata['os'] = $regs[1];
+          $this->uadata['lang'] = $regs[2];
+        }
       }
       elseif ($this->hasEngine('nscp')) {
         if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
@@ -1093,6 +1102,24 @@ class userAgent {
   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() {