/wp-content/plugins/newstatpress/newstatpress.php
PHP | 3334 lines | 2753 code | 269 blank | 312 comment | 380 complexity | d0f5ca5e121e2cf049afb43acdb4832b MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- Plugin Name: NewStatPress
- Plugin URI: http://newstatpress.altervista.org
- Description: Real time stats for your Wordpress blog
- Version: 0.4.4
- Author: Stefano Tognon (from Daniele Lippi works)
- Author URI: http://newstatpress.altervista.org
- */
- $_NEWSTATPRESS['version']='0.4.4';
- $_NEWSTATPRESS['feedtype']='';
- include ABSPATH.'wp-content/plugins/'.dirname(plugin_basename(__FILE__)).'/includes/charts.php';
- /**
- * Get the url of the plugin
- *
- * @return the url of the plugin
- */
- function PluginUrl() {
- //Try to use WP API if possible, introduced in WP 2.6
- if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__))));
- //Try to find manually... can't work if wp-content was renamed or is redirected
- $path = dirname(__FILE__);
- $path = str_replace("\\","/",$path);
- $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/")));
- return $path;
- }
- /**
- * Add pages with NewStatPress commands
- */
- function iri_add_pages() {
- # Create/update table if it not exists
- global $wpdb;
- $table_name = $wpdb->prefix . "statpress";
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
- iri_NewStatPress_CreateTable();
- }
- # add submenu
- $mincap=get_option('newstatpress_mincap');
- if($mincap == '') {
- $mincap="level_8";
- }
- // ORIG add_submenu_page('index.php', 'StatPress', 'StatPress', 8, 'statpress', 'iriNewStatPress');
- add_menu_page('NewStatPress', 'NewStatPress', $mincap, __FILE__, 'iriNewStatPress', plugins_url('newstatpress/images/stat.png',dirname(plugin_basename(__FILE__))));
- add_submenu_page(__FILE__, __('Overview','newstatpress'), __('Overview','newstatpress'), $mincap, __FILE__, 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Details','newstatpress'), __('Details','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=details', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Spy','newstatpress'), __('Spy','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=spy', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('New Spy','newstatpress'), __('New Spy','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=newspy', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Spy Bot','newstatpress'), __('Spy Bot','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=spybot', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Search','newstatpress'), __('Search','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=search', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Export','newstatpress'), __('Export','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=export', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Options','newstatpress'), __('Options','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=options', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('NewStatPressUpdate','newstatpress'), __('NewStatPressUpdate','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=up', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('NewStatpress blog','newstatpress'), __('NewStatpress blog','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=redirect', 'iriNewStatPress');
- add_submenu_page(__FILE__, __('Credits','newstatpress'), __('Credits','newstatpress'), $mincap, __FILE__ . '&newstatpress_action=credits', 'iriNewStatPress');
- }
- /**
- * General function for calling the action that user had choice
- */
- function iriNewStatPress() {
- ?>
- <?php
- if(isset($_GET['newstatpress_action'])){
- if ($_GET['newstatpress_action'] == 'export') {
- iriNewStatPressExport();
- } elseif ($_GET['newstatpress_action'] == 'up') {
- iriNewStatPressUpdate();
- } elseif ($_GET['newstatpress_action'] == 'spy') {
- iriNewStatPressSpy();
- } elseif ($_GET['newstatpress_action'] == 'newspy') {
- iriNewStatPressNewSpy();
- } elseif ($_GET['newstatpress_action'] == 'spybot') {
- iriNewStatPressSpyBot();
- } elseif ($_GET['newstatpress_action'] == 'search') {
- iriNewStatPressSearch();
- } elseif ($_GET['newstatpress_action'] == 'details') {
- iriNewStatPressDetails();
- } elseif ($_GET['newstatpress_action'] == 'options') {
- iriNewStatPressOptions();
- } elseif ($_GET['newstatpress_action'] == 'redirect') {
- iriNewStatPressRedirect();
- } elseif ($_GET['newstatpress_action'] == 'credits') {
- iriNewStatPressCredits();
- }
- } else iriNewStatPressMain();
- }
- /**
- * Redirect the wordpress page to the newstatpress blog
- */
- function iriNewStatPressRedirect() {
- echo "<script language=javascript>window.location.href= 'http://newstatpress.altervista.org'</script>";
- }
- /**
- * Filter the given value for preventing XSS attacks
- *
- * @param _value the value to filter
- * @return filtered value
- */
- function iriNewStatPress_filter_for_xss($_value){
- $_value=trim($_value);
- // Avoid XSS attacks
- $clean_value = preg_replace('/[^a-zA-Z0-9\,\.\/\ \-\_\?=&;]/', '', $_value);
- if (strlen($_value)==0){
- return array();
- } else {
- $array_values = explode(',',$clean_value);
- array_walk($array_values, 'iriNewStatPress_trim_value');
- return $array_values;
- }
- }
- /**
- * Trim the given string
- */
- function iriNewStatPress_trim_value(&$value) {
- $value = trim($value);
- }
- /**
- * Generate HTML for option menu in Wordpress
- */
- function iriNewStatPressOptions() {
- if(isset($_POST['saveit']) && $_POST['saveit'] == 'yes') {
- if (isset($_POST['newstatpress_collectloggeduser'])) update_option('newstatpress_collectloggeduser', $_POST['newstatpress_collectloggeduser']);
- else update_option('newstatpress_collectloggeduser', null);
- update_option('newstatpress_ip_per_page_newspy', $_POST['newstatpress_ip_per_page_newspy']);
- update_option('newstatpress_visits_per_ip_newspy', $_POST['newstatpress_visits_per_ip_newspy']);
- update_option('newstatpress_bot_per_page_spybot', $_POST['newstatpress_bot_per_page_spybot']);
- update_option('newstatpress_visits_per_bot_spybot', $_POST['newstatpress_visits_per_bot_spybot']);
- update_option('newstatpress_autodelete', $_POST['newstatpress_autodelete']);
- update_option('newstatpress_daysinoverviewgraph', $_POST['newstatpress_daysinoverviewgraph']);
- update_option('newstatpress_mincap', $_POST['newstatpress_mincap']);
- if (isset($_POST['newstatpress_donotcollectspider'])) update_option('newstatpress_donotcollectspider', $_POST['newstatpress_donotcollectspider']);
- else update_option('newstatpress_donotcollectspider', null);
- if (isset($_POST['newstatpress_cryptip'])) update_option('newstatpress_cryptip', $_POST['newstatpress_cryptip']);
- else update_option('newstatpress_cryptip', null);
- if (isset($_POST['newstatpress_dashboard'])) update_option('newstatpress_dashboard', $_POST['newstatpress_dashboard']);
- else update_option('newstatpress_dashboard', null);
- update_option('newstatpress_ignore_users', iriNewStatPress_filter_for_xss($_POST['newstatpress_ignore_users']));
- update_option('newstatpress_ignore_ip', iriNewStatPress_filter_for_xss($_POST['newstatpress_ignore_ip']));
- update_option('newstatpress_ignore_permalink', iriNewStatPress_filter_for_xss($_POST['newstatpress_ignore_permalink']));
- update_option('newstatpress_el_top_days', $_POST['newstatpress_el_top_days']);
- update_option('newstatpress_el_os', $_POST['newstatpress_el_os']);
- update_option('newstatpress_el_browser', $_POST['newstatpress_el_browser']);
- update_option('newstatpress_el_feed', $_POST['newstatpress_el_feed']);
- update_option('newstatpress_el_searchengine', $_POST['newstatpress_el_searchengine']);
- update_option('newstatpress_el_search', $_POST['newstatpress_el_search']);
- update_option('newstatpress_el_referrer', $_POST['newstatpress_el_referrer']);
- update_option('newstatpress_el_languages', $_POST['newstatpress_el_languages']);
- update_option('newstatpress_el_spiders', $_POST['newstatpress_el_spiders']);
- update_option('newstatpress_el_pages', $_POST['newstatpress_el_pages']);
- update_option('newstatpress_el_visitors', $_POST['newstatpress_el_visitors']);
- update_option('newstatpress_el_daypages', $_POST['newstatpress_el_daypages']);
- update_option('newstatpress_el_ippages', $_POST['newstatpress_el_ippages']);
- update_option('newstatpress_updateint', $_POST['newstatpress_updateint']);
- # update database too
- iri_NewStatPress_CreateTable();
- print "<br /><div class='updated'><p>".__('Saved','newstatpress')."!</p></div>";
- } else {
- ?>
- <div class='wrap'><h2><?php _e('Options','newstatpress'); ?></h2>
- <form method=post><table width=100%>
- <?php
- print "<tr><td><input type=checkbox name='newstatpress_collectloggeduser' value='checked' ".get_option('newstatpress_collectloggeduser')."> ".__('Collect data about logged users, too.','newstatpress')."</td></tr>";
- print "<tr><td><input type=checkbox name='newstatpress_donotcollectspider' value='checked' ".get_option('newstatpress_donotcollectspider')."> ".__('Do not collect spiders visits','newstatpress')."</td></tr>";
- print "<tr><td><input type=checkbox name='newstatpress_cryptip' value='checked' ".get_option('newstatpress_cryptip')."> ".__('Crypt IP addresses','newstatpress')."</td></tr>";
- print "<tr><td><input type=checkbox name='newstatpress_dashboard' value='checked' ".get_option('newstatpress_dashboard')."> ".__('Show NewStatPress dashboard widget','newstatpress')."</td></tr>";
- ?>
- <tr><td><?php _e('New Spy: number of IP per page','newstatpress'); ?>
- <select name="newstatpress_ip_per_page_newspy">
- <option value="20" <?php if(get_option('newstatpress_ip_per_page_newspy') == "20") print "selected"; ?>>20</option>
- <option value="50" <?php if(get_option('newstatpress_ip_per_page_newspy') == "50") print "selected"; ?>>50</option>
- <option value="100" <?php if(get_option('newstatpress_ip_per_page_newspy') == "100") print "selected"; ?>>100</option>
- </select></td></tr>
- <tr><td><?php _e('New Spy: number of visits for IP','newstatpress'); ?>
- <select name="newstatpress_visits_per_ip_newspy">
- <option value="20" <?php if(get_option('newstatpress_visits_per_ip_newspy') == "20") print "selected"; ?>>20</option>
- <option value="50" <?php if(get_option('newstatpress_visits_per_ip_newspy') == "50") print "selected"; ?>>50</option>
- <option value="100" <?php if(get_option('newstatpress_visits_per_ip_newspy') == "100") print "selected"; ?>>100</option>
- </select></td></tr>
- <tr><td><?php _e('Spy Bot: number of bot per page','newstatpress'); ?>
- <select name="newstatpress_bot_per_page_spybot">
- <option value="20" <?php if(get_option('newstatpress_bot_per_page_spybot') == "20") print "selected"; ?>>20</option>
- <option value="50" <?php if(get_option('newstatpress_bot_per_page_spybot') == "50") print "selected"; ?>>50</option>
- <option value="100" <?php if(get_option('newstatpress_bot_per_page_spybot') == "100") print "selected"; ?>>100</option>
- </select></td></tr>
- <tr><td><?php _e('Spy Bot: number of bot for IP','newstatpress'); ?>
- <select name="newstatpress_visits_per_bot_spybot">
- <option value="20" <?php if(get_option('newstatpress_visits_per_bot_spybot') == "20") print "selected"; ?>>20</option>
- <option value="50" <?php if(get_option('newstatpress_visits_per_bot_spybot') == "50") print "selected"; ?>>50</option>
- <option value="100" <?php if(get_option('newstatpress_visits_per_bot_spybot') == "100") print "selected"; ?>>100</option>
- </select></td></tr>
- <tr><td><?php _e('Automatically delete visits older than','newstatpress'); ?>
- <select name="newstatpress_autodelete">
- <option value="" <?php if(get_option('newstatpress_autodelete') =='' ) print "selected"; ?>><?php _e('Never delete!','newstatpress'); ?></option>
- <option value="1 month" <?php if(get_option('newstatpress_autodelete') == "1 month") print "selected"; ?>>1 <?php _e('month','newstatpress'); ?></option>
- <option value="3 months" <?php if(get_option('newstatpress_autodelete') == "3 months") print "selected"; ?>>3 <?php _e('months','newstatpress'); ?></option>
- <option value="6 months" <?php if(get_option('newstatpress_autodelete') == "6 months") print "selected"; ?>>6 <?php _e('months','newstatpress'); ?></option>
- <option value="1 year" <?php if(get_option('newstatpress_autodelete') == "1 year") print "selected"; ?>>1 <?php _e('year','newstatpress'); ?></option>
- </select></td></tr>
- <tr><td><?php _e('Days in Overview graph','newstatpress'); ?>
- <select name="newstatpress_daysinoverviewgraph">
- <option value="7" <?php if(get_option('newstatpress_daysinoverviewgraph') == 7) print "selected"; ?>>7</option>
- <option value="10" <?php if(get_option('newstatpress_daysinoverviewgraph') == 10) print "selected"; ?>>10</option>
- <option value="20" <?php if(get_option('newstatpress_daysinoverviewgraph') == 20) print "selected"; ?>>20</option>
- <option value="30" <?php if(get_option('newstatpress_daysinoverviewgraph') == 30) print "selected"; ?>>30</option>
- <option value="50" <?php if(get_option('newstatpress_daysinoverviewgraph') == 50) print "selected"; ?>>50</option>
- </select></td></tr>
- <tr><td><?php _e('Minimum capability to view stats','newstatpress'); ?>
- <select name="newstatpress_mincap">
- <?php iri_dropdown_caps(get_option('newstatpress_mincap')); ?>
- </select>
- <a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank"><?php _e("more info",'newstatpress'); ?></a>
- </td></tr>
- <tr><td><hr></hr></td></tr>
- <tr><td>
- <h3><label for="newstatpress_ignore_users"><?php _e('Logged users to ignore','newstatpress') ?></label></h3>
- <p><?php _e("Enter a list of users you don't want to track, separated by commas, even if collect data about logged users is on",'newstatpress') ?></p>
- <p><textarea class="large-text code" cols="50" rows="1" name="newstatpress_ignore_users" id="newstatpress_ignore_users">
- <?php echo implode(',', get_option('newstatpress_ignore_users',array())) ?>
- </textarea></p>
- </td></tr>
- <tr><td>
- <h3><label for="newstatpress_ignore_ip"><?php _e('IP addresses to ignore','newstatpress') ?></label></h3>
- <p><?php _e("Enter a list of networks you don't want to track, separated by commas. Each network <strong>must</strong> be defined using the CIDR notation (i.e. <em>192.168.1.1/24</em>). If the format is incorrect, NewStatPress may not track pageviews properly.",'newstatpress') ?></p>
- <p><textarea class="large-text code" cols="50" rows="1" name="newstatpress_ignore_ip" id="newstatpress_ignore_ip">
- <?php echo implode(',', get_option('newstatpress_ignore_ip',array())) ?>
- </textarea></p>
- </td></tr>
- <tr><td>
- <h3><label for="newstatpress_ignore_permalink"><?php _e('Pages and posts to ignore','newstatpress') ?></label></h3>
- <p><?php _e("Enter a list of permalinks you don't want to track, separated by commas. You should omit the domain name from these resources: <em>/about, p=1</em>, etc. NewStatPress will ignore all the pageviews whose permalink <strong>contains</strong> at least one of them.",'newstatpress') ?></p>
- <p><textarea class="large-text code" cols="50" rows="1" name="newstatpress_ignore_permalink" id="newstatpress_ignore_permalink">
- <?php echo implode(',', get_option('newstatpress_ignore_permalink',array())) ?>
- </textarea></p>
- </td></tr>
- <tr><td><hr></hr></td></tr>
- <tr>
- <td>
- <h3><label for="newstatpress_details_options"><?php _e('Details options','newstatpress') ?></label></h3>
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_top_days"><?php _e('Elements in Top days (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_top_days" value="<?php echo (get_option('newstatpress_el_top_days')=='') ? 5:get_option('newstatpress_el_top_days'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_os"><?php _e('Elements in O.S. (default 10)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_os" value="<?php echo (get_option('newstatpress_el_os')=='') ? 10:get_option('newstatpress_el_os'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_browser"><?php _e('Elements in Browser (default 10)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_browser" value="<?php echo (get_option('newstatpress_el_browser')=='') ? 10:get_option('newstatpress_el_browser'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_feed"><?php _e('Elements in Feed (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_feed" value="<?php echo (get_option('newstatpress_el_feed')=='') ? 5:get_option('newstatpress_el_feed'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_searchengine"><?php _e('Elements in Search Engines (default 10)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_searchengine" value="<?php echo (get_option('newstatpress_el_searchengine')=='') ? 10:get_option('newstatpress_el_searchengine'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_search"><?php _e('Elements in Top Search Terms (default 20)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_search" value="<?php echo (get_option('newstatpress_el_search')=='') ? 20:get_option('newstatpress_el_search'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_referrer"><?php _e('Elements in Top Refferer (default 10)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_referrer" value="<?php echo (get_option('newstatpress_el_referrer')=='') ? 10:get_option('newstatpress_el_referrer'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_languages"><?php _e('Elements in Countries/Languages (default 20)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_languages" value="<?php echo (get_option('newstatpress_el_languages')=='') ? 20:get_option('newstatpress_el_languages'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_spiders"><?php _e('Elements in Spiders (default 10)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_spiders" value="<?php echo (get_option('newstatpress_el_spiders')=='') ? 10:get_option('newstatpress_el_spiders'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_pages"><?php _e('Elements in Top Pages (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_pages" value="<?php echo (get_option('newstatpress_el_pages')=='') ? 5:get_option('newstatpress_el_pages'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_visitors"><?php _e('Elements in Top Days - Unique visitors (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_visitors" value="<?php echo (get_option('newstatpress_el_visitors')=='') ? 5:get_option('newstatpress_el_visitors'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_daypages"><?php _e('Elements in Top Days - Pageviews (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_daypages" value="<?php echo (get_option('newstatpress_el_daypages')=='') ? 5:get_option('newstatpress_el_daypages'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr>
- <td>
- <label for="newstatpress_el_ippages"><?php _e('Elements in Top IPs - Pageviews (default 5)','newstatpress') ?></label>
- <input type="text" name="newstatpress_el_ippages" value="<?php echo (get_option('newstatpress_el_ippages')=='') ? 5:get_option('newstatpress_el_ippages'); ?>" size="3" maxlength="3" />
- </td></tr>
- <tr><td><hr></hr></td></tr>
- <tr>
- <td>
- <h2><?php _e('Database update option','newstatpress'); ?></h3>
- </td></tr>
- <tr>
- <td>
- <p><?php _e("Select the interval of date from today you want to use for updating your database with new definitions. More it is big and more times and resources it require. You can choose to not update some fields if you want.",'newstatpress') ?></p>
- </td></tr>
- <tr>
- <td>
- <?php _e('Update data in the given period','newstatpress'); ?>
- <select name="newstatpress_updateint">
- <option value="" <?php if(get_option('newstatpress_updateint') =='' ) print "selected"; ?>><?php _e('All!','newstatpress'); ?></option>
- <option value="1 week" <?php if(get_option('newstatpress_updateint') == "1 week") print "selected"; ?>>1 <?php _e('week','newstatpress'); ?></option>
- <option value="2 weeks" <?php if(get_option('newstatpress_updateint') == "2 weeks") print "selected"; ?>>2 <?php _e('weeks','newstatpress'); ?></option>
- <option value="3 weeks" <?php if(get_option('newstatpress_updateint') == "3 weeks") print "selected"; ?>>3 <?php _e('weeks','newstatpress'); ?></option>
- <option value="1 month" <?php if(get_option('newstatpress_updateint') == "1 month") print "selected"; ?>>1 <?php _e('month','newstatpress'); ?></option>
- <option value="2 months" <?php if(get_option('newstatpress_updateint') == "2 months") print "selected"; ?>>2 <?php _e('months','newstatpress'); ?></option>
- <option value="3 months" <?php if(get_option('newstatpress_updateint') == "3 months") print "selected"; ?>>3 <?php _e('months','newstatpress'); ?></option>
- <option value="6 months" <?php if(get_option('newstatpress_updateint') == "6 months") print "selected"; ?>>6 <?php _e('months','newstatpress'); ?></option>
- <option value="9 months" <?php if(get_option('newstatpress_updateint') == "9 months") print "selected"; ?>>9 <?php _e('months','newstatpress'); ?></option>
- <option value="1 year" <?php if(get_option('newstatpress_updateint') == "1 year") print "selected"; ?>>1 <?php _e('year','newstatpress'); ?></option>
- </select></td></tr>
- </td></tr>
- <tr><td><hr></hr></td></tr>
- <tr><td><br><input type=submit value="<?php _e('Save options','newstatpress'); ?>"></td></tr>
- </tr>
- </table>
- <input type=hidden name=saveit value=yes>
- <input type=hidden name=page value=newstatpress><input type=hidden name=newstatpress_action value=options>
- </form>
- </div>
- <?php
- }
- }
- function iri_dropdown_caps( $default = false ) {
- global $wp_roles;
- $role = get_role('administrator');
- foreach($role->capabilities as $cap => $grant) {
- print "<option ";
- if($default == $cap) { print "selected "; }
- print ">$cap</option>";
- }
- }
- /**
- * Show credits about this plugin
- */
- function iriNewStatPressCredits() {
- ?>
- <div class='wrap'><h2><?php _e('Credits','newstatpress'); ?></h2>
- <table border="1">
- <tr>
- <th>People</th>
- <th>Description</th>
- <th>Link</th>
- </tr>
- <tr>
- <td>Stefano Tognon</td>
- <td>NewStatPress develoup</td>
- <td><a href="http://newstatpress.altervista.org">NewStatPress site</a></td>
- </tr>
- <tr>
- <td>Daniele Lippi</td>
- <td>Original StatPress develoup</td>
- <td><a href="http://wordpress.org/extend/plugins/statpress/">StatPress site</a></td>
- </tr>
- <tr>
- <td>Pawel Dworniak</td>
- <td>Better polish translation</td>
- <td></td>
- </tr>
- <tr>
- <td>Sisko</td>
- <td>Open link in new tab/window<br>
- New displays of data for spy function<br>
- </td>
- <td></td>
- </tr>
- <tr>
- <td>from wp_slimstat</td>
- <td>Add option for not track given IPs<br>
- Add option for not track given permalinks
- </td>
- <td></td>
- </tr>
- <tr>
- <td>Ladislav</td>
- <td>Let Search function to works again</td>
- <td></td>
- </tr>
- <tr>
- <td>from statpress-visitors</td>
- <td>Add new OS (+44), browsers (+52) and spiders (+71)<br>
- Add in the option the ability to update in a range of date<br>
- New spy and bot
- </td>
- <td></td>
- </tr>
- <tr>
- <td>Christopher Meng</td>
- <td>Add Simplified Chinese translation</td>
- <td><a href="http://cicku.me">cicku.me</a></td>
- </tr>
- <tr>
- <td>Maurice Cramer</td>
- <td>Add dashboard widget<br>
- Fix total since in overwiew<br>
- Fix missing browser image and IE aligment failure in spy section<br>
- Fix nation image display in spy
- </td>
- <td></td>
- </tr>
- <tr>
- <td>shilom</td>
- <td>Updating French translation</td>
- <td></td>
- </tr>
- <tr>
- <td>Vincent G</td>
- <td>Add Lithuanian translation</td>
- <td><a href="http://www.Host1Free.com">Host1Free (Free Hosting)</a></td>
- </tr>
- <tr>
- <td>Ruud van der Veen</td>
- <td>Add tab delimiter for exporting data</td>
- <td></td>
- </tr>
- </table>
- </div>
- <?php
- }
- function iriNewStatPressExport() {
- ?>
- <div class='wrap'><h2><?php _e('Export stats to text file','newstatpress'); ?> (csv)</h2>
- <form method=get><table>
- <tr><td><?php _e('From','newstatpress'); ?></td><td><input type=text name=from> (YYYYMMDD)</td></tr>
- <tr><td><?php _e('To','newstatpress'); ?></td><td><input type=text name=to> (YYYYMMDD)</td></tr>
- <tr><td><?php _e('Fields delimiter','newstatpress'); ?></td><td><select name=del><option>,</option><option>tab</option><option>;</option><option>|</option></select></tr>
- <tr><td></td><td><input type=submit value=<?php _e('Export','newstatpress'); ?>></td></tr>
- <input type=hidden name=page value=newstatpress><input type=hidden name=newstatpress_action value=exportnow>
- </table></form>
- </div>
- <?php
- }
- /**
- * Check and export if capability of user allow that
- */
- function iri_checkExport(){
- if (isset($_GET['newstatpress_action']) && $_GET['newstatpress_action'] == 'exportnow') {
- $mincap=get_option('newstatpress_mincap');
- if ($mincap == '') $mincap = "level_8";
- if ( current_user_can( $mincap ) ) {
- iriNewStatPressExportNow();
- }
- }
- }
- /**
- * Export the NewStatPress data
- */
- function iriNewStatPressExportNow() {
- global $wpdb;
- $table_name = $wpdb->prefix . "statpress";
- $filename=get_bloginfo('title' )."-newstatpress_".$_GET['from']."-".$_GET['to'].".csv";
- header('Content-Description: File Transfer');
- header("Content-Disposition: attachment; filename=$filename");
- header('Content-Type: text/plain charset=' . get_option('blog_charset'), true);
- $qry = $wpdb->get_results(
- "SELECT *
- FROM $table_name
- WHERE
- date>='".(date("Ymd",strtotime(substr($_GET['from'],0,8))))."' AND
- date<='".(date("Ymd",strtotime(substr($_GET['to'],0,8))))."';
- ");
- $del=substr($_GET['del'],0,1);
- if ($del=="t") {
- $del="\t";
- }
- print "date".$del."time".$del."ip".$del."urlrequested".$del."agent".$del."referrer".$del."search".$del."nation".$del."os".$del."browser".$del."searchengine".$del."spider".$del."feed\n";
- foreach ($qry as $rk) {
- print '"'.$rk->date.'"'.$del.'"'.$rk->time.'"'.$del.'"'.$rk->ip.'"'.$del.'"'.$rk->urlrequested.'"'.$del.'"'.$rk->agent.'"'.$del.'"'.$rk->referrer.'"'.$del.'"'.$rk->search.'"'.$del.'"'.$rk->nation.'"'.$del.'"'.$rk->os.'"'.$del.'"'.$rk->browser.'"'.$del.'"'.$rk->searchengine.'"'.$del.'"'.$rk->spider.'"'.$del.'"'.$rk->feed.'"'."\n";
- }
- die();
- }
- /**
- * Show overwiew
- */
- function iriNewStatPressMain() {
- global $wpdb;
- $table_name = $wpdb->prefix . "statpress";
- iriOverview();
- $_newstatpress_url=PluginUrl();
- $querylimit="LIMIT 10";
-
- # Tabella Last hits
- print "<div class='wrap'><h2>". __('Last hits','newstatpress'). "</h2><table class='widefat'><thead><tr><th scope='col'>". __('Date','newstatpress'). "</th><th scope='col'>". __('Time','newstatpress'). "</th><th scope='col'>IP</th><th scope='col'>". __('Country','newstatpress').'/'.__('Language','newstatpress'). "</th><th scope='col'>". __('Page','newstatpress'). "</th><th scope='col'>Feed</th><th></th><th scope='col' style='width:120px;'>OS</th><th></th><th scope='col' style='width:120px;'>Browser</th></tr></thead>";
- print "<tbody id='the-list'>";
- $fivesdrafts = $wpdb->get_results("
- SELECT *
- FROM $table_name
- WHERE (os<>'' OR feed<>'')
- ORDER bY id DESC $querylimit
- ");
- foreach ($fivesdrafts as $fivesdraft) {
- print "<tr>";
- print "<td>". irihdate($fivesdraft->date) ."</td>";
- print "<td>". $fivesdraft->time ."</td>";
- print "<td>". $fivesdraft->ip ."</td>";
- print "<td>". $fivesdraft->nation ."</td>";
- print "<td>". iri_NewStatPress_Abbrevia(iri_NewStatPress_Decode($fivesdraft->urlrequested),30) ."</td>";
- print "<td>". $fivesdraft->feed . "</td>";
- if($fivesdraft->os != '') {
- $img=str_replace(" ","_",strtolower($fivesdraft->os)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/os/$img'> </td>";
- } else {
- print "<td></td>";
- }
- print "<td>". $fivesdraft->os . "</td>";
- if($fivesdraft->browser != '') {
- $img=str_replace(" ","",strtolower($fivesdraft->browser)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/browsers/$img'></td>";
- } else {
- print "<td></td>";
- }
- print "<td>".$fivesdraft->browser."</td></tr>\n";
- print "</tr>";
- }
- print "</table></div>";
- # Last Search terms
- print "<div class='wrap'><h2>" . __('Last search terms','newstatpress') . "</h2><table class='widefat'><thead><tr><th scope='col'>".__('Date','newstatpress')."</th><th scope='col'>".__('Time','newstatpress')."</th><th scope='col'>".__('Terms','newstatpress')."</th><th scope='col'>". __('Engine','newstatpress'). "</th><th scope='col'>". __('Result','newstatpress'). "</th></tr></thead>";
- print "<tbody id='the-list'>";
- $qry = $wpdb->get_results("
- SELECT date,time,referrer,urlrequested,search,searchengine
- FROM $table_name
- WHERE search<>''
- ORDER BY id DESC $querylimit
- ");
- foreach ($qry as $rk) {
- print "<tr><td>".irihdate($rk->date)."</td><td>".$rk->time."</td><td><a href='".$rk->referrer."' target='_blank'>".$rk->search."</a></td><td>".$rk->searchengine."</td><td><a href='".get_bloginfo('url')."/?".$rk->urlrequested."' target='_blank'>". __('page viewed','newstatpress'). "</a></td></tr>\n";
- }
- print "</table></div>";
- # Referrer
- print "<div class='wrap'><h2>".__('Last referrers','newstatpress')."</h2><table class='widefat'><thead><tr><th scope='col'>".__('Date','newstatpress')."</th><th scope='col'>".__('Time','newstatpress')."</th><th scope='col'>".__('URL','newstatpress')."</th><th scope='col'>".__('Result','newstatpress')."</th></tr></thead>";
- print "<tbody id='the-list'>";
- $qry = $wpdb->get_results("
- SELECT date,time,referrer,urlrequested
- FROM $table_name
- WHERE
- ((referrer NOT LIKE '".get_option('home')."%') AND
- (referrer <>'') AND
- (searchengine='')
- ) ORDER BY id DESC $querylimit
- ");
- foreach ($qry as $rk) {
- print "<tr><td>".irihdate($rk->date)."</td><td>".$rk->time."</td><td><a href='".$rk->referrer."' target='_blank'>".iri_NewStatPress_Abbrevia($rk->referrer,80)."</a></td><td><a href='".get_bloginfo('url')."/?".$rk->urlrequested."' target='_blank'>". __('page viewed','newstatpress'). "</a></td></tr>\n";
- }
- print "</table></div>";
- # Last Agents
- print "<div class='wrap'><h2>".__('Last agents','newstatpress')."</h2><table class='widefat'><thead><tr><th scope='col'>".__('Agent','newstatpress')."</th><th scope='col'></th><th scope='col' style='width:120px;'>OS</th><th scope='col'></th><th scope='col' style='width:120px;'>Browser/Spider</th></tr></thead>";
- print "<tbody id='the-list'>";
- $qry = $wpdb->get_results("
- SELECT agent,os,browser,spider
- FROM $table_name
- GROUP BY agent,os,browser,spider
- ORDER BY id DESC $querylimit
- ");
- foreach ($qry as $rk) {
- print "<tr><td>".$rk->agent."</td>";
- if($rk->os != '') {
- $img=str_replace(" ","_",strtolower($rk->os)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/os/$img'> </td>";
- } else {
- print "<td></td>";
- }
- print "<td>". $rk->os . "</td>";
- if($rk->browser != '') {
- $img=str_replace(" ","",strtolower($rk->browser)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/browsers/$img'></td>";
- } else {
- print "<td></td>";
- }
- print "<td>".$rk->browser." ".$rk->spider."</td></tr>\n";
- }
- print "</table></div>";
- # Last pages
- print "<div class='wrap'><h2>".__('Last pages','newstatpress')."</h2><table class='widefat'><thead><tr><th scope='col'>".__('Date','newstatpress')."</th><th scope='col'>".__('Time','newstatpress')."</th><th scope='col'>".__('Page','newstatpress')."</th><th scope='col' style='width:17px;'></th><th scope='col' style='width:120px;'>".__('OS','newstatpress')."</th><th style='width:17px;'></th><th scope='col' style='width:120px;'>".__('Browser','newstatpress')."</th></tr></thead>";
- print "<tbody id='the-list'>";
- $qry = $wpdb->get_results("
- SELECT date,time,urlrequested,os,browser,spider
- FROM $table_name
- WHERE (spider='' AND feed='')
- ORDER BY id DESC $querylimit
- ");
- foreach ($qry as $rk) {
- print "<tr><td>".irihdate($rk->date)."</td><td>".$rk->time."</td><td>".iri_NewStatPress_Abbrevia(iri_NewStatPress_Decode($rk->urlrequested),60)."</td>";
- if($rk->os != '') {
- $img=str_replace(" ","_",strtolower($rk->os)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/os/$img'> </td>";
- } else {
- print "<td></td>";
- }
- print "<td>". $rk->os . "</td>";
- if($rk->browser != '') {
- $img=str_replace(" ","",strtolower($rk->browser)).".png";
- print "<td><IMG style='border:0px;width:16px;height:16px;' SRC='".$_newstatpress_url."/images/browsers/$img'></td>";
- } else {
- print "<td></td>";
- }
- print "<td>".$rk->browser." ".$rk->spider."</td></tr>\n";
- }
- print "</table></div>";
- # Last Spiders
- print "<div class='wrap'><h2>".__('Last spiders','newstatpress')."</h2><table class='widefat'><thead><tr><th scope='col'>".__('Date','newstatpress')."</th><th scope='col'>".__('Time','newstatpress')."</th><th scope='col'></th><th scope='col'>".__('Spider','newstatpress')."</th><th scope='col'>".__('Agent','newstatpress')."</th></tr></thead>";
- print "<tbody id='the-list'>";
- $qry = $wpdb->get_results("
- SELECT date,time,agent,os,browser,spider
- FROM $table_name
- WHERE (spider<>'')
- ORDER BY id DESC $querylimit
- ");
- foreach ($qry as $rk) {
- print "<tr><td>".irihdate($rk->date)."</td><td>".$rk->time."</td>";
- if($rk->spider != '') {
- $img=str_replace(" ","_",strtolower($rk->spider)).".png";
- print "<td><IMG style='border:0px;height:16px;' SRC='".$_newstatpress_url."/images/spider/$img'> </td>";
- } else print "<td></td>";
- print "<td>".$rk->spider."</td><td> ".$rk->agent."</td></tr>\n";
- }
- print "</table></div>";
- print "<br />";
- print " <i>StatPress table size: <b>".iritablesize($wpdb->prefix . "statpress")."</b></i><br />";
- print " <i>StatPress current time: <b>".current_time('mysql')."</b></i><br />";
- print " <i>RSS2 url: <b>".get_bloginfo('rss2_url').' ('.iriNewStatPress_extractfeedreq(get_bloginfo('rss2_url')).")</b></i><br />";
- }
- /**
- * Extract the feed from the given url
- *
- * @param url the url to parse
- * @return the extracted url
- */
- function iriNewStatPress_extractfeedreq($url) {
- list($null,$q)=explode("?",$url);
- if (strpos($q, "&")!== false) list($res,$null)=explode("&",$q);
- else $res=$q;
- return $res;
- }
- function iriNewStatPressDetails() {
- global $wpdb;
- $table_name = $wpdb->prefix . "statpress";
- $querylimit="LIMIT 10";
- # Top days
- iriValueTable2("date","Top days",(get_option('newstatpress_el_top_days')=='') ? 5:get_option('newstatpress_el_top_days'));
- # O.S.
- iriValueTable2("os","O.S.",(get_option('newstatpress_el_os')=='') ? 10:get_option('newstatpress_el_os'),"","","AND feed='' AND spider='' AND os<>''");
- # Browser
- iriValueTable2("browser","Browser",(get_option('newstatpress_el_browser')=='') ? 10:get_option('newstatpress_el_browser'),"","","AND feed='' AND spider='' AND browser<>''");
- # Feeds
- iriValueTable2("feed","Feeds",(get_option('newstatpress_el_feed')=='') ? 5:get_option('newstatpress_el_feed'),"","","AND feed<>''");
-
- # SE
- iriValueTable2("searchengine","Search engines",(get_option('newstatpress_el_searchengine')=='') ? 10:get_option('newstatpress_el_searchengine'),"","","AND searchengine<>''");
- # Search terms
- iriValueTable2("search","Top search terms",(get_option('newstatpress_el_search')=='') ? 20:get_option('newstatpress_el_search'),"","","AND search<>''");
- # Top referrer
- iriValueTable2("referrer","Top referrer",(get_option('newstatpress_el_referrer')=='') ? 10:get_option('newstatpress_el_referrer'),"","","AND referrer<>'' AND referrer NOT LIKE '%".get_bloginfo('url')."%'");
-
- # Languages
- iriValueTable2("nation","Countries/Languages",(get_option('newstatpress_el_languages')=='') ? 20:get_option('newstatpress_el_languages'),"","","AND nation<>'' AND spider=''");
- # Spider
- iriValueTable2("spider","Spiders",(get_option('newstatpress_el_spiders')=='') ? 10:get_option('newstatpress_el_spiders'),"","","AND spider<>''");
- # Top Pages
- iriValueTable2("urlrequested","Top pages",(get_option('newstatpress_el_pages')=='') ? 5:get_option('newstatpress_el_pages'),"","urlrequested","AND feed='' and spider=''");
- # Top Days - Unique visitors
- iriValueTable2("date","Top Days - Unique visitors",(get_option('newstatpress_el_visitors')=='') ? 5:get_option('newstatpress_el_visitors'),"distinct","ip","AND feed='' and spider=''"); /* Maddler 04112007: required patching iriValueTable */
- # Top Days - Pageviews
- iriValueTable2("date","Top Days - Pageviews",(get_option('newstatpress_el_daypages')=='') ? 5:get_option('newstatpress_el_daypages'),"","urlrequested","AND feed='' and spider=''"); /* Maddler 04112007: required patching iriValueTable */
- # Top IPs - Pageviews
- iriValueTable2("ip","Top IPs - Pageviews",(get_option('newstatpress_el_ippages')=='') ? 5:get_option('newstatpress_el_ippages'),"","urlrequested","AND feed='' and spider=''"); /* Maddler 04112007: required patching iriValueTable */
- }
- /**
- * Converte da data us to default format di Wordpress
- *
- * @param dt the date to convert
- * @return converted data
- */
- function newstatpress_hdate($dt = "00000000") {
- return mysql2date(get_option('date_format'), my_substr($dt, 0, 4) . "-" . my_substr($dt, 4, 2) . "-" . my_substr($dt, 6, 2));
- }
- /**
- * Decode the url in a better manner
- */
- function newstatpress_Decode($out_url) {
- if(!permalinksEnabled()) {
- if ($out_url == '') $out_url = __('Page', 'newstatpress') . ": Home";
- if (my_substr($out_url, 0, 4) == "cat=") $out_url = __('Category', 'statpress') . ": " . get_cat_name(my_substr($out_url, 4));
- if (my_substr($out_url, 0, 2) == "m=") $out_url = __('Calendar', 'newstatpress') . ": " . my_substr($out_url, 6, 2) . "/" . my_substr($out_url, 2, 4);
- if (my_substr($out_url, 0, 2) == "s=") $out_url = __('Search', 'newstatpress') . ": " . my_substr($out_url, 2);
- if (my_substr($out_url, 0, 2) == "p=") {
- $post_id_7 = get_post(my_substr($out_url, 2), ARRAY_A);
- $out_url = $post_id_7['post_title'];
- }
- if (my_substr($out_url, 0, 8) == "page_id=") {
- $post_id_7 = get_page(my_substr($out_url, 8), ARRAY_A);
- $out_url = __('Page', 'newstatpress') . ": " . $post_id_7['post_title'];
- }
- } else {
- if ($out_url == '') $out_url = __('Page', 'newstatpress') . ": Home";
- else if (my_substr($out_url, 0, 9) == "category/") $out_url = __('Category', 'newstatpress') . ": " . get_cat_name(my_substr($out_url, 9));
- else if (my_substr($out_url, 0, 2) == "s=") $out_url = __('Search', 'newstatpress') . ": " . my_substr($out_url, 2);
- else if (my_substr($out_url, 0, 2) == "p=") {
- // not working yet
- $post_id_7 = get_post(my_substr($out_url, 2), ARRAY_A);
- $out_url = $post_id_7['post_title'];
- } else if (my_substr($out_url, 0, 8) == "page_id=") {
- // not working yet
- $post_id_7 = get_page(my_substr($out_url, 8), ARRAY_A);
- $out_url = __('Page', 'newstatpress') . ": " . $post_id_7['post_title'];
- }
- }
- return $out_url;
- }
- /**
- * Get true if permalink is enabled in Wordpress
- * (taken in statpress-visitors)
- *
- * @return true if permalink is enabled in Wordpress
- */
- function permalinksEnabled() {
- global $wpdb;
-
- $result = $wpdb->get_row('SELECT `option_value` FROM `' . $wpdb->prefix . 'options` WHERE `option_name` = "permalink_structure"');
- if ($result->option_value != '') return true;
- else return false;
- }
- /**
- * PHP 4 compatible mb_substr function
- * (taken in statpress-visitors)
- */
- function my_substr($str, $x, $y = 0) {
- if($y == 0) $y = strlen($str) - $x;
- if(function_exists('mb_substr'))
- return mb_substr($str, $x, $y);
- else
- return substr($str, $x, $y);
- }
- /**
- * Display links for group of pages
- *
- * @param NP the group of pages
- * @param pp the page to show
- * @param action the action
- */
- function newstatpress_print_pp_link($NP,$pp,$action) {
- // For all pages ($NP) Display first 3 pages, 3 pages before current page($pp), 3 pages after current page , each 25 pages and the 3 last pages for($action)
- $GUIL1 = FALSE;
- $GUIL2 = FALSE;// suspension points not writed style='border:0px;width:16px;height:16px; style="border:0px;width:16px;height:16px;"
- if ($NP >1) {
- print "<font size='1'>".__('period of days','newstatpress')." : </font>";
- for ($i = 1; $i <= $NP; $i++) {
- if ($i <= $NP) {
- // $page is not the last page
- if($i == $pp) echo " [{$i}] "; // $page is current page
- else {
- // Not the current page Hyperlink them
- if (($i <= 3) or (($i >= $pp-3) and ($i <= $pp+3)) or ($i >= $NP-3) or is_int($i/100)) {
- echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '?page=newstatpress/newstatpress.php&newstatpress_action='.$action.'&pp=' . $i .'">' . $i . '</a> ';
- } else {
- if (($GUIL1 == FALSE) OR ($i==$pp+4)) {
- echo "...";
- $GUIL1 = TRUE;
- }
- if ($i == $pp-4) echo "..";
- if (is_int(($i-1)/100)) echo ".";
- if ($i == $NP-4) echo "..";
- // suspension points writed
- }
- }
- }
- }
- }
- }
- /**
- * Display links for group of pages
- *
- * @param NP the group of pages
- * @param pp the page to show
- * @param action the action
- * @param NA group
- * @param pa current page
- */
- function newstatpress_print_pp_pa_link($NP,$pp,$action,$NA,$pa) {
- if ($NP<>0) newstatpress_print_pp_link($NP,$pp,$action);
- // For all pages ($NP) display first 5 pages, 3 pages before current page($pa), 3 pages after current page , 3 last pages
- $GUIL1 = FALSE;// suspension points not writed
- $GUIL2 = FALSE;
- echo '<table width="100%" border="0"><tr></tr></table>';
- if ($NA >1 ) {
- echo "<font size='1'>".__('Pages','newstatpress')." : </font>";
- for ($j = 1; $j <= $NA; $j++) {
- if ($j <= $NA) { // $i is not the last Articles page
- if($j == $pa) // $i is current page
- echo " [{$j}] ";
- else { // Not the current page Hyperlink them
- if (($j <= 5) or (( $j>=$pa-2) and ($j <= $pa+2)) or ($j >= $NA-2))
- echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '?page=newstatpress/newstatpress.php&newstatpress_action='.$action.'&pp=' . $pp . '&pa='. $j . '">' . $j . '</a> ';
- else {
- if ($GUIL1 == FALSE) echo "... "; $GUIL1 = TRUE;
- if (($j == $pa+4) and ($GUIL2 == FALSE)) {
- echo " ... ";
- $GUIL2 = TRUE;
- }
- // suspension points writed
- }
- }
- }
- }
- }
- }
- /**
- * Get page period taken in statpress-visitors
- */
- function newstatpress_page_periode() {
- // pp is the display page periode
- if(isset($_GET['pp'])) {
- // Get Current page periode from URL
- $periode = $_GET['pp'];
- if($periode <= 0)
- // Periode is less than 0 then set it to 1
- $periode = 1;
- } else
- // URL does not show the page set it to 1
- $periode = 1;
- return $periode;
- }
- /**
- * Get page post taken in statprss-visitors
- */
- function newstatpress_page_posts() {
- global $wpdb;
- // pa is the display pages Articles
- if(isset($_GET['pa'])) {
- // Get Current page Articles from URL
- $pageA = $_GET['pa'];
- if($pageA <= 0)
- // Article is less than 0 then set it to 1
- $pageA = 1;
- } else
- // URL does not show the Article set it to 1
- $pageA = 1;
- return $pageA;
- }
- /**
- * New spy function taken in statpress-visitors
- */
- function iriNewStatPressNewSpy() {
- global $wpdb;
- $action="newspy";
- $table_name = $wpdb->prefix . "statpress";
-
- // number of IP or bot by page
- $LIMIT = get_option('newstatpress_ip_per_page_newspy');
- $LIMIT_PROOF = get_option('newstatpress_visits_per_ip_newspy');
- if ($LIMIT == 0) $LIMIT = 20;
- if ($LIMIT_PROOF == 0) $LIMIT_PROOF = 20;
- $pp = newstatpress_page_periode();
- // Number of distinct ip (unique visitors)
- $NumIP = $wpdb->get_var("
- SELECT count(distinct ip)
- FROM $table_name
- WHERE spider=''"
- );
- $NP = ceil($NumIP/$LIMIT);
- $LimitValue = ($pp * $LIMIT) - $LIMIT;
-
- $sql = "
- SELECT *
- FROM $table_name as T1
- JOIN
- (SELECT max(id) as MaxId,min(id) as MinId,ip, nation
- FROM $table_name
- WHERE spider=''
- GROUP BY ip
- ORDER BY MaxId
- DESC LIMIT $LimitValue, $LIMIT ) as T2
- ON T1.ip = T2.ip
- WHERE id BETWEEN MinId AND MaxId
- ORDER BY MaxId DESC, id DESC
- ";
- $qry = $wpdb->get_results($sql);
- echo "<div class='wrap'><h2>" . __('Visitor Spy', 'newstatpress') . "</h2>";
- ?>
- <script>
- function ttogle(thediv){
- if (document.getElementById(thediv).style.display=="inline") {
- document.getElementById(thediv).style.display="none"
- } else {document.getElementById(thediv).style.display="inline"}
- }
- </script>
- <?php
- $ip = 0;
- $num_row=0;
- echo'<div id="paginating" align="center">';
- newstatpress_print_pp_link($NP,$pp,$action);
- echo'</div><table id="mainspytab" name="mainspytab" width="99%" border="0" cellspacing="0" cellpadding="4">';
- foreach ($qry as $rk) {
- // Visitor Spy
- if ($ip <> $rk->ip) {
- //this is the first time these ip appear, print informations
- echo "<tr><td colspan='2' bgcolor='#dedede'><div align='left'>";
- $title='';
- $id ='';
- ///if ($rk->country <> '') {
- /// $img=strtolower($rk->country).".png";
- /// $lines = file(ABSPATH.'wp-content/plugins/'.dirname(dirname(dirname(plugin_basename(__FILE__)))) .'/def/domain.dat');
- /// foreach($lines as $line_num => $country) {
- /// list($id,$title)=explode("|",$country);
- /// if($id===strtolower($rk->country)) break;
- /// }
- /// echo "http country <IMG style='border:0px;height:16px;' alt='".$title."' title='".$title."' SRC='" .plugins_url('newstatpress/images/domain/'.$img, dirname(dirname(dirname(__FILE__)))). "'> ";
- ///} else
- if($rk->nation <> '') {
- // the nation exist
- $img=strtolower($rk->nation).".png";
- $lines = file(ABSPATH.'wp-content/plugins/'.dirname(plugin_basename(__FILE__)).'/def/domain.dat');
- foreach($lines as $line_num => $nation) {
- list($id,$title)=explode("|",$nation);
- if($id===$rk->nation) break;
- }
- print "".__('Http domain', 'newstatpress')." <IMG style='border:0px;height:16px;' alt='".$title."' title='".$title."' SRC='" .plugins_url('newstatpress/images/domain/'.$img, dirname(plugin_basename(__FILE__))). "'> ";
- } else {
- $ch = curl_init('http://api.hostip.info/country.php?ip='.$rk->ip);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- $output .=".png";
- $output = strtolower($output);
- curl_close($ch);
- print "".__('Hostip country','newstatpress'). "<IMG style='border:0px;width:18;height:12px;' alt='".$title."' title='".$title."' SRC='" .plugins_url('newstatpress/images/domain/'.$output, dirname(plugin_basename(__FILE__))). "'> ";
- }
- print "<strong><span><font size='2' color='#7b7b7b'>".$rk->ip."</font></span></strong> ";
- print "<span style='color:#006dca;cursor:pointer;border-bottom:1px dotted #AFD5F9;font-size:8pt;' onClick=ttogle('".$rk->ip."');>".__('more info','newstatpress')."</s…
Large files files are truncated, but you can click here to view the full file