Version Description
- new feature, User Role Exclusion From Statistics
Download this release
Release Info
Developer | osamaesh |
Plugin | Visitors Traffic Real Time Statistics |
Version | 4.8 |
Comparing to | |
See all releases |
Code changes from version 4.6 to 4.8
- Visitors-Traffic-Real-Time-Statistics.php +1 -1
- ahc_help.php +32 -21
- ahc_settings.php +257 -210
- css/custom.css +89 -0
- functions.php +1413 -1422
- overview.php +777 -754
- readme.txt +10 -3
Visitors-Traffic-Real-Time-Statistics.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visitor Traffic Real Time Statistics
|
|
4 |
Description: Hits counter that shows analytical numbers of your WordPress site visitors and hits.
|
5 |
Author: wp-buy
|
6 |
Author URI: https://www.wp-buy.com/
|
7 |
-
Version: 4.
|
8 |
Text Domain: visitors-traffic-real-time-statistics
|
9 |
Domain Path: /languages
|
10 |
*/
|
4 |
Description: Hits counter that shows analytical numbers of your WordPress site visitors and hits.
|
5 |
Author: wp-buy
|
6 |
Author URI: https://www.wp-buy.com/
|
7 |
+
Version: 4.8
|
8 |
Text Domain: visitors-traffic-real-time-statistics
|
9 |
Domain Path: /languages
|
10 |
*/
|
ahc_help.php
CHANGED
@@ -1,37 +1,48 @@
|
|
1 |
-
|
2 |
<script language="javascript" type="text/javascript">
|
3 |
-
function imgFlagError(image){
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
}
|
8 |
</script>
|
9 |
|
10 |
|
11 |
|
12 |
<div class="ahc_main_container">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
<
|
15 |
-
<
|
16 |
-
|
17 |
-
|
18 |
-
<p>wp-buy is a software development company that provides IT solutions to successfully improving your business performance.<br> We are a team working at wp-buy.com and dishing out absolute awesomeness in the form of WordPress plugins and themes.<br>Our brains are plump with theme & plugin ideas.</p>
|
19 |
-
</div>
|
20 |
|
21 |
-
|
22 |
-
<
|
23 |
-
|
24 |
-
</
|
|
|
|
|
25 |
|
26 |
|
27 |
-
<p
|
28 |
-
<
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
-
<p><h3>Have your own issue? Create A New Ticket</h3></p>
|
32 |
-
<p><a href="https://www.wp-buy.com/support-center/" target="_blank"><img title="create new ticket" border="0" src="<?php echo plugins_url('/images/newticket.png', AHCFREE_PLUGIN_MAIN_FILE) ?>" /></a></p>
|
33 |
|
34 |
|
35 |
|
36 |
-
</div>
|
37 |
|
|
|
|
1 |
<script language="javascript" type="text/javascript">
|
2 |
+
function imgFlagError(image) {
|
3 |
+
image.onerror = "";
|
4 |
+
image.src = "<?php echo plugins_url('/images/flags/noFlag.png', AHCFREE_PLUGIN_MAIN_FILE) ?>";
|
5 |
+
return true;
|
6 |
+
}
|
7 |
</script>
|
8 |
|
9 |
|
10 |
|
11 |
<div class="ahc_main_container">
|
12 |
+
<h1><img width="70px" src="<?php echo plugins_url('/images/logo.png', AHCFREE_PLUGIN_MAIN_FILE) ?>"> Visitor Traffic Real Time Statistics Free <a title="change settings" href="admin.php?page=ahc_hits_counter_settings"><img src="<?php echo plugins_url('/images/settings.jpg', AHCFREE_PLUGIN_MAIN_FILE) ?>" /></a></h1><br />
|
13 |
+
|
14 |
+
<div class="panel grid-Qr" style="border-radius: 7px !important;
|
15 |
+
border: 0 !important; box-shadow: 0 4px 25px 0 rgb(168 180 208 / 10%) !important; padding:15px; background:#fff ; width: 90%; ">
|
16 |
+
<div>
|
17 |
+
<div class="row">
|
18 |
+
<div class="col-md-6">
|
19 |
+
<h3>Welcme to wp-buy.com !</h3>
|
20 |
+
<p>wp-buy is a software development company that provides IT solutions to successfully improving your business performance.<br> We are a team working at wp-buy.com and dishing out absolute awesomeness in the form of WordPress plugins and themes.<br>Our brains are plump with theme & plugin ideas.</p>
|
21 |
+
</div>
|
22 |
|
23 |
+
<div class="col-md-4">
|
24 |
+
<img style="float:right" height="150px" src="<?php echo plugins_url('/images/24_7.ico', AHCFREE_PLUGIN_MAIN_FILE) ?>" />
|
25 |
+
</div>
|
26 |
+
</div>
|
|
|
|
|
27 |
|
28 |
+
</div>
|
29 |
+
<div>
|
30 |
+
<p>
|
31 |
+
<h3>Frequently Asked Questions</h3>
|
32 |
+
</p>
|
33 |
+
<p><a href="https://wordpress.org/plugins/visitors-traffic-real-time-statistics/#faq" target="_blank">Click here to view our FAQ</a></p>
|
34 |
|
35 |
|
36 |
+
<p>
|
37 |
+
<h3>Have your own issue? Create A New Ticket</h3>
|
38 |
+
</p>
|
39 |
+
<p><a href="https://www.wp-buy.com/support-center/" target="_blank"><img title="create new ticket" border="0" src="<?php echo plugins_url('/images/newticket.png', AHCFREE_PLUGIN_MAIN_FILE) ?>" /></a></p>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
|
43 |
|
|
|
|
|
44 |
|
45 |
|
46 |
|
|
|
47 |
|
48 |
+
</div>
|
ahc_settings.php
CHANGED
@@ -1,61 +1,58 @@
|
|
1 |
<?php
|
2 |
-
if (
|
3 |
?>
|
4 |
<script language="javascript" type="text/javascript">
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
return true;
|
11 |
-
}
|
12 |
-
|
13 |
-
|
14 |
</script>
|
15 |
<style type="text/css">
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
.panel{
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
-
|
36 |
-
|
37 |
-
input[type=checkbox]{
|
38 |
-
border: 1px solid #7e8993;
|
39 |
-
border-radius: 4px;
|
40 |
-
background: #fff;
|
41 |
-
color: #555;
|
42 |
-
clear: none;
|
43 |
-
cursor: pointer;
|
44 |
-
display: inline-block;
|
45 |
-
line-height: 0;
|
46 |
-
height: auto !important;
|
47 |
-
margin: -.25rem .25rem 0 0;
|
48 |
-
outline: 0;
|
49 |
-
padding: 0!important;
|
50 |
-
text-align: center;
|
51 |
-
vertical-align: middle;
|
52 |
-
width: auto !important;
|
53 |
-
min-width: auto !important;
|
54 |
-
-webkit-appearance: auto !important;
|
55 |
-
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
|
56 |
-
transition: .05s border-color ease-in-out;
|
57 |
-
}
|
58 |
-
|
59 |
</style>
|
60 |
<?php
|
61 |
//ahcfree_include_scripts();
|
@@ -63,16 +60,12 @@ $msg = '';
|
|
63 |
$save_btn = (isset($_POST['save'])) ? sanitize_text_field($_POST['save']) : '';
|
64 |
$saved_suc = false;
|
65 |
|
66 |
-
if(!empty($save_btn))
|
67 |
-
|
68 |
-
$verify = isset($_POST['ahc_settings_send']) ? wp_verify_nonce( sanitize_text_field($_POST['ahc_settings_send']), 'ahc_settings_action' ) : false;
|
69 |
|
70 |
-
if ($verify && current_user_can(
|
71 |
-
|
72 |
-
if (ahcfree_savesettings())
|
73 |
-
{
|
74 |
$saved_suc = true;
|
75 |
-
|
76 |
}
|
77 |
}
|
78 |
}
|
@@ -80,192 +73,246 @@ $ahcfree_get_save_settings = ahcfree_get_save_settings();
|
|
80 |
$hits_days = $ahcfree_get_save_settings[0]->set_hits_days;
|
81 |
$ajax_check = ($ahcfree_get_save_settings[0]->set_ajax_check * 1000);
|
82 |
$set_ips = $ahcfree_get_save_settings[0]->set_ips;
|
83 |
-
$set_ips = str_ireplace(' ',' '
|
84 |
|
85 |
$delete_plugin_data = get_option('ahcfree_delete_plugin_data_on_uninstall');
|
86 |
$ahcfree_hide_top_bar_icon = get_option('ahcfree_hide_top_bar_icon');
|
87 |
-
|
88 |
$ahcfree_ahcfree_haships = get_option('ahcfree_ahcfree_haships');
|
89 |
$ahcfree_save_ips = get_option('ahcfree_save_ips_opn');
|
90 |
$ahcproUserRoles = get_option('ahcproUserRoles');
|
91 |
$ahcproRobots = get_option('ahcproRobots');
|
92 |
?>
|
93 |
-
<div class="ahc_main_container"
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
<
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
<
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
<div class="row">
|
137 |
-
|
138 |
-
|
139 |
-
<div class="form-group col-md-6">
|
140 |
-
|
141 |
-
<label for="exampleInput">check for online users every</label>
|
142 |
-
<input type="text" value="<?php echo esc_attr(intval($ajax_check) / 1000); ?>" class="form-control" id="set_ajax_check" name="set_ajax_check" placeholder="Enter number of days">
|
143 |
-
<small id="Help" class="form-text text-muted">Enter total seconds. default: 10 seconds</small>
|
144 |
-
|
145 |
-
</div>
|
146 |
-
<div class="form-group col-md-6">
|
147 |
-
<label for="exampleInput">IP's to exclude</label>
|
148 |
-
<textarea placeholder='192.168.1.1 192.168.1.2' name="set_ips" id="set_ips" rows="3" class="form-control" ><?php echo esc_html($set_ips); ?></textarea>
|
149 |
-
<small id="Help" class="form-text text-muted">Excluded IPs will not be tracked by your counter, enter IP per line</small>
|
150 |
-
</div>
|
151 |
-
|
152 |
</div>
|
153 |
-
|
154 |
-
<div class="row">
|
155 |
-
<div class="form-group col-md-6">
|
156 |
-
<label for='exampleInput'>Plugin Accessibility</label><br>
|
157 |
-
<?php
|
158 |
-
|
159 |
-
|
160 |
-
global $wp_roles;
|
161 |
-
if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles();
|
162 |
-
$capabilites = array();
|
163 |
-
$available_roles_names = $wp_roles->get_names();//we get all roles names
|
164 |
-
$available_roles_capable = array();
|
165 |
-
foreach ($available_roles_names as $role_key => $role_name) { //we iterate all the names
|
166 |
-
$role_object = get_role( $role_key );//we get the Role Object
|
167 |
-
$array_of_capabilities = $role_object->capabilities;//we get the array of capabilities for this role
|
168 |
-
|
169 |
-
$available_roles_capable[$role_key] = $role_name; //we populate the array of capable roles
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
$UserRoles = get_option('ahcproUserRoles');
|
175 |
-
|
176 |
-
$UserRoles_arr = explode(',',$UserRoles);
|
177 |
-
?>
|
178 |
-
<select id='ahcproUserRoles' name='ahcproUserRoles[]' multiple='true' style='width:50%;'>
|
179 |
-
<?php
|
180 |
-
foreach($available_roles_capable as $role)
|
181 |
-
{
|
182 |
-
$translated_role_name = $role;
|
183 |
-
if(in_array($translated_role_name, $UserRoles_arr) or $translated_role_name == 'Administrator' or $translated_role_name == 'Super Admin')
|
184 |
-
{
|
185 |
-
$selected_value = 'selected=selected';
|
186 |
-
}else{
|
187 |
-
$selected_value = '';
|
188 |
-
}
|
189 |
-
?>
|
190 |
-
<option <?php echo $selected_value;?> value="<?php echo esc_attr($translated_role_name); ?>"><?php echo esc_html($translated_role_name); ?></option>
|
191 |
-
<?php
|
192 |
-
}
|
193 |
-
|
194 |
-
?></select>
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
<script language="javascript" type="text/javascript">
|
199 |
-
jQuery(document).ready(function() {
|
200 |
-
new SlimSelect({
|
201 |
-
select: '#ahcproUserRoles'
|
202 |
-
})
|
203 |
-
});
|
204 |
|
205 |
|
206 |
-
</script>
|
207 |
-
</div></div>
|
208 |
-
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
-
<div class="row">
|
212 |
-
<div class="form-group col-md-6">
|
213 |
-
<label for="exampleInput">Hide Top Bar Icon</label>
|
214 |
-
<p> <label><input type="checkbox" value="1" name="ahcfree_hide_top_bar_icon" <?php echo ($ahcfree_hide_top_bar_icon == 1) ? 'checked=checked' : ''; ?> > If checked, We will hide the top bar icon. </label></p>
|
215 |
-
<br />
|
216 |
</div>
|
|
|
|
|
|
|
|
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
-
</div>
|
220 |
-
|
221 |
-
<div class="row">
|
222 |
-
<div class="form-group col-md-6">
|
223 |
-
<label for="exampleInput">Hash IPs</label>
|
224 |
-
<p> <label><input type="checkbox" value="1" name="ahcfree_ahcfree_haships" <?php echo ($ahcfree_ahcfree_haships == 1) ? 'checked=checked' : ''; ?> > If checked, We will hide the last 3 digits in all IP's. </label></p>
|
225 |
-
<br />
|
226 |
</div>
|
227 |
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
</div>
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
border: none;
|
245 |
color: white;
|
246 |
padding: 15px 32px;
|
247 |
text-align: center;
|
248 |
text-decoration: none;
|
249 |
display: inline-block;
|
250 |
-
font-size: 16px;
|
251 |
-
|
|
|
252 |
border: none;
|
253 |
|
254 |
padding: 15px 32px;
|
255 |
text-align: center;
|
256 |
text-decoration: none;
|
257 |
display: inline-block;
|
258 |
-
font-size: 16px;
|
259 |
-
|
|
|
|
|
|
|
260 |
<?php
|
261 |
-
if($saved_suc)
|
262 |
-
{
|
263 |
?>
|
264 |
<br /><b style="color:green; margin-left:30px; float:left">settings saved successfully</b><br /><b style=" margin-left:30px; float:left"><a href="admin.php?page=ahc_hits_counter_settings">back to settings</a> | <a href="admin.php?page=ahc_hits_counter_menu_free">back to dashboard</a></b>
|
265 |
<?php
|
266 |
}
|
267 |
|
268 |
|
269 |
-
|
270 |
-
|
271 |
-
|
1 |
<?php
|
2 |
+
if (!defined('ABSPATH')) exit; // Exit if accessed directly
|
3 |
?>
|
4 |
<script language="javascript" type="text/javascript">
|
5 |
+
function imgFlagError(image) {
|
6 |
+
image.onerror = "";
|
7 |
+
image.src = "<?php echo plugins_url('/images/flags/noFlag.png', AHCFREE_PLUGIN_MAIN_FILE) ?>";
|
8 |
+
return true;
|
9 |
+
}
|
|
|
|
|
|
|
|
|
10 |
</script>
|
11 |
<style type="text/css">
|
12 |
+
i {
|
13 |
+
color: #999
|
14 |
+
}
|
15 |
+
|
16 |
+
.panel {
|
17 |
+
width: 90% !important;
|
18 |
+
margin-bottom: 10px;
|
19 |
+
border: 1px solid transparent;
|
20 |
+
padding: 20px;
|
21 |
+
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
a,
|
26 |
+
div {
|
27 |
+
outline: 0;
|
28 |
+
}
|
29 |
+
|
30 |
+
body {
|
31 |
+
background-color: #F1F1F1
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
input[type=checkbox] {
|
36 |
+
border: 1px solid #7e8993;
|
37 |
+
border-radius: 4px;
|
38 |
+
background: #fff;
|
39 |
+
color: #555;
|
40 |
+
clear: none;
|
41 |
+
cursor: pointer;
|
42 |
+
display: inline-block;
|
43 |
+
line-height: 0;
|
44 |
+
height: auto !important;
|
45 |
+
margin: -.25rem .25rem 0 0;
|
46 |
+
outline: 0;
|
47 |
+
padding: 0 !important;
|
48 |
+
text-align: center;
|
49 |
+
vertical-align: middle;
|
50 |
+
width: auto !important;
|
51 |
+
min-width: auto !important;
|
52 |
+
-webkit-appearance: auto !important;
|
53 |
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
|
54 |
+
transition: .05s border-color ease-in-out;
|
55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
</style>
|
57 |
<?php
|
58 |
//ahcfree_include_scripts();
|
60 |
$save_btn = (isset($_POST['save'])) ? sanitize_text_field($_POST['save']) : '';
|
61 |
$saved_suc = false;
|
62 |
|
63 |
+
if (!empty($save_btn)) {
|
64 |
+
$verify = isset($_POST['ahc_settings_send']) ? wp_verify_nonce(sanitize_text_field($_POST['ahc_settings_send']), 'ahc_settings_action') : false;
|
|
|
65 |
|
66 |
+
if ($verify && current_user_can('manage_options')) {
|
67 |
+
if (ahcfree_savesettings()) {
|
|
|
|
|
68 |
$saved_suc = true;
|
|
|
69 |
}
|
70 |
}
|
71 |
}
|
73 |
$hits_days = $ahcfree_get_save_settings[0]->set_hits_days;
|
74 |
$ajax_check = ($ahcfree_get_save_settings[0]->set_ajax_check * 1000);
|
75 |
$set_ips = $ahcfree_get_save_settings[0]->set_ips;
|
76 |
+
$set_ips = str_ireplace(' ', ' ', $set_ips);
|
77 |
|
78 |
$delete_plugin_data = get_option('ahcfree_delete_plugin_data_on_uninstall');
|
79 |
$ahcfree_hide_top_bar_icon = get_option('ahcfree_hide_top_bar_icon');
|
80 |
+
$ahcproExcludeRoles = get_option('ahcproExcludeRoles');
|
81 |
$ahcfree_ahcfree_haships = get_option('ahcfree_ahcfree_haships');
|
82 |
$ahcfree_save_ips = get_option('ahcfree_save_ips_opn');
|
83 |
$ahcproUserRoles = get_option('ahcproUserRoles');
|
84 |
$ahcproRobots = get_option('ahcproRobots');
|
85 |
?>
|
86 |
+
<div class="ahc_main_container">
|
87 |
+
<h3><img width="40px" src="<?php echo esc_url(plugins_url('/images/logo.png', AHCFREE_PLUGIN_MAIN_FILE)); ?>"> Visitor Traffic Real Time Statistics Free <a title="change settings" href="admin.php?page=ahc_hits_counter_settings"><img src="<?php echo esc_url(plugins_url('/images/settings.jpg', AHCFREE_PLUGIN_MAIN_FILE)); ?>" /></a></h3><br />
|
88 |
+
<div class="panel" style="border-radius: 7px !important;
|
89 |
+
border: 0 !important; box-shadow: 0 4px 25px 0 rgb(168 180 208 / 10%) !important; background:#fff">
|
90 |
+
<h2 class="box-heading">Settings</h2>
|
91 |
+
<hr>
|
92 |
+
<div class="panelcontent">
|
93 |
+
<form method="post" enctype="multipart/form-data" name="myform">
|
94 |
+
<?php $nonce = wp_create_nonce('ahc_settings_action'); ?>
|
95 |
+
<input type="hidden" name="ahc_settings_send" value="<?php echo esc_attr($nonce); ?>" />
|
96 |
+
|
97 |
+
<div class="row">
|
98 |
+
<div class="form-group col-md-6">
|
99 |
+
|
100 |
+
<label for="exampleInput">show hits in last</label>
|
101 |
+
<input type="text" value="<?php echo esc_attr($hits_days); ?>" class="form-control" id="set_hits_days" name="set_hits_days" placeholder="Enter number of days">
|
102 |
+
<small id="Help" class="form-text text-muted">this will affect the chart in the statistics page. default: 14 day</small>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<div class="form-group col-md-2">
|
106 |
+
<label for="exampleFormControlSelect1">Select Timezone</label>
|
107 |
+
|
108 |
+
<select class="form-control" id="set_custom_timezone" name="set_custom_timezone">
|
109 |
+
|
110 |
+
<?php
|
111 |
+
|
112 |
+
$wp_timezone_string = get_option('timezone_string');
|
113 |
+
$custom_timezone_offset = (get_option('ahcfree_custom_timezone') != '') ? get_option('ahcfree_custom_timezone') : $wp_timezone_string;
|
114 |
+
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
|
115 |
+
foreach ($timezones as $key => $value) {
|
116 |
+
?>
|
117 |
+
<option value="<?php echo esc_attr($value); ?>" <?php echo ($value == $custom_timezone_offset) ? 'selected' : ''; ?>><?php echo esc_html($value); ?></option>
|
118 |
+
<?php
|
119 |
+
}
|
120 |
+
?>
|
121 |
+
</select>
|
122 |
+
</div>
|
123 |
+
<div class="form-group col-md-4">
|
124 |
+
<br><span style="color:red; font-size:13px; ">Please select the same timezone in your</span> <a style="font-size:13px; " href="options-general.php" target="_blank">general settings page</a>
|
125 |
+
</div>
|
126 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
|
|
|
|
|
|
|
130 |
|
131 |
+
<div class="row">
|
132 |
+
|
133 |
+
|
134 |
+
<div class="form-group col-md-6">
|
135 |
+
|
136 |
+
<label for="exampleInput">check for online users every</label>
|
137 |
+
<input type="text" value="<?php echo esc_attr(intval($ajax_check) / 1000); ?>" class="form-control" id="set_ajax_check" name="set_ajax_check" placeholder="Enter number of days">
|
138 |
+
<small id="Help" class="form-text text-muted">Enter total seconds. default: 10 seconds</small>
|
139 |
|
|
|
|
|
|
|
|
|
|
|
140 |
</div>
|
141 |
+
<div class="form-group col-md-6">
|
142 |
+
<label for="exampleInput">IP's to exclude</label>
|
143 |
+
<textarea placeholder='192.168.1.1 192.168.1.2' name="set_ips" id="set_ips" rows="3" class="form-control"><?php echo esc_html($set_ips); ?></textarea>
|
144 |
+
<small id="Help" class="form-text text-muted">Excluded IPs will not be tracked by your counter, enter IP per line</small>
|
145 |
|
146 |
+
<br />
|
147 |
+
<label for='exampleInput'>User Role Exclusion From Statistics</label><br>
|
148 |
+
<?php
|
149 |
+
$html = '';
|
150 |
+
|
151 |
+
global $wp_roles;
|
152 |
+
if (!isset($wp_roles)) $wp_roles = new WP_Roles();
|
153 |
+
$capabilites = array();
|
154 |
+
$available_roles_names = $wp_roles->get_names(); //we get all roles names
|
155 |
+
$available_roles_capable = array();
|
156 |
+
foreach ($available_roles_names as $role_key => $role_name) { //we iterate all the names
|
157 |
+
$role_object = get_role($role_key); //we get the Role Object
|
158 |
+
$array_of_capabilities = $role_object->capabilities; //we get the array of capabilities for this role
|
159 |
+
|
160 |
+
$available_roles_capable[$role_key] = $role_name; //we populate the array of capable roles
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
$UserRoles = get_option('ahcproExcludeRoles');
|
166 |
+
|
167 |
+
$UserRoles_arr = explode(',', $UserRoles);
|
168 |
+
?>
|
169 |
+
<select id='ahcproExcludeRoles' name='ahcproExcludeRoles[]' multiple='true' style='width:50%;'>
|
170 |
+
<?php
|
171 |
+
foreach ($available_roles_capable as $role) {
|
172 |
+
$translated_role_name = $role;
|
173 |
+
if (in_array($translated_role_name, $UserRoles_arr) ) {
|
174 |
+
$selected_value = 'selected=selected';
|
175 |
+
} else {
|
176 |
+
$selected_value = '';
|
177 |
+
}
|
178 |
+
?>
|
179 |
+
<option <?php echo $selected_value; ?> value="<?php echo esc_attr($translated_role_name); ?>"><?php echo esc_html($translated_role_name); ?></option>
|
180 |
+
<?php
|
181 |
+
}
|
182 |
+
|
183 |
+
?>
|
184 |
+
</select>
|
185 |
+
|
186 |
+
|
187 |
+
|
188 |
+
<script language="javascript" type="text/javascript">
|
189 |
+
jQuery(document).ready(function() {
|
190 |
+
new SlimSelect({
|
191 |
+
select: '#ahcproExcludeRoles'
|
192 |
+
})
|
193 |
+
});
|
194 |
+
</script>
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
</div>
|
197 |
|
198 |
|
199 |
+
|
200 |
+
</div>
|
201 |
+
|
202 |
+
<div class="row">
|
203 |
+
<div class="form-group col-md-6">
|
204 |
+
<label for='exampleInput'>Plugin Accessibility</label><br>
|
205 |
+
<?php
|
206 |
+
|
207 |
+
|
208 |
+
global $wp_roles;
|
209 |
+
if (!isset($wp_roles)) $wp_roles = new WP_Roles();
|
210 |
+
$capabilites = array();
|
211 |
+
$available_roles_names = $wp_roles->get_names(); //we get all roles names
|
212 |
+
$available_roles_capable = array();
|
213 |
+
foreach ($available_roles_names as $role_key => $role_name) { //we iterate all the names
|
214 |
+
$role_object = get_role($role_key); //we get the Role Object
|
215 |
+
$array_of_capabilities = $role_object->capabilities; //we get the array of capabilities for this role
|
216 |
+
|
217 |
+
$available_roles_capable[$role_key] = $role_name; //we populate the array of capable roles
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
$UserRoles = get_option('ahcproUserRoles');
|
223 |
+
|
224 |
+
$UserRoles_arr = explode(',', $UserRoles);
|
225 |
+
?>
|
226 |
+
<select id='ahcproUserRoles' name='ahcproUserRoles[]' multiple='true' style='width:50%;'>
|
227 |
+
<?php
|
228 |
+
foreach ($available_roles_capable as $role) {
|
229 |
+
$translated_role_name = $role;
|
230 |
+
if (in_array($translated_role_name, $UserRoles_arr) or $translated_role_name == 'Administrator' or $translated_role_name == 'Super Admin') {
|
231 |
+
$selected_value = 'selected=selected';
|
232 |
+
} else {
|
233 |
+
$selected_value = '';
|
234 |
+
}
|
235 |
+
?>
|
236 |
+
<option <?php echo $selected_value; ?> value="<?php echo esc_attr($translated_role_name); ?>"><?php echo esc_html($translated_role_name); ?></option>
|
237 |
+
<?php
|
238 |
+
}
|
239 |
+
|
240 |
+
?>
|
241 |
+
</select>
|
242 |
+
|
243 |
+
|
244 |
+
|
245 |
+
<script language="javascript" type="text/javascript">
|
246 |
+
jQuery(document).ready(function() {
|
247 |
+
new SlimSelect({
|
248 |
+
select: '#ahcproUserRoles'
|
249 |
+
})
|
250 |
+
});
|
251 |
+
</script>
|
252 |
</div>
|
253 |
+
</div>
|
254 |
+
|
255 |
+
|
256 |
+
|
257 |
+
<div class="row">
|
258 |
+
<div class="form-group col-md-6">
|
259 |
+
<label for="exampleInput">Hide Top Bar Icon</label>
|
260 |
+
<p> <label><input type="checkbox" value="1" name="ahcfree_hide_top_bar_icon" <?php echo ($ahcfree_hide_top_bar_icon == 1) ? 'checked=checked' : ''; ?>> If checked, We will hide the top bar icon. </label></p>
|
261 |
+
<br />
|
262 |
+
</div>
|
263 |
+
|
264 |
+
|
265 |
+
</div>
|
266 |
+
|
267 |
+
<div class="row">
|
268 |
+
<div class="form-group col-md-6">
|
269 |
+
<label for="exampleInput">Hash IPs</label>
|
270 |
+
<p> <label><input type="checkbox" value="1" name="ahcfree_ahcfree_haships" <?php echo ($ahcfree_ahcfree_haships == 1) ? 'checked=checked' : ''; ?>> If checked, We will hide the last 3 digits in all IP's. </label></p>
|
271 |
+
<br />
|
272 |
+
</div>
|
273 |
+
|
274 |
+
|
275 |
+
</div>
|
276 |
+
|
277 |
+
|
278 |
+
<div class="row">
|
279 |
+
<div class="form-group col-md-6">
|
280 |
+
<label for="exampleInput">Stats Data</label>
|
281 |
+
<p> <label style="color:red"><input type="checkbox" value="1" name="delete_plugin_data" <?php echo ($delete_plugin_data == 1) ? 'checked=checked' : ''; ?>> If checked, all the stats data will be deleted on deleting plugin. </label></p>
|
282 |
+
<br />
|
283 |
+
</div>
|
284 |
+
|
285 |
+
|
286 |
+
</div>
|
287 |
+
</div>
|
288 |
+
<input type="submit" name="save" value="save settings" style=" background-color: #4CAF50; /* Green */
|
289 |
border: none;
|
290 |
color: white;
|
291 |
padding: 15px 32px;
|
292 |
text-align: center;
|
293 |
text-decoration: none;
|
294 |
display: inline-block;
|
295 |
+
font-size: 16px;
|
296 |
+
border-radius:4px" />
|
297 |
+
<input type="button" name="cancel" value="back to dashboard" onclick="javascript:window.location.href = 'admin.php?page=ahc_hits_counter_menu_free'" style=" background-color: #e7e7e7; color: black;
|
298 |
border: none;
|
299 |
|
300 |
padding: 15px 32px;
|
301 |
text-align: center;
|
302 |
text-decoration: none;
|
303 |
display: inline-block;
|
304 |
+
font-size: 16px;
|
305 |
+
border-radius:4px" />
|
306 |
+
</div>
|
307 |
+
|
308 |
+
</div>
|
309 |
<?php
|
310 |
+
if ($saved_suc) {
|
|
|
311 |
?>
|
312 |
<br /><b style="color:green; margin-left:30px; float:left">settings saved successfully</b><br /><b style=" margin-left:30px; float:left"><a href="admin.php?page=ahc_hits_counter_settings">back to settings</a> | <a href="admin.php?page=ahc_hits_counter_menu_free">back to dashboard</a></b>
|
313 |
<?php
|
314 |
}
|
315 |
|
316 |
|
317 |
+
?>
|
318 |
+
</form>
|
|
css/custom.css
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.add{
|
2 |
+
display: none !important;
|
3 |
+
}
|
4 |
+
.googlePlay{
|
5 |
+
animation: translate 3s infinite;
|
6 |
+
}
|
7 |
+
@keyframes translate {
|
8 |
+
0%{
|
9 |
+
transform: translateX(0px);
|
10 |
+
}
|
11 |
+
50%{
|
12 |
+
transform: translateX(-8px);
|
13 |
+
}
|
14 |
+
100%{
|
15 |
+
transform: translateX(0px);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
@media (max-width: 800px) {
|
20 |
+
.add{
|
21 |
+
display: flex !important;
|
22 |
+
justify-content: space-between;
|
23 |
+
align-items: center;
|
24 |
+
text-align: center;
|
25 |
+
background: #6747f5 ;
|
26 |
+
border-radius: 3px;
|
27 |
+
color: #fff;
|
28 |
+
box-shadow: rgba(33, 35, 38, 0.4) 0px 10px 10px -10px;
|
29 |
+
|
30 |
+
}
|
31 |
+
.add p {
|
32 |
+
margin: 0!important;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
.panelcontent{
|
36 |
+
border-radius: 7px;
|
37 |
+
}
|
38 |
+
.box_widget{
|
39 |
+
border: 0px !important;
|
40 |
+
border-radius: 7px !important;
|
41 |
+
box-shadow: 0 4px 25px 0 rgb(168 180 208 / 10%) !important;
|
42 |
+
margin-bottom: 8px;
|
43 |
+
}
|
44 |
+
.panel .box-heading{
|
45 |
+
border-radius: 7px 7px 0 0 !important;
|
46 |
+
}
|
47 |
+
thead{
|
48 |
+
background-color: #F5F5F5 ;
|
49 |
+
}
|
50 |
+
thead th {
|
51 |
+
padding: 13px 10px !important;
|
52 |
+
|
53 |
+
}
|
54 |
+
thead th:first-child{
|
55 |
+
border-radius: 4px 0 0 4px !important;
|
56 |
+
}
|
57 |
+
thead th:last-child{
|
58 |
+
border-radius: 0 4px 4px 0 !important;
|
59 |
+
}
|
60 |
+
|
61 |
+
input[type="text"] , textarea , .wp-core-ui select{
|
62 |
+
background-color: #F5F5F5 !important ;
|
63 |
+
border: 1px solid #ffffff !important;
|
64 |
+
transition: .3s all;
|
65 |
+
border-radius: 4px !important;
|
66 |
+
}
|
67 |
+
input[type="text"] , .wp-core-ui select , .ss-multi-selected{
|
68 |
+
height: 38px !important;
|
69 |
+
}
|
70 |
+
.wp-core-ui select:hover ,.wp-core-ui select:focus ,input[type="text"]:hover ,input[type="text"]:focus , textarea:hover , textarea:focus {
|
71 |
+
background-color: #ebebeb !important ;
|
72 |
+
color: #2c3338;
|
73 |
+
border: 1px solid #c7c7c7 !important;
|
74 |
+
outline: 0 !important;
|
75 |
+
box-shadow: none !important;
|
76 |
+
}
|
77 |
+
.ss-main .ss-multi-selected .ss-add {
|
78 |
+
margin: 13px 12px 0 5px;
|
79 |
+
}
|
80 |
+
.grid-Qr {
|
81 |
+
display: grid;
|
82 |
+
grid-template-columns: 1fr 1fr;
|
83 |
+
}
|
84 |
+
|
85 |
+
@media (max-width: 600px) {
|
86 |
+
.grid-Qr {
|
87 |
+
grid-template-columns: 1fr;
|
88 |
+
}
|
89 |
+
}
|
functions.php
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
function vtrts_free_top_bar_enqueue_style()
|
|
|
4 |
|
5 |
?>
|
6 |
-
<style>
|
7 |
-
#wpadminbar #wp-admin-bar-vtrts_free_top_button .ab-icon:before {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
}
|
12 |
-
</style>
|
13 |
-
<?php
|
14 |
|
15 |
}
|
16 |
|
@@ -21,16 +22,16 @@ function vtrts_free_top_bar_enqueue_style() {
|
|
21 |
* @since 0.1
|
22 |
* @return mixed
|
23 |
*/
|
24 |
-
function ahc_free_sanitize_text_or_array_field($array_or_string)
|
25 |
-
|
|
|
26 |
$array_or_string = sanitize_text_field($array_or_string);
|
27 |
-
}elseif(
|
28 |
-
foreach (
|
29 |
-
if (
|
30 |
$value = ahc_free_sanitize_text_or_array_field($value);
|
31 |
-
}
|
32 |
-
|
33 |
-
$value = sanitize_text_field( $value );
|
34 |
}
|
35 |
}
|
36 |
}
|
@@ -40,23 +41,25 @@ function ahc_free_sanitize_text_or_array_field($array_or_string) {
|
|
40 |
|
41 |
function vtrts_free_add_items($admin_bar)
|
42 |
{
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
60 |
}
|
61 |
|
62 |
|
@@ -68,22 +71,22 @@ function vtrts_free_add_items($admin_bar)
|
|
68 |
*
|
69 |
* @return void
|
70 |
*/
|
71 |
-
|
72 |
|
73 |
function ahcfree_localtime($dateformat)
|
74 |
{
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}
|
82 |
}
|
83 |
|
84 |
|
85 |
|
86 |
-
function ahcfree_getVisitsTime()
|
|
|
87 |
global $wpdb;
|
88 |
$result = $wpdb->get_results("SELECT COUNT( `vtm_id` ) cnt FROM ahc_visits_time", OBJECT);
|
89 |
if ($result !== false) {
|
@@ -97,62 +100,78 @@ function ahcfree_getVisitsTime() {
|
|
97 |
* change plugin settings
|
98 |
* @return void
|
99 |
*/
|
100 |
-
|
101 |
-
function ahcfree_savesettings()
|
102 |
-
|
|
|
103 |
global $wpdb;
|
104 |
|
105 |
-
|
106 |
-
|
|
|
107 |
|
108 |
-
|
109 |
-
{
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
$set_google_map = '';
|
117 |
-
$ahcfree_hide_top_bar_icon = isset($_POST['ahcfree_hide_top_bar_icon']) ? intval($_POST['ahcfree_hide_top_bar_icon']) : '0';
|
118 |
-
$ahcfree_ahcfree_haships = isset($_POST['ahcfree_ahcfree_haships']) ? intval($_POST['ahcfree_ahcfree_haships']) : '0';
|
119 |
-
$delete_plugin_data = isset($_POST['delete_plugin_data']) ? intval($_POST['delete_plugin_data']) : '';
|
120 |
-
|
121 |
-
$custom_timezone_offset = ahc_free_sanitize_text_or_array_field($_POST['set_custom_timezone']);
|
122 |
-
if ($custom_timezone_offset && $custom_timezone_offset != '') {
|
123 |
-
update_option('ahcfree_custom_timezone', $custom_timezone_offset);
|
124 |
-
}
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
$ahcproUserRoles = (isset($_POST['ahcproUserRoles']) && is_array($_POST['ahcproUserRoles'])) ? $_POST['ahcproUserRoles'] : ''; // sanitize inside the loop
|
133 |
-
if(isset($ahcproUserRoles))
|
134 |
-
{
|
135 |
-
foreach ($ahcproUserRoles as $v)
|
136 |
-
{
|
137 |
-
|
138 |
-
$ahcproUserRoles_ .= $v.",";
|
139 |
-
}
|
140 |
-
|
141 |
-
$ahcproUserRoles_ = substr($ahcproUserRoles_,0,-1);
|
142 |
-
update_option('ahcproUserRoles',$ahcproUserRoles_);
|
143 |
-
}
|
144 |
-
|
145 |
-
ahcfree_update_tables();
|
146 |
|
147 |
-
|
148 |
-
|
|
|
|
|
149 |
|
150 |
-
|
|
|
|
|
|
|
151 |
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
return false;
|
158 |
}
|
@@ -226,29 +245,31 @@ function ahcfree_rate_us($plugin_url, $box_color = '#1D1F21') {
|
|
226 |
return $ret;
|
227 |
}*/
|
228 |
|
229 |
-
function ahcfree_get_save_settings()
|
|
|
230 |
global $wpdb;
|
231 |
$table_exist = ahcfree_check_table_exists('ahc_settings');
|
232 |
-
if(
|
233 |
$result = $wpdb->get_results("SELECT set_hits_days, set_ajax_check, set_ips, set_google_map FROM ahc_settings", OBJECT);
|
234 |
if ($result !== false) {
|
235 |
return $result;
|
236 |
}
|
237 |
}
|
238 |
-
|
239 |
return false;
|
240 |
}
|
241 |
|
242 |
-
function ahcfree_get_timezone_string()
|
|
|
243 |
$custom_timezone = get_option('ahcfree_custom_timezone');
|
244 |
if (!$custom_timezone) {
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
$custom_timezone = get_option( 'timezone_string' );
|
253 |
|
254 |
if ( ! empty( $custom_timezone ) ) {
|
@@ -262,16 +283,16 @@ function ahcfree_get_timezone_string() {
|
|
262 |
$hours = '0'+$hours;
|
263 |
}
|
264 |
echo $custom_timezone = sprintf( '%s:%s', $hours, $minutes );*/
|
265 |
-
|
266 |
}
|
267 |
return $custom_timezone;
|
268 |
}
|
269 |
|
270 |
|
271 |
-
function ahcfree_CleanupTimeZoneString($tzString)
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
275 |
/*$offset=$tzString;
|
276 |
|
277 |
|
@@ -288,29 +309,30 @@ function ahcfree_CleanupTimeZoneString($tzString){
|
|
288 |
}
|
289 |
|
290 |
|
291 |
-
function ahcfree_GetWPTimezoneString()
|
|
|
292 |
// if site timezone string exists, return it
|
293 |
-
if (
|
294 |
return $timezone;
|
295 |
|
296 |
// get UTC offset, if it isn't set then return UTC
|
297 |
-
if (
|
298 |
return 'UTC';
|
299 |
|
300 |
// adjust UTC offset from hours to seconds
|
301 |
$utc_offset *= 3600;
|
302 |
|
303 |
// attempt to guess the timezone string from the UTC offset
|
304 |
-
if (
|
305 |
return $timezone;
|
306 |
}
|
307 |
|
308 |
// last try, guess timezone string manually
|
309 |
-
$is_dst = date(
|
310 |
|
311 |
-
foreach (
|
312 |
-
foreach (
|
313 |
-
if (
|
314 |
return $city['timezone_id'];
|
315 |
}
|
316 |
}
|
@@ -319,7 +341,8 @@ function ahcfree_GetWPTimezoneString() {
|
|
319 |
return 'UTC';
|
320 |
}
|
321 |
|
322 |
-
function ahcfree_get_current_timezone_offset()
|
|
|
323 |
$tz = ahcfree_get_timezone_string();
|
324 |
try {
|
325 |
$timeZone = new DateTimeZone($tz);
|
@@ -331,7 +354,8 @@ function ahcfree_get_current_timezone_offset() {
|
|
331 |
return $date->format('P');
|
332 |
}
|
333 |
|
334 |
-
function ahcfree_last_hit_date()
|
|
|
335 |
global $wpdb;
|
336 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
337 |
$sql = "SELECT max(CONVERT_TZ(vtr_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as last_date FROM ahc_recent_visitors";
|
@@ -343,7 +367,8 @@ function ahcfree_last_hit_date() {
|
|
343 |
return ahcfree_localtime('Y-m-d', time());
|
344 |
}
|
345 |
|
346 |
-
function ahcfree_getCountriesCount()
|
|
|
347 |
global $wpdb;
|
348 |
$result = $wpdb->get_results("SELECT COUNT( `ctr_id` ) cnt FROM ahc_countries", OBJECT);
|
349 |
if ($result !== false) {
|
@@ -352,7 +377,8 @@ function ahcfree_getCountriesCount() {
|
|
352 |
return false;
|
353 |
}
|
354 |
|
355 |
-
function ahcfree_getBrowsersCount()
|
|
|
356 |
global $wpdb;
|
357 |
$result = $wpdb->get_results("SELECT COUNT( `bsr_id` ) cnt FROM ahc_browsers", OBJECT);
|
358 |
if ($result !== false) {
|
@@ -361,7 +387,8 @@ function ahcfree_getBrowsersCount() {
|
|
361 |
return false;
|
362 |
}
|
363 |
|
364 |
-
function ahcfree_getSearchEnginesCount()
|
|
|
365 |
global $wpdb;
|
366 |
$result = $wpdb->get_results("SELECT COUNT( `srh_id` ) cnt FROM ahc_search_engines", OBJECT);
|
367 |
if ($result !== false) {
|
@@ -370,18 +397,19 @@ function ahcfree_getSearchEnginesCount() {
|
|
370 |
return false;
|
371 |
}
|
372 |
|
373 |
-
function ahcfree_set_default_options()
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
|
|
380 |
// plugin activation
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
require_once("database_basics_data.php");
|
386 |
if (get_option('ahcfree_wp_hits_counter_options') === false) {
|
387 |
|
@@ -417,7 +445,6 @@ function ahcfree_set_default_options() {
|
|
417 |
ahcfree_insert_browsers_into_table($browsers);
|
418 |
}
|
419 |
}
|
420 |
-
|
421 |
}
|
422 |
|
423 |
|
@@ -431,49 +458,49 @@ function ahcfree_set_default_options() {
|
|
431 |
*
|
432 |
* @return void
|
433 |
*/
|
434 |
-
function ahcfree_create_admin_menu_link()
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
add_menu_page('Visitor Traffic Real Time Statistics Free', 'Visitor Traffic', 'manage_options', 'ahc_hits_counter_menu_free', 'ahcfree_create_plugin_overview_page', plugins_url('/images/vtrts.png', AHCFREE_PLUGIN_MAIN_FILE));
|
459 |
add_submenu_page('ahc_hits_counter_menu_free', 'Settings', 'Settings', 'manage_options', 'ahc_hits_counter_settings', 'ahcfree_create_plugin_settings_page');
|
460 |
add_submenu_page('ahc_hits_counter_menu_free', 'Contact Support', 'Help', 'manage_options', 'ahc_hits_counter_help', 'ahcfree_create_plugin_help_page');
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
}
|
478 |
|
479 |
//--------------------------------------------
|
@@ -482,7 +509,8 @@ function ahcfree_create_admin_menu_link() {
|
|
482 |
*
|
483 |
* @return number
|
484 |
*/
|
485 |
-
function ahcfree_NumFormat($num)
|
|
|
486 |
if ($num > 1000) {
|
487 |
return number_format($num, 0, ',', ',');
|
488 |
} else {
|
@@ -495,50 +523,50 @@ function ahcfree_NumFormat($num) {
|
|
495 |
|
496 |
function ahcfree_init()
|
497 |
{
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
}
|
505 |
-
add_action('admin_init','ahcfree_init');
|
506 |
|
507 |
function ahcfree_enqueue_scripts()
|
508 |
{
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
if(is_singular() || is_page()
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
wp_register_script('ahc_front_js', plugins_url('/js/front.js', AHCFREE_PLUGIN_MAIN_FILE),'jquery', '', false);
|
526 |
wp_enqueue_script('ahc_front_js');
|
527 |
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
|
|
533 |
}
|
534 |
-
add_action('wp_enqueue_scripts','ahcfree_enqueue_scripts', 1);
|
535 |
//--------------------------------------------
|
536 |
/**
|
537 |
* Creates the main overview page
|
538 |
*
|
539 |
* @return void
|
540 |
*/
|
541 |
-
function ahcfree_create_plugin_overview_page()
|
|
|
542 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
543 |
include("overview.php");
|
544 |
}
|
@@ -549,7 +577,8 @@ function ahcfree_create_plugin_overview_page() {
|
|
549 |
*
|
550 |
* @return void
|
551 |
*/
|
552 |
-
function ahcfree_create_plugin_settings_page()
|
|
|
553 |
|
554 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
555 |
include("ahc_settings.php");
|
@@ -561,7 +590,8 @@ function ahcfree_create_plugin_settings_page() {
|
|
561 |
*
|
562 |
* @return void
|
563 |
*/
|
564 |
-
function ahcfree_create_plugin_help_page()
|
|
|
565 |
|
566 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
567 |
include("ahc_help.php");
|
@@ -573,7 +603,8 @@ function ahcfree_create_plugin_help_page() {
|
|
573 |
*
|
574 |
* @return void
|
575 |
*/
|
576 |
-
function ahcfree_create_plugin_about_page()
|
|
|
577 |
|
578 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
579 |
include("ahc_about.php");
|
@@ -588,7 +619,8 @@ function ahcfree_create_plugin_about_page() {
|
|
588 |
*
|
589 |
* @return array
|
590 |
*/
|
591 |
-
function ahcfree_get_change_lang_links()
|
|
|
592 |
$plugin_options = get_option('ahcfree_wp_hits_counter_options');
|
593 |
$links = array();
|
594 |
$i = 0;
|
@@ -613,22 +645,39 @@ function ahcfree_get_change_lang_links() {
|
|
613 |
*
|
614 |
* @return boolean
|
615 |
*/
|
616 |
-
function ahcfree_should_track_visitor()
|
617 |
-
|
|
|
618 |
$allow = true;
|
|
|
|
|
619 |
if (is_user_logged_in()) {
|
620 |
$user = new WP_User($current_user->ID);
|
621 |
if (!empty($user->roles) && is_array($user->roles)) {
|
622 |
foreach ($user->roles as $role) {
|
623 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
if ($found) {
|
625 |
$allow = false;
|
626 |
break;
|
627 |
-
}
|
628 |
}
|
629 |
}
|
630 |
}
|
631 |
-
return
|
632 |
}
|
633 |
|
634 |
//--------------------------------------------
|
@@ -640,7 +689,8 @@ function ahcfree_should_track_visitor() {
|
|
640 |
*
|
641 |
* @return boolean
|
642 |
*/
|
643 |
-
function ahcfree_has_administrator_role()
|
|
|
644 |
global $user_ID;
|
645 |
$is_admin = false;
|
646 |
if (is_user_logged_in()) {
|
@@ -665,7 +715,8 @@ function ahcfree_has_administrator_role() {
|
|
665 |
*
|
666 |
* @return boolean
|
667 |
*/
|
668 |
-
function ahcfree_check_table_column_exists($table_name, $column_name)
|
|
|
669 |
global $wpdb;
|
670 |
$column = $wpdb->get_row($wpdb->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", DB_NAME, $table_name, $column_name));
|
671 |
|
@@ -683,16 +734,17 @@ function ahcfree_check_table_column_exists($table_name, $column_name) {
|
|
683 |
*
|
684 |
* @return boolean
|
685 |
*/
|
686 |
-
function ahcfree_check_column_index_exists($table_name, $column_name)
|
|
|
687 |
global $wpdb;
|
688 |
-
|
689 |
-
$column = $wpdb->get_row("show index from "
|
690 |
|
691 |
if (!empty($column)) {
|
692 |
-
|
693 |
return true;
|
694 |
}
|
695 |
-
|
696 |
return false;
|
697 |
}
|
698 |
|
@@ -705,15 +757,16 @@ function ahcfree_check_column_index_exists($table_name, $column_name) {
|
|
705 |
*
|
706 |
* @return boolean
|
707 |
*/
|
708 |
-
function ahcfree_check_table_exists($table_name)
|
|
|
709 |
global $wpdb;
|
710 |
-
$table_data = $wpdb->get_row(
|
711 |
|
712 |
if (!empty($table_data)) {
|
713 |
-
|
714 |
return true;
|
715 |
}
|
716 |
-
|
717 |
return false;
|
718 |
}
|
719 |
|
@@ -726,29 +779,29 @@ function ahcfree_check_table_exists($table_name) {
|
|
726 |
*
|
727 |
* @return boolean
|
728 |
*/
|
729 |
-
function ahcfree_update_tables()
|
|
|
730 |
global $wpdb;
|
731 |
$sqlQueries = array();
|
732 |
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
$sqlQueries[] = "alter table ahc_visitors add index idx_vst_date(vst_date)";
|
738 |
}
|
739 |
|
740 |
foreach ($sqlQueries as $sql) {
|
741 |
$wpdb->query($sql);
|
742 |
-
|
743 |
}
|
744 |
-
|
745 |
}
|
746 |
|
747 |
-
function ahcfree_add_settings()
|
|
|
748 |
|
749 |
global $wpdb;
|
750 |
-
|
751 |
-
|
752 |
`set_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
753 |
`set_hits_days` int(10) unsigned NOT NULL DEFAULT '14',
|
754 |
`set_ajax_check` int(10) unsigned NOT NULL DEFAULT '10',
|
@@ -757,10 +810,10 @@ function ahcfree_add_settings() {
|
|
757 |
|
758 |
PRIMARY KEY (`set_id`)
|
759 |
) DEFAULT CHARSET=utf8";
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
$sql1 = "truncate table `ahc_settings`";
|
765 |
$wpdb->query($sql1);
|
766 |
|
@@ -781,11 +834,12 @@ function ahcfree_add_settings() {
|
|
781 |
*
|
782 |
* @return boolean
|
783 |
*/
|
784 |
-
function ahcfree_create_database_tables()
|
|
|
785 |
global $wpdb;
|
786 |
$sqlQueries = array();
|
787 |
-
|
788 |
-
|
789 |
(
|
790 |
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
791 |
PRIMARY KEY(`id`),
|
@@ -793,7 +847,7 @@ function ahcfree_create_database_tables() {
|
|
793 |
`hit_page_id` VARCHAR(30) NOT NULL,
|
794 |
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
795 |
) DEFAULT CHARSET=utf8";
|
796 |
-
|
797 |
$sqlQueries[] = "CREATE TABLE IF NOT EXISTS `ahc_hits`
|
798 |
(
|
799 |
`hit_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
@@ -867,8 +921,8 @@ function ahcfree_create_database_tables() {
|
|
867 |
|
868 |
|
869 |
|
870 |
-
|
871 |
-
|
872 |
$sqlQueries[] = "CREATE TABLE IF NOT EXISTS `ahc_visitors`
|
873 |
(
|
874 |
`vst_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
@@ -980,7 +1034,8 @@ function ahcfree_create_database_tables() {
|
|
980 |
* @param array $contriesLatLng. LatLng of countries
|
981 |
* @return boolean
|
982 |
*/
|
983 |
-
function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng)
|
|
|
984 |
global $wpdb;
|
985 |
$c = 1;
|
986 |
$length = count($internetCountryCodes);
|
@@ -990,14 +1045,17 @@ function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLat
|
|
990 |
$ctr_latitude = $contriesLatLng[$internetCode][0];
|
991 |
$ctr_longitude = $contriesLatLng[$internetCode][1];
|
992 |
}
|
993 |
-
$result = $wpdb->insert(
|
994 |
-
'
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
|
|
|
|
|
|
1001 |
);
|
1002 |
if ($result === false) {
|
1003 |
return false;
|
@@ -1016,27 +1074,34 @@ function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLat
|
|
1016 |
* @param array $searchEngines.
|
1017 |
* @return boolean
|
1018 |
*/
|
1019 |
-
function ahcfree_insert_search_engines_into_table($searchEngines)
|
|
|
1020 |
global $wpdb;
|
1021 |
foreach ($searchEngines as $se) {
|
1022 |
-
$result = $wpdb->insert(
|
1023 |
-
'
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
|
|
|
|
|
|
1030 |
);
|
1031 |
if ($result !== false) {
|
1032 |
$srh_id = $wpdb->insert_id;
|
1033 |
foreach ($se['crawlers'] as $crawler) {
|
1034 |
-
$result2 = $wpdb->insert(
|
1035 |
-
'
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
|
|
|
|
|
|
1040 |
);
|
1041 |
if ($result2 === false) {
|
1042 |
return false;
|
@@ -1058,16 +1123,20 @@ function ahcfree_insert_search_engines_into_table($searchEngines) {
|
|
1058 |
* @param array $browsers
|
1059 |
* @return boolean
|
1060 |
*/
|
1061 |
-
function ahcfree_insert_browsers_into_table($browsers)
|
|
|
1062 |
global $wpdb;
|
1063 |
foreach ($browsers as $browser) {
|
1064 |
-
$result = $wpdb->insert(
|
1065 |
-
'
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
|
|
|
|
|
|
1071 |
);
|
1072 |
if ($result === false) {
|
1073 |
return false;
|
@@ -1085,16 +1154,20 @@ function ahcfree_insert_browsers_into_table($browsers) {
|
|
1085 |
* @param array $dayHours
|
1086 |
* @return boolean
|
1087 |
*/
|
1088 |
-
function ahcfree_insert_visit_times_into_table($dayHours)
|
|
|
1089 |
global $wpdb;
|
1090 |
foreach ($dayHours as $t) {
|
1091 |
-
$result = $wpdb->insert(
|
1092 |
-
'
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
|
|
|
|
|
|
1098 |
);
|
1099 |
if ($result === false) {
|
1100 |
return false;
|
@@ -1111,13 +1184,14 @@ function ahcfree_insert_visit_times_into_table($dayHours) {
|
|
1111 |
* @param string $format Optional
|
1112 |
* @return array
|
1113 |
*/
|
1114 |
-
function ahcfree_get_week_limits($date, $format = 'Y-m-d')
|
|
|
1115 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1116 |
$beginingDay = new DateTime($date);
|
1117 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
1118 |
$endingDay = new DateTime($date);
|
1119 |
$date = new DateTime($date);
|
1120 |
-
|
1121 |
switch ($date->format('w')) {
|
1122 |
case 0: // sun
|
1123 |
//$beginingDay->modify('-1 day');
|
@@ -1149,12 +1223,12 @@ function ahcfree_get_week_limits($date, $format = 'Y-m-d') {
|
|
1149 |
$endingDay->modify('+1 day');
|
1150 |
break;
|
1151 |
}*/
|
1152 |
-
|
1153 |
-
|
1154 |
//$endingDay->modify();
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
//$beginingDay->modify('-'.$day.' days');
|
1159 |
//$endingDay->modify('+'.(6-$day).' days');
|
1160 |
return array(0 => $beginingDay->format($format), 1 => $endingDay->format($format));
|
@@ -1166,7 +1240,8 @@ function ahcfree_get_week_limits($date, $format = 'Y-m-d') {
|
|
1166 |
*
|
1167 |
* @return array
|
1168 |
*/
|
1169 |
-
function ahcfree_get_summary_statistics()
|
|
|
1170 |
$arr = array();
|
1171 |
$arr['today'] = ahcfree_get_visitors_visits_in_period('today');
|
1172 |
$arr['yesterday'] = ahcfree_get_visitors_visits_in_period('yesterday');
|
@@ -1187,30 +1262,31 @@ function ahcfree_get_summary_statistics() {
|
|
1187 |
* @param string $period Optional
|
1188 |
* @return mixed
|
1189 |
*/
|
1190 |
-
function ahcfree_get_visitors_visits_in_period($period = 'total')
|
|
|
1191 |
global $wpdb;
|
1192 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1193 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
1194 |
-
// echo AHCFREE_SERVER_CURRENT_TIMEZONE;
|
1195 |
|
1196 |
-
|
1197 |
$current_date->setTimezone($custom_timezone);
|
1198 |
-
|
1199 |
-
|
1200 |
$date = new DateTime();
|
1201 |
$date->setTimezone($custom_timezone);
|
1202 |
-
|
1203 |
-
|
1204 |
$sql = "SELECT SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits
|
1205 |
FROM `ahc_visitors`
|
1206 |
WHERE 1 = 1";
|
1207 |
$results = false;
|
1208 |
switch ($period) {
|
1209 |
case 'today':
|
1210 |
-
|
1211 |
-
|
1212 |
-
$sql .= " AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) = '". ahcfree_localtime('Y-m-d') ."'";
|
1213 |
-
|
1214 |
$results = $wpdb->get_results($sql, OBJECT);
|
1215 |
break;
|
1216 |
|
@@ -1222,54 +1298,54 @@ function ahcfree_get_visitors_visits_in_period($period = 'total') {
|
|
1222 |
|
1223 |
case 'week': // last 7 days
|
1224 |
$limits = ahcfree_get_week_limits($date->format('Y-m-d'));
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('"
|
1229 |
-
and vst_date < DATE_FORMAT(CONVERT_TZ('"
|
|
|
1230 |
|
1231 |
|
1232 |
-
|
1233 |
$results = $wpdb->get_results($sql);
|
1234 |
-
|
1235 |
break;
|
1236 |
|
1237 |
case 'month':
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('"
|
1242 |
-
and vst_date < DATE_FORMAT(CONVERT_TZ('"
|
|
|
1243 |
|
1244 |
|
1245 |
-
|
1246 |
$results = $wpdb->get_results($sql);
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
break;
|
1252 |
|
1253 |
case 'year':
|
1254 |
-
|
1255 |
-
|
1256 |
-
$custom_timezone_offset = str_ireplace('+','-',$custom_timezone_offset);
|
1257 |
-
|
1258 |
-
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('".$date->modify('-365 day')->format('Y-m-d')." 23:59:59','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '".$custom_timezone_offset."'),'%Y-%m-%d %H:%i') - INTERVAL 1 DAY
|
1259 |
-
and vst_date < DATE_FORMAT(CONVERT_TZ('".$current_date->format('Y-m-d')." 00:00:00','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '".$custom_timezone_offset."'),'%Y-%m-%d %H:%i') + INTERVAL 1 DAY";
|
1260 |
|
1261 |
|
1262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1263 |
$results = $wpdb->get_results($sql);
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
break;
|
1268 |
|
1269 |
default:
|
1270 |
$results = $wpdb->get_results($sql, OBJECT);
|
1271 |
}
|
1272 |
-
|
1273 |
if ($results !== false) {
|
1274 |
return array(
|
1275 |
'visitors' => (empty($results[0]->vst_visitors) ? 0 : $results[0]->vst_visitors),
|
@@ -1289,7 +1365,8 @@ and vst_date < DATE_FORMAT(CONVERT_TZ('".$current_date->format('Y-m-d')." 00:00:
|
|
1289 |
*
|
1290 |
* @return array
|
1291 |
*/
|
1292 |
-
function ahcfree_get_visitors_visits_by_date()
|
|
|
1293 |
global $wpdb;
|
1294 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT - 1;
|
1295 |
$response = array();
|
@@ -1327,7 +1404,8 @@ function ahcfree_get_visitors_visits_by_date() {
|
|
1327 |
return $response;
|
1328 |
}
|
1329 |
|
1330 |
-
function ahcfree_get_visitors_by_date()
|
|
|
1331 |
global $wpdb;
|
1332 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT;
|
1333 |
$response = array();
|
@@ -1359,7 +1437,8 @@ function ahcfree_get_visitors_by_date() {
|
|
1359 |
return '[' . $xx . ']';
|
1360 |
}
|
1361 |
|
1362 |
-
function ahcfree_get_visits_by_date()
|
|
|
1363 |
global $wpdb;
|
1364 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT;
|
1365 |
$response = array();
|
@@ -1402,30 +1481,31 @@ function ahcfree_get_visits_by_date() {
|
|
1402 |
|
1403 |
|
1404 |
|
1405 |
-
function ahcfree_get_serch_visits_by_date()
|
|
|
1406 |
global $wpdb;
|
1407 |
-
|
1408 |
$response = array();
|
1409 |
$sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.srh_id = ase.srh_id GROUP by asv.srh_id order by SUM(asv.vtsh_visits) DESC";
|
1410 |
|
1411 |
|
1412 |
$results = $wpdb->get_results($sql, OBJECT);
|
1413 |
-
|
1414 |
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
|
|
1418 |
$response['success'] = true;
|
1419 |
$data = '';
|
1420 |
$c = 0;
|
1421 |
foreach ($results as $r) {
|
1422 |
-
$data .= "['"
|
1423 |
$c++;
|
1424 |
}
|
1425 |
} else {
|
1426 |
$data = '';
|
1427 |
}
|
1428 |
-
|
1429 |
return $data;
|
1430 |
}
|
1431 |
|
@@ -1438,7 +1518,8 @@ function ahcfree_get_serch_visits_by_date() {
|
|
1438 |
*
|
1439 |
* @return mixed
|
1440 |
*/
|
1441 |
-
function ahcfree_get_total_visits_by_search_engines()
|
|
|
1442 |
global $wpdb;
|
1443 |
$result = $wpdb->get_results("SELECT SUM(vtsh_visits) AS total FROM ahc_searching_visits", OBJECT);
|
1444 |
if ($result !== false) {
|
@@ -1457,7 +1538,8 @@ function ahcfree_get_total_visits_by_search_engines() {
|
|
1457 |
* @param string $period Optional
|
1458 |
* @return mixed
|
1459 |
*/
|
1460 |
-
function ahcfree_get_hits_search_engines_referers($period = 'total')
|
|
|
1461 |
global $wpdb;
|
1462 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1463 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
@@ -1467,8 +1549,8 @@ function ahcfree_get_hits_search_engines_referers($period = 'total') {
|
|
1467 |
$results = false;
|
1468 |
switch ($period) {
|
1469 |
case 'today':
|
1470 |
-
$sql .= " AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) = '". ahcfree_localtime('Y-m-d') ."'";
|
1471 |
-
|
1472 |
$results = $wpdb->get_results($sql, OBJECT);
|
1473 |
break;
|
1474 |
|
@@ -1493,13 +1575,13 @@ function ahcfree_get_hits_search_engines_referers($period = 'total') {
|
|
1493 |
$sql .= " AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
|
1494 |
$results = $wpdb->get_results($wpdb->prepare($sql, $date->format('Y-01-01'), $date->format('Y-12-31')), OBJECT);
|
1495 |
break;
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
|
1504 |
default:
|
1505 |
}
|
@@ -1507,7 +1589,7 @@ function ahcfree_get_hits_search_engines_referers($period = 'total') {
|
|
1507 |
$hitsReferers = array();
|
1508 |
if ($results !== false) {
|
1509 |
foreach ($results as $r) {
|
1510 |
-
|
1511 |
$hitsReferers[$r->srh_name] = $r->vtsh_visits;
|
1512 |
}
|
1513 |
return $hitsReferers;
|
@@ -1523,7 +1605,8 @@ function ahcfree_get_hits_search_engines_referers($period = 'total') {
|
|
1523 |
*
|
1524 |
* @return mixed
|
1525 |
*/
|
1526 |
-
function ahcfree_get_all_search_engines()
|
|
|
1527 |
global $wpdb;
|
1528 |
$sql = "SELECT `srh_id`, `srh_name`, `srh_icon` FROM `ahc_search_engines`";
|
1529 |
$searchEngines = array();
|
@@ -1549,7 +1632,8 @@ function ahcfree_get_all_search_engines() {
|
|
1549 |
*
|
1550 |
* @return array
|
1551 |
*/
|
1552 |
-
function ahcfree_get_browsers_hits_counts()
|
|
|
1553 |
global $wpdb;
|
1554 |
$sql = "SELECT `bsr_id`, `bsr_name`, `bsr_visits`
|
1555 |
FROM `ahc_browsers`
|
@@ -1561,13 +1645,13 @@ function ahcfree_get_browsers_hits_counts() {
|
|
1561 |
$data = '';
|
1562 |
$c = 0;
|
1563 |
foreach ($results as $bsr) {
|
1564 |
-
$data .= "['"
|
1565 |
$c++;
|
1566 |
}
|
1567 |
} else {
|
1568 |
$data = '';
|
1569 |
}
|
1570 |
-
|
1571 |
return $data;
|
1572 |
}
|
1573 |
|
@@ -1580,26 +1664,26 @@ function ahcfree_get_browsers_hits_counts() {
|
|
1580 |
*
|
1581 |
* @return mixed
|
1582 |
*/
|
1583 |
-
function ahcfree_get_top_refering_sites($start=''
|
|
|
1584 |
global $wpdb;
|
1585 |
-
$limitCond="";
|
1586 |
-
if($start!='' && $limit!='')
|
1587 |
-
|
1588 |
-
$sql = "SELECT rfr_site_name, rfr_visits
|
1589 |
FROM `ahc_refering_sites`
|
1590 |
ORDER BY rfr_visits DESC LIMIT %d, %d ";
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
FROM `ahc_refering_sites`
|
1596 |
ORDER BY rfr_visits DESC LIMIT 20 ";
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
|
|
|
|
1600 |
|
1601 |
-
|
1602 |
-
|
1603 |
if ($results !== false) {
|
1604 |
$arr = array();
|
1605 |
$c = 0;
|
@@ -1623,82 +1707,74 @@ function ahcfree_get_top_refering_sites($start='',$limit='') {
|
|
1623 |
*
|
1624 |
* @return mixed
|
1625 |
*/
|
1626 |
-
function ahcfree_get_top_countries(
|
|
|
1627 |
global $wpdb;
|
1628 |
-
if(
|
1629 |
$limit = AHCFREE_TOP_COUNTRIES_LIMIT;
|
1630 |
}
|
1631 |
-
|
1632 |
-
if($cnt==true)
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
}
|
1639 |
-
|
1640 |
$limitCond = "";
|
1641 |
-
if($start !='' && $pagelimit!='')
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
if($limit > 0 && $pagelimit == "" )
|
1650 |
-
{
|
1651 |
-
$sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
|
1652 |
FROM `ahc_countries` WHERE ctr_visits > 0
|
1653 |
ORDER BY ctr_visitors DESC
|
1654 |
LIMIT %d OFFSET 0";
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
{
|
1660 |
-
$sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
|
1661 |
FROM `ahc_countries` WHERE ctr_visits > 0
|
1662 |
ORDER BY ctr_visitors DESC $limitCond";
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
$response = array();
|
1667 |
if ($results !== false) {
|
1668 |
-
|
1669 |
$response['success'] = true;
|
1670 |
$response['data'] = array();
|
1671 |
$c = 0;
|
1672 |
-
if($start=="")
|
1673 |
-
|
1674 |
-
$rank
|
1675 |
foreach ($results as $ctr) {
|
1676 |
$response['data'][$c]['rank'] = $rank;
|
1677 |
-
$furl = plugins_url('/images/flags/' . strtolower(
|
1678 |
-
$flag ='<img src="'.esc_url($furl).'" border="0" alt="'.esc_attr($ctr->ctr_name).'" width="30" height="20" onerror="imgFlagError(this)" />';
|
1679 |
$response['data'][$c]['flag'] = $flag;
|
1680 |
$response['data'][$c]['ctr_name'] = $ctr->ctr_name;
|
1681 |
//$response['data'][$c]['ctr_internet_code'] = $ctr->ctr_internet_code;
|
1682 |
$response['data'][$c]['visitors'] = $ctr->ctr_visitors;
|
1683 |
$response['data'][$c]['visits'] = $ctr->ctr_visits;
|
1684 |
-
|
1685 |
-
if($all==1)
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
}
|
1692 |
$c++;
|
1693 |
$rank++;
|
1694 |
}
|
1695 |
} else {
|
1696 |
$response['success'] = false;
|
1697 |
}
|
1698 |
-
if($all==1)
|
1699 |
-
|
1700 |
-
|
1701 |
-
}
|
1702 |
return $response;
|
1703 |
}
|
1704 |
|
@@ -1711,126 +1787,108 @@ function ahcfree_get_top_countries( $limit = 0,$start='',$pagelimit='' ,$all='',
|
|
1711 |
*
|
1712 |
* @return mixed
|
1713 |
*/
|
1714 |
-
function ahcfree_get_vsitors_by_country($all
|
|
|
1715 |
global $wpdb;
|
1716 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1717 |
$vtr_date = "CONVERT_TZ(concat(vtr_date,' ',vtr_time), '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')";
|
1718 |
-
$cond="";
|
1719 |
-
if(isset($_POST['t_from_dt']) && $_POST['t_from_dt']!='' && isset($_POST['t_to_dt']) && $_POST['t_to_dt']!='' && isset($_POST['section']) && $_POST['section']=="traffic_index_country")
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
}
|
1744 |
-
else
|
1745 |
-
{
|
1746 |
-
$cond ="and DATE(CONVERT_TZ(concat(vtr_date,' ',vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '". ahcfree_localtime('Y-m-d') ."'";
|
1747 |
-
}
|
1748 |
-
|
1749 |
-
if($cnt==true)
|
1750 |
-
{
|
1751 |
-
/*$sql = "select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id $cond group by ctr_name) as tot order by tot.total desc";
|
1752 |
$results = $wpdb->get_results($sql, OBJECT);*/
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
$sql = $wpdb->prepare("select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc %s", $cond, $limitCond );
|
1770 |
-
$results = $wpdb->get_results($sql, OBJECT);
|
1771 |
-
//echo $sql;
|
1772 |
if ($results !== false) {
|
1773 |
$arr = array();
|
1774 |
$new = array();
|
1775 |
$c = 0;
|
1776 |
-
if($start=="")
|
1777 |
-
|
1778 |
-
$no
|
1779 |
-
$sum=0;
|
1780 |
foreach ($results as $ctr) {
|
1781 |
-
|
1782 |
/*if ($ctr->total > 1) {*/
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
/*} else {
|
1802 |
|
1803 |
$sum += 1;
|
1804 |
}*/
|
1805 |
-
|
1806 |
-
|
1807 |
}
|
1808 |
-
|
1809 |
-
if($sum>0)
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
}
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
return $arr;
|
1835 |
} else {
|
1836 |
return false;
|
@@ -1845,13 +1903,12 @@ function ahcfree_get_vsitors_by_country($all,$cnt=true,$start='',$limit='',$fdt=
|
|
1845 |
|
1846 |
function ahcfree_haship($ip)
|
1847 |
{
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
}
|
1855 |
}
|
1856 |
//--------------------------------------------
|
1857 |
/**
|
@@ -1862,77 +1919,66 @@ function ahcfree_haship($ip)
|
|
1862 |
*
|
1863 |
* @return mixed
|
1864 |
*/
|
1865 |
-
|
1866 |
-
function ahcfree_get_recent_visitors($all
|
|
|
1867 |
global $wpdb, $_SERVER;
|
1868 |
-
$cond="";
|
1869 |
-
$cond1="";
|
1870 |
$ahcfree_save_ips = get_option('ahcfree_save_ips_opn');
|
1871 |
-
|
1872 |
-
if(isset($_POST['r_from_dt']) && $_POST['r_from_dt']!='' && isset($_POST['r_to_dt']) && $_POST['r_to_dt']!='' && isset($_POST['section']) && $_POST['section']=='recent_visitor_by_ip')
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
{
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
if($
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
$cond1 .=" and (vtr_date between '$fromdt' and '$todt')";
|
1899 |
-
}
|
1900 |
-
else if($fdt!='' && $tdt='')
|
1901 |
-
{
|
1902 |
-
$fromdt = ahcfree_getFormattedDate($fdt,'yymmdd');
|
1903 |
-
$cond .=" and dt ='$fromdt'";
|
1904 |
-
$cond1 .=" and dt ='$fromdt'";
|
1905 |
-
}
|
1906 |
-
|
1907 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1908 |
-
if($cnt==true)
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
$sql_query = "SELECT v.vtr_id, v.vtr_ip_address, v.vtr_referer, DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as dt ,DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as vtr_date, DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%H:%i:%s') as vtr_time, v.ahc_city, v.ahc_region,
|
1927 |
c.ctr_name, c.ctr_internet_code, b.bsr_name, b.bsr_icon
|
1928 |
FROM `ahc_recent_visitors` AS v
|
1929 |
LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id
|
1930 |
LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id
|
1931 |
WHERE 1=1 and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond
|
1932 |
ORDER BY v.vtr_id DESC $limitCond";
|
1933 |
-
|
1934 |
$results = $wpdb->get_results($sql_query);
|
1935 |
-
|
1936 |
if ($results !== false) {
|
1937 |
$arr = array();
|
1938 |
$new = array();
|
@@ -1940,60 +1986,58 @@ function ahcfree_get_recent_visitors($all,$cnt=true,$start='',$limit='',$fdt='',
|
|
1940 |
if (is_array($results)) {
|
1941 |
foreach ($results as $hit) {
|
1942 |
if (strlen($hit->vtr_ip_address) < 17) {
|
1943 |
-
|
1944 |
-
|
1945 |
$arr[$c]['hit_id'] = $hit->vtr_id;
|
1946 |
$hit_referer = (parse_url($hit->vtr_referer, PHP_URL_HOST) == $_SERVER['SERVER_NAME']) ? '' : rawurldecode($hit->vtr_referer);
|
1947 |
-
$hitip = (!empty($hit->hit_referer) ? '<a href="'.esc_url($hit_referer).'" target="_blank"><img src="'.esc_url(plugins_url('/images/openW.jpg', AHCFREE_PLUGIN_MAIN_FILE)).'" title="'.esc_attr(ahc_view_referer).'"></a>' : '');
|
1948 |
-
$arr[$c]['hit_ip_address'] = (get_option('ahcfree_ahcfree_haships') != '1') ? $hit->vtr_ip_address ." ". $hitip : ahcfree_haship($hit->vtr_ip_address) ." ". $hitip;
|
1949 |
-
$img="";
|
1950 |
-
if (
|
1951 |
-
{
|
1952 |
$imgurl = plugins_url('/images/flags/' . strtolower($hit->ctr_internet_code) . '.png', AHCFREE_PLUGIN_MAIN_FILE);
|
1953 |
-
$img = "<img src='".esc_url($imgurl)."' border='0' width='22' height='18' title='".esc_attr($hit->ctr_name)."' onerror='imgFlagError(this)' /> ";
|
1954 |
}
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
$arr[$c]['hit_date'] = $hit->vtr_date;
|
1959 |
$arr[$c]['hit_time'] = $hit->vtr_time;
|
1960 |
-
|
1961 |
$arr[$c]['ctr_internet_code'] = $hit->ctr_internet_code;
|
1962 |
$arr[$c]['bsr_name'] = $hit->bsr_name;
|
1963 |
$arr[$c]['bsr_icon'] = $hit->bsr_icon;
|
1964 |
-
|
1965 |
if (strpos($hit->ahc_region, '}')) {
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
$arr[$c]['time'] = $visitDate->format('d M Y @ h:i a');
|
1983 |
-
|
1984 |
-
if($all==1)
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
$c++;
|
1992 |
}
|
1993 |
}
|
1994 |
}
|
1995 |
-
if($all==1)
|
1996 |
-
|
1997 |
return $arr;
|
1998 |
} else {
|
1999 |
return false;
|
@@ -2009,46 +2053,42 @@ function ahcfree_get_recent_visitors($all,$cnt=true,$start='',$limit='',$fdt='',
|
|
2009 |
*
|
2010 |
* @return mixed
|
2011 |
*/
|
2012 |
-
function ahcfree_get_latest_search_key_words_used($all
|
|
|
2013 |
global $wpdb;
|
2014 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
{
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
{
|
2048 |
-
$limitCond="";
|
2049 |
-
}
|
2050 |
-
|
2051 |
-
$sql = "SELECT k.kwd_date as dt,k.kwd_ip_address, k.kwd_referer, k.kwd_keywords, CONVERT_TZ(CONCAT_WS(' ',k.kwd_date,k.kwd_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') as kwd_date, CONVERT_TZ(k.kwd_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') as kwd_time, k.ctr_id,
|
2052 |
c.ctr_name, c.ctr_internet_code, b.bsr_name, b.bsr_icon, s.srh_name, s.srh_icon
|
2053 |
FROM `ahc_keywords` AS k
|
2054 |
LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id
|
@@ -2056,18 +2096,18 @@ function ahcfree_get_latest_search_key_words_used($all,$cnt=true,$start='',$limi
|
|
2056 |
JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id
|
2057 |
WHERE k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond
|
2058 |
ORDER BY k.kwd_date DESC, k.kwd_time DESC $limitCond";
|
2059 |
-
|
2060 |
-
|
2061 |
if ($results !== false) {
|
2062 |
$arr = array();
|
2063 |
$new = array();
|
2064 |
$c = 0;
|
2065 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2066 |
$custom_timezone_string = ahcfree_get_timezone_string();
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
foreach ($results as $re) {
|
2072 |
|
2073 |
$arr[$c]['hit_referer'] = rawurldecode($re->kwd_referer);
|
@@ -2081,39 +2121,38 @@ function ahcfree_get_latest_search_key_words_used($all,$cnt=true,$start='',$limi
|
|
2081 |
$arr[$c]['bsr_icon'] = $re->bsr_icon;
|
2082 |
$arr[$c]['srh_name'] = $re->srh_name;
|
2083 |
$arr[$c]['srh_icon'] = $re->srh_icon;
|
2084 |
-
|
2085 |
-
$img='<span>';
|
2086 |
-
if ($re->ctr_internet_code != '') {
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
$img.='<span><img src="'.$eurl.'" border="0" width="22" height="22" title="'.$re->srh_name.'" /></span>';
|
2093 |
|
2094 |
$burl=plugins_url('/images/browsers/' . $re->bsr_icon, AHCFREE_PLUGIN_MAIN_FILE);
|
2095 |
$img.='<span><img src="'.$burl.'" border="0" width="20" height="20" title="'.$re->bsr_name.'" /></span>';
|
2096 |
*/
|
2097 |
-
$arr[$c]['img']
|
2098 |
-
$arr[$c]['csb']
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
}
|
2113 |
$c++;
|
2114 |
}
|
2115 |
-
if($all==1)
|
2116 |
-
|
2117 |
return $arr;
|
2118 |
} else {
|
2119 |
return false;
|
@@ -2126,19 +2165,18 @@ function ahcfree_get_latest_search_key_words_used($all,$cnt=true,$start='',$limi
|
|
2126 |
*
|
2127 |
* @return boolean
|
2128 |
*/
|
2129 |
-
function ahcfree_is_login_page()
|
|
|
2130 |
global $GLOBALS;
|
2131 |
-
|
2132 |
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
}
|
2141 |
-
|
2142 |
}
|
2143 |
|
2144 |
//--------------------------------------------
|
@@ -2149,38 +2187,37 @@ function ahcfree_is_login_page() {
|
|
2149 |
*
|
2150 |
* @return array
|
2151 |
*/
|
2152 |
-
function ahcfree_get_today_visitors_for_map($map_status = '')
|
|
|
2153 |
global $wpdb;
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
$results
|
2179 |
-
|
2180 |
-
|
2181 |
-
$
|
2182 |
-
$response['data'] = array();
|
2183 |
-
if (is_array($results) && isset($results[0]->visitors) && !empty($results[0]->visitors)) {
|
2184 |
foreach ($results as $r) {
|
2185 |
$response['data'][$r->ctr_id]['visitors'] = $r->visitors;
|
2186 |
$response['data'][$r->ctr_id]['ctr_name'] = $r->ctr_name;
|
@@ -2194,7 +2231,8 @@ function ahcfree_get_today_visitors_for_map($map_status = '') {
|
|
2194 |
}
|
2195 |
return $response;
|
2196 |
}
|
2197 |
-
function ahcfree_get_all_visitors_for_map()
|
|
|
2198 |
global $wpdb;
|
2199 |
$sql = "SELECT c.`ctr_visitors` as visitors, c.ctr_id, c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude from `ahc_countries` c where c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 group by `ctr_name` ORDER BY ctr_visitors desc LIMIT 10";
|
2200 |
|
@@ -2225,14 +2263,15 @@ function ahcfree_get_all_visitors_for_map() {
|
|
2225 |
*
|
2226 |
* @return array
|
2227 |
*/
|
2228 |
-
function ahcfree_get_online_visitors_for_map()
|
|
|
2229 |
global $wpdb;
|
2230 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2231 |
$sql = "SELECT hits.visitors, hits.ctr_id,
|
2232 |
c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude FROM (
|
2233 |
SELECT COUNT(v.visitor) AS visitors, v.ctr_id FROM (
|
2234 |
SELECT ctr_id, 1 AS visitor FROM `ahc_hits`
|
2235 |
-
WHERE ctr_id IS NOT NULL AND hit_ip_address NOT LIKE 'UNKNOWN%' and hit_date = DATE( CONVERT_TZ( '". ahcfree_localtime("Y-m-d H:i:s") ."' ,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) and TIME( CONVERT_TZ(hit_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) between TIME(CONVERT_TZ('". date("Y-m-d H:i:s") ."','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') - INTERVAL 60 SECOND) and TIME( CONVERT_TZ('". date("Y-m-d H:i:s") ."','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') )
|
2236 |
GROUP BY hit_ip_address
|
2237 |
) AS v
|
2238 |
GROUP BY ctr_id) AS hits
|
@@ -2267,7 +2306,8 @@ function ahcfree_get_online_visitors_for_map() {
|
|
2267 |
*
|
2268 |
* @return boolean
|
2269 |
*/
|
2270 |
-
function ahcfree_is_search_engine_bot()
|
|
|
2271 |
global $wpdb, $_SERVER;
|
2272 |
$results = $wpdb->get_results("SELECT `bot_name` FROM `ahc_search_engine_crawlers`", OBJECT);
|
2273 |
foreach ($results as $crawler) {
|
@@ -2296,7 +2336,8 @@ function ahcfree_is_search_engine_bot() {
|
|
2296 |
*
|
2297 |
* @return boolean
|
2298 |
*/
|
2299 |
-
function ahcfree_is_wordpress_bot()
|
|
|
2300 |
global $_SERVER;
|
2301 |
if (stripos($_SERVER['HTTP_USER_AGENT'], 'WordPress') !== false) {
|
2302 |
return true;
|
@@ -2314,7 +2355,8 @@ function ahcfree_is_wordpress_bot() {
|
|
2314 |
* @param object $query. this object is passed to the callback function of "parse_query" hooked action
|
2315 |
* @return mixed
|
2316 |
*/
|
2317 |
-
function ahcfree_detect_requested_page($query)
|
|
|
2318 |
global $wpdb;
|
2319 |
$vars = $query->query_vars;
|
2320 |
if (isset($vars['p']) && !empty($vars['p'])) {
|
@@ -2342,7 +2384,8 @@ function ahcfree_detect_requested_page($query) {
|
|
2342 |
}
|
2343 |
}
|
2344 |
|
2345 |
-
function ahcfree_get_subpage_name($page_name)
|
|
|
2346 |
$sub_name = strrchr($page_name, '/');
|
2347 |
if (!$sub_name) {
|
2348 |
return $page_name;
|
@@ -2387,36 +2430,34 @@ function ahcfree_get_subpage_name($page_name) {
|
|
2387 |
|
2388 |
function ahcfree_track_visitor()
|
2389 |
{
|
2390 |
-
|
2391 |
-
|
2392 |
if ($exclude_ips == '' or empty($exclude_ips)) {
|
2393 |
$exclude_ips = array();
|
2394 |
-
}else{
|
|
|
|
|
|
|
2395 |
|
2396 |
-
$exclude_ips = str_ireplace("\n"," ",$exclude_ips);
|
2397 |
-
$exclude_ips = str_ireplace(","," ",$exclude_ips);
|
2398 |
-
|
2399 |
$exclude_ips = explode(" ", $exclude_ips);
|
2400 |
}
|
2401 |
|
2402 |
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2406 |
|
2407 |
-
if($v!='')
|
2408 |
-
{
|
2409 |
-
|
2410 |
-
$exclude_ips_arr[] = trim($v);
|
2411 |
-
}
|
2412 |
-
}
|
2413 |
-
|
2414 |
|
2415 |
-
|
2416 |
if (!ahcfree_is_login_page() && !ahcfree_is_search_engine_bot() && !ahcfree_is_wordpress_bot()) {
|
2417 |
-
|
2418 |
if (!in_array($client_ip_address, $exclude_ips_arr)) {
|
2419 |
-
|
2420 |
|
2421 |
$page_id = intval($_POST['page_id']);
|
2422 |
$page_title = ahc_free_sanitize_text_or_array_field($_POST['page_title']);
|
@@ -2426,12 +2467,12 @@ function ahcfree_track_visitor()
|
|
2426 |
$_SERVER['SERVER_NAME'] = ahc_free_sanitize_text_or_array_field($_POST['servername']);
|
2427 |
$_SERVER['HTTP_HOST'] = ahc_free_sanitize_text_or_array_field($_POST['hostname']);
|
2428 |
$_SERVER['REQUEST_URI'] = ahc_free_sanitize_text_or_array_field($_POST['request_uri']);
|
2429 |
-
|
2430 |
$hitsCounter = new WPHitsCounter($page_id, $page_title, $post_type);
|
2431 |
$hitsCounter->traceVisitorHit();
|
2432 |
}
|
2433 |
}
|
2434 |
-
|
2435 |
die;
|
2436 |
}
|
2437 |
|
@@ -2444,7 +2485,8 @@ function ahcfree_track_visitor()
|
|
2444 |
* @param string $separator
|
2445 |
* @return float
|
2446 |
*/
|
2447 |
-
function ahcfree_ceil_dec($number, $precision, $separator)
|
|
|
2448 |
if (strpos($number, '.') !== false) {
|
2449 |
$numberpart = explode($separator, $number);
|
2450 |
$numberpart[1] = substr_replace($numberpart[1], $separator, $precision, 0);
|
@@ -2469,70 +2511,68 @@ function ahcfree_ceil_dec($number, $precision, $separator) {
|
|
2469 |
*
|
2470 |
* @return mixed
|
2471 |
*/
|
2472 |
-
function ahcfree_get_traffic_by_title($all
|
|
|
2473 |
|
2474 |
global $wpdb;
|
2475 |
-
|
2476 |
$sql1 = "SELECT SUM(hits) AS sm FROM (
|
2477 |
SELECT SUM(til_hits) AS hits
|
2478 |
FROM ahc_title_traffic
|
2479 |
GROUP BY til_page_id
|
2480 |
) myTable";
|
2481 |
-
|
2482 |
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
$sql2 = "SELECT til_page_id, til_page_title, til_hits
|
2492 |
FROM ahc_title_traffic where 1=1 $cond
|
2493 |
GROUP BY til_page_id , til_page_title, til_hits
|
2494 |
-
ORDER BY til_hits DESC limit %d, %d";
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
$sql2 = "SELECT til_page_id, til_page_title, til_hits
|
2504 |
FROM ahc_title_traffic where 1=1 $cond
|
2505 |
GROUP BY til_page_id , til_page_title, til_hits
|
2506 |
ORDER BY til_hits DESC limit %d, %d";
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
$result1 = $wpdb->get_results($sql1);
|
2514 |
-
if ($result1 !== false && $sql2!='') {
|
2515 |
$total = $result1[0]->sm;
|
2516 |
-
|
2517 |
$result2 = $wpdb->get_results($wpdb->prepare($sql2, $start, $limit));
|
2518 |
if ($result2 !== false) {
|
2519 |
$arr = array();
|
2520 |
if ($wpdb->num_rows > 0) {
|
2521 |
$c = 0;
|
2522 |
-
if($start=="")
|
2523 |
-
|
2524 |
-
$no
|
2525 |
foreach ($result2 as $r) {
|
2526 |
-
|
2527 |
$arr[$c]['rank'] = $no + 1;
|
2528 |
//$arr[$c]['til_page_id'] = $r->til_page_id;
|
2529 |
-
if($all==1)
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
$arr[$c]['til_hits'] = $r->til_hits;
|
2534 |
-
|
2535 |
-
$arr[$c]['percent'] = ahcfree_NumFormat($ans).'%';
|
2536 |
$c++;
|
2537 |
$no++;
|
2538 |
}
|
@@ -2551,176 +2591,157 @@ function ahcfree_get_traffic_by_title($all,$cnt=false, $start='0', $limit='10',$
|
|
2551 |
*
|
2552 |
* @return mixed
|
2553 |
*/
|
2554 |
-
function ahcfree_get_time_visits($all
|
|
|
2555 |
global $wpdb;
|
2556 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
{
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
$cond = "DATE($vst_date) = '".ahcfree_localtime('Y-m-d')."'";
|
2586 |
-
$groupby = " hour($vst_date)";
|
2587 |
-
}
|
2588 |
-
|
2589 |
-
$sql1 = "SELECT SUM(vtm_visitors) AS sm FROM ahc_visits_time WHERE DATE($vst_date) = '".ahcfree_localtime('Y-m-d')."'";
|
2590 |
-
|
2591 |
-
|
2592 |
-
$sql2 = "SELECT date(vst_date) as dt,hour($vst_date) AS hour, SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits FROM `ahc_visitors`
|
2593 |
WHERE $cond GROUP BY $groupby";
|
2594 |
-
|
2595 |
-
|
2596 |
//$result1 = $wpdb->get_results($sql1);
|
2597 |
//if ($result1 !== false) {
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
'visits' => $r->vst_visits,
|
2620 |
-
'counter' => 1
|
2621 |
-
);
|
2622 |
-
}
|
2623 |
-
//$dtArr[]= $hourDetails;
|
2624 |
-
$total += $r->vst_visitors;
|
2625 |
}
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
$avgtotal = 0;
|
2643 |
-
for( $i = $start; $i < $end; $i++ ){
|
2644 |
-
|
2645 |
-
$vtm_visitors = 0;
|
2646 |
-
$vtm_visits = 0;
|
2647 |
-
$totalDt = count($hourDetails);
|
2648 |
-
|
2649 |
-
if( isset( $hourDetails[$i] ) ){
|
2650 |
-
$vtm_visitors = $hourDetails[$i]['visitor']/$hourDetails[$i]['counter'];
|
2651 |
-
$avgtotal +=$vtm_visitors;
|
2652 |
-
$vtm_visits = $hourDetails[$i]['visits']/$hourDetails[$i]['counter'];
|
2653 |
-
}
|
2654 |
-
if( $i < 10 ){
|
2655 |
-
$timeTo = $timeFrom = '0'.$i;
|
2656 |
-
}else{
|
2657 |
-
$timeTo = $timeFrom = $i;
|
2658 |
-
}
|
2659 |
-
$arr[$k]['vtm_time_from'] = $timeFrom.':00';
|
2660 |
-
$arr[$k]['vtm_time_to'] = $timeTo.':59';
|
2661 |
-
// $arr[$k]['percent'] = ($total > 0) ? ahcfree_ceil_dec((($vtm_visitors / $total) * 100), 2, ".") : 0;
|
2662 |
-
|
2663 |
-
$arr[$k]['time'] = $timeFrom.':00 - '.$timeTo.':59';
|
2664 |
-
|
2665 |
-
$arr[$k]['vtm_visitors'] = ceil($vtm_visitors);
|
2666 |
-
$arr[$k]['vtm_visits'] = ceil($vtm_visits);
|
2667 |
-
|
2668 |
-
if($all==1)
|
2669 |
-
{
|
2670 |
-
$new[$k]['time'] = $timeFrom.':00 - '.$timeTo.':59';
|
2671 |
-
$new[$k]['vtm_visitors'] = ceil($vtm_visitors);
|
2672 |
-
$new[$k]['vtm_visits'] = ceil($vtm_visits);
|
2673 |
-
}
|
2674 |
-
$k++;
|
2675 |
-
}
|
2676 |
-
$avgtotal = $total;
|
2677 |
-
|
2678 |
-
$j=0;
|
2679 |
-
for( $i = $start; $i < $end; $i++ )
|
2680 |
-
{
|
2681 |
-
if( isset( $hourDetails[$i] ) )
|
2682 |
-
{
|
2683 |
-
$vtm_visitors = $hourDetails[$i]['visitor']/$hourDetails[$i]['counter'];
|
2684 |
-
}else{
|
2685 |
-
$vtm_visitors = 0;
|
2686 |
-
}
|
2687 |
-
|
2688 |
-
$arr[$j]['percent'] = ($avgtotal > 0) ? ahcfree_ceil_dec((($vtm_visitors / $total) * 100), 2, ".") : 0;
|
2689 |
-
$per = ($avgtotal > 0) ? ahcfree_ceil_dec((($vtm_visitors / $avgtotal) * 100), 2, ".") : 0;
|
2690 |
-
|
2691 |
-
if($all==1)
|
2692 |
-
$new[$j]['percent'] = $per;
|
2693 |
-
|
2694 |
-
if(ceil($per) > 25 && ceil($per) < 50)
|
2695 |
-
{
|
2696 |
-
$cls= 'visitorsGraph2';
|
2697 |
-
}
|
2698 |
-
else if (ceil($per) > 50)
|
2699 |
-
{
|
2700 |
-
$cls= 'visitorsGraph3';
|
2701 |
-
}
|
2702 |
-
else {
|
2703 |
-
$cls= 'visitorsGraph';
|
2704 |
-
}
|
2705 |
-
$css = (!empty($per)) ? 'style="width: ' . ceil($per) . '%;"' : '';
|
2706 |
-
$arr[$j]['graph'] = '<div class="visitorsGraphContainer"><div class="'.esc_attr($cls).'" '.$css.'> </div><div class="cleaner"></div></div><div class="visitorsPercent">('. ceil($per).')%</div>';
|
2707 |
-
$j++;
|
2708 |
-
$cls = '';
|
2709 |
-
$per = 0;
|
2710 |
-
}
|
2711 |
-
if($all==1)
|
2712 |
-
return $new;
|
2713 |
-
return $arr;
|
2714 |
}
|
2715 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2716 |
return false;
|
2717 |
-
|
2718 |
}
|
2719 |
|
2720 |
-
function ahcfree_advanced_get_link($url, $followRedirects = true)
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
}
|
2725 |
|
2726 |
//--------------------------------------------
|
@@ -2729,28 +2750,29 @@ function ahcfree_advanced_get_link($url, $followRedirects = true) {
|
|
2729 |
*
|
2730 |
* @return string
|
2731 |
*/
|
2732 |
-
function ahcfree_get_client_ip_address()
|
|
|
2733 |
global $_SERVER;
|
2734 |
$ipAddress = '';
|
2735 |
-
if (isset($_SERVER['HTTP_X_REAL_IP']) && !empty($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP']!='127.0.0.1') {
|
2736 |
$ipAddress = $_SERVER['HTTP_X_REAL_IP'];
|
2737 |
-
}else if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP']!='127.0.0.1') {
|
2738 |
$ipAddress = $_SERVER['HTTP_CLIENT_IP'];
|
2739 |
-
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']!='127.0.0.1') {
|
2740 |
$ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
2741 |
-
} else if (isset($_SERVER['HTTP_X_FORWARDED']) && !empty($_SERVER['HTTP_X_FORWARDED']) && $_SERVER['HTTP_X_FORWARDED']!='127.0.0.1') {
|
2742 |
$ipAddress = $_SERVER['HTTP_X_FORWARDED'];
|
2743 |
-
} else if (isset($_SERVER['HTTP_FORWARDED_FOR']) && !empty($_SERVER['HTTP_FORWARDED_FOR']) && $_SERVER['HTTP_FORWARDED_FOR']!='127.0.0.1') {
|
2744 |
$ipAddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
2745 |
-
} else if (isset($_SERVER['HTTP_FORWARDED']) && !empty($_SERVER['HTTP_FORWARDED']) && $_SERVER['HTTP_FORWARDED']!='127.0.0.1') {
|
2746 |
$ipAddress = $_SERVER['HTTP_FORWARDED'];
|
2747 |
-
} else if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR']!='127.0.0.1') {
|
2748 |
$ipAddress = $_SERVER['REMOTE_ADDR'];
|
2749 |
-
}
|
2750 |
$ipAddress = 'UNKNOWN';
|
2751 |
}
|
2752 |
|
2753 |
-
|
2754 |
$ipAddress = ahc_free_sanitize_text_or_array_field($ipAddress);
|
2755 |
$ipAddress = explode(',', $ipAddress);
|
2756 |
|
@@ -2768,31 +2790,35 @@ function ahcfree_get_client_ip_address() {
|
|
2768 |
*
|
2769 |
* @return void
|
2770 |
*/
|
2771 |
-
function ahcfree_include_scripts()
|
|
|
|
|
|
|
|
|
2772 |
wp_register_style('ahc_lang_css', plugins_url('/css/vtrts_css_stylesheet.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.4');
|
2773 |
wp_enqueue_style('ahc_lang_css');
|
2774 |
|
2775 |
-
|
2776 |
-
wp_register_script( 'slimselect_js', plugins_url('js/slimselect.min.js',AHCFREE_PLUGIN_MAIN_FILE), null, null, true );
|
2777 |
-
wp_enqueue_script('slimselect_js');
|
2778 |
|
|
|
|
|
2779 |
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
|
|
2784 |
wp_enqueue_style('ahc_bootstrap_css');
|
2785 |
|
2786 |
wp_enqueue_script('jquery');
|
2787 |
|
2788 |
-
wp_register_script('ahc_bootstrap_js', plugins_url('/lib/bootstrap/js/bootstrap.min.js',AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2789 |
wp_enqueue_script('ahc_bootstrap_js');
|
2790 |
|
2791 |
wp_register_script('ahc_lang_js', plugins_url('/lang/js/' . GlobalsAHC::$lang . '_lang.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2792 |
wp_enqueue_script('ahc_lang_js');
|
2793 |
|
2794 |
-
|
2795 |
-
|
2796 |
wp_enqueue_script('ahc_datatable_js');
|
2797 |
wp_register_script('ahc_tableexport_js', plugins_url('/js/dataTables.buttons.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2798 |
wp_enqueue_script('ahc_tableexport_js');
|
@@ -2800,65 +2826,58 @@ function ahcfree_include_scripts() {
|
|
2800 |
wp_enqueue_script('ahc_jzip_js');
|
2801 |
wp_register_script('ahc_tableexportbutton_js', plugins_url('/js/buttons.html5.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2802 |
wp_enqueue_script('ahc_tableexportbutton_js');
|
2803 |
-
|
2804 |
wp_register_script('ahc_xlscore_js', plugins_url('/js/xlsx.core.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2805 |
wp_enqueue_script('ahc_xlscore_js');
|
2806 |
wp_register_script('ahc_filesave_js', plugins_url('/js/FileSaver.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2807 |
wp_enqueue_script('ahc_filesave_js');
|
2808 |
wp_register_script('ahc_xls_js', plugins_url('/js/jhxlsx.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2809 |
wp_enqueue_script('ahc_xls_js');
|
2810 |
-
|
2811 |
wp_register_style('jquery_date_css', plugins_url('/css/datepicker.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2812 |
wp_enqueue_style('jquery_date_css');
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
|
2817 |
-
wp_register_script('ahc_main_js', plugins_url('/js/ahcfree_js_scripts.js', AHCFREE_PLUGIN_MAIN_FILE), '', '2.5');
|
2818 |
-
wp_enqueue_script('ahc_main_js');
|
2819 |
|
2820 |
-
wp_localize_script('ahc_main_js', 'ahc_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
|
2821 |
|
2822 |
-
|
2823 |
|
2824 |
-
|
2825 |
-
|
|
|
2826 |
|
|
|
2827 |
}
|
2828 |
|
2829 |
|
2830 |
|
2831 |
-
function ahcfree_settings_scripts()
|
|
|
2832 |
|
2833 |
|
2834 |
-
|
2835 |
wp_enqueue_style('ahc_bootstrap_css');
|
2836 |
|
2837 |
wp_enqueue_script('jquery');
|
2838 |
|
2839 |
-
wp_register_script('ahc_bootstrap_js', plugins_url('/lib/bootstrap/js/bootstrap.min.js',AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2840 |
wp_enqueue_script('ahc_bootstrap_js');
|
2841 |
|
2842 |
-
|
2843 |
-
|
2844 |
|
2845 |
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
}
|
2852 |
|
2853 |
|
2854 |
|
2855 |
//--------------------------------------------
|
2856 |
//---------------------------------------------Add button to the admin bar
|
2857 |
-
function ahcfree_vtrts_add_items($admin_bar)
|
|
|
2858 |
global $pluginsurl;
|
2859 |
|
2860 |
$wccpadminurl = get_admin_url();
|
2861 |
-
//The properties of the new item. Read More about the missing 'parent' parameter below
|
2862 |
$args = array(
|
2863 |
'id' => 'visitorstraffic',
|
2864 |
'title' => __('<img src="' . plugins_url('/images/vtrtspro.png', AHCFREE_PLUGIN_MAIN_FILE) . '" style="vertical-align:middle;margin-right:5px;" alt="visitor traffic" title="visitor traffic" />'),
|
@@ -2871,7 +2890,8 @@ function ahcfree_vtrts_add_items($admin_bar) {
|
|
2871 |
}
|
2872 |
|
2873 |
//---------------------------------------- Add plugin settings link to Plugins page
|
2874 |
-
function ahcfree_vtrtsp_plugin_add_settings_link($links)
|
|
|
2875 |
$settings_link = '<a href="admin.php?page=ahc_hits_counter_menu_free">' . __('visitor traffic') . '</a>';
|
2876 |
array_push($links, $settings_link);
|
2877 |
return $links;
|
@@ -2881,48 +2901,49 @@ function ahcfree_vtrtsp_plugin_add_settings_link($links) {
|
|
2881 |
|
2882 |
|
2883 |
|
2884 |
-
function ahcfree_get_hits_by_custom_duration_callback()
|
|
|
2885 |
$hits_duration = ahc_free_sanitize_text_or_array_field($_POST['hits_duration']);
|
2886 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2887 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
2888 |
-
|
2889 |
$myend_date = new DateTime();
|
2890 |
$myend_date->setTimezone($custom_timezone);
|
2891 |
-
|
2892 |
$end_date = $myend_date->format('Y-m-d');
|
2893 |
$full_end_date = $myend_date->format('Y-m-d 23:59:59');
|
2894 |
-
|
2895 |
$mystart_date = new DateTime();
|
2896 |
$mystart_date->setTimezone($custom_timezone);
|
2897 |
$stat = '';
|
2898 |
-
switch ($hits_duration){
|
2899 |
-
|
2900 |
case '7':
|
2901 |
$mystart_date->modify('-6 days');
|
2902 |
$start_date = $mystart_date->format('Y-m-d');
|
2903 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
2904 |
$interval = '1 day';
|
2905 |
-
|
2906 |
break;
|
2907 |
-
|
2908 |
case 'current_month':
|
2909 |
//$mystart_date->modify('0:00 first day of curent month');
|
2910 |
$start_date = $mystart_date->format('Y-m-01');
|
2911 |
-
|
2912 |
$full_start_date = $mystart_date->format('Y-m-01');
|
2913 |
-
|
2914 |
$interval = '1 day';
|
2915 |
-
|
2916 |
break;
|
2917 |
|
2918 |
case 'last_month':
|
2919 |
$mystart_date->modify('0:00 first day of previous month');
|
2920 |
$start_date = $mystart_date->format('Y-m-d');
|
2921 |
-
|
2922 |
$full_start_date = $mystart_date->format('Y-m-d');
|
2923 |
-
|
2924 |
$interval = '1 day';
|
2925 |
-
|
2926 |
break;
|
2927 |
|
2928 |
case '30':
|
@@ -2933,28 +2954,28 @@ function ahcfree_get_hits_by_custom_duration_callback(){
|
|
2933 |
$myend_date->modify('last day of previous month');
|
2934 |
$end_date = $myend_date->format('Y-m-d');
|
2935 |
$full_end_date = $myend_date->format('Y-m-d H:i:s');*/
|
2936 |
-
|
2937 |
$mystart_date->modify('-30 days');
|
2938 |
$start_date = $mystart_date->format('Y-m-d');
|
2939 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
2940 |
-
|
2941 |
$interval = '1 week';
|
2942 |
break;
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
case '0':
|
2947 |
-
|
2948 |
-
|
2949 |
break;
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
break;
|
2956 |
-
|
2957 |
-
default
|
2958 |
$mystart_date->modify(' - ' . (AHCFREE_VISITORS_VISITS_LIMIT - 1) . ' days');
|
2959 |
$start_date = $mystart_date->format('Y-m-d');
|
2960 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
@@ -2962,149 +2983,138 @@ function ahcfree_get_hits_by_custom_duration_callback(){
|
|
2962 |
break;
|
2963 |
}
|
2964 |
|
2965 |
-
$visits_visitors_data = ahcfree_get_visits_by_custom_duration_callback($full_start_date
|
2966 |
-
|
2967 |
-
|
2968 |
-
$response = array(
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
|
|
2978 |
die;
|
2979 |
}
|
2980 |
|
2981 |
|
2982 |
-
function ahcfree_get_visits_by_custom_duration_callback( $
|
|
|
2983 |
global $wpdb;
|
2984 |
$visits_arr = array();
|
2985 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2986 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
2987 |
-
|
2988 |
$results = false;
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
$cond = "DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE('". $start_date ." 00:00:00') AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE('". $end_date ." 23:59:59')";
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
{
|
3009 |
-
$sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, SUM(vst_visits) AS vst_visits,SUM(vst_visitors) as vst_visitors FROM ahc_visitors WHERE ". $cond ." GROUP BY DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
|
3010 |
-
}
|
3011 |
-
//echo $sql;
|
3012 |
$results = $wpdb->get_results($sql, OBJECT);
|
3013 |
if ($results !== false) {
|
3014 |
-
|
3015 |
-
if($stat == 'year')
|
3016 |
-
{
|
3017 |
-
for ($i = 1; $i <= ahcfree_localtime('n'); $i++) {
|
3018 |
-
$month = $mystart_date->format('m');
|
3019 |
-
$year = $mystart_date->format('Y');
|
3020 |
-
$total_days = cal_days_in_month(CAL_GREGORIAN, $month ,$year);
|
3021 |
-
|
3022 |
-
$visits_arr['visits'][] = array($mystart_date->format('Y-m-d'), 0);
|
3023 |
-
$visits_arr['visitors'][] = array($mystart_date->format('Y-m-d'), 0);
|
3024 |
-
$mystart_date->modify( '+'.$total_days.' days' );
|
3025 |
-
}
|
3026 |
-
}
|
3027 |
-
elseif($stat == 'all')
|
3028 |
-
{
|
3029 |
-
foreach($results as $key =>$element) {
|
3030 |
-
reset($results);
|
3031 |
-
if ($key === key($results)){
|
3032 |
-
$first_date = $element->vst_date;
|
3033 |
-
}
|
3034 |
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3096 |
}
|
3097 |
//echo $wpdb->last_query;
|
3098 |
return $visits_arr;
|
3099 |
-
|
3100 |
}
|
3101 |
-
function ahcfree_admin_notice_to_set_timezone()
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
|
|
3105 |
|
3106 |
-
|
3107 |
-
|
3108 |
}
|
3109 |
/*function ahcfree_get_visitors_by_custom_duration_callback( $start_date,$end_date ){
|
3110 |
|
@@ -3156,269 +3166,249 @@ function ahcfree_admin_notice_to_set_timezone(){
|
|
3156 |
|
3157 |
}*/
|
3158 |
|
3159 |
-
function ahcfree_getFormattedDate($date
|
3160 |
{
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
}
|
3169 |
-
|
3170 |
}
|
3171 |
-
add_action("wp_ajax_traffic_by_title","ahcfree_traffic_by_title_callback");
|
3172 |
function ahcfree_traffic_by_title_callback()
|
3173 |
{
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
echo json_encode($arr);
|
3200 |
-
exit;
|
3201 |
-
}
|
3202 |
}
|
3203 |
//add_action("wp_ajax_traffic_by_countries","ahcfree_traffic_by_countries_callback");
|
3204 |
function ahcfree_traffic_by_countries_callback()
|
3205 |
{
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
echo json_encode($arr);
|
3228 |
-
exit;
|
3229 |
-
}
|
3230 |
}
|
3231 |
|
3232 |
-
add_action("wp_ajax_recent_visitor_by_ip","ahcfree_recent_visitor_by_ip_callback");
|
3233 |
function ahcfree_recent_visitor_by_ip_callback()
|
3234 |
{
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
echo json_encode($arr);
|
3263 |
-
exit;
|
3264 |
-
}
|
3265 |
}
|
3266 |
-
add_action("wp_ajax_latest_search_words","ahcfree_latest_search_words_callback");
|
3267 |
function ahcfree_latest_search_words_callback()
|
3268 |
{
|
3269 |
-
|
3270 |
-
{
|
3271 |
-
|
3272 |
-
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3273 |
-
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3274 |
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
|
|
3299 |
}
|
3300 |
-
add_action("wp_ajax_today_traffic_index","ahcfree_today_traffic_index_callback");
|
3301 |
function ahcfree_today_traffic_index_callback()
|
3302 |
{
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
echo json_encode($arr);
|
3328 |
-
exit;
|
3329 |
-
}
|
3330 |
}
|
3331 |
-
add_action("wp_ajax_visits_time_graph","ahcfree_visits_time_graph_callback");
|
3332 |
function ahcfree_visits_time_graph_callback()
|
3333 |
{
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
echo json_encode($arr);
|
3361 |
-
exit;
|
3362 |
-
}
|
3363 |
}
|
3364 |
|
3365 |
//------------------------------------------------------------------------
|
3366 |
// --------------------------------------- Create front-end widget
|
3367 |
// Creating the widget
|
3368 |
-
class ahcfree_vtrts_widget extends WP_Widget
|
|
|
3369 |
|
3370 |
-
function __construct()
|
|
|
3371 |
parent::__construct(
|
3372 |
-
// Base ID of your widget
|
3373 |
-
|
3374 |
-
// Widget name will appear in UI
|
3375 |
-
|
3376 |
-
// Widget description
|
3377 |
-
|
3378 |
);
|
3379 |
}
|
3380 |
|
3381 |
-
// Creating widget front-end
|
3382 |
-
// This is where the action happens
|
3383 |
-
public function widget($args, $instance)
|
|
|
3384 |
$title = apply_filters('widget_title', $instance['title']);
|
3385 |
-
// before and after widget arguments are defined by themes
|
3386 |
-
|
3387 |
if (!empty($title))
|
3388 |
echo esc_html($title);
|
3389 |
|
3390 |
|
3391 |
$ahc_sum_stats = ahcfree_get_summary_statistics();
|
3392 |
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
echo '<ul style="list-style:none; ' . esc_attr($instance['fontTypeCombo']) . '; font-size:' . esc_attr($instance['fontSizeCombo']) . 'px">';
|
3397 |
-
|
3398 |
-
if (isset($instance['display_visitorstoday']) && ($instance['display_visitorstoday'] == 1 or $instance['display_visitorstoday'] == '1')) {
|
3399 |
-
echo '<li><b>Today\'s visitors: </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visitors'])) . '</span></li>';
|
3400 |
-
}
|
3401 |
-
if (isset($instance['display_pageviewtoday']) && ($instance['display_pageviewtoday'] == 1 or $instance['display_pageviewtoday'] == '1')) {
|
3402 |
-
echo '<li><b>Today\'s page views: : </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visits'])) . '</span></li>';
|
3403 |
-
}
|
3404 |
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
|
|
|
|
|
|
3408 |
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
|
|
|
|
|
|
|
3413 |
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
}
|
3419 |
|
3420 |
-
// Widget Backend
|
3421 |
-
public function form($instance)
|
|
|
3422 |
extract($instance);
|
3423 |
|
3424 |
if (isset($instance['title'])) {
|
@@ -3426,23 +3416,23 @@ class ahcfree_vtrts_widget extends WP_Widget {
|
|
3426 |
} else {
|
3427 |
$title = __('Site Statistics', 'wpb_widget_domain');
|
3428 |
}
|
3429 |
-
// Widget admin form
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3430 |
|
3431 |
-
$fontTypeCombo = (isset($fontTypeCombo)) ? $fontTypeCombo : '';
|
3432 |
-
$display_valuescolor = (isset($display_valuescolor)) ? $display_valuescolor : '';
|
3433 |
-
$display_titlecolor = (isset($display_titlecolor)) ? $display_titlecolor : '';
|
3434 |
-
|
3435 |
-
|
3436 |
-
?>
|
3437 |
|
3438 |
-
|
3439 |
<p>
|
3440 |
-
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Widget Title:'); ?></label>
|
3441 |
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
|
3442 |
</p>
|
3443 |
|
3444 |
-
|
3445 |
-
|
3446 |
|
3447 |
|
3448 |
<p>
|
@@ -3480,8 +3470,8 @@ class ahcfree_vtrts_widget extends WP_Widget {
|
|
3480 |
<select class="widefat" id="<?php echo esc_attr($this->get_field_id('fontSizeCombo')); ?>" name="<?php echo esc_attr($this->get_field_name('fontSizeCombo')); ?>">
|
3481 |
<?php
|
3482 |
for ($fs = 8; $fs <= 22; $fs++) {
|
3483 |
-
|
3484 |
-
|
3485 |
<option value="<?php echo intval($fs) ?>" <?php selected($fontSizeCombo, $fs); ?>><?php echo intval($fs); ?>px</option>
|
3486 |
<?php } ?>
|
3487 |
</select>
|
@@ -3490,45 +3480,46 @@ class ahcfree_vtrts_widget extends WP_Widget {
|
|
3490 |
</p>
|
3491 |
|
3492 |
<p><em>Display :</em></p>
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
|
|
3500 |
|
3501 |
-
|
3502 |
<p>
|
3503 |
-
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_visitorstoday')); ?>" name="<?php echo esc_attr($this->get_field_name('display_visitorstoday')); ?>" type="checkbox" value="1" <?php checked($display_visitorstoday, '1');
|
3504 |
</p>
|
3505 |
<p>
|
3506 |
-
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_pageviewtoday')); ?>" name="<?php echo esc_attr($this->get_field_name('display_pageviewtoday')); ?>" type="checkbox" value="1" <?php checked($display_pageviewtoday, '1');
|
3507 |
</p>
|
3508 |
<p>
|
3509 |
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_totalpageview')); ?>" name="<?php echo esc_attr($this->get_field_name('display_totalpageview')); ?>" type="checkbox" value="1" <?php checked($display_totalpageview, '1'); ?> /> <label for="<?php echo esc_attr($this->get_field_id('display_totalpageview')); ?>">Total page views</label>
|
3510 |
</p>
|
3511 |
<p>
|
3512 |
-
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_totalvisitors')); ?>" name="<?php echo esc_attr($this->get_field_name('display_totalvisitors')); ?>" type="checkbox" value="1" <?php checked($display_totalvisitors, '1');
|
3513 |
</p>
|
3514 |
-
|
3515 |
-
|
3516 |
}
|
3517 |
|
3518 |
-
// Updating widget replacing old instances with new
|
3519 |
-
public function update($new_instance, $old_instance)
|
|
|
3520 |
|
3521 |
return $new_instance;
|
3522 |
}
|
3523 |
-
|
3524 |
}
|
3525 |
|
3526 |
// Class ahcfree_vtrts_widget ends here
|
3527 |
// Register and load the widget
|
3528 |
-
function ahcfree_wpb_load_widget()
|
|
|
3529 |
register_widget('ahcfree_vtrts_widget');
|
3530 |
}
|
3531 |
|
3532 |
add_action('widgets_init', 'ahcfree_wpb_load_widget');
|
3533 |
|
3534 |
-
?>
|
1 |
<?php
|
2 |
|
3 |
+
function vtrts_free_top_bar_enqueue_style()
|
4 |
+
{
|
5 |
|
6 |
?>
|
7 |
+
<style>
|
8 |
+
#wpadminbar #wp-admin-bar-vtrts_free_top_button .ab-icon:before {
|
9 |
+
content: "\f185";
|
10 |
+
color: #1DAE22;
|
11 |
+
top: 3px;
|
12 |
+
}
|
13 |
+
</style>
|
14 |
+
<?php
|
15 |
|
16 |
}
|
17 |
|
22 |
* @since 0.1
|
23 |
* @return mixed
|
24 |
*/
|
25 |
+
function ahc_free_sanitize_text_or_array_field($array_or_string)
|
26 |
+
{
|
27 |
+
if (is_string($array_or_string)) {
|
28 |
$array_or_string = sanitize_text_field($array_or_string);
|
29 |
+
} elseif (is_array($array_or_string)) {
|
30 |
+
foreach ($array_or_string as $key => &$value) {
|
31 |
+
if (is_array($value)) {
|
32 |
$value = ahc_free_sanitize_text_or_array_field($value);
|
33 |
+
} else {
|
34 |
+
$value = sanitize_text_field($value);
|
|
|
35 |
}
|
36 |
}
|
37 |
}
|
41 |
|
42 |
function vtrts_free_add_items($admin_bar)
|
43 |
{
|
44 |
+
if (!current_user_can('manage_options')) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
global $pluginsurl;
|
48 |
+
//The properties of the new item. Read More about the missing 'parent' parameter below
|
49 |
+
$args = array(
|
50 |
+
'id' => 'vtrts_free_top_button',
|
51 |
+
'parent' => null,
|
52 |
+
'group' => null,
|
53 |
+
'title' => '<span class="ab-icon"></span>' . '' . __('Stats', 'visitors-traffic-real-time-statistics'),
|
54 |
+
'href' => admin_url('admin.php?page=ahc_hits_counter_menu_free'),
|
55 |
+
'meta' => array(
|
56 |
+
'title' => __('visitor traffic real-time statistics', 'visitors-traffic-real-time-statistics'), //This title will show on hover
|
57 |
+
'class' => ''
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
//This is where the magic works.
|
62 |
+
$admin_bar->add_menu($args);
|
63 |
}
|
64 |
|
65 |
|
71 |
*
|
72 |
* @return void
|
73 |
*/
|
74 |
+
|
75 |
|
76 |
function ahcfree_localtime($dateformat)
|
77 |
{
|
78 |
+
if (function_exists('date_i18n')) {
|
79 |
+
|
80 |
+
return date_i18n($dateformat);
|
81 |
+
} else {
|
82 |
+
return gmdate($dateformat);
|
83 |
+
}
|
|
|
84 |
}
|
85 |
|
86 |
|
87 |
|
88 |
+
function ahcfree_getVisitsTime()
|
89 |
+
{
|
90 |
global $wpdb;
|
91 |
$result = $wpdb->get_results("SELECT COUNT( `vtm_id` ) cnt FROM ahc_visits_time", OBJECT);
|
92 |
if ($result !== false) {
|
100 |
* change plugin settings
|
101 |
* @return void
|
102 |
*/
|
103 |
+
|
104 |
+
function ahcfree_savesettings()
|
105 |
+
{
|
106 |
+
|
107 |
global $wpdb;
|
108 |
|
109 |
+
$ahcproUserRoles_ = '';
|
110 |
+
$ahcproExcludeRoles_ = '';
|
111 |
+
$verify = isset($_POST['ahc_settings_send']) ? wp_verify_nonce(sanitize_text_field($_POST['ahc_settings_send']), 'ahc_settings_action') : false;
|
112 |
|
113 |
+
if ($verify && current_user_can('manage_options')) {
|
|
|
114 |
|
115 |
+
$set_hits_days = intval($_POST['set_hits_days']);
|
116 |
+
$set_ajax_check = intval($_POST['set_ajax_check']);
|
117 |
+
$posts_type = '';
|
118 |
+
$set_ips = ahc_free_sanitize_text_or_array_field($_POST['set_ips']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
+
$set_google_map = '';
|
121 |
+
$ahcfree_hide_top_bar_icon = isset($_POST['ahcfree_hide_top_bar_icon']) ? intval($_POST['ahcfree_hide_top_bar_icon']) : '0';
|
122 |
+
$ahcfree_ahcfree_haships = isset($_POST['ahcfree_ahcfree_haships']) ? intval($_POST['ahcfree_ahcfree_haships']) : '0';
|
123 |
+
$delete_plugin_data = isset($_POST['delete_plugin_data']) ? intval($_POST['delete_plugin_data']) : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
$custom_timezone_offset = ahc_free_sanitize_text_or_array_field($_POST['set_custom_timezone']);
|
126 |
+
if ($custom_timezone_offset && $custom_timezone_offset != '') {
|
127 |
+
update_option('ahcfree_custom_timezone', $custom_timezone_offset);
|
128 |
+
}
|
129 |
|
130 |
+
$delete_plugin_data = (isset($delete_plugin_data)) ? intval($delete_plugin_data) : 0;
|
131 |
+
update_option('ahcfree_ahcfree_haships', $ahcfree_ahcfree_haships);
|
132 |
+
update_option('ahcfree_delete_plugin_data_on_uninstall', $delete_plugin_data);
|
133 |
+
update_option('ahcfree_hide_top_bar_icon', $ahcfree_hide_top_bar_icon);
|
134 |
|
135 |
+
$ahcproExcludeRoles = (isset($_POST['ahcproExcludeRoles']) && is_array($_POST['ahcproExcludeRoles'])) ? ahc_free_sanitize_text_or_array_field($_POST['ahcproExcludeRoles']) : ''; // sanitize inside the loop
|
136 |
+
|
137 |
+
if (isset($ahcproExcludeRoles)) {
|
138 |
+
foreach ($ahcproExcludeRoles as $v) {
|
139 |
+
|
140 |
+
$ahcproExcludeRoles_ .= $v . ",";
|
141 |
+
}
|
142 |
+
|
143 |
+
$ahcproExcludeRoles_ = substr($ahcproExcludeRoles_, 0, -1);
|
144 |
+
|
145 |
+
update_option('ahcproExcludeRoles', $ahcproExcludeRoles_);
|
146 |
+
}
|
147 |
|
148 |
+
|
149 |
+
$ahcproUserRoles = (isset($_POST['ahcproUserRoles']) && is_array($_POST['ahcproUserRoles'])) ? ahc_free_sanitize_text_or_array_field($_POST['ahcproUserRoles']) : ''; // sanitize inside the loop
|
150 |
+
if (isset($ahcproUserRoles)) {
|
151 |
+
foreach ($ahcproUserRoles as $v) {
|
152 |
+
|
153 |
+
$ahcproUserRoles_ .= $v . ",";
|
154 |
+
}
|
155 |
+
|
156 |
+
$ahcproUserRoles_ = substr($ahcproUserRoles_, 0, -1);
|
157 |
+
update_option('ahcproUserRoles', $ahcproUserRoles_);
|
158 |
+
}
|
159 |
+
|
160 |
+
ahcfree_update_tables();
|
161 |
+
|
162 |
+
$sql = $wpdb->prepare(
|
163 |
+
"UPDATE `ahc_settings` set `set_hits_days` = %s, `set_ajax_check` = %s, `set_ips` = %s, `set_google_map` = %s ",
|
164 |
+
$set_hits_days,
|
165 |
+
$set_ajax_check,
|
166 |
+
$set_ips,
|
167 |
+
$set_google_map
|
168 |
+
);
|
169 |
+
|
170 |
+
if ($wpdb->query($sql) !== false) {
|
171 |
+
|
172 |
+
return true;
|
173 |
+
}
|
174 |
+
}
|
175 |
|
176 |
return false;
|
177 |
}
|
245 |
return $ret;
|
246 |
}*/
|
247 |
|
248 |
+
function ahcfree_get_save_settings()
|
249 |
+
{
|
250 |
global $wpdb;
|
251 |
$table_exist = ahcfree_check_table_exists('ahc_settings');
|
252 |
+
if ($table_exist) {
|
253 |
$result = $wpdb->get_results("SELECT set_hits_days, set_ajax_check, set_ips, set_google_map FROM ahc_settings", OBJECT);
|
254 |
if ($result !== false) {
|
255 |
return $result;
|
256 |
}
|
257 |
}
|
258 |
+
|
259 |
return false;
|
260 |
}
|
261 |
|
262 |
+
function ahcfree_get_timezone_string()
|
263 |
+
{
|
264 |
$custom_timezone = get_option('ahcfree_custom_timezone');
|
265 |
if (!$custom_timezone) {
|
266 |
+
$wsmTimeZone = get_option('timezone_string');
|
267 |
+
if (is_null($wsmTimeZone) || $wsmTimeZone == '') {
|
268 |
+
$wsmTimeZone = ahcfree_GetWPTimezoneString();
|
269 |
+
}
|
270 |
+
$custom_timezone = ahcfree_CleanupTimeZoneString($wsmTimeZone);
|
271 |
+
|
272 |
+
/*
|
273 |
$custom_timezone = get_option( 'timezone_string' );
|
274 |
|
275 |
if ( ! empty( $custom_timezone ) ) {
|
283 |
$hours = '0'+$hours;
|
284 |
}
|
285 |
echo $custom_timezone = sprintf( '%s:%s', $hours, $minutes );*/
|
|
|
286 |
}
|
287 |
return $custom_timezone;
|
288 |
}
|
289 |
|
290 |
|
291 |
+
function ahcfree_CleanupTimeZoneString($tzString)
|
292 |
+
{
|
293 |
+
$time = new DateTime('now', new DateTimeZone($tzString));
|
294 |
+
return $time->format('P');
|
295 |
+
|
296 |
/*$offset=$tzString;
|
297 |
|
298 |
|
309 |
}
|
310 |
|
311 |
|
312 |
+
function ahcfree_GetWPTimezoneString()
|
313 |
+
{
|
314 |
// if site timezone string exists, return it
|
315 |
+
if ($timezone = get_option('timezone_string'))
|
316 |
return $timezone;
|
317 |
|
318 |
// get UTC offset, if it isn't set then return UTC
|
319 |
+
if (0 === ($utc_offset = get_option('gmt_offset', 0)))
|
320 |
return 'UTC';
|
321 |
|
322 |
// adjust UTC offset from hours to seconds
|
323 |
$utc_offset *= 3600;
|
324 |
|
325 |
// attempt to guess the timezone string from the UTC offset
|
326 |
+
if ($timezone = timezone_name_from_abbr('', $utc_offset, 0)) {
|
327 |
return $timezone;
|
328 |
}
|
329 |
|
330 |
// last try, guess timezone string manually
|
331 |
+
$is_dst = date('I');
|
332 |
|
333 |
+
foreach (timezone_abbreviations_list() as $abbr) {
|
334 |
+
foreach ($abbr as $city) {
|
335 |
+
if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset)
|
336 |
return $city['timezone_id'];
|
337 |
}
|
338 |
}
|
341 |
return 'UTC';
|
342 |
}
|
343 |
|
344 |
+
function ahcfree_get_current_timezone_offset()
|
345 |
+
{
|
346 |
$tz = ahcfree_get_timezone_string();
|
347 |
try {
|
348 |
$timeZone = new DateTimeZone($tz);
|
354 |
return $date->format('P');
|
355 |
}
|
356 |
|
357 |
+
function ahcfree_last_hit_date()
|
358 |
+
{
|
359 |
global $wpdb;
|
360 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
361 |
$sql = "SELECT max(CONVERT_TZ(vtr_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as last_date FROM ahc_recent_visitors";
|
367 |
return ahcfree_localtime('Y-m-d', time());
|
368 |
}
|
369 |
|
370 |
+
function ahcfree_getCountriesCount()
|
371 |
+
{
|
372 |
global $wpdb;
|
373 |
$result = $wpdb->get_results("SELECT COUNT( `ctr_id` ) cnt FROM ahc_countries", OBJECT);
|
374 |
if ($result !== false) {
|
377 |
return false;
|
378 |
}
|
379 |
|
380 |
+
function ahcfree_getBrowsersCount()
|
381 |
+
{
|
382 |
global $wpdb;
|
383 |
$result = $wpdb->get_results("SELECT COUNT( `bsr_id` ) cnt FROM ahc_browsers", OBJECT);
|
384 |
if ($result !== false) {
|
387 |
return false;
|
388 |
}
|
389 |
|
390 |
+
function ahcfree_getSearchEnginesCount()
|
391 |
+
{
|
392 |
global $wpdb;
|
393 |
$result = $wpdb->get_results("SELECT COUNT( `srh_id` ) cnt FROM ahc_search_engines", OBJECT);
|
394 |
if ($result !== false) {
|
397 |
return false;
|
398 |
}
|
399 |
|
400 |
+
function ahcfree_set_default_options()
|
401 |
+
{
|
402 |
+
|
403 |
+
|
404 |
+
if (is_multisite())
|
405 |
+
die('<b style="color:red">Sorry, This plugin can\'t be activated networkwide :(</b>');
|
406 |
+
|
407 |
+
|
408 |
// plugin activation
|
409 |
+
|
410 |
+
if (is_plugin_active('visitors-traffic-real-time-statistics-pro/visitors-traffic-real-time-statistics-pro.php')) {
|
411 |
+
deactivate_plugins('visitors-traffic-real-time-statistics-pro/visitors-traffic-real-time-statistics-pro.php');
|
412 |
+
}
|
413 |
require_once("database_basics_data.php");
|
414 |
if (get_option('ahcfree_wp_hits_counter_options') === false) {
|
415 |
|
445 |
ahcfree_insert_browsers_into_table($browsers);
|
446 |
}
|
447 |
}
|
|
|
448 |
}
|
449 |
|
450 |
|
458 |
*
|
459 |
* @return void
|
460 |
*/
|
461 |
+
function ahcfree_create_admin_menu_link()
|
462 |
+
{
|
463 |
+
|
464 |
+
global $current_user;
|
465 |
+
$ahcUserRoles = str_ireplace('Array', '', get_option('ahcproUserRoles'));
|
466 |
+
|
467 |
+
$ahcproUserRole = explode(',', $ahcUserRoles);
|
468 |
+
|
469 |
+
$roles_arr = array();
|
470 |
+
|
471 |
+
foreach ($ahcproUserRole as $k => $v) {
|
472 |
+
|
473 |
+
$roles_arr[] = strtolower($v);
|
474 |
+
}
|
475 |
+
|
476 |
+
$current_use_roles_ = $current_user->roles;
|
477 |
+
$current_use_roles_ = strtolower($current_use_roles_[0]);
|
478 |
+
|
479 |
+
if (!in_array($current_use_roles_, $roles_arr) && !current_user_can('manage_options')) {
|
480 |
+
return;
|
481 |
+
}
|
482 |
+
|
483 |
+
|
484 |
+
|
485 |
add_menu_page('Visitor Traffic Real Time Statistics Free', 'Visitor Traffic', 'manage_options', 'ahc_hits_counter_menu_free', 'ahcfree_create_plugin_overview_page', plugins_url('/images/vtrts.png', AHCFREE_PLUGIN_MAIN_FILE));
|
486 |
add_submenu_page('ahc_hits_counter_menu_free', 'Settings', 'Settings', 'manage_options', 'ahc_hits_counter_settings', 'ahcfree_create_plugin_settings_page');
|
487 |
add_submenu_page('ahc_hits_counter_menu_free', 'Contact Support', 'Help', 'manage_options', 'ahc_hits_counter_help', 'ahcfree_create_plugin_help_page');
|
488 |
+
|
489 |
+
|
490 |
+
|
491 |
+
$ahcfree_custom_timezone = get_option('ahcfree_custom_timezone', false);
|
492 |
+
if (!$ahcfree_custom_timezone) {
|
493 |
+
|
494 |
+
update_option('ahcfree_custom_timezone', get_option('timezone_string'));
|
495 |
+
add_action('admin_notices', 'ahcfree_admin_notice_to_set_timezone');
|
496 |
+
}
|
497 |
+
$page = isset($_GET['page']) ? ahc_free_sanitize_text_or_array_field($_GET['page']) : '';
|
498 |
+
|
499 |
+
|
500 |
+
|
501 |
+
if ($page == 'ahc_hits_counter_settings') {
|
502 |
+
remove_action('admin_notices', 'ahcfree_admin_notice_to_set_timezone');
|
503 |
+
}
|
504 |
}
|
505 |
|
506 |
//--------------------------------------------
|
509 |
*
|
510 |
* @return number
|
511 |
*/
|
512 |
+
function ahcfree_NumFormat($num)
|
513 |
+
{
|
514 |
if ($num > 1000) {
|
515 |
return number_format($num, 0, ',', ',');
|
516 |
} else {
|
523 |
|
524 |
function ahcfree_init()
|
525 |
{
|
526 |
+
//add_action('wp_ajax_ahcfree_countOnlineusers','ahcfree_countOnlineusers');
|
527 |
+
add_action('wp_ajax_ahcfree_track_visitor', 'ahcfree_track_visitor');
|
528 |
+
add_action('wp_ajax_nopriv_ahcfree_track_visitor', 'ahcfree_track_visitor');
|
529 |
+
|
530 |
+
ahcfree_update_tables();
|
|
|
531 |
}
|
532 |
+
add_action('admin_init', 'ahcfree_init');
|
533 |
|
534 |
function ahcfree_enqueue_scripts()
|
535 |
{
|
536 |
+
global $post, $wp_query;
|
537 |
+
$post_id = "HOMEPAGE";
|
538 |
+
$page_title = '';
|
539 |
+
$post_type = '';
|
540 |
+
if (is_singular() || is_page()) {
|
541 |
+
$post_id = $post->ID;
|
542 |
+
$page_title = get_the_title($post->ID);
|
543 |
+
$post_type = get_post_type($post->ID);
|
544 |
+
}
|
545 |
+
if (is_home()) {
|
546 |
+
$post_id = "BLOGPAGE";
|
547 |
+
}
|
548 |
+
if (is_archive()) {
|
549 |
+
$post_id = get_the_archive_title();
|
550 |
+
}
|
551 |
+
wp_register_script('ahc_front_js', plugins_url('/js/front.js', AHCFREE_PLUGIN_MAIN_FILE), 'jquery', '', false);
|
|
|
552 |
wp_enqueue_script('ahc_front_js');
|
553 |
|
554 |
+
wp_localize_script('ahc_front_js', 'ahc_ajax_front', array(
|
555 |
+
'ajax_url' => admin_url('admin-ajax.php'),
|
556 |
+
'page_id' => $post_id,
|
557 |
+
'page_title' => $page_title,
|
558 |
+
'post_type' => $post_type
|
559 |
+
));
|
560 |
}
|
561 |
+
add_action('wp_enqueue_scripts', 'ahcfree_enqueue_scripts', 1);
|
562 |
//--------------------------------------------
|
563 |
/**
|
564 |
* Creates the main overview page
|
565 |
*
|
566 |
* @return void
|
567 |
*/
|
568 |
+
function ahcfree_create_plugin_overview_page()
|
569 |
+
{
|
570 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
571 |
include("overview.php");
|
572 |
}
|
577 |
*
|
578 |
* @return void
|
579 |
*/
|
580 |
+
function ahcfree_create_plugin_settings_page()
|
581 |
+
{
|
582 |
|
583 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
584 |
include("ahc_settings.php");
|
590 |
*
|
591 |
* @return void
|
592 |
*/
|
593 |
+
function ahcfree_create_plugin_help_page()
|
594 |
+
{
|
595 |
|
596 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
597 |
include("ahc_help.php");
|
603 |
*
|
604 |
* @return void
|
605 |
*/
|
606 |
+
function ahcfree_create_plugin_about_page()
|
607 |
+
{
|
608 |
|
609 |
require_once(AHCFREE_PLUGIN_ROOT_DIR . AHCFREE_DS . 'lang' . AHCFREE_DS . GlobalsAHC::$lang . '_lang.php');
|
610 |
include("ahc_about.php");
|
619 |
*
|
620 |
* @return array
|
621 |
*/
|
622 |
+
function ahcfree_get_change_lang_links()
|
623 |
+
{
|
624 |
$plugin_options = get_option('ahcfree_wp_hits_counter_options');
|
625 |
$links = array();
|
626 |
$i = 0;
|
645 |
*
|
646 |
* @return boolean
|
647 |
*/
|
648 |
+
function ahcfree_should_track_visitor()
|
649 |
+
{
|
650 |
+
global $current_user;
|
651 |
$allow = true;
|
652 |
+
|
653 |
+
|
654 |
if (is_user_logged_in()) {
|
655 |
$user = new WP_User($current_user->ID);
|
656 |
if (!empty($user->roles) && is_array($user->roles)) {
|
657 |
foreach ($user->roles as $role) {
|
658 |
+
|
659 |
+
$ahcproExcludeRoles = get_option('ahcproExcludeRoles');
|
660 |
+
if (isset($ahcproExcludeRoles))
|
661 |
+
{
|
662 |
+
|
663 |
+
$ahcproExcludeRoles = explode(',',$ahcproExcludeRoles);
|
664 |
+
foreach($ahcproExcludeRoles as $k=>$v)
|
665 |
+
{
|
666 |
+
if (strtolower($v) == strtolower($role) )
|
667 |
+
{
|
668 |
+
return false;
|
669 |
+
}
|
670 |
+
}
|
671 |
+
}
|
672 |
+
/*$found = (isset(GlobalsPro::$plugin_options['user_roles_to_not_track'][$role])) ? GlobalsPro::$plugin_options['user_roles_to_not_track'][$role] : false;
|
673 |
if ($found) {
|
674 |
$allow = false;
|
675 |
break;
|
676 |
+
}*/
|
677 |
}
|
678 |
}
|
679 |
}
|
680 |
+
return true;
|
681 |
}
|
682 |
|
683 |
//--------------------------------------------
|
689 |
*
|
690 |
* @return boolean
|
691 |
*/
|
692 |
+
function ahcfree_has_administrator_role()
|
693 |
+
{
|
694 |
global $user_ID;
|
695 |
$is_admin = false;
|
696 |
if (is_user_logged_in()) {
|
715 |
*
|
716 |
* @return boolean
|
717 |
*/
|
718 |
+
function ahcfree_check_table_column_exists($table_name, $column_name)
|
719 |
+
{
|
720 |
global $wpdb;
|
721 |
$column = $wpdb->get_row($wpdb->prepare("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", DB_NAME, $table_name, $column_name));
|
722 |
|
734 |
*
|
735 |
* @return boolean
|
736 |
*/
|
737 |
+
function ahcfree_check_column_index_exists($table_name, $column_name)
|
738 |
+
{
|
739 |
global $wpdb;
|
740 |
+
|
741 |
+
$column = $wpdb->get_row("show index from " . $table_name . " where column_name='" . $column_name . "' ");
|
742 |
|
743 |
if (!empty($column)) {
|
744 |
+
|
745 |
return true;
|
746 |
}
|
747 |
+
|
748 |
return false;
|
749 |
}
|
750 |
|
757 |
*
|
758 |
* @return boolean
|
759 |
*/
|
760 |
+
function ahcfree_check_table_exists($table_name)
|
761 |
+
{
|
762 |
global $wpdb;
|
763 |
+
$table_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s", DB_NAME, $table_name));
|
764 |
|
765 |
if (!empty($table_data)) {
|
766 |
+
|
767 |
return true;
|
768 |
}
|
769 |
+
|
770 |
return false;
|
771 |
}
|
772 |
|
779 |
*
|
780 |
* @return boolean
|
781 |
*/
|
782 |
+
function ahcfree_update_tables()
|
783 |
+
{
|
784 |
global $wpdb;
|
785 |
$sqlQueries = array();
|
786 |
|
787 |
+
|
788 |
+
|
789 |
+
if (!ahcfree_check_column_index_exists('ahc_visitors', 'vst_date')) {
|
790 |
+
|
791 |
$sqlQueries[] = "alter table ahc_visitors add index idx_vst_date(vst_date)";
|
792 |
}
|
793 |
|
794 |
foreach ($sqlQueries as $sql) {
|
795 |
$wpdb->query($sql);
|
|
|
796 |
}
|
|
|
797 |
}
|
798 |
|
799 |
+
function ahcfree_add_settings()
|
800 |
+
{
|
801 |
|
802 |
global $wpdb;
|
803 |
+
|
804 |
+
$sql_ahc_settings = "CREATE TABLE IF NOT EXISTS `ahc_settings` (
|
805 |
`set_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
806 |
`set_hits_days` int(10) unsigned NOT NULL DEFAULT '14',
|
807 |
`set_ajax_check` int(10) unsigned NOT NULL DEFAULT '10',
|
810 |
|
811 |
PRIMARY KEY (`set_id`)
|
812 |
) DEFAULT CHARSET=utf8";
|
813 |
+
|
814 |
+
$wpdb->query($sql_ahc_settings);
|
815 |
+
|
816 |
+
|
817 |
$sql1 = "truncate table `ahc_settings`";
|
818 |
$wpdb->query($sql1);
|
819 |
|
834 |
*
|
835 |
* @return boolean
|
836 |
*/
|
837 |
+
function ahcfree_create_database_tables()
|
838 |
+
{
|
839 |
global $wpdb;
|
840 |
$sqlQueries = array();
|
841 |
+
|
842 |
+
$sqlQueries[] = "CREATE TABLE IF NOT EXISTS `ahc_online_users`
|
843 |
(
|
844 |
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
845 |
PRIMARY KEY(`id`),
|
847 |
`hit_page_id` VARCHAR(30) NOT NULL,
|
848 |
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
849 |
) DEFAULT CHARSET=utf8";
|
850 |
+
|
851 |
$sqlQueries[] = "CREATE TABLE IF NOT EXISTS `ahc_hits`
|
852 |
(
|
853 |
`hit_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
921 |
|
922 |
|
923 |
|
924 |
+
|
925 |
+
|
926 |
$sqlQueries[] = "CREATE TABLE IF NOT EXISTS `ahc_visitors`
|
927 |
(
|
928 |
`vst_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
1034 |
* @param array $contriesLatLng. LatLng of countries
|
1035 |
* @return boolean
|
1036 |
*/
|
1037 |
+
function ahcfree_insert_countries_into_table($internetCountryCodes, $contriesLatLng)
|
1038 |
+
{
|
1039 |
global $wpdb;
|
1040 |
$c = 1;
|
1041 |
$length = count($internetCountryCodes);
|
1045 |
$ctr_latitude = $contriesLatLng[$internetCode][0];
|
1046 |
$ctr_longitude = $contriesLatLng[$internetCode][1];
|
1047 |
}
|
1048 |
+
$result = $wpdb->insert(
|
1049 |
+
'ahc_countries',
|
1050 |
+
array(
|
1051 |
+
'ctr_name' => $countryName,
|
1052 |
+
'ctr_internet_code' => $internetCode,
|
1053 |
+
'ctr_latitude' => $ctr_latitude,
|
1054 |
+
'ctr_longitude' => $ctr_longitude
|
1055 |
+
),
|
1056 |
+
array(
|
1057 |
+
'%s', '%s', '%s', '%s'
|
1058 |
+
)
|
1059 |
);
|
1060 |
if ($result === false) {
|
1061 |
return false;
|
1074 |
* @param array $searchEngines.
|
1075 |
* @return boolean
|
1076 |
*/
|
1077 |
+
function ahcfree_insert_search_engines_into_table($searchEngines)
|
1078 |
+
{
|
1079 |
global $wpdb;
|
1080 |
foreach ($searchEngines as $se) {
|
1081 |
+
$result = $wpdb->insert(
|
1082 |
+
'ahc_search_engines',
|
1083 |
+
array(
|
1084 |
+
'srh_name' => $se['srh_name'],
|
1085 |
+
'srh_query_parameter' => $se['srh_query_parameter'],
|
1086 |
+
'srh_icon' => $se['srh_icon'],
|
1087 |
+
'srh_identifier' => $se['srh_identifier']
|
1088 |
+
),
|
1089 |
+
array(
|
1090 |
+
'%s', '%s', '%s', '%s'
|
1091 |
+
)
|
1092 |
);
|
1093 |
if ($result !== false) {
|
1094 |
$srh_id = $wpdb->insert_id;
|
1095 |
foreach ($se['crawlers'] as $crawler) {
|
1096 |
+
$result2 = $wpdb->insert(
|
1097 |
+
'ahc_search_engine_crawlers',
|
1098 |
+
array(
|
1099 |
+
'bot_name' => $crawler,
|
1100 |
+
'srh_id' => $srh_id
|
1101 |
+
),
|
1102 |
+
array(
|
1103 |
+
'%s', '%d'
|
1104 |
+
)
|
1105 |
);
|
1106 |
if ($result2 === false) {
|
1107 |
return false;
|
1123 |
* @param array $browsers
|
1124 |
* @return boolean
|
1125 |
*/
|
1126 |
+
function ahcfree_insert_browsers_into_table($browsers)
|
1127 |
+
{
|
1128 |
global $wpdb;
|
1129 |
foreach ($browsers as $browser) {
|
1130 |
+
$result = $wpdb->insert(
|
1131 |
+
'ahc_browsers',
|
1132 |
+
array(
|
1133 |
+
'bsr_id' => $browser['bsr_id'],
|
1134 |
+
'bsr_name' => $browser['bsr_name'],
|
1135 |
+
'bsr_icon' => $browser['bsr_icon']
|
1136 |
+
),
|
1137 |
+
array(
|
1138 |
+
'%d', '%s', '%s'
|
1139 |
+
)
|
1140 |
);
|
1141 |
if ($result === false) {
|
1142 |
return false;
|
1154 |
* @param array $dayHours
|
1155 |
* @return boolean
|
1156 |
*/
|
1157 |
+
function ahcfree_insert_visit_times_into_table($dayHours)
|
1158 |
+
{
|
1159 |
global $wpdb;
|
1160 |
foreach ($dayHours as $t) {
|
1161 |
+
$result = $wpdb->insert(
|
1162 |
+
'ahc_visits_time',
|
1163 |
+
array(
|
1164 |
+
'vtm_time_from' => $t['vtm_time_from'],
|
1165 |
+
'vtm_time_to' => $t['vtm_time_to'],
|
1166 |
+
'vtm_visitors' => 0
|
1167 |
+
),
|
1168 |
+
array(
|
1169 |
+
'%s', '%s', '%d'
|
1170 |
+
)
|
1171 |
);
|
1172 |
if ($result === false) {
|
1173 |
return false;
|
1184 |
* @param string $format Optional
|
1185 |
* @return array
|
1186 |
*/
|
1187 |
+
function ahcfree_get_week_limits($date, $format = 'Y-m-d')
|
1188 |
+
{
|
1189 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1190 |
$beginingDay = new DateTime($date);
|
1191 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
1192 |
$endingDay = new DateTime($date);
|
1193 |
$date = new DateTime($date);
|
1194 |
+
/*
|
1195 |
switch ($date->format('w')) {
|
1196 |
case 0: // sun
|
1197 |
//$beginingDay->modify('-1 day');
|
1223 |
$endingDay->modify('+1 day');
|
1224 |
break;
|
1225 |
}*/
|
1226 |
+
|
1227 |
+
$beginingDay->modify('-6 day');
|
1228 |
//$endingDay->modify();
|
1229 |
+
|
1230 |
+
$day = ahcfree_localtime('w');
|
1231 |
+
|
1232 |
//$beginingDay->modify('-'.$day.' days');
|
1233 |
//$endingDay->modify('+'.(6-$day).' days');
|
1234 |
return array(0 => $beginingDay->format($format), 1 => $endingDay->format($format));
|
1240 |
*
|
1241 |
* @return array
|
1242 |
*/
|
1243 |
+
function ahcfree_get_summary_statistics()
|
1244 |
+
{
|
1245 |
$arr = array();
|
1246 |
$arr['today'] = ahcfree_get_visitors_visits_in_period('today');
|
1247 |
$arr['yesterday'] = ahcfree_get_visitors_visits_in_period('yesterday');
|
1262 |
* @param string $period Optional
|
1263 |
* @return mixed
|
1264 |
*/
|
1265 |
+
function ahcfree_get_visitors_visits_in_period($period = 'total')
|
1266 |
+
{
|
1267 |
global $wpdb;
|
1268 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1269 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
1270 |
+
// echo AHCFREE_SERVER_CURRENT_TIMEZONE;
|
1271 |
|
1272 |
+
$current_date = new DateTime();
|
1273 |
$current_date->setTimezone($custom_timezone);
|
1274 |
+
|
1275 |
+
|
1276 |
$date = new DateTime();
|
1277 |
$date->setTimezone($custom_timezone);
|
1278 |
+
|
1279 |
+
|
1280 |
$sql = "SELECT SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits
|
1281 |
FROM `ahc_visitors`
|
1282 |
WHERE 1 = 1";
|
1283 |
$results = false;
|
1284 |
switch ($period) {
|
1285 |
case 'today':
|
1286 |
+
|
1287 |
+
|
1288 |
+
$sql .= " AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) = '" . ahcfree_localtime('Y-m-d') . "'";
|
1289 |
+
|
1290 |
$results = $wpdb->get_results($sql, OBJECT);
|
1291 |
break;
|
1292 |
|
1298 |
|
1299 |
case 'week': // last 7 days
|
1300 |
$limits = ahcfree_get_week_limits($date->format('Y-m-d'));
|
1301 |
+
|
1302 |
+
$custom_timezone_offset = str_ireplace('+', '-', $custom_timezone_offset);
|
1303 |
+
|
1304 |
+
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('" . $limits[0] . " 23:59:59','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') - INTERVAL 1 DAY
|
1305 |
+
and vst_date < DATE_FORMAT(CONVERT_TZ('" . $limits[1] . " 00:00:00','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') + INTERVAL 1 DAY";
|
1306 |
+
|
1307 |
|
1308 |
|
|
|
1309 |
$results = $wpdb->get_results($sql);
|
1310 |
+
|
1311 |
break;
|
1312 |
|
1313 |
case 'month':
|
1314 |
+
|
1315 |
+
$custom_timezone_offset = str_ireplace('+', '-', $custom_timezone_offset);
|
1316 |
+
|
1317 |
+
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('" . $date->modify('-30 day')->format('Y-m-d') . " 23:59:59','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') - INTERVAL 1 DAY
|
1318 |
+
and vst_date < DATE_FORMAT(CONVERT_TZ('" . $current_date->format('Y-m-d') . " 00:00:00','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') + INTERVAL 1 DAY";
|
1319 |
+
|
1320 |
|
1321 |
|
|
|
1322 |
$results = $wpdb->get_results($sql);
|
1323 |
+
|
1324 |
+
|
1325 |
+
|
1326 |
+
|
1327 |
break;
|
1328 |
|
1329 |
case 'year':
|
|
|
|
|
|
|
|
|
|
|
|
|
1330 |
|
1331 |
|
1332 |
+
$custom_timezone_offset = str_ireplace('+', '-', $custom_timezone_offset);
|
1333 |
+
|
1334 |
+
$sql .= " AND vst_date >= DATE_FORMAT(CONVERT_TZ('" . $date->modify('-365 day')->format('Y-m-d') . " 23:59:59','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') - INTERVAL 1 DAY
|
1335 |
+
and vst_date < DATE_FORMAT(CONVERT_TZ('" . $current_date->format('Y-m-d') . " 00:00:00','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m-%d %H:%i') + INTERVAL 1 DAY";
|
1336 |
+
|
1337 |
+
|
1338 |
+
|
1339 |
$results = $wpdb->get_results($sql);
|
1340 |
+
|
1341 |
+
|
1342 |
+
|
1343 |
break;
|
1344 |
|
1345 |
default:
|
1346 |
$results = $wpdb->get_results($sql, OBJECT);
|
1347 |
}
|
1348 |
+
//echo $wpdb->last_query.'<br />';
|
1349 |
if ($results !== false) {
|
1350 |
return array(
|
1351 |
'visitors' => (empty($results[0]->vst_visitors) ? 0 : $results[0]->vst_visitors),
|
1365 |
*
|
1366 |
* @return array
|
1367 |
*/
|
1368 |
+
function ahcfree_get_visitors_visits_by_date()
|
1369 |
+
{
|
1370 |
global $wpdb;
|
1371 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT - 1;
|
1372 |
$response = array();
|
1404 |
return $response;
|
1405 |
}
|
1406 |
|
1407 |
+
function ahcfree_get_visitors_by_date()
|
1408 |
+
{
|
1409 |
global $wpdb;
|
1410 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT;
|
1411 |
$response = array();
|
1437 |
return '[' . $xx . ']';
|
1438 |
}
|
1439 |
|
1440 |
+
function ahcfree_get_visits_by_date()
|
1441 |
+
{
|
1442 |
global $wpdb;
|
1443 |
$lastDays = AHCFREE_VISITORS_VISITS_LIMIT;
|
1444 |
$response = array();
|
1481 |
|
1482 |
|
1483 |
|
1484 |
+
function ahcfree_get_serch_visits_by_date()
|
1485 |
+
{
|
1486 |
global $wpdb;
|
1487 |
+
|
1488 |
$response = array();
|
1489 |
$sql = "SELECT ase.srh_name, asv.vtsh_date, asv.srh_id, SUM(asv.vtsh_visits) as vtsh_visits FROM `ahc_searching_visits` asv, `ahc_search_engines` ase where asv.srh_id = ase.srh_id GROUP by asv.srh_id order by SUM(asv.vtsh_visits) DESC";
|
1490 |
|
1491 |
|
1492 |
$results = $wpdb->get_results($sql, OBJECT);
|
|
|
1493 |
|
1494 |
+
|
1495 |
+
|
1496 |
+
|
1497 |
+
if ($results !== false) {
|
1498 |
$response['success'] = true;
|
1499 |
$data = '';
|
1500 |
$c = 0;
|
1501 |
foreach ($results as $r) {
|
1502 |
+
$data .= "['" . $r->srh_name . "', " . $r->vtsh_visits . "],";
|
1503 |
$c++;
|
1504 |
}
|
1505 |
} else {
|
1506 |
$data = '';
|
1507 |
}
|
1508 |
+
$data = substr($data, 0, -1);
|
1509 |
return $data;
|
1510 |
}
|
1511 |
|
1518 |
*
|
1519 |
* @return mixed
|
1520 |
*/
|
1521 |
+
function ahcfree_get_total_visits_by_search_engines()
|
1522 |
+
{
|
1523 |
global $wpdb;
|
1524 |
$result = $wpdb->get_results("SELECT SUM(vtsh_visits) AS total FROM ahc_searching_visits", OBJECT);
|
1525 |
if ($result !== false) {
|
1538 |
* @param string $period Optional
|
1539 |
* @return mixed
|
1540 |
*/
|
1541 |
+
function ahcfree_get_hits_search_engines_referers($period = 'total')
|
1542 |
+
{
|
1543 |
global $wpdb;
|
1544 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1545 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
1549 |
$results = false;
|
1550 |
switch ($period) {
|
1551 |
case 'today':
|
1552 |
+
$sql .= " AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) = '" . ahcfree_localtime('Y-m-d') . "'";
|
1553 |
+
|
1554 |
$results = $wpdb->get_results($sql, OBJECT);
|
1555 |
break;
|
1556 |
|
1575 |
$sql .= " AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) AND DATE(CONVERT_TZ(asv.vtsh_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE(CONVERT_TZ(%s, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'))";
|
1576 |
$results = $wpdb->get_results($wpdb->prepare($sql, $date->format('Y-01-01'), $date->format('Y-12-31')), OBJECT);
|
1577 |
break;
|
1578 |
+
|
1579 |
+
case 'alltime':
|
1580 |
+
|
1581 |
+
$sql .= " GROUP by asv.srh_id order by SUM(asv.vtsh_visits) DESC";
|
1582 |
+
|
1583 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
1584 |
+
break;
|
1585 |
|
1586 |
default:
|
1587 |
}
|
1589 |
$hitsReferers = array();
|
1590 |
if ($results !== false) {
|
1591 |
foreach ($results as $r) {
|
1592 |
+
|
1593 |
$hitsReferers[$r->srh_name] = $r->vtsh_visits;
|
1594 |
}
|
1595 |
return $hitsReferers;
|
1605 |
*
|
1606 |
* @return mixed
|
1607 |
*/
|
1608 |
+
function ahcfree_get_all_search_engines()
|
1609 |
+
{
|
1610 |
global $wpdb;
|
1611 |
$sql = "SELECT `srh_id`, `srh_name`, `srh_icon` FROM `ahc_search_engines`";
|
1612 |
$searchEngines = array();
|
1632 |
*
|
1633 |
* @return array
|
1634 |
*/
|
1635 |
+
function ahcfree_get_browsers_hits_counts()
|
1636 |
+
{
|
1637 |
global $wpdb;
|
1638 |
$sql = "SELECT `bsr_id`, `bsr_name`, `bsr_visits`
|
1639 |
FROM `ahc_browsers`
|
1645 |
$data = '';
|
1646 |
$c = 0;
|
1647 |
foreach ($results as $bsr) {
|
1648 |
+
$data .= "['" . $bsr->bsr_name . "', " . $bsr->bsr_visits . "],";
|
1649 |
$c++;
|
1650 |
}
|
1651 |
} else {
|
1652 |
$data = '';
|
1653 |
}
|
1654 |
+
$data = substr($data, 0, -1);
|
1655 |
return $data;
|
1656 |
}
|
1657 |
|
1664 |
*
|
1665 |
* @return mixed
|
1666 |
*/
|
1667 |
+
function ahcfree_get_top_refering_sites($start = '', $limit = '')
|
1668 |
+
{
|
1669 |
global $wpdb;
|
1670 |
+
$limitCond = "";
|
1671 |
+
if ($start != '' && $limit != '') {
|
1672 |
+
$sql = "SELECT rfr_site_name, rfr_visits
|
|
|
1673 |
FROM `ahc_refering_sites`
|
1674 |
ORDER BY rfr_visits DESC LIMIT %d, %d ";
|
1675 |
+
|
1676 |
+
$results = $wpdb->get_results($wpdb->prepare($sql, $start, $limit), OBJECT);
|
1677 |
+
} else {
|
1678 |
+
$sql = "SELECT rfr_site_name, rfr_visits
|
1679 |
FROM `ahc_refering_sites`
|
1680 |
ORDER BY rfr_visits DESC LIMIT 20 ";
|
1681 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
|
1685 |
+
|
1686 |
|
|
|
|
|
1687 |
if ($results !== false) {
|
1688 |
$arr = array();
|
1689 |
$c = 0;
|
1707 |
*
|
1708 |
* @return mixed
|
1709 |
*/
|
1710 |
+
function ahcfree_get_top_countries($limit = 0, $start = '', $pagelimit = '', $all = '', $cnt = true)
|
1711 |
+
{
|
1712 |
global $wpdb;
|
1713 |
+
if ($limit == 0) {
|
1714 |
$limit = AHCFREE_TOP_COUNTRIES_LIMIT;
|
1715 |
}
|
1716 |
+
|
1717 |
+
if ($cnt == true) {
|
1718 |
+
$sql = "SELECT count(*) FROM `ahc_countries` WHERE ctr_visits > 0 ORDER BY ctr_visitors DESC";
|
1719 |
+
$count = $wpdb->get_var($sql);
|
1720 |
+
return $count;
|
1721 |
+
}
|
1722 |
+
|
|
|
|
|
1723 |
$limitCond = "";
|
1724 |
+
if ($start != '' && $pagelimit != '') {
|
1725 |
+
|
1726 |
+
$limitCond = " limit " . intval($start) . "," . intval($pagelimit);
|
1727 |
+
}
|
1728 |
+
|
1729 |
+
|
1730 |
+
if ($limit > 0 && $pagelimit == "") {
|
1731 |
+
$sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
|
|
|
|
|
|
|
1732 |
FROM `ahc_countries` WHERE ctr_visits > 0
|
1733 |
ORDER BY ctr_visitors DESC
|
1734 |
LIMIT %d OFFSET 0";
|
1735 |
+
|
1736 |
+
$results = $wpdb->get_results($wpdb->prepare($sql, $limit), OBJECT);
|
1737 |
+
} else {
|
1738 |
+
$sql = "SELECT ctr_name, ctr_internet_code, ctr_visitors, ctr_visits
|
|
|
|
|
1739 |
FROM `ahc_countries` WHERE ctr_visits > 0
|
1740 |
ORDER BY ctr_visitors DESC $limitCond";
|
1741 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
1742 |
+
}
|
1743 |
+
|
1744 |
$response = array();
|
1745 |
if ($results !== false) {
|
1746 |
+
$new = array();
|
1747 |
$response['success'] = true;
|
1748 |
$response['data'] = array();
|
1749 |
$c = 0;
|
1750 |
+
if ($start == "")
|
1751 |
+
$start = 0;
|
1752 |
+
$rank = $start + 1;
|
1753 |
foreach ($results as $ctr) {
|
1754 |
$response['data'][$c]['rank'] = $rank;
|
1755 |
+
$furl = plugins_url('/images/flags/' . strtolower($ctr->ctr_internet_code) . '.png', AHCFREE_PLUGIN_MAIN_FILE);
|
1756 |
+
$flag = '<img src="' . esc_url($furl) . '" border="0" alt="' . esc_attr($ctr->ctr_name) . '" width="30" height="20" onerror="imgFlagError(this)" />';
|
1757 |
$response['data'][$c]['flag'] = $flag;
|
1758 |
$response['data'][$c]['ctr_name'] = $ctr->ctr_name;
|
1759 |
//$response['data'][$c]['ctr_internet_code'] = $ctr->ctr_internet_code;
|
1760 |
$response['data'][$c]['visitors'] = $ctr->ctr_visitors;
|
1761 |
$response['data'][$c]['visits'] = $ctr->ctr_visits;
|
1762 |
+
|
1763 |
+
if ($all == 1) {
|
1764 |
+
$new[$c]['rank'] = $rank;
|
1765 |
+
$new[$c]['ctr_name'] = $ctr->ctr_name;
|
1766 |
+
$new[$c]['visitors'] = $ctr->ctr_visitors;
|
1767 |
+
$new[$c]['visits'] = $ctr->ctr_visits;
|
1768 |
+
}
|
|
|
1769 |
$c++;
|
1770 |
$rank++;
|
1771 |
}
|
1772 |
} else {
|
1773 |
$response['success'] = false;
|
1774 |
}
|
1775 |
+
if ($all == 1) {
|
1776 |
+
return $new;
|
1777 |
+
}
|
|
|
1778 |
return $response;
|
1779 |
}
|
1780 |
|
1787 |
*
|
1788 |
* @return mixed
|
1789 |
*/
|
1790 |
+
function ahcfree_get_vsitors_by_country($all, $cnt = true, $start = '', $limit = '', $fdt = '', $tdt = '')
|
1791 |
+
{
|
1792 |
global $wpdb;
|
1793 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1794 |
$vtr_date = "CONVERT_TZ(concat(vtr_date,' ',vtr_time), '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')";
|
1795 |
+
$cond = "";
|
1796 |
+
if (isset($_POST['t_from_dt']) && $_POST['t_from_dt'] != '' && isset($_POST['t_to_dt']) && $_POST['t_to_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "traffic_index_country") {
|
1797 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['t_from_dt']);
|
1798 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_POST['t_to_dt']);
|
1799 |
+
} else if (isset($_POST['t_from_dt']) && $_POST['t_from_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "traffic_index_country") {
|
1800 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['t_from_dt']);
|
1801 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
1802 |
+
$cond = " and vtr_date ='$fromdt'";
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
if ($fdt != '' && $tdt != '') {
|
1806 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
1807 |
+
$todt = ahcfree_getFormattedDate($tdt, 'yymmdd');
|
1808 |
+
$cond = "and (DATE($vtr_date) between '" . $fromdt . "' and '$todt')";
|
1809 |
+
//$cond =" and (vtr_date between '$fromdt' and '$todt')";
|
1810 |
+
} else if ($fdt != '') {
|
1811 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
1812 |
+
$cond = "and DATE($vtr_date) = '" . $fromdt . "'";
|
1813 |
+
//$cond =" and vtr_date ='$fromdt'";
|
1814 |
+
} else {
|
1815 |
+
$cond = "and DATE(CONVERT_TZ(concat(vtr_date,' ',vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '" . ahcfree_localtime('Y-m-d') . "'";
|
1816 |
+
}
|
1817 |
+
|
1818 |
+
if ($cnt == true) {
|
1819 |
+
/*$sql = "select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id $cond group by ctr_name) as tot order by tot.total desc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1820 |
$results = $wpdb->get_results($sql, OBJECT);*/
|
1821 |
+
$sql = $wpdb->prepare("select count(*) as cnt from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc", $cond);
|
1822 |
+
|
1823 |
+
return $wpdb->get_var($sql);
|
1824 |
+
}
|
1825 |
+
|
1826 |
+
$limitCond = "";
|
1827 |
+
if ($start != '' && $limit != '') {
|
1828 |
+
$limitCond = " limit " . intval($start) . "," . intval($limit);
|
1829 |
+
}
|
1830 |
+
if ($all == 1) {
|
1831 |
+
$limitCond = "";
|
1832 |
+
}
|
1833 |
+
|
1834 |
+
$sql = $wpdb->prepare("select tot.ctr_name, tot.ctr_internet_code, tot.total from (SELECT c.ctr_name, c.ctr_internet_code, count(1) as total FROM ahc_recent_visitors v, ahc_countries c where v.ctr_id = c.ctr_id %s group by ctr_name ) as tot order by tot.total desc %s", $cond, $limitCond);
|
1835 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
1836 |
+
//echo $sql;
|
|
|
|
|
|
|
1837 |
if ($results !== false) {
|
1838 |
$arr = array();
|
1839 |
$new = array();
|
1840 |
$c = 0;
|
1841 |
+
if ($start == "")
|
1842 |
+
$start = 0;
|
1843 |
+
$no = $start + 1;
|
1844 |
+
$sum = 0;
|
1845 |
foreach ($results as $ctr) {
|
1846 |
+
|
1847 |
/*if ($ctr->total > 1) {*/
|
1848 |
+
$imgurl = plugins_url('/images/flags/' . strtolower($ctr->ctr_internet_code) . '.png', AHCFREE_PLUGIN_MAIN_FILE);
|
1849 |
+
$arr[$c]['no'] = $no;
|
1850 |
+
$arr[$c]['country'] = '<img src="' . $imgurl . '" border="0" alt="' . $ctr->ctr_name . '" width="30" height="20" onerror="imgFlagError(this)" />';
|
1851 |
+
$arr[$c]['ctr_name'] = $ctr->ctr_name;
|
1852 |
+
$arr[$c]['ctr_internet_code'] = $ctr->ctr_internet_code;
|
1853 |
+
$arr[$c]['total'] = $ctr->total;
|
1854 |
+
|
1855 |
+
if ($all == 1) {
|
1856 |
+
$new[$c]['no'] = $no;
|
1857 |
+
$new[$c]['ctr_name'] = $ctr->ctr_name;
|
1858 |
+
$new[$c]['total'] = $ctr->total;
|
1859 |
+
}
|
1860 |
+
|
1861 |
+
$c++;
|
1862 |
+
$no++;
|
1863 |
+
|
1864 |
+
|
|
|
1865 |
/*} else {
|
1866 |
|
1867 |
$sum += 1;
|
1868 |
}*/
|
|
|
|
|
1869 |
}
|
1870 |
+
|
1871 |
+
if ($sum > 0) {
|
1872 |
+
$k = count($arr);
|
1873 |
+
$arr[$k]['no'] = $no;
|
1874 |
+
$imgurl = plugins_url('/images/flags/xx.png', AHCFREE_PLUGIN_MAIN_FILE);
|
1875 |
+
$arr[$k]['country'] = '<img src="' . esc_url($imgurl) . '" border="0" alt="' . esc_url($ctr->ctr_name) . '" width="30" height="20" onerror="imgFlagError(this)" />';
|
1876 |
+
$arr[$k]['ctr_name'] = 'others';
|
1877 |
+
$arr[$k]['ctr_internet_code'] = 'XX';
|
1878 |
+
$arr[$k]['total'] = $sum;
|
1879 |
+
|
1880 |
+
if ($all == 1) {
|
1881 |
+
$new[$k]['no'] = $no;
|
1882 |
+
$new[$k]['ctr_name'] = 'others';
|
1883 |
+
$new[$k]['total'] = $sum;
|
1884 |
+
}
|
1885 |
+
}
|
1886 |
+
if ($all == 1) {
|
1887 |
+
return $new;
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
|
1891 |
+
|
|
|
|
|
|
|
|
|
1892 |
return $arr;
|
1893 |
} else {
|
1894 |
return false;
|
1903 |
|
1904 |
function ahcfree_haship($ip)
|
1905 |
{
|
1906 |
+
if ($ip != '') {
|
1907 |
+
$ip = explode('.', $ip);
|
1908 |
+
return $ip[0] . "." . $ip[1] . "." . $ip[2] . ".***";
|
1909 |
+
} else {
|
1910 |
+
return '';
|
1911 |
+
}
|
|
|
1912 |
}
|
1913 |
//--------------------------------------------
|
1914 |
/**
|
1919 |
*
|
1920 |
* @return mixed
|
1921 |
*/
|
1922 |
+
|
1923 |
+
function ahcfree_get_recent_visitors($all, $cnt = true, $start = '', $limit = '', $fdt = '', $tdt = '', $ip = '')
|
1924 |
+
{
|
1925 |
global $wpdb, $_SERVER;
|
1926 |
+
$cond = "";
|
1927 |
+
$cond1 = "";
|
1928 |
$ahcfree_save_ips = get_option('ahcfree_save_ips_opn');
|
1929 |
+
|
1930 |
+
if (isset($_POST['r_from_dt']) && $_POST['r_from_dt'] != '' && isset($_POST['r_to_dt']) && $_POST['r_to_dt'] != '' && isset($_POST['section']) && $_POST['section'] == 'recent_visitor_by_ip') {
|
1931 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['r_from_dt']);
|
1932 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_POST['r_to_dt']);
|
1933 |
+
} else if (isset($_POST['r_from_dt']) && $_POST['r_from_dt'] != '') {
|
1934 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['r_from_dt']);
|
1935 |
+
}
|
1936 |
+
if (isset($_POST['ip_addr']) && $_POST['ip_addr'] != '' && isset($_POST['section']) && $_POST['section'] == 'recent_visitor_by_ip') {
|
1937 |
+
$ip = ahc_free_sanitize_text_or_array_field($_POST['ip_addr']);
|
1938 |
+
}
|
1939 |
+
|
1940 |
+
if ($ip != '') {
|
1941 |
+
$cond .= " and vtr_ip_address='" . $ip . "'";
|
1942 |
+
$cond1 .= " and vtr_ip_address='" . $ip . "'";
|
1943 |
+
}
|
1944 |
+
|
1945 |
+
if ($fdt != '' && $tdt != '') {
|
1946 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
1947 |
+
$todt = ahcfree_getFormattedDate($tdt, 'yymmdd');
|
1948 |
+
$cond .= " having (dt between '$fromdt' and '$todt')";
|
1949 |
+
$cond1 .= " and (vtr_date between '$fromdt' and '$todt')";
|
1950 |
+
} else if ($fdt != '' && $tdt = '') {
|
1951 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
1952 |
+
$cond .= " and dt ='$fromdt'";
|
1953 |
+
$cond1 .= " and dt ='$fromdt'";
|
1954 |
+
}
|
1955 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1956 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
1957 |
+
if ($cnt == true) {
|
1958 |
+
$sql_query = "SELECT count(*) from (Select DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as dt FROM `ahc_recent_visitors` AS v LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id WHERE 1=1 and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond ORDER BY v.vtr_id DESC) as res";
|
1959 |
+
$count = $wpdb->get_var($sql_query);
|
1960 |
+
return $count;
|
1961 |
+
}
|
1962 |
+
|
1963 |
+
$limitCond = "";
|
1964 |
+
if ($start != '' && $limit != '') {
|
1965 |
+
$limitCond = " LIMIT " . intval($start) . ", " . intval($limit);
|
1966 |
+
}
|
1967 |
+
|
1968 |
+
if ($all == 1) {
|
1969 |
+
$limitCond = "";
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
$sql_query = "SELECT v.vtr_id, v.vtr_ip_address, v.vtr_referer, DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as dt ,DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%Y-%m-%d') as vtr_date, DATE_FORMAT(CONVERT_TZ(CONCAT_WS(' ',v.vtr_date,v.vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'), '%H:%i:%s') as vtr_time, v.ahc_city, v.ahc_region,
|
|
|
|
|
|
|
1973 |
c.ctr_name, c.ctr_internet_code, b.bsr_name, b.bsr_icon
|
1974 |
FROM `ahc_recent_visitors` AS v
|
1975 |
LEFT JOIN `ahc_countries` AS c ON v.ctr_id = c.ctr_id
|
1976 |
LEFT JOIN `ahc_browsers` AS b ON v.bsr_id = b.bsr_id
|
1977 |
WHERE 1=1 and v.vtr_ip_address NOT LIKE 'UNKNOWN%%' $cond
|
1978 |
ORDER BY v.vtr_id DESC $limitCond";
|
1979 |
+
|
1980 |
$results = $wpdb->get_results($sql_query);
|
1981 |
+
|
1982 |
if ($results !== false) {
|
1983 |
$arr = array();
|
1984 |
$new = array();
|
1986 |
if (is_array($results)) {
|
1987 |
foreach ($results as $hit) {
|
1988 |
if (strlen($hit->vtr_ip_address) < 17) {
|
1989 |
+
$visitDate = new DateTime($hit->vtr_date . ' ' . $hit->vtr_time);
|
1990 |
+
|
1991 |
$arr[$c]['hit_id'] = $hit->vtr_id;
|
1992 |
$hit_referer = (parse_url($hit->vtr_referer, PHP_URL_HOST) == $_SERVER['SERVER_NAME']) ? '' : rawurldecode($hit->vtr_referer);
|
1993 |
+
$hitip = (!empty($hit->hit_referer) ? '<a href="' . esc_url($hit_referer) . '" target="_blank"><img src="' . esc_url(plugins_url('/images/openW.jpg', AHCFREE_PLUGIN_MAIN_FILE)) . '" title="' . esc_attr(ahc_view_referer) . '"></a>' : '');
|
1994 |
+
$arr[$c]['hit_ip_address'] = (get_option('ahcfree_ahcfree_haships') != '1') ? $hit->vtr_ip_address . " " . $hitip : ahcfree_haship($hit->vtr_ip_address) . " " . $hitip;
|
1995 |
+
$img = "";
|
1996 |
+
if ($hit->ctr_internet_code != '') {
|
|
|
1997 |
$imgurl = plugins_url('/images/flags/' . strtolower($hit->ctr_internet_code) . '.png', AHCFREE_PLUGIN_MAIN_FILE);
|
1998 |
+
$img = "<img src='" . esc_url($imgurl) . "' border='0' width='22' height='18' title='" . esc_attr($hit->ctr_name) . "' onerror='imgFlagError(this)' /> ";
|
1999 |
}
|
2000 |
+
|
2001 |
+
// $bimgurl = plugins_url('/images/browsers/' . $hit->bsr_icon, AHCFREE_PLUGIN_MAIN_FILE);
|
2002 |
+
// $bimg = '<img src="'.$bimgurl.'" border="0" width="20" height="20" title="'.$hit->bsr_name.'" /> ';
|
2003 |
$arr[$c]['hit_date'] = $hit->vtr_date;
|
2004 |
$arr[$c]['hit_time'] = $hit->vtr_time;
|
2005 |
+
|
2006 |
$arr[$c]['ctr_internet_code'] = $hit->ctr_internet_code;
|
2007 |
$arr[$c]['bsr_name'] = $hit->bsr_name;
|
2008 |
$arr[$c]['bsr_icon'] = $hit->bsr_icon;
|
2009 |
+
|
2010 |
if (strpos($hit->ahc_region, '}')) {
|
2011 |
+
$arr[$c]['ahc_region'] = "-";
|
2012 |
+
} else {
|
2013 |
+
$arr[$c]['ahc_region'] = $hit->ahc_region;
|
2014 |
+
}
|
2015 |
+
|
2016 |
+
if (strpos($hit->ahc_city, 'charset')) {
|
2017 |
+
$arr[$c]['ahc_city'] = '-';
|
2018 |
+
} else {
|
2019 |
+
$arr[$c]['ahc_city'] = $hit->ahc_city;
|
2020 |
+
}
|
2021 |
+
|
2022 |
+
$arr[$c]['ctr_name'] = $img . $hit->ctr_name;
|
2023 |
+
$arr[$c]['ctr_name'] .= (!empty($hit->ahc_city)) ? ', ' . $hit->ahc_city : '';
|
2024 |
+
$arr[$c]['ctr_name'] .= (!empty($hit->ahc_region)) ? ', ' . $hit->ahc_region : '';
|
2025 |
+
|
2026 |
+
|
2027 |
$arr[$c]['time'] = $visitDate->format('d M Y @ h:i a');
|
2028 |
+
|
2029 |
+
if ($all == 1) {
|
2030 |
+
$new[$c]['hit_ip_address'] = $hit->vtr_ip_address;
|
2031 |
+
$new[$c]['ctr_name'] = $hit->ctr_name . ", " . $hit->ahc_city . ", " . $hit->ahc_region;
|
2032 |
+
$new[$c]['time'] = $visitDate->format('d M Y @ h:i a');
|
2033 |
+
}
|
2034 |
+
|
|
|
2035 |
$c++;
|
2036 |
}
|
2037 |
}
|
2038 |
}
|
2039 |
+
if ($all == 1)
|
2040 |
+
return $new;
|
2041 |
return $arr;
|
2042 |
} else {
|
2043 |
return false;
|
2053 |
*
|
2054 |
* @return mixed
|
2055 |
*/
|
2056 |
+
function ahcfree_get_latest_search_key_words_used($all, $cnt = true, $start = '', $limit = '', $fdt = '', $tdt = '')
|
2057 |
+
{
|
2058 |
global $wpdb;
|
2059 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2060 |
+
$cond = "";
|
2061 |
+
$cond1 = "";
|
2062 |
+
|
2063 |
+
if (isset($_POST['from_dt']) && $_POST['from_dt'] != '' && isset($_POST['to_dt']) && $_POST['to_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "lastest_search") {
|
2064 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['from_dt']);
|
2065 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_POST['to_dt']);
|
2066 |
+
}
|
2067 |
+
|
2068 |
+
if ($fdt != '' && $tdt != '') {
|
2069 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
2070 |
+
$todt = ahcfree_getFormattedDate($tdt, 'yymmdd');
|
2071 |
+
//$cond =" and (k.kwd_date between '$fromdt' and '$todt')";
|
2072 |
+
$cond = " having (dt between '$fromdt' and '$todt')";
|
2073 |
+
$cond1 = " and (kwd_date between '$fromdt' and '$todt')";
|
2074 |
+
}
|
2075 |
+
|
2076 |
+
if ($cnt == true) {
|
2077 |
+
$sql = "SELECT count(*) FROM `ahc_keywords` AS k LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id JOIN `ahc_browsers` AS b ON k.bsr_id = b.bsr_id JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id WHERE k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond1 ORDER BY k.kwd_date DESC, k.kwd_time DESC ";
|
2078 |
+
$count = $wpdb->get_var($sql);
|
2079 |
+
return $count;
|
2080 |
+
}
|
2081 |
+
|
2082 |
+
$limitCond = "";
|
2083 |
+
if ($start != '' && $limit != '') {
|
2084 |
+
$limitCond = " LIMIT " . intval($start) . ", " . intval($limit);
|
2085 |
+
}
|
2086 |
+
|
2087 |
+
if ($all == 1) {
|
2088 |
+
$limitCond = "";
|
2089 |
+
}
|
2090 |
+
|
2091 |
+
$sql = "SELECT k.kwd_date as dt,k.kwd_ip_address, k.kwd_referer, k.kwd_keywords, CONVERT_TZ(CONCAT_WS(' ',k.kwd_date,k.kwd_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') as kwd_date, CONVERT_TZ(k.kwd_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') as kwd_time, k.ctr_id,
|
|
|
|
|
|
|
|
|
|
|
2092 |
c.ctr_name, c.ctr_internet_code, b.bsr_name, b.bsr_icon, s.srh_name, s.srh_icon
|
2093 |
FROM `ahc_keywords` AS k
|
2094 |
LEFT JOIN `ahc_countries` AS c ON k.ctr_id = c.ctr_id
|
2096 |
JOIN `ahc_search_engines` AS s on k.srh_id = s.srh_id
|
2097 |
WHERE k.kwd_ip_address != 'UNKNOWN' and k.kwd_keywords !='amazon' and c.ctr_id IS NOT NULL $cond
|
2098 |
ORDER BY k.kwd_date DESC, k.kwd_time DESC $limitCond";
|
2099 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
2100 |
+
|
2101 |
if ($results !== false) {
|
2102 |
$arr = array();
|
2103 |
$new = array();
|
2104 |
$c = 0;
|
2105 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2106 |
$custom_timezone_string = ahcfree_get_timezone_string();
|
2107 |
+
$ahcfree_save_ips = get_option('ahcfree_save_ips_opn');
|
2108 |
+
if ($custom_timezone_string) {
|
2109 |
+
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
2110 |
+
}
|
2111 |
foreach ($results as $re) {
|
2112 |
|
2113 |
$arr[$c]['hit_referer'] = rawurldecode($re->kwd_referer);
|
2121 |
$arr[$c]['bsr_icon'] = $re->bsr_icon;
|
2122 |
$arr[$c]['srh_name'] = $re->srh_name;
|
2123 |
$arr[$c]['srh_icon'] = $re->srh_icon;
|
2124 |
+
|
2125 |
+
$img = '<span>';
|
2126 |
+
if ($re->ctr_internet_code != '') {
|
2127 |
+
$imgurl = plugins_url('/images/flags/' . strtolower($re->ctr_internet_code) . '.png', AHCFREE_PLUGIN_MAIN_FILE);
|
2128 |
+
$img .= '<img src="' . esc_url($imgurl) . '" border="0" width="22" height="18" title="' . esc_attr($re->ctr_name) . '" onerror="imgFlagError(this)" />';
|
2129 |
+
}
|
2130 |
+
$img .= ' ' . esc_html($re->ctr_name) . '</span>';
|
2131 |
+
/*$eurl=plugins_url('/images/search_engines/' . $re->srh_icon, AHCFREE_PLUGIN_MAIN_FILE);
|
2132 |
$img.='<span><img src="'.$eurl.'" border="0" width="22" height="22" title="'.$re->srh_name.'" /></span>';
|
2133 |
|
2134 |
$burl=plugins_url('/images/browsers/' . $re->bsr_icon, AHCFREE_PLUGIN_MAIN_FILE);
|
2135 |
$img.='<span><img src="'.$burl.'" border="0" width="20" height="20" title="'.$re->bsr_name.'" /></span>';
|
2136 |
*/
|
2137 |
+
$arr[$c]['img'] = $img;
|
2138 |
+
$arr[$c]['csb'] = $re->ctr_name . "/" . $re->srh_name . "/" . $re->bsr_name;
|
2139 |
+
|
2140 |
+
$arr[$c]['keyword'] = '<span class="searchKeyWords"><a href="' . esc_url($re->kwd_referer) . '" target="_blank">' . esc_html($re->kwd_keywords) . '</a></span>';
|
2141 |
+
|
2142 |
+
$visitDate = new DateTime($re->kwd_date);
|
2143 |
+
$visitDate->setTimezone($custom_timezone);
|
2144 |
+
//$arr[$c]['dt'] = '<span class="visitDateTime">'.$visitDate->format('d/m/Y').'</span>';
|
2145 |
+
$arr[$c]['dt'] = $visitDate->format('d/m/Y');
|
2146 |
+
|
2147 |
+
if ($all == 1) {
|
2148 |
+
$new[$c]['csb'] = $re->ctr_name . "/" . $re->srh_name . "/" . $re->bsr_name;
|
2149 |
+
$new[$c]['keyword'] = $re->kwd_keywords;
|
2150 |
+
$new[$c]['dt'] = $visitDate->format('d/m/Y');
|
2151 |
+
}
|
|
|
2152 |
$c++;
|
2153 |
}
|
2154 |
+
if ($all == 1)
|
2155 |
+
return $new;
|
2156 |
return $arr;
|
2157 |
} else {
|
2158 |
return false;
|
2165 |
*
|
2166 |
* @return boolean
|
2167 |
*/
|
2168 |
+
function ahcfree_is_login_page()
|
2169 |
+
{
|
2170 |
global $GLOBALS;
|
2171 |
+
// global $GlobalsAHC;
|
2172 |
|
2173 |
+
// return in_array($GlobalsAHC['pagenow'], array('wp-login.php', 'wp-register.php'));
|
2174 |
+
|
2175 |
+
if ($GLOBALS['pagenow'] === 'wp-login.php' || $GLOBALS['pagenow'] === 'wp-register.php') {
|
2176 |
+
return true;
|
2177 |
+
} else {
|
2178 |
+
return false;
|
2179 |
+
}
|
|
|
|
|
2180 |
}
|
2181 |
|
2182 |
//--------------------------------------------
|
2187 |
*
|
2188 |
* @return array
|
2189 |
*/
|
2190 |
+
function ahcfree_get_today_visitors_for_map($map_status = '')
|
2191 |
+
{
|
2192 |
global $wpdb;
|
2193 |
+
$whr = '';
|
2194 |
+
|
2195 |
+
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2196 |
+
|
2197 |
+
$current_month = ahcfree_localtime("m");
|
2198 |
+
$current_year = ahcfree_localtime("Y");
|
2199 |
+
$past_year = ahcfree_localtime("Y") - 1;
|
2200 |
+
$past_month = date('m', strtotime('last month'));
|
2201 |
+
|
2202 |
+
|
2203 |
+
if ($map_status == 'this_month') {
|
2204 |
+
$whr = " and month(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'+00:00','+02:00')) = " . $current_month . " and year(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'+00:00','+02:00')) = " . $current_year;
|
2205 |
+
} else if ($map_status == 'past_month') {
|
2206 |
+
$whr = " and month(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'+00:00','+02:00')) = " . $past_month . " and year(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'+00:00','+02:00')) = " . $past_year;
|
2207 |
+
} else {
|
2208 |
+
$whr = " and DATE(CONVERT_TZ(concat(vtr_date, ' ', vtr_time),'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) = '" . ahcfree_localtime("Y-m-d") . "'";
|
2209 |
+
}
|
2210 |
+
|
2211 |
+
$sql = "select count(vtr_id) as visitors, c.* from `ahc_recent_visitors` recent, `ahc_countries` c where recent.ctr_id = c.ctr_id
|
2212 |
+
and c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 " . $whr . " GROUP by ctr_id";
|
2213 |
+
|
2214 |
+
|
2215 |
+
$results = $wpdb->get_results($sql, OBJECT);
|
2216 |
+
$response = array();
|
2217 |
+
if ($results !== false) {
|
2218 |
+
$response['success'] = true;
|
2219 |
+
$response['data'] = array();
|
2220 |
+
if (is_array($results) && isset($results[0]->visitors) && !empty($results[0]->visitors)) {
|
|
|
|
|
2221 |
foreach ($results as $r) {
|
2222 |
$response['data'][$r->ctr_id]['visitors'] = $r->visitors;
|
2223 |
$response['data'][$r->ctr_id]['ctr_name'] = $r->ctr_name;
|
2231 |
}
|
2232 |
return $response;
|
2233 |
}
|
2234 |
+
function ahcfree_get_all_visitors_for_map()
|
2235 |
+
{
|
2236 |
global $wpdb;
|
2237 |
$sql = "SELECT c.`ctr_visitors` as visitors, c.ctr_id, c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude from `ahc_countries` c where c.ctr_latitude IS NOT NULL AND c.ctr_latitude <> 0 AND c.ctr_longitude IS NOT NULL AND c.ctr_longitude <> 0 group by `ctr_name` ORDER BY ctr_visitors desc LIMIT 10";
|
2238 |
|
2263 |
*
|
2264 |
* @return array
|
2265 |
*/
|
2266 |
+
function ahcfree_get_online_visitors_for_map()
|
2267 |
+
{
|
2268 |
global $wpdb;
|
2269 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2270 |
$sql = "SELECT hits.visitors, hits.ctr_id,
|
2271 |
c.ctr_name, c.ctr_internet_code, c.ctr_latitude, c.ctr_longitude FROM (
|
2272 |
SELECT COUNT(v.visitor) AS visitors, v.ctr_id FROM (
|
2273 |
SELECT ctr_id, 1 AS visitor FROM `ahc_hits`
|
2274 |
+
WHERE ctr_id IS NOT NULL AND hit_ip_address NOT LIKE 'UNKNOWN%' and hit_date = DATE( CONVERT_TZ( '" . ahcfree_localtime("Y-m-d H:i:s") . "' ,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) and TIME( CONVERT_TZ(hit_time,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') ) between TIME(CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') - INTERVAL 60 SECOND) and TIME( CONVERT_TZ('" . date("Y-m-d H:i:s") . "','" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "') )
|
2275 |
GROUP BY hit_ip_address
|
2276 |
) AS v
|
2277 |
GROUP BY ctr_id) AS hits
|
2306 |
*
|
2307 |
* @return boolean
|
2308 |
*/
|
2309 |
+
function ahcfree_is_search_engine_bot()
|
2310 |
+
{
|
2311 |
global $wpdb, $_SERVER;
|
2312 |
$results = $wpdb->get_results("SELECT `bot_name` FROM `ahc_search_engine_crawlers`", OBJECT);
|
2313 |
foreach ($results as $crawler) {
|
2336 |
*
|
2337 |
* @return boolean
|
2338 |
*/
|
2339 |
+
function ahcfree_is_wordpress_bot()
|
2340 |
+
{
|
2341 |
global $_SERVER;
|
2342 |
if (stripos($_SERVER['HTTP_USER_AGENT'], 'WordPress') !== false) {
|
2343 |
return true;
|
2355 |
* @param object $query. this object is passed to the callback function of "parse_query" hooked action
|
2356 |
* @return mixed
|
2357 |
*/
|
2358 |
+
function ahcfree_detect_requested_page($query)
|
2359 |
+
{
|
2360 |
global $wpdb;
|
2361 |
$vars = $query->query_vars;
|
2362 |
if (isset($vars['p']) && !empty($vars['p'])) {
|
2384 |
}
|
2385 |
}
|
2386 |
|
2387 |
+
function ahcfree_get_subpage_name($page_name)
|
2388 |
+
{
|
2389 |
$sub_name = strrchr($page_name, '/');
|
2390 |
if (!$sub_name) {
|
2391 |
return $page_name;
|
2430 |
|
2431 |
function ahcfree_track_visitor()
|
2432 |
{
|
2433 |
+
$exclude_ips_arr = array();
|
2434 |
+
$exclude_ips = AHCFREE_EXCLUDE_IPS;
|
2435 |
if ($exclude_ips == '' or empty($exclude_ips)) {
|
2436 |
$exclude_ips = array();
|
2437 |
+
} else {
|
2438 |
+
|
2439 |
+
$exclude_ips = str_ireplace("\n", " ", $exclude_ips);
|
2440 |
+
$exclude_ips = str_ireplace(",", " ", $exclude_ips);
|
2441 |
|
|
|
|
|
|
|
2442 |
$exclude_ips = explode(" ", $exclude_ips);
|
2443 |
}
|
2444 |
|
2445 |
|
2446 |
+
$client_ip_address = trim(ahcfree_get_client_ip_address());
|
2447 |
+
foreach ($exclude_ips as $k => $v) {
|
2448 |
+
|
2449 |
+
if ($v != '') {
|
2450 |
+
|
2451 |
+
$exclude_ips_arr[] = trim($v);
|
2452 |
+
}
|
2453 |
+
}
|
2454 |
+
|
2455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2456 |
|
|
|
2457 |
if (!ahcfree_is_login_page() && !ahcfree_is_search_engine_bot() && !ahcfree_is_wordpress_bot()) {
|
2458 |
+
|
2459 |
if (!in_array($client_ip_address, $exclude_ips_arr)) {
|
2460 |
+
|
2461 |
|
2462 |
$page_id = intval($_POST['page_id']);
|
2463 |
$page_title = ahc_free_sanitize_text_or_array_field($_POST['page_title']);
|
2467 |
$_SERVER['SERVER_NAME'] = ahc_free_sanitize_text_or_array_field($_POST['servername']);
|
2468 |
$_SERVER['HTTP_HOST'] = ahc_free_sanitize_text_or_array_field($_POST['hostname']);
|
2469 |
$_SERVER['REQUEST_URI'] = ahc_free_sanitize_text_or_array_field($_POST['request_uri']);
|
2470 |
+
|
2471 |
$hitsCounter = new WPHitsCounter($page_id, $page_title, $post_type);
|
2472 |
$hitsCounter->traceVisitorHit();
|
2473 |
}
|
2474 |
}
|
2475 |
+
|
2476 |
die;
|
2477 |
}
|
2478 |
|
2485 |
* @param string $separator
|
2486 |
* @return float
|
2487 |
*/
|
2488 |
+
function ahcfree_ceil_dec($number, $precision, $separator)
|
2489 |
+
{
|
2490 |
if (strpos($number, '.') !== false) {
|
2491 |
$numberpart = explode($separator, $number);
|
2492 |
$numberpart[1] = substr_replace($numberpart[1], $separator, $precision, 0);
|
2511 |
*
|
2512 |
* @return mixed
|
2513 |
*/
|
2514 |
+
function ahcfree_get_traffic_by_title($all, $cnt = false, $start = '0', $limit = '10', $search = '')
|
2515 |
+
{
|
2516 |
|
2517 |
global $wpdb;
|
2518 |
+
$sql2 = '';
|
2519 |
$sql1 = "SELECT SUM(hits) AS sm FROM (
|
2520 |
SELECT SUM(til_hits) AS hits
|
2521 |
FROM ahc_title_traffic
|
2522 |
GROUP BY til_page_id
|
2523 |
) myTable";
|
|
|
2524 |
|
2525 |
+
|
2526 |
+
$cond = "";
|
2527 |
+
if ($search != '') {
|
2528 |
+
$cond = " and til_page_title like '%" . $search . "%'";
|
2529 |
+
}
|
2530 |
+
|
2531 |
+
if ($cnt == true) {
|
2532 |
+
$sql2 = "SELECT til_page_id, til_page_title, til_hits
|
|
|
2533 |
FROM ahc_title_traffic where 1=1 $cond
|
2534 |
GROUP BY til_page_id , til_page_title, til_hits
|
2535 |
+
ORDER BY til_hits DESC limit %d, %d";
|
2536 |
+
|
2537 |
+
$count = $wpdb->get_results($wpdb->prepare($sql2, $start, $limit));
|
2538 |
+
return $wpdb->num_rows;
|
2539 |
+
}
|
2540 |
+
|
2541 |
+
$limitCond = "";
|
2542 |
+
if ($start != '' && $limit != '') {
|
2543 |
+
$sql2 = "SELECT til_page_id, til_page_title, til_hits
|
|
|
2544 |
FROM ahc_title_traffic where 1=1 $cond
|
2545 |
GROUP BY til_page_id , til_page_title, til_hits
|
2546 |
ORDER BY til_hits DESC limit %d, %d";
|
2547 |
+
}
|
2548 |
+
|
2549 |
+
|
2550 |
+
|
2551 |
+
|
2552 |
+
|
2553 |
$result1 = $wpdb->get_results($sql1);
|
2554 |
+
if ($result1 !== false && $sql2 != '') {
|
2555 |
$total = $result1[0]->sm;
|
2556 |
+
|
2557 |
$result2 = $wpdb->get_results($wpdb->prepare($sql2, $start, $limit));
|
2558 |
if ($result2 !== false) {
|
2559 |
$arr = array();
|
2560 |
if ($wpdb->num_rows > 0) {
|
2561 |
$c = 0;
|
2562 |
+
if ($start == "")
|
2563 |
+
$start = 0;
|
2564 |
+
$no = $start;
|
2565 |
foreach ($result2 as $r) {
|
2566 |
+
$ans = 0;
|
2567 |
$arr[$c]['rank'] = $no + 1;
|
2568 |
//$arr[$c]['til_page_id'] = $r->til_page_id;
|
2569 |
+
if ($all == 1)
|
2570 |
+
$arr[$c]['til_page_title'] = $r->til_page_title;
|
2571 |
+
else
|
2572 |
+
$arr[$c]['til_page_title'] = "<a href='" . get_permalink($r->til_page_id) . "' target='_blank'>" . $r->til_page_title . "</a>";
|
2573 |
$arr[$c]['til_hits'] = $r->til_hits;
|
2574 |
+
$ans = ($total > 0) ? ahcfree_ceil_dec((($r->til_hits / $total) * 100), 2, ".") : 0;
|
2575 |
+
$arr[$c]['percent'] = ahcfree_NumFormat($ans) . '%';
|
2576 |
$c++;
|
2577 |
$no++;
|
2578 |
}
|
2591 |
*
|
2592 |
* @return mixed
|
2593 |
*/
|
2594 |
+
function ahcfree_get_time_visits($all, $start = '', $limit = '', $fdt = '', $tdt = '')
|
2595 |
+
{
|
2596 |
global $wpdb;
|
2597 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2598 |
+
$vst_date = "CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')";
|
2599 |
+
|
2600 |
+
$cond = "";
|
2601 |
+
|
2602 |
+
if (isset($_POST['vfrom_dt']) && $_POST['vfrom_dt'] != '' && isset($_POST['vto_dt']) && $_POST['vto_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "visit_time") {
|
2603 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['vfrom_dt']);
|
2604 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_POST['vto_dt']);
|
2605 |
+
} else if (isset($_POST['vfrom_dt']) && $_POST['vfrom_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "visit_time") {
|
2606 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_POST['vfrom_dt']);
|
2607 |
+
}
|
2608 |
+
if ($fdt != '' && $tdt != '') {
|
2609 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
2610 |
+
$todt = ahcfree_getFormattedDate($tdt, 'yymmdd');
|
2611 |
+
$cond = "(DATE($vst_date) between '" . $fromdt . "' and '$todt')";
|
2612 |
+
$groupby = " hour";
|
2613 |
+
} else if ($fdt != '') {
|
2614 |
+
$fromdt = ahcfree_getFormattedDate($fdt, 'yymmdd');
|
2615 |
+
$cond = "DATE($vst_date) = '" . $fromdt . "'";
|
2616 |
+
$groupby = " hour($vst_date)";
|
2617 |
+
} else {
|
2618 |
+
$cond = "DATE($vst_date) = '" . ahcfree_localtime('Y-m-d') . "'";
|
2619 |
+
$groupby = " hour($vst_date)";
|
2620 |
+
}
|
2621 |
+
|
2622 |
+
$sql1 = "SELECT SUM(vtm_visitors) AS sm FROM ahc_visits_time WHERE DATE($vst_date) = '" . ahcfree_localtime('Y-m-d') . "'";
|
2623 |
+
|
2624 |
+
|
2625 |
+
$sql2 = "SELECT date(vst_date) as dt,hour($vst_date) AS hour, SUM(vst_visitors) AS vst_visitors, SUM(vst_visits) AS vst_visits FROM `ahc_visitors`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2626 |
WHERE $cond GROUP BY $groupby";
|
2627 |
+
|
2628 |
+
//echo $sql2;
|
2629 |
//$result1 = $wpdb->get_results($sql1);
|
2630 |
//if ($result1 !== false) {
|
2631 |
+
$total = 0;
|
2632 |
+
$result2 = $wpdb->get_results($sql2);
|
2633 |
+
//asort($result2);
|
2634 |
+
$utc_data = array();
|
2635 |
+
|
2636 |
+
if ($result2 !== false) {
|
2637 |
+
$arr = array();
|
2638 |
+
$new = array();
|
2639 |
+
$hourDetails = array();
|
2640 |
+
foreach ($result2 as $r) {
|
2641 |
+
|
2642 |
+
if (isset($hourDetails[$r->hour])) {
|
2643 |
+
$hourDetails[$r->hour]['visitor'] += $r->vst_visitors;
|
2644 |
+
$hourDetails[$r->hour]['visits'] += $r->vst_visits;
|
2645 |
+
$hourDetails[$r->hour]['counter'] += 1;
|
2646 |
+
} else {
|
2647 |
+
$hourDetails[$r->hour] = array(
|
2648 |
+
'visitor' => $r->vst_visitors,
|
2649 |
+
'visits' => $r->vst_visits,
|
2650 |
+
'counter' => 1
|
2651 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
2652 |
}
|
2653 |
+
//$dtArr[]= $hourDetails;
|
2654 |
+
$total += $r->vst_visitors;
|
2655 |
+
}
|
2656 |
+
|
2657 |
+
if ($start == '')
|
2658 |
+
$start = 0;
|
2659 |
+
if ($limit != '' && $start == 20)
|
2660 |
+
$end = 24;
|
2661 |
+
else if ($limit == "")
|
2662 |
+
$end = 24;
|
2663 |
+
else
|
2664 |
+
$end = $limit + $start;
|
2665 |
+
|
2666 |
+
if ($all == 1) {
|
2667 |
+
$start = 0;
|
2668 |
+
$end = 24;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2669 |
}
|
2670 |
+
$k = 0;
|
2671 |
+
$avgtotal = 0;
|
2672 |
+
for ($i = $start; $i < $end; $i++) {
|
2673 |
+
|
2674 |
+
$vtm_visitors = 0;
|
2675 |
+
$vtm_visits = 0;
|
2676 |
+
$totalDt = count($hourDetails);
|
2677 |
+
|
2678 |
+
if (isset($hourDetails[$i])) {
|
2679 |
+
$vtm_visitors = $hourDetails[$i]['visitor'] / $hourDetails[$i]['counter'];
|
2680 |
+
$avgtotal += $vtm_visitors;
|
2681 |
+
$vtm_visits = $hourDetails[$i]['visits'] / $hourDetails[$i]['counter'];
|
2682 |
+
}
|
2683 |
+
if ($i < 10) {
|
2684 |
+
$timeTo = $timeFrom = '0' . $i;
|
2685 |
+
} else {
|
2686 |
+
$timeTo = $timeFrom = $i;
|
2687 |
+
}
|
2688 |
+
$arr[$k]['vtm_time_from'] = $timeFrom . ':00';
|
2689 |
+
$arr[$k]['vtm_time_to'] = $timeTo . ':59';
|
2690 |
+
// $arr[$k]['percent'] = ($total > 0) ? ahcfree_ceil_dec((($vtm_visitors / $total) * 100), 2, ".") : 0;
|
2691 |
+
|
2692 |
+
$arr[$k]['time'] = $timeFrom . ':00 - ' . $timeTo . ':59';
|
2693 |
+
|
2694 |
+
$arr[$k]['vtm_visitors'] = ceil($vtm_visitors);
|
2695 |
+
$arr[$k]['vtm_visits'] = ceil($vtm_visits);
|
2696 |
+
|
2697 |
+
if ($all == 1) {
|
2698 |
+
$new[$k]['time'] = $timeFrom . ':00 - ' . $timeTo . ':59';
|
2699 |
+
$new[$k]['vtm_visitors'] = ceil($vtm_visitors);
|
2700 |
+
$new[$k]['vtm_visits'] = ceil($vtm_visits);
|
2701 |
+
}
|
2702 |
+
$k++;
|
2703 |
+
}
|
2704 |
+
$avgtotal = $total;
|
2705 |
+
|
2706 |
+
$j = 0;
|
2707 |
+
for ($i = $start; $i < $end; $i++) {
|
2708 |
+
if (isset($hourDetails[$i])) {
|
2709 |
+
$vtm_visitors = $hourDetails[$i]['visitor'] / $hourDetails[$i]['counter'];
|
2710 |
+
} else {
|
2711 |
+
$vtm_visitors = 0;
|
2712 |
+
}
|
2713 |
+
|
2714 |
+
$arr[$j]['percent'] = ($avgtotal > 0) ? ahcfree_ceil_dec((($vtm_visitors / $total) * 100), 2, ".") : 0;
|
2715 |
+
$per = ($avgtotal > 0) ? ahcfree_ceil_dec((($vtm_visitors / $avgtotal) * 100), 2, ".") : 0;
|
2716 |
+
|
2717 |
+
if ($all == 1)
|
2718 |
+
$new[$j]['percent'] = $per;
|
2719 |
+
|
2720 |
+
if (ceil($per) > 25 && ceil($per) < 50) {
|
2721 |
+
$cls = 'visitorsGraph2';
|
2722 |
+
} else if (ceil($per) > 50) {
|
2723 |
+
$cls = 'visitorsGraph3';
|
2724 |
+
} else {
|
2725 |
+
$cls = 'visitorsGraph';
|
2726 |
+
}
|
2727 |
+
$css = (!empty($per)) ? 'style="width: ' . ceil($per) . '%;"' : '';
|
2728 |
+
$arr[$j]['graph'] = '<div class="visitorsGraphContainer"><div class="' . esc_attr($cls) . '" ' . $css . '> </div><div class="cleaner"></div></div><div class="visitorsPercent">(' . ceil($per) . ')%</div>';
|
2729 |
+
$j++;
|
2730 |
+
$cls = '';
|
2731 |
+
$per = 0;
|
2732 |
+
}
|
2733 |
+
if ($all == 1)
|
2734 |
+
return $new;
|
2735 |
+
return $arr;
|
2736 |
+
}
|
2737 |
+
//}
|
2738 |
return false;
|
|
|
2739 |
}
|
2740 |
|
2741 |
+
function ahcfree_advanced_get_link($url, $followRedirects = true)
|
2742 |
+
{
|
2743 |
+
$ahc_data = wp_remote_get($url);
|
2744 |
+
return json_decode(wp_remote_retrieve_body($ahc_data));
|
2745 |
}
|
2746 |
|
2747 |
//--------------------------------------------
|
2750 |
*
|
2751 |
* @return string
|
2752 |
*/
|
2753 |
+
function ahcfree_get_client_ip_address()
|
2754 |
+
{
|
2755 |
global $_SERVER;
|
2756 |
$ipAddress = '';
|
2757 |
+
if (isset($_SERVER['HTTP_X_REAL_IP']) && !empty($_SERVER['HTTP_X_REAL_IP']) && $_SERVER['HTTP_X_REAL_IP'] != '127.0.0.1') {
|
2758 |
$ipAddress = $_SERVER['HTTP_X_REAL_IP'];
|
2759 |
+
} else if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != '127.0.0.1') {
|
2760 |
$ipAddress = $_SERVER['HTTP_CLIENT_IP'];
|
2761 |
+
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '127.0.0.1') {
|
2762 |
$ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
2763 |
+
} else if (isset($_SERVER['HTTP_X_FORWARDED']) && !empty($_SERVER['HTTP_X_FORWARDED']) && $_SERVER['HTTP_X_FORWARDED'] != '127.0.0.1') {
|
2764 |
$ipAddress = $_SERVER['HTTP_X_FORWARDED'];
|
2765 |
+
} else if (isset($_SERVER['HTTP_FORWARDED_FOR']) && !empty($_SERVER['HTTP_FORWARDED_FOR']) && $_SERVER['HTTP_FORWARDED_FOR'] != '127.0.0.1') {
|
2766 |
$ipAddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
2767 |
+
} else if (isset($_SERVER['HTTP_FORWARDED']) && !empty($_SERVER['HTTP_FORWARDED']) && $_SERVER['HTTP_FORWARDED'] != '127.0.0.1') {
|
2768 |
$ipAddress = $_SERVER['HTTP_FORWARDED'];
|
2769 |
+
} else if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
|
2770 |
$ipAddress = $_SERVER['REMOTE_ADDR'];
|
2771 |
+
} else {
|
2772 |
$ipAddress = 'UNKNOWN';
|
2773 |
}
|
2774 |
|
2775 |
+
|
2776 |
$ipAddress = ahc_free_sanitize_text_or_array_field($ipAddress);
|
2777 |
$ipAddress = explode(',', $ipAddress);
|
2778 |
|
2790 |
*
|
2791 |
* @return void
|
2792 |
*/
|
2793 |
+
function ahcfree_include_scripts()
|
2794 |
+
{
|
2795 |
+
wp_register_style('ahc_custom_css', plugins_url('/css/custom.css', AHCFREE_PLUGIN_MAIN_FILE), '', time());
|
2796 |
+
wp_enqueue_style('ahc_custom_css');
|
2797 |
+
|
2798 |
wp_register_style('ahc_lang_css', plugins_url('/css/vtrts_css_stylesheet.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.4');
|
2799 |
wp_enqueue_style('ahc_lang_css');
|
2800 |
|
|
|
|
|
|
|
2801 |
|
2802 |
+
wp_register_script('slimselect_js', plugins_url('js/slimselect.min.js', AHCFREE_PLUGIN_MAIN_FILE), null, null, true);
|
2803 |
+
wp_enqueue_script('slimselect_js');
|
2804 |
|
2805 |
+
|
2806 |
+
wp_register_style('slimselect', plugins_url('css/slimselect.min.css', AHCFREE_PLUGIN_MAIN_FILE));
|
2807 |
+
wp_enqueue_style('slimselect');
|
2808 |
+
|
2809 |
+
wp_register_style('ahc_bootstrap_css', plugins_url('/lib/bootstrap/css/bootstrap.min.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2810 |
wp_enqueue_style('ahc_bootstrap_css');
|
2811 |
|
2812 |
wp_enqueue_script('jquery');
|
2813 |
|
2814 |
+
wp_register_script('ahc_bootstrap_js', plugins_url('/lib/bootstrap/js/bootstrap.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2815 |
wp_enqueue_script('ahc_bootstrap_js');
|
2816 |
|
2817 |
wp_register_script('ahc_lang_js', plugins_url('/lang/js/' . GlobalsAHC::$lang . '_lang.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2818 |
wp_enqueue_script('ahc_lang_js');
|
2819 |
|
2820 |
+
/* Pagination and export */
|
2821 |
+
wp_register_script('ahc_datatable_js', plugins_url('/js/jquery.dataTables.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2822 |
wp_enqueue_script('ahc_datatable_js');
|
2823 |
wp_register_script('ahc_tableexport_js', plugins_url('/js/dataTables.buttons.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2824 |
wp_enqueue_script('ahc_tableexport_js');
|
2826 |
wp_enqueue_script('ahc_jzip_js');
|
2827 |
wp_register_script('ahc_tableexportbutton_js', plugins_url('/js/buttons.html5.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2828 |
wp_enqueue_script('ahc_tableexportbutton_js');
|
2829 |
+
|
2830 |
wp_register_script('ahc_xlscore_js', plugins_url('/js/xlsx.core.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2831 |
wp_enqueue_script('ahc_xlscore_js');
|
2832 |
wp_register_script('ahc_filesave_js', plugins_url('/js/FileSaver.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2833 |
wp_enqueue_script('ahc_filesave_js');
|
2834 |
wp_register_script('ahc_xls_js', plugins_url('/js/jhxlsx.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2835 |
wp_enqueue_script('ahc_xls_js');
|
2836 |
+
|
2837 |
wp_register_style('jquery_date_css', plugins_url('/css/datepicker.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2838 |
wp_enqueue_style('jquery_date_css');
|
|
|
|
|
|
|
|
|
|
|
|
|
2839 |
|
|
|
2840 |
|
|
|
2841 |
|
2842 |
+
wp_enqueue_script('jquery-ui-datepicker', array('jquery'));
|
2843 |
+
wp_register_script('ahc_main_js', plugins_url('/js/ahcfree_js_scripts.js', AHCFREE_PLUGIN_MAIN_FILE), '', '2.5');
|
2844 |
+
wp_enqueue_script('ahc_main_js');
|
2845 |
|
2846 |
+
wp_localize_script('ahc_main_js', 'ahc_ajax', array('ajax_url' => admin_url('admin-ajax.php')));
|
2847 |
}
|
2848 |
|
2849 |
|
2850 |
|
2851 |
+
function ahcfree_settings_scripts()
|
2852 |
+
{
|
2853 |
|
2854 |
|
2855 |
+
wp_register_style('ahc_bootstrap_css', plugins_url('/lib/bootstrap/css/bootstrap.min.css', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2856 |
wp_enqueue_style('ahc_bootstrap_css');
|
2857 |
|
2858 |
wp_enqueue_script('jquery');
|
2859 |
|
2860 |
+
wp_register_script('ahc_bootstrap_js', plugins_url('/lib/bootstrap/js/bootstrap.min.js', AHCFREE_PLUGIN_MAIN_FILE), '', '1.21');
|
2861 |
wp_enqueue_script('ahc_bootstrap_js');
|
2862 |
|
2863 |
+
wp_register_script('slimselect_js', plugins_url('js/slimselect.min.js', AHCFREE_PLUGIN_MAIN_FILE), null, null, true);
|
2864 |
+
wp_enqueue_script('slimselect_js');
|
2865 |
|
2866 |
|
2867 |
+
wp_register_style('slimselect', plugins_url('css/slimselect.min.css', AHCFREE_PLUGIN_MAIN_FILE));
|
2868 |
+
wp_enqueue_style('slimselect');
|
|
|
|
|
|
|
2869 |
}
|
2870 |
|
2871 |
|
2872 |
|
2873 |
//--------------------------------------------
|
2874 |
//---------------------------------------------Add button to the admin bar
|
2875 |
+
function ahcfree_vtrts_add_items($admin_bar)
|
2876 |
+
{
|
2877 |
global $pluginsurl;
|
2878 |
|
2879 |
$wccpadminurl = get_admin_url();
|
2880 |
+
//The properties of the new item. Read More about the missing 'parent' parameter below
|
2881 |
$args = array(
|
2882 |
'id' => 'visitorstraffic',
|
2883 |
'title' => __('<img src="' . plugins_url('/images/vtrtspro.png', AHCFREE_PLUGIN_MAIN_FILE) . '" style="vertical-align:middle;margin-right:5px;" alt="visitor traffic" title="visitor traffic" />'),
|
2890 |
}
|
2891 |
|
2892 |
//---------------------------------------- Add plugin settings link to Plugins page
|
2893 |
+
function ahcfree_vtrtsp_plugin_add_settings_link($links)
|
2894 |
+
{
|
2895 |
$settings_link = '<a href="admin.php?page=ahc_hits_counter_menu_free">' . __('visitor traffic') . '</a>';
|
2896 |
array_push($links, $settings_link);
|
2897 |
return $links;
|
2901 |
|
2902 |
|
2903 |
|
2904 |
+
function ahcfree_get_hits_by_custom_duration_callback()
|
2905 |
+
{
|
2906 |
$hits_duration = ahc_free_sanitize_text_or_array_field($_POST['hits_duration']);
|
2907 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
2908 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
2909 |
+
|
2910 |
$myend_date = new DateTime();
|
2911 |
$myend_date->setTimezone($custom_timezone);
|
2912 |
+
|
2913 |
$end_date = $myend_date->format('Y-m-d');
|
2914 |
$full_end_date = $myend_date->format('Y-m-d 23:59:59');
|
2915 |
+
|
2916 |
$mystart_date = new DateTime();
|
2917 |
$mystart_date->setTimezone($custom_timezone);
|
2918 |
$stat = '';
|
2919 |
+
switch ($hits_duration) {
|
2920 |
+
|
2921 |
case '7':
|
2922 |
$mystart_date->modify('-6 days');
|
2923 |
$start_date = $mystart_date->format('Y-m-d');
|
2924 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
2925 |
$interval = '1 day';
|
2926 |
+
|
2927 |
break;
|
2928 |
+
|
2929 |
case 'current_month':
|
2930 |
//$mystart_date->modify('0:00 first day of curent month');
|
2931 |
$start_date = $mystart_date->format('Y-m-01');
|
2932 |
+
$end_date = $mystart_date->format('Y-m-t');
|
2933 |
$full_start_date = $mystart_date->format('Y-m-01');
|
2934 |
+
$full_end_date = $mystart_date->format('Y-m-t');
|
2935 |
$interval = '1 day';
|
2936 |
+
$stat = 'current_month';
|
2937 |
break;
|
2938 |
|
2939 |
case 'last_month':
|
2940 |
$mystart_date->modify('0:00 first day of previous month');
|
2941 |
$start_date = $mystart_date->format('Y-m-d');
|
2942 |
+
$end_date = $mystart_date->format('Y-m-t');
|
2943 |
$full_start_date = $mystart_date->format('Y-m-d');
|
2944 |
+
$full_end_date = $mystart_date->format('Y-m-t');
|
2945 |
$interval = '1 day';
|
2946 |
+
$stat = 'last_month';
|
2947 |
break;
|
2948 |
|
2949 |
case '30':
|
2954 |
$myend_date->modify('last day of previous month');
|
2955 |
$end_date = $myend_date->format('Y-m-d');
|
2956 |
$full_end_date = $myend_date->format('Y-m-d H:i:s');*/
|
2957 |
+
|
2958 |
$mystart_date->modify('-30 days');
|
2959 |
$start_date = $mystart_date->format('Y-m-d');
|
2960 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
2961 |
+
|
2962 |
$interval = '1 week';
|
2963 |
break;
|
2964 |
+
|
2965 |
+
|
2966 |
+
|
2967 |
case '0':
|
2968 |
+
$full_start_date = $full_end_date = '';
|
2969 |
+
$stat = 'all';
|
2970 |
break;
|
2971 |
+
|
2972 |
+
case 'range':
|
2973 |
+
$full_start_date = $start_date = ahc_free_sanitize_text_or_array_field($_POST['hits_duration_from']);
|
2974 |
+
$full_end_date = ahc_free_sanitize_text_or_array_field($_POST['hits_duration_to']);
|
2975 |
+
$interval = '1 day';
|
2976 |
break;
|
2977 |
+
|
2978 |
+
default:
|
2979 |
$mystart_date->modify(' - ' . (AHCFREE_VISITORS_VISITS_LIMIT - 1) . ' days');
|
2980 |
$start_date = $mystart_date->format('Y-m-d');
|
2981 |
$full_start_date = $mystart_date->format('Y-m-d 00:00:00');
|
2983 |
break;
|
2984 |
}
|
2985 |
|
2986 |
+
$visits_visitors_data = ahcfree_get_visits_by_custom_duration_callback($full_start_date, $full_end_date, $stat);
|
2987 |
+
//print_r($visits_visitors_data);
|
2988 |
+
|
2989 |
+
$response = array(
|
2990 |
+
'mystart_date' => $start_date,
|
2991 |
+
'myend_date' => $end_date,
|
2992 |
+
'full_start_date' => $full_start_date,
|
2993 |
+
'full_end_date' => $full_end_date,
|
2994 |
+
'interval' => $interval,
|
2995 |
+
'visitors_data' => json_encode($visits_visitors_data['visitors']),
|
2996 |
+
'visits_data' => json_encode($visits_visitors_data['visits'])
|
2997 |
+
);
|
2998 |
+
|
2999 |
+
echo json_encode($response);
|
3000 |
die;
|
3001 |
}
|
3002 |
|
3003 |
|
3004 |
+
function ahcfree_get_visits_by_custom_duration_callback($start_date, $end_date, $stat)
|
3005 |
+
{
|
3006 |
global $wpdb;
|
3007 |
$visits_arr = array();
|
3008 |
$custom_timezone_offset = ahcfree_get_current_timezone_offset();
|
3009 |
$custom_timezone = new DateTimeZone(ahcfree_get_timezone_string());
|
3010 |
+
|
3011 |
$results = false;
|
3012 |
+
|
3013 |
+
$mystart_date = new DateTime($start_date);
|
3014 |
+
$myend_date = new DateTime($end_date);
|
3015 |
+
|
3016 |
+
$total_days = date_diff($mystart_date, $myend_date);
|
3017 |
+
$total_days = $total_days->format("%a");
|
3018 |
+
|
3019 |
+
$cond = "DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) >= DATE('" . $start_date . " 00:00:00') AND DATE(CONVERT_TZ(vst_date, '" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "')) <= DATE('" . $end_date . " 23:59:59')";
|
3020 |
+
|
3021 |
+
if ($stat == 'year') {
|
3022 |
+
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors WHERE " . $cond . " GROUP BY group_date";
|
3023 |
+
}
|
3024 |
+
if ($stat == 'all') {
|
3025 |
+
$sql = "SELECT DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "', '" . $custom_timezone_offset . "'),'%Y-%m') as group_date,DATE_FORMAT(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'),'%Y-%m-01') as vst_date,SUM(vst_visitors) as vst_visitors,SUM(vst_visits) as vst_visits FROM ahc_visitors GROUP BY group_date ORDER BY vst_date ASC";
|
3026 |
+
}
|
3027 |
+
if ($stat == '' || $stat == 'current_month' || $stat == 'last_month') {
|
3028 |
+
$sql = "SELECT DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "')) as vst_date, SUM(vst_visits) AS vst_visits,SUM(vst_visitors) as vst_visitors FROM ahc_visitors WHERE " . $cond . " GROUP BY DATE(CONVERT_TZ(vst_date,'" . AHCFREE_SERVER_CURRENT_TIMEZONE . "','" . $custom_timezone_offset . "'))";
|
3029 |
+
}
|
3030 |
+
//echo $sql;
|
|
|
|
|
|
|
|
|
3031 |
$results = $wpdb->get_results($sql, OBJECT);
|
3032 |
if ($results !== false) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3033 |
|
3034 |
+
if ($stat == 'year') {
|
3035 |
+
for ($i = 1; $i <= ahcfree_localtime('n'); $i++) {
|
3036 |
+
$month = $mystart_date->format('m');
|
3037 |
+
$year = $mystart_date->format('Y');
|
3038 |
+
$total_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
3039 |
+
|
3040 |
+
$visits_arr['visits'][] = array($mystart_date->format('Y-m-d'), 0);
|
3041 |
+
$visits_arr['visitors'][] = array($mystart_date->format('Y-m-d'), 0);
|
3042 |
+
$mystart_date->modify('+' . $total_days . ' days');
|
3043 |
+
}
|
3044 |
+
} elseif ($stat == 'all') {
|
3045 |
+
foreach ($results as $key => $element) {
|
3046 |
+
reset($results);
|
3047 |
+
if ($key === key($results)) {
|
3048 |
+
$first_date = $element->vst_date;
|
3049 |
+
}
|
3050 |
+
|
3051 |
+
end($results);
|
3052 |
+
if ($key === key($results)) {
|
3053 |
+
$last_date = $element->vst_date;
|
3054 |
+
}
|
3055 |
+
}
|
3056 |
+
|
3057 |
+
$d1 = new DateTime($first_date);
|
3058 |
+
$d2 = new DateTime($last_date);
|
3059 |
+
|
3060 |
+
if (count($results) == 1) {
|
3061 |
+
$pre_d1 = new DateTime($first_date);
|
3062 |
+
$pre_d1->modify('first day of previous month');
|
3063 |
+
$visits_arr['visits'][] = array($pre_d1->format('Y-m-d'), 0);
|
3064 |
+
$visits_arr['visitors'][] = array($pre_d1->format('Y-m-d'), 0);
|
3065 |
+
}
|
3066 |
+
|
3067 |
+
$diff = $d1->diff($d2)->m + 1;
|
3068 |
+
|
3069 |
+
for ($i = 1; $i <= $diff; $i++) {
|
3070 |
+
$visits_arr['visits'][] = array($d1->format('Y-m-d'), 0);
|
3071 |
+
$visits_arr['visitors'][] = array($d1->format('Y-m-d'), 0);
|
3072 |
+
$d1->modify('+1 Month');
|
3073 |
+
}
|
3074 |
+
} else {
|
3075 |
+
if ($stat == 'current_month') {
|
3076 |
+
$total_days = ahcfree_localtime('t');
|
3077 |
+
$total_days--;
|
3078 |
+
}
|
3079 |
+
if ($stat == 'last_month') {
|
3080 |
+
$total_days = ahcfree_localtime('t', strtotime('first day of previous month'));
|
3081 |
+
$total_days--;
|
3082 |
+
}
|
3083 |
+
$visits_arr['visits'][] = array($mystart_date->format('Y-m-d'), 0);
|
3084 |
+
$visits_arr['visitors'][] = array($mystart_date->format('Y-m-d'), 0);
|
3085 |
+
for ($i = 1; $i <= $total_days; $i++) {
|
3086 |
+
$mystart_date->modify('+1 Day');
|
3087 |
+
$visits_arr['visits'][] = array($mystart_date->format('Y-m-d'), 0);
|
3088 |
+
$visits_arr['visitors'][] = array($mystart_date->format('Y-m-d'), 0);
|
3089 |
+
}
|
3090 |
+
}
|
3091 |
+
//print_r($visits_arr['visits']);
|
3092 |
+
foreach ($visits_arr['visits'] as $key => $visits) {
|
3093 |
+
foreach ($results as $r) {
|
3094 |
+
if ($visits[0] == $r->vst_date) {
|
3095 |
+
$visits_arr['visits'][$key][1] = $r->vst_visits;
|
3096 |
+
}
|
3097 |
+
}
|
3098 |
+
}
|
3099 |
+
|
3100 |
+
foreach ($visits_arr['visitors'] as $key => $visits) {
|
3101 |
+
foreach ($results as $r) {
|
3102 |
+
if ($visits[0] == $r->vst_date) {
|
3103 |
+
$visits_arr['visitors'][$key][1] = $r->vst_visitors;
|
3104 |
+
}
|
3105 |
+
}
|
3106 |
+
}
|
3107 |
}
|
3108 |
//echo $wpdb->last_query;
|
3109 |
return $visits_arr;
|
|
|
3110 |
}
|
3111 |
+
function ahcfree_admin_notice_to_set_timezone()
|
3112 |
+
{
|
3113 |
+
$class = 'notice notice-error';
|
3114 |
+
$name = 'Visitor Traffic Real Time Statistics Free - Invalid Timezone';
|
3115 |
+
$message = sprintf(__('Invalid timezone, Please visit the <a href="%s">settings</a> page and select your current timezone.'), site_url('wp-admin/admin.php?page=ahc_hits_counter_settings'));
|
3116 |
|
3117 |
+
printf('<br><div class="%1$s" style="padding-top:5px;"><b>%2$s</b><p>%3$s</p></div>', esc_attr($class), $name, $message);
|
|
|
3118 |
}
|
3119 |
/*function ahcfree_get_visitors_by_custom_duration_callback( $start_date,$end_date ){
|
3120 |
|
3166 |
|
3167 |
}*/
|
3168 |
|
3169 |
+
function ahcfree_getFormattedDate($date, $format = "")
|
3170 |
{
|
3171 |
+
if ($date != '') {
|
3172 |
+
if ($format == "yymmdd")
|
3173 |
+
return DateTime::createFromFormat('m-d-Y', $date)->format('Y-m-d');
|
3174 |
+
else
|
3175 |
+
return DateTime::createFromFormat('m-d-Y', $date)->format('m/d/Y');
|
3176 |
+
}
|
|
|
|
|
|
|
3177 |
}
|
3178 |
+
add_action("wp_ajax_traffic_by_title", "ahcfree_traffic_by_title_callback");
|
3179 |
function ahcfree_traffic_by_title_callback()
|
3180 |
{
|
3181 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
3182 |
+
|
3183 |
+
$search_value = ahc_free_sanitize_text_or_array_field($_REQUEST['search']['value']);
|
3184 |
+
|
3185 |
+
$search_page = ahc_free_sanitize_text_or_array_field($search_value);
|
3186 |
+
|
3187 |
+
$res = ahcfree_get_traffic_by_title(1, false, "", "", $search_page);
|
3188 |
+
echo json_encode($res);
|
3189 |
+
exit;
|
3190 |
+
} else {
|
3191 |
+
$search_page = ahc_free_sanitize_text_or_array_field($_REQUEST['search']['value']);
|
3192 |
+
$search_start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3193 |
+
$search_length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3194 |
+
|
3195 |
+
$cnt = ahcfree_get_traffic_by_title("", true, "", "", $search_page);
|
3196 |
+
|
3197 |
+
$tTitles = ahcfree_get_traffic_by_title("", false, $search_start, $search_length, $search_page);
|
3198 |
+
|
3199 |
+
$arr["draw"] = 0;
|
3200 |
+
$arr["recordsTotal"] = $cnt;
|
3201 |
+
$arr["recordsFiltered"] = $cnt;
|
3202 |
+
$arr['data'] = $tTitles;
|
3203 |
+
echo json_encode($arr);
|
3204 |
+
exit;
|
3205 |
+
}
|
|
|
|
|
|
|
3206 |
}
|
3207 |
//add_action("wp_ajax_traffic_by_countries","ahcfree_traffic_by_countries_callback");
|
3208 |
function ahcfree_traffic_by_countries_callback()
|
3209 |
{
|
3210 |
+
|
3211 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
3212 |
+
$res = ahcfree_get_top_countries(0, "", "", 1, false);
|
3213 |
+
echo json_encode($res);
|
3214 |
+
exit;
|
3215 |
+
} else {
|
3216 |
+
|
3217 |
+
$search_start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3218 |
+
$search_length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3219 |
+
|
3220 |
+
|
3221 |
+
$tTitles = ahcfree_get_top_countries(0, $search_start, $search_length, "", false);
|
3222 |
+
$cnt = ahcfree_get_top_countries(0, "", "", "", true);
|
3223 |
+
|
3224 |
+
$arr["draw"] = 0;
|
3225 |
+
$arr["recordsTotal"] = $cnt;
|
3226 |
+
$arr["recordsFiltered"] = $cnt;
|
3227 |
+
$arr['data'] = $tTitles['data'];
|
3228 |
+
echo json_encode($arr);
|
3229 |
+
exit;
|
3230 |
+
}
|
|
|
|
|
|
|
3231 |
}
|
3232 |
|
3233 |
+
add_action("wp_ajax_recent_visitor_by_ip", "ahcfree_recent_visitor_by_ip_callback");
|
3234 |
function ahcfree_recent_visitor_by_ip_callback()
|
3235 |
{
|
3236 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
3237 |
+
|
3238 |
+
$ip = ahc_free_sanitize_text_or_array_field($_REQUEST['ip']);
|
3239 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3240 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3241 |
+
|
3242 |
+
$res = ahcfree_get_recent_visitors(1, false, "", "", $fdt, $tdt, $ip);
|
3243 |
+
echo json_encode($res);
|
3244 |
+
exit;
|
3245 |
+
} else {
|
3246 |
+
$ip = ahc_free_sanitize_text_or_array_field($_REQUEST['ip']);
|
3247 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3248 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3249 |
+
$start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3250 |
+
$length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3251 |
+
|
3252 |
+
$cnt = ahcfree_get_recent_visitors("", true, "", "", $fdt, $tdt, $ip);
|
3253 |
+
$recentVisitors = ahcfree_get_recent_visitors("", false, $start, $length, $fdt, $tdt, $ip);
|
3254 |
+
|
3255 |
+
|
3256 |
+
$arr["draw"] = 0;
|
3257 |
+
$arr["recordsTotal"] = $cnt;
|
3258 |
+
$arr["recordsFiltered"] = $cnt;
|
3259 |
+
$arr['data'] = $recentVisitors;
|
3260 |
+
echo json_encode($arr);
|
3261 |
+
exit;
|
3262 |
+
}
|
|
|
|
|
|
|
3263 |
}
|
3264 |
+
add_action("wp_ajax_latest_search_words", "ahcfree_latest_search_words_callback");
|
3265 |
function ahcfree_latest_search_words_callback()
|
3266 |
{
|
3267 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
|
|
|
|
|
|
|
|
3268 |
|
3269 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3270 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3271 |
+
|
3272 |
+
|
3273 |
+
$res = ahcfree_get_latest_search_key_words_used(1, false, "", "", $fdt, $tdt);
|
3274 |
+
echo json_encode($res);
|
3275 |
+
exit;
|
3276 |
+
} else {
|
3277 |
+
|
3278 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3279 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3280 |
+
$start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3281 |
+
$length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3282 |
+
|
3283 |
+
|
3284 |
+
$cnt = ahcfree_get_latest_search_key_words_used("", true, "", "", $fdt, $tdt);
|
3285 |
+
$recentVisitors = ahcfree_get_latest_search_key_words_used("", false, $start, $length, $fdt, $tdt);
|
3286 |
+
|
3287 |
+
$arr["draw"] = 0;
|
3288 |
+
$arr["recordsTotal"] = $cnt;
|
3289 |
+
$arr["recordsFiltered"] = $cnt;
|
3290 |
+
$arr['data'] = $recentVisitors;
|
3291 |
+
echo json_encode($arr);
|
3292 |
+
exit;
|
3293 |
+
}
|
3294 |
}
|
3295 |
+
add_action("wp_ajax_today_traffic_index", "ahcfree_today_traffic_index_callback");
|
3296 |
function ahcfree_today_traffic_index_callback()
|
3297 |
{
|
3298 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
3299 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3300 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3301 |
+
|
3302 |
+
|
3303 |
+
$res = ahcfree_get_vsitors_by_country(1, false, "", "", $fdt, $tdt);
|
3304 |
+
echo json_encode($res);
|
3305 |
+
exit;
|
3306 |
+
} else {
|
3307 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3308 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3309 |
+
$start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3310 |
+
$length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3311 |
+
|
3312 |
+
$cnt = ahcfree_get_vsitors_by_country("", true, "", "", $fdt, $tdt);
|
3313 |
+
$countries = ahcfree_get_vsitors_by_country("", false, $start, $length, $fdt, $tdt);
|
3314 |
+
|
3315 |
+
$arr["draw"] = 0;
|
3316 |
+
$arr["recordsTotal"] = $cnt;
|
3317 |
+
$arr["recordsFiltered"] = $cnt;
|
3318 |
+
$arr['data'] = $countries;
|
3319 |
+
echo json_encode($arr);
|
3320 |
+
exit;
|
3321 |
+
}
|
|
|
|
|
|
|
3322 |
}
|
3323 |
+
add_action("wp_ajax_visits_time_graph", "ahcfree_visits_time_graph_callback");
|
3324 |
function ahcfree_visits_time_graph_callback()
|
3325 |
{
|
3326 |
+
if (isset($_REQUEST['page']) && $_REQUEST['page'] == "all") {
|
3327 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3328 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3329 |
+
|
3330 |
+
|
3331 |
+
$times = ahcfree_get_time_visits(1, "", "", $fdt, $tdt);
|
3332 |
+
echo json_encode($times);
|
3333 |
+
exit;
|
3334 |
+
} else {
|
3335 |
+
|
3336 |
+
$fdt = ahc_free_sanitize_text_or_array_field($_REQUEST['fdt']);
|
3337 |
+
$tdt = ahc_free_sanitize_text_or_array_field($_REQUEST['tdt']);
|
3338 |
+
$start = ahc_free_sanitize_text_or_array_field($_REQUEST['start']);
|
3339 |
+
$length = ahc_free_sanitize_text_or_array_field($_REQUEST['length']);
|
3340 |
+
|
3341 |
+
|
3342 |
+
$times = ahcfree_get_time_visits("", $start, $length, $fdt, $tdt);
|
3343 |
+
//$res = ahcfree_get_time_visits("","","",$_REQUEST['fdt'],$_REQUEST['tdt']);
|
3344 |
+
$cnt = 24;
|
3345 |
+
$arr["draw"] = 0;
|
3346 |
+
$arr["recordsTotal"] = $cnt;
|
3347 |
+
$arr["recordsFiltered"] = $cnt;
|
3348 |
+
$arr['data'] = $times;
|
3349 |
+
echo json_encode($arr);
|
3350 |
+
exit;
|
3351 |
+
}
|
|
|
|
|
|
|
3352 |
}
|
3353 |
|
3354 |
//------------------------------------------------------------------------
|
3355 |
// --------------------------------------- Create front-end widget
|
3356 |
// Creating the widget
|
3357 |
+
class ahcfree_vtrts_widget extends WP_Widget
|
3358 |
+
{
|
3359 |
|
3360 |
+
function __construct()
|
3361 |
+
{
|
3362 |
parent::__construct(
|
3363 |
+
// Base ID of your widget
|
3364 |
+
'ahcfree_vtrts_widget',
|
3365 |
+
// Widget name will appear in UI
|
3366 |
+
__('Visitor Traffic', 'wpb_widget_domain'),
|
3367 |
+
// Widget description
|
3368 |
+
array('description' => __('Display your site statistics', 'wpb_widget_domain'),)
|
3369 |
);
|
3370 |
}
|
3371 |
|
3372 |
+
// Creating widget front-end
|
3373 |
+
// This is where the action happens
|
3374 |
+
public function widget($args, $instance)
|
3375 |
+
{
|
3376 |
$title = apply_filters('widget_title', $instance['title']);
|
3377 |
+
// before and after widget arguments are defined by themes
|
3378 |
+
|
3379 |
if (!empty($title))
|
3380 |
echo esc_html($title);
|
3381 |
|
3382 |
|
3383 |
$ahc_sum_stats = ahcfree_get_summary_statistics();
|
3384 |
|
3385 |
+
if (is_array($instance)) {
|
3386 |
+
// This is where you run the code and display the output
|
3387 |
+
echo '<ul style="list-style:none; ' . esc_attr($instance['fontTypeCombo']) . '; font-size:' . esc_attr($instance['fontSizeCombo']) . 'px">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3388 |
|
3389 |
+
if (isset($instance['display_visitorstoday']) && ($instance['display_visitorstoday'] == 1 or $instance['display_visitorstoday'] == '1')) {
|
3390 |
+
echo '<li><b>Today\'s visitors: </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visitors'])) . '</span></li>';
|
3391 |
+
}
|
3392 |
+
if (isset($instance['display_pageviewtoday']) && ($instance['display_pageviewtoday'] == 1 or $instance['display_pageviewtoday'] == '1')) {
|
3393 |
+
echo '<li><b>Today\'s page views: : </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['today']['visits'])) . '</span></li>';
|
3394 |
+
}
|
3395 |
|
3396 |
+
if (isset($instance['display_totalvisitors']) && ($instance['display_totalvisitors'] == 1 or $instance['display_totalvisitors'] == '1')) {
|
3397 |
+
echo '<li><b>Total visitors : </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['total']['visitors'])) . '</span></li>';
|
3398 |
+
}
|
3399 |
|
3400 |
+
if (isset($instance['display_totalpageview']) && ($instance['display_totalpageview'] == 1 or $instance['display_totalpageview'] == '1')) {
|
3401 |
+
echo '<li><b>Total page views: </b><span>' . ahcfree_NumFormat(intval($ahc_sum_stats['total']['visits'])) . '</span></li>';
|
3402 |
+
}
|
3403 |
|
3404 |
+
|
3405 |
+
echo '</ul>';
|
3406 |
+
}
|
|
|
3407 |
}
|
3408 |
|
3409 |
+
// Widget Backend
|
3410 |
+
public function form($instance)
|
3411 |
+
{
|
3412 |
extract($instance);
|
3413 |
|
3414 |
if (isset($instance['title'])) {
|
3416 |
} else {
|
3417 |
$title = __('Site Statistics', 'wpb_widget_domain');
|
3418 |
}
|
3419 |
+
// Widget admin form
|
3420 |
+
|
3421 |
+
$fontTypeCombo = (isset($fontTypeCombo)) ? $fontTypeCombo : '';
|
3422 |
+
$display_valuescolor = (isset($display_valuescolor)) ? $display_valuescolor : '';
|
3423 |
+
$display_titlecolor = (isset($display_titlecolor)) ? $display_titlecolor : '';
|
3424 |
+
|
3425 |
+
|
3426 |
+
?>
|
3427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3428 |
|
|
|
3429 |
<p>
|
3430 |
+
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Widget Title:'); ?></label>
|
3431 |
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
|
3432 |
</p>
|
3433 |
|
3434 |
+
|
3435 |
+
|
3436 |
|
3437 |
|
3438 |
<p>
|
3470 |
<select class="widefat" id="<?php echo esc_attr($this->get_field_id('fontSizeCombo')); ?>" name="<?php echo esc_attr($this->get_field_name('fontSizeCombo')); ?>">
|
3471 |
<?php
|
3472 |
for ($fs = 8; $fs <= 22; $fs++) {
|
3473 |
+
$fontSizeCombo = (isset($fontSizeCombo)) ? $fontSizeCombo : '12';
|
3474 |
+
?>
|
3475 |
<option value="<?php echo intval($fs) ?>" <?php selected($fontSizeCombo, $fs); ?>><?php echo intval($fs); ?>px</option>
|
3476 |
<?php } ?>
|
3477 |
</select>
|
3480 |
</p>
|
3481 |
|
3482 |
<p><em>Display :</em></p>
|
3483 |
+
<?php
|
3484 |
+
|
3485 |
+
$display_visitorstoday = isset($display_visitorstoday) ? $display_visitorstoday : '0';
|
3486 |
+
$display_pageviewtoday = isset($display_pageviewtoday) ? $display_pageviewtoday : '0';
|
3487 |
+
$display_totalpageview = isset($display_totalpageview) ? $display_totalpageview : '0';
|
3488 |
+
$display_totalvisitors = isset($display_totalvisitors) ? $display_totalvisitors : '0';
|
3489 |
+
?>
|
3490 |
+
|
3491 |
|
|
|
3492 |
<p>
|
3493 |
+
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_visitorstoday')); ?>" name="<?php echo esc_attr($this->get_field_name('display_visitorstoday')); ?>" type="checkbox" value="1" <?php checked($display_visitorstoday, '1'); ?> /> <label for="<?php echo esc_attr($this->get_field_id('display_visitorstoday')); ?>">Today\'s visitors</label>
|
3494 |
</p>
|
3495 |
<p>
|
3496 |
+
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_pageviewtoday')); ?>" name="<?php echo esc_attr($this->get_field_name('display_pageviewtoday')); ?>" type="checkbox" value="1" <?php checked($display_pageviewtoday, '1'); ?> /> <label for="<?php echo esc_attr($this->get_field_id('display_pageviewtoday')); ?>">Today\'s page views</label>
|
3497 |
</p>
|
3498 |
<p>
|
3499 |
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_totalpageview')); ?>" name="<?php echo esc_attr($this->get_field_name('display_totalpageview')); ?>" type="checkbox" value="1" <?php checked($display_totalpageview, '1'); ?> /> <label for="<?php echo esc_attr($this->get_field_id('display_totalpageview')); ?>">Total page views</label>
|
3500 |
</p>
|
3501 |
<p>
|
3502 |
+
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('display_totalvisitors')); ?>" name="<?php echo esc_attr($this->get_field_name('display_totalvisitors')); ?>" type="checkbox" value="1" <?php checked($display_totalvisitors, '1'); ?> /> <label for="<?php echo esc_attr($this->get_field_id('display_totalvisitors')); ?>">Total visitors</label>
|
3503 |
</p>
|
3504 |
+
|
3505 |
+
<?php
|
3506 |
}
|
3507 |
|
3508 |
+
// Updating widget replacing old instances with new
|
3509 |
+
public function update($new_instance, $old_instance)
|
3510 |
+
{
|
3511 |
|
3512 |
return $new_instance;
|
3513 |
}
|
|
|
3514 |
}
|
3515 |
|
3516 |
// Class ahcfree_vtrts_widget ends here
|
3517 |
// Register and load the widget
|
3518 |
+
function ahcfree_wpb_load_widget()
|
3519 |
+
{
|
3520 |
register_widget('ahcfree_vtrts_widget');
|
3521 |
}
|
3522 |
|
3523 |
add_action('widgets_init', 'ahcfree_wpb_load_widget');
|
3524 |
|
3525 |
+
?>
|
overview.php
CHANGED
@@ -32,105 +32,102 @@ $mystart_date = $mystart_date->format('Y-m-d');
|
|
32 |
image.src = "<?php echo plugins_url('/images/flags/noFlag.png', AHCFREE_PLUGIN_MAIN_FILE) ?>";
|
33 |
return true;
|
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 |
-
const d = new Date();
|
68 |
-
|
69 |
-
|
70 |
-
var dateTime = day+' '+monthNames[d.getMonth()]+' '+year+', '+hour+':'+minute+':'+second;
|
71 |
-
|
72 |
-
|
73 |
</script>
|
74 |
|
75 |
<style>
|
76 |
-
|
|
|
|
|
77 |
</style>
|
78 |
|
79 |
-
<div class="ahc_main_container"
|
80 |
-
|
81 |
-
<div class="row"
|
82 |
-
<div class="col-lg-12">
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
</div>
|
127 |
-
</div>
|
128 |
-
|
129 |
-
|
130 |
-
<div class="row" >
|
131 |
<div class="col-lg-3">
|
132 |
-
<div class="box_widget greenBox"
|
133 |
-
|
134 |
<br /><span class="txt"><img src="<?php echo esc_url(plugins_url('/images/live.gif', AHCFREE_PLUGIN_MAIN_FILE)) ?>"> Online Users</span>
|
135 |
</div>
|
136 |
</div>
|
@@ -150,38 +147,38 @@ var dateTime = day+' '+monthNames[d.getMonth()]+' '+year+', '+hour+':'+minute+':
|
|
150 |
</div>
|
151 |
</div>
|
152 |
</div>
|
153 |
-
|
154 |
<div class="row">
|
155 |
<div class="col-lg-12">
|
156 |
-
|
157 |
-
<div class="panel" style="background-color:white">
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
<div class="panelcontent"
|
185 |
<div id="visitscount" style="height:400px; width:99% !important; "></div>
|
186 |
</div>
|
187 |
</div>
|
@@ -191,11 +188,11 @@ var dateTime = day+' '+monthNames[d.getMonth()]+' '+year+', '+hour+':'+minute+':
|
|
191 |
<div class="row">
|
192 |
<div class="col-lg-8">
|
193 |
<div class="panel" style="width:100% !important">
|
194 |
-
|
195 |
<div class="panelcontent" style="width:100% !important">
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
</div>
|
200 |
</div>
|
201 |
</div>
|
@@ -203,234 +200,234 @@ var dateTime = day+' '+monthNames[d.getMonth()]+' '+year+', '+hour+':'+minute+':
|
|
203 |
$ahc_sum_stat = ahcfree_get_summary_statistics();
|
204 |
?>
|
205 |
<div class="col-lg-4">
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
258 |
</div>
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
<thead>
|
266 |
-
<tr>
|
267 |
-
<th width="40%">Engine</th>
|
268 |
-
<th width="30%">Total</th>
|
269 |
-
|
270 |
-
</tr>
|
271 |
-
</thead>
|
272 |
-
<tbody>
|
273 |
-
<?php
|
274 |
-
|
275 |
-
$alltimeSER = ahcfree_get_hits_search_engines_referers('alltime');
|
276 |
-
|
277 |
-
$tot_srch = 0;
|
278 |
-
if (is_array($alltimeSER)) {
|
279 |
-
foreach ($alltimeSER as $ser=>$v) {
|
280 |
-
$tot_srch += $v;
|
281 |
-
$ser = (!empty($ser)) ? $ser : 'Other';
|
282 |
-
?>
|
283 |
<tr>
|
284 |
-
<
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
</tr>
|
|
|
|
|
289 |
<?php
|
290 |
-
}
|
291 |
-
}
|
292 |
-
?>
|
293 |
-
<tr>
|
294 |
-
<td><strong>Total </strong></td>
|
295 |
-
<td class="values" ><strong id="today_search"><?php echo ahcfree_NumFormat(intval($tot_srch)); ?></strong></td>
|
296 |
-
|
297 |
-
</tr>
|
298 |
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
</div>
|
302 |
</div>
|
303 |
-
</div>
|
304 |
</div>
|
305 |
</div>
|
306 |
<div class="row">
|
307 |
-
|
308 |
<div class="panel" style="width:100% !important">
|
309 |
-
<h2 class="box-heading">Recent visitors by IP<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span></h2>
|
310 |
-
<div class="search-panel <?php echo (isset($_POST['section']) && $_POST['section']=="recent_visitor_by_ip") ? "open" : ''; ?>">
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
<div class="panelcontent" style="width:100% !important">
|
332 |
|
333 |
|
334 |
<table width="95%" border="0" cellspacing="0" class="recentv" id="recent_visit_by_ip">
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
</table>
|
353 |
-
|
354 |
|
355 |
</div>
|
356 |
</div>
|
357 |
</div>
|
358 |
<?php
|
359 |
-
|
360 |
-
$countries =array();
|
361 |
?>
|
362 |
<div class="col-lg-4">
|
363 |
<div class="panel" style="width:100% !important">
|
364 |
-
<h2 class="box-heading">
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
?>
|
376 |
-
<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span></h2>
|
377 |
-
|
378 |
<div class="panelcontent" style="width:100% !important">
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
</div>
|
383 |
|
384 |
</div>
|
385 |
</div>
|
386 |
</div>
|
387 |
-
|
388 |
<div class="row">
|
389 |
<div class="col-lg-6">
|
390 |
<!-- browsers chart panel -->
|
391 |
<div class="panel" style="width:100% !important; overflow:hidden">
|
392 |
-
<h2 class="box-heading"><?php echo ahc_browsers ?></h2>
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
</div>
|
405 |
<div class="col-lg-6">
|
406 |
<!-- search engines chart panel -->
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
<h2 class="box-heading">Search Engines</h2>
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
</div>
|
427 |
</div>
|
428 |
-
|
429 |
-
|
430 |
<div class="row">
|
431 |
<?php
|
432 |
/*$countries_data = ahcfree_get_top_countries("","","","",true);*/
|
433 |
-
$countries_data=array();
|
434 |
if (isset($countries_data['data'])) {
|
435 |
$countries = $countries_data['data'];
|
436 |
} else {
|
@@ -439,521 +436,547 @@ var dateTime = day+' '+monthNames[d.getMonth()]+' '+year+', '+hour+':'+minute+':
|
|
439 |
?>
|
440 |
<div class="col-lg-6">
|
441 |
<div class="panel" style="width:100% !important">
|
442 |
-
<h2 class="box-heading">Traffic by country (all time)</h2>
|
443 |
<div class="panelcontent" style="width:100% !important">
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
</div>
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
<div class="col-lg-6">
|
453 |
-
|
454 |
<div class="panel" style="width:100% !important">
|
455 |
-
<h2 class="box-heading">Top Referring Countries (all time)</h2>
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
</div>
|
464 |
-
|
465 |
</div>
|
466 |
</div>
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
$googlehits += $site['total_hits'];
|
490 |
} else {
|
491 |
*/
|
492 |
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
}
|
520 |
-
?>
|
521 |
-
</div>
|
522 |
-
</div>
|
523 |
-
|
524 |
</div>
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
<!-- time visits graph begin -->
|
530 |
<?php
|
531 |
//$times = ahcfree_get_time_visits();
|
532 |
$times = array();
|
533 |
?>
|
534 |
<div class="panel" style="width:100% !important">
|
535 |
-
<h2 class="box-heading">Today's time graph<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span><span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
536 |
-
<div class="search-panel <?php echo (isset($_POST['section']) && $_POST['section']=="visit_time") ? "open" : ''; ?>">
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
<div class="panelcontent" style="padding-right: 50px;">
|
553 |
<table width="100%" border="0" cellspacing="0" id="visit_time_graph_table">
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
</thead>
|
562 |
<tbody>
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
|
|
588 |
}
|
589 |
-
|
590 |
-
?>
|
591 |
</tbody>
|
592 |
</table>
|
593 |
</div>
|
594 |
</div>
|
595 |
-
</div>
|
596 |
-
|
597 |
<div class="row">
|
598 |
<!-- traffic by title -->
|
599 |
<div class="col-lg-6">
|
600 |
<?php
|
601 |
/*$tTitles = ahcfree_get_traffic_by_title();*/
|
602 |
-
$tTitles=array();
|
603 |
?>
|
604 |
<div class="panel" style="width:100% !important">
|
605 |
-
<h2 class="box-heading"><?php echo traffic_by_title ?> (all time)<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span><span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
606 |
-
|
607 |
<div class="panelcontent" style="padding-right: 50px;">
|
608 |
<table width="100%" border="0" cellspacing="0" id="traffic_by_title">
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
</thead>
|
617 |
<tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
<?php
|
619 |
-
$
|
620 |
-
|
621 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
?>
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
<?php
|
630 |
-
|
|
|
|
|
|
|
631 |
}
|
632 |
-
|
633 |
?>
|
634 |
-
</tbody>
|
635 |
</table>
|
636 |
-
|
637 |
</div>
|
638 |
</div>
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
?>
|
659 |
-
<label>Search in Time Frame: </label>
|
660 |
-
<input type="hidden" name="page" value="ahc_hits_counter_menu_free"/>
|
661 |
-
<input type="hidden" name="section" value="lastest_search"/>
|
662 |
-
<input type="text" readonly="readonly" placeholder="From Date" class="ahc_clear" name="from_dt" id="from_dt" autocomplete="off" value="<?php echo esc_attr($from_dt); ?>"/>
|
663 |
-
<input type="text" readonly="readonly" placeholder="To Date" class="ahc_clear" name="to_dt" id="to_dt" autocomplete="off" value="<?php echo esc_attr($to_dt); ?>"/>
|
664 |
-
<input type="submit" class="button button-primary"/>
|
665 |
-
<input type="button" class="button button-primary clear_form" value="Clear"/>
|
666 |
-
</form>
|
667 |
-
</div>
|
668 |
-
<div class="panelcontent" style="padding-right: 50px;">
|
669 |
-
<table width="100%" border="0" cellspacing="0" id="lasest_search_words">
|
670 |
-
<thead>
|
671 |
-
<tr>
|
672 |
-
<th width="20%">Country</th>
|
673 |
-
<th width="30%">Info.</th>
|
674 |
-
<th width="40%">Keyword</th>
|
675 |
-
<th width="10%" class='text-center'>Date</th>
|
676 |
-
</tr>
|
677 |
-
</thead>
|
678 |
-
|
679 |
-
|
680 |
-
<?php
|
681 |
-
if(count($lastSearchKeyWordsUsed) > 0)
|
682 |
-
{
|
683 |
-
?>
|
684 |
-
<tbody>
|
685 |
-
<?php
|
686 |
-
foreach ($lastSearchKeyWordsUsed as $searchWord) {
|
687 |
-
$visitDate = new DateTime($searchWord['hit_date']);
|
688 |
-
$visitDate->setTimezone($custom_timezone);
|
689 |
-
?>
|
690 |
-
<tr>
|
691 |
-
<td>
|
692 |
-
<span><?php if ($searchWord['ctr_internet_code'] != '') { ?><img src="<?php echo plugins_url('/images/flags/' . strtolower($searchWord['ctr_internet_code']) . '.png', AHCFREE_PLUGIN_MAIN_FILE); ?>" border="0" width="22" height="18" title="<?php echo esc_html($searchWord['ctr_name']) ?>" onerror="imgFlagError(this)" /><?php } ?></span>
|
693 |
-
</td>
|
694 |
-
<td class="hide"><?php echo esc_html($searchWord['csb']);?></td>
|
695 |
-
<td>
|
696 |
-
<span class="searchKeyWords"><a href="<?php echo esc_url($searchWord['hit_referer']); ?>" target="_blank"><?php echo esc_html($searchWord['hit_search_words']) ?></a></span>
|
697 |
-
</td>
|
698 |
-
<td>
|
699 |
-
<span class="visitDateTime"> <?php echo esc_html($visitDate->format('d/m/Y')); ?></span>
|
700 |
-
</td>
|
701 |
-
</tr>
|
702 |
-
<?php
|
703 |
-
}
|
704 |
-
?>
|
705 |
-
</tbody>
|
706 |
-
<?php
|
707 |
-
}
|
708 |
-
|
709 |
-
?>
|
710 |
-
</table>
|
711 |
-
</div>
|
712 |
-
</div>
|
713 |
-
<?php /*}*/ ?>
|
714 |
-
</div>
|
715 |
-
</div>
|
716 |
-
<div class="row">
|
717 |
-
<div class="col-12">
|
718 |
-
<center>
|
719 |
-
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&footer=true">
|
720 |
-
<p style="color:#00F; font-size:15px;">if you need more statistics you can upgrade to the professional version now, The premium version of Visitor Traffic real-time statistics is completely different from the free version as there are a lot more features included.</p>
|
721 |
-
|
722 |
-
<p><img style="border:#CCC solid 1px; margin-right:30px" height="auto" src="<?php echo esc_url(plugins_url('/images/upgradenow-button.png', AHCFREE_PLUGIN_MAIN_FILE)); ?>" /></p>
|
723 |
-
</a>
|
724 |
-
</center>
|
725 |
-
|
726 |
-
</div>
|
727 |
-
</div>
|
728 |
<?php
|
729 |
-
|
730 |
?>
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
wp_enqueue_script('ahc_gstatic_js');
|
736 |
-
|
737 |
<script language="javascript" type="text/javascript">
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
function drawChart() {
|
782 |
-
|
783 |
-
var data = new google.visualization.DataTable();
|
784 |
-
data.addColumn('string', 'Browser');
|
785 |
-
data.addColumn('number', 'Hits');
|
786 |
-
data.addRows([
|
787 |
-
|
788 |
-
<?php echo ahcfree_get_browsers_hits_counts(); ?>
|
789 |
-
]);
|
790 |
-
|
791 |
-
var options = {
|
792 |
-
title: '',
|
793 |
-
slices: { 4: {offset: 0.2},
|
794 |
-
12: {offset: 0.3},
|
795 |
-
14: {offset: 0.4},
|
796 |
-
15: {offset: 0.5},
|
797 |
-
},
|
798 |
-
};
|
799 |
-
|
800 |
-
var chart = new google.visualization.PieChart(document.getElementById('brsPiechartContainer'));
|
801 |
-
chart.draw(data, options);
|
802 |
-
}
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
}
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
}
|
840 |
-
|
841 |
-
var mystart_date = "<?php echo esc_js($mystart_date)
|
842 |
var myend_date = "<?php echo esc_js($myend_date); ?>";
|
843 |
-
var mystart_date_full = "<?php echo esc_js($mystart_date_full)
|
844 |
var myend_date_full = "<?php echo esc_js($myend_date_full); ?>";
|
845 |
-
|
846 |
-
|
847 |
-
var countriesData = <?php echo json_encode(ahcfree_get_top_countries(10,"","","",false)); ?>;
|
848 |
-
var visits_data = <?php echo json_encode($visits_visitors_data['visits'])
|
849 |
-
var visitors_data = <?php echo json_encode($visits_visitors_data['visitors'])
|
850 |
//console.log(visits_data);
|
851 |
-
|
852 |
-
jQuery(document).ready(function
|
853 |
-
|
854 |
-
|
855 |
//------------------------------------------
|
856 |
//if(visitsData.success && typeof visitsData.data != 'undefined'){
|
857 |
-
|
858 |
-
drawVisitsLineChart(
|
859 |
//}
|
860 |
//------------------------------------------
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
if (typeof drawBrowsersPieChart === "function") {
|
865 |
-
|
866 |
drawBrowsersPieChart();
|
867 |
}
|
868 |
//------------------------------------------
|
869 |
if (typeof drawSrhEngVstLineChart === "function") {
|
870 |
drawSrhEngVstLineChart();
|
871 |
}
|
872 |
-
|
873 |
|
874 |
});
|
875 |
-
|
876 |
-
jQuery(document).on('change','#hits-duration',function(){
|
877 |
-
|
878 |
-
|
879 |
var self = jQuery(this);
|
880 |
var duration = self.val();
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
}
|
914 |
-
}
|
915 |
});
|
916 |
-
|
917 |
-
|
918 |
var self = jQuery(this);
|
919 |
-
var duration = jQuery('#summary_from_dt').val()+'#'+self.val();
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
}
|
953 |
-
}
|
954 |
});
|
955 |
|
956 |
-
|
957 |
//document.getElementById('today_visitors_detail_cnt').innerHTML = (document.getElementById('today_visitors').innerHTML);
|
958 |
document.getElementById('today_visits_box').innerHTML = (document.getElementById('today_visits').innerHTML);
|
959 |
document.getElementById('today_search_box').innerHTML = (document.getElementById('today_search').innerHTML);
|
32 |
image.src = "<?php echo plugins_url('/images/flags/noFlag.png', AHCFREE_PLUGIN_MAIN_FILE) ?>";
|
33 |
return true;
|
34 |
}
|
35 |
+
|
36 |
+
setInterval(function() {
|
37 |
+
|
38 |
+
var now = new Date();
|
39 |
+
var year = now.getFullYear();
|
40 |
+
var month = now.getMonth() + 1;
|
41 |
+
var day = now.getDate();
|
42 |
+
var hour = now.getHours();
|
43 |
+
var minute = now.getMinutes();
|
44 |
+
var second = now.getSeconds();
|
45 |
+
if (month.toString().length == 1) {
|
46 |
+
month = '0' + month;
|
47 |
+
}
|
48 |
+
if (day.toString().length == 1) {
|
49 |
+
day = '0' + day;
|
50 |
+
}
|
51 |
+
if (hour.toString().length == 1) {
|
52 |
+
hour = '0' + hour;
|
53 |
+
}
|
54 |
+
if (minute.toString().length == 1) {
|
55 |
+
minute = '0' + minute;
|
56 |
+
}
|
57 |
+
if (second.toString().length == 1) {
|
58 |
+
second = '0' + second;
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
64 |
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
65 |
+
];
|
66 |
+
|
67 |
+
const d = new Date();
|
68 |
+
|
69 |
+
|
70 |
+
var dateTime = day + ' ' + monthNames[d.getMonth()] + ' ' + year + ', ' + hour + ':' + minute + ':' + second;
|
71 |
+
document.getElementById('ahcfree_currenttime').innerHTML = dateTime;
|
72 |
+
}, 500);
|
73 |
</script>
|
74 |
|
75 |
<style>
|
76 |
+
body {
|
77 |
+
background: #F1F1F1 !important
|
78 |
+
}
|
79 |
</style>
|
80 |
|
81 |
+
<div class="ahc_main_container">
|
82 |
+
|
83 |
+
<div class="row">
|
84 |
+
<div class="col-lg-12">
|
85 |
+
<br />
|
86 |
+
<div id="vtrts_subscribe" class="alert alert-success is-dismissible alert alert-info is-dismissible" role="alert" style="font-size:12px">
|
87 |
+
|
88 |
+
<input type="text" width="400px" name="ahc_admin_email" id="ahc_admin_email" value="<?php echo get_bloginfo("admin_email"); ?>">
|
89 |
+
<button type="button" class="btn btn-primary" onclick="vtrts_open_subscribe_page('<?php echo get_bloginfo("admin_email") ?>')">Subscribe</button><br /><br />Subscribe now to get latest news and updates, plugin recommendations and configuration help, promotional email with<b style="color:red"> discount codes :) </b><br />
|
90 |
+
<div style="float:right; font-size:12px; display:inline"><a href="#" style="cursor: pointer; !important;" onclick="vtrts_dismiss_notice()">Dismiss this notice</a></div>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<script>
|
94 |
+
function vtrts_dismiss_notice() {
|
95 |
+
localStorage.setItem('vtrts_subscribed', 'vtrts_subs_users');
|
96 |
+
document.getElementById("vtrts_subscribe").style.display = "none";
|
97 |
+
}
|
98 |
+
|
99 |
+
function vtrts_open_subscribe_page() {
|
100 |
+
if (localStorage.getItem('vtrts_subscribed') != 'vtrts_subs_users') {
|
101 |
+
var ahc_admin_email = document.getElementById("ahc_admin_email").value;
|
102 |
+
window.open('https://www.wp-buy.com/vtrts-subscribe/?email=' + ahc_admin_email, '_blank');
|
103 |
+
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
if (localStorage.getItem('vtrts_subscribed') == 'vtrts_subs_users') {
|
108 |
+
|
109 |
+
document.getElementById("vtrts_subscribe").style.display = "none";
|
110 |
+
}
|
111 |
+
</script>
|
112 |
+
|
113 |
+
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
<div class="row">
|
117 |
+
<div class="col-lg-8">
|
118 |
+
<h1><img height="55px" src="<?php echo esc_url(plugins_url('/images/logo.png', AHCFREE_PLUGIN_MAIN_FILE)); ?>"> Visitor Traffic Real Time Statistics free <a title="change settings" href="admin.php?page=ahc_hits_counter_settings"><img src="<?php echo esc_url(plugins_url('/images/settings.jpg', AHCFREE_PLUGIN_MAIN_FILE)) ?>" /></a></h1>
|
119 |
+
|
120 |
+
</div>
|
121 |
+
<div class="col-lg-4">
|
122 |
+
<h2 id="ahcfree_currenttime"></h2>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
|
127 |
+
<div class="row">
|
|
|
|
|
|
|
|
|
|
|
128 |
<div class="col-lg-3">
|
129 |
+
<div class="box_widget greenBox">
|
130 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&box=true"><img src="<?php echo esc_url(plugins_url('/images/upgrade_now.png', AHCFREE_PLUGIN_MAIN_FILE)) ?>"></a>
|
131 |
<br /><span class="txt"><img src="<?php echo esc_url(plugins_url('/images/live.gif', AHCFREE_PLUGIN_MAIN_FILE)) ?>"> Online Users</span>
|
132 |
</div>
|
133 |
</div>
|
147 |
</div>
|
148 |
</div>
|
149 |
</div>
|
150 |
+
|
151 |
<div class="row">
|
152 |
<div class="col-lg-12">
|
153 |
+
|
154 |
+
<div class="panel" style="background-color:white ;border-radius: 7px;">
|
155 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">
|
156 |
+
<?php echo "Traffic Report "; ?></h2>
|
157 |
+
<div class="hits_duration_select">
|
158 |
+
|
159 |
+
|
160 |
+
<select id="hits-duration" class="hits-duration" style="width: 150px; height: 35px; font-size: 15px;">
|
161 |
+
<option value="">Last <?php echo AHCFREE_VISITORS_VISITS_LIMIT; ?> days</option>
|
162 |
+
<option value="7">Last 7 days</option>
|
163 |
+
<option value="30">Last 30 days</option>
|
164 |
+
<option value="current_month">This month</option>
|
165 |
+
<option value="last_month">Last month</option>
|
166 |
+
<option value="0">All Time</option>
|
167 |
+
<option value="range">Custom Period</option>
|
168 |
+
</select>
|
169 |
+
|
170 |
+
<span id="duration_area">
|
171 |
+
<?php
|
172 |
+
$summary_from_dt = isset($_POST['summary_from_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['summary_from_dt']) : '';
|
173 |
+
$summary_to_dt = isset($_POST['summary_to_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['summary_to_dt']) : '';
|
174 |
+
?>
|
175 |
+
<input type="text" readonly="readonly" placeholder="From Date" class="ahc_clear" name="summary_from_dt" id="summary_from_dt" autocomplete="off" value="<?php echo esc_attr($summary_from_dt); ?>" />
|
176 |
+
<input type="text" readonly="readonly" placeholder="To Date" class="ahc_clear" name="summary_to_dt" id="summary_to_dt" autocomplete="off" value="<?php echo esc_attr($summary_to_dt); ?>" />
|
177 |
+
</span>
|
178 |
+
|
179 |
+
|
180 |
+
</div>
|
181 |
+
<div class="panelcontent" id="visitors_graph_stats" style="width:100% !important; overflow:hidden">
|
182 |
<div id="visitscount" style="height:400px; width:99% !important; "></div>
|
183 |
</div>
|
184 |
</div>
|
188 |
<div class="row">
|
189 |
<div class="col-lg-8">
|
190 |
<div class="panel" style="width:100% !important">
|
191 |
+
|
192 |
<div class="panelcontent" style="width:100% !important">
|
193 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&box=true">
|
194 |
+
<img width="99%" src="<?php echo esc_url(plugins_url('/images/geomap_pro.jpg', AHCFREE_PLUGIN_MAIN_FILE)); ?>">
|
195 |
+
</a>
|
196 |
</div>
|
197 |
</div>
|
198 |
</div>
|
200 |
$ahc_sum_stat = ahcfree_get_summary_statistics();
|
201 |
?>
|
202 |
<div class="col-lg-4">
|
203 |
+
<div class="panel-group">
|
204 |
+
<div class="panel" style="width:100% !important">
|
205 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo ahc_summary_statistics ?></h2>
|
206 |
+
<div class="panelcontent" style="width:100% !important">
|
207 |
+
<table width="95%" border="0" cellspacing="0" id="summary_statistics">
|
208 |
+
<thead>
|
209 |
+
<tr>
|
210 |
+
<th width="40%"></th>
|
211 |
+
<th width="30%"><b><?php echo ahc_visitors ?></b></th>
|
212 |
+
<th width="30%"><?php echo ahc_visits ?></th>
|
213 |
+
</tr>
|
214 |
+
</thead>
|
215 |
+
<tbody>
|
216 |
+
<tr>
|
217 |
+
<td><b><?php echo ahc_today ?></b></td>
|
218 |
+
<td class="values"><span id="today_visitors"><?php echo ahcfree_NumFormat($ahc_sum_stat['today']['visitors']); ?></span></td>
|
219 |
+
<td class="values"><span id="today_visits"><?php echo ahcfree_NumFormat($ahc_sum_stat['today']['visits']); ?></span></td>
|
220 |
+
</tr>
|
221 |
+
|
222 |
+
<tr>
|
223 |
+
<td><b><?php echo ahc_yesterday ?></b></td>
|
224 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['yesterday']['visitors']); ?></td>
|
225 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['yesterday']['visits']); ?></td>
|
226 |
+
</tr>
|
227 |
+
|
228 |
+
<tr>
|
229 |
+
<td><b><?php echo ahc_this_week ?></b></td>
|
230 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['week']['visitors']); ?></td>
|
231 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['week']['visits']); ?></td>
|
232 |
+
</tr>
|
233 |
+
|
234 |
+
<tr>
|
235 |
+
<td><b><?php echo ahc_this_month ?></b></td>
|
236 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['month']['visitors']); ?></td>
|
237 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['month']['visits']); ?></td>
|
238 |
+
</tr>
|
239 |
+
|
240 |
+
<tr>
|
241 |
+
<td><b><?php echo ahc_this_yesr ?></b></td>
|
242 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['year']['visitors']); ?></td>
|
243 |
+
<td class="values"><?php echo ahcfree_NumFormat($ahc_sum_stat['year']['visits']); ?></td>
|
244 |
+
</tr>
|
245 |
+
|
246 |
+
<tr>
|
247 |
+
<td style="color:#090"><strong><b><?php echo ahc_total ?></b></strong></td>
|
248 |
+
<td class="values" style="color:#090"><strong><?php echo ahcfree_NumFormat($ahc_sum_stat['total']['visitors']); ?></strong></td>
|
249 |
+
<td class="values" style="color:#090"><strong><?php echo ahcfree_NumFormat($ahc_sum_stat['total']['visits']); ?></strong></td>
|
250 |
+
</tr>
|
251 |
+
</tbody>
|
252 |
+
</table>
|
253 |
+
<!-- end visitors and visits section -->
|
254 |
+
|
255 |
+
</div>
|
256 |
</div>
|
257 |
+
|
258 |
+
<div class="panel" style="width:100% !important">
|
259 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo ahc_search_engines_statistics ?></h2>
|
260 |
+
<div class="panelcontent" style="width:100% !important">
|
261 |
+
<table width="95%" border="0" cellspacing="0" id="search_engine">
|
262 |
+
<thead>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
<tr>
|
264 |
+
<th width="40%">Engine</th>
|
265 |
+
<th width="30%">Total</th>
|
266 |
+
|
|
|
267 |
</tr>
|
268 |
+
</thead>
|
269 |
+
<tbody>
|
270 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
|
272 |
+
$alltimeSER = ahcfree_get_hits_search_engines_referers('alltime');
|
273 |
+
|
274 |
+
$tot_srch = 0;
|
275 |
+
if (is_array($alltimeSER)) {
|
276 |
+
foreach ($alltimeSER as $ser => $v) {
|
277 |
+
$tot_srch += $v;
|
278 |
+
$ser = (!empty($ser)) ? $ser : 'Other';
|
279 |
+
?>
|
280 |
+
<tr>
|
281 |
+
<td>
|
282 |
+
<div>
|
283 |
+
<span><b><?php echo esc_html($ser); ?></b></span>
|
284 |
+
</div>
|
285 |
+
</td>
|
286 |
+
<td class="values"><?php echo ahcfree_NumFormat(intval($v)); ?></td>
|
287 |
+
|
288 |
+
</tr>
|
289 |
+
<?php
|
290 |
+
}
|
291 |
+
}
|
292 |
+
?>
|
293 |
+
<tr>
|
294 |
+
<td><strong>Total </strong></td>
|
295 |
+
<td class="values"><strong id="today_search"><?php echo ahcfree_NumFormat(intval($tot_srch)); ?></strong></td>
|
296 |
+
|
297 |
+
</tr>
|
298 |
+
|
299 |
+
</tbody>
|
300 |
+
</table>
|
301 |
+
</div>
|
302 |
</div>
|
303 |
</div>
|
|
|
304 |
</div>
|
305 |
</div>
|
306 |
<div class="row">
|
307 |
+
<div class="col-lg-8">
|
308 |
<div class="panel" style="width:100% !important">
|
309 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">Recent visitors by IP<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span></h2>
|
310 |
+
<div class="search-panel <?php echo (isset($_POST['section']) && $_POST['section'] == "recent_visitor_by_ip") ? "open" : ''; ?>">
|
311 |
+
<form method="post" class="search_frm">
|
312 |
+
|
313 |
+
|
314 |
+
<?php
|
315 |
+
$r_from_dt = isset($_POST['r_from_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['r_from_dt']) : '';
|
316 |
+
$r_to_dt = isset($_POST['r_to_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['r_to_dt']) : '';
|
317 |
+
$ip_addr = isset($_POST['ip_addr']) ? ahc_free_sanitize_text_or_array_field($_POST['ip_addr']) : '';
|
318 |
+
?>
|
319 |
+
|
320 |
+
|
321 |
+
<label>Search: </label>
|
322 |
+
<input type="hidden" name="page" value="ahc_hits_counter_menu_free" />
|
323 |
+
<input type="hidden" name="section" value="recent_visitor_by_ip" />
|
324 |
+
<input type="text" readonly="readonly" placeholder="From Date" class="ahc_clear" name="r_from_dt" id="r_from_dt" autocomplete="off" value="<?php echo esc_attr($r_from_dt); ?>" />
|
325 |
+
<input type="text" readonly="readonly" placeholder="To Date" class="ahc_clear" name="r_to_dt" id="r_to_dt" autocomplete="off" value="<?php echo esc_attr($r_to_dt); ?>" />
|
326 |
+
<input type="text" name="ip_addr" id="ip_addr" placeholder="IP address" class="ahc_clear" value="<?php echo esc_attr($ip_addr); ?>" />
|
327 |
+
<input type="submit" class="button button-primary" />
|
328 |
+
<input type="button" class="button button-primary clear_form" value="Clear" />
|
329 |
+
</form>
|
330 |
+
</div>
|
331 |
<div class="panelcontent" style="width:100% !important">
|
332 |
|
333 |
|
334 |
<table width="95%" border="0" cellspacing="0" class="recentv" id="recent_visit_by_ip">
|
335 |
+
<thead>
|
336 |
+
<tr>
|
337 |
+
|
338 |
+
<th>IP Address</th>
|
339 |
+
<th>Location</th>
|
340 |
+
|
341 |
+
|
342 |
+
<th>Time</th>
|
343 |
+
</tr>
|
344 |
+
</thead>
|
345 |
+
|
346 |
+
|
347 |
+
<tbody>
|
348 |
+
|
349 |
+
</tbody>
|
350 |
+
|
351 |
+
|
352 |
</table>
|
353 |
+
|
354 |
|
355 |
</div>
|
356 |
</div>
|
357 |
</div>
|
358 |
<?php
|
359 |
+
|
360 |
+
$countries = array();
|
361 |
?>
|
362 |
<div class="col-lg-4">
|
363 |
<div class="panel" style="width:100% !important">
|
364 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">
|
365 |
+
<?php
|
366 |
+
if (isset($_POST['t_from_dt']) && $_POST['t_from_dt'] != '' && isset($_POST['section']) && $_POST['section'] == "traffic_index_country") {
|
367 |
+
echo "Traffic Index by Country";
|
368 |
+
} else {
|
369 |
+
echo "Today Traffic by Country ";
|
370 |
+
}
|
371 |
+
?>
|
372 |
+
<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span>
|
373 |
+
</h2>
|
374 |
+
|
|
|
|
|
|
|
375 |
<div class="panelcontent" style="width:100% !important">
|
376 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&box=true">
|
377 |
+
<img width="99%" src="<?php echo plugins_url('/images/today_traffic_by_country_pro.jpg', AHCFREE_PLUGIN_MAIN_FILE) ?>">
|
378 |
+
</a>
|
379 |
</div>
|
380 |
|
381 |
</div>
|
382 |
</div>
|
383 |
</div>
|
384 |
+
|
385 |
<div class="row">
|
386 |
<div class="col-lg-6">
|
387 |
<!-- browsers chart panel -->
|
388 |
<div class="panel" style="width:100% !important; overflow:hidden">
|
389 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo ahc_browsers ?></h2>
|
390 |
+
<div class="panelcontent" style="width:100% !important">
|
391 |
+
<div class="row">
|
392 |
+
<div class="col-lg-12">
|
393 |
+
<div id="brsPiechartContainer" style=" height: 400px;"></div>
|
394 |
+
</div>
|
395 |
+
|
396 |
+
|
397 |
+
|
398 |
+
</div>
|
399 |
+
</div>
|
400 |
+
</div>
|
401 |
</div>
|
402 |
<div class="col-lg-6">
|
403 |
<!-- search engines chart panel -->
|
404 |
+
|
405 |
+
|
406 |
+
<div class="panel" style="width:100% !important; overflow:hidden">
|
407 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">Search Engines</h2>
|
408 |
+
<div class="panelcontent" style="width:100% !important">
|
409 |
+
<div class="row">
|
410 |
+
<div class="col-lg-12">
|
411 |
+
<div id="srhEngBieChartContainer" style=" height: 400px;"></div>
|
412 |
+
</div>
|
413 |
+
|
414 |
+
|
415 |
+
|
416 |
+
</div>
|
417 |
+
</div>
|
418 |
+
</div>
|
419 |
+
|
420 |
+
|
421 |
+
|
422 |
+
|
423 |
</div>
|
424 |
</div>
|
425 |
+
|
426 |
+
|
427 |
<div class="row">
|
428 |
<?php
|
429 |
/*$countries_data = ahcfree_get_top_countries("","","","",true);*/
|
430 |
+
$countries_data = array();
|
431 |
if (isset($countries_data['data'])) {
|
432 |
$countries = $countries_data['data'];
|
433 |
} else {
|
436 |
?>
|
437 |
<div class="col-lg-6">
|
438 |
<div class="panel" style="width:100% !important">
|
439 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">Traffic by country (all time)</h2>
|
440 |
<div class="panelcontent" style="width:100% !important">
|
441 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&box=true">
|
442 |
+
<img width="99%" src="<?php echo esc_url(plugins_url('/images/traffic_by_country_pro.jpg', AHCFREE_PLUGIN_MAIN_FILE)); ?>">
|
443 |
+
</a>
|
444 |
</div>
|
445 |
+
</div>
|
446 |
+
|
447 |
+
</div>
|
448 |
+
|
449 |
<div class="col-lg-6">
|
450 |
+
<!-- Countries chart panel -->
|
451 |
<div class="panel" style="width:100% !important">
|
452 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">Top Referring Countries (all time)</h2>
|
453 |
+
|
454 |
+
<div class="panelcontent" style="width:100% !important">
|
455 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&box=true">
|
456 |
+
<img width="99%" src="<?php echo esc_url(plugins_url('/images/top_refferring_countries_pro.jpg', AHCFREE_PLUGIN_MAIN_FILE)); ?>">
|
457 |
+
</a>
|
458 |
+
</div>
|
459 |
+
|
460 |
</div>
|
461 |
+
|
462 |
</div>
|
463 |
</div>
|
464 |
+
<div class="row">
|
465 |
+
<div class="col-lg-6">
|
466 |
+
|
467 |
+
<div class="panel" style="width:100% !important">
|
468 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo ahc_refering_sites ?> (Top 20)<span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
469 |
+
<div class="panelcontent" style="width:100% !important">
|
470 |
+
<table width="95%" border="0" cellspacing="0" id="top_refering_sites">
|
471 |
+
<thead>
|
472 |
+
<tr>
|
473 |
+
<th width="70%"><?php echo ahc_site_name ?></th>
|
474 |
+
<th width="30%"><?php echo ahc_total_times ?></th>
|
475 |
+
</tr>
|
476 |
+
</thead>
|
477 |
+
<tbody>
|
478 |
+
<?php
|
479 |
+
$googlehits = 0;
|
480 |
+
|
481 |
+
$norecord = "";
|
482 |
+
$referingSites = ahcfree_get_top_refering_sites();
|
483 |
+
if (is_array($referingSites) && count($referingSites) > 0) {
|
484 |
+
foreach ($referingSites as $site) {
|
485 |
+
/*if (strpos($site['site_name'], 'google')) {
|
486 |
$googlehits += $site['total_hits'];
|
487 |
} else {
|
488 |
*/
|
489 |
|
490 |
+
str_replace('https://', '', $site['site_name']);
|
491 |
+
?>
|
492 |
+
<tr>
|
493 |
+
<td class="values"><?php echo esc_html($site['site_name']); ?> <a href="https://<?php echo str_replace('http://', '', esc_url($site['site_name'])) ?>" target="_blank"><img src="<?php echo esc_url(plugins_url('/images/openW.jpg', AHCFREE_PLUGIN_MAIN_FILE)) ?>" title="<?php echo esc_attr(ahc_view_referer) ?>"></a></td>
|
494 |
+
<td class="values"><?php echo intval($site['total_hits']); ?></td>
|
495 |
+
</tr>
|
496 |
+
|
497 |
+
<?php
|
498 |
+
//}
|
499 |
+
}
|
500 |
+
} else {
|
501 |
+
$norecord = 1;
|
502 |
+
}
|
503 |
+
?>
|
504 |
+
</tbody>
|
505 |
+
</table>
|
506 |
+
<?php
|
507 |
+
if ($norecord == "1") {
|
508 |
+
?>
|
509 |
+
<div class="no-record">No data available.</div>
|
510 |
+
<?php
|
511 |
+
}
|
512 |
+
?>
|
513 |
+
</div>
|
514 |
+
</div>
|
515 |
+
|
|
|
|
|
|
|
|
|
|
|
516 |
</div>
|
517 |
+
|
518 |
+
|
519 |
+
|
520 |
+
<div class="col-lg-6">
|
521 |
<!-- time visits graph begin -->
|
522 |
<?php
|
523 |
//$times = ahcfree_get_time_visits();
|
524 |
$times = array();
|
525 |
?>
|
526 |
<div class="panel" style="width:100% !important">
|
527 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important">Today's time graph<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span><span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
528 |
+
<div class="search-panel <?php echo (isset($_POST['section']) && $_POST['section'] == "visit_time") ? "open" : ''; ?>">
|
529 |
+
<form method="post" class="search_frm">
|
530 |
+
<?php
|
531 |
+
$vfrom_dt = isset($_POST['vfrom_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['vfrom_dt']) : '';
|
532 |
+
$vto_dt = isset($_POST['vto_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['vto_dt']) : '';
|
533 |
+
?>
|
534 |
+
|
535 |
+
<label>Search : </label>
|
536 |
+
<input type="hidden" name="page" value="ahc_hits_counter_menu_free" />
|
537 |
+
<input type="hidden" name="section" value="visit_time" />
|
538 |
+
<input type="text" readonly="readonly" placeholder="From Date" class="ahc_clear" name="vfrom_dt" id="vfrom_dt" autocomplete="off" value="<?php echo esc_attr($vfrom_dt); ?>" />
|
539 |
+
<input type="text" readonly="readonly" placeholder="To Date" class="ahc_clear" name="vto_dt" id="vto_dt" autocomplete="off" value="<?php echo esc_attr($vto_dt); ?>" />
|
540 |
+
<input type="submit" class="button button-primary" />
|
541 |
+
<input type="button" class="button button-primary clear_form" value="Clear" />
|
542 |
+
</form>
|
543 |
+
</div>
|
544 |
<div class="panelcontent" style="padding-right: 50px;">
|
545 |
<table width="100%" border="0" cellspacing="0" id="visit_time_graph_table">
|
546 |
+
<thead>
|
547 |
+
<tr>
|
548 |
+
<th width="25%"><?php echo ahc_time ?></th>
|
549 |
+
<th width="55%"><?php echo ahc_visitors_graph ?></th>
|
550 |
+
<th width="10%"><?php echo ahc_visitors ?></th>
|
551 |
+
<th width="10%">Visits</th>
|
552 |
+
</tr>
|
553 |
</thead>
|
554 |
<tbody>
|
555 |
+
<?php
|
556 |
+
if (is_array($times)) {
|
557 |
+
foreach ($times as $t) {
|
558 |
+
?>
|
559 |
+
<tr>
|
560 |
+
<td class="values"><?php echo esc_html($t['vtm_time_from']) . ' - ' . esc_html($t['vtm_time_to']) ?></td>
|
561 |
+
<td class="values">
|
562 |
+
<div class="visitorsGraphContainer">
|
563 |
+
<div class="<?php
|
564 |
+
if (ceil($t['percent']) > 25 && ceil($t['percent']) < 50) {
|
565 |
+
echo 'visitorsGraph2';
|
566 |
+
} else if (ceil($t['percent']) > 50) {
|
567 |
+
echo 'visitorsGraph3';
|
568 |
+
} else {
|
569 |
+
echo 'visitorsGraph';
|
570 |
+
}
|
571 |
+
?>" <?php echo (!empty($t['percent']) ? ' ** style="width: ' . ceil($t['percent']) . '%;"' : '') ?>> </div>
|
572 |
+
<div class="cleaner"></div>
|
573 |
+
</div>
|
574 |
+
<div class="visitorsPercent">(<?php echo ceil($t['percent']) ?>)%..</div>
|
575 |
+
</td>
|
576 |
+
<td class="values"><?php echo intval($t['vtm_visitors']); ?></td>
|
577 |
+
<td class="values"><?php echo intval($t['vtm_visits']); ?></td>
|
578 |
+
</tr>
|
579 |
+
<?php
|
580 |
+
}
|
581 |
}
|
582 |
+
?>
|
|
|
583 |
</tbody>
|
584 |
</table>
|
585 |
</div>
|
586 |
</div>
|
587 |
+
</div>
|
588 |
+
</div>
|
589 |
<div class="row">
|
590 |
<!-- traffic by title -->
|
591 |
<div class="col-lg-6">
|
592 |
<?php
|
593 |
/*$tTitles = ahcfree_get_traffic_by_title();*/
|
594 |
+
$tTitles = array();
|
595 |
?>
|
596 |
<div class="panel" style="width:100% !important">
|
597 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo traffic_by_title ?> (all time)<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span><span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
598 |
+
|
599 |
<div class="panelcontent" style="padding-right: 50px;">
|
600 |
<table width="100%" border="0" cellspacing="0" id="traffic_by_title">
|
601 |
+
<thead>
|
602 |
+
<tr>
|
603 |
+
<th width="5%"><?php echo ahc_rank ?></th>
|
604 |
+
<th width="65%"><?php echo ahc_title ?></th>
|
605 |
+
<th width="15%"><?php echo ahc_hits ?></th>
|
606 |
+
<th width="15%"><?php echo ahc_percent ?></th>
|
607 |
+
</tr>
|
608 |
</thead>
|
609 |
<tbody>
|
610 |
+
<?php
|
611 |
+
$norecord = "";
|
612 |
+
if (is_array($tTitles) && count($tTitles) > 0) {
|
613 |
+
foreach ($tTitles as $t) {
|
614 |
+
?>
|
615 |
+
<tr>
|
616 |
+
<td class="values"><?php echo intval($t['rank']) ?></td>
|
617 |
+
<td class="values"><a href="<?php echo esc_url(get_permalink($t['til_page_id'])); ?>" target="_blank"><?php echo esc_html($t['til_page_title']); ?></a></td>
|
618 |
+
<td class="values"><?php echo ahcfree_NumFormat(intval($t['til_hits'])); ?></td>
|
619 |
+
<td class="values"><?php echo esc_html($t['percent']) ?></td>
|
620 |
+
</tr>
|
621 |
+
<?php
|
622 |
+
}
|
623 |
+
}
|
624 |
+
|
625 |
+
?>
|
626 |
+
</tbody>
|
627 |
+
</table>
|
628 |
+
|
629 |
+
</div>
|
630 |
+
</div>
|
631 |
+
</div>
|
632 |
+
|
633 |
+
<div class="col-lg-6">
|
634 |
+
<?php
|
635 |
+
/*$lastSearchKeyWordsUsed = ahcfree_get_latest_search_key_words_used();*/
|
636 |
+
$lastSearchKeyWordsUsed = array();
|
637 |
+
/*if ($lastSearchKeyWordsUsed)
|
638 |
+
{*/
|
639 |
+
?>
|
640 |
+
<!-- last search key words used -->
|
641 |
+
<div class="panel" style="width:100% !important">
|
642 |
+
<h2 class="box-heading" style="border-radius: 7px 7px 0 0 !important; padding:12px 15px !important ; border-bottom:0 !important"><?php echo ahc_latest_search_words; ?> (all time)<span class="search_data"><a href="#" class="dashicons dashicons-search" title="Search"></a></span><span class="export_data"><a href="#" class="dashicons dashicons-external" title="Export Data"></a></span></h2>
|
643 |
+
<div class="search-panel <?php echo (isset($_POST['section']) && $_POST['section'] == "lastest_search") ? "open" : ''; ?>">
|
644 |
+
<form method="post" class="search_frm">
|
645 |
+
|
646 |
<?php
|
647 |
+
$from_dt = isset($_POST['from_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['from_dt']) : '';
|
648 |
+
$to_dt = isset($_POST['to_dt']) ? ahc_free_sanitize_text_or_array_field($_POST['to_dt']) : '';
|
649 |
+
|
650 |
+
?>
|
651 |
+
<label>Search in Time Frame: </label>
|
652 |
+
<input type="hidden" name="page" value="ahc_hits_counter_menu_free" />
|
653 |
+
<input type="hidden" name="section" value="lastest_search" />
|
654 |
+
<input type="text" readonly="readonly" placeholder="From Date" class="ahc_clear" name="from_dt" id="from_dt" autocomplete="off" value="<?php echo esc_attr($from_dt); ?>" />
|
655 |
+
<input type="text" readonly="readonly" placeholder="To Date" class="ahc_clear" name="to_dt" id="to_dt" autocomplete="off" value="<?php echo esc_attr($to_dt); ?>" />
|
656 |
+
<input type="submit" class="button button-primary" />
|
657 |
+
<input type="button" class="button button-primary clear_form" value="Clear" />
|
658 |
+
</form>
|
659 |
+
</div>
|
660 |
+
<div class="panelcontent" style="padding-right: 50px;">
|
661 |
+
<table width="100%" border="0" cellspacing="0" id="lasest_search_words">
|
662 |
+
<thead>
|
663 |
+
<tr>
|
664 |
+
<th width="20%">Country</th>
|
665 |
+
<th width="30%">Info.</th>
|
666 |
+
<th width="40%">Keyword</th>
|
667 |
+
<th width="10%" class='text-center'>Date</th>
|
668 |
+
</tr>
|
669 |
+
</thead>
|
670 |
+
|
671 |
+
|
672 |
+
<?php
|
673 |
+
if (count($lastSearchKeyWordsUsed) > 0) {
|
674 |
+
?>
|
675 |
+
<tbody>
|
676 |
+
<?php
|
677 |
+
foreach ($lastSearchKeyWordsUsed as $searchWord) {
|
678 |
+
$visitDate = new DateTime($searchWord['hit_date']);
|
679 |
+
$visitDate->setTimezone($custom_timezone);
|
680 |
?>
|
681 |
+
<tr>
|
682 |
+
<td>
|
683 |
+
<span><?php if ($searchWord['ctr_internet_code'] != '') { ?><img src="<?php echo plugins_url('/images/flags/' . strtolower($searchWord['ctr_internet_code']) . '.png', AHCFREE_PLUGIN_MAIN_FILE); ?>" border="0" width="22" height="18" title="<?php echo esc_html($searchWord['ctr_name']) ?>" onerror="imgFlagError(this)" /><?php } ?></span>
|
684 |
+
</td>
|
685 |
+
<td class="hide"><?php echo esc_html($searchWord['csb']); ?></td>
|
686 |
+
<td>
|
687 |
+
<span class="searchKeyWords"><a href="<?php echo esc_url($searchWord['hit_referer']); ?>" target="_blank"><?php echo esc_html($searchWord['hit_search_words']) ?></a></span>
|
688 |
+
</td>
|
689 |
+
<td>
|
690 |
+
<span class="visitDateTime"> <?php echo esc_html($visitDate->format('d/m/Y')); ?></span>
|
691 |
+
</td>
|
692 |
+
</tr>
|
693 |
<?php
|
694 |
+
}
|
695 |
+
?>
|
696 |
+
</tbody>
|
697 |
+
<?php
|
698 |
}
|
699 |
+
|
700 |
?>
|
|
|
701 |
</table>
|
|
|
702 |
</div>
|
703 |
</div>
|
704 |
+
|
705 |
+
<?php /*}*/ ?>
|
706 |
+
</div>
|
707 |
+
</div>
|
708 |
+
<div class="row">
|
709 |
+
<div class="col-12">
|
710 |
+
<div class="panel" style="background-color: #fff; border-radius:7px ; padding:20px 10px 10px 10px">
|
711 |
+
<center>
|
712 |
+
<a target="_blank" href="https://www.wp-buy.com/product/visitors-traffic-real-time-statistics-pro/?attribute_license=Single%20License%2029$&footer=true">
|
713 |
+
<p style="color:#00F; font-size:15px;">if you need more statistics you can upgrade to the professional version now, The premium version of Visitor Traffic real-time statistics is completely different from the free version as there are a lot more features included.</p>
|
714 |
+
|
715 |
+
<p><img height="auto" src="<?php echo esc_url(plugins_url('/images/upgradenow-button.png', AHCFREE_PLUGIN_MAIN_FILE)); ?>" /></p>
|
716 |
+
</a>
|
717 |
+
</center>
|
718 |
+
</div>
|
719 |
+
|
720 |
+
|
721 |
+
</div>
|
722 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
723 |
<?php
|
724 |
+
$visits_visitors_data = ahcfree_get_visits_by_custom_duration_callback($mystart_date, $myend_date, $stat = '');
|
725 |
?>
|
726 |
+
|
727 |
+
|
728 |
+
<?php
|
729 |
+
wp_register_script('ahc_gstatic_js', 'https://www.gstatic.com/charts/loader.js', array(), '1.0.0', true);
|
730 |
wp_enqueue_script('ahc_gstatic_js');
|
731 |
+
?>
|
732 |
<script language="javascript" type="text/javascript">
|
733 |
+
function drawVisitsLineChart(start_date, end_date, interval, visitors, visits, duration) {
|
734 |
+
|
735 |
+
|
736 |
+
|
737 |
+
google.charts.load('current', {
|
738 |
+
'packages': ['line']
|
739 |
+
});
|
740 |
+
google.charts.setOnLoadCallback(drawChart);
|
741 |
+
|
742 |
+
|
743 |
+
var dataRows = [
|
744 |
+
['Date', 'Visitors', 'Page Views']
|
745 |
+
];
|
746 |
+
for (var i = 0; i < visitors.length; i++) {
|
747 |
+
//alert(visitors[i][1]);
|
748 |
+
dataRows.push([visitors[i][0], parseFloat(visitors[i][1]), parseFloat(visits[i][1])]);
|
749 |
+
}
|
750 |
+
|
751 |
+
|
752 |
+
function drawChart() {
|
753 |
+
var data = google.visualization.arrayToDataTable(dataRows);
|
754 |
+
|
755 |
+
var options = {
|
756 |
+
title: 'Traffic Report',
|
757 |
+
|
758 |
+
curveType: 'none',
|
759 |
+
legend: {
|
760 |
+
position: 'top',
|
761 |
+
textStyle: {
|
762 |
+
color: 'blue',
|
763 |
+
fontSize: 16
|
764 |
+
}
|
765 |
+
}
|
766 |
+
};
|
767 |
+
|
768 |
+
var chart = new google.charts.Line(document.getElementById('visitscount'));
|
769 |
+
|
770 |
+
chart.draw(data, options);
|
771 |
+
}
|
772 |
+
|
773 |
+
|
774 |
+
|
775 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
776 |
}
|
777 |
+
|
778 |
+
function drawBrowsersPieChart() {
|
779 |
+
|
780 |
+
|
781 |
+
google.charts.load('current', {
|
782 |
+
'packages': ['corechart']
|
783 |
+
});
|
784 |
+
google.charts.setOnLoadCallback(drawChart);
|
785 |
+
|
786 |
+
function drawChart() {
|
787 |
+
|
788 |
+
var data = new google.visualization.DataTable();
|
789 |
+
data.addColumn('string', 'Browser');
|
790 |
+
data.addColumn('number', 'Hits');
|
791 |
+
data.addRows([
|
792 |
+
|
793 |
+
<?php echo ahcfree_get_browsers_hits_counts(); ?>
|
794 |
+
]);
|
795 |
+
|
796 |
+
var options = {
|
797 |
+
title: '',
|
798 |
+
slices: {
|
799 |
+
4: {
|
800 |
+
offset: 0.2
|
801 |
+
},
|
802 |
+
12: {
|
803 |
+
offset: 0.3
|
804 |
+
},
|
805 |
+
14: {
|
806 |
+
offset: 0.4
|
807 |
+
},
|
808 |
+
15: {
|
809 |
+
offset: 0.5
|
810 |
+
},
|
811 |
+
},
|
812 |
+
};
|
813 |
+
|
814 |
+
var chart = new google.visualization.PieChart(document.getElementById('brsPiechartContainer'));
|
815 |
+
chart.draw(data, options);
|
816 |
+
}
|
817 |
+
|
818 |
+
|
819 |
+
|
820 |
+
}
|
821 |
+
|
822 |
+
function drawSrhEngVstLineChart() {
|
823 |
+
|
824 |
+
|
825 |
+
google.charts.load('current', {
|
826 |
+
'packages': ['corechart']
|
827 |
+
});
|
828 |
+
google.charts.setOnLoadCallback(drawChart);
|
829 |
+
|
830 |
+
function drawChart() {
|
831 |
+
|
832 |
+
var data = new google.visualization.DataTable();
|
833 |
+
data.addColumn('string', 'Browser');
|
834 |
+
data.addColumn('number', 'Hits');
|
835 |
+
data.addRows([
|
836 |
+
|
837 |
+
<?php echo ahcfree_get_serch_visits_by_date(); ?>
|
838 |
+
]);
|
839 |
+
|
840 |
+
var options = {
|
841 |
+
title: '',
|
842 |
+
slices: {
|
843 |
+
4: {
|
844 |
+
offset: 0.2
|
845 |
+
},
|
846 |
+
12: {
|
847 |
+
offset: 0.3
|
848 |
+
},
|
849 |
+
14: {
|
850 |
+
offset: 0.4
|
851 |
+
},
|
852 |
+
15: {
|
853 |
+
offset: 0.5
|
854 |
+
},
|
855 |
+
},
|
856 |
+
};
|
857 |
+
|
858 |
+
var chart = new google.visualization.PieChart(document.getElementById('srhEngBieChartContainer'));
|
859 |
+
chart.draw(data, options);
|
860 |
+
}
|
861 |
+
|
862 |
+
|
863 |
+
|
864 |
}
|
865 |
+
|
866 |
+
var mystart_date = "<?php echo esc_js($mystart_date); ?>";
|
867 |
var myend_date = "<?php echo esc_js($myend_date); ?>";
|
868 |
+
var mystart_date_full = "<?php echo esc_js($mystart_date_full); ?>";
|
869 |
var myend_date_full = "<?php echo esc_js($myend_date_full); ?>";
|
870 |
+
|
871 |
+
|
872 |
+
var countriesData = <?php echo json_encode(ahcfree_get_top_countries(10, "", "", "", false)); ?>;
|
873 |
+
var visits_data = <?php echo json_encode($visits_visitors_data['visits']); ?>;
|
874 |
+
var visitors_data = <?php echo json_encode($visits_visitors_data['visitors']); ?>;
|
875 |
//console.log(visits_data);
|
876 |
+
// console.log(visitors_data);
|
877 |
+
jQuery(document).ready(function() {
|
878 |
+
jQuery('#duration_area').hide();
|
879 |
+
|
880 |
//------------------------------------------
|
881 |
//if(visitsData.success && typeof visitsData.data != 'undefined'){
|
882 |
+
var duration = jQuery('#hits-duration').val();
|
883 |
+
drawVisitsLineChart(mystart_date, myend_date, '1 day', visitors_data, visits_data, duration);
|
884 |
//}
|
885 |
//------------------------------------------
|
886 |
+
|
887 |
+
|
888 |
+
|
889 |
if (typeof drawBrowsersPieChart === "function") {
|
890 |
+
|
891 |
drawBrowsersPieChart();
|
892 |
}
|
893 |
//------------------------------------------
|
894 |
if (typeof drawSrhEngVstLineChart === "function") {
|
895 |
drawSrhEngVstLineChart();
|
896 |
}
|
897 |
+
|
898 |
|
899 |
});
|
900 |
+
|
901 |
+
jQuery(document).on('change', '#hits-duration', function() {
|
902 |
+
|
903 |
+
|
904 |
var self = jQuery(this);
|
905 |
var duration = self.val();
|
906 |
+
if (duration == 'range') {
|
907 |
+
jQuery('#duration_area').show();
|
908 |
+
|
909 |
+
} else {
|
910 |
+
jQuery('#duration_area').hide();
|
911 |
+
|
912 |
+
jQuery('#visitors_graph_stats').addClass('loader');
|
913 |
+
jQuery.ajax({
|
914 |
+
url: ahc_ajax.ajax_url,
|
915 |
+
data: {
|
916 |
+
action: 'ahcfree_get_hits_by_custom_duration',
|
917 |
+
'hits_duration': duration
|
918 |
+
},
|
919 |
+
method: 'post',
|
920 |
+
success: function(res) {
|
921 |
+
if (res) {
|
922 |
+
var data = jQuery.parseJSON(res);
|
923 |
+
|
924 |
+
var start_date = data.mystart_date;
|
925 |
+
var end_date = data.myend_date;
|
926 |
+
var full_start_date = data.full_start_date;
|
927 |
+
var full_end_date = data.full_end_date;
|
928 |
+
var interval = data.interval;
|
929 |
+
var visitors = JSON.parse(data.visitors_data);
|
930 |
+
var visits = JSON.parse(data.visits_data);
|
931 |
+
|
932 |
+
drawVisitsLineChart(start_date, end_date, interval, visitors, visits, duration);
|
933 |
+
jQuery('#visitors_graph_stats').removeClass('loader');
|
934 |
+
return false;
|
935 |
+
}
|
936 |
+
}
|
937 |
+
});
|
938 |
+
}
|
|
|
939 |
});
|
940 |
+
|
941 |
+
jQuery(document).on('change', '#summary_from_dt, #summary_to_dt', function() {
|
942 |
var self = jQuery(this);
|
943 |
+
var duration = jQuery('#summary_from_dt').val() + '#' + self.val();
|
944 |
+
|
945 |
+
if (jQuery('#summary_to_dt').val() != '') {
|
946 |
+
jQuery('#visitors_graph_stats').addClass('loader');
|
947 |
+
|
948 |
+
jQuery.ajax({
|
949 |
+
url: ahc_ajax.ajax_url,
|
950 |
+
data: {
|
951 |
+
action: 'ahcfree_get_hits_by_custom_duration',
|
952 |
+
'hits_duration_from': jQuery('#summary_from_dt').val(),
|
953 |
+
'hits_duration_to': jQuery('#summary_to_dt').val(),
|
954 |
+
'hits_duration': 'range'
|
955 |
+
},
|
956 |
+
method: 'post',
|
957 |
+
success: function(res) {
|
958 |
+
if (res) {
|
959 |
+
var data = jQuery.parseJSON(res);
|
960 |
+
//console.log(data);
|
961 |
+
var start_date = data.full_start_date;
|
962 |
+
var end_date = data.full_end_date;
|
963 |
+
var full_start_date = data.full_start_date;
|
964 |
+
var full_end_date = data.full_end_date;
|
965 |
+
var interval = data.interval;
|
966 |
+
var visitors = JSON.parse(data.visitors_data);
|
967 |
+
var visits = JSON.parse(data.visits_data);
|
968 |
+
// console.log(visitors);
|
969 |
+
// console.log(visits);
|
970 |
+
drawVisitsLineChart(start_date, end_date, interval, visitors, visits, 'range');
|
971 |
+
jQuery('#visitors_graph_stats').removeClass('loader');
|
972 |
+
return false;
|
973 |
+
}
|
974 |
+
}
|
975 |
+
});
|
976 |
+
}
|
|
|
977 |
});
|
978 |
|
979 |
+
document.getElementById('today_visitors_box').innerHTML = (document.getElementById('today_visitors').innerHTML);
|
980 |
//document.getElementById('today_visitors_detail_cnt').innerHTML = (document.getElementById('today_visitors').innerHTML);
|
981 |
document.getElementById('today_visits_box').innerHTML = (document.getElementById('today_visits').innerHTML);
|
982 |
document.getElementById('today_search_box').innerHTML = (document.getElementById('today_search').innerHTML);
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: wp-buy, osamaesh
|
3 |
Tags: visitor, traffic, statistics, analytics, stats, online, Visit, WordPress analytics ,visitors online, count visitor, google analytics, analytics, GeoIP, Geo locations, analytics dashboard, visits, chart, browser, blog, today, yesterday, week, month, wp Statistics, year, post, page, sidebar, summary, feedburner, hits, pagerank, google, histats, alexa, live visit, counter, diagram, graph
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -150,11 +150,18 @@ This plugin supports IPv6; however, PHP must be compiled with IPv6 support enabl
|
|
150 |
|
151 |
== Changelog ==
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
= 4.6 =
|
154 |
1. Bug fixing in menu
|
155 |
|
156 |
|
157 |
-
|
158 |
= 4.5 =
|
159 |
1. Bug fixing in IP execlusion
|
160 |
|
2 |
Contributors: wp-buy, osamaesh
|
3 |
Tags: visitor, traffic, statistics, analytics, stats, online, Visit, WordPress analytics ,visitors online, count visitor, google analytics, analytics, GeoIP, Geo locations, analytics dashboard, visits, chart, browser, blog, today, yesterday, week, month, wp Statistics, year, post, page, sidebar, summary, feedburner, hits, pagerank, google, histats, alexa, live visit, counter, diagram, graph
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 5.9.1
|
6 |
+
Stable tag: 4.8
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
150 |
|
151 |
== Changelog ==
|
152 |
|
153 |
+
= 4.8 =
|
154 |
+
1. new feature, User Role Exclusion From Statistics
|
155 |
+
|
156 |
+
|
157 |
+
= 4.7 =
|
158 |
+
1. interface enehancment
|
159 |
+
|
160 |
+
|
161 |
= 4.6 =
|
162 |
1. Bug fixing in menu
|
163 |
|
164 |
|
|
|
165 |
= 4.5 =
|
166 |
1. Bug fixing in IP execlusion
|
167 |
|