-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy path_history.php
executable file
·94 lines (85 loc) · 3.05 KB
/
_history.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/*
* History page, record subscribers's messages while send to this plugin.
*
*/
require_once( 'class-wpwsl-history-table.php' );
if (isset($_GET['clear_all_records'])) {
global $wpdb;
$db_table = DB_TABLE_WPWSL_HISTORY;
$wpdb->query("delete from $db_table");
}
function delete_record($id)
{
global $wpdb;
$db_table = DB_TABLE_WPWSL_HISTORY;
$wpdb->query("delete from $db_table where id='$id'");
}
if (isset($_GET['action']) && isset($_GET['action2'])) {
if ($_GET['action'] == 'delete' || $_GET['action2'] == 'delete') {
if (isset($_GET['record'])) {
foreach ($_GET['record'] as $r) {
delete_record($r);
}
}
}
}
function results_order()
{
$orderby = (!empty($_GET['orderby']) ) ? $_GET['orderby'] : 'time';
$order = (!empty($_GET['order']) ) ? $_GET['order'] : 'desc';
return $orderby . " " . $order;
}
$order = results_order();
$paged = WpwslHelper::get('paged', 1);
$start = ($paged - 1) * SELECT_ROWS_AMOUNT;
global $wpdb;
//history
$db_table = DB_TABLE_WPWSL_HISTORY;
$match = $wpdb->get_results("select count(id) as count from $db_table where is_match = 'y';");
$unmatch = $wpdb->get_results("select count(id) as count from $db_table where is_match = 'n';");
$match = $match ? $match[0]->count : 0;
$unmatch = $unmatch ? $unmatch[0]->count : 0;
$unmatch_ = $unmatch == 0 && $match == 0 ? 0 : $unmatch;
$unmatch = $unmatch == 0 && $match == 0 ? 1 : $unmatch;
//records
$raw = $wpdb->get_results("select id,openid,keyword,is_match,time from $db_table order by $order limit $start," . SELECT_ROWS_AMOUNT);
$data = [];
foreach ($raw as $d) {
$d->is_match = $d->is_match == "y" ? __("Yes", "WPWSL") : "<span style='color:red;'>" . __("No", "WPWSL") . "<span>";
$data[] = [
'ID' => $d->id,
'openid' => $d->openid,
'keyword' => $d->keyword,
'is_match' => $d->is_match,
'time' => $d->time];
}
//Prepare Table of elements
$wp_list_table = new WPWSL_History_Table($data);
$wp_list_table->prepare_items();
//Load content
require_once( 'content.php' );
?>
<link href="<?php echo WPWSL_PLUGIN_URL; ?>/css/style.css" rel="stylesheet">
<div class="wrap">
<?php echo $content['header']; ?>
<hr>
<h2>
<?php _e('Statistics', 'WPWSL'); ?>
<form action="" method="get" style="float:right;">
<input type="hidden" name="page" value="wpwsl-history-page" />
<button id="clear_all_records" type="submit" name="clear_all_records" value="rows" class="add-new-h2"><?php _e("Clear All Records", "WPWSL"); ?></button>
</form>
</h2>
<br>
<form action="" method="get">
<input type="hidden" name="page" value="<?php echo WPWSL_HISTORY_PAGE; ?>" />
<input type="hidden" name="per_page" value="<?php _e($per_page); ?>" />
<?php $wp_list_table->display(); ?>
</form>
</div>
<script>document.getElementById("clear_all_records").onclick = function () {
var r = confirm("<?php _e('Empty all the records ?', 'WPWSL'); ?>");
if (!r)
return false;
}</script>