Skip to content

Commit

Permalink
no more eval
Browse files Browse the repository at this point in the history
Signed-off-by: John Rayes <[email protected]>
  • Loading branch information
live627 committed Dec 10, 2023
1 parent 908c47d commit b03480c
Show file tree
Hide file tree
Showing 24 changed files with 269 additions and 431 deletions.
5 changes: 2 additions & 3 deletions Themes/default/Admin.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function template_admin()
echo '
<script>
var oAdminIndex = new smf_AdminIndex({
sSelf: \'oAdminCenter\',
bLoadAnnouncements: true,
sAnnouncementTemplate: ', Utils::JavaScriptEscape('
Expand Down Expand Up @@ -696,7 +695,7 @@ function doAutoSubmit()
document.forms.autoSubmit.cont.value = "', Lang::$txt['not_done_continue'], ' (" + countdown + ")";
countdown--;
setTimeout("doAutoSubmit();", 1000);
setTimeout(doAutoSubmit, 1000);
}
</script>';
}
Expand Down Expand Up @@ -1487,7 +1486,7 @@ function doAutoSubmit()
document.forms.recount_form.recount_now.value = "', Lang::$txt['errors_recount_now'], ' (" + countdown + ")";
countdown--;
setTimeout("doAutoSubmit();", 1000);
setTimeout(doAutoSubmit, 1000);
}
</script>';
}
Expand Down
6 changes: 3 additions & 3 deletions Themes/default/Calendar.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ function update()
else
icons[i].src = "', Utils::$context['onimg'], '";
window.setTimeout("update();", 500);
window.setTimeout(update, 500);
}
// Checks for variable in theArray.
function in_array(variable, theArray)
Expand Down Expand Up @@ -1078,7 +1078,7 @@ function update()
else
icons[i].src = "', Utils::$context['onimg'], '";
window.setTimeout("update();", 500);
window.setTimeout(update, 500);
}
// Checks for variable in theArray.
function in_array(variable, theArray)
Expand Down Expand Up @@ -1171,7 +1171,7 @@ function update()
else
icons[i].src = "', Utils::$context['onimg'], '";
window.setTimeout("update();", 500);
window.setTimeout(update, 500);
}
// Checks for variable in theArray.
function in_array(variable, theArray)
Expand Down
3 changes: 0 additions & 3 deletions Themes/default/Display.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ function template_main()
{
echo '
var oInTopicModeration = new InTopicModeration({
sSelf: \'oInTopicModeration\',
sCheckboxContainerMask: \'in_topic_mod_check_\',
aMessageIds: [\'', implode('\', \'', Utils::$context['removableMessageIDs']), '\'],
sSessionId: smf_session_id,
Expand All @@ -362,7 +361,6 @@ function template_main()
// Add it to the mobile button strip as well
echo '
var oInTopicModerationMobile = new InTopicModeration({
sSelf: \'oInTopicModerationMobile\',
sCheckboxContainerMask: \'in_topic_mod_check_\',
aMessageIds: [\'', implode('\', \'', Utils::$context['removableMessageIDs']), '\'],
sSessionId: smf_session_id,
Expand Down Expand Up @@ -1020,7 +1018,6 @@ function insertQuoteFast(messageid)
echo '
<script>
var oDraftAutoSave = new smf_DraftAutoSave({
sSelf: \'oDraftAutoSave\',
sLastNote: \'draft_lastautosave\',
sLastID: \'id_draft\',', !empty(Utils::$context['post_box_name']) ? '
sSceditorID: \'' . Utils::$context['post_box_name'] . '\',' : '', '
Expand Down
1 change: 0 additions & 1 deletion Themes/default/GenericControls.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function template_control_richedit_buttons($editor_id)
</span>
<script>
var oDraftAutoSave = new smf_DraftAutoSave({
sSelf: \'oDraftAutoSave\',
sLastNote: \'draft_lastautosave\',
sLastID: \'id_draft\',
sSceditorID: \'', $editor_id, '\',
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/ManageAttachments.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function template_maintenance()
</form>
<script>
function start_progress() {
setTimeout(\'show_msg()\', 1000);
setTimeout(show_msg, 1000);
}
function show_msg() {
Expand All @@ -197,7 +197,7 @@ function show_msg() {
function show_progress() {
$(\'#show_progress\').on("load", "progress.php");
setTimeout(\'show_progress()\', 1500);
setTimeout(show_progress, 1500);
}
</script>
Expand Down
12 changes: 0 additions & 12 deletions Themes/default/ManageBans.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,14 @@ function template_ban_edit()
if (Utils::$context['ban']['is_new'] && empty($_REQUEST['u']))
echo '
var oAddMemberSuggest = new smc_AutoSuggest({
sSelf: \'oAddMemberSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'user\',
sControlId: \'user\',
sSearchType: \'member\',
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
bItemList: false
});
function onUpdateName(oAutoSuggest)
{
document.getElementById(\'user_check\').checked = true;
return true;
}
oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');';

echo '
function confirmBan(aForm)
{
if (aForm.ban_name.value == \'\')
Expand Down Expand Up @@ -316,14 +306,12 @@ function template_ban_edit_trigger()
</div><!-- #manage_bans -->
<script>
var oAddMemberSuggest = new smc_AutoSuggest({
sSelf: \'oAddMemberSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'username\',
sControlId: \'user\',
sSearchType: \'member\',
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
bItemList: false
});
function onUpdateName(oAutoSuggest)
Expand Down
2 changes: 0 additions & 2 deletions Themes/default/ManageBoards.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ function template_modify_board()
<script>
var oModeratorSuggest = new smc_AutoSuggest({
sSelf: \'oModeratorSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'moderators\',
Expand All @@ -629,7 +628,6 @@ function template_modify_board()
});
var oModeratorGroupSuggest = new smc_AutoSuggest({
sSelf: \'oModeratorGroupSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'moderator_groups\',
Expand Down
2 changes: 0 additions & 2 deletions Themes/default/ManageMembergroups.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ function template_edit_group()
</form>
<script>
var oModeratorSuggest = new smc_AutoSuggest({
sSelf: \'oModeratorSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'group_moderators\',
Expand Down Expand Up @@ -698,7 +697,6 @@ function template_group_members()
echo '
<script>
var oAddMemberSuggest = new smc_AutoSuggest({
sSelf: \'oAddMemberSuggest\',
sSessionId: \'', Utils::$context['session_id'], '\',
sSessionVar: \'', Utils::$context['session_var'], '\',
sSuggestId: \'to_suggest\',
Expand Down
2 changes: 0 additions & 2 deletions Themes/default/ManageNews.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function template_email_members()
</script>
<script>
var oMemberSuggest = new smc_AutoSuggest({
sSelf: \'oMemberSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'members\',
Expand All @@ -156,7 +155,6 @@ function template_email_members()
aListItems: []
});
var oExcludeMemberSuggest = new smc_AutoSuggest({
sSelf: \'oExcludeMemberSuggest\',
sSessionId: \'', Utils::$context['session_id'], '\',
sSessionVar: \'', Utils::$context['session_var'], '\',
sSuggestId: \'exclude_members\',
Expand Down
4 changes: 1 addition & 3 deletions Themes/default/ManagePaid.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,13 @@ function template_modify_user_subscription()
</form>
<script>
var oAddMemberSuggest = new smc_AutoSuggest({
sSelf: \'oAddMemberSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'name_subscriber\',
sControlId: \'name_control\',
sSearchType: \'member\',
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
bItemList: false
});
});
</script>';

if (!empty(Utils::$context['pending_payments']))
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/ManageSearch.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ function doAutoSubmit()
document.forms.autoSubmit.b.value = "', Lang::$txt['search_create_index_continue'], ' (" + countdown + ")";
countdown--;
setTimeout("doAutoSubmit();", 1000);
setTimeout(doAutoSubmit, 1000);
}
</script>';

Expand Down
3 changes: 1 addition & 2 deletions Themes/default/Packages.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ function template_browse()
echo '
<script>
var oAdminIndex = new smf_AdminIndex({
sSelf: \'oAdminCenter\',
bLoadAnnouncements: false,
bLoadVersions: false,
bLoadUpdateNotification: true,
Expand Down Expand Up @@ -1834,7 +1833,7 @@ function doAutoSubmit()
document.getElementById(\'cont\').value = "', Lang::$txt['not_done_continue'], ' (" + countdown + ")";
countdown--;
setTimeout("doAutoSubmit();", 1000);
setTimeout(doAutoSubmit, 1000);
}
</script>';
}
Expand Down
1 change: 0 additions & 1 deletion Themes/default/PersonalMessage.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,6 @@ function onDocSent(XMLDoc)
echo '
<script>
var oPersonalMessageSend = new smf_PersonalMessageSend({
sSelf: \'oPersonalMessageSend\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/Post.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ function template_quotefast()
window.opener.onReceiveOpener(quote);
window.focus();
setTimeout("window.close();", 400);';
setTimeout(function() { window.close(); }, 400);';
}
echo '
</script>
Expand Down Expand Up @@ -925,7 +925,7 @@ function doAutoSubmit()
document.forms.autoSubmit.b.value = "', Lang::$txt['announce_continue'], ' (" + countdown + ")";
countdown--;
setTimeout("doAutoSubmit();", 1000);
setTimeout(doAutoSubmit, 1000);
}
</script>';
}
Expand Down
4 changes: 0 additions & 4 deletions Themes/default/Profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,14 +818,12 @@ function template_editBuddies()
</form>
<script>
var oAddBuddySuggest = new smc_AutoSuggest({
sSelf: \'oAddBuddySuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sSuggestId: \'new_buddy\',
sControlId: \'new_buddy\',
sSearchType: \'member\',
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
bItemList: false
});
</script>';
}
Expand Down Expand Up @@ -929,14 +927,12 @@ function template_editIgnoreList()
</form>
<script>
var oAddIgnoreSuggest = new smc_AutoSuggest({
sSelf: \'oAddIgnoreSuggest\',
sSessionId: \'', Utils::$context['session_id'], '\',
sSessionVar: \'', Utils::$context['session_var'], '\',
sSuggestId: \'new_ignore\',
sControlId: \'new_ignore\',
sSearchType: \'member\',
sTextDeleteItem: \'', Lang::$txt['autosuggest_delete_item'], '\',
bItemList: false
});
</script>';
}
Expand Down
5 changes: 1 addition & 4 deletions Themes/default/Search.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ function template_main()
</dd>
</dl>
<script>
createEventListener(window);
window.addEventListener("load", initSearch, false);
</script>
<input type="hidden" name="advanced" value="1">';
Expand Down Expand Up @@ -236,12 +235,10 @@ function template_main()
</form>
<script>
var oAddMemberSuggest = new smc_AutoSuggest({
sSelf: \'oAddMemberSuggest\',
sSessionId: smf_session_id,
sSessionVar: smf_session_var,
sControlId: \'userspec\',
sSearchType: \'member\',
bItemList: false
sSearchType: \'member\'
});
</script>';
}
Expand Down
22 changes: 8 additions & 14 deletions Themes/default/scripts/PersonalMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ smf_PersonalMessageSend.prototype.init = function()

// Make the link show the BCC control.
var oBccLink = document.getElementById(this.opt.sBccLinkId);
oBccLink.instanceRef = this;
oBccLink.onclick = function () {
this.instanceRef.showBcc();
return false;
};
oBccLink.onclick = this.showBcc.bind(this);
}

var oToControl = document.getElementById(this.opt.sToControlId);
this.oToAutoSuggest = new smc_AutoSuggest({
sSelf: this.opt.sSelf + '.oToAutoSuggest',
sSessionId: this.opt.sSessionId,
sSessionVar: this.opt.sSessionVar,
sSuggestId: 'to_suggest',
Expand All @@ -50,10 +45,9 @@ smf_PersonalMessageSend.prototype.init = function()
sItemListContainerId: 'to_item_list_container',
aListItems: this.opt.aToRecipients
});
this.oToAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');
this.oToAutoSuggest.registerCallback('onBeforeAddItem', this.callbackAddItem.bind(this));

this.oBccAutoSuggest = new smc_AutoSuggest({
sSelf: this.opt.sSelf + '.oBccAutoSuggest',
sSessionId: this.opt.sSessionId,
sSessionVar: this.opt.sSessionVar,
sSuggestId: 'bcc_suggest',
Expand All @@ -66,23 +60,23 @@ smf_PersonalMessageSend.prototype.init = function()
sItemListContainerId: 'bcc_item_list_container',
aListItems: this.opt.aBccRecipients
});
this.oBccAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');

this.oBccAutoSuggest.registerCallback('onBeforeAddItem', this.callbackAddItem.bind(this));
}

smf_PersonalMessageSend.prototype.showBcc = function()
{
// No longer hide it, show it to the world!
this.oBccDiv.style.display = '';
this.oBccDiv2.style.display = '';
}

return false;
}

// Prevent items to be added twice or to both the 'To' and 'Bcc'.
smf_PersonalMessageSend.prototype.callbackAddItem = function(oAutoSuggestInstance, sSuggestId)
smf_PersonalMessageSend.prototype.callbackAddItem = function(sItemId)
{
this.oToAutoSuggest.deleteAddedItem(sSuggestId);
this.oBccAutoSuggest.deleteAddedItem(sSuggestId);
this.oToAutoSuggest.deleteAddedItem(sItemId);
this.oBccAutoSuggest.deleteAddedItem(sItemId);

return true;
}
2 changes: 1 addition & 1 deletion Themes/default/scripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function setPreviewTimeout()
previewTimeout = null;
}

previewTimeout = window.setTimeout("refreshPreview(true); previewTimeout = null;", 500);
previewTimeout = window.setTimeout(function() { refreshPreview(true); previewTimeout = null; }, 500);
}

function toggleDuration(toChange)
Expand Down
6 changes: 0 additions & 6 deletions Themes/default/scripts/captcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ function smfCaptcha(imageURL, uniqueID, useLibrary, letterCount)
// Is there anything to cycle images with - if so attach the refresh image function?
var cycleHandle = document.getElementById('visual_verification' + uniqueID + '_refresh');
if (cycleHandle)
{
createEventListener(cycleHandle);
cycleHandle.addEventListener('click', refreshImages, false);
}

// Maybe a voice is here to spread light?
var soundHandle = document.getElementById('visual_verification' + uniqueID + '_sound');
if (soundHandle)
{
createEventListener(soundHandle);
soundHandle.addEventListener('click', playSound, false);
}
}

// Change the images.
Expand Down
Loading

0 comments on commit b03480c

Please sign in to comment.