Shoutbox!

Started by LancelowDowell, July 26, 2004, 07:48:41 PM

Previous topic - Next topic

LancelowDowell

Not sure where this should go, since there really isn't a hack forum anywhere....  but anyways...

Well, I have most of my shoutbox coding done..  It's now functional, just has a few minor tweaks to make it fit on the board better.  You can check it out at http://www.cursedlegacy.net/smf.  I'll be doing a quick write up on how to set it up.  Let me know what you think!

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

Peter Duggan

Did you know that Grudge has already done a shoutbox mod, but the SMF mod site hasn't been fully implemented yet?

LancelowDowell

eh, actually i wasn't aware of that....  i still had fun doing in though! :-)

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

Grudge

Quote from: LancelowDowell on July 26, 2004, 10:43:11 PM
eh, actually i wasn't aware of that.... i still had fun doing in though! :-)
Heh - always space for more than one mod of the same type ;) Feel free to download my version from my package server if it helps you. Besides - my shoutbox is more a port of Greg Haase's than my own work!
I'm only a half geek really...

[Unknown]

(and who knows, they might be completely different?)

-[Unknown]

LancelowDowell

#5
Ok, finally got around to putting this together enough to post....  if you have any questions please let me know!  Also, feel free to hack out the comments I put in, those were just in there for my records.


Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

[Unknown]

Quote from: LancelowDowell on August 01, 2004, 12:19:50 AM
you'll just have to put a copy of shoutbox.php in the template folders

Actually, you don't even have to do that ^_^.  Just put it in default and it should work for all themes - assuming you edit index.template.php for each.

Hmm, okay.  In your header for shout.php, you use tabs... which doesn't align the *'s properly in my editor.

include('Settings.php');
require('SSI.php');
include($sourcedir . '/Subs-Post.php');
include_once($sourcedir . '/Security.php');


Only the second and third should be necessary. (Security and Settings are loaded by SSI.php...)

redirectexit('');
Nitpick: I'd recommend just redirectexit();...

'$currentDate[0]'
I recommend replacing that with " . time() . ".

if($user['id']=="")
{
//do nothing since it's a guest.
}
else

I recommend using instead:
if(!$user_info['is_guest'])

And instead of using:
$user = ssi_welcome('array');
I would just say:
global $user_info, $ID_MEMBER;
And replace:
{$user['id']}
With:
$ID_MEMBER

And, shoutbox.php might be more efficient if you made this:
SELECT userid, shoutDate, pageText
FROM {$db_prefix}shout
order by id desc
limit 10", __FILE__, __LINE__);

Read instead:
SELECT s.userid, s.shoutDate, s.pageText, mem.realName
FROM {$db_prefix}shout AS s
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = s.userid)
ORDER BY id DESC
LIMIT 10", __FILE__, __LINE__);


And then remove:
$shoutUser = db_query("
SELECT realName
FROM {$db_prefix}members
WHERE ID_MEMBER=" . $row["userid"] . "
limit 1", __FILE__, __LINE__);

$row2 = mysql_fetch_array($shoutUser);


And make:
$row2['realName']
Instead:
$row['realName']

I know I nitpick a lot, but I do it equally to everyone - just ask Grudge ^_^.

-[Unknown]

LancelowDowell

#7
actually for some reason I had to run the include on settings and security...  I didn't play with it a whole lot, but I couldn't get it to work unless I included those files...

Thanks for the comments though.  Most of that stuff I didn't know about, like the user id and such.  I'll have to change the sql statement as well...  not a big deal having 2 statements vs 1, but every little bit helps.


Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

[Unknown]

Quote from: LancelowDowell on August 01, 2004, 12:41:49 AM
Thanks for the comments though.  Most of that stuff I didn't know about, like the user id and such.  I'll have to change the sql statement as well...  not a big deal having 2 statements vs 1, but every little bit helps.

Actually, it's 1 + n where n is the number of shouts.... that's a bit more, isn't it?

You need to include Security.php, really?  Strange, I'll see if I can look into that.

-[Unknown]

LancelowDowell

hmm, I just commeted that out, and it's working fine now....  I can't recall what was excatly happening that cause me to add that, but if it's working fine now....

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

LancelowDowell

I do need settings though... I get this error when I comment out settings.  Looks like it can't find subs-post since it doesn't have the sourcedir from settings.

Notice: Undefined variable: sourcedir in /u/htdocs/ribcra/smf/Sources/shout.php on line 19
Warning: shoutbox(/Subs-Post.php) [function.shoutbox]: failed to create stream: No such file or directory in /u/htdocs/ribcra/smf/Sources/shout.php on line 19
Warning: shoutbox() [function.shoutbox]: Failed opening '/Subs-Post.php' for inclusion (include_path='.:/usr/local/lib/php') in /u/htdocs/ribcra/smf/Sources/shout.php on line 19

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

[Unknown]

Try this instead:

global $sourcedir;

-[Unknown]

LancelowDowell

Hmm, I also tried your change for the guest thing, but it didn't pick up that I was a guest.  It still posted the shout with no user name.

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

LancelowDowell

eh, nm, i think i see what i did wrong....

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

[Unknown]

Okay, well, interesting.  Here, try the attached - does it work?

-[Unknown]

LancelowDowell

worked for a normal insert, but when I was logged in as a guest, it didn't run redirectexit(); because of the return command.  So it just hung the page...  so I replaced the return; with a redirectexit(); and looks a bit better now.

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

LancelowDowell

also, just a question since I couldn't find it on my digging through code...  where is the text processor for output?  It runs the preparse and sets up the user's text, but I couldn't find any of the functions to do the reverse...

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

[Unknown]

For output?  You mean the one that parses smileys and bbc?

It's doUBBC() in Subs.php, use it like so:

echo doUBBC($string, $useSmileys);

Where $string is the string to parse, and $parseSmileys is true or false, whether you want them parsed or not.

-[Unknown]

LancelowDowell


Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

LancelowDowell

Just a few updates I did to it....  I cleaned up the html a little bit, I had a small type that was causing some screwy things.  I also fixed it up so that when a guest is logged in, it won't display the text box.  Next in line will be an archive and basic stats....

Dave Hurt
Support Specialist
[email protected]
       
Personal Signature:
www.cursedlegacy.net

Advertisement: