| @@ -132,10 +132,10 @@ | ||
| 132 | 132 | * constructor |
| 133 | 133 | */ |
| 134 | 134 | private function __construct() { |
| 135 | 135 | $this->_php_version = phpversion(); |
| 136 | - $this->_timestamp = $this->_php_version >= 5.1 ? $_SERVER[ 'REQUEST_TIME' ] : time(); | |
| 137 | - $this->_json[ 'request_uri' ] = $_SERVER[ 'REQUEST_URI' ]; | |
| 136 | + $this->_timestamp = $this->_php_version >= 5.1 ? sanitize_text_field($_SERVER[ 'REQUEST_TIME' ]) : time(); | |
| 137 | + $this->_json[ 'request_uri' ] = sanitize_text_field($_SERVER[ 'REQUEST_URI' ]); | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * gets instance of this class |
| @@ -387,9 +387,21 @@ | ||
| 387 | 387 | * @param array $data |
| 388 | 388 | * @return string |
| 389 | 389 | */ |
| 390 | 390 | protected function _encode( $data ) { |
| 391 | - return base64_encode( utf8_encode( json_encode( $data ) ) ); | |
| 391 | + if ( function_exists('mb_convert_encoding') ) { | |
| 392 | + $encoded = json_encode($data); | |
| 393 | + | |
| 394 | + if ( $encoded !== false ) { | |
| 395 | + $utf8 = mb_convert_encoding($encoded, 'UTF-8', 'UTF-8'); | |
| 396 | + | |
| 397 | + if ($utf8 !== false) { | |
| 398 | + return base64_encode($utf8); | |
| 399 | + } | |
| 400 | + } | |
| 401 | + } | |
| 402 | + | |
| 403 | + return false; | |
| 392 | 404 | } |
| 393 | 405 | |
| 394 | 406 | /** |
| 395 | 407 | * adds a setting |