News:

Join the Facebook Fan Page.

Main Menu

Shoutbox!

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

Previous topic - Next topic

LancelowDowell

Ok, I did quite a few updates to the shoutbox...  it has a working archive now along with some basic stats.  I also moved it from the index template to the board index template.  The link again...

http://www.cursedlegacy.net/davestuff/shoutbox.zip

You can check it out at http://www.cursedlegacy.net

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

[Unknown]

Looking pretty good, I'd say..

I recommend you change this:
//update shout counter in user profile...
$result = db_query("
SELECT shouts
FROM {$db_prefix}members
WHERE ID_MEMBER=$ID_MEMBER", __FILE__, __LINE__);

$row = mysql_fetch_array($result);
$shouts = $row['shouts']+1;

db_query("
UPDATE {$db_prefix}members
SET shouts = $shouts
WHERE ID_MEMBER=$ID_MEMBER", __FILE__, __LINE__);


To this:
//update shout counter in user profile...
$result = db_query("
UPDATE {$db_prefix}members
SET shouts = shouts + 1
WHERE ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);


As it's much faster... or, actually: (for reasons of later versions possibly requiring this...)
//update shout counter in user profile...
updateMemberData($ID_MEMBER, array('shouts' => '+'));


$shoutPage = $_REQUEST['shoutPage'];
$shoutResults = db_query("
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", __FILE__, __LINE__);

$i = $pageSize * ($shoutPage-1);
//cycles through records till gets to first record of that page
while($i != 0 AND $row=mysql_fetch_array($shoutResults))
{
$i--;
}
$context['shouts']['currentPage'] = $shoutPage;


I smell Microsoft SQL experience!!!  MySQL has an excellent feature for skipping records, namley LIMIT.  Personally, I can't understand how anyone could consider SQL complete without it... but that's just me.

I'd rewrite that whole if block like so:
// Clean the request and make sure it's a number...
$_REQUEST['shoutPage'] = !isset($_REQUEST['shoutPage']) ? 1 : (int) $_REQUEST['shoutPage'];
$context['shouts']['currentPage'] = $_REQUEST['shoutPage'];

$shoutResults = db_query("
SELECT s.userid, s.shoutDate, s.pageText, IFNULL(mem.realName, '$txt[28]') AS 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 " . (($_REQUEST['shoutPage'] - 1) * $pageSize) . ", $pageSize", __FILE__, __LINE__);


I also see you don't have any predefinition for $context['shouts'].  I strongly suggest you set it to an empty array before filling it, just to protect against security holes.

$context['shouts'] = array();

Of course, with the limit, this won't work anymore:
$totalShouts = mysql_num_rows($shoutResults)+1;
$totalPages = ((int)($totalShouts/$pageSize))+1;


So, we need a separate query.... but it's worth it with all the memory and resources we save with the limit, imho...
$shoutCount = db_query("
SELECT COUNT(id)
FROM {$db_prefix}shout", __FILE__, __LINE__);
list ($totalShouts) = mysql_fetch_row($shoutCount);
mysql_free_result($shoutCount);
$totalPages = (int) ($totalShouts / $pageSize) + 1;


Of course, this is all moot considering how lovely the constructPageIndex() function is... it's in Subs.php.

-[Unknown]

Vinoth

does it work on RC1 or Beta 5
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

LancelowDowell

Well, I currently run it in rc1, but I wrote it when I was on beta5.  I don't think I made any changes at all for it.

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

Vinoth

so could work on beta5 too.
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

LancelowDowell

Yes, it should work in beta 5.

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

LancelowDowell

Well, I got to play around with the suggestions you made, [Unknown].... 

Just a quick question...  I've always wondered what's up with $txt...  what is $txt[28]?  I understand what it's being used for... I've seen it in several other files, but I haven't had the time to track it down yet.  Also, is there any documentation on how to build mods into packages yet?

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

Grudge

Quote from: LancelowDowell on August 12, 2004, 05:15:41 PM
Also, is there any documentation on how to build mods into packages yet?

Download any package from my server and load it up - it's easy to work out. Basically, it's just a tar.gz file with a xml file in it called package-info.xml. You just edit that to reflect the work needed to be done. Package servers are just as easy *really*. If you want your own package server go to http://www.mymods.co.uk/Packages/packages.xml for a good start ;)
I'm only a half geek really...

[Unknown]

The $txt array is a huge array (the memory it takes up is sometimes depressing!) that stores all the language strings used.

It is done this way for localization reasons, as you probably know.  The strings are stored in flat files under Themes/themename/languages.  The function loadLanguage() loads extra language files.

You probably realized that $txt[28] is Guest.  In German, it would be Gast.... etc.

Regrettably, there is not currently any extended documentation on packages yet... just not enough hours in a day.

-[Unknown]

trenchteam

I installed this successfully. but it doesnt appear.  Can someone assist me?  http://www.7milesdown.com/forum

LancelowDowell

Did you stick the include shoutbox.php in your display.template.php file?  Is shoutbox.php in all of your theme directories?  Also, check your forum error log, it might be kicking out an error.

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

roboter88

Nice MOD i testing it here

www.beatboxbattle.org/bbn2k4/bbs/

cheers

trenchteam

Quote from: LancelowDowell on August 20, 2004, 10:38:12 PM
Did you stick the include shoutbox.php in your display.template.php file?  Is shoutbox.php in all of your theme directories?  Also, check your forum error log, it might be kicking out an error.


can you give me the code you used to place your shoutbox in your forum.  Im not good with the php mixed with html.  Im not sure where to put it.  Thanks.

roboter88

#33
The download.zip contains a very small readme ...

u must change some files and upload and run a sql statement with phpMyadmin and add a new table to _members table...

Sorry cant sent u my files cause i customized my theme.

BACKUP all files u overwrite and make a DATABASE BAckup if u need more help just ask away :P

l8r

trenchteam

So do I create a seperate SQL database for this?  I was also wondering.  Do i take the code, but it in a notepad document and then upload it to Mysqladmin?  Im not sure how to do this. 

roboter88

#35
No you editing your old existing SMF database.

To do this you need best for phpMyAdmin
QuotephpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges,export data into various formats and is available in 47 languages.  GPL License


Do you have phpMyAdmin?

With this you can manage your MYSQL Database.
eg. Add/Edit/Delete tables

Otherwise go here http://www.phpmyadmin.net/home_page/ and download-
Install is easy - just upload teh extracted directory somewhere to your webspace.

If i remember right all you have to do is editing the config file where u put in the database login(username,host,password,database name).
Host is mostly localhost.

If you done this browse to the directory where you just uploaded phpMyAdmin and now you should see the administrativ backend for your MYSQL database.

Click on "SQL" and run the SQL content as stated in the readme. ( CREATE a new table and INSERT data).
Copy//Past the code from teh readme into the window that pops up after u click teh  SQL link.

At last you have to alter the "*_members" table.

On the left side you see all the tables click on "*_members" and browse down till you find ADD new FIELD - click "GO" and in the new window  you can edit the new table-field as written in teh readme add a table name=shouts typ=int(10) and default=0
That it is - the sql part is done.


About the shoutbox script:

i would request a shouts delete function :)

and i didnt edited the files from the downloaded yet but shouts want show in user profil yet (or i missunderstood something?)...hmmm when i watch at ur site i dont find shouts stats in profil either...where can u see the shouts statistic (if its possibel)?

Here is a nice tutorial about adding custom profil fields.
http://unknown.network32.net/tutorial.smf_custom-profile


Quote
index.php

Find code:

'setreserve2' => array('ManageMembers.php', 'SetReserve2'),

After that add this:

'shout' => array('shout.php', 'Shoutbox'),  //added by dmh 7-26-04
'shoutarchive' => array('shoutArchive.php', 'ShoutboxArchive'), //added by dmh 8-3-04

well i did this in the root index.php still i cant find teh shoutbox admin...where is it located normaly?

@LancelowDowell
QuoteDid you stick the include shoutbox.php in your display.template.php file?
What you mean with "stick" ?
Nothing about that in the readme. hmmm

cheers



LancelowDowell

Yea, I've just been really busy lately and haven't had any time to do any more work on it.  Delete functions are next in line...

If you have a custom display.template.php file, you need to put the shoutbox.php file in that template folder... the way I have it setup needs it wherever the display template is.  Not sure if I put that in the readme file, but I'll have to add that if it's not there....

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

roboter88

#37
The display.template.php is in the theme folder...(eg. classic theme)

But is there an admin or stats display already - cause i cant find....
and teh code counts the stats....


-roboter

Dragon Gamer

ok, i did this too

i'll tell you when i have it up yet. I only dl it so far and i am currently going over the code.
Jason-Marc Labban
Graphic Maker...Sigs, Avatars, Banners and Buttons.



Neo Hacks

Dragon Gamer

Ok i put it up just check http://megagaming.mycubix.com/mega_fourm/index.php

Question ???
How do you take out the date and time from it
I just want to see the name of the members who post, not really when they post or what day.
Jason-Marc Labban
Graphic Maker...Sigs, Avatars, Banners and Buttons.



Neo Hacks

Advertisement: