From 8fdbddca3d0f4712036675d5e32d5db9a8a7931b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 5 Oct 2009 23:45:29 +0000 Subject: only counting human viewers now --- lib/image.php | 2 +- lib/tidypics.php | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/image.php b/lib/image.php index f782f0386..34b054898 100644 --- a/lib/image.php +++ b/lib/image.php @@ -138,7 +138,7 @@ */ 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); } } diff --git a/lib/tidypics.php b/lib/tidypics.php index 6bed421ed..38afc27f2 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -56,7 +56,7 @@ /********************************************************************* * the functions below replace broken core functions or add functions - * that should exist in the core + * that could/should exist in the core */ /** @@ -173,6 +173,11 @@ } + /** + * Is page owner a group - convenience function + * + * @return true/false + */ function tp_is_group_page() { if ($group = page_owner_entity()) { @@ -183,4 +188,25 @@ return false; } + + /** + * Is the request from a known browser + * + * @return true/false + */ + function tp_is_person() + { + $known = array('msie', 'mozilla', 'firefox', 'safari', 'webkit', 'opera', 'netscape', 'konqueror', 'gecko'); + + $agent = strtolower($_SERVER['HTTP_USER_AGENT']); + + foreach ($known as $browser) + { + if (strpos($agent, $browser) !== false) { + return true; + } + } + + return false; + } ?> \ No newline at end of file -- cgit v1.2.3