Google Analytics Counter Tracker - Version 3.0.3

Version Description

Download this release

Release Info

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

Code changes from version 3.0.1 to 3.0.3

analytics-counter.php CHANGED
@@ -3,7 +3,7 @@
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: 3.0.1
7
  Author: WPAdm
8
  Author URI: http://www.wpadm.com
9
  Plugin URI: http://www.wpadm.com
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: 3.0.3
7
  Author: WPAdm
8
  Author URI: http://www.wpadm.com
9
  Plugin URI: http://www.wpadm.com
class.wpadm-ga.php CHANGED
@@ -5,6 +5,7 @@ class WPAdm_GA
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';
@@ -82,6 +83,10 @@ class WPAdm_GA
82
  && isset($_POST['form_name'])
83
  && 'ga-account' == $_POST['form_name']
84
  ) {
 
 
 
 
85
  $id = filter_input(INPUT_POST, 'ga-id', FILTER_SANITIZE_NUMBER_INT);
86
  $url = filter_input(INPUT_POST, 'ga-url', FILTER_SANITIZE_URL);
87
  $webPropertyId = filter_input(INPUT_POST, 'ga-webPropertyId', FILTER_SANITIZE_STRING);
@@ -288,6 +293,50 @@ class WPAdm_GA
288
  }
289
 
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
  protected static function requireFiles() {
293
  require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-options.php' );
@@ -300,7 +349,7 @@ class WPAdm_GA
300
 
301
  }
302
 
303
- public static function registerPluginStyles() {
304
  wp_register_style( 'wpadm-ga-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.css' ) );
305
  wp_enqueue_style( 'wpadm-ga-css' );
306
 
@@ -414,7 +463,7 @@ public static function registerPluginStyles() {
414
  return null;
415
  }
416
 
417
- function getParamsForRequest($data) {
418
  $params = array(
419
  'data' => $data,
420
  'sign' => self::getSSLSign($data)
@@ -423,7 +472,7 @@ public static function registerPluginStyles() {
423
  return array(REQUEST_PARAM_NAME => base64_encode(serialize($params)));
424
  }
425
 
426
- function getSSLSign($data) {
427
  $str = md5(serialize($data));
428
  if(function_exists('openssl_public_encrypt')) {
429
  openssl_public_encrypt($str, $sign, get_option('wpadm_ga_pub_key'));
@@ -453,6 +502,22 @@ public static function registerPluginStyles() {
453
  }
454
  }
455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
  protected static function decodeData($str) {
457
  return json_decode(base64_decode($str), true);
458
  }
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 EMAIL_SUPPORT = 'support@wpadm.com';
10
 
11
  const REQUEST_PARAM_NAME = 'wpadm_ga_request';
83
  && isset($_POST['form_name'])
84
  && 'ga-account' == $_POST['form_name']
85
  ) {
86
+ if ('disconnect' == filter_input(INPUT_POST, 'ga-disconnect-btn', FILTER_SANITIZE_STRING)) {
87
+ self::googleAnalyticsDisconnect();
88
+ return;
89
+ }
90
  $id = filter_input(INPUT_POST, 'ga-id', FILTER_SANITIZE_NUMBER_INT);
91
  $url = filter_input(INPUT_POST, 'ga-url', FILTER_SANITIZE_URL);
92
  $webPropertyId = filter_input(INPUT_POST, 'ga-webPropertyId', FILTER_SANITIZE_STRING);
293
  }
294
 
295
 
296
+ protected static function googleAnalyticsDisconnect() {
297
+ self::sendRequest(self::URL_GA_SERVER . 'disconnect', array(
298
+ 'action' => 'disconnect',
299
+ 'refer'=>self::getCurUrl()
300
+ ));
301
+
302
+ WPAdm_GA_Options::setGAId(null);
303
+ WPAdm_GA_Options::setGAWebPropertyId(null);
304
+ WPAdm_GA_Options::setGAUrl(null);
305
+ WPAdm_GA_Options::setGAAccessToken(null);
306
+ WPAdm_GA_Options::setGACreated(null);
307
+ WPAdm_GA_Options::setGAEnableCode(null);
308
+ WPAdm_GA_Options::setGATypeCode(null);
309
+
310
+ header('location: ' . self::getCurUrl());
311
+
312
+ }
313
+
314
+ protected static function sendRequest($url, array $params) {
315
+ $data = base64_encode(serialize($params));
316
+ $req = array(
317
+ 'data' => $data,
318
+ 'sign' => self::getSignature(get_option('wpadm_ga_pub_key'), $data),
319
+ 'refer'=>self::getCurUrl(),
320
+ );
321
+
322
+
323
+ echo '<!-- start dump --><pre><small>' . __FILE__ . "</small>\n";
324
+ print_r($url);
325
+ echo '</pre><!-- end dump -->';
326
+
327
+ $response = wp_remote_post($url, array(
328
+ 'method' => 'POST',
329
+ 'timeout' => 45,
330
+ 'body' => $req
331
+ ));
332
+
333
+ // if ( is_wp_error( $response ) ) {
334
+ // $error_message = $response->get_error_message();
335
+ // } else {
336
+ // }
337
+
338
+ }
339
+
340
 
341
  protected static function requireFiles() {
342
  require_once( WPADM_GA__PLUGIN_DIR . 'class.wpadm-ga-options.php' );
349
 
350
  }
351
 
352
+ public static function registerPluginStyles() {
353
  wp_register_style( 'wpadm-ga-css', plugins_url(WPADM_GA__PLUGIN_NAME. '/view/scripts/wpadm-ga.css' ) );
354
  wp_enqueue_style( 'wpadm-ga-css' );
355
 
463
  return null;
464
  }
465
 
466
+ protected static function getParamsForRequest($data) {
467
  $params = array(
468
  'data' => $data,
469
  'sign' => self::getSSLSign($data)
472
  return array(REQUEST_PARAM_NAME => base64_encode(serialize($params)));
473
  }
474
 
475
+ protected static function getSSLSign($data) {
476
  $str = md5(serialize($data));
477
  if(function_exists('openssl_public_encrypt')) {
478
  openssl_public_encrypt($str, $sign, get_option('wpadm_ga_pub_key'));
502
  }
503
  }
504
 
505
+ protected static function getSignature($pub_key, $text) {
506
+ if (function_exists('openssl_public_encrypt')) {
507
+ $signature = '';
508
+ openssl_public_encrypt($text, $signature, $pub_key);
509
+ return $signature;
510
+ } else
511
+ {
512
+ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/lib/phpseclib');
513
+ require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib'.DIRECTORY_SEPARATOR . 'phpseclib' . DIRECTORY_SEPARATOR . 'Crypt'.DIRECTORY_SEPARATOR.'RSA.php';
514
+ $rsa = new Crypt_RSA();
515
+ $rsa->loadKey($pub_key);
516
+ $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
517
+ return $rsa->encrypt($text);
518
+ }
519
+ }
520
+
521
  protected static function decodeData($str) {
522
  return json_decode(base64_decode($str), true);
523
  }
readme.txt CHANGED
@@ -1,6 +1,6 @@
1
  === Google Analytics Counter Tracker ===
2
  Plugin Name: Google Analytics Counter Tracker
3
- Version: 3.0.1
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.4
1
  === Google Analytics Counter Tracker ===
2
  Plugin Name: Google Analytics Counter Tracker
3
+ Version: 3.0.3
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.4
view/scripts/wpadm-ga.js CHANGED
@@ -147,53 +147,59 @@ function wpadm_ga_formatError(error) {
147
 
148
  function wpadm_ga_getCache(gapi_object) {
149
 
150
- if (!gapi_object.wc) {
151
- gapi_object.execute();
152
- return;
153
- }
154
-
155
- var query = gapi_object.wc.query;
156
- var object_type = (undefined !== gapi_object.wc.chart) ? 'chart': 'data';
157
 
158
- query['start-index'] = (undefined == query['start-index']) ? 1 : query['start-index'];
159
- query['max-results'] = (undefined == query['max-results']) ? 1000 : query['max-results'];
160
 
161
- var data = {
162
- 'action': 'getCache',
163
 
164
- 'query': query,
165
- 'request_type': 'success',
166
- 'object_type': object_type
167
 
 
 
 
168
 
169
- }
170
- jQuery.post(ajaxurl, data, function(response) {
171
- try{
172
- var res = jQuery.parseJSON(response);
173
- if (res && res.status=='success') {
174
- if (object_type == 'chart') {
175
- if (res.html) {
176
- gapi_object.wc.chart.container.innerHTML = '<div class="gapi-analytics-data-chart">' + res.html + '</div>';
 
 
177
  }
178
- }
179
 
180
- var result = jQuery.parseJSON(res.result);
181
 
182
- if (object_type == 'chart' || object_type == 'data') {
183
- for (i in gapi_object.zt.zt.success) {
184
- var fun = gapi_object.zt.po[gapi_object.zt.zt.success[i] + 1];
185
- if (fun.toString().indexOf('wpadm_ga_setCache') < 0) {
186
- fun(result);
 
187
  }
 
188
  }
189
- return;
190
- }
191
 
192
 
 
 
193
  }
194
- } catch(e) {}
 
 
195
  gapi_object.execute();
196
- });
 
197
  }
198
 
199
  function wpadm_ga_setCache(result, type) {
147
 
148
  function wpadm_ga_getCache(gapi_object) {
149
 
150
+ try {
151
+ if (!gapi_object.wc) {
152
+ gapi_object.execute();
153
+ return;
154
+ }
 
 
155
 
156
+ var query = gapi_object.wc.query;
157
+ var object_type = (undefined !== gapi_object.wc.chart) ? 'chart' : 'data';
158
 
159
+ query['start-index'] = (undefined == query['start-index']) ? 1 : query['start-index'];
160
+ query['max-results'] = (undefined == query['max-results']) ? 1000 : query['max-results'];
161
 
162
+ var data = {
163
+ 'action': 'getCache',
 
164
 
165
+ 'query': query,
166
+ 'request_type': 'success',
167
+ 'object_type': object_type
168
 
169
+
170
+ }
171
+ jQuery.post(ajaxurl, data, function (response) {
172
+ try {
173
+ var res = jQuery.parseJSON(response);
174
+ if (res && res.status == 'success') {
175
+ if (object_type == 'chart') {
176
+ if (res.html) {
177
+ gapi_object.wc.chart.container.innerHTML = '<div class="gapi-analytics-data-chart">' + res.html + '</div>';
178
+ }
179
  }
 
180
 
181
+ var result = jQuery.parseJSON(res.result);
182
 
183
+ if (object_type == 'chart' || object_type == 'data') {
184
+ for (i in gapi_object.zt.zt.success) {
185
+ var fun = gapi_object.zt.po[gapi_object.zt.zt.success[i] + 1];
186
+ if (fun.toString().indexOf('wpadm_ga_setCache') < 0) {
187
+ fun(result);
188
+ }
189
  }
190
+ return;
191
  }
 
 
192
 
193
 
194
+ }
195
+ } catch (e) {
196
  }
197
+ gapi_object.execute();
198
+ });
199
+ } catch (e) {
200
  gapi_object.execute();
201
+ }
202
+
203
  }
204
 
205
  function wpadm_ga_setCache(result, type) {
view/settings_ga_account.php CHANGED
@@ -73,6 +73,10 @@ if($type == 'empty_token') {
73
  <button type="submit" class="btn btn-success">Save</button>
74
  </div>
75
  </div>
 
 
 
 
76
  </form>
77
  </div>
78
  </div>
73
  <button type="submit" class="btn btn-success">Save</button>
74
  </div>
75
  </div>
76
+
77
+ <hr>
78
+ Status: <span style="color: green; font-weight: bold; margin-right: 50px; ">connected</span><button type="submit" name="ga-disconnect-btn" value="disconnect" class="btn btn-link" onclick="return confirm('Are you sure you want to disconnect from your Google Analytics account?');">Disconnect your Google Analytics Account</button>
79
+
80
  </form>
81
  </div>
82
  </div>