| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @subpackage Statistics 5 * @author Mambo Foundation Inc see README.php 6 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 7 * See COPYRIGHT.php for copyright notices and details. 8 * @license GNU/GPL Version 2, see LICENSE.php 9 * 10 * Redistributions of files must retain the above copyright notice. 11 * 12 * Mambo is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; version 2 of the License. 15 */ 16 17 /** ensure this file is being included by a parent file */ 18 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 19 require_once( $mainframe->getPath( 'admin_html' ) ); 20 21 switch ($task) { 22 case 'searches': 23 showSearches( $option, $task ); 24 break; 25 26 case 'pageimp': 27 showPageImpressions( $option, $task ); 28 break; 29 30 default: 31 showSummary( $option, $task ); 32 break; 33 } 34 35 function showSummary( $option, $task ) { 36 global $database, $mainframe; 37 38 // get sort field and check against allowable field names 39 $field = strtolower( mosGetParam( $_REQUEST, 'field', '' ) ); 40 if (!in_array( $field, array( 'agent', 'hits' ) )) { 41 $field = ''; 42 } 43 44 // get field ordering or set the default field to order 45 $order = strtolower( mosGetParam( $_REQUEST, 'order', 'asc' ) ); 46 if ($order != 'asc' && $order != 'desc' && $order != 'none') { 47 $order = 'asc'; 48 } else if ($order == 'none') { 49 $field = 'agent'; 50 $order = 'asc'; 51 } 52 53 // browser stats 54 $order_by = ''; 55 $sorts = array(); 56 $tab = mosGetParam( $_REQUEST, 'tab', 'tab1' ); 57 $sort_base = "index2.php?option=$option&task=$task"; 58 59 switch ($field) { 60 case 'hits': 61 $order_by = "hits $order"; 62 $sorts['b_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab1", "agent" ); 63 $sorts['b_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab1", "hits", $order ); 64 $sorts['o_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab2", "agent" ); 65 $sorts['o_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab2", "hits", $order ); 66 $sorts['d_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab3", "agent" ); 67 $sorts['d_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab3", "hits", $order ); 68 break; 69 70 case 'agent': 71 default: 72 $order_by = "agent $order"; 73 $sorts['b_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab1", "agent", $order ); 74 $sorts['b_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab1", "hits" ); 75 $sorts['o_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab2", "agent", $order ); 76 $sorts['o_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab2", "hits" ); 77 $sorts['d_agent'] = mosHTML::sortIcon( "$sort_base&tab=tab3", "agent", $order ); 78 $sorts['d_hits'] = mosHTML::sortIcon( "$sort_base&tab=tab3", "hits" ); 79 break; 80 } 81 82 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 83 $database->setQuery( "SELECT * FROM #__stats_agents WHERE type='0' ORDER BY $order_by" ); 84 $browsers = $database->loadObjectList(); 85 86 $database->setQuery( "SELECT SUM(hits) AS totalhits,MAX(hits) AS maxhits FROM #__stats_agents WHERE type='0'" ); 87 $bstats = null; 88 $database->loadObject( $bstats ); 89 90 // platform statistics 91 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 92 $database->setQuery( "SELECT * FROM #__stats_agents WHERE type='1' ORDER BY hits DESC" ); 93 $platforms = $database->loadObjectList(); 94 95 $database->setQuery( "SELECT SUM(hits) AS totalhits,MAX(hits) AS maxhits FROM #__stats_agents WHERE type='1'" ); 96 $pstats = null; 97 $database->loadObject( $pstats ); 98 99 // domain statistics 100 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 101 $database->setQuery( "SELECT * FROM #__stats_agents WHERE type='2' ORDER BY hits DESC" ); 102 $tldomains = $database->loadObjectList(); 103 104 $database->setQuery( "SELECT SUM(hits) AS totalhits,MAX(hits) AS maxhits FROM #__stats_agents WHERE type='2'" ); 105 $dstats = null; 106 $database->loadObject( $dstats ); 107 108 HTML_statistics::show( $browsers, $platforms, $tldomains, $bstats, $pstats, $dstats, $sorts, $option ); 109 } 110 111 function showPageImpressions( $option, $task ) { 112 global $database, $mainframe, $mosConfig_list_limit; 113 114 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 115 $query = "SELECT count(id) FROM #__content"; 116 $database->setQuery($query); 117 $total = $database->loadResult(); 118 119 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); 120 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}{$task}limitstart", 'limitstart', 0 ); 121 122 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 123 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 124 125 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 126 $query = "SELECT id, title, created, hits FROM #__content ORDER BY hits DESC LIMIT $pageNav->limitstart, $pageNav->limit"; 127 $database->setQuery($query); 128 129 $rows = $database->loadObjectList(); 130 131 HTML_statistics::pageImpressions( $rows, $pageNav, $option, $task ); 132 } 133 134 function showSearches( $option, $task ) { 135 global $database, $mainframe, $mosConfig_list_limit; 136 global $_MAMBOTS; 137 138 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ); 139 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}{$task}limitstart", 'limitstart', 0 ); 140 141 // get the total number of records 142 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 143 $database->setQuery( "SELECT count(*) FROM #__core_log_searches"); 144 $total = $database->loadResult(); 145 146 require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' ); 147 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 148 149 // @RawSQLUse, trivial_implementation, SELECT, CONCEPT 150 $database->setQuery( "SELECT *" 151 . "\nFROM #__core_log_searches" 152 . "\nORDER BY hits DESC" 153 . "\nLIMIT $pageNav->limitstart,$pageNav->limit" 154 ); 155 156 $rows = $database->loadObjectList(); 157 if ($database->getErrorNum()) { 158 echo $database->stderr(); 159 return false; 160 } 161 162 $_MAMBOTS->loadBotGroup( 'search' ); 163 164 for ($i=0, $n = count($rows); $i < $n; $i++) { 165 $results = $_MAMBOTS->trigger( 'onSearch', array( $rows[$i]->search_term ) ); 166 167 $count = 0; 168 for ($j = 0, $n2 = count( $results ); $j < $n2; $j++) { 169 $count += count( $results[$j] ); 170 } 171 172 $rows[$i]->returns = $count; 173 } 174 175 HTML_statistics::showSearches( $rows, $pageNav, $option, $task ); 176 } 177 178 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |