Permalink
Browse files

Fixed empty country in Statistics if country is unknown

Fixed fetching year's statistics without checking if they exist first
  • Loading branch information...
1 parent d8819e3 commit cfdedf5ad38bcdd979be2797a7e0affd9eaf47cf @Myatu committed May 23, 2012
Showing with 22 additions and 8 deletions.
  1. +11 −6 app/Myatu/WordPress/Cookillian/Main.php
  2. +1 −1 cookillian.php
  3. +5 −0 readme.txt
  4. +5 −1 resources/views/stats.html.twig
@@ -565,7 +565,7 @@ public function addStat($type)
break;
}
- // Return the updated stats back to where they belong
+ // Return thde updated stats back to where they belong
$stats[$year][$month][$remote_country] = $country_stats;
// And save
@@ -578,6 +578,11 @@ public function addStat($type)
public function processResponse($answer)
{
$opt_in_or_out = '';
+ $redir_url = add_query_arg(array(
+ '__r' => substr(md5(time() . rand()), 0, 8),
+ $this->short_name . static::RESP_ID => false,
+
+ ));
switch ($answer) {
case 2 :
@@ -586,7 +591,7 @@ public function processResponse($answer)
setcookie($this->short_name . static::OPTOUT_ID, '', time() - 3600, '/');
// Send the visitor back now
- if (isset($_SERVER['HTTP_REFERER'])) { wp_redirect($_SERVER['HTTP_REFERER']); die(); }
+ wp_redirect($redir_url); die();
break;
@@ -611,7 +616,7 @@ public function processResponse($answer)
Cookies::set($opt_in_or_out, 1, strtotime(static::COOKIE_LIFE), true, false, '/');
// And send the visitor back to where they were, if possible
- if (isset($_SERVER['HTTP_REFERER'])) { wp_redirect($_SERVER['HTTP_REFERER']); die(); }
+ wp_redirect($redir_url); die();
}
/**
@@ -663,7 +668,7 @@ protected function handleFileUpload($upload)
WP_Filesystem();
// Create a working directory to extract file(s) to
- $temp_dir = \Pf4wp\Storage\StoragePath::validate(trailingslashit(realpath(sys_get_temp_dir())) . 'cookillian_' . substr(md5(time() . rand()), 8), false);
+ $temp_dir = \Pf4wp\Storage\StoragePath::validate(trailingslashit(realpath(sys_get_temp_dir())) . 'cookillian_' . substr(md5(time() . rand()), 0, 8), false);
// If we have a valid working directory and could extract the ZIP file, look at the contents
if ($temp_dir && unzip_file($upload['file'], $temp_dir)) {
@@ -1336,8 +1341,8 @@ public function onStatsMenu()
$vars = array(
'year' => $year,
- 'years' => $years,
- 'stats' => $stats[$year],
+ 'years' => (!empty($years)) ? $years : array($year),
+ 'stats' => (isset($stats[$year])) ? $stats[$year] : array(),
'countries' => $this->getCountries(),
);
View
@@ -3,7 +3,7 @@
Plugin Name: Cookillian
Plugin URI: http://www.myatus.com/2012/05/05/cookillian/
Description: Provides extensible support for EU/UK compliance of the EC Cookie Directive (2009/136/EC), based on a visitor's location.
-Version: 1.0.17.1
+Version: 1.0.17.1-dev20
Author: Mike Green (Myatu)
Author URI: http://www.myatus.com/
*/
View
@@ -63,6 +63,11 @@ with PHP versions older than 5.3.
== Changelog ==
+= 1.0.20 =
+* Fixed: Fixed a bug that overwrote existing cookies from the __Cookies__ listing
+* Fixed: Added a method for avoiding cached reloads of the visiting page, after a visitor answered the alert, to avoid alert from showing again
+* Changed: On JavaScript-enabled browsers, the _Delete_ box has been replaced by a _Remove_ button in the __Cookies__ listing
+
= 1.0.17.1 (22 May 2012) =
* Fixed: Fixed bug that caused the plugin from operating on certain systems
@@ -44,9 +44,13 @@
{% set total_display = total_display + country_stat.0 %}
{% set total_optin = total_optin + country_stat.1 %}
{% set total_optout = total_optout + country_stat.2 %}
+ {% set country_name = countries[country_abbr].country %}
+ {% if country_name is empty %}
+ {% set country_name = 'Unknown' %}
+ {% endif %}
<tr>
- <td>{{ countries[country_abbr].country }}</td>
+ <td>{{ country_name }}</td>
<td>{{ country_stat.0 }}</td>
<td>{{ country_stat.1 }}</td>
<td>{{ country_stat.2 }}</td>

0 comments on commit cfdedf5

Please sign in to comment.