Google Analytics Counter Tracker - Version 1.0.2

Version Description

Download this release

Release Info

Developer Analytics Counter
Plugin Icon 128x128 Google Analytics Counter Tracker
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.2

analytics-counter.php CHANGED
@@ -1,41 +1,46 @@
1
- <?php
2
- /*
3
- Plugin Name: Google Analytics Counter Tracker
4
-
5
- Description: Google analytics counter tracker - analyse the visitors hits on you website and display it graphically
6
- Version: 1.0.0
7
- Author: WPAdm
8
- Author URI: http://www.wpadm.com
9
- Plugin URI: http://www.wpadm.com
10
- License: GPLv2 or later
11
- */
12
-
13
- define( 'WPADM_GA__VIEW_TITLE', 'Analytics Counter');
14
- define( 'WPADM_GA__PLUGIN_NAME', basename(dirname(__FILE__)) );
15
-
16
- define( 'WPADM_GA__MENU_PREFIX', 'wpadm-ga-menu-' );
17
- define( 'WPADM_GA__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
18
- define( 'WPADM_GA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
19
- define( 'WPADM_GA__VIEW_DIR', plugin_dir_path( __FILE__ ) . 'view' . DIRECTORY_SEPARATOR );
20
- define( 'WPADM_GA__VIEW_LAYOUT', WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'layout.php');
21
-
22
- define( 'WPADM_GA__DB_VERSION', 1);
23
-
24
- add_action('init', array( 'Wpadm_GA', 'init'));
25
- add_action('admin_menu', array( 'Wpadm_GA', 'generateMenu'));
26
-
27
- register_activation_hook(__FILE__, array( 'Wpadm_GA', 'plugin_activation'));
28
- register_deactivation_hook(__FILE__, array( 'Wpadm_GA', 'plugin_deactivation'));
29
-
30
- register_uninstall_hook(__FILE__, array( 'Wpadm_GA', 'plugin_uninstall'));
31
-
32
- add_action( 'admin_enqueue_scripts', array( 'Wpadm_GA', 'registerPluginScripts') );
33
-
34
- add_action('wp_footer', array('Wpadm_GA', 'generateGACodeOnSite'));
35
-
36
- add_action( 'wp_ajax_getCache', array('Wpadm_GA_Cache', 'getCache') );
37
- add_action( 'wp_ajax_setCache', array('Wpadm_GA_Cache', 'setCache') );
38
-
39
-
40
- require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga.php' );
41
-
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Google Analytics Counter Tracker
4
+
5
+ Description: Google analytics counter tracker - analyse the visitors hits on you website and display it graphically
6
+ Version: 1.0.2
7
+ Author: WPAdm
8
+ Author URI: http://www.wpadm.com
9
+ Plugin URI: http://www.wpadm.com
10
+ License: GPLv2 or later
11
+ */
12
+
13
+ define( 'WPADM_GA__VIEW_TITLE', 'Analytics Counter');
14
+ define( 'WPADM_GA__PLUGIN_NAME', basename(dirname(__FILE__)) );
15
+
16
+ define( 'WPADM_GA__MENU_PREFIX', 'wpadm-ga-menu-' );
17
+ define( 'WPADM_GA__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
18
+ define( 'WPADM_GA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
19
+ define( 'WPADM_GA__VIEW_DIR', plugin_dir_path( __FILE__ ) . 'view' . DIRECTORY_SEPARATOR );
20
+ define( 'WPADM_GA__VIEW_LAYOUT', WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'layout.php');
21
+
22
+ define( 'WPADM_GA__DB_VERSION', 1);
23
+
24
+ add_action('init', array( 'Wpadm_GA', 'init'));
25
+ add_action('admin_menu', array( 'Wpadm_GA', 'generateMenu'));
26
+
27
+ register_activation_hook(__FILE__, array( 'Wpadm_GA', 'plugin_activation'));
28
+ register_deactivation_hook(__FILE__, array( 'Wpadm_GA', 'plugin_deactivation'));
29
+
30
+ register_uninstall_hook(__FILE__, array( 'Wpadm_GA', 'plugin_uninstall'));
31
+
32
+ add_action( 'admin_enqueue_scripts', array( 'Wpadm_GA', 'registerPluginScripts') );
33
+
34
+ add_action('wp_footer', array('Wpadm_GA', 'generateGACodeOnSite'));
35
+
36
+ add_action( 'wp_ajax_getCache', array('Wpadm_GA_Cache', 'getCache') );
37
+
38
+ add_action( 'wp_ajax_setCache', array('Wpadm_GA', 'setDtStartWork') );
39
+ add_action( 'wp_ajax_setCache', array('Wpadm_GA_Cache', 'setCache') );
40
+
41
+ add_action( 'wp_ajax_sendSupport', array('Wpadm_GA', 'sendSupport') );
42
+
43
+ add_action( 'wp_ajax_stopNotice5Stars', array('Wpadm_GA', 'stopNotice5Stars') );
44
+
45
+ require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga.php' );
46
+
class.wpadm-ga-options.php CHANGED
@@ -15,6 +15,8 @@ class WPAdm_GA_Options
15
  protected $ga_typeCode = '';
16
 
17
  protected $wpadmin_token = null;
 
 
18
 
19
 
20
  /**
@@ -34,6 +36,8 @@ class WPAdm_GA_Options
34
  $this->ga_enableCode = (isset($wpadm_ga['ga_enableCode'])) ? $wpadm_ga['ga_enableCode'] : null;
35
  $this->ga_typeCode = self::TYPE_CODE_UNIVERSAL;
36
  }
 
 
37
  }
38
 
39
  protected static function getInstance() {
15
  protected $ga_typeCode = '';
16
 
17
  protected $wpadmin_token = null;
18
+
19
+ protected $dt_install = '';
20
 
21
 
22
  /**
36
  $this->ga_enableCode = (isset($wpadm_ga['ga_enableCode'])) ? $wpadm_ga['ga_enableCode'] : null;
37
  $this->ga_typeCode = self::TYPE_CODE_UNIVERSAL;
38
  }
39
+
40
+
41
  }
42
 
43
  protected static function getInstance() {
class.wpadm-ga.php CHANGED
@@ -1,468 +1,548 @@
1
- <?php
2
-
3
- class WPAdm_GA
4
- {
5
- const URL_GA_SERVER = 'http://secure.wpadm.com/ga/';
6
- const URL_GA_AUTH = 'http://secure.wpadm.com/ga.php';
7
- const URL_GA_PUB_KEY = 'http://secure.wpadm.com/ga/getPubKey';
8
-
9
- const REQUEST_PARAM_NAME = 'wpadm_ga_request';
10
-
11
- public function visitView() {
12
-
13
- WPAdm_GA_View::$subtitle = 'Audience Overview';
14
-
15
- if($template = self::getErrorTemplate()) {
16
- WPAdm_GA_View::$content_file = $template;
17
- } else {
18
- if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
19
- ob_clean();
20
- $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
21
- // wp_redirect($localion);
22
- header("Location: $location");
23
- }
24
- WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'visit.php';
25
- }
26
- require WPADM_GA__VIEW_LAYOUT;
27
- }
28
-
29
-
30
-
31
- public function usersView() {
32
- WPAdm_GA_View::$subtitle = 'Visitors Overview';
33
-
34
- if($template = self::getErrorTemplate()) {
35
- WPAdm_GA_View::$content_file = $template;
36
- } else {
37
- if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
38
- ob_clean();
39
- $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
40
- header("Location: $location");
41
- }
42
- WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'users.php';
43
- }
44
- require WPADM_GA__VIEW_LAYOUT;
45
- }
46
-
47
- public function sourceView() {
48
- WPAdm_GA_View::$subtitle = 'Source stat';
49
- WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'source.php';
50
- require WPADM_GA__VIEW_LAYOUT;
51
- }
52
-
53
- public function settingsView() {
54
- WPAdm_GA_View::$subtitle = 'settings';
55
-
56
- if($template = self::getErrorTemplate()) {
57
- WPAdm_GA_View::$content_file = $template;
58
- } else {
59
- if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
60
- ob_clean();
61
- $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
62
- header("Location: $location");
63
- }
64
- WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'settings.php';
65
- }
66
-
67
-
68
-
69
- //GA Account
70
- $ga_accout_form = new wpadmForm();
71
- $ga_accout_form->setValue('ga-id', WPAdm_GA_Options::getGAId());
72
- $ga_accout_form->setValue('ga-webPropertyId', WPAdm_GA_Options::getGAWebPropertyId());
73
- $ga_accout_form->setValue('ga-url', WPAdm_GA_Options::getGAUrl());
74
- $ga_accout_form->setValue('ga-enableCode', WPAdm_GA_Options::getGAEnableCode());
75
-
76
- if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
77
- && isset($_POST['form_name'])
78
- && 'ga-account' == $_POST['form_name']
79
- ) {
80
- $id = filter_input(INPUT_POST, 'ga-id', FILTER_SANITIZE_NUMBER_INT);
81
- $url = filter_input(INPUT_POST, 'ga-url', FILTER_SANITIZE_URL);
82
- $webPropertyId = filter_input(INPUT_POST, 'ga-webPropertyId', FILTER_SANITIZE_STRING);
83
- $enableCode = (int)filter_input(INPUT_POST, 'ga-enableCode', FILTER_SANITIZE_NUMBER_INT);
84
- $enableCode = ($enableCode) ? 1 : 0;
85
-
86
- WPAdm_GA_Options::setGAId($id);
87
- WPAdm_GA_Options::setGAUrl($url);
88
- WPAdm_GA_Options::setGAWebPropertyId($webPropertyId);
89
- WPAdm_GA_Options::setGAEnableCode($enableCode);
90
-
91
- $ga_accout_form->setValue('ga-id', $id);
92
- $ga_accout_form->setValue('ga-webPropertyId', $webPropertyId);
93
- $ga_accout_form->setValue('ga-enableCode', $enableCode);
94
-
95
- //redirect to stat
96
- ob_clean();
97
-
98
- if (isset($_GET['modal'])) {
99
- echo '<script> top.frames.location.reload(false);</script>';
100
- } else {
101
- $location = admin_url() . 'options-general.php?page=wpadm-ga-menu-visit';
102
- header("Location: $location");
103
- }
104
- exit;
105
- }
106
-
107
-
108
-
109
- // $wpadm_account_form = new wpadmAuthForm();
110
-
111
- // if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
112
- // && isset($_POST['form_name'])
113
- // && 'wpadm-account' == $_POST['form_name']
114
- // ) {
115
- // $form_data = array(
116
- // 'wpadm_username' => $_POST['wpadm_username'],
117
- // 'wpadm_password' => $_POST['wpadm_password'],
118
- // 'wpadm_password_confirm' => $_POST['wpadm_password_confirm'],
119
- // 'wpadm_imnewuser_checkbox' => (isset($_POST['wpadm_imnewuser_checkbox'])&& $_POST['wpadm_imnewuser_checkbox'] == 1) ? 1 :0
120
- // );
121
- // $wpadm_account_form->setData($form_data);
122
- //
123
- // if ($wpadm_account_form->isValid()) {
124
- //
125
- // WPAdm_GA_Api::register();
126
- // echo 'doit';
127
- // exit;
128
- // }
129
- // }
130
-
131
-
132
-
133
- // if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
134
- // && isset($_POST['form_name'])
135
- // && 'ga-account-logout' == $_POST['form_name']
136
- // ) {
137
- //
138
- // $url = get_option('siteurl');
139
- // $p_url = parse_url($url);
140
- // $postdata = array(
141
- // 'host' => $p_url['host'],
142
- // );
143
- //
144
- // $response = wp_remote_post(self::URL_GA_SERVER . 'logout', array(
145
- // 'method' => 'POST',
146
- // 'timeout' => 45,
147
- // 'body' => self::getParamsForRequest($postdata)
148
- // ));
149
- //
150
- // if ( is_wp_error( $response ) ) {
151
- // //todo: отработать исключение
152
- // $error_message = $response->get_error_message();
153
- // echo "Something went wrong: $error_message";
154
- // } else {
155
- //
156
- // }
157
- //
158
- // echo '<!-- start dump --><pre><small>' . __FILE__ . "</small>\n";
159
- // print_r($response['body']);
160
- // echo '</pre><!-- end dump -->';
161
- // exit;
162
- //
163
- //
164
- // }
165
-
166
-
167
-
168
- require WPADM_GA__VIEW_LAYOUT;
169
- }
170
-
171
-
172
- public static function plugin_activation() {
173
- //get pub key
174
- $response = wp_remote_post(self::URL_GA_PUB_KEY, array(
175
- 'method' => 'POST',
176
- 'timeout' => 45,
177
- 'body' => array('refer'=>site_url())
178
- ));
179
-
180
- if ( is_wp_error( $response ) ) {
181
- ////
182
- $error_message = $response->get_error_message();
183
- } else {
184
- preg_match("|(-----BEGIN PUBLIC KEY-----.*-----END PUBLIC KEY-----)|Uis", $response['body'], $m);
185
- if (isset($m[1]) && !empty($m[1])) {
186
- update_option('wpadm_ga_pub_key', $m[1]);
187
- }
188
- }
189
-
190
- self::cron_activation();
191
- }
192
-
193
- public static function plugin_deactivation() {
194
- delete_option('wpadm_ga_pub_key');
195
- delete_option('wpadm_ga');
196
- self::cron_deactivation();
197
- //todo: delete cahce table
198
- }
199
-
200
- public static function cron_activation() {
201
- add_action('wpadm_ga_cache_clear', array('Wpadm_GA_Cache', 'cronRemoveExpiredCache'));
202
- wp_clear_scheduled_hook('wpadm_ga_cache_clear');
203
- wp_schedule_event(time(), 'daily', 'wpadm_ga_cache_clear');
204
- }
205
-
206
- public static function cron_deactivation() {
207
- wp_clear_scheduled_hook('wpadm_ga_cache_clear');
208
- }
209
-
210
-
211
- public static function init() {
212
- ob_start();
213
- self::requireFiles();
214
- self::checkDB();
215
- $request_name = self::REQUEST_PARAM_NAME;
216
- if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
217
- self::proccessRequest();
218
- }
219
-
220
-
221
- }
222
-
223
- protected static function proccessRequest() {
224
- $request_name = self::REQUEST_PARAM_NAME;
225
- $params = unserialize(base64_decode($_POST[$request_name]));
226
-
227
- $v = self::verifySignature($params['sign'], get_option('wpadm_ga_pub_key'), md5(serialize($params['data'])));
228
-
229
- $request = $params['data'];
230
-
231
- if($v && isset($request['action'])) {
232
- switch($request['action']) {
233
- case 'access_token':
234
- WPAdm_GA_Options::setGAAccessToken($request['data']['access_token']);
235
- WPAdm_GA_Options::setGAExpiresIn($request['data']['expires_in']);
236
- WPAdm_GA_Options::setGACreated($request['data']['created']);
237
-
238
- $ga_id = WPAdm_GA_Options::getGAId();
239
- if (isset($request['data']['property']) && empty($ga_id)
240
- && isset($request['data']['property']['ga_id']) && !empty($request['data']['property']['ga_id'])
241
- && isset($request['data']['property']['ga_url']) && !empty($request['data']['property']['ga_url'])
242
- && isset($request['data']['property']['ga_webPropertyId']) && !empty($request['data']['property']['ga_webPropertyId'])
243
- ) {
244
- WPAdm_GA_Options::setGAUrl($request['data']['property']['ga_url']);
245
- WPAdm_GA_Options::setGAId($request['data']['property']['ga_id']);
246
- WPAdm_GA_Options::setGAWebPropertyId($request['data']['property']['ga_webPropertyId']);
247
- }
248
-
249
- header("HTTP/1.0 201 Created");
250
- break;
251
- }
252
- }
253
- exit;
254
- }
255
-
256
-
257
-
258
- protected static function requireFiles() {
259
- require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-options.php' );
260
- require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-view.php' );
261
- require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-cache.php' );
262
-
263
- require_once( WPADM_GA__PLUGIN_DIR . 'form'.DIRECTORY_SEPARATOR.'wpadmForm.php' );
264
- require_once( WPADM_GA__PLUGIN_DIR . 'form'.DIRECTORY_SEPARATOR.'wpadmAuthForm.php' );
265
-
266
-
267
- }
268
-
269
- public static function registerPluginStyles() {
270
- wp_register_style( 'wpadm-ga-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.css' ) );
271
- wp_enqueue_style( 'wpadm-ga-css' );
272
-
273
- wp_register_style( 'wpadm-daterangepicker-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/daterangepicker/daterangepicker.css' ) );
274
- wp_enqueue_style( 'wpadm-daterangepicker-css' );
275
-
276
- }
277
-
278
- public static function registerPluginScripts() {
279
- wp_register_script( 'wpadm-ga-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.js' ) );
280
- wp_enqueue_script( 'wpadm-ga-js' );
281
-
282
- wp_register_script( 'wpadm-moment-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/moment.min.js' ) );
283
- wp_enqueue_script( 'wpadm-moment-js' );
284
-
285
- wp_register_script( 'wpadm-daterangepicker-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/daterangepicker/daterangepicker.js' ) );
286
- wp_enqueue_script( 'wpadm-daterangepicker-js' );
287
- }
288
-
289
- public static function generateMenu() {
290
- $pages = array();
291
-
292
- $menu_position = '1.9998887770';
293
- $pages[] = add_menu_page(
294
- 'Analytics Counter',
295
- 'Analytics Counter',
296
- 'read',
297
- WPADM_GA__MENU_PREFIX . 'visit',
298
- array('Wpadm_GA', 'visitView'),
299
- plugins_url('/view/img/icon.png',__FILE__),
300
- $menu_position
301
- );
302
- $pages[] = add_submenu_page(
303
- WPADM_GA__MENU_PREFIX . 'visit',
304
- 'Audience overview',
305
- 'Audience overview',
306
- 'read',
307
- WPADM_GA__MENU_PREFIX . 'visit',
308
- array('Wpadm_GA', 'visitView')
309
- );
310
-
311
-
312
- $pages[] = add_submenu_page(
313
- WPADM_GA__MENU_PREFIX . 'visit',
314
- 'Visitors overview',
315
- 'Visitors overview',
316
- 'read',
317
- WPADM_GA__MENU_PREFIX . 'users',
318
- array('Wpadm_GA', 'usersView')
319
- );
320
-
321
-
322
- $pages[] = add_options_page(
323
- 'Analytics Counter Settings',
324
- 'Analytics Counter',
325
- 'administrator',
326
- WPADM_GA__MENU_PREFIX . 'settings',
327
- array('Wpadm_GA', 'settingsView')
328
- );
329
-
330
- foreach($pages as $page) {
331
- add_action( 'admin_print_scripts-' . $page, array('Wpadm_GA', 'registerPluginScripts' ));
332
- add_action( 'admin_print_styles-' . $page, array('Wpadm_GA', 'registerPluginStyles' ) );
333
- }
334
-
335
- }
336
-
337
- public static function generateGACodeOnSite() {
338
- if (WPAdm_GA_Options::getGAEnableCode() == 1 && WPAdm_GA_Options::getGAWebPropertyId()) {
339
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'ga_code_universal.php';
340
- }
341
- }
342
-
343
-
344
- protected function getErrorTemplate() {
345
- if(!get_option('wpadm_ga_pub_key')) {
346
- return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_pub_key.php';
347
- }
348
-
349
- $token = WPAdm_GA_Options::getGAAccessToken();
350
- if (empty($token)) {
351
- return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_ga_token.php';
352
- }
353
-
354
- $site = WPAdm_GA_Options::getGAUrl();
355
- if (empty($site) && $_GET['page'] != 'wpadm-ga-menu-settings') {
356
- return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_ga_site.php';
357
- }
358
-
359
- if(isset($_GET['google_oauth2_error'])) {
360
- return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_google_error.php';
361
- }
362
-
363
- if(isset($_GET['error'])) {
364
- return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_wpadm_error.php';
365
- }
366
-
367
- return null;
368
- }
369
-
370
- function getParamsForRequest($data) {
371
- $params = array(
372
- 'data' => $data,
373
- 'sign' => self::getSSLSign($data)
374
- );
375
-
376
- return array(REQUEST_PARAM_NAME => base64_encode(serialize($params)));
377
- }
378
-
379
- function getSSLSign($data) {
380
- $str = md5(serialize($data));
381
- if(function_exists('openssl_public_encrypt')) {
382
- openssl_public_encrypt($str, $sign, get_option('wpadm_ga_pub_key'));
383
- } else {
384
- set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/lib/phpseclib');
385
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib'.DIRECTORY_SEPARATOR . 'phpseclib' . DIRECTORY_SEPARATOR . 'Crypt'.DIRECTORY_SEPARATOR.'RSA.php';
386
- $rsa = new Crypt_RSA();
387
- $rsa->loadKey(get_option('wpadm_ga_pub_key'));
388
- $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
389
- $sign = $rsa->encrypt($str);
390
- }
391
- return $sign;
392
- }
393
-
394
- protected static function verifySignature($sign, $pub_key, $text) {
395
- if (function_exists('openssl_public_decrypt')) {
396
- openssl_public_decrypt($sign, $request_sign, $pub_key);
397
- $ret = ($text == $request_sign);
398
- return $ret;
399
- } else {
400
- set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/lib/phpseclib');
401
- require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib'.DIRECTORY_SEPARATOR . 'phpseclib' . DIRECTORY_SEPARATOR . 'Crypt'.DIRECTORY_SEPARATOR.'RSA.php';
402
- $rsa = new Crypt_RSA();
403
- $rsa->loadKey($pub_key);
404
- $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
405
- return ($rsa->decrypt($sign) == $text);
406
- }
407
- }
408
-
409
- protected static function decodeData($str) {
410
- return json_decode(base64_decode($str), true);
411
- }
412
-
413
-
414
- protected static function checkDB() {
415
- $opt_ver = WPADM_GA__PLUGIN_NAME . '-db-version';
416
- $cur_version = get_option($opt_ver, 0);
417
-
418
- if ($cur_version < WPADM_GA__DB_VERSION) {
419
- global $wpdb;
420
- $table_name = $wpdb->prefix . "wpadm_ga_cache";
421
- $sql = "CREATE TABLE " . $table_name . " (
422
- id int(11) NOT NULL AUTO_INCREMENT,
423
- query text NOT NULL,
424
- html text,
425
- result text,
426
- request_type varchar(20),
427
- object_type varchar(20),
428
- clearable tinyint(4) DEFAULT '1',
429
- expired_in int(11) DEFAULT 0,
430
- PRIMARY KEY (id)
431
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
432
-
433
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
434
- dbDelta($sql);
435
-
436
- $sql = $sql = "CREATE TABLE " . $table_name . " (
437
- id int(11) NOT NULL AUTO_INCREMENT,
438
- query text NOT NULL,
439
- html text,
440
- result text,
441
- request_type varchar(20),
442
- object_type varchar(20),
443
- clearable tinyint(4) DEFAULT '1',
444
- expired_in int(11) DEFAULT 0,
445
- PRIMARY KEY (id),
446
- KEY expired_in (expired_in),
447
- FULLTEXT KEY query (query)
448
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
449
-
450
- dbDelta($sql);
451
-
452
- self::cron_activation();
453
-
454
- update_option($opt_ver, WPADM_GA__DB_VERSION);
455
- }
456
- }
457
-
458
- public static function plugin_uninstall() {
459
- global $wpdb;
460
- $table_name = $wpdb->prefix . "wpadm_ga_cache";
461
- $sql = "DROP TABLE " . $table_name;
462
- $wpdb->query($sql);
463
-
464
- $opt_ver = WPADM_GA__PLUGIN_NAME . '-db-version';
465
- delete_option($opt_ver);
466
- }
467
- }
468
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPAdm_GA
4
+ {
5
+ const URL_GA_SERVER = 'http://secure.wpadm.com/ga/';
6
+ const URL_GA_AUTH = 'http://secure.wpadm.com/ga.php';
7
+ const URL_GA_PUB_KEY = 'http://secure.wpadm.com/ga/getPubKey';
8
+ const EMAIL_SUPPORT = 'support@wpadm.com';
9
+
10
+ const REQUEST_PARAM_NAME = 'wpadm_ga_request';
11
+
12
+ public static function visitView() {
13
+
14
+ WPAdm_GA_View::$subtitle = 'Audience Overview';
15
+
16
+ if($template = self::getErrorTemplate()) {
17
+ WPAdm_GA_View::$content_file = $template;
18
+ } else {
19
+ if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
20
+ ob_clean();
21
+ $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
22
+ // wp_redirect($localion);
23
+ header("Location: $location");
24
+ }
25
+ WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'visit.php';
26
+ }
27
+ require WPADM_GA__VIEW_LAYOUT;
28
+ }
29
+
30
+
31
+
32
+
33
+ public static function usersView() {
34
+ WPAdm_GA_View::$subtitle = 'Visitors Overview';
35
+
36
+ if($template = self::getErrorTemplate()) {
37
+ WPAdm_GA_View::$content_file = $template;
38
+ } else {
39
+ if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
40
+ ob_clean();
41
+ $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
42
+ header("Location: $location");
43
+ }
44
+ WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'users.php';
45
+ }
46
+ require WPADM_GA__VIEW_LAYOUT;
47
+ }
48
+
49
+ public function sourceView() {
50
+ WPAdm_GA_View::$subtitle = 'Source stat';
51
+ WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'source.php';
52
+ require WPADM_GA__VIEW_LAYOUT;
53
+ }
54
+
55
+ public function settingsView() {
56
+ WPAdm_GA_View::$subtitle = 'settings';
57
+
58
+ if($template = self::getErrorTemplate()) {
59
+ WPAdm_GA_View::$content_file = $template;
60
+ } else {
61
+ if(WPAdm_GA_Options::gaTokenIsExpired() && !isset($_GET['token'])) {
62
+ ob_clean();
63
+ $location = self::URL_GA_AUTH . '?redirect=' . urlencode(home_url( add_query_arg( NULL, NULL ) ));
64
+ header("Location: $location");
65
+ }
66
+ WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'settings.php';
67
+ }
68
+
69
+
70
+
71
+ //GA Account
72
+ $ga_accout_form = new wpadmForm();
73
+ $ga_accout_form->setValue('ga-id', WPAdm_GA_Options::getGAId());
74
+ $ga_accout_form->setValue('ga-webPropertyId', WPAdm_GA_Options::getGAWebPropertyId());
75
+ $ga_accout_form->setValue('ga-url', WPAdm_GA_Options::getGAUrl());
76
+ $ga_accout_form->setValue('ga-enableCode', WPAdm_GA_Options::getGAEnableCode());
77
+
78
+ if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
79
+ && isset($_POST['form_name'])
80
+ && 'ga-account' == $_POST['form_name']
81
+ ) {
82
+ $id = filter_input(INPUT_POST, 'ga-id', FILTER_SANITIZE_NUMBER_INT);
83
+ $url = filter_input(INPUT_POST, 'ga-url', FILTER_SANITIZE_URL);
84
+ $webPropertyId = filter_input(INPUT_POST, 'ga-webPropertyId', FILTER_SANITIZE_STRING);
85
+ $enableCode = (int)filter_input(INPUT_POST, 'ga-enableCode', FILTER_SANITIZE_NUMBER_INT);
86
+ $enableCode = ($enableCode) ? 1 : 0;
87
+
88
+ WPAdm_GA_Options::setGAId($id);
89
+ WPAdm_GA_Options::setGAUrl($url);
90
+ WPAdm_GA_Options::setGAWebPropertyId($webPropertyId);
91
+ WPAdm_GA_Options::setGAEnableCode($enableCode);
92
+
93
+ $ga_accout_form->setValue('ga-id', $id);
94
+ $ga_accout_form->setValue('ga-webPropertyId', $webPropertyId);
95
+ $ga_accout_form->setValue('ga-enableCode', $enableCode);
96
+
97
+ //redirect to stat
98
+ ob_clean();
99
+
100
+ if (isset($_GET['modal'])) {
101
+ echo '<script> top.frames.location.reload(false);</script>';
102
+ } else {
103
+ $location = admin_url() . 'options-general.php?page=wpadm-ga-menu-visit';
104
+ header("Location: $location");
105
+ }
106
+ exit;
107
+ }
108
+
109
+
110
+
111
+ // $wpadm_account_form = new wpadmAuthForm();
112
+
113
+ // if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
114
+ // && isset($_POST['form_name'])
115
+ // && 'wpadm-account' == $_POST['form_name']
116
+ // ) {
117
+ // $form_data = array(
118
+ // 'wpadm_username' => $_POST['wpadm_username'],
119
+ // 'wpadm_password' => $_POST['wpadm_password'],
120
+ // 'wpadm_password_confirm' => $_POST['wpadm_password_confirm'],
121
+ // 'wpadm_imnewuser_checkbox' => (isset($_POST['wpadm_imnewuser_checkbox'])&& $_POST['wpadm_imnewuser_checkbox'] == 1) ? 1 :0
122
+ // );
123
+ // $wpadm_account_form->setData($form_data);
124
+ //
125
+ // if ($wpadm_account_form->isValid()) {
126
+ //
127
+ // WPAdm_GA_Api::register();
128
+ // echo 'doit';
129
+ // exit;
130
+ // }
131
+ // }
132
+
133
+
134
+
135
+ // if('POST' == strtoupper($_SERVER['REQUEST_METHOD'])
136
+ // && isset($_POST['form_name'])
137
+ // && 'ga-account-logout' == $_POST['form_name']
138
+ // ) {
139
+ //
140
+ // $url = get_option('siteurl');
141
+ // $p_url = parse_url($url);
142
+ // $postdata = array(
143
+ // 'host' => $p_url['host'],
144
+ // );
145
+ //
146
+ // $response = wp_remote_post(self::URL_GA_SERVER . 'logout', array(
147
+ // 'method' => 'POST',
148
+ // 'timeout' => 45,
149
+ // 'body' => self::getParamsForRequest($postdata)
150
+ // ));
151
+ //
152
+ // if ( is_wp_error( $response ) ) {
153
+ // //todo: отработать исключение
154
+ // $error_message = $response->get_error_message();
155
+ // echo "Something went wrong: $error_message";
156
+ // } else {
157
+ //
158
+ // }
159
+ //
160
+ // echo '<!-- start dump --><pre><small>' . __FILE__ . "</small>\n";
161
+ // print_r($response['body']);
162
+ // echo '</pre><!-- end dump -->';
163
+ // exit;
164
+ //
165
+ //
166
+ // }
167
+
168
+
169
+
170
+ require WPADM_GA__VIEW_LAYOUT;
171
+ }
172
+
173
+
174
+ static function adminNotice() {
175
+
176
+ }
177
+
178
+ public static function plugin_activation() {
179
+ //get pub key
180
+ $response = wp_remote_post(self::URL_GA_PUB_KEY, array(
181
+ 'method' => 'POST',
182
+ 'timeout' => 45,
183
+ 'body' => array('refer'=>site_url())
184
+ ));
185
+
186
+ if ( is_wp_error( $response ) ) {
187
+ ////
188
+ $error_message = $response->get_error_message();
189
+ } else {
190
+ preg_match("|(-----BEGIN PUBLIC KEY-----.*-----END PUBLIC KEY-----)|Uis", $response['body'], $m);
191
+ if (isset($m[1]) && !empty($m[1])) {
192
+ update_option('wpadm_ga_pub_key', $m[1]);
193
+ }
194
+ }
195
+
196
+ self::cron_activation();
197
+ }
198
+
199
+ public static function plugin_deactivation() {
200
+ delete_option('wpadm_ga_pub_key');
201
+ //delete_option('wpadm_ga');
202
+ self::cron_deactivation();
203
+ //todo: delete cahce table
204
+ }
205
+
206
+ public static function cron_activation() {
207
+ add_action('wpadm_ga_cache_clear', array('Wpadm_GA_Cache', 'cronRemoveExpiredCache'));
208
+ wp_clear_scheduled_hook('wpadm_ga_cache_clear');
209
+ wp_schedule_event(time(), 'daily', 'wpadm_ga_cache_clear');
210
+ }
211
+
212
+ public static function cron_deactivation() {
213
+ wp_clear_scheduled_hook('wpadm_ga_cache_clear');
214
+ }
215
+
216
+
217
+ public static function init() {
218
+ ob_start();
219
+ self::requireFiles();
220
+ self::checkDB();
221
+ $request_name = self::REQUEST_PARAM_NAME;
222
+ if( isset( $_POST[$request_name] ) && ! empty ( $_POST[$request_name] ) ) {
223
+ self::proccessRequest();
224
+ }
225
+
226
+
227
+ // if ($show_notice_5star === false) {
228
+ //
229
+ // }
230
+
231
+
232
+ }
233
+
234
+ public static function setDtStartWork() {
235
+ if (!get_option('wpadm-ga-first_time')) {
236
+ update_option('wpadm-ga-first_time', time());
237
+ }
238
+ }
239
+
240
+ protected static function proccessRequest() {
241
+ $request_name = self::REQUEST_PARAM_NAME;
242
+ $params = unserialize(base64_decode($_POST[$request_name]));
243
+
244
+ $v = self::verifySignature($params['sign'], get_option('wpadm_ga_pub_key'), md5(serialize($params['data'])));
245
+
246
+ $request = $params['data'];
247
+
248
+ if($v && isset($request['action'])) {
249
+ switch($request['action']) {
250
+ case 'access_token':
251
+ WPAdm_GA_Options::setGAAccessToken($request['data']['access_token']);
252
+ WPAdm_GA_Options::setGAExpiresIn($request['data']['expires_in']);
253
+ WPAdm_GA_Options::setGACreated($request['data']['created']);
254
+
255
+ $ga_id = WPAdm_GA_Options::getGAId();
256
+ if (isset($request['data']['property']) && empty($ga_id)
257
+ && isset($request['data']['property']['ga_id']) && !empty($request['data']['property']['ga_id'])
258
+ && isset($request['data']['property']['ga_url']) && !empty($request['data']['property']['ga_url'])
259
+ && isset($request['data']['property']['ga_webPropertyId']) && !empty($request['data']['property']['ga_webPropertyId'])
260
+ ) {
261
+ WPAdm_GA_Options::setGAUrl($request['data']['property']['ga_url']);
262
+ WPAdm_GA_Options::setGAId($request['data']['property']['ga_id']);
263
+ WPAdm_GA_Options::setGAWebPropertyId($request['data']['property']['ga_webPropertyId']);
264
+ }
265
+
266
+ header("HTTP/1.0 201 Created");
267
+ break;
268
+ }
269
+ }
270
+ exit;
271
+ }
272
+
273
+
274
+
275
+ protected static function requireFiles() {
276
+ require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-options.php' );
277
+ require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-view.php' );
278
+ require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-cache.php' );
279
+
280
+ require_once( WPADM_GA__PLUGIN_DIR . 'form'.DIRECTORY_SEPARATOR.'wpadmForm.php' );
281
+ require_once( WPADM_GA__PLUGIN_DIR . 'form'.DIRECTORY_SEPARATOR.'wpadmAuthForm.php' );
282
+
283
+
284
+ }
285
+
286
+ public static function registerPluginStyles() {
287
+ wp_register_style( 'wpadm-ga-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.css' ) );
288
+ wp_enqueue_style( 'wpadm-ga-css' );
289
+
290
+ wp_register_style( 'wpadm-daterangepicker-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/daterangepicker/daterangepicker.css' ) );
291
+ wp_enqueue_style( 'wpadm-daterangepicker-css' );
292
+
293
+ }
294
+
295
+ public static function registerPluginScripts() {
296
+ wp_register_script( 'wpadm-ga-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.js' ) );
297
+ wp_enqueue_script( 'wpadm-ga-js' );
298
+
299
+ wp_register_script( 'wpadm-moment-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/moment.min.js' ) );
300
+ wp_enqueue_script( 'wpadm-moment-js' );
301
+
302
+ wp_register_script( 'wpadm-daterangepicker-js', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/daterangepicker/daterangepicker.js' ) );
303
+ wp_enqueue_script( 'wpadm-daterangepicker-js' );
304
+ }
305
+
306
+ public static function generateMenu() {
307
+ $pages = array();
308
+
309
+ $menu_position = '1.9998887770';
310
+ $pages[] = add_menu_page(
311
+ 'Analytics Counter',
312
+ 'Analytics Counter',
313
+ 'read',
314
+ WPADM_GA__MENU_PREFIX . 'visit',
315
+ array('Wpadm_GA', 'visitView'),
316
+ plugins_url('/view/img/icon.png',__FILE__),
317
+ $menu_position
318
+ );
319
+ $pages[] = add_submenu_page(
320
+ WPADM_GA__MENU_PREFIX . 'visit',
321
+ 'Audience overview',
322
+ 'Audience overview',
323
+ 'read',
324
+ WPADM_GA__MENU_PREFIX . 'visit',
325
+ array('Wpadm_GA', 'visitView')
326
+ );
327
+
328
+
329
+ $pages[] = add_submenu_page(
330
+ WPADM_GA__MENU_PREFIX . 'visit',
331
+ 'Visitors overview',
332
+ 'Visitors overview',
333
+ 'read',
334
+ WPADM_GA__MENU_PREFIX . 'users',
335
+ array('Wpadm_GA', 'usersView')
336
+ );
337
+
338
+
339
+ $pages[] = add_options_page(
340
+ 'Analytics Counter Settings',
341
+ 'Analytics Counter',
342
+ 'administrator',
343
+ WPADM_GA__MENU_PREFIX . 'settings',
344
+ array('Wpadm_GA', 'settingsView')
345
+ );
346
+
347
+ foreach($pages as $page) {
348
+ add_action( 'admin_print_scripts-' . $page, array('Wpadm_GA', 'registerPluginScripts' ));
349
+ add_action( 'admin_print_styles-' . $page, array('Wpadm_GA', 'registerPluginStyles' ) );
350
+ }
351
+
352
+ }
353
+
354
+ public static function generateGACodeOnSite() {
355
+ if (WPAdm_GA_Options::getGAEnableCode() == 1 && WPAdm_GA_Options::getGAWebPropertyId()) {
356
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'ga_code_universal.php';
357
+ }
358
+ }
359
+
360
+
361
+ protected static function getErrorTemplate() {
362
+
363
+ if(!get_option('wpadm_ga_pub_key')) {
364
+ return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_pub_key.php';
365
+ }
366
+
367
+ $token = WPAdm_GA_Options::getGAAccessToken();
368
+ if (empty($token)) {
369
+ return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_ga_token.php';
370
+ }
371
+
372
+ $site = WPAdm_GA_Options::getGAUrl();
373
+ if (empty($site) && $_GET['page'] != 'wpadm-ga-menu-settings') {
374
+ return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_empty_ga_site.php';
375
+ }
376
+
377
+ if(isset($_GET['google_oauth2_error'])) {
378
+ return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_google_error.php';
379
+ }
380
+
381
+ if(isset($_GET['error'])) {
382
+ return WPAdm_GA_View::$content_file = WPADM_GA__PLUGIN_DIR . 'view' . DIRECTORY_SEPARATOR . 'error_admin_wpadm_error.php';
383
+ }
384
+
385
+ return null;
386
+ }
387
+
388
+ function getParamsForRequest($data) {
389
+ $params = array(
390
+ 'data' => $data,
391
+ 'sign' => self::getSSLSign($data)
392
+ );
393
+
394
+ return array(REQUEST_PARAM_NAME => base64_encode(serialize($params)));
395
+ }
396
+
397
+ function getSSLSign($data) {
398
+ $str = md5(serialize($data));
399
+ if(function_exists('openssl_public_encrypt')) {
400
+ openssl_public_encrypt($str, $sign, get_option('wpadm_ga_pub_key'));
401
+ } else {
402
+ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/lib/phpseclib');
403
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib'.DIRECTORY_SEPARATOR . 'phpseclib' . DIRECTORY_SEPARATOR . 'Crypt'.DIRECTORY_SEPARATOR.'RSA.php';
404
+ $rsa = new Crypt_RSA();
405
+ $rsa->loadKey(get_option('wpadm_ga_pub_key'));
406
+ $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
407
+ $sign = $rsa->encrypt($str);
408
+ }
409
+ return $sign;
410
+ }
411
+
412
+ protected static function verifySignature($sign, $pub_key, $text) {
413
+ if (function_exists('openssl_public_decrypt')) {
414
+ openssl_public_decrypt($sign, $request_sign, $pub_key);
415
+ $ret = ($text == $request_sign);
416
+ return $ret;
417
+ } else {
418
+ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/lib/phpseclib');
419
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib'.DIRECTORY_SEPARATOR . 'phpseclib' . DIRECTORY_SEPARATOR . 'Crypt'.DIRECTORY_SEPARATOR.'RSA.php';
420
+ $rsa = new Crypt_RSA();
421
+ $rsa->loadKey($pub_key);
422
+ $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
423
+ return ($rsa->decrypt($sign) == $text);
424
+ }
425
+ }
426
+
427
+ protected static function decodeData($str) {
428
+ return json_decode(base64_decode($str), true);
429
+ }
430
+
431
+
432
+ protected static function checkDB() {
433
+ $opt_ver = WPADM_GA__PLUGIN_NAME . '-db-version';
434
+ $cur_version = get_option($opt_ver, 0);
435
+
436
+ if ($cur_version < WPADM_GA__DB_VERSION) {
437
+ global $wpdb;
438
+ $table_name = $wpdb->prefix . "wpadm_ga_cache";
439
+ $sql = "CREATE TABLE " . $table_name . " (
440
+ id int(11) NOT NULL AUTO_INCREMENT,
441
+ query text NOT NULL,
442
+ html text,
443
+ result text,
444
+ request_type varchar(20),
445
+ object_type varchar(20),
446
+ clearable tinyint(4) DEFAULT '1',
447
+ expired_in int(11) DEFAULT 0,
448
+ PRIMARY KEY (id)
449
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
450
+
451
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
452
+ dbDelta($sql);
453
+
454
+ $sql = $sql = "CREATE TABLE " . $table_name . " (
455
+ id int(11) NOT NULL AUTO_INCREMENT,
456
+ query text NOT NULL,
457
+ html text,
458
+ result text,
459
+ request_type varchar(20),
460
+ object_type varchar(20),
461
+ clearable tinyint(4) DEFAULT '1',
462
+ expired_in int(11) DEFAULT 0,
463
+ PRIMARY KEY (id),
464
+ KEY expired_in (expired_in),
465
+ FULLTEXT KEY query (query)
466
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
467
+
468
+ dbDelta($sql);
469
+
470
+ self::cron_activation();
471
+
472
+ update_option($opt_ver, WPADM_GA__DB_VERSION);
473
+ }
474
+ }
475
+
476
+ public static function plugin_uninstall() {
477
+ global $wpdb;
478
+ $table_name = $wpdb->prefix . "wpadm_ga_cache";
479
+ $sql = "DROP TABLE " . $table_name;
480
+ $wpdb->query($sql);
481
+
482
+ $opt_ver = WPADM_GA__PLUGIN_NAME . '-db-version';
483
+ delete_option($opt_ver);
484
+ }
485
+
486
+ protected static function getIp()
487
+ {
488
+ $user_ip = '';
489
+ if ( getenv('REMOTE_ADDR') ){
490
+ $user_ip = getenv('REMOTE_ADDR');
491
+ }elseif ( getenv('HTTP_FORWARDED_FOR') ){
492
+ $user_ip = getenv('HTTP_FORWARDED_FOR');
493
+ }elseif ( getenv('HTTP_X_FORWARDED_FOR') ){
494
+ $user_ip = getenv('HTTP_X_FORWARDED_FOR');
495
+ }elseif ( getenv('HTTP_X_COMING_FROM') ){
496
+ $user_ip = getenv('HTTP_X_COMING_FROM');
497
+ }elseif ( getenv('HTTP_VIA') ){
498
+ $user_ip = getenv('HTTP_VIA');
499
+ }elseif ( getenv('HTTP_XROXY_CONNECTION') ){
500
+ $user_ip = getenv('HTTP_XROXY_CONNECTION');
501
+ }elseif ( getenv('HTTP_CLIENT_IP') ){
502
+ $user_ip = getenv('HTTP_CLIENT_IP');
503
+ }
504
+
505
+ $user_ip = trim($user_ip);
506
+ if ( empty($user_ip) ){
507
+ return '';
508
+ }
509
+ if ( !preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $user_ip) ){
510
+ return '';
511
+ }
512
+ return $user_ip;
513
+ }
514
+
515
+
516
+ public static function sendSupport() {
517
+ if (isset($_POST['message'])) {
518
+ $ticket = date('ymdHis') . rand(1000, 9999);
519
+ $subject = "Support [sug:$ticket]: Analytics counter plugin";
520
+ $message = "Client email: " . get_option('admin_email') . "\n";
521
+ $message .= "Client site: " . home_url() . "\n";
522
+ $message .= "Client suggestion: " . $_POST['message']. "\n\n";
523
+ $message .= "Client ip: " . self::getIp() . "\n";
524
+ $browser = @$_SERVER['HTTP_USER_AGENT'];
525
+ $message .= "Client useragent: " . $browser . "\n";
526
+ $header[] = "Reply-To: " . get_option('admin_email') . "\r\n";
527
+ if (wp_mail(self::EMAIL_SUPPORT, $subject, $message, $header)) {
528
+ echo json_encode(array(
529
+ 'status' => 'success'
530
+ ));
531
+ } else {
532
+ echo json_encode(array(
533
+ 'status' => 'error'
534
+ ));
535
+ }
536
+ wp_die();
537
+ }
538
+ }
539
+
540
+ public static function stopNotice5Stars() {
541
+ if (isset($_POST['stop'])) {
542
+ update_option('wpadm-ga-stopNotice5Stars', true);
543
+
544
+ }
545
+ wp_die();
546
+ }
547
+ }
548
+
readme.txt CHANGED
@@ -1,79 +1,79 @@
1
- === Google Analytics Counter Tracker ===
2
- Plugin Name: Google Analytics Counter Tracker
3
- Version: 1.0.0
4
- Tags: Google Analytics, Analytics, Statistics, Analytics dashboard, Reports, Charts, Stats, Web stats, Visit, Audience Overview, Visitors Overview, Marketing, Google, Keywords, Counter, Tracker, Hit counter, hitcounter, visitor tracker, visitor tracking, visitors, tracking, stats, statscounter, analyse, hits, hit, track
5
- Requires at least: 3.9
6
- Tested up to: 4.3.1
7
- Stable tag: trunk
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
- Author: wpadm.com
11
- Contributors: WPAdm, wpadm.com
12
-
13
- Google analytics counter tracker - analyse the visitors hits on you website and display it graphically
14
-
15
- == Description ==
16
-
17
- Google analytics counter tracker - analyse the visitors hits on you homepage and display it graphically
18
-
19
- **The Google Analytics Counter Tracker plugin include this data:**
20
-
21
- * Audience Overview:<br />
22
- * Sessions<br />
23
- * Page views (Pageviews)<br />
24
- * Users<br />
25
- * Page views per session<br />
26
- * Session duration<br />
27
- * Bounces<br />
28
- * Percent new sessions<br />
29
- * Most popular pages<br />
30
- * Search keywords<br />
31
- * Visitors Overview<br />
32
- * Users<br />
33
- * New users<br />
34
- * Top Countries by Users<br />
35
- * Geo Location<br />
36
- * Browser<br />
37
- * Operating system<br />
38
- * Screen resolution<br />
39
-
40
- = Features of Google Analytics Counter Tracker =
41
- * Very simple and easy to use.
42
- * Connect your Google Analytics account and get Google Analytics stats;
43
- * Group stats by hour, day, month and year;
44
- * See data for different time periods in your reports;
45
- * Compatible with almost every version of WordPress;
46
- * Mobile-Friendly Design;
47
-
48
- = Support for Google Analytics Counter Tracker =
49
- If you need help with the Google Analytics Counter Tracker plugin or you want to report a bug please refer to http://www.wpadm.com/support/
50
-
51
-
52
-
53
- == Screenshots ==
54
-
55
- Screenshots for Google Analytics Counter Tracker coming soon.
56
-
57
- * Overview
58
- * Mobile-Friendly Design
59
- * Sessions and Pageviews
60
- * Users and new users
61
- * Top countries and geo locations
62
- * Browsers, Operating systems and Screen resolutions
63
-
64
- == Installation ==
65
-
66
- = Follow this simple steps for Google Analytics Counter Tracker correct installation =
67
-
68
- 1. Upload `analytics-counter` folder to the `/wp-content/plugins/` directory.
69
- 2. Activate Google Analytics WPAdm plugin through the 'Plugins' menu in the WordPress admin area.
70
- 3. Link your Google Analytics account under 'Settings -> Analytics Counter'.
71
- 4. Select target site under 'Settings -> Analytics Counter'.
72
-
73
- = Support for Google Analytics Counter Tracker =
74
- If you need help with the Google Analytics Counter Tracker plugin or you want to report a bug please refer to http://www.wpadm.com/support/
75
-
76
-
77
- == Other ==
78
-
79
  Other
1
+ === Google Analytics Counter Tracker ===
2
+ Plugin Name: Google Analytics Counter Tracker
3
+ Version: 1.0.2
4
+ Tags: Google Analytics, Analytics, Statistics, Analytics dashboard, Reports, Charts, Stats, Web stats, Visit, Audience Overview, Visitors Overview, Marketing, Google, Keywords, Counter, Tracker, Hit counter, hitcounter, visitor tracker, visitor tracking, visitors, tracking, stats, statscounter, analyse, hits, hit, track
5
+ Requires at least: 3.9
6
+ Tested up to: 4.3.1
7
+ Stable tag: trunk
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+ Author: wpadm.com
11
+ Contributors: WPAdm, wpadm.com
12
+
13
+ Google analytics counter tracker - analyse the visitors hits on you website and display it graphically
14
+
15
+ == Description ==
16
+
17
+ Google analytics counter tracker - analyse the visitors hits on you homepage and display it graphically
18
+
19
+ **The Google Analytics Counter Tracker plugin include this data:**
20
+
21
+ * Audience Overview:<br />
22
+ * Sessions<br />
23
+ * Page views (Pageviews)<br />
24
+ * Users<br />
25
+ * Page views per session<br />
26
+ * Session duration<br />
27
+ * Bounces<br />
28
+ * Percent new sessions<br />
29
+ * Most popular pages<br />
30
+ * Search keywords<br />
31
+ * Visitors Overview<br />
32
+ * Users<br />
33
+ * New users<br />
34
+ * Top Countries by Users<br />
35
+ * Geo Location<br />
36
+ * Browser<br />
37
+ * Operating system<br />
38
+ * Screen resolution<br />
39
+
40
+ = Features of Google Analytics Counter Tracker =
41
+ * Very simple and easy to use.
42
+ * Connect your Google Analytics account and get Google Analytics stats;
43
+ * Group stats by hour, day, month and year;
44
+ * See data for different time periods in your reports;
45
+ * Compatible with almost every version of WordPress;
46
+ * Mobile-Friendly Design;
47
+
48
+ = Support for Google Analytics Counter Tracker =
49
+ If you need help with the Google Analytics Counter Tracker plugin or you want to report a bug please refer to http://www.wpadm.com/support/
50
+
51
+
52
+
53
+ == Screenshots ==
54
+
55
+ Screenshots for Google Analytics Counter Tracker coming soon.
56
+
57
+ * Overview
58
+ * Mobile-Friendly Design
59
+ * Sessions and Pageviews
60
+ * Users and new users
61
+ * Top countries and geo locations
62
+ * Browsers, Operating systems and Screen resolutions
63
+
64
+ == Installation ==
65
+
66
+ = Follow this simple steps for Google Analytics Counter Tracker correct installation =
67
+
68
+ 1. Upload `analytics-counter` folder to the `/wp-content/plugins/` directory.
69
+ 2. Activate Google Analytics WPAdm plugin through the 'Plugins' menu in the WordPress admin area.
70
+ 3. Link your Google Analytics account under 'Settings -> Analytics Counter'.
71
+ 4. Select target site under 'Settings -> Analytics Counter'.
72
+
73
+ = Support for Google Analytics Counter Tracker =
74
+ If you need help with the Google Analytics Counter Tracker plugin or you want to report a bug please refer to http://www.wpadm.com/support/
75
+
76
+
77
+ == Other ==
78
+
79
  Other
view/layout.php CHANGED
@@ -1,17 +1,76 @@
 
 
1
  <?php $url = plugins_url(WPADM_GA__PLUGIN_NAME . '/view/scripts'); ?>
2
  <link rel="stylesheet" type="text/css" href="<?php echo plugins_url(WPADM_GA__PLUGIN_NAME . '/view/scripts'); ?>/bootstrap/css/bootstrap.min.css" />
3
  <link rel="stylesheet" type="text/css" href="<?php echo $url; ?>/glyphicons.css" />
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  <?php
6
  /**
7
  * @var $wpadm_ga_view WPAdm_GA_View
8
  */
 
 
 
 
 
 
 
 
9
  ?>
10
 
11
  <div id="wpadm-ga-layout">
12
  <div id="wpadm-ga-header">
13
- <h1><img src="<?php echo plugins_url('/img/big_icon.png',__FILE__); ?>" style="height: 48px; width: 48px;"> <?php echo WPAdm_GA_View::$title; ?> <small><?php echo WPAdm_GA_View::$subtitle;?></small></h1>
14
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  <div id="wpadm-ga-content">
16
  <?php
17
  if(WPAdm_GA_View::$content_file) {
1
+ <?php add_thickbox(); ?>
2
+
3
  <?php $url = plugins_url(WPADM_GA__PLUGIN_NAME . '/view/scripts'); ?>
4
  <link rel="stylesheet" type="text/css" href="<?php echo plugins_url(WPADM_GA__PLUGIN_NAME . '/view/scripts'); ?>/bootstrap/css/bootstrap.min.css" />
5
  <link rel="stylesheet" type="text/css" href="<?php echo $url; ?>/glyphicons.css" />
6
 
7
+
8
+ <div id="wpadm-ga-support_container" style="display:none;">
9
+ <div id="wpadm-ga_support_text_container">
10
+ <h2>Suggestion</h2>
11
+ <textarea style="width: 100%; height: 300px" id="wpadm-ga_support_text"></textarea>
12
+ </div>
13
+
14
+ <div id="wpadm-ga_support_thank_container" style="display: none;">
15
+ <h2>Thanks for your suggestion!</h2>
16
+ Within next plugin updates we will try to satisfy your request.
17
+ </div>
18
+
19
+ <div id="wpadm-ga_support_error_container" style="display: none;">
20
+ <br><b>At your website the mail functionality is not available.</b><br /><br />
21
+ Your request was not sent.
22
+ </div>
23
+
24
+
25
+ <div style="text-align: right; margin-top: 20px;">
26
+ <button type="button" class="btn btn-default" onclick="jQuery('.tb-close-icon').click()">close</button>
27
+ <button type="button" class="btn btn-primary" id="wpadm-ga-support_send_button" onclick="wpadm_ga_sendSupportText()">Send suggestion</button>
28
+
29
+ </div>
30
+ </div>
31
+
32
+
33
  <?php
34
  /**
35
  * @var $wpadm_ga_view WPAdm_GA_View
36
  */
37
+ $show_notice_5stars = false;
38
+ if (!isset($_GET['modal'])) {
39
+ if (!get_option('wpadm-ga-stopNotice5Stars')) {
40
+ $first_time = get_option('wpadm-ga-first_time');
41
+ $show_notice_5stars = ($first_time && $first_time < time() - 24 * 60 * 60);
42
+
43
+ }
44
+ }
45
  ?>
46
 
47
  <div id="wpadm-ga-layout">
48
  <div id="wpadm-ga-header">
49
+ <h1 style="display: inline;"><img src="<?php echo plugins_url('/img/big_icon.png',__FILE__); ?>" style="height: 48px; width: 48px;"> <?php echo WPAdm_GA_View::$title; ?> <small><?php echo WPAdm_GA_View::$subtitle;?></small></h1>
50
  </div>
51
+
52
+ <?php if ($show_notice_5stars): ?>
53
+ <div class="wpadm-ga-notice-5stars-content">
54
+ <div class="wpadm-ga-notice-5stars-right">
55
+ <a id="wpadm-ga-notice-5stars-remover" href="javascript:void(0)" onclick="wpadm_ga_stopNotice5Stars()">[ Hide this message ]</a>
56
+ </div>
57
+ <div class="wpadm-ga-notice-5stars-left" onclick="window.open('https://wordpress.org/support/view/plugin-reviews/analytics-counter?filter=5#postform')">
58
+ Leave us 5 stars
59
+ <button id="wpadm-ga-button-5stars" type="button" class="btn btn-default btn-sm">
60
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
61
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
62
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
63
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
64
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
65
+ </button>
66
+ <small>It will help us to develop this plugin for you</small>
67
+ </div>
68
+ </div>
69
+
70
+ <div class="clear"></div>
71
+ <?php endif; ?>
72
+
73
+
74
  <div id="wpadm-ga-content">
75
  <?php
76
  if(WPAdm_GA_View::$content_file) {
view/scripts/wpadm-ga.css CHANGED
@@ -194,4 +194,45 @@ button.active_group_by {
194
 
195
  .wpadm-gapi-analytics-data-chart-styles-table-tr-odd {
196
  background-color: #EEEEEE;
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  .wpadm-gapi-analytics-data-chart-styles-table-tr-odd {
196
  background-color: #EEEEEE;
197
+ }
198
+
199
+
200
+ .wpadm-ga-notice-5stars-content .wpadm-ga-notice-5stars-left {
201
+
202
+ padding-left: 10px;
203
+ padding-top: 4px;
204
+ min-height: 43px;
205
+ vertical-align: middle;
206
+ background-color: #FF7F00;
207
+ font-weight: bold;
208
+ font-size: 1.5em;
209
+ color: white;
210
+ cursor: pointer;
211
+ }
212
+
213
+ .wpadm-ga-notice-5stars-content .wpadm-ga-notice-5stars-right {
214
+ float: right;
215
+ text-align: right;
216
+ vertical-align: text-bottom;
217
+ background-color: #FF7F00;
218
+ min-height: 43px;
219
+ padding-right: 10px;
220
+ }
221
+
222
+ #wpadm-ga-button-5stars {
223
+ background-color: #B15801;
224
+ border-color: #A0540A;
225
+ margin-left: 10px;
226
+ font-size: 0.7em; color: gold;
227
+ text-align: left;
228
+
229
+ }
230
+ #wpadm-ga-button-5stars:hover {
231
+ font-size: 0.7em; color: yellow;
232
+ border-color: #A07F4C;
233
+ }
234
+
235
+ #wpadm-ga-notice-5stars-remover {
236
+ font-size: 1em;
237
+ color: white;
238
+ }
view/scripts/wpadm-ga.js CHANGED
@@ -217,7 +217,7 @@ function wpadm_ga_setCache(result, type) {
217
 
218
  jQuery.post(ajaxurl, data, function (response) {
219
  try {
220
- var res = jQuery.parseJSON(responce);
221
  } catch (e) {
222
  }
223
 
@@ -228,3 +228,57 @@ function wpadm_ga_setCache(result, type) {
228
  }
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  jQuery.post(ajaxurl, data, function (response) {
219
  try {
220
+ var res = jQuery.parseJSON(response);
221
  } catch (e) {
222
  }
223
 
228
  }
229
  }
230
 
231
+ function wpadm_ga_sendSupportText() {
232
+
233
+ if(jQuery('#wpadm-ga_support_text').val().trim() == '') {
234
+ return;
235
+ }
236
+
237
+ var data = {
238
+ 'action': 'sendSupport',
239
+
240
+ 'message': jQuery('#wpadm-ga_support_text').val()
241
+ }
242
+
243
+ jQuery.post(ajaxurl, data, function (response) {
244
+ try {
245
+ console.dir(response)
246
+ var res = jQuery.parseJSON(response);
247
+ console.dir(res);
248
+ if (res) {
249
+ jQuery('#wpadm-ga_support_text_container').hide();
250
+ jQuery('#wpadm-ga-support_send_button').hide();
251
+ if(res.status=='success') {
252
+ jQuery('#wpadm-ga_support_thank_container').show();
253
+ } else if(res.status=='error') {
254
+ jQuery('#wpadm-ga_support_error_container').show();
255
+ }
256
+ } else {
257
+ jQuery('.tb-close-icon').click();
258
+ }
259
+ } catch (e) {
260
+ jQuery('.tb-close-icon').click();
261
+ }
262
+ });
263
+ }
264
+
265
+ function wpadm_ga_supportFormNormalize() {
266
+ if (jQuery('#wpadm-ga_support_text_container')[0].style.display == 'none') {
267
+ jQuery('#wpadm-ga_support_text').val('');
268
+ }
269
+ jQuery('#wpadm-ga_support_text_container').show();
270
+ jQuery('#wpadm-ga-support_send_button').show();
271
+ jQuery('#wpadm-ga_support_thank_container').hide();
272
+ jQuery('#wpadm-ga_support_error_container').hide();
273
+ }
274
+
275
+ function wpadm_ga_stopNotice5Stars() {
276
+ jQuery('.wpadm-ga-notice-5stars-content').hide( "slow" );
277
+ var data = {
278
+ 'action': 'stopNotice5Stars',
279
+
280
+ 'stop': 1
281
+ }
282
+ jQuery.post(ajaxurl, data, function (response) {
283
+ });
284
+ }
view/users.php CHANGED
@@ -14,7 +14,7 @@ $end_date = date("Y-m-d", strtotime("-1 day"));
14
  <span></span> <b class="caret"></b>
15
  </div>
16
  </div>
17
- <div style="float: left; margin-bottom: 20px;">
18
  <div style="font-weight: bold;">Group statistics data by</div>
19
  <div class="btn-group" role="group" aria-label="...">
20
  <button class="group_by btn btn-default" onclick="changeGroupBy('dateHour', this)">Hour</button>
@@ -24,10 +24,17 @@ $end_date = date("Y-m-d", strtotime("-1 day"));
24
  </div>
25
  </div>
26
 
27
- <div style="float: right;">
28
- <?php add_thickbox(); ?>
 
 
 
 
 
 
29
  <br>
30
  <a class="btn btn-info thickbox" href="<?php echo admin_url() . 'options-general.php?page=wpadm-ga-menu-settings&modal&TB_iframe=true&height=370'; ?>">Settings</a>
 
31
  </div>
32
 
33
 
14
  <span></span> <b class="caret"></b>
15
  </div>
16
  </div>
17
+ <div style="float: left; padding-right: 30px; margin-bottom: 20px;">
18
  <div style="font-weight: bold;">Group statistics data by</div>
19
  <div class="btn-group" role="group" aria-label="...">
20
  <button class="group_by btn btn-default" onclick="changeGroupBy('dateHour', this)">Hour</button>
24
  </div>
25
  </div>
26
 
27
+
28
+ <div style="float: left; padding-right: 50px; margin-bottom: 20px;">
29
+
30
+ <br>
31
+ If you have any suggestions or wishes <a class="btn btn-info thickbox" href="#TB_inline?width=600&height=500&inlineId=wpadm-ga-support_container" style="margin-right: 0px;" onclick="wpadm_ga_supportFormNormalize()">Contact us</a>
32
+
33
+ </div>
34
+ <div style="float:left; margin-bottom: 20px;">
35
  <br>
36
  <a class="btn btn-info thickbox" href="<?php echo admin_url() . 'options-general.php?page=wpadm-ga-menu-settings&modal&TB_iframe=true&height=370'; ?>">Settings</a>
37
+
38
  </div>
39
 
40
 
view/visit.php CHANGED
@@ -8,7 +8,7 @@
8
  <span></span> <b class="caret"></b>
9
  </div>
10
  </div>
11
- <div style="float: left; margin-bottom: 20px;">
12
  <div style="font-weight: bold;">Group statistics data by</div>
13
  <div class="btn-group" role="group" aria-label="...">
14
  <button class="group_by btn btn-default" onclick="changeGroupBy('dateHour', this)">Hour</button>
@@ -17,10 +17,16 @@
17
  <button class="group_by btn btn-default" onclick="changeGroupBy('yearMonth', this)">Month</button>
18
  </div>
19
  </div>
20
- <div style="float: right;">
21
- <?php add_thickbox(); ?>
 
 
 
 
 
22
  <br>
23
  <a class="btn btn-info thickbox" href="<?php echo admin_url() . 'options-general.php?page=wpadm-ga-menu-settings&modal&TB_iframe=true&height=370'; ?>">Settings</a>
 
24
  </div>
25
 
26
  <div class="clear"></div>
8
  <span></span> <b class="caret"></b>
9
  </div>
10
  </div>
11
+ <div style="float: left; padding-right: 30px; margin-bottom: 20px;">
12
  <div style="font-weight: bold;">Group statistics data by</div>
13
  <div class="btn-group" role="group" aria-label="...">
14
  <button class="group_by btn btn-default" onclick="changeGroupBy('dateHour', this)">Hour</button>
17
  <button class="group_by btn btn-default" onclick="changeGroupBy('yearMonth', this)">Month</button>
18
  </div>
19
  </div>
20
+ <div style="float: left; padding-right: 50px; margin-bottom: 20px;">
21
+
22
+ <br>
23
+ If you have any suggestions or wishes <a class="btn btn-info thickbox" href="#TB_inline?width=600&height=500&inlineId=wpadm-ga-support_container" style="margin-right: 0px;" onclick="wpadm_ga_supportFormNormalize()">Contact us</a>
24
+
25
+ </div>
26
+ <div style="float:left; margin-bottom: 20px;">
27
  <br>
28
  <a class="btn btn-info thickbox" href="<?php echo admin_url() . 'options-general.php?page=wpadm-ga-menu-settings&modal&TB_iframe=true&height=370'; ?>">Settings</a>
29
+
30
  </div>
31
 
32
  <div class="clear"></div>