function sp_shoutbox($parameters, $id, $return_parameters = false) { global $smcFunc, $context, $sourcedir, $modSettings, $user_info, $settings, $txt, $scripturl; $block_parameters = array('shoutbox' => array()); if ($return_parameters) { $shoutboxes = sportal_get_shoutbox(); $in_use = array(); $request = $smcFunc['db_query']('', ' SELECT id_block, value FROM {db_prefix}sp_parameters WHERE variable = {string:name}', array('name' => 'shoutbox')); while ($row = $smcFunc['db_fetch_assoc']($request)) { if (empty($_REQUEST['block_id']) || $_REQUEST['block_id'] != $row['id_block']) { $in_use[] = $row['value']; } } $smcFunc['db_free_result']($request); foreach ($shoutboxes as $shoutbox) { if (!in_array($shoutbox['id'], $in_use)) { $block_parameters['shoutbox'][$shoutbox['id']] = $shoutbox['name']; } } if (empty($block_parameters['shoutbox'])) { fatal_error(allowedTo(array('sp_admin', 'sp_manage_shoutbox')) ? $txt['error_sp_no_shoutbox'] . '<br />' . sprintf($txt['error_sp_no_shoutbox_sp_moderator'], $scripturl . '?action=admin;area=portalshoutbox;sa=add') : $txt['error_sp_no_shoutbox_normaluser'], false); } return $block_parameters; } loadTemplate('PortalShoutbox'); loadLanguage('Post'); $shoutbox = sportal_get_shoutbox($parameters['shoutbox'], true, true); if (empty($shoutbox)) { echo ' ', $txt['error_sp_shoutbox_not_exist']; return; } if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id']) { checkSession(); is_not_guest(); if (!($flood = sp_prevent_flood('spsbp', false))) { require_once $sourcedir . '/Subs-Post.php'; $_POST['new_shout'] = $smcFunc['htmlspecialchars'](trim($_POST['new_shout'])); preparsecode($_POST['new_shout']); if (!empty($_POST['new_shout'])) { sportal_create_shout($shoutbox, $_POST['new_shout']); } } else { $shoutbox['warning'] = $flood; } } $can_moderate = allowedTo('sp_admin') || allowedTo('sp_manage_shoutbox'); if (!$can_moderate && !empty($shoutbox['moderator_groups'])) { $can_moderate = count(array_intersect($user_info['groups'], $shoutbox['moderator_groups'])) > 0; } $shout_parameters = array('limit' => $shoutbox['num_show'], 'bbc' => $shoutbox['allowed_bbc'], 'reverse' => $shoutbox['reverse'], 'cache' => $shoutbox['caching'], 'can_moderate' => $can_moderate); $shoutbox['shouts'] = sportal_get_shouts($shoutbox['id'], $shout_parameters); $shoutbox['warning'] = parse_bbc($shoutbox['warning']); $context['can_shout'] = $context['user']['is_logged']; if ($context['can_shout']) { $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; $shoutbox['smileys'] = array('normal' => array(), 'popup' => array()); if (empty($modSettings['smiley_enable'])) { $shoutbox['smileys']['normal'] = array(array('code' => ':)', 'filename' => 'smiley.gif', 'description' => $txt['icon_smiley']), array('code' => ';)', 'filename' => 'wink.gif', 'description' => $txt['icon_wink']), array('code' => ':D', 'filename' => 'cheesy.gif', 'description' => $txt['icon_cheesy']), array('code' => ';D', 'filename' => 'grin.gif', 'description' => $txt['icon_grin']), array('code' => '>:(', 'filename' => 'angry.gif', 'description' => $txt['icon_angry']), array('code' => ':(', 'filename' => 'sad.gif', 'description' => $txt['icon_sad']), array('code' => ':o', 'filename' => 'shocked.gif', 'description' => $txt['icon_shocked']), array('code' => '8)', 'filename' => 'cool.gif', 'description' => $txt['icon_cool']), array('code' => '???', 'filename' => 'huh.gif', 'description' => $txt['icon_huh']), array('code' => '::)', 'filename' => 'rolleyes.gif', 'description' => $txt['icon_rolleyes']), array('code' => ':P', 'filename' => 'tongue.gif', 'description' => $txt['icon_tongue']), array('code' => ':-[', 'filename' => 'embarrassed.gif', 'description' => $txt['icon_embarrassed']), array('code' => ':-X', 'filename' => 'lipsrsealed.gif', 'description' => $txt['icon_lips']), array('code' => ':-\\', 'filename' => 'undecided.gif', 'description' => $txt['icon_undecided']), array('code' => ':-*', 'filename' => 'kiss.gif', 'description' => $txt['icon_kiss']), array('code' => ':\'(', 'filename' => 'cry.gif', 'description' => $txt['icon_cry'])); } else { if (($temp = cache_get_data('shoutbox_smileys', 3600)) == null) { $request = $smcFunc['db_query']('', ' SELECT code, filename, description, smiley_row, hidden FROM {db_prefix}smileys WHERE hidden IN ({array_int:hidden}) ORDER BY smiley_row, smiley_order', array('hidden' => array(0, 2))); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['filename'] = htmlspecialchars($row['filename']); $row['description'] = htmlspecialchars($row['description']); $row['code'] = htmlspecialchars($row['code']); $shoutbox['smileys'][empty($row['hidden']) ? 'normal' : 'popup'][] = $row; } $smcFunc['db_free_result']($request); cache_put_data('shoutbox_smileys', $shoutbox['smileys'], 3600); } else { $shoutbox['smileys'] = $temp; } } foreach (array_keys($shoutbox['smileys']) as $location) { $n = count($shoutbox['smileys'][$location]); for ($i = 0; $i < $n; $i++) { $shoutbox['smileys'][$location][$i]['code'] = addslashes($shoutbox['smileys'][$location][$i]['code']); $shoutbox['smileys'][$location][$i]['js_description'] = addslashes($shoutbox['smileys'][$location][$i]['description']); } if (!empty($shoutbox['smileys'][$location])) { $shoutbox['smileys'][$location][$n - 1]['last'] = true; } } $shoutbox['bbc'] = array('bold' => array('code' => 'b', 'before' => '[b]', 'after' => '[/b]', 'description' => $txt['bold']), 'italicize' => array('code' => 'i', 'before' => '[i]', 'after' => '[/i]', 'description' => $txt['italic']), 'underline' => array('code' => 'u', 'before' => '[u]', 'after' => '[/u]', 'description' => $txt['underline']), 'strike' => array('code' => 's', 'before' => '[s]', 'after' => '[/s]', 'description' => $txt['strike']), 'pre' => array('code' => 'pre', 'before' => '[pre]', 'after' => '[/pre]', 'description' => $txt['preformatted']), 'flash' => array('code' => 'flash', 'before' => '[flash=200,200]', 'after' => '[/flash]', 'description' => $txt['flash']), 'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt['image']), 'url' => array('code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt['hyperlink']), 'email' => array('code' => 'email', 'before' => '[email]', 'after' => '[/email]', 'description' => $txt['insert_email']), 'ftp' => array('code' => 'ftp', 'before' => '[ftp]', 'after' => '[/ftp]', 'description' => $txt['ftp']), 'glow' => array('code' => 'glow', 'before' => '[glow=red,2,300]', 'after' => '[/glow]', 'description' => $txt['glow']), 'shadow' => array('code' => 'shadow', 'before' => '[shadow=red,left]', 'after' => '[/shadow]', 'description' => $txt['shadow']), 'sup' => array('code' => 'sup', 'before' => '[sup]', 'after' => '[/sup]', 'description' => $txt['superscript']), 'sub' => array('code' => 'sub', 'before' => '[sub]', 'after' => '[/sub]', 'description' => $txt['subscript']), 'tele' => array('code' => 'tt', 'before' => '[tt]', 'after' => '[/tt]', 'description' => $txt['teletype']), 'code' => array('code' => 'code', 'before' => '[code]', 'after' => '[/code]', 'description' => $txt['bbc_code']), 'quote' => array('code' => 'quote', 'before' => '[quote]', 'after' => '[/quote]', 'description' => $txt['bbc_quote'])); } template_shoutbox_embed($shoutbox); }
/** * Shoutbox Block, show the shoutbox thoughts box * * @param mixed[] $parameters * 'shoutbox' => list of shoutboxes to choose from * @param int $id - not used in this block * @param boolean $return_parameters if true returns the configuration options for the block */ function sp_shoutbox($parameters, $id, $return_parameters = false) { global $context, $modSettings, $user_info, $settings, $txt, $scripturl, $editortxt; $db = database(); $block_parameters = array('shoutbox' => array()); require_once SUBSDIR . '/PortalShoutbox.subs.php'; // return the parameters for use in setting up the blocks if ($return_parameters) { $shoutboxes = sportal_get_shoutbox(); $in_use = array(); $request = $db->query('', ' SELECT id_block, value FROM {db_prefix}sp_parameters WHERE variable = {string:name}', array('name' => 'shoutbox')); while ($row = $db->fetch_assoc($request)) { if (empty($_REQUEST['block_id']) || $_REQUEST['block_id'] != $row['id_block']) { $in_use[] = $row['value']; } } $db->free_result($request); // Load up all the shoutboxes that are NOT being used foreach ($shoutboxes as $shoutbox) { if (!in_array($shoutbox['id'], $in_use)) { $block_parameters['shoutbox'][$shoutbox['id']] = $shoutbox['name']; } } if (empty($block_parameters['shoutbox'])) { fatal_error(allowedTo(array('sp_admin', 'sp_manage_shoutbox')) ? $txt['error_sp_no_shoutbox'] . '<br />' . sprintf($txt['error_sp_no_shoutbox_sp_moderator'], $scripturl . '?action=admin;area=portalshoutbox;sa=add') : $txt['error_sp_no_shoutbox_normaluser'], false); } return $block_parameters; } loadTemplate('PortalShoutbox'); loadLanguage('Editor'); loadLanguage('Post'); $shoutbox = sportal_get_shoutbox($parameters['shoutbox'], true, true); // To add a shoutbox you must have one or more defined for use if (empty($shoutbox)) { echo ' ', $txt['error_sp_shoutbox_not_exist']; return; } // Going to add to the shoutbox \ if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id']) { // Make sure things are in order checkSession(); is_not_guest(); if (!($flood = sp_prevent_flood('spsbp', false))) { require_once SUBSDIR . '/Post.subs.php'; $_POST['new_shout'] = Util::htmlspecialchars(trim($_POST['new_shout'])); preparsecode($_POST['new_shout']); if (!empty($_POST['new_shout'])) { sportal_create_shout($shoutbox, $_POST['new_shout']); } } else { $shoutbox['warning'] = $flood; } } // Can they moderate the shoutbox (delete shouts?) $can_moderate = allowedTo('sp_admin') || allowedTo('sp_manage_shoutbox'); if (!$can_moderate && !empty($shoutbox['moderator_groups'])) { $can_moderate = count(array_intersect($user_info['groups'], $shoutbox['moderator_groups'])) > 0; } $shout_parameters = array('limit' => $shoutbox['num_show'], 'bbc' => $shoutbox['allowed_bbc'], 'reverse' => $shoutbox['reverse'], 'cache' => $shoutbox['caching'], 'can_moderate' => $can_moderate); $shoutbox['shouts'] = sportal_get_shouts($shoutbox['id'], $shout_parameters); $shoutbox['warning'] = parse_bbc($shoutbox['warning']); $context['can_shout'] = $context['user']['is_logged']; if ($context['can_shout']) { // Set up the smiley tags for the shoutbox $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; $shoutbox['smileys'] = array('normal' => array(), 'popup' => array()); if (empty($modSettings['smiley_enable'])) { $shoutbox['smileys']['normal'] = array(array('code' => ':)', 'filename' => 'smiley.gif', 'description' => $txt['icon_smiley']), array('code' => ';)', 'filename' => 'wink.gif', 'description' => $txt['icon_wink']), array('code' => ':D', 'filename' => 'cheesy.gif', 'description' => $txt['icon_cheesy']), array('code' => ';D', 'filename' => 'grin.gif', 'description' => $txt['icon_grin']), array('code' => '>:(', 'filename' => 'angry.gif', 'description' => $txt['icon_angry']), array('code' => ':(', 'filename' => 'sad.gif', 'description' => $txt['icon_sad']), array('code' => ':o', 'filename' => 'shocked.gif', 'description' => $txt['icon_shocked']), array('code' => '8)', 'filename' => 'cool.gif', 'description' => $txt['icon_cool']), array('code' => '???', 'filename' => 'huh.gif', 'description' => $txt['icon_huh']), array('code' => '::)', 'filename' => 'rolleyes.gif', 'description' => $txt['icon_rolleyes']), array('code' => ':P', 'filename' => 'tongue.gif', 'description' => $txt['icon_tongue']), array('code' => ':-[', 'filename' => 'embarrassed.gif', 'description' => $txt['icon_embarrassed']), array('code' => ':-X', 'filename' => 'lipsrsealed.gif', 'description' => $txt['icon_lips']), array('code' => ':-\\', 'filename' => 'undecided.gif', 'description' => $txt['icon_undecided']), array('code' => ':-*', 'filename' => 'kiss.gif', 'description' => $txt['icon_kiss']), array('code' => ':\'(', 'filename' => 'cry.gif', 'description' => $txt['icon_cry'])); } else { if (($temp = cache_get_data('shoutbox_smileys', 3600)) == null) { $request = $db->query('', ' SELECT code, filename, description, smiley_row, hidden FROM {db_prefix}smileys WHERE hidden IN ({array_int:hidden}) ORDER BY smiley_row, smiley_order', array('hidden' => array(0, 2))); while ($row = $db->fetch_assoc($request)) { $row['filename'] = htmlspecialchars($row['filename']); $row['description'] = htmlspecialchars($row['description']); $row['code'] = htmlspecialchars($row['code']); $shoutbox['smileys'][empty($row['hidden']) ? 'normal' : 'popup'][] = $row; } $db->free_result($request); cache_put_data('shoutbox_smileys', $shoutbox['smileys'], 3600); } else { $shoutbox['smileys'] = $temp; } } foreach (array_keys($shoutbox['smileys']) as $location) { $n = count($shoutbox['smileys'][$location]); for ($i = 0; $i < $n; $i++) { $shoutbox['smileys'][$location][$i]['code'] = addslashes($shoutbox['smileys'][$location][$i]['code']); $shoutbox['smileys'][$location][$i]['js_description'] = addslashes($shoutbox['smileys'][$location][$i]['description']); } if (!empty($shoutbox['smileys'][$location])) { $shoutbox['smileys'][$location][$n - 1]['last'] = true; } } // Basic shoutbox bbc we allow $shoutbox['bbc'] = array('bold' => array('code' => 'b', 'before' => '[b]', 'after' => '[/b]', 'description' => $editortxt['Bold']), 'italicize' => array('code' => 'i', 'before' => '[i]', 'after' => '[/i]', 'description' => $editortxt['Italic']), 'underline' => array('code' => 'u', 'before' => '[u]', 'after' => '[/u]', 'description' => $editortxt['Underline']), 'strike' => array('code' => 's', 'before' => '[s]', 'after' => '[/s]', 'description' => $editortxt['Strikethrough']), 'pre' => array('code' => 'pre', 'before' => '[pre]', 'after' => '[/pre]', 'description' => $editortxt['Preformatted Text']), 'img' => array('code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $editortxt['Insert an image']), 'url' => array('code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $editortxt['Insert a link']), 'email' => array('code' => 'email', 'before' => '[email]', 'after' => '[/email]', 'description' => $editortxt['Insert an email']), 'sup' => array('code' => 'sup', 'before' => '[sup]', 'after' => '[/sup]', 'description' => $editortxt['Superscript']), 'sub' => array('code' => 'sub', 'before' => '[sub]', 'after' => '[/sub]', 'description' => $editortxt['Subscript']), 'tele' => array('code' => 'tt', 'before' => '[tt]', 'after' => '[/tt]', 'description' => $editortxt['Teletype']), 'code' => array('code' => 'code', 'before' => '[code]', 'after' => '[/code]', 'description' => $editortxt['Code']), 'quote' => array('code' => 'quote', 'before' => '[quote]', 'after' => '[/quote]', 'description' => $editortxt['Insert a Quote'])); } template_shoutbox_embed($shoutbox); }