Sync plugins from current page
Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<div class="wrap wps-wrap">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Database Setup', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="index-submit"><?php _e( 'Re-run Install:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input id="install-submit" class="button button-primary" type="button" value="<?php _e( 'Install Now!', 'wp-statistics' ); ?>" name="install-submit" onclick="location.href=document.URL+'&install=1&tab=database'">
|
||||
<p class="description"><?php _e( 'If for some reason your installation of WP Statistics is missing the database tables or other core items, this will re-execute the install process.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Database Index', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="index-submit"><?php _e( 'Countries:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<?php
|
||||
GLOBAL $wpdb, $WP_Statistics;
|
||||
$wp_prefix = $wpdb->prefix;
|
||||
|
||||
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
||||
|
||||
// Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
|
||||
$result = $wpdb->query(
|
||||
"SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip_agent'"
|
||||
);
|
||||
|
||||
// Note, the result will be the number of fields contained in the index, so in our case 5.
|
||||
if ( $result != 5 ) {
|
||||
$dbupdates['date_ip_agent'] = true;
|
||||
?>
|
||||
<input id="index-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="index-submit" onclick="location.href=document.URL+'&index=1&tab=database'">
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ) . ' ' . __( 'To create the index on the older installs duplicate entries must be deleted first.', 'wp-statistics' ) . ' ' . __( 'Clicking "Update Now" will scan the vistitors table, delete duplicate entries and add the index.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
} else {
|
||||
$dbupdates['date_ip_agent'] = false;
|
||||
?>
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visitors table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="index-submit"><?php _e( 'Visits Table:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
GLOBAL $wpdb;
|
||||
$wp_prefix = $wpdb->prefix;
|
||||
|
||||
// Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
|
||||
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
|
||||
|
||||
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
||||
if ( $result != 1 ) {
|
||||
$dbupdates['unique_date'] = true;
|
||||
?>
|
||||
<input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="visit-submit" onclick="location.href=document.URL+'&visits=1&tab=database'">
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ) . ' ' . __( 'To create the index on the older installs duplicate entries must be deleted first.', 'wp-statistics' ) . ' ' . __( 'Clicking "Update Now" will scan the vistits table, delete duplicate entries and add the index.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visits table.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
} else {
|
||||
$dbupdates['unique_date'] = false;
|
||||
?>
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics allow for duplicate entries in the visits table in a corner case.', 'wp-statistics' ) . ' ' . __( 'Newer installs protect against this with a unique index on the table.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
||||
?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Search Table', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="index-submit"><?php _e( 'Convert:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
||||
if ( $WP_Statistics->get_option( 'search_converted' ) != 1 ) {
|
||||
?>
|
||||
<input id="visits-submit" class="button button-primary" type="button" value="<?php _e( 'Convert Now!', 'wp-statistics' ); ?>" name="search-submit" onclick="location.href=document.URL+'&search=1&tab=database'">
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets.', 'wp-statistics' ) . ' ' . __( 'A new table has been created to hold this information in a more scalable fashion, however the old data must first be converted to the new format before it can be used.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'This operation could take a long time on installs with many rows in the visitors table.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p class="description"><?php echo __( 'Older installs of WP Statistics store details of searches in the visitors table which can become a performance issue on large datasets.', 'wp-statistics' ) . ' ' . __( 'A new table has been created to hold this information in a more scalable fashion.', 'wp-statistics' ); ?></p>
|
||||
<p class="description"><?php _e( 'Congratulations, your installation is already up to date, nothing to do.', 'wp-statistics' ); ?></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,63 @@
|
||||
<div class="wrap wps-wrap">
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="wps_export" value="true">
|
||||
<?php wp_nonce_field( 'wp_statistics_export_nonce', 'wps_export_file' ); ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Export', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="table-to-export"><?php _e( 'Export from:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<select dir="ltr" id="table-to-export" name="table-to-export" required>
|
||||
<option value=""><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
||||
<?php
|
||||
foreach ( wp_statistics_db_table( 'all', array( 'historical', 'visitor_relationships' ) ) as $tbl_key => $tbl_name ) {
|
||||
echo '<option value="' . $tbl_key . '">' . $tbl_name . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<p class="description"><?php _e( 'Select the table for the output file.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="export-file-type"><?php _e( 'Export To:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<select dir="ltr" id="export-file-type" name="export-file-type" required>
|
||||
<option value=""><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
||||
<option value="xml">XML</option>
|
||||
<option value="csv">CSV</option>
|
||||
<option value="tsv">TSV</option>
|
||||
</select>
|
||||
|
||||
<p class="description"><?php _e( 'Select the output file type.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="export-headers"><?php _e( 'Include Header Row:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input id="export-headers" type="checkbox" value="1" name="export-headers">
|
||||
<p class="description"><?php _e( 'Include a header row as the first line of the exported file.', 'wp-statistics' ); ?></p>
|
||||
<?php submit_button( __( 'Start Now!', 'wp-statistics' ), 'primary', 'export-file-submit' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// Get the historical number of visitors to the site
|
||||
$historical_visitors = $WP_Statistics->Get_Historical_Data( 'visitors' );
|
||||
|
||||
// Get the historical number of visits to the site
|
||||
$historical_visits = $WP_Statistics->Get_Historical_Data( 'visits' );
|
||||
|
||||
?>
|
||||
<div class="wrap wps-wrap">
|
||||
<form id="wps_historical_form" method="post">
|
||||
<?php wp_nonce_field( 'historical_form', 'wp-statistics-nonce' ); ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Historical Values', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top" id="wps_historical_purge" style="display: none">
|
||||
<th scope="row" colspan=2>
|
||||
<?php _e(
|
||||
'Note: As you have just purged the database you must reload this page for these numbers to be correct.',
|
||||
'wp-statistics'
|
||||
); ?>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Visitors', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input type="text" size="10" value="<?php echo $historical_visitors; ?>"
|
||||
id="wps_historical_visitors" name="wps_historical_visitors">
|
||||
|
||||
<p class="description"><?php echo sprintf(
|
||||
__(
|
||||
'Number of historical number of visitors to the site (current value is %s).',
|
||||
'wp-statistics'
|
||||
),
|
||||
number_format_i18n( $historical_visitors )
|
||||
); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Visits', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input type="text" size="10" value="<?php echo $historical_visits; ?>" id="wps_historical_visits"
|
||||
name="wps_historical_visits">
|
||||
|
||||
<p class="description"><?php echo sprintf(
|
||||
__(
|
||||
'Number of historical number of visits to the site (current value is %s).',
|
||||
'wp-statistics'
|
||||
),
|
||||
number_format_i18n( $historical_visits )
|
||||
); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td colspan=2>
|
||||
<input id="historical-submit" class="button button-primary" type="submit"
|
||||
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="historical-submit"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,341 @@
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#purge-data-submit").click(function () {
|
||||
|
||||
var action = jQuery('#purge-data').val();
|
||||
|
||||
if (action == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#purge-data-submit").attr("disabled", "disabled");
|
||||
jQuery("#purge-data-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_purge_data',
|
||||
'purge-days': action,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#purge-data-status").html("");
|
||||
jQuery("#purge-data-result").html(result);
|
||||
jQuery("#purge-data-submit").removeAttr("disabled");
|
||||
jQuery("#wps_historical_purge").show();
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#purge-visitor-hits-submit").click(function () {
|
||||
|
||||
var action = jQuery('#purge-visitor-hits').val();
|
||||
|
||||
if (action == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#purge-visitor-hits-submit").attr("disabled", "disabled");
|
||||
jQuery("#purge-visitor-hits-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_purge_visitor_hits',
|
||||
'purge-hits': action,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#purge-visitor-hits-status").html("");
|
||||
jQuery("#purge-visitor-hits-result").html(result);
|
||||
jQuery("#purge-visitor-hits-submit").removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#empty-table-submit").click(function () {
|
||||
|
||||
var action = jQuery('#empty-table').val();
|
||||
|
||||
if (action == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#empty-table-submit").attr("disabled", "disabled");
|
||||
jQuery("#empty-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_empty_table',
|
||||
'table-name': action,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#empty-status").html("");
|
||||
jQuery("#empty-result").html(result);
|
||||
jQuery("#empty-table-submit").removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#delete-agents-submit").click(function () {
|
||||
|
||||
var action = jQuery('#delete-agent').val();
|
||||
|
||||
if (action == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#delete-agents-submit").attr("disabled", "disabled");
|
||||
jQuery("#delete-agents-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_delete_agents',
|
||||
'agent-name': action,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#delete-agents-status").html("");
|
||||
jQuery("#delete-agents-result").html(result);
|
||||
jQuery("#delete-agents-submit").removeAttr("disabled");
|
||||
aid = data['agent-name'].replace(/[^a-zA-Z]/g, "");
|
||||
jQuery("#agent-" + aid + "-id").remove();
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#delete-platforms-submit").click(function () {
|
||||
|
||||
var action = jQuery('#delete-platform').val();
|
||||
|
||||
if (action == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#delete-platforms-submit").attr("disabled", "disabled");
|
||||
jQuery("#delete-platforms-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_delete_platforms',
|
||||
'platform-name': action,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#delete-platforms-status").html("");
|
||||
jQuery("#delete-platforms-result").html(result);
|
||||
jQuery("#delete-platforms-submit").removeAttr("disabled");
|
||||
pid = data['platform-name'].replace(/[^a-zA-Z]/g, "");
|
||||
jQuery("#platform-" + pid + "-id").remove();
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#delete-ip-submit").click(function () {
|
||||
|
||||
var value = jQuery('#delete-ip').val();
|
||||
|
||||
if (value == 0)
|
||||
return false;
|
||||
|
||||
var agree = confirm('<?php _e( 'Are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (!agree)
|
||||
return false;
|
||||
|
||||
jQuery("#delete-ip-submit").attr("disabled", "disabled");
|
||||
jQuery("#delete-ip-status").html("<img src='<?php echo plugins_url( 'wp-statistics' ); ?>/assets/images/loading.gif'/>");
|
||||
|
||||
var data = {
|
||||
'action': 'wp_statistics_delete_ip',
|
||||
'ip-address': value,
|
||||
};
|
||||
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
data: data,
|
||||
datatype: 'json',
|
||||
})
|
||||
.always(function (result) {
|
||||
jQuery("#delete-ip-status").html("");
|
||||
jQuery("#delete-ip-result").html(result);
|
||||
jQuery("#delete-ip-submit").removeAttr("disabled");
|
||||
jQuery("#delete-ip").value('');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="wrap wps-wrap">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Data', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="empty-table"><?php _e( 'Empty Table:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<select dir="ltr" id="empty-table" name="empty-table">
|
||||
<option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
||||
<?php
|
||||
foreach ( wp_statistics_db_table( 'all', 'historical' ) as $tbl_key => $tbl_name ) {
|
||||
echo '<option value="' . $tbl_key . '">' . $tbl_name . '</option>';
|
||||
}
|
||||
?>
|
||||
<option value="all"><?php echo __( 'All', 'wp-statistics' ); ?></option>
|
||||
</select>
|
||||
|
||||
<p class="description"><?php _e( 'All data table will be lost.', 'wp-statistics' ); ?></p>
|
||||
<input id="empty-table-submit" class="button button-primary" type="submit" value="<?php _e( 'Clear now!', 'wp-statistics' ); ?>" name="empty-table-submit" Onclick="return false;"/>
|
||||
<span id="empty-status"></span>
|
||||
<div id="empty-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="purge-data"><?php _e( 'Purge records older than:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input type="text" class="small-text code" id="purge-data" name="wps_purge_data" value="365"/>
|
||||
<label for="purge-data"><?php _e( 'Days', 'wp-statistics' ); ?></label>
|
||||
|
||||
<p class="description"><?php echo __( 'Delete user statistics data older than the selected number of days.', 'wp-statistics' ) . ' ' . __( 'Minimum value is 30 days.', 'wp-statistics' ); ?></p>
|
||||
<input id="purge-data-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-data-submit" Onclick="return false;"/>
|
||||
<span id="purge-data-status"></span>
|
||||
<div id="purge-data-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="purge-visitor-hits"><?php _e( 'Purge visitors with more than:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input type="text" class="small-text code" id="purge-visitor-hits" name="wps_purge_visitor_hits" value="10"/>
|
||||
<label for="purge-visitor-hits"><?php _e( 'Hits', 'wp-statistics' ); ?></label>
|
||||
|
||||
<p class="description"><?php echo __( 'Delete user statistics data where the user has more than the defined number of hits in a day.', 'wp-statistics' ) . ' ' . __( 'This can be useful to clear up old data when your site has been hit by a bot.', 'wp-statistics' ) . ' ' . __( 'This will remove the visitor and their hits to the site, however it will not remove individual page hits as that data is not recorded on a per use basis.', 'wp-statistics' ) . ' ' . __( 'Minimum value is 10 hits.', 'wp-statistics' ); ?></p>
|
||||
<input id="purge-visitor-hits-submit" class="button button-primary" type="submit" value="<?php _e( 'Purge now!', 'wp-statistics' ); ?>" name="purge-visitor-hits-submit" Onclick="return false;"/>
|
||||
<span id="purge-visitor-hits-status"></span>
|
||||
<div id="purge-visitor-hits-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Delete User Agent Types', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="delete-agent"><?php _e( 'Delete Agents:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<select dir="ltr" id="delete-agent" name="delete-agent">
|
||||
<option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
||||
<?php
|
||||
$agents = wp_statistics_ua_list();
|
||||
|
||||
foreach ( $agents as $agent ) {
|
||||
$aid = preg_replace( "/[^a-zA-Z]/", "", $agent );
|
||||
echo "<option value='$agent' id='agent-" . $aid . "-id'>" . $agent . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<p class="description"><?php _e( 'All visitor data will be lost for this agent type.', 'wp-statistics' ); ?></p>
|
||||
<input id="delete-agents-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-agents-submit" Onclick="return false;">
|
||||
<span id="delete-agents-status"></span>
|
||||
<div id="delete-agents-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="delete-platform"><?php _e( 'Delete Platforms:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<select dir="ltr" id="delete-platform" name="delete-platform">
|
||||
<option value="0"><?php _e( 'Please select', 'wp-statistics' ); ?></option>
|
||||
<?php
|
||||
$platforms = wp_statistics_platform_list();
|
||||
|
||||
foreach ( $platforms as $platform ) {
|
||||
$pid = preg_replace( "/[^a-zA-Z]/", "", $platform );
|
||||
echo "<option value='$platform' id='platform-" . $pid . "-id'>" . $platform . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<p class="description"><?php _e( 'All visitor data will be lost for this platform type.', 'wp-statistics' ); ?></p>
|
||||
<input id="delete-platforms-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-platforms-submit" Onclick="return false;">
|
||||
<span id="delete-platforms-status"></span>
|
||||
<div id="delete-platforms-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="delete-ip"><?php _e( 'Delete IP:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input dir="ltr" id="delete-ip" type="text" name="delete-ip"/>
|
||||
|
||||
<p class="description"><?php _e( 'All visitor data will be lost for this IP.', 'wp-statistics' ); ?></p>
|
||||
<input id="delete-ip-submit" class="button button-primary" type="submit" value="<?php _e( 'Delete now!', 'wp-statistics' ); ?>" name="delete-ip-submit" Onclick="return false;">
|
||||
<span id="delete-ip-status"></span>
|
||||
<div id="delete-ip-result"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,294 @@
|
||||
<div class="wrap wps-wrap">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Resources', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo number_format_i18n( memory_get_usage() ); ?></strong> <?php _e( 'Bytes', 'wp-statistics' ); ?>
|
||||
<p class="description"><?php _e( 'Memory usage in PHP', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'PHP Memory Limit', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo ini_get( 'memory_limit' ); ?></strong>
|
||||
<p class="description"><?php _e( 'The memory limit a script is allowed to consume, set in php.ini.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
foreach ( $result as $table_name => $number_row ) {
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php echo sprintf( __( 'Number of rows in the %s table', 'wp-statistics' ), '<code>' . $table_name . '</code>' ); ?>
|
||||
:
|
||||
</th>
|
||||
<td>
|
||||
<strong><?php echo number_format_i18n( $number_row ); ?></strong> <?php echo _n( 'Row', 'Rows', number_format_i18n( $number_row ), 'wp-statistics' ); ?>
|
||||
<p class="description"><?php _e( 'Number of rows', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Version Info', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'WP Statistics Version', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo WP_Statistics::$reg['version']; ?></strong>
|
||||
<p class="description"><?php _e( 'The WP Statistics version you are running.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'PHP Version', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo phpversion(); ?></strong>
|
||||
<p class="description"><?php _e( 'The PHP version you are running.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'PHP Safe Mode', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( ini_get( 'safe_mode' ) ) {
|
||||
_e( 'Yes', 'wp-statistics' );
|
||||
} else {
|
||||
_e( 'No', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'Is PHP Safe Mode active. The GeoIP code is not supported in Safe Mode.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'PHP IPv6 Enabled', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( defined( 'AF_INET6' ) ) {
|
||||
_e( 'Yes', 'wp-statistics' );
|
||||
} else {
|
||||
_e( 'No', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'Is PHP compiled with IPv6 support. You may see warning messages in your PHP log if it is not and you receive HTTP headers with IPv6 addresses in them.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'jQuery Version', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong>
|
||||
<script type="text/javascript">document.write(jQuery().jquery);</script>
|
||||
</strong>
|
||||
|
||||
<p class="description"><?php _e( 'The jQuery version you are running.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'cURL Version', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( function_exists( 'curl_version' ) ) {
|
||||
$curl_ver = curl_version();
|
||||
echo $curl_ver['version'];
|
||||
} else {
|
||||
_e( 'cURL not installed', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e(
|
||||
'The PHP cURL Extension version you are running. cURL is required for the GeoIP code, if it is not installed GeoIP will be disabled.',
|
||||
'wp-statistics'
|
||||
); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Zlib gzopen()', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( function_exists( 'gzopen' ) ) {
|
||||
_e( 'Installed', 'wp-statistics' );
|
||||
} else {
|
||||
_e( 'Not installed', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'If the gzopen() function is installed. The gzopen() function is required for the GeoIP database to be downloaded successfully.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'GMP PHP extension', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( extension_loaded( 'gmp' ) ) {
|
||||
_e( 'Installed', 'wp-statistics' );
|
||||
} else {
|
||||
_e( 'Not installed', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'If the GMP Math PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'BCMath PHP extension', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php if ( extension_loaded( 'bcmath' ) ) {
|
||||
_e( 'Installed', 'wp-statistics' );
|
||||
} else {
|
||||
_e( 'Not installed', 'wp-statistics' );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'If the BCMath PHP extension is loaded, either GMP or BCMath is required for the GeoIP database to be read successfully.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'File Info', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'GeoIP Database', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php $upload_dir = wp_upload_dir();
|
||||
$GeoIP_filename = $upload_dir['basedir'] . '/wp-statistics/GeoLite2-Country.mmdb';
|
||||
$GeoIP_filedate = @filemtime( $GeoIP_filename );
|
||||
|
||||
if ( $GeoIP_filedate === false ) {
|
||||
_e( 'Database file does not exist.', 'wp-statistics' );
|
||||
} else {
|
||||
echo size_format( @filesize( $GeoIP_filename ), 2 ) . __( ', created on ', 'wp-statistics' ) . date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $GeoIP_filedate );
|
||||
} ?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'The file size and date of the GeoIP database.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Client Info', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Client IP', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo $WP_Statistics->get_IP(); ?></strong>
|
||||
<p class="description"><?php _e( 'The client IP address.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'User Agent', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo htmlentities( $_SERVER['HTTP_USER_AGENT'], ENT_QUOTES ); ?></strong>
|
||||
<p class="description"><?php _e( 'The client user agent string.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Browser', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php $agent = $WP_Statistics->get_UserAgent();
|
||||
echo $agent['browser'];
|
||||
?></strong>
|
||||
|
||||
<p class="description"><?php _e( 'The detected client browser.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Version', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo $agent['version']; ?></strong>
|
||||
<p class="description"><?php _e( 'The detected client browser version.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<?php _e( 'Platform', 'wp-statistics' ); ?>:
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<strong><?php echo $agent['platform']; ?></strong>
|
||||
<p class="description"><?php _e( 'The detected client platform.', 'wp-statistics' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'Server Info', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$list = array( 'SERVER_SOFTWARE', 'HTTP_HOST', 'REMOTE_ADDR', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'HTTP_X_REAL_IP', );
|
||||
foreach ( $list as $server ) {
|
||||
if ( isset( $_SERVER[ $server ] ) ) {
|
||||
echo '<tr valign="top">
|
||||
<th scope="row">
|
||||
' . $server . '
|
||||
</th>
|
||||
<td>
|
||||
<strong>' . $_SERVER[ $server ] . '</strong>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,58 @@
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#hash-ips-submit").click(function () {
|
||||
var agree = confirm('<?php _e( 'This will replace all IP addresses in the database with hash values and cannot be undo, are you sure?', 'wp-statistics' ); ?>');
|
||||
|
||||
if (agree)
|
||||
location.href = document.URL + '&tab=updates&hash-ips=1';
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="wrap wps-wrap">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'GeoIP Options', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="populate-submit"><?php _e( 'Countries:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input id="populate-submit" class="button button-primary" type="button"
|
||||
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="populate-submit"
|
||||
onclick="location.href=document.URL+'&tab=updates&populate=1'">
|
||||
|
||||
<p class="description"><?php _e(
|
||||
'Updates any unknown location data in the database, this may take a while',
|
||||
'wp-statistics'
|
||||
); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row" colspan="2"><h3><?php _e( 'IP Addresses', 'wp-statistics' ); ?></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="populate-submit"><?php _e( 'Hash IP Addresses:', 'wp-statistics' ); ?></label>
|
||||
</th>
|
||||
|
||||
<td>
|
||||
<input id="hash-ips-submit" class="button button-primary" type="button"
|
||||
value="<?php _e( 'Update Now!', 'wp-statistics' ); ?>" name="hash-ips-submit">
|
||||
|
||||
<p class="description"><?php _e(
|
||||
'Replace IP addresses in the database with hash values, you will not be able to recover the IP addresses in the future to populate location information afterwards and this may take a while',
|
||||
'wp-statistics'
|
||||
); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
global $wpdb, $WP_Statistics;
|
||||
$wp_prefix = $wpdb->prefix;
|
||||
|
||||
if ( ! is_super_admin() ) {
|
||||
wp_die( __( 'Access denied!', 'wp-statistics' ) );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'populate', $_GET ) ) {
|
||||
if ( intval( $_GET['populate'] ) == 1 ) {
|
||||
echo WP_Statistics_Updates::populate_geoip_info();
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'hash-ips', $_GET ) ) {
|
||||
if ( intval( $_GET['hash-ips'] ) == 1 ) {
|
||||
// Generate a random salt
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$randomString = '';
|
||||
for ( $i = 0; $i < 50; $i ++ ) {
|
||||
$randomString .= $characters[ rand( 0, strlen( $characters ) - 1 ) ];
|
||||
}
|
||||
|
||||
// Get the rows from the Visitors table.
|
||||
$result = $wpdb->get_results( "SELECT DISTINCT ip FROM {$wp_prefix}statistics_visitor" );
|
||||
|
||||
foreach ( $result as $row ) {
|
||||
if ( substr( $row->ip, 0, 6 ) != '#hash#' ) {
|
||||
$wpdb->update(
|
||||
$wp_prefix . "statistics_visitor",
|
||||
array(
|
||||
'ip' => '#hash#' . sha1( $row->ip . $randomString ),
|
||||
),
|
||||
array(
|
||||
'ip' => $row->ip,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<div class='updated settings-error'><p><strong>" . __( 'IP Addresses replaced with hash values.', 'wp-statistics' ) . "</strong></p></div>";
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'install', $_GET ) ) {
|
||||
if ( intval( $_GET['install'] ) == 1 ) {
|
||||
$WPS_Installed = "1.0";
|
||||
new WP_Statistics_Install( $WP_Statistics );
|
||||
echo "<div class='updated settings-error'><p><strong>" . __( 'Install routine complete.', 'wp-statistics' ) . "</strong></p></div>";
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'index', $_GET ) ) {
|
||||
if ( intval( $_GET['index'] ) == 1 ) {
|
||||
// Check the number of index's on the visitors table, if it's only 5 we need to check for duplicate entries and remove them
|
||||
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visitor WHERE Key_name = 'date_ip'" );
|
||||
|
||||
if ( $result != 5 ) {
|
||||
// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
|
||||
$result = $wpdb->get_results(
|
||||
"SELECT ID, last_counter, ip FROM {$wp_prefix}statistics_visitor ORDER BY last_counter, ip"
|
||||
);
|
||||
|
||||
// Setup the inital values.
|
||||
$lastrow = array( 'last_counter' => '', 'ip' => '' );
|
||||
$deleterows = array();
|
||||
|
||||
// Ok, now iterate over the results.
|
||||
foreach ( $result as $row ) {
|
||||
// if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
|
||||
if ( $row->last_counter == $lastrow['last_counter'] && $row->ip == $lastrow['ip'] ) {
|
||||
$deleterows[] .= $row->ID;
|
||||
}
|
||||
|
||||
// Update the last row data.
|
||||
$lastrow['last_counter'] = $row->last_counter;
|
||||
$lastrow['ip'] = $row->ip;
|
||||
}
|
||||
|
||||
// Now do the actual deletions.
|
||||
foreach ( $deleterows as $row ) {
|
||||
$wpdb->delete( $wp_prefix . 'statistics_visitor', array( 'ID' => $row ) );
|
||||
}
|
||||
|
||||
// The table should be ready to be updated now with the new index, so let's do it.
|
||||
$result = $wpdb->get_results( "ALTER TABLE " . $wp_prefix . 'statistics_visitor' . " ADD UNIQUE `date_ip_agent` ( `last_counter`, `ip`, `agent` (75), `platform` (75), `version` (75) )" );
|
||||
|
||||
// We might have an old index left over from 7.1-7.3 so lets make sure to delete it.
|
||||
$wpdb->query( "DROP INDEX `date_ip` ON {$wp_prefix}statistics_visitor" );
|
||||
|
||||
// Record in the options that we've done this update.
|
||||
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
||||
$dbupdates['date_ip_agent'] = false;
|
||||
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'visits', $_GET ) ) {
|
||||
if ( intval( $_GET['visits'] ) == 1 ) {
|
||||
// Check the number of index's on the visits table, if it's only 5 we need to check for duplicate entries and remove them
|
||||
$result = $wpdb->query( "SHOW INDEX FROM {$wp_prefix}statistics_visit WHERE Key_name = 'unique_date'" );
|
||||
|
||||
// Note, the result will be the number of fields contained in the index, so in our case 1.
|
||||
if ( $result != 1 ) {
|
||||
// We have to loop through all the rows in the visitors table to check for duplicates that may have been created in error.
|
||||
$result = $wpdb->get_results(
|
||||
"SELECT ID, last_counter, visit FROM {$wp_prefix}statistics_visit ORDER BY last_counter, visit DESC"
|
||||
);
|
||||
|
||||
// Setup the initial values.
|
||||
$lastrow = array( 'last_counter' => '', 'visit' => 0, 'id' => 0 );
|
||||
$deleterows = array();
|
||||
|
||||
// Ok, now iterate over the results.
|
||||
foreach ( $result as $row ) {
|
||||
// if the last_counter (the date) and IP is the same as the last row, add the row to be deleted.
|
||||
if ( $row->last_counter == $lastrow['last_counter'] ) {
|
||||
$deleterows[] .= $row->ID;
|
||||
}
|
||||
|
||||
// Update the lastrow data.
|
||||
$lastrow['last_counter'] = $row->last_counter;
|
||||
$lastrow['id'] = $row->ID;
|
||||
$lastrow['visit'] = $row->visit;
|
||||
}
|
||||
|
||||
// Now do the acutal deletions.
|
||||
foreach ( $deleterows as $row ) {
|
||||
$wpdb->delete( $wp_prefix . 'statistics_visit', array( 'ID' => $row ) );
|
||||
}
|
||||
|
||||
// The table should be ready to be updated now with the new index, so let's do it.
|
||||
$result = $wpdb->get_results(
|
||||
"ALTER TABLE " . $wp_prefix . 'statistics_visit' . " ADD UNIQUE `unique_date` ( `last_counter` )"
|
||||
);
|
||||
|
||||
// Record in the options that we've done this update.
|
||||
$dbupdates = $WP_Statistics->get_option( 'pending_db_updates' );
|
||||
$dbupdates['unique_date'] = false;
|
||||
$WP_Statistics->update_option( 'pending_db_updates', $dbupdates );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'historical-submit', $_POST ) ) {
|
||||
if ( array_key_exists( 'wps_historical_visitors', $_POST ) ) {
|
||||
$result = $wpdb->update(
|
||||
$wp_prefix . "statistics_historical",
|
||||
array( 'value' => $_POST['wps_historical_visitors'] ),
|
||||
array( 'category' => 'visitors' )
|
||||
);
|
||||
|
||||
if ( $result == 0 ) {
|
||||
$result = $wpdb->insert(
|
||||
$wp_prefix . "statistics_historical",
|
||||
array(
|
||||
'value' => $_POST['wps_historical_visitors'],
|
||||
'category' => 'visitors',
|
||||
'page_id' => - 1,
|
||||
'uri' => '-1',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'wps_historical_visits', $_POST ) ) {
|
||||
$result = $wpdb->update(
|
||||
$wp_prefix . "statistics_historical",
|
||||
array( 'value' => $_POST['wps_historical_visits'] ),
|
||||
array( 'category' => 'visits' )
|
||||
);
|
||||
|
||||
if ( $result == 0 ) {
|
||||
$result = $wpdb->insert(
|
||||
$wp_prefix . "statistics_historical",
|
||||
array(
|
||||
'value' => $_POST['wps_historical_visits'],
|
||||
'category' => 'visits',
|
||||
'page_id' => - 2,
|
||||
'uri' => '-2',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'search', $_GET ) ) {
|
||||
|
||||
// Make sure we get all the search engines, even the ones the disabled ones.
|
||||
$se_list = wp_statistics_searchengine_list();
|
||||
$total = 0;
|
||||
$limitsize = 10000;
|
||||
|
||||
foreach ( $se_list as $key => $se ) {
|
||||
$sql = wp_statistics_searchengine_query( $key );
|
||||
$rowcount = $wpdb->get_var( "SELECT count(*) FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql}" );
|
||||
$offset = 0;
|
||||
|
||||
while ( $rowcount > 0 ) {
|
||||
$result = $wpdb->get_results(
|
||||
"SELECT * FROM `{$wpdb->prefix}statistics_visitor` WHERE {$sql} LIMIT {$offset}, {$limitsize}"
|
||||
);
|
||||
foreach ( $result as $row ) {
|
||||
$parts = parse_url( $row->referred );
|
||||
$data['last_counter'] = $row->last_counter;
|
||||
$data['engine'] = $key;
|
||||
$data['host'] = $parts['host'];
|
||||
$data['words'] = $WP_Statistics->Search_Engine_QueryString( $row->referred );
|
||||
$data['visitor'] = $row->ID;
|
||||
|
||||
if ( $data['words'] == 'No search query found!' ) {
|
||||
$data['words'] = '';
|
||||
}
|
||||
|
||||
$wpdb->insert( $wpdb->prefix . 'statistics_search', $data );
|
||||
$total ++;
|
||||
}
|
||||
|
||||
$rowcount -= $limitsize;
|
||||
$offset += $limitsize;
|
||||
}
|
||||
}
|
||||
|
||||
$WP_Statistics->update_option( 'search_converted', 1 );
|
||||
echo "<div class='updated settings-error'><p><strong>" . sprintf( __( 'Search table conversion complete, %d rows added.', 'wp-statistics' ), $total ) . "</strong></p></div>";
|
||||
}
|
||||
?>
|
||||
<div class="wrap wps-wrap wp-statistics-settings">
|
||||
<?php WP_Statistics_Admin_Pages::show_page_title( __( 'Optimization', 'wp-statistics' ) ); ?>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div class="wp-list-table widefat widefat">
|
||||
<div class="wp-statistics-container">
|
||||
<ul class="tabs">
|
||||
<li class="tab-link current" data-tab="resources"><?php _e( 'Resources/Information', 'wp-statistics' ); ?></li>
|
||||
<li class="tab-link" data-tab="export"><?php _e( 'Export', 'wp-statistics' ); ?></li>
|
||||
<li class="tab-link" data-tab="purging"><?php _e( 'Purging', 'wp-statistics' ); ?></li>
|
||||
<li class="tab-link" data-tab="database"><?php _e( 'Database', 'wp-statistics' ); ?></li>
|
||||
<li class="tab-link" data-tab="updates"><?php _e( 'Updates', 'wp-statistics' ); ?></li>
|
||||
<li class="tab-link" data-tab="historical"><?php _e( 'Historical', 'wp-statistics' ); ?></li>
|
||||
</ul>
|
||||
|
||||
<div id="resources" class="tab-content current">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-resources.php' ); ?>
|
||||
</div>
|
||||
<div id="export" class="tab-content">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-export.php' ); ?>
|
||||
</div>
|
||||
<div id="purging" class="tab-content">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-purging.php' ); ?>
|
||||
</div>
|
||||
<div id="database" class="tab-content">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-database.php' ); ?>
|
||||
</div>
|
||||
<div id="updates" class="tab-content">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-updates.php' ); ?>
|
||||
</div>
|
||||
<div id="historical" class="tab-content">
|
||||
<?php include( WP_Statistics::$reg['plugin-dir'] . 'includes/optimization/tabs/wps-optimization-historical.php' ); ?>
|
||||
</div>
|
||||
</div><!-- container -->
|
||||
</div>
|
||||
|
||||
<?php include WP_Statistics::$reg['plugin-dir'] . 'includes/templates/postbox.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user