Skip to content

Commit

Permalink
Merge pull request #3075 from MissAllSunday/stuff
Browse files Browse the repository at this point in the history
Rename error_handler() to smf_error_handler

moving forward...
  • Loading branch information
MissAllSunday committed Sep 30, 2015
2 parents 2826e01 + ff6721e commit 892d9d9
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 36 deletions.
5 changes: 2 additions & 3 deletions SSI.php
Expand Up @@ -2179,7 +2179,7 @@ function ssi_checkPassword($id = null, $password = null, $is_username = false)
* @param string $output_method The output method. If 'echo', displays a table with links/info, otherwise returns an array with information about the attachments
* @return void|array Displays a table of attachment info or returns an array containing info about the attachments, depending on output_method.
*/
function ssi_recentAttachmenets($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo')
function ssi_recentAttachments($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo')
{
global $smcFunc, $modSettings, $scripturl, $txt, $settings;

Expand All @@ -2191,8 +2191,7 @@ function ssi_recentAttachmenets($num_attachments = 10, $attachment_ext = array()
return array();

// Is it an array?
if (!is_array($attachment_ext))
$attachment_ext = array($attachment_ext);
$attachment_ext = (array) $attachment_ext;

// Lets build the query.
$request = $smcFunc['db_query']('', '
Expand Down
2 changes: 1 addition & 1 deletion Sources/Errors.php
Expand Up @@ -206,7 +206,7 @@ function fatal_lang_error($error, $log = 'general', $sprintf = array(), $status
* @param string $file The file where the error occurred
* @param int $line The line where the error occurred
*/
function error_handler($error_level, $error_string, $file, $line)
function smf_error_handler($error_level, $error_string, $file, $line)
{
global $settings, $modSettings, $db_show_debug;

Expand Down
2 changes: 1 addition & 1 deletion Sources/Load.php
Expand Up @@ -2254,7 +2254,7 @@ function loadSubTemplate($sub_template_name, $fatal = false)
if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
{
echo '
<div style="font-size: 8pt; border: 1px dashed red; background: orange; text-align: center; font-weight: bold;">---- ', $sub_template_name, ' ends ----</div>';
<div class="warningbox">---- ', $sub_template_name, ' ends ----</div>';
}
}

Expand Down
22 changes: 12 additions & 10 deletions Sources/ManageBoards.php
Expand Up @@ -223,6 +223,7 @@ function EditCategory()

loadTemplate('ManageBoards');
require_once($sourcedir . '/Subs-Boards.php');
require_once($sourcedir . '/Subs-Editor.php');
getBoardTree();

// id_cat must be a number.... if it exists.
Expand Down Expand Up @@ -259,8 +260,8 @@ function EditCategory()
$context['category'] = array(
'id' => $_REQUEST['cat'],
'name' => $cat_tree[$_REQUEST['cat']]['node']['name'],
'editable_name' => $smcFunc['htmlspecialchars']($cat_tree[$_REQUEST['cat']]['node']['name']),
'description' => $smcFunc['htmlspecialchars']($cat_tree[$_REQUEST['cat']]['node']['description']),
'editable_name' => html_to_bbc($cat_tree[$_REQUEST['cat']]['node']['name']),
'description' => html_to_bbc($cat_tree[$_REQUEST['cat']]['node']['description']),
'can_collapse' => !empty($cat_tree[$_REQUEST['cat']]['node']['can_collapse']),
'children' => array(),
'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children'])
Expand Down Expand Up @@ -312,7 +313,7 @@ function EditCategory()
*/
function EditCategory2()
{
global $sourcedir;
global $sourcedir, $smcFunc, $context;

checkSession();
validateToken('admin-bc-' . $_REQUEST['cat']);
Expand All @@ -330,8 +331,8 @@ function EditCategory2()
$catOptions['move_after'] = (int) $_POST['cat_order'];

// Change "This & That" to "This &amp; That" but don't change "&cent" to "&amp;cent;"...
$catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['cat_name']);
$catOptions['cat_desc'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['cat_desc']);
$catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']);
$catOptions['cat_desc'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_desc']), false, '', $context['description_allowed_tags']);

$catOptions['is_collapsible'] = isset($_POST['collapse']);

Expand Down Expand Up @@ -379,6 +380,7 @@ function EditBoard()

loadTemplate('ManageBoards');
require_once($sourcedir . '/Subs-Boards.php');
require_once($sourcedir . '/Subs-Editor.php');
getBoardTree();

// For editing the profile we'll need this.
Expand Down Expand Up @@ -433,8 +435,8 @@ function EditBoard()
// Just some easy shortcuts.
$curBoard = &$boards[$_REQUEST['boardid']];
$context['board'] = $boards[$_REQUEST['boardid']];
$context['board']['name'] = $smcFunc['htmlspecialchars'](strtr($context['board']['name'], array('&amp;' => '&')));
$context['board']['description'] = $smcFunc['htmlspecialchars']($context['board']['description']);
$context['board']['name'] = html_to_bbc($context['board']['name']);
$context['board']['description'] = html_to_bbc($context['board']['description']);
$context['board']['no_children'] = empty($boards[$_REQUEST['boardid']]['tree']['children']);
$context['board']['is_recycle'] = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) && $modSettings['recycle_board'] == $context['board']['id'];
}
Expand Down Expand Up @@ -673,9 +675,9 @@ function EditBoard2()
if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255)
fatal_lang_error('too_many_groups', false);

// Change '1 & 2' to '1 &amp; 2', but not '&amp;' to '&amp;amp;'...
$boardOptions['board_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['board_name']);
$boardOptions['board_description'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&amp;$1', $_POST['desc']);
// Do not allow HTML tags. Parse the string.
$boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']);
$boardOptions['board_description'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['desc']), false, '', $context['description_allowed_tags']);

$boardOptions['moderator_string'] = $_POST['moderators'];

Expand Down
4 changes: 2 additions & 2 deletions Sources/Subs-BoardIndex.php
Expand Up @@ -99,7 +99,7 @@ function getBoardIndex($boardIndexOptions)
$categories[$row_board['id_cat']] = array(
'id' => $row_board['id_cat'],
'name' => $row_board['cat_name'],
'description' => parse_bbc($row_board['cat_desc'], false, '', $context['description_allowed_tags']),
'description' => $row_board['cat_desc'],
'is_collapsed' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1 && !empty($options['collapse_category_' . $row_board['id_cat']]),
'can_collapse' => isset($row_board['can_collapse']) && $row_board['can_collapse'] == 1,
'href' => $scripturl . '#c' . $row_board['id_cat'],
Expand Down Expand Up @@ -134,7 +134,7 @@ function getBoardIndex($boardIndexOptions)
'new' => empty($row_board['is_read']),
'id' => $row_board['id_board'],
'name' => $row_board['board_name'],
'description' => parse_bbc($row_board['description'], false, '', $context['description_allowed_tags']),
'description' => $row_board['description'],
'moderators' => array(),
'moderator_groups' => array(),
'link_moderators' => array(),
Expand Down
2 changes: 1 addition & 1 deletion Sources/Subs.php
Expand Up @@ -3282,7 +3282,7 @@ function template_javascript($do_defered = false)
*/
function template_css()
{
global $context, $db_show_debug, $boardurl;
global $context, $db_show_debug, $boardurl, $settings;

// Use this hook to minify/optimize CSS files
call_integration_hook('integrate_pre_css_output');
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/ManageBoards.template.php
Expand Up @@ -151,7 +151,7 @@ function template_modify_category()
</dd>
<dt>
<strong>', $txt['mboards_description'], '</strong><br>
<span class="smalltext">', $txt['mboards_cat_description_desc'], '</span>
<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_cat_description_desc']), '</span>
</dt>
<dd>
<textarea name="cat_desc" rows="3" cols="35" style="width: 99%;">', $context['category']['description'], '</textarea>
Expand Down Expand Up @@ -320,7 +320,7 @@ function template_modify_board()
</dd>
<dt>
<strong>', $txt['mboards_description'], ':</strong><br>
<span class="smalltext">', $txt['mboards_description_desc'], '</span>
<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_description_desc']), '</span>
</dt>
<dd>
<textarea name="desc" rows="3" cols="35" style="width:99%;">', $context['board']['description'], '</textarea>
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/Profile.template.php
Expand Up @@ -2852,8 +2852,8 @@ function template_profile_avatar_select()
{
echo '
<div id="avatar_upload">
<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" class="input_file" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt=""><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" class="input_file" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
</div>';
}

Expand Down
2 changes: 1 addition & 1 deletion Themes/default/index.template.php
Expand Up @@ -581,7 +581,7 @@ function template_maint_warning_above()
<div class="errorbox" id="errors">
<dl>
<dt>
<strong id="error_serious">', $txt['forum_in_maintainence'], '</strong>
<strong id="error_serious">', $txt['forum_in_maintenance'], '</strong>
</dt>
<dd class="error" id="error_list">
', sprintf($txt['maintenance_page'], $scripturl . '?action=admin;area=serversettings;' . $context['session_var'] . '=' . $context['session_id']), '
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/languages/EmailTemplates.english.php
Expand Up @@ -191,7 +191,7 @@
{REGARDS}';

$txt['admin_register_immediate_subject'] = 'Welcome to {FORUMNAME}';
$txt['admin_register_immediate_body'] = 'Thank you for registering at {FORUMNAME}. Your username is {USERNAME} and your password is {PASSWORD}.
$txt['admin_register_immediate_body'] = 'Thank you for registering at {FORUMNAME}. Your username is {USERNAME}, your password is {PASSWORD} and the forum url is: {SCRIPTURL}.
{REGARDS}';

Expand Down
4 changes: 2 additions & 2 deletions Themes/default/languages/ManageBoards.english.php
Expand Up @@ -46,8 +46,8 @@

$txt['mboards_category'] = 'Category';
$txt['mboards_description'] = 'Description';
$txt['mboards_description_desc'] = 'A short description of your board.';
$txt['mboards_cat_description_desc'] = 'A short description of your category.';
$txt['mboards_description_desc'] = 'A short description of your board. HTML is not allowed, you can use the following BBC tags: {allowed_tags}';
$txt['mboards_cat_description_desc'] = 'A short description of your category. HTML is not allowed, you can use the following BBC tags: {allowed_tags}';
$txt['mboards_groups'] = 'Allowed Groups';
$txt['mboards_groups_desc'] = 'Groups allowed to access this board.<br><em>Note: if the member is in any group or post group checked, they will have access to this board.</em>';
$txt['mboards_groups_regular_members'] = 'This group contains all members that have no primary group set.';
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/languages/index.english.php
Expand Up @@ -338,7 +338,7 @@
$txt['search_for'] = 'Search for';
$txt['search_match'] = 'Match';

$txt['forum_in_maintainence'] = 'Your forum is in Maintenance Mode. Only administrators can currently log in.';
$txt['forum_in_maintenance'] = 'Your forum is in Maintenance Mode. Only administrators can currently log in.';
$txt['maintenance_page'] = 'You can turn off Maintenance Mode from the <a href="%1$s">Server Settings</a> area.';

$txt['read_one_time'] = 'Read 1 time';
Expand Down
43 changes: 43 additions & 0 deletions Themes/default/scripts/profile.js
Expand Up @@ -239,3 +239,46 @@ function previewExternalAvatar(src)
}
document.getElementById("avatar").src = src;
}

function readfromUpload(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {

// If there is an image already, hide it...
if ($('#attached_image').length){
$('#attached_image').remove();
}

if ($('#attached_image_new').length){
$('#attached_image_new').remove();
}

var tempImage = new Image();
tempImage.src = e.target.result;

var uploadedImage = $('<img />', {
id: 'attached_image_new',
src: e.target.result,
image: tempImage.width,
height: tempImage.height,
});

if (maxWidth != 0 && uploadedImage.width() > maxWidth)
{
uploadedImage.height(parseInt((maxWidth * uploadedImage.height()) / uploadedImage.width()) + "px");
uploadedImage.width(maxWidth + "px");
}
else if (maxHeight != 0 && uploadedImage.height() > maxHeight)
{
uploadedImage.width(parseInt((maxHeight * uploadedImage.width) / uploadedImage.height) + "px");
uploadedImage.height(maxHeight + "px");
}

uploadedImage.appendTo($('#avatar_upload'));
}

reader.readAsDataURL(input.files[0]);
}
}
22 changes: 16 additions & 6 deletions Themes/default/scripts/quotedText.js
Expand Up @@ -28,7 +28,8 @@ function getSelectedText(divID)

var text = '',
selection,
found = 0;
found = 0,
container = document.createElement("div");

if (window.getSelection)
{
Expand All @@ -49,6 +50,8 @@ function getSelectedText(divID)
if (s !== null && e !== null)
{
found = 1;
container.appendChild(selection.getRangeAt(i).cloneContents());
text = container.innerHTML;
break;
}
}
Expand All @@ -71,15 +74,24 @@ function quotedTextClick(oOptions)
beforeSend: function () {
ajax_indicator(true);
},
complete: function(jqXHR, textStatus){
ajax_indicator(false);
},
success: function (data, textStatus, xhr) {
// Search the xml data to get the quote tag.
text = $(data).find('quote').text();

// Insert the selected text between the quotes BBC tags.
text = text.match(/^\[quote(.*)]/ig) + oOptions.text + '[/quote]' + '\n\n';

// Add the whole text to the editor's instance.
$('#' + oEditorID).data('sceditor').sourceEditorInsertText(text);
// Get the editor stuff.
var oEditor = $('#' + oEditorID).data('sceditor');

// Convert any HTML into BBC tags.
text = oEditor.toBBCode(text);

// Push the text to the editor.
oEditor.insert(text);

// Move the view to the quick reply box. If available.
if (typeof oJumpAnchor != 'undefined'){
Expand All @@ -88,11 +100,9 @@ function quotedTextClick(oOptions)
else
window.location.hash = '#' + oJumpAnchor;
}

ajax_indicator(false);
},
error: function (xhr, textStatus, errorThrown) {
ajax_indicator(false);
// @todo Show some error.
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions cron.php
Expand Up @@ -87,7 +87,7 @@
reloadSettings();

// Just in case there's a problem...
set_error_handler('error_handler_cron');
set_error_handler('smf_error_handler_cron');
$sc = '';
$_SERVER['QUERY_STRING'] = '';
$_SERVER['REQUEST_URL'] = FROM_CLI ? 'CLI cron.php' : $boardurl . '/cron.php';
Expand Down Expand Up @@ -242,7 +242,7 @@ function cleanRequest_cron()
* @param int $line What line of the specified file the error occurred on
* @return void
*/
function error_handler_cron($error_level, $error_string, $file, $line)
function smf_error_handler_cron($error_level, $error_string, $file, $line)
{
global $modSettings;

Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -107,7 +107,7 @@
}

// Register an error handler.
set_error_handler('error_handler');
set_error_handler('smf_error_handler');

// Start the session. (assuming it hasn't already been.)
loadSession();
Expand Down

0 comments on commit 892d9d9

Please sign in to comment.