| 17 | | define ('ABSPATH', substr(__FILE__,0,strpos(__FILE__,'/wp-content/')+1)); |
| 18 | | if (file_exists(ABSPATH. 'wp-blog-header.php')) { |
| 19 | | include_once(ABSPATH. 'wp-blog-header.php'); |
| 20 | | } |
| | 17 | $wpabspath=substr(__FILE__,0,strpos(__FILE__,'/wp-content/')+1); |
| | 18 | if (file_exists($wpabspath. 'wp-blog-header.php')) { |
| | 19 | include_once($wpabspath. 'wp-blog-header.php'); |
| | 20 | } |
| | 21 | } else { |
| | 22 | $wpabspath=ABSPATH; |
| | 45 | //#set required variables |
| | 46 | $siteurl = get_bloginfo('siteurl'); |
| | 47 | $wpurl = get_bloginfo('wpurl'); |
| | 48 | $table_name = $wpdb->prefix . "wassup"; |
| | 49 | $wassup_settings = get_option('wassup_settings'); |
| | 50 | if (!defined('WASSUPFOLDER')) { |
| | 51 | define('WASSUPFOLDER', substr(__FILE__,0,strpos(__FILE__,'/lib/')+1)); |
| | 52 | } |
| | 53 | |
| 155 | | $ch_search = $wpdb->get_results("SELECT count(search) as top_search, search, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND search!='' $spamselect GROUP BY search ORDER BY top_search DESC LIMIT 10"); |
| 156 | | $col_count = $col_count+1; |
| 157 | | } |
| 158 | | //#get top 10 requests... |
| 159 | | if ($top_ten['toprequest'] == 1) { |
| 160 | | $ch_urlreq = $wpdb->get_results("SELECT count(urlrequested) as top_urlrequested, urlrequested FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND urlrequested!='' $spamselect GROUP BY REPLACE(urlrequested, '/', '') ORDER BY top_urlrequested DESC LIMIT 10"); |
| 161 | | $col_count = $col_count+1; |
| 162 | | } |
| 163 | | //#get top 200 referrers...will be narrowed down to 10 |
| | 170 | $top_results = $wpdb->get_results("SELECT count(search) as top_search, search, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND search!='' $spamselect GROUP BY search ORDER BY top_search DESC LIMIT 10"); |
| | 171 | $char_len = round(($max_char_len*.30)+$widthoffset,0); |
| | 172 | ?> |
| | 173 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 174 | <ul class="charts"> |
| | 175 | <li class="chartsT"><?php _e("TOP QUERY", "wassup"); ?></li> |
| | 176 | <?php |
| | 177 | foreach ($top_results as $top10) { ?> |
| | 178 | <li class="charts"><?php echo $top10->top_search.': <a href="'.$top10->referrer.'" target="_BLANK">'.stringShortener(preg_replace('/'.preg_quote($siteurl,'/').'/i', '', $top10->search),$char_len).'</a>'; ?></li> |
| | 179 | <?php } ?> |
| | 180 | </ul> |
| | 181 | </td> |
| | 182 | <?php |
| | 183 | } // end if topsearch |
| | 184 | |
| | 185 | //#output top 10 referrers |
| | 186 | //# select top 200 referrers: will be narrowed down to 10 |
| 166 | | $ch_referer = $wpdb->get_results("SELECT count(referrer) as top_referrer, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND referrer!='' AND referrer NOT LIKE '%".$sitedomain."%' AND searchengine='' $spamselect GROUP BY referrer ORDER BY top_referrer DESC LIMIT 200"); |
| 167 | | $col_count = $col_count+1; |
| 168 | | } |
| 169 | | //#get top 10 browsers... |
| 170 | | if ($top_ten['topbrowser'] == 1) { |
| 171 | | $ch_browser = $wpdb->get_results("SELECT count(browser) as top_browser, browser FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND browser!='' AND browser NOT LIKE '%N/A%' $spamselect GROUP BY browser ORDER BY top_browser DESC LIMIT 10"); |
| 172 | | $col_count = $col_count+1; |
| 173 | | } |
| 174 | | //#get top 10 operating systems... |
| 175 | | if ($top_ten['topos'] == 1) { |
| 176 | | $ch_os = $wpdb->get_results("SELECT count(os) as top_os, os FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND os!='' AND os NOT LIKE '%N/A%' $spamselect GROUP BY os ORDER BY top_os DESC LIMIT 10"); |
| 177 | | $col_count = $col_count+1; |
| 178 | | } |
| 179 | | |
| 180 | | //#add an extra width offset when number of columns < 5 |
| 181 | | if ($col_count > 0 && $col_count < 5 ) { |
| 182 | | $widthoffset = (($max_char_len*(5 - $col_count))/$col_count)*.4; //just a guess |
| 183 | | } else { |
| 184 | | $widthoffset = 0; |
| 185 | | } |
| 186 | | ?> |
| 187 | | <div id="toptenchart"> |
| 188 | | <table width="100%" border=0> |
| 189 | | <tr valign="top"> |
| 190 | | <?php if ($top_ten['topsearch'] == 1) { ?> |
| 191 | | <td><ul class="charts"> |
| 192 | | <li class="chartsT"><?php _e("TOP QUERY", "wassup") ?></li> |
| 193 | | <?php |
| 194 | | $char_len = round(($max_char_len*.30)+$widthoffset,0); |
| 195 | | foreach ($ch_search as $chS) { |
| 196 | | print '<li class="charts">'.$chS->top_search.': <a href="'.$chS->referrer.'" target="_BLANK">'.stringShortener(preg_replace('/'.preg_quote($siteurl,'/').'/i', '', $chS->search),$char_len).'</a></li>'."\n"; |
| 197 | | } ?> |
| 198 | | </ul> |
| 199 | | </td> |
| 200 | | <?php } |
| 201 | | if ($top_ten['topreferrer'] == 1) { ?> |
| 202 | | <td><ul class="charts"> |
| 203 | | <li class="chartsT"><?php _e("TOP REFERER", "wassup") ?></li> |
| 204 | | <?php |
| 205 | | $char_len = round(($max_char_len*.22)+$widthoffset,0); |
| | 189 | $top_results = $wpdb->get_results("SELECT count(referrer) as top_referrer, referrer FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND referrer!='' AND referrer NOT LIKE '%".$sitedomain."%' AND searchengine='' $spamselect GROUP BY referrer ORDER BY top_referrer DESC LIMIT 200"); |
| | 190 | $char_len = round(($max_char_len*.22)+$widthoffset,0); |
| | 191 | ?> |
| | 192 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 193 | <ul class="charts"> |
| | 194 | <li class="chartsT"><?php _e("TOP REFERRER", "wassup"); ?></li> |
| | 195 | <?php |
| 227 | | <?php } |
| 228 | | if ($top_ten['toprequest'] == 1) { ?> |
| 229 | | <td><ul class="charts"> |
| 230 | | <li class="chartsT"><?php _e("TOP REQUEST", "wassup") ?></li> |
| 231 | | <?php |
| 232 | | $char_len = round(($max_char_len*.28)+$widthoffset,0); |
| 233 | | foreach ($ch_urlreq as $chU) { |
| 234 | | print '<li class="charts">'.$chU->top_urlrequested.': '; |
| 235 | | print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($chU->urlrequested))).'" title="'.html_entity_decode($chU->urlrequested).'" target="_BLANK">'; |
| 236 | | print stringShortener(urlencode(html_entity_decode($chU->urlrequested)),$char_len).'</a></li>'."\n"; |
| 237 | | } ?> |
| 238 | | </ul> |
| 239 | | </td> |
| 240 | | <?php } |
| 241 | | if ($top_ten['topbrowser'] == 1) { ?> |
| 242 | | <td><ul class="charts"> |
| | 218 | <?php |
| | 219 | } //end if topreferrer |
| | 220 | |
| | 221 | //#output top 10 url requests |
| | 222 | if ($top_ten['toprequest'] == 1) { |
| | 223 | $top_results = $wpdb->get_results("SELECT count(urlrequested) as top_urlrequested, urlrequested FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND urlrequested!='' $spamselect GROUP BY REPLACE(urlrequested, '/', '') ORDER BY top_urlrequested DESC LIMIT 10"); |
| | 224 | $char_len = round(($max_char_len*.28)+$widthoffset,0); |
| | 225 | ?> |
| | 226 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 227 | <ul class="charts"> |
| | 228 | <li class="chartsT"><?php _e("TOP REQUEST", "wassup"); ?></li> |
| | 229 | <?php |
| | 230 | foreach ($top_results as $top10) { ?> |
| | 231 | <li class="charts"><?php echo $top10->top_urlrequested.': '; |
| | 232 | print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($top10->urlrequested))).'" title="'.html_entity_decode($top10->urlrequested).'" target="_BLANK">'; |
| | 233 | print stringShortener(urlencode(html_entity_decode($top10->urlrequested)),$char_len).'</a>'; ?></li> |
| | 234 | <?php } ?> |
| | 235 | </ul> |
| | 236 | </td> |
| | 237 | <?php |
| | 238 | } //end if toprequest |
| | 239 | |
| | 240 | //#get top 10 browsers... |
| | 241 | if ($top_ten['topbrowser'] == 1) { |
| | 242 | $top_results = $wpdb->get_results("SELECT count(browser) as top_browser, browser FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND browser!='' AND browser NOT LIKE '%N/A%' $spamselect GROUP BY browser ORDER BY top_browser DESC LIMIT 10"); |
| | 243 | $char_len = round(($max_char_len*.17)+$widthoffset,0); |
| | 244 | ?> |
| | 245 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 246 | <ul class="charts"> |
| 245 | | $char_len = round(($max_char_len*.17)+$widthoffset,0); |
| 246 | | foreach ($ch_browser as $chB) { |
| 247 | | print '<li class="charts"><span title="'.$chB->browser.'">'; |
| 248 | | print $chB->top_browser.': '.stringShortener($chB->browser, $char_len); |
| 249 | | print '</span></li>'."\n"; |
| 250 | | } ?> |
| 251 | | </ul> |
| 252 | | </td> |
| 253 | | <?php } |
| 254 | | if ($top_ten['topos'] == 1) { ?> |
| 255 | | <td><ul class="charts"> |
| | 249 | foreach ($top_results as $top10) { ?> |
| | 250 | <li class="charts"><?php echo $top10->top_browser.': '; |
| | 251 | echo '<span class="top10" title="'.$top10->browser.'">'.stringShortener($top10->browser, $char_len).'</span>'; ?> |
| | 252 | </li> |
| | 253 | <?php } ?> |
| | 254 | </ul> |
| | 255 | </td> |
| | 256 | <?php } //end if topbrowser |
| | 257 | |
| | 258 | //#output top 10 operating systems... |
| | 259 | if ($top_ten['topos'] == 1) { |
| | 260 | $top_results = $wpdb->get_results("SELECT count(os) as top_os, os FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND os!='' AND os NOT LIKE '%N/A%' $spamselect GROUP BY os ORDER BY top_os DESC LIMIT 10"); |
| | 261 | $char_len = round(($max_char_len*.15)+$widthoffset,0); |
| | 262 | |
| | 263 | ?> |
| | 264 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 265 | <ul class="charts"> |
| 258 | | $char_len = round(($max_char_len*.15)+$widthoffset,0); |
| 259 | | foreach ($ch_os as $chO) { |
| 260 | | print '<li class="charts"><span title="'.$chO->os.'">'; |
| 261 | | print $chO->top_os.': '.stringShortener($chO->os, $char_len); |
| 262 | | print '</span></li>'."\n"; |
| 263 | | } ?> |
| 264 | | </ul> |
| 265 | | </td> |
| 266 | | <?php } ?> |
| | 268 | foreach ($top_results as $top10) { ?> |
| | 269 | <li class="charts"><?php print $top10->top_os.': '; ?> |
| | 270 | <span class="top10" title="<?php echo $top10->os; ?>"><?php echo stringShortener($top10->os, $char_len); ?></span> |
| | 271 | </li> |
| | 272 | <?php } ?> |
| | 273 | </ul> |
| | 274 | </td> |
| | 275 | <?php } // end if topos |
| | 276 | |
| | 277 | //#output top 10 locales/geographic regions... |
| | 278 | if ($top_ten['toplocale'] == 1) { |
| | 279 | $top_results = $wpdb->get_results("SELECT count(UPPER(language)) as top_locale, UPPER(language) as locale FROM $table_name WHERE timestamp BETWEEN $from_date AND $to_date AND language!='' AND language NOT LIKE '%N/A%' $spamselect GROUP BY locale ORDER BY top_locale DESC LIMIT 10"); |
| | 280 | $char_len = round(($max_char_len*.15)+$widthoffset,0); |
| | 281 | |
| | 282 | ?> |
| | 283 | <td style="min-width:<?php echo $char_len; ?>px;"> |
| | 284 | <ul class="charts"> |
| | 285 | <li class="chartsT"><?php _e("TOP LOCALE", "wassup"); ?></li> |
| | 286 | <?php |
| | 287 | foreach ($top_results as $top10) { ?> |
| | 288 | <li class="charts"><?php echo $top10->top_locale.': '; |
| | 289 | echo '<img src="'.$wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img/flags/'.strtolower($top10->locale).'.png" alt="" />'; ?> |
| | 290 | <span class="top10" title="<?php echo $top10->locale; ?>"><?php echo $top10->locale; ?></span> |
| | 291 | </li> |
| | 292 | <?php } ?> |
| | 293 | </ul> |
| | 294 | </td> |
| | 295 | <?php } // end if toplocale |
| | 296 | ?> |