SimplePortal
Customization => Custom Coding => Topic started by: ccbtimewiz on October 05, 2011, 03:36:00 PM
-
The following edits allow guests to shout in the shoutbox.
SMF version: 2.0 series
SP version: 2.3 series
(http://i.imgur.com/2AAtQ.png)
Open ./Sources/PortalShoutbox.php
Find:
function sportal_create_shout($shoutbox, $shout)
{
global $smcFunc, $user_info;
Replace with:
function sportal_create_shout($shoutbox, $shout)
{
global $txt, $smcFunc, $user_info;
Find:
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
Replace with:
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
if ($user_info['is_guest'])
{
if (!isset($_SESSION['guest_has_shouted']))
{
$_SESSION['guest_has_shouted'] = rand(10, 1000);
$user_info['name'] = $txt['guest'] . $_SESSION['guest_has_shouted'];
$user_info['id'] = 0;
}
else
$user_info['name'] = $txt['guest'] . (!empty($_SESSION['guest_has_shouted']) ? $_SESSION['guest_has_shouted'] : rand(10, 1000));
}
Find:
if (!empty($_REQUEST['shout']))
{
checkSession('request');
is_not_guest();
Replace with:
if (!empty($_REQUEST['shout']))
{
checkSession('request');
//is_not_guest();
Open ./Sources/Subs-Portal.php
Find:
if ($user_info['is_guest'])
return false;
Replace with:
//if ($user_info['is_guest'])
//return false;
Find:
'name' => $row['member_name'],
Replace with:
'name' => (!empty($row['member_name']) ? $row['member_name'] : $txt['guest']),
Find:
'link' => $row['id_member'] ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(timeformat($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>') : $row['member_name'],
Replace with:
'link' => $row['id_member'] ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(timeformat($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>') : (!empty($row['member_name']) ? $row['member_name'] : $txt['guest']),
Open ./Sources/PortalBlocks.php
Find:
if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id'])
{
checkSession();
is_not_guest();
Replace with:
if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id'])
{
checkSession();
//is_not_guest();
Open ./Themes/default/Portal.template.php
Find:
if ($context['can_shout'])
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
Replace with:
if ($context['can_shout'] || $context['user']['is_guest'])
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
-
Can I see a screen shoot?
-
(http://i.imgur.com/1W5IZ.png)
-
People may want to think about this.
Is a good way for a shoutbox to be spammed.
-
Well, the shoutbox by default doesn't have a really good anti-spam mechanism in the first place.
I might add my own mechanism when I update this code.
-
Also, I made it so each guest has their own random ID when they comment, so you can tell them apart if you have multiple guests.
After performing my instructions in the first post, do this as well..
(note that I now include this in my post)
Open ./Sources/Subs-Portal.php
Find:
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
Replace with:
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
if ($user_info['is_guest'])
{
if (!isset($_SESSION['guest_has_shouted']))
{
$_SESSION['guest_has_shouted'] = rand(10, 1000);
$user_info['name'] = $txt['guest'] . $_SESSION['guest_has_shouted'];
$user_info['id'] = 0;
}
else
$user_info['name'] = $txt['guest'] . (!empty($_SESSION['guest_has_shouted']) ? $_SESSION['guest_has_shouted'] : rand(10, 1000));
}
(http://i.imgur.com/2AAtQ.png)
-
The screen shoots of this code you made. Look neat.
I have a Q for you. If you have few shout boxer that code will input all them? If you have one shout box hidden from guests and other have guests and members?
I'm so sorry If I get the words in the wrong order. Please forgive me
-
All permissions are respected. If a guest cannot view a particular shoutbox, they cannot use it. However, if guests can see the shoutbox, they can use it no matter what other settings you have. If you want to make a read-only shoutbox to guests, then it's best not to use this code adaption.
-
I'm just making sure. Because I am thinking to use this code on my forum.
I do thank you!
-
I can write exceptions for you if you really need to make it so you have a shoutbox visible to guests but they can't use that particular one. Just let me know, it's fairly easy to hardcode in.
I'm open for other block requests or modifications to blocks via PM too if anyone has some ideas, though note that everything I write is mine, and I reserve the right to post it in public or reuse it as I see fit. I might be making an edit to the Who's Online that groups it.
-
I would really, really, like to utilize this function, but it doesn't appear to be compatible with SMF 2.0.2
Is there a way to get a version for the newest SMF?
-
any idea how to do this in 2.3.4
looked at the code and it is completely different
-
any idea how to do this in 2.3.4
looked at the code and it is completely different
Don't you mean 2.3.5?
-
Yes that would be preety well if any one change this code to 2.3.5 version.
-
I don't know if I can post this as Package, so here is update for SP 2.3.5 :)
Open: $sourcedir/PortalShoutbox.php
if (!empty($_REQUEST['shout']))
{
checkSession('request');
is_not_guest();
if (!empty($_REQUEST['shout']))
{
checkSession('request');
//is_not_guest();
Open: $sourcedir/Subs-Portal.php
function sportal_create_shout($shoutbox, $shout)
{
global $smcFunc, $user_info;
function sportal_create_shout($shoutbox, $shout)
{
global $smcFunc, $user_info, $txt;
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
if (trim(strip_tags(parse_bbc($shout, false), '<img>')) === '')
return false;
if ($user_info['is_guest'])
{
if (!isset($_SESSION['guest_has_shouted']))
{
$_SESSION['guest_has_shouted'] = rand(10, 1000);
$user_info['name'] = $txt['guest'] . $_SESSION['guest_has_shouted'];
$user_info['id'] = 0;
}
else
$user_info['name'] = $txt['guest'] . (!empty($_SESSION['guest_has_shouted']) ? $_SESSION['guest_has_shouted'] : rand(10, 1000));
}
if ($user_info['is_guest'])
return false;
//if ($user_info['is_guest'])
//return false;
'name' => $row['member_name'],
'name' => (!empty($row['member_name']) ? $row['member_name'] : $txt['guest']),
'link' => $row['id_member'] ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(timeformat($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>') : $row['member_name'],
'link' => $row['id_member'] ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(timeformat($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>') : (!empty($row['member_name']) ? $row['member_name'] : $txt['guest']),
Open: $sourcedir/PortalBlocks.php
if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id'])
{
checkSession();
is_not_guest();
if (!empty($_POST['new_shout']) && !empty($_POST['submit_shout']) && !empty($_POST['shoutbox_id']) && $_POST['shoutbox_id'] == $shoutbox['id'])
{
checkSession();
//is_not_guest();
Open: $themedir/PortalShoutbox.template.php
if ($context['can_shout'])
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
if ($context['can_shout'] || $context['user']['is_guest'])
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
-
Isn't a little bit silly to allow guests to chat in the first place? Cause then you'll get spammers and idiot's flooding the shoutbox? No offense.
-
I'm sure that if someone wants to make this edits knows what is he doing :)
But if I remember correctly, there is mod (at SMF Mod Site) for blocking bots before they enter site? Then maybe this can be used as some kind of 'anti-spam' :E
-
Isn't a little bit silly to allow guests to chat in the first place? Cause then you'll get spammers and idiot's flooding the shoutbox? No offense.
It depends on what your board is for. In the RP community, guests expect to be able to interact with a site before they decide to join, so guest shouts are incredibly important. It's not the best option in every situation, but I think it's up to the admin to make that choice. :)
-
its something that site owners will or wont use. We are discussing it as we have shoutboxes dedicated to races when they happen, that always have a moderator present so are looking if its a viable option to bring in new members who hopefully then register.
but its not without its pitfalls.
Useful for specific events with a dedicated shoutbox and moderation, total clustermess for unmoderated shoutboxes.
-
Hi
Just reopening the old issue of the shoutbox -I need help
I need to allow guests to see the shoutbox activity without ability of shouting
By me guests can not see the shoutbox
Any advice is appreciated.
Regards
Ilya
You just need to give permission to guests too (both for the shoutbox and block) and they will be able to see the shoutbox but they won't be able to shout. (like we have here)
-
phantomm you are nice! thanks for share! :applause: :thumbsup:
-
Has anything new been done about this? Ideally, I would like to see a package for this mod and an easy way to deny access to the shout box by guest if we start getting a lot of spam.