Permalink
Browse files

Update all usages of son

Changed all json_(smf_de|en)code\(  to $smcFunc['json_\2code']
Hopefully ensured $smcFunc is global in said functions

Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
  • Loading branch information...
jdarwood007 committed Jul 5, 2017
1 parent 2e08ece commit 9278d8ce56b3e07efb6dff89595246008d2e4ae1
Showing with 246 additions and 220 deletions.
  1. +2 −2 Sources/Admin.php
  2. +2 −2 Sources/Attachments.php
  3. +4 −4 Sources/Calendar.php
  4. +5 −5 Sources/Drafts.php
  5. +9 −2 Sources/Errors.php
  6. +1 −1 Sources/Groups.php
  7. +4 −2 Sources/Likes.php
  8. +17 −14 Sources/Load.php
  9. +4 −8 Sources/LogInOut.php
  10. +2 −2 Sources/Logging.php
  11. +21 −21 Sources/ManageAttachments.php
  12. +2 −2 Sources/ManageMembers.php
  13. +6 −6 Sources/ManagePaid.php
  14. +3 −3 Sources/ManageSearch.php
  15. +2 −2 Sources/ManageSearchEngines.php
  16. +4 −4 Sources/ManageServer.php
  17. +3 −3 Sources/ManageSettings.php
  18. +1 −1 Sources/ManageSmileys.php
  19. +2 −2 Sources/Memberlist.php
  20. +8 −8 Sources/ModerationCenter.php
  21. +3 −3 Sources/Modlog.php
  22. +1 −1 Sources/News.php
  23. +37 −19 Sources/Packages.php
  24. +5 −5 Sources/PersonalMessage.php
  25. +6 −6 Sources/Profile-Actions.php
  26. +3 −3 Sources/Profile-Modify.php
  27. +2 −2 Sources/Profile-View.php
  28. +1 −1 Sources/Recent.php
  29. +2 −2 Sources/RemoveTopic.php
  30. +2 −2 Sources/ReportToMod.php
  31. +3 −3 Sources/ScheduledTasks.php
  32. +4 −4 Sources/SearchAPI-Custom.php
  33. +1 −1 Sources/Subs-Admin.php
  34. +13 −13 Sources/Subs-Attachments.php
  35. +6 −6 Sources/Subs-Auth.php
  36. +1 −1 Sources/Subs-Calendar.php
  37. +1 −1 Sources/Subs-Charset.php
  38. +3 −3 Sources/Subs-Editor.php
  39. +1 −1 Sources/Subs-Members.php
  40. +1 −1 Sources/Subs-MembersOnline.php
  41. +2 −2 Sources/Subs-Menu.php
  42. +8 −8 Sources/Subs-Post.php
  43. +1 −1 Sources/Subs-ReportedContent.php
  44. +2 −2 Sources/Subs-Themes.php
  45. +5 −5 Sources/Subs.php
  46. +2 −2 Sources/Themes.php
  47. +4 −4 Sources/Who.php
  48. +1 −1 Sources/tasks/ApprovePost-Notify.php
  49. +1 −1 Sources/tasks/ApproveReply-Notify.php
  50. +1 −1 Sources/tasks/Birthday-Notify.php
  51. +5 −5 Sources/tasks/CreatePost-Notify.php
  52. +1 −1 Sources/tasks/EventNew-Notify.php
  53. +1 −1 Sources/tasks/GroupAct-Notify.php
  54. +1 −1 Sources/tasks/GroupReq-Notify.php
  55. +1 −1 Sources/tasks/MemberReport-Notify.php
  56. +1 −1 Sources/tasks/MemberReportReply-Notify.php
  57. +1 −1 Sources/tasks/MsgReport-Notify.php
  58. +1 −1 Sources/tasks/MsgReportReply-Notify.php
  59. +3 −3 Themes/default/Packages.template.php
  60. +2 −2 cron.php
  61. +1 −1 other/buildTools
  62. +3 −3 subscriptions.php
View
@@ -25,7 +25,7 @@
function AdminMain()
{
global $txt, $context, $scripturl, $modSettings, $settings;
global $sourcedir, $options, $boarddir;
global $smcFunc, $sourcedir, $options, $boarddir;
// Load the language and templates....
loadLanguage('Admin');
@@ -39,7 +39,7 @@ function AdminMain()
require_once($sourcedir . '/Subs-Menu.php');
// Some preferences.
$context['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array();
$context['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
/** @var array $admin_areas Defines the menu structure for the admin center. See {@link Subs-Menu.php Subs-Menu.php} for details! */
$admin_areas = array(
View
@@ -422,7 +422,7 @@ protected function setResponse($data = array())
protected function sendResponse()
{
global $modSettings, $context;
global $smcFunc, $modSettings, $context;
ob_end_clean();
@@ -435,7 +435,7 @@ protected function sendResponse()
// Set the header.
header('Content-Type: application/json; charset='. $context['character_set'] .'');
echo json_encode($this->_response ? $this->_response : array());
echo $smcFunc['json_encode']($this->_response ? $this->_response : array());
// Done.
obExit(false);
View
@@ -647,7 +647,7 @@ function iCalDownload()
*/
function clock()
{
global $settings, $context, $scripturl;
global $smcFunc, $settings, $context, $scripturl;
$context['onimg'] = $settings['images_url'] . '/bbc/bbc_bg.png';
$context['offimg'] = $settings['images_url'] . '/bbc/bbc_hoverbg.png';
@@ -668,19 +668,19 @@ function clock()
{
$context['sub_template'] = 'bcd';
$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
$context['clockicons'] = smf_json_decode(base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true);
$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true);
}
elseif (!$omfg && !isset($_REQUEST['time']))
{
$context['sub_template'] = 'hms';
$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
$context['clockicons'] = smf_json_decode(base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true);
$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true);
}
elseif ($omfg)
{
$context['sub_template'] = 'omfg';
$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
$context['clockicons'] = smf_json_decode(base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true);
$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true);
}
elseif (isset($_REQUEST['time']))
{
View
@@ -206,7 +206,7 @@ function SavePMDraft(&$post_errors, $recipientList)
$recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array();
}
elseif (!empty($draft_info['to_list']) && empty($recipientList))
$recipientList = smf_json_decode($draft_info['to_list'], true);
$recipientList = $smcFunc['json_decode']($draft_info['to_list'], true);
// prepare the data we got from the form
$reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to'];
@@ -238,7 +238,7 @@ function SavePMDraft(&$post_errors, $recipientList)
'subject' => $draft['subject'],
'body' => $draft['body'],
'id_pm_draft' => $id_pm_draft,
'to_list' => json_encode($recipientList),
'to_list' => $smcFunc['json_encode']($recipientList),
)
);
@@ -267,7 +267,7 @@ function SavePMDraft(&$post_errors, $recipientList)
$user_info['id'],
$draft['subject'],
$draft['body'],
json_encode($recipientList),
$smcFunc['json_encode']($recipientList),
),
array(
'id_draft'
@@ -366,7 +366,7 @@ function ReadDraft($id_draft, $type = 0, $check = true, $load = false)
$_REQUEST['message'] = !empty($draft_info['body']) ? str_replace('<br>', "\n", un_htmlspecialchars(stripslashes($draft_info['body']))) : '';
$_REQUEST['replied_to'] = !empty($draft_info['id_reply']) ? $draft_info['id_reply'] : 0;
$context['id_pm_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0;
$recipients = smf_json_decode($draft_info['to_list'], true);
$recipients = $smcFunc['json_decode']($draft_info['to_list'], true);
// make sure we only have integers in this array
$recipients['to'] = array_map('intval', $recipients['to']);
@@ -785,7 +785,7 @@ function showPMDrafts($memID = -1)
'to' => array(),
'bcc' => array(),
);
$recipient_ids = (!empty($row['to_list'])) ? smf_json_decode($row['to_list'], true) : array();
$recipient_ids = (!empty($row['to_list'])) ? $smcFunc['json_decode']($row['to_list'], true) : array();
// @todo ... this is a bit ugly since it runs an extra query for every message, do we want this?
// at least its only for draft PM's and only the user can see them ... so not heavily used .. still
View
@@ -502,8 +502,15 @@ function log_error_online($error, $sprintf = array())
);
if ($smcFunc['db_num_rows']($request) != 0)
{
// If this happened very early on in SMF startup, $smcFunc may not fully be defined.
if (!isset($smcFunc['json_decode']))
{
$smcFunc['json_decode'] = 'smf_json_decode';
$smcFunc['json_encode'] = 'json_encode';
}
list ($url) = $smcFunc['db_fetch_row']($request);
$url = smf_json_decode($url, true);
$url = $smcFunc['json_decode']($url, true);
$url['error'] = $error;
if (!empty($sprintf))
@@ -514,7 +521,7 @@ function log_error_online($error, $sprintf = array())
SET url = {string:url}
WHERE session = {string:session}',
array(
'url' => json_encode($url),
'url' => $smcFunc['json_encode']($url),
'session' => $session_id,
)
);
View
@@ -527,7 +527,7 @@ function GroupRequests()
$smcFunc['db_free_result']($request);
// Add a background task to handle notifying people of this request
$data = json_encode(array('member_id' => $user_info['id'], 'member_ip' => $user_info['ip'], 'request_list' => $request_list, 'status' => $_POST['req_action'], 'reason' => isset($_POST['groupreason']) ? $_POST['groupreason'] : '', 'time' => time()));
$data = $smcFunc['json_encode'](array('member_id' => $user_info['id'], 'member_ip' => $user_info['ip'], 'request_list' => $request_list, 'status' => $_POST['req_action'], 'reason' => isset($_POST['groupreason']) ? $_POST['groupreason'] : '', 'time' => time()));
$smcFunc['db_insert']('insert', '{db_prefix}background_tasks',
array('task_file' => 'string-255', 'task_class' => 'string-255', 'task_data' => 'string', 'claimed_time' => 'int'),
array('$sourcedir/tasks/GroupAct-Notify.php', 'GroupAct_Notify_Background', $data, 0), array()
View
@@ -326,7 +326,7 @@ protected function insert()
$smcFunc['db_insert']('insert',
'{db_prefix}background_tasks',
array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array(
array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array(
'content_id' => $content,
'content_type' => $type,
'sender_id' => $user['id'],
@@ -605,6 +605,8 @@ protected function response()
*/
protected function jsonResponse()
{
global $smcFunc;
$print = array(
'data' => $this->_data,
);
@@ -622,7 +624,7 @@ protected function jsonResponse()
call_integration_hook('integrate_likes_json_response', array(&$print));
// Print the data.
smf_serverResponse(json_encode($print));
smf_serverResponse($smcFunc['json_encode']($print));
die;
}
}
View
@@ -62,6 +62,7 @@ function reloadSettings()
if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
$modSettings['defaultMaxListItems'] = 15;
// We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded.
if (!is_array($modSettings['attachmentUploadDir']))
$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
@@ -218,6 +219,8 @@ function reloadSettings()
$words[$i] = $smcFunc['ucfirst']($words[$i]);
return implode('', $words);
} : 'ucwords',
'json_decode' => 'smf_json_decode',
'json_encode' => 'json_encode',
);
// Setting the timezone is a requirement for some functions.
@@ -275,15 +278,15 @@ function reloadSettings()
if (empty($modSettings['currentAttachmentUploadDir']))
{
updateSettings(array(
'attachmentUploadDir' => json_encode(array(1 => $modSettings['attachmentUploadDir'])),
'attachmentUploadDir' => $smcFunc['json_encode'](array(1 => $modSettings['attachmentUploadDir'])),
'currentAttachmentUploadDir' => 1,
));
}
// Integration is cool.
if (defined('SMF_INTEGRATION_SETTINGS'))
{
$integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true);
$integration_settings = $smcFUnc['json_decode'](SMF_INTEGRATION_SETTINGS, true);
foreach ($integration_settings as $hook => $function)
add_integration_function($hook, $function, '', false);
}
@@ -406,7 +409,7 @@ function loadUserSettings()
if (empty($id_member) && isset($_COOKIE[$cookiename]))
{
$cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false);
$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
if (empty($cookie_data))
$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
@@ -417,7 +420,7 @@ function loadUserSettings()
elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
{
// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
$cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]);
$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
if (empty($cookie_data))
$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
@@ -488,7 +491,7 @@ function loadUserSettings()
{
if (!empty($_COOKIE[$tfacookie]))
{
$tfa_data = smf_json_decode($_COOKIE[$tfacookie]);
$tfa_data = $smcFunc['json_decode']($_COOKIE[$tfacookie]);
list ($tfamember, $tfasecret) = $tfa_data;
@@ -642,7 +645,7 @@ function loadUserSettings()
// Expire the 2FA cookie
if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
{
$tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true);
$tfa_data = $smcFunc['json_decode']($_COOKIE[$cookiename . '_tfa'], true);
list ($id, $user, $exp, $state, $preserve) = $tfa_data;
@@ -1529,7 +1532,7 @@ function loadMemberContext($user, $display_custom_fields = false)
$memberContext[$user]['custom_fields'] = array();
if (!isset($context['display_fields']))
$context['display_fields'] = smf_json_decode($modSettings['displayFields'], true);
$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
foreach ($context['display_fields'] as $custom)
{
@@ -2820,7 +2823,7 @@ function getLanguages($use_cache = true)
$language_directories = array_unique($language_directories);
// Get a list of languages.
$langList = !empty($modSettings['langList']) ? json_decode($modSettings['langList'], true) : array();
$langList = !empty($modSettings['langList']) ? $smcFunc['json_decode']($modSettings['langList'], true) : array();
$langList = is_array($langList) ? $langList : false;
$catchLang = array();
@@ -2883,7 +2886,7 @@ function getLanguages($use_cache = true)
// Do we need to store the lang list?
if (empty($langList))
updateSettings(array('langList' => json_encode($catchLang)));
updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
// Let's cash in on this deal.
if (!empty($modSettings['cache_enable']))
@@ -3315,7 +3318,7 @@ function cache_quick_get($key, $file, $function, $params, $level = 1)
*/
function cache_put_data($key, $value, $ttl = 120)
{
global $cache_enable, $cacheAPI;
global $smcFunc, $cache_enable, $cacheAPI;
global $cache_hits, $cache_count, $db_show_debug;
if (empty($cache_enable) || empty($cacheAPI))
@@ -3324,12 +3327,12 @@ function cache_put_data($key, $value, $ttl = 120)
$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
if (isset($db_show_debug) && $db_show_debug === true)
{
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen(json_encode($value)));
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'put', 's' => $value === null ? 0 : strlen($smcFunc['json_encode']($value)));
$st = microtime();
}
// The API will handle the rest.
$value = $value === null ? null : json_encode($value);
$value = $value === null ? null : $smcFunc['json_encode']($value);
$cacheAPI->putData($key, $value, $ttl);
if (function_exists('call_integration_hook'))
@@ -3350,7 +3353,7 @@ function cache_put_data($key, $value, $ttl = 120)
*/
function cache_get_data($key, $ttl = 120)
{
global $cache_enable, $cacheAPI;
global $smcFunc, $cache_enable, $cacheAPI;
global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
if (empty($cache_enable) || empty($cacheAPI))
@@ -3385,7 +3388,7 @@ function cache_get_data($key, $ttl = 120)
if (function_exists('call_integration_hook') && isset($value))
call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
return empty($value) ? null : smf_json_decode($value, true);
return empty($value) ? null : $smcFunc['json_decode']($value, true);
}
/**
View
@@ -99,15 +99,15 @@ function Login2()
{
if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d{1,7};i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$cookiename]) === 1)
{
list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true);
list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
// That didn't work... Maybe it's using serialize?
if (is_null($timeout))
list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
}
elseif (isset($_SESSION['login_' . $cookiename]))
{
list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]);
list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
// Try for old format
if (is_null($timeout))
@@ -122,16 +122,12 @@ function Login2()
// Preserve the 2FA cookie?
if (!empty($modSettings['tfa_mode']) && !empty($_COOKIE[$cookiename . '_tfa']))
{
$tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true);
// If that didn't work, try unserialize instead...
if (is_null($tfadata))
$tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']);
$tfadata = $smcFunc['json_decode']($_COOKIE[$cookiename . '_tfa'], true);
list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata;
// If we're preserving the cookie, reset it with updated salt
if ($preserve && time() < $exp)
if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp)
setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true);
else
setTFACookie(-3600, 0, '');
View
@@ -81,7 +81,7 @@ function writeLog($force = false)
$context['session_var'] = $_SESSION['session_var'];
unset($encoded_get['sesc'], $encoded_get[$context['session_var']]);
$encoded_get = json_encode($encoded_get);
$encoded_get = $smcFunc['json_encode']($encoded_get);
}
else
$encoded_get = '';
@@ -541,7 +541,7 @@ function logActions($logs)
$inserts[] = array(
time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
$board_id, $topic_id, $msg_id, json_encode($log['extra']),
$board_id, $topic_id, $msg_id, $smcFunc['json_encode']($log['extra']),
);
}
Oops, something went wrong.

0 comments on commit 9278d8c

Please sign in to comment.