From 48bce3074b47df078b835715be88e9ad78c02d73 Mon Sep 17 00:00:00 2001 From: Tim Coombs Date: Wed, 12 Aug 2015 14:57:00 +1000 Subject: Update Useragent to Win8.1 and FF36 --- inc/poche/Tools.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 9c748391..e5e150cd 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -141,7 +141,7 @@ final class Tools public static function getFile($url) { $timeout = 15; - $useragent = "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"; + $useragent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0"; if (in_array ('curl', get_loaded_extensions())) { # Fetch feed from URL -- cgit v1.2.3 From 206c2a734e2a0d100af6d772d90b01c5cb8fe870 Mon Sep 17 00:00:00 2001 From: Eric Fredj Date: Tue, 5 Apr 2016 16:30:08 +0200 Subject: Fix UTF-8 encoding before JSON export --- inc/poche/Tools.class.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index e5e150cd..d84850cf 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -232,6 +232,27 @@ final class Tools exit(); } + /** + * UTF-8 encode array of string + * + * @param $data + */ + public static function utf8ize($data) + { + if (is_array($data)) + { + foreach ($data as $k => $v) + { + $data[$k] = self::utf8ize($v); + } + } + else if (is_string ($data)) + { + return utf8_encode($data); + } + return $data; + } + /** * Create new line in log file * -- cgit v1.2.3 From ccf59ac4fff1f66b312828cffbbb7090ef72d528 Mon Sep 17 00:00:00 2001 From: Eric Fredj Date: Tue, 5 Apr 2016 20:07:55 +0200 Subject: Fix indentation --- inc/poche/Tools.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index d84850cf..3f68cff5 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -239,7 +239,7 @@ final class Tools */ public static function utf8ize($data) { - if (is_array($data)) + if (is_array($data)) { foreach ($data as $k => $v) { -- cgit v1.2.3 From 7672a10776136842906e4f34e3ced0d7286f1c4a Mon Sep 17 00:00:00 2001 From: Ymage Date: Thu, 7 Apr 2016 22:35:37 +0200 Subject: Apply utf8_encode only on unrecognized encoded string --- inc/poche/Tools.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 3f68cff5..2ee86c74 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -237,18 +237,25 @@ final class Tools * * @param $data */ - public static function utf8ize($data) + public static function utf8ize($data) { - if (is_array($data)) + if (is_array($data)) { - foreach ($data as $k => $v) + foreach ($data as $k => $v) { $data[$k] = self::utf8ize($v); } } - else if (is_string ($data)) + else if (is_string ($data)) { - return utf8_encode($data); + if ('' == mb_detect_encoding($data)) + { + return utf8_encode($data); + } + else + { + return $data; + } } return $data; } -- cgit v1.2.3 From af8b3b649e9956fe15c98298faf6755c29edcf77 Mon Sep 17 00:00:00 2001 From: Ymage Date: Thu, 7 Apr 2016 22:49:15 +0200 Subject: Factorize --- inc/poche/Tools.class.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'inc/poche/Tools.class.php') diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 2ee86c74..263034f0 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -239,23 +239,16 @@ final class Tools */ public static function utf8ize($data) { - if (is_array($data)) + if (is_array($data)) { foreach ($data as $k => $v) { $data[$k] = self::utf8ize($v); } } - else if (is_string ($data)) + else if (is_string ($data) && '' == mb_detect_encoding($data)) { - if ('' == mb_detect_encoding($data)) - { - return utf8_encode($data); - } - else - { - return $data; - } + return utf8_encode($data); } return $data; } -- cgit v1.2.3