source: extensions/EStat/estat_pip.class.inc.php @ 27153

Last change on this file since 27153 was 17862, checked in by grum, 12 years ago

version 0.1.0b
. fix bug on thumb view
. fix SQLite compression managment & 'compress.method' config
. manage number of items per page by config

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : EStat
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  EStat_PIP : classe to manage plugin public pages
13
14  --------------------------------------------------------------------------- */
15
16include_once('estat_root.class.inc.php');
17include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCUserAgent.class.inc.php');
18include_once(ESTAT_LIB.'statDB.class.inc.php');
19
20class EStat_PIP extends EStat_root
21{
22  public function __construct($prefixeTable, $filelocation)
23  {
24    parent::__construct($prefixeTable, $filelocation);
25    $this->loadConfig();
26    $this->initEvents();
27  }
28
29  public function initEvents()
30  {
31    parent::initEvents();
32    add_event_handler('pwg_log_allowed', array(&$this, 'logVisit'), 50, 3);
33  }
34
35  public function logVisit($do_log, $image_id=null, $image_type=null)
36  {
37    global $conf, $user, $page;
38
39    if($do_log)
40    {
41      $statDB=new StatDBMonth($this->fileStatDir, self::FILE_MONTH, date('Y'), date('m'));
42
43      if($statDB->open(ASDF_OPEN_WRITE))
44      {
45        $ua=GPCUserAgent::parse($_SERVER['HTTP_USER_AGENT']);
46        $statDB->addLog(
47          array(
48            'date' => time(),
49            'IPadress' => $_SERVER['REMOTE_ADDR'],
50            'userId' => $user['id'],
51            'catId'  => isset($page['category']['id'])?$page['category']['id']:0,
52            'imageId'  => ($image_id!=null)?$image_id:0,
53            'section' => isset($page['section'])?$page['section']:'',
54            'tagsId' => ('tags'==$page['section'])?implode(',', $page['tag_ids']):'',
55            'userAgent' => $_SERVER['HTTP_USER_AGENT'],
56            'uaBrowser' => $ua[UA_DATA_BROWSER],
57            'uaEngine' => $ua[UA_DATA_ENGINE],
58            'uaOS' => $ua[UA_DATA_OS],
59            'uaType' => $ua[UA_DATA_BROWSER_TYPE],
60            'uaBrowserVersion' => $ua[UA_DATA_BROWSER_VERSION],
61            'uaEngineVersion' => $ua[UA_DATA_ENGINE_VERSION],
62            'uaOSVersion' => $ua[UA_DATA_OS_VERSION],
63            'screenSizeW' => 0,
64            'screenSizeH' => 0
65          )
66        );
67        $statDB->close(true);
68      }
69
70      $this->checkBuildStatPeriod(false, ($this->config['compress.public']=='y' and $this->config['compress.method']=='gz'));
71    }
72    return($do_log);
73  }
74
75
76
77} //class
78
79?>
Note: See TracBrowser for help on using the repository browser.