News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

nneonneo's Shoutbox

Started by nneonneo, December 26, 2006, 06:58:11 PM

Previous topic - Next topic

nando1965


This is my code, nneonneo's AJAX ShoutBox 1.21:

  // YSHOUT HERE - shoutbox code
       
   global $txt,$context,$boarddir;
   if(allowedTo('yshout_view'))
   {
      echo '<br /><b>',$txt['yshout_shoutbox'],'</b><br /><br />';
      echo '<div id="yshout">';
      include_once($boarddir.'/yshout/yshout.php');
      echo '</div>';
   
      echo '</div><div class="smalltext" style="padding-left:25px;"></a>';
                     require('mymod/smiley.php');
                     loadSmileys();
      echo '
           <div id="check_smileys">'; printSmileys('shout_form','shout_text');
      echo '
          </div>
                     
      </div>';
   }
   elseif($context['user']['is_guest'])
      echo $txt['yshout_no_guests'];
   // YSHOUT END - shoutbox code



but after update to the SMF 1.1.7, the Smileys have not sent over the code for the shoutbox.

Please let me help's

Nando1965 

PipeRain

Quote from: nneonneo on November 25, 2008, 02:19:26 AM
@PipeRain: Well, you have another option: you can force the Package Manager to uninstall the shoutbox for you.

The procedure is as follows: download the 1.11 package to your computer and unzip it. Open up package-info.xml, and change
<uninstall for="1.1.0-1.1.4">
to
<uninstall for="1.1.0-1.1.9">
Zip everything back up into a package (with package-info.xml and other files at the top level) and upload that changed package to the server. You should then be able to simply uninstall it without any issues.

Or, you could opt to manually reverse the instructions in install.xml to uninstall the mod (you can consult the main mod page for the 1.11 manual install instructions)

1.21 *should* install cleanly provided the modifications to index.template.php and elsewhere are not too severe. Again, manual instructions can be had from the main mod page.


Thanks!

I'll give it a whirl in the morning when I'm not so bleary-eyed...

fext

I have a problem...

Hi dude,

I did a clean install of SMF 1.1.7 on a new server and I am using simpleportal and I have managed to install the shoutbox but for some reason it says "Sorry, you must be logged in to use the shoutbox!" and I am the admin?

I have changed perms on the chat txt files and looked into perms for admin (says all perms/no edit required), reg members also have perms to view/use it and I also set up a test account but it still won't work?
Does anyone have any ideas regarding this?

Please help... Cheers!

natefish

For the most part I have this mod working the way I want it to. It is awesome, and very easy to edit. :)

I found the change (several pages back) about being able to have it update when someone posts a new topic. I have a few questions about this feature:

1.  Is it possible to make it link to the topic and display the forum that it was posted in?

Right now it just says "Bob: NEW TOPIC POSTED! -- <Name of topic here>."

I'd like it to appear as "Bob: NEW TOPIC POSTED in <Forum Name Here>! -- <Link to Topic Here>."


2. Is it possible to have it update with replies to topics? Like this:

"Bob: REPLIED to the topic <Link to reply here>."


And finally....


3. Is it possible to have this not work in hidden forums? We have moderator-only forums and I don't want it to show the new topics (or replies) that are posted in that forum.

Dordt

error in shoutbox

Notice: Undefined variable: smcFunc in /mounted-storage/home65b/sub009/sc41673-EFEQ/www/smf/yshout/yshout.php on line 203

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /mounted-storage/home65b/sub009/sc41673-EFEQ/www/smf/Sources/Subs.php on line 321

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /mounted-storage/home65b/sub009/sc41673-EFEQ/www/smf/Sources/Errors.php on line 123

Warning: mysql_errno(): supplied argument is not a valid MySQL-Link resource in /mounted-storage/home65b/sub009/sc41673-EFEQ/www/smf/Sources/Errors.php on line 124



DarkRage64

Quote from: nneonneo on November 23, 2008, 03:05:21 PM
@DarkRage64: Check the server error log (not the forum error log). There's likely to be an entry in there about the shoutbox.

I asked my hostingcompany about the error log of the server, but they told me, that they cant find anything there.

They ask if your script runs any other processes (like sendmail, exec())...?!

natefish

#4486
OK. My friend owns the server we are running the site on, so we have a somewhat unique view of things.

It seems as though the shoutbox is generating 1000's of HTTP requests and at the same time, it has created nearly 200MB of an access log in just under 1 week.

It caused the entire server (which hosts ~30 websites) to crash entirely just about 1 hour ago.

EDIT: We fixed it. Seems as though the 500ms refresh setting (default) was too fast for our site's traffic. Upped it to 1.5s and things seem to be better. We'll see where it goes in about a week.

freudlund

Couldn't it be an idea to divide this thread? I dont know compatibility between versions, but lets say one thread for 1.1.1-1.1.x, 1.1.6(5)-1.1.7, and one for 2.0.4? There are 4500 posts in one thread, and I for one am struggling to find what Q&A refers to what version? have only fiddled a little with 1.1.6/7 and now 2.0.4, already there i'm lost...or maybe someone could extract a 10 post FAQ for the major or most recent or different versions(of wich 2.0.4 i think is one?) ?
Just a humble idea from one who really tried using the search funtion, but failed....

nneonneo

#4488
@nando1965: SMF 1.17 should not have changed anything if you installed it by patch. This is probably something best dealt with if I just visit your forum to see the problem firsthand.

@natefish: All three are possible, with extra code. The link to the topic is
$scripturl . '?topic=' . $topic . '.new#new'

The forum name, though, is a little more difficult. The problem is mainly due to the fact that the notify function only knows the board *number* but not the board *name*. Another query would likely be needed to do that, for example
$res = db_query("
SELECT
b.name
FROM ({$db_prefix}boards AS b)
WHERE b.ID_BOARD = $board", __FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
if($row) $boardName = $row['name'];

at which point $boardName contains the name of the board.

To prevent this from showing up for certain boards, wrap the whole thing in
if(!in_array($board,array(HIDDEN BOARD IDS))) {
CODE
}

where HIDDEN BOARD IDS is a comma-separated list of board IDs to hide.

All together:
if(!in_array($board,array(HIDDEN BOARD IDS))) {
$res = db_query("SELECT b.name FROM ({$db_prefix}boards AS b) WHERE b.ID_BOARD = $board", __FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
if($row) $boardName = $row['name'];
ob_start();
global $context;
include_once('yshout/yshout.php');
makeShout('New Topic in board [url='.$scripturl.'?board='.$board.']'.html_entity_decode($boardName).'[/url]: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.$_POST['subject'].'[/url]');
ob_end_clean();
}


For reply notification, add
if($type=='reply') {
ob_start();
global $context;
include_once('yshout/yshout.php');
makeShout('New reply: [url='.$scripturl . '?topic=' . $ID_TOPIC . '.new;topicseen#new'.']'.$subject.'[/url]');
ob_end_clean();
}

after
if ($type == 'reply' && !empty($sent))
db_query("
UPDATE {$db_prefix}log_notify
SET sent = 1
WHERE ID_TOPIC = $ID_TOPIC
AND ID_MEMBER != $ID_MEMBER", __FILE__, __LINE__);

in Subs-Post.php.

This ONLY works in SMF 1.1.x!

@DarkRage64: No other processes are executed. The shoutbox only interacts with two files (chats/home.txt and chats/history.home.txt) and the SMF functions.

@Dordt: SMF 2.0?

@freudlund: I understand the problem. The main mod page has a number of topics and such, but it is definitely challenging to face such a large thread.

Unfortunately, I don't have the ability to split the thread. One thing that might be useful: the main mod page has links to each post where I announce a new version. That gives you a rough estimate of where to start (however, given that 1.21 is already a few months old, that's still a lot of posts to go through).

I have no problem with answering questions that have been asked before, so you may go ahead and just ask the question directly ^^
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

nneonneo

#4489
This is a how-to for making the shoutbox notify on new topics or posts (with thanks to Gaugenstien for the idea and natefish for suggesting improvements).

For shoutbox versions 1.21 or lower, make this change:
In yshout/yshout.php, find
session_write_close(); // so that future session requests succeed
$heartBeatSent=false;
if(!$forceRefresh)
{
while((time() - $start_time < $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
}
@session_start(); // restart session, so updates to $_SESSION are applied

and replace by
$heartBeatSent=false;
if(!$forceRefresh)
{
session_write_close(); // so that future session requests succeed
while((time() - $start_time < $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
@session_start(); // restart session, so updates to $_SESSION are applied
}


Edit Post.php.
For SMF 1.1.x, find
if ($newTopic)
notifyMembersBoard();
elseif (empty($_REQUEST['msg']))
sendNotifications($topic, 'reply');

and change it to
if ($newTopic) {
notifyMembersBoard();
// YSHOUT TOPIC NOTIFICATION
$res = db_query("
SELECT
b.name
FROM ({$db_prefix}boards AS b)
WHERE b.ID_BOARD = $board", __FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
if($row) $boardName = $row['name'];
ob_start();
global $context,$scripturl,$topic;
include_once('yshout/yshout.php');
makeShout('New Topic in board [url='.$scripturl.'?board='.$board.']'.html_entity_decode($boardName).'[/url]: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url]');
ob_end_clean();
// YSHOUT TOPIC NOTIFICATION END
}
elseif (empty($_REQUEST['msg'])) {
sendNotifications($topic, 'reply');
// YSHOUT REPLY NOTIFICATION
ob_start();
global $context,$scripturl;
include_once('yshout/yshout.php');
makeShout('New reply: [url='.$scripturl . '?topic=' . $topic . '.new;topicseen#new'.']'.html_entity_decode($_POST['subject']).'[/url]');
ob_end_clean();
// YSHOUT REPLY NOTIFICATION END
}


For SMF 2.0, change
if ($newTopic)
{
$notifyData = array(
'body' => $_POST['message'],
'subject' => $_POST['subject'],
'name' => $user_info['name'],
'poster' => $user_info['id'],
'msg' => $msgOptions['id'],
'board' => $board,
'topic' => $topic,
);
notifyMembersBoard($notifyData);
}
elseif (empty($_REQUEST['msg']))
{
// Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it.
if ($topic_info['approved'])
sendNotifications($topic, 'reply');
else
sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']);
}

to
if ($newTopic)
{
$notifyData = array(
'body' => $_POST['message'],
'subject' => $_POST['subject'],
'name' => $user_info['name'],
'poster' => $user_info['id'],
'msg' => $msgOptions['id'],
'board' => $board,
'topic' => $topic,
);
notifyMembersBoard($notifyData);
// YSHOUT TOPIC NOTIFICATION
$res = $smcFunc['db_query']('','SELECT b.name
FROM ({db_prefix}boards AS b)
WHERE b.ID_BOARD = {int:board}', array('board' => $board));
$row = $smcFunc['db_fetch_assoc']($res);
if($row) $boardName = $row['name'];
ob_start();
global $context,$scripturl;
include_once('yshout/yshout.php');
makeShout('New Topic in board [url='.$scripturl.'?board='.$board.']'.html_entity_decode($boardName).'[/url]: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.html_entity_decode($_POST['subject']).'[/url]');
ob_end_clean();
// YSHOUT TOPIC NOTIFICATION END
}
elseif (empty($_REQUEST['msg']))
{
// Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it.
if ($topic_info['approved']) {
sendNotifications($topic, 'reply');
// YSHOUT REPLY NOTIFICATION
ob_start();
global $context,$scripturl;
include_once('yshout/yshout.php');
makeShout('New reply: [url='.$scripturl . '?topic=' . $topic . '.new;topicseen#new'.']'.html_entity_decode($_POST['subject']).'[/url]');
ob_end_clean();
// YSHOUT REPLY NOTIFICATION END
}
else
sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']);
}


You may omit either NOTIFICATION block.

To prevent notification for hidden boards, wrap both NOTIFICATION blocks in this code, substituting <BoardIDs> with a comma-separated list of hidden boards (e.g. 3,5,8)
if(!in_array($board, array(<BoardIDs>))) {
// YSHOUT -- NOTIFICATION
...
// YSHOUT -- NOTIFICATION END
}


To open links in the same window, use "[iurl=" instead of "[url=".
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

nneonneo

@nando1965: I think the name= fields have gone missing on the shoutbox. No worries, it is easy to fix. Just do step 5 on http://www.simplemachines.org/community/index.php?topic=137508.msg1388091#msg1388091.
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

tyhgdgh

how do i add a scroller bar in ADVance Shoutbox??

nneonneo

Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

fext

Quote from: nneonneo on November 26, 2008, 06:09:01 PM
@nando1965: SMF 1.17 should not have changed anything if you installed it by patch. This is probably something best dealt with if I just visit your forum to see the problem firsthand.

@natefish: All three are possible, with extra code. The link to the topic is
$scripturl . '?topic=' . $topic . '.new#new'

The forum name, though, is a little more difficult. The problem is mainly due to the fact that the notify function only knows the board *number* but not the board *name*. Another query would likely be needed to do that, for example
$res = db_query("
SELECT
b.name
FROM ({$db_prefix}boards AS b)
WHERE b.ID_BOARD = $board", __FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
if($row) $boardName = $row['name'];

at which point $boardName contains the name of the board.

To prevent this from showing up for certain boards, wrap the whole thing in
if(!in_array($board,array(HIDDEN BOARD IDS))) {
CODE
}

where HIDDEN BOARD IDS is a comma-separated list of board IDs to hide.

All together:
if(!in_array($board,array(HIDDEN BOARD IDS))) {
$res = db_query("SELECT b.name FROM ({$db_prefix}boards AS b) WHERE b.ID_BOARD = $board", __FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
if($row) $boardName = $row['name'];
ob_start();
global $context;
include_once('yshout/yshout.php');
makeShout('New Topic in board [url='.$scripturl.'?board='.$board.']'.html_entity_decode($boardName).'[/url]: [url='.$scripturl . '?topic=' . $topic . '.new#new'.']'.$_POST['subject'].'[/url]');
ob_end_clean();
}


For reply notification, add
if($type=='reply') {
ob_start();
global $context;
include_once('yshout/yshout.php');
makeShout('New reply: [url='.$scripturl . '?topic=' . $ID_TOPIC . '.new;topicseen#new'.']'.$subject.'[/url]');
ob_end_clean();
}

after
if ($type == 'reply' && !empty($sent))
db_query("
UPDATE {$db_prefix}log_notify
SET sent = 1
WHERE ID_TOPIC = $ID_TOPIC
AND ID_MEMBER != $ID_MEMBER", __FILE__, __LINE__);

in Subs-Post.php.

This ONLY works in SMF 1.1.x!

@DarkRage64: No other processes are executed. The shoutbox only interacts with two files (chats/home.txt and chats/history.home.txt) and the SMF functions.

@Dordt: SMF 2.0?

@freudlund: I understand the problem. The main mod page has a number of topics and such, but it is definitely challenging to face such a large thread.

Unfortunately, I don't have the ability to split the thread. One thing that might be useful: the main mod page has links to each post where I announce a new version. That gives you a rough estimate of where to start (however, given that 1.21 is already a few months old, that's still a lot of posts to go through).

I have no problem with answering questions that have been asked before, so you may go ahead and just ask the question directly ^^

This is a great enhancement! I was just wondering could the same be applied to members signing in and out of the forum - so if you follow when a member signs in it would reflect this in the shoutbox - something like "member A has just signed in" and "member B has just signed out".

Is this possible?

nneonneo

While it is possible, it is unlikely that this will give you the results you probably want, since most people I know will just close the browser when done, rather than logging in/out. So, you would get very few notifications about status changes (only when people use a public computer or one they have not been on before will they have to login and logout).
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

nneonneo

[announce] SB_1.22 and AdvSB_1.22 released.

Major fixes for 1.22:
Compatibility with SMF 2.0 Beta 4

1.22 should upgrade over a 1.21 installation. If there are any problems in upgrading, try a manual install (use upgrade-from-1.21.xml as a reference).
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

nando1965

Quote from: nneonneo on November 26, 2008, 07:08:13 PM
@nando1965: I think the name= fields have gone missing on the shoutbox. No worries, it is easy to fix. Just do step 5 on http://www.simplemachines.org/community/index.php?topic=137508.msg1388091#msg1388091.

The problem is resolved.

Thank's Nneonneo.

Nando1965

fext

#4497
Hey Neo,

I have a problem with the topic notification - it redirects to a new page and not back to the forum topic?

I am running 1.1.7 and I have 'return to topic' switched on so would this affect it at all? When I click on the browser back button it takes me back to the reply wysiwyg screen and then when i click to the home page on portal the shout reflects a post has been made but it is this intermittent error...

Here is the URL i get (see pic 1): http://url.co.uk/subfolder/index.php?action=post2;start=2;board=10

See pic 2 to see what i get after hitting back button then clicking home button.

Any ideas?

nneonneo

@Youngiiie:

In yshout/yshout.php, find
session_write_close(); // so that future session requests succeed
$heartBeatSent=false;
if(!$forceRefresh)
{
while((time() - $start_time < $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
}
@session_start(); // restart session, so updates to $_SESSION are applied

and replace by
$heartBeatSent=false;
if(!$forceRefresh)
{
session_write_close(); // so that future session requests succeed
while((time() - $start_time < $updateTimeout) && ($time==filemtime($chatPath)))
{
usleep($updatePeriod*1000);
// heartbeat - check connection to ensure client is still connected
echo ' ';
flush();
ob_flush();
$heartBeatSent=true;
clearstatcache();
}
@session_start(); // restart session, so updates to $_SESSION are applied
}
Check out the AJAX Shoutbox (my one and only mod to date :P)
Do you like SMF? Are you using ProBoards, InvisionFree, ActiveBoards or some other web-hosted forum? I can help you convert to SMF (without having to purchase a DB conversion)...contact me [nneonneo {at} gmail *dot* com], and see this topic
spammers here!

fext

Cheers bro - works great now!

Advertisement: