]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
only counting human viewers now
authorCash Costello <cash.costello@gmail.com>
Mon, 5 Oct 2009 23:45:29 +0000 (23:45 +0000)
committerCash Costello <cash.costello@gmail.com>
Mon, 5 Oct 2009 23:45:29 +0000 (23:45 +0000)
lib/image.php
lib/tidypics.php

index f782f0386b34bffdec239114c9730937c1cd5e36..34b0548983ca07b3e5bb2987e6cf8480d6661d8e 100644 (file)
                 */
                public function addView($viewer_guid)
                {
-                       if ($viewer_guid != $this->owner_guid)
+                       if ($viewer_guid != $this->owner_guid && tp_is_person())
                                create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC);
                }
        }
index 6bed421ed504da95ea59a4453be5b4f1c25e1405..38afc27f2b061afd113aaf126636e6f2eb4da8bb 100644 (file)
@@ -56,7 +56,7 @@
        \r
        /*********************************************************************\r
         * the functions below replace broken core functions or add functions \r
-        * that should exist in the core\r
+        * that could/should exist in the core\r
         */\r
         \r
        /**\r
                \r
        }\r
        \r
+       /**\r
+        * Is page owner a group - convenience function\r
+        * \r
+        * @return true/false\r
+        */\r
        function tp_is_group_page() {\r
                \r
                if ($group = page_owner_entity()) {\r
                return false;\r
        }\r
        \r
+       \r
+       /**\r
+        * Is the request from a known browser\r
+        * \r
+        * @return true/false\r
+        */\r
+       function tp_is_person()\r
+       {\r
+               $known = array('msie', 'mozilla', 'firefox', 'safari', 'webkit', 'opera', 'netscape', 'konqueror', 'gecko');\r
+               \r
+               $agent = strtolower($_SERVER['HTTP_USER_AGENT']);\r
+               \r
+               foreach ($known as $browser)\r
+               {\r
+                       if (strpos($agent, $browser) !== false) {\r
+                               return true;\r
+                       }\r
+               }\r
+               \r
+               return false;\r
+       }\r
 ?>
\ No newline at end of file