source: extensions/Statistics/main.inc.php @ 3438

Last change on this file since 3438 was 3438, checked in by sakkhho, 15 years ago

added

File size: 1.8 KB
Line 
1<?php
2/*
3Plugin Name: Statistics
4Version: 2.0.b
5Description: Add source code like Google Analytics on each page.
6Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
7Author: Ruben & Sakkhho
8Author URI: http://piwigo.org
9*/
10if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
11define('STAT_DIR' , basename(dirname(__FILE__)));
12
13define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');
14
15function statistics_admin_menu($menu)
16
17{
18
19    array_push($menu, array('NAME' => 'Statistics',
20
21      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
22
23    return $menu;
24
25}
26
27
28
29function stat_candoit($type)
30
31{
32
33  global $conf, $user;
34
35
36
37  $conf_statistics = explode("," , $conf['statistics']);
38
39
40
41  $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);
42
43
44
45  if
46
47  (
48
49    (
50
51      (($conf_statistics[0] == 'on') and ($type == 'header')) or 
52
53      (($conf_statistics[1] == 'on') and ($type == 'tail'))
54
55    ) and 
56
57    (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
58
59    (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
60
61  )
62
63  {
64
65    return '
66
67<!-- Plugin Statitics -->
68
69'.$conf_statistics[2].'
70
71<!-- Plugin Statitics -->';
72
73  }
74
75  else
76
77  {
78
79    return false;
80
81  }
82
83}
84function stat_tail()
85{
86
87  global $template;
88  if ($code_stat = stat_candoit('tail'))
89
90  {
91
92    $template->append('footer_elements', $code_stat);
93
94  }
95
96}
97
98
99
100function stat_header()
101
102{
103
104  global $template;
105
106
107
108  if ($code_stat = stat_candoit('header'))
109
110  {
111
112    $template->append('head_elements', $code_stat);
113
114  }
115
116}
117add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
118add_event_handler('loc_end_page_tail', 'stat_tail');
119add_event_handler('loc_end_page_header', 'stat_header');
120
121?>
Note: See TracBrowser for help on using the repository browser.