diff --git a/ajax.php b/ajax.php index 0f40f474d..b0d3e8b0b 100644 --- a/ajax.php +++ b/ajax.php @@ -249,7 +249,7 @@ class ajax_common } } - $response_js = bb_json_encode($this->response); + $response_js = Zend\Json\Json::encode($this->response); if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { diff --git a/library/ajax/change_user_opt.php b/library/ajax/change_user_opt.php index 5cf33d2ef..c5ab0fbf1 100644 --- a/library/ajax/change_user_opt.php +++ b/library/ajax/change_user_opt.php @@ -5,7 +5,7 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $bf, $lang; $user_id = (int) $this->request['user_id']; -$new_opt = bb_json_decode($this->request['user_opt']); +$new_opt = Zend\Json\Json::decode($this->request['user_opt']); if (!$user_id OR !$u_data = get_userdata($user_id)) { diff --git a/library/config.php b/library/config.php index 2e7d35932..8a8d94565 100644 --- a/library/config.php +++ b/library/config.php @@ -72,8 +72,8 @@ $domain_name = 'torrentpier.me'; // enter here your primary domain name of your $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $domain_name; // Version info -$bb_cfg['tp_version'] = '2.1.4'; -$bb_cfg['tp_release_date'] = '26-11-2014'; +$bb_cfg['tp_version'] = '2.1.5'; +$bb_cfg['tp_release_date'] = '**-12-2014'; $bb_cfg['tp_release_state'] = 'ALPHA'; $bb_cfg['tp_zf_version'] = '2.3.3'; diff --git a/library/includes/functions.php b/library/includes/functions.php index 96dc8bb83..123b9e893 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2287,7 +2287,7 @@ function get_poll_data_items_js ($topic_id) } foreach ($items as $k => $v) { - $items[$k] = php2js($v); + $items[$k] = Zend\Json\Json::encode($v); } return is_array($topic_id) ? $items : $items[$topic_id]; @@ -2296,7 +2296,7 @@ function get_poll_data_items_js ($topic_id) function poll_is_active ($t_data) { global $bb_cfg; - return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $bb_cfg['poll_max_days']*86400); + return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $bb_cfg['poll_max_days'] * 86400); } function print_confirmation ($tpl_vars) @@ -2373,86 +2373,6 @@ function caching_output ($enabled, $mode, $cache_var_name, $ttl = 300) } } -// -// Ajax -// -/** - * Encode PHP var to JSON (PHP -> JS) - */ -function bb_json_encode ($data) -{ - return json_encode($data); -} - -/** - * Decode JSON to PHP (JS -> PHP) - */ -function bb_json_decode ($data) -{ - if (!is_string($data)) trigger_error('invalid argument for '. __FUNCTION__, E_USER_ERROR); - return json_decode($data, true); -} - -/** - * -- from JsHttpRequest -- - * Convert a PHP scalar, array or hash to JS scalar/array/hash. This function is - * an analog of json_encode(), but it can work with a non-UTF8 input and does not - * analyze the passed data. Output format must be fully JSON compatible. - * - * @param mixed $a Any structure to convert to JS. - * @return string JavaScript equivalent structure. - */ -function php2js ($a = false) -{ - if (is_null($a)) return 'null'; - if ($a === false) return 'false'; - if ($a === true) return 'true'; - if (is_scalar($a)) - { - if (is_float($a)) - { - // Always use "." for floats. - $a = str_replace(",", ".", strval($a)); - } - // All scalars are converted to strings to avoid indeterminism. - // PHP's "1" and 1 are equal for all PHP operators, but - // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend, - // we should get the same result in the JS frontend (string). - // Character replacements for JSON. - static $jsonReplaces = array( - array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), - array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), - ); - return '"'. str_replace($jsonReplaces[0], $jsonReplaces[1], $a) .'"'; - } - $isList = true; - for ($i = 0, reset($a); $i < count($a); $i++, next($a)) - { - if (key($a) !== $i) - { - $isList = false; - break; - } - } - $result = array(); - if ($isList) - { - foreach ($a as $v) - { - $result[] = php2js($v); - } - return '[ '. join(', ', $result) .' ]'; - } - else - { - foreach ($a as $k => $v) - { - $result[] = php2js($k) .': '. php2js($v); - } - return '{ '. join(', ', $result) .' }'; - } -} - function clean_title ($str, $replace_underscore = false) { $str = ($replace_underscore) ? str_replace('_', ' ', $str) : $str; diff --git a/library/includes/page_header.php b/library/includes/page_header.php index 17eaf93a3..3c6741eca 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -118,7 +118,7 @@ $template->assign_vars(array( 'USER_LANG' => $userdata['user_lang'], 'INCLUDE_BBCODE_JS' => !empty($page_cfg['include_bbcode_js']), - 'USER_OPTIONS_JS' => (IS_GUEST) ? '{}' : bb_json_encode($user->opt_js), + 'USER_OPTIONS_JS' => (IS_GUEST) ? '{}' : Zend\Json\Json::encode($user->opt_js), 'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), diff --git a/library/includes/sessions.php b/library/includes/sessions.php index 8442d27e5..a7e5b62c0 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -671,7 +671,7 @@ class user_common } else if (!empty($_COOKIE['opt_js'])) { - $opt_js = bb_json_decode($_COOKIE['opt_js']); + $opt_js = Zend\Json\Json::decode($_COOKIE['opt_js']); if (is_array($opt_js)) { diff --git a/library/includes/ucp/viewprofile.php b/library/includes/ucp/viewprofile.php index 99ac117fc..84ab4e7fc 100644 --- a/library/includes/ucp/viewprofile.php +++ b/library/includes/ucp/viewprofile.php @@ -190,7 +190,7 @@ else if (IS_ADMIN) { - $ajax_user_opt = bb_json_encode(array( + $ajax_user_opt = Zend\Json\Json::encode(array( 'dis_avatar' => bf($profiledata['user_opt'], 'user_opt', 'dis_avatar'), 'dis_sig' => bf($profiledata['user_opt'], 'user_opt', 'dis_sig'), 'dis_passkey' => bf($profiledata['user_opt'], 'user_opt', 'dis_passkey'),