00001 <?php
00002
00003
00004 include 'includes/stats.inc.php';
00005
00006 function stats_install()
00007
00008 {
00009 $info['name'] = 'stats';
00010 $info['title'] = 'Statistics';
00011 $info['description'] = 'Detailed statistics and counters.';
00012 $info['has_admin'] = 1;
00013 $info['enabled'] = 1;
00014 set_module_info($info);
00015
00016 create_entry_table('stats_osHits');
00017 create_entry_table('stats_browserHits');
00018 create_entry_table('stats_config');
00019 add_field('pages', 'hits', 'BIGINT');
00020
00021 $toclean = get_entry('config', 'cleaning_tables');
00022 ListAdd('stats_osHits', $toclean);
00023 ListAdd('stats_browserHits', $toclean);
00024 ListAdd('stats_config', $toclean);
00025 set_entry('config', 'cleaning_tables', $hooks);
00026
00027 $hooks = get_entry('hooks', 'on_request');
00028 ListAdd('stats', $hooks);
00029 set_entry('hooks', 'on_request', $hooks);
00030
00031
00032
00033 $config = serialize(array(
00034 'mode' => 'total',
00035 'style' => 'text',
00036 'pretext' => 'Total hits: ',
00037 'showpre' => 'y'));
00038 set_entry('stats_config', 'tr', $config);
00039 $hooks = get_entry('hooks', 'tr_cell');
00040 ListAdd('stats', $hooks);
00041 set_entry('hooks', 'tr_cell', $hooks);
00042
00043 module_installed();
00044 }
00045
00046 function stats_uninstall($preserve_data)
00047
00048 {
00049 delete_module('stats');
00050
00051 if (!$preserve_data)
00052 {
00053 drop_table('stats_osHits');
00054 drop_table('stats_browserHits');
00055 drop_table('stats_config');
00056 drop_field('pages', 'hits');
00057 $toclean = get_entry('config', 'cleaning_tables');
00058 ListDel('stats_osHits', $toclean);
00059 ListDel('stats_browserHits', $toclean);
00060 ListDel('stats_config', $toclean);
00061 set_entry('config', 'cleaning_tables');
00062 }
00063
00064 $hooks = get_entry('hooks', 'on_request');
00065 ListDel('stats', $hooks);
00066 set_entry('hooks', 'on_request', $hooks);
00067
00068 Istats_URIH('tl');
00069 Istats_URIH('tc');
00070 Istats_URIH('tr');
00071 Istats_URIH('ml');
00072 Istats_URIH('mr');
00073 Istats_URIH('bl');
00074 Istats_URIH('bc');
00075 Istats_URIH('br');
00076 }
00077
00078 function stats_on_request()
00079
00080 {
00081 $info = get_module_info('stats');
00082 if (!$info['enabled'])
00083 return;
00084
00085
00086 $browser = 'Unknown';
00087 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Konqueror'))
00088 $browser = 'Konqueror';
00089 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Opera'))
00090 $browser = 'Opera';
00091 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Galeon'))
00092 $browser = 'Galeon';
00093 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Epiphany'))
00094 $browser = 'Epiphany';
00095 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Lynx'))
00096 $browser = 'Lynx/Links';
00097 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Links'))
00098 $browser = 'Lynx/Links';
00099 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Phoenix'))
00100 $browser = 'Firefox';
00101 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Firebird'))
00102 $browser = 'Firefox';
00103 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Firefox'))
00104 $browser = 'Firefox';
00105 if (stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
00106 {
00107 if (Istats_reallyIE())
00108 $browser = 'Internet Explorer';
00109 else
00110 $browser = 'Fake MSIE';
00111 }
00112 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Mozilla 1.'))
00113 $browser = 'Mozilla';
00114
00115
00116 $client_os = 'Unknown';
00117 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Windows') AND $browser != 'Fake MSIE')
00118 $client_os = 'Windows';
00119 if (stristr($_SERVER['HTTP_USER_AGENT'], 'Linux'))
00120 $client_os = 'Linux';
00121
00122
00123
00124 if ($_REQUEST['pid'] == '')
00125 $pid = 0;
00126 else
00127 $pid = $_REQUEST['pid'];
00128
00129 $browserhits = get_entry('stats_browserHits', $browser);
00130 set_entry('stats_browserHits', $browser, ++$browserhits);
00131 $oshits = get_entry('stats_osHits', $client_os);
00132 set_entry('stats_osHits', $client_os, ++$oshits);
00133 $pagehits = get_field('pages', 'id', $pid, 'hits');
00134 set_field('pages', 'id', $pid, 'hits', ++$pagehits);
00135 }
00136
00137 function stats_tr_cell()
00138
00139 {
00140 CallHooks('DoStats', 'tr');
00141 }
00142
00143 ?>