| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Statistics |
|---|
| 4 | Version: auto |
|---|
| 5 | Description: Add source code like Google Analytics on each page. |
|---|
| 6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174 |
|---|
| 7 | Author: Ruben & Sakkhho |
|---|
| 8 | Author URI: http://piwigo.org |
|---|
| 9 | */ |
|---|
| 10 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
|---|
| 11 | define('STAT_DIR' , basename(dirname(__FILE__))); |
|---|
| 12 | define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/'); |
|---|
| 13 | |
|---|
| 14 | function statistics_admin_menu($menu) |
|---|
| 15 | { |
|---|
| 16 | array_push( |
|---|
| 17 | $menu, |
|---|
| 18 | array( |
|---|
| 19 | 'NAME' => 'Statistics', |
|---|
| 20 | 'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php') |
|---|
| 21 | ) |
|---|
| 22 | ); |
|---|
| 23 | return $menu; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | function stat_candoit($type) |
|---|
| 27 | { |
|---|
| 28 | global $conf, $user; |
|---|
| 29 | |
|---|
| 30 | $conf_statistics = unserialize($conf['statistics']); |
|---|
| 31 | |
|---|
| 32 | if (is_admin() and $conf_statistics['exclude_admin']) |
|---|
| 33 | { |
|---|
| 34 | return false; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | if (is_a_guest() and $conf_statistics['exclude_guest']) |
|---|
| 38 | { |
|---|
| 39 | return false; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | $show_htmlcontent = false; |
|---|
| 44 | if ($conf_statistics['header'] and $type == 'header') |
|---|
| 45 | { |
|---|
| 46 | $show_htmlcontent = true; |
|---|
| 47 | } |
|---|
| 48 | if ($conf_statistics['tail'] and $type == 'tail') |
|---|
| 49 | { |
|---|
| 50 | $show_htmlcontent = true; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | if (!$show_htmlcontent) |
|---|
| 54 | { |
|---|
| 55 | return false; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | return ' |
|---|
| 59 | <!-- Plugin Statistics --> |
|---|
| 60 | '.$conf_statistics['content'].' |
|---|
| 61 | <!-- Plugin Statistics --> |
|---|
| 62 | '; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | function stat_tail() |
|---|
| 66 | { |
|---|
| 67 | global $template; |
|---|
| 68 | |
|---|
| 69 | if ($code_stat = stat_candoit('tail')) |
|---|
| 70 | { |
|---|
| 71 | $template->append('footer_elements', $code_stat); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | function stat_header() |
|---|
| 76 | { |
|---|
| 77 | global $template; |
|---|
| 78 | |
|---|
| 79 | if ($code_stat = stat_candoit('header')) |
|---|
| 80 | { |
|---|
| 81 | $template->append('head_elements', $code_stat); |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu'); |
|---|
| 86 | add_event_handler('loc_end_page_tail', 'stat_tail'); |
|---|
| 87 | add_event_handler('loc_end_page_header', 'stat_header'); |
|---|
| 88 | ?> |
|---|