Changeset 7445 for extensions/Statistics/main.inc.php
- Timestamp:
- Oct 28, 2010, 12:19:44 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Statistics/main.inc.php
r3438 r7445 2 2 /* 3 3 Plugin Name: Statistics 4 Version: 2.0. b4 Version: 2.0.c 5 5 Description: Add source code like Google Analytics on each page. 6 6 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174 … … 10 10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 11 11 define('STAT_DIR' , basename(dirname(__FILE__))); 12 13 12 define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/'); 14 13 15 14 function statistics_admin_menu($menu) 16 17 15 { 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 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; 25 24 } 26 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 } 27 41 28 42 29 function 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 43 $show_htmlcontent = false; 44 if ($conf_statistics['header'] and $type == 'header') 63 45 { 64 65 return ' 66 67 <!-- Plugin Statitics --> 68 69 '.$conf_statistics[2].' 70 71 <!-- Plugin Statitics -->'; 72 46 $show_htmlcontent = true; 47 } 48 if ($conf_statistics['tail'] and $type == 'tail') 49 { 50 $show_htmlcontent = true; 73 51 } 74 52 75 else 76 53 if (!$show_htmlcontent) 77 54 { 78 79 55 return false; 80 81 56 } 82 57 58 return ' 59 <!-- Plugin Statistics --> 60 '.$conf_statistics['content'].' 61 <!-- Plugin Statistics --> 62 '; 83 63 } 64 84 65 function stat_tail() 85 66 { 67 global $template; 86 68 87 global $template;88 69 if ($code_stat = stat_candoit('tail')) 89 90 70 { 91 92 71 $template->append('footer_elements', $code_stat); 93 94 72 } 95 96 73 } 97 74 98 99 100 75 function stat_header() 101 102 76 { 103 104 77 global $template; 105 78 79 if ($code_stat = stat_candoit('header')) 80 { 81 $template->append('head_elements', $code_stat); 82 } 83 } 106 84 107 108 if ($code_stat = stat_candoit('header'))109 110 {111 112 $template->append('head_elements', $code_stat);113 114 }115 116 }117 85 add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu'); 118 86 add_event_handler('loc_end_page_tail', 'stat_tail'); 119 87 add_event_handler('loc_end_page_header', 'stat_header'); 120 121 88 ?>
Note: See TracChangeset
for help on using the changeset viewer.