]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 23 Jun 2014 10:17:34 +0000 (10:17 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 23 Jun 2014 10:17:34 +0000 (10:17 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.url.php

index 853b3593d4ef0862a1a4270fa2ddef85d4bda1a3..0b80db14199a5c7d7f4426795fc8c778c61155a5 100644 (file)
@@ -407,6 +407,11 @@ class commonCore extends cubeCore {
                $db->books->index('index_books_demo_counter', 'BTREE', 'demo_counter');\r
                $db->books->index('index_books_lang', 'BTREE', 'lang');\r
                $db->books->index('index_books_cid', 'BTREE', 'cid');\r
+               // Book referers\r
+               $db->books_referer->book_id('integer', 0, false);\r
+               $db->books_referer->referer('varchar', 256, false);\r
+               $db->books_referer->count('integer', 0, false);\r
+               $db->books_referer->primary('pk_books_referer', 'book_id', 'referer');\r
                // .\r
                // Table pages des publications\r
                $db->book_pages->book_id('integer', 0, false);\r
index f599bfcadc58959d73e6aba206fef9c849da6b12..dbb36658f345e1a0f56b37cf645bd968ee90cbff 100644 (file)
@@ -1157,8 +1157,10 @@ html{height:100%}' . "\n";
                        }
                }
 
+               self::logReferer($book_id);
 
                echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');
+
                exit;
        }
 
@@ -1333,9 +1335,36 @@ html{height:100%}' . "\n";
                $res .= '</body>';
                $res .= '</html>';
 
+               self::logReferer($book_id);
+
                return $res;
        }
 
+       public static function logReferer($id) {
+
+               if (!isset($_SERVER['HTTP_REFERER']) || !$_SERVER['HTTP_REFERER']) {
+                       $r = '';
+               } else {
+                       $r = $_SERVER['HTTP_REFERER'];
+               }
+
+               fb($r, $id);
+
+               global $core;
+               $rr = $core->con->select('SELECT * FROM books_referer WHERE book_id=\'' . $core->con->escape($id) . '\' AND referer=\'' . $core->con->escape($r) . '\'');
+               $c = $core->con->openCursor('books_referer');
+               if (!$rr->count()) {
+                       $c->book_id = $id;
+                       $c->referer = $r;
+                       $c->count = 1;
+                       $c->insert();
+               } else {
+                       $rr->fetch();
+                       $c->count = $rr->count + 1;
+                       $c->update('WHERE book_id=\'' . $core->con->escape($id) . '\' AND referer=\'' . $core->con->escape($r) . '\'');
+               }
+       }
+
        public static function statsxls($args) {
                $bid = (isset($args[1])) ? $args[1] : null;
                $annee = (isset($args[2])) ? $args[2] : null;