Welcome to Geeklog, Anonymous Thursday, November 21 2024 @ 06:24 pm EST
Geeklog Forums
Shout it out!
Page navigation
dreamscape
Beyond that, there wasn't much, so I did a little research and finally said we can do this ourselves. So that is what we set out to do, and did.
This is how to do it:
1) Add this mysql to your database:
CREATE TABLE `shoutbox` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
`time` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
2) Get your table listed in $_TABLES: You need to go to ~/geeklog/system/lib-database.php and at the bottom of a long list of $_TABLES, you want to add this:
$_TABLES['shoutbox'] = 'shoutbox';
3) Now add the code to lib-custom.php file in the system directory. You can get the source for it here
Just don't include the tags in lib-custom.php
4) Configure it how you want it to act. There are 3 variables you might want to edit:
$wrap_width, the number of columns you want to wrap at. Very useful so someone doesn't type xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with no space (thanks John).
$max_stories, how many shouts you want to show at any given time.
$welcome, just a quick message that will be displayed over the form input.
This was a quick hack to make something work. The database structure came from Spoono and John Holmes helped with some sticking points we didn't see.
If you have anything to add, ways to make it better, or just find an error let us know.
Tony
The reason people blame things on previous generations is that there's only one other choice.
dreamscape
dreamscape
dreamscape
Anonymous
Anonymous
isol8
Tony
The reason people blame things on previous generations is that there's only one other choice.
LWC
I've:
- Removed many unused variables.
- Added IP address' support (note for upgraders: you'd need to add the correct row to the table!).
- Made it multilingual (using global enough strings from the official language files, not the hack...).
- And most importantly - made it register_globals/register_long_arrays free!
I suggest to everyone to ignore instructions #1 and #2 from the original post as I've replaced #1 with new instructions and #2 (hacking Geeklog) was not correct anyway. The original block as well as mine call the table directly. I see no sense in doing it otherwise unless it was an official plugin.
Note: I haven't tested it! Please provide feedback.
I hope to see my version used on the PHPS file as well...and on this site's block, of course.
<?php
/*
*
* Shout box test
*
* Modified by: @ LWC
* http://lior.weissbrod.com
* Version 2
*
* you need to put this in your database:
CREATE TABLE `shoutbox` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
`time` text NOT NULL,
`remote_address` text NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
*/
function phpblock_shoutblock()
{
global $_CONF, $_USER, $LANG03, $LANG08;
$shout_out = "";
$wrap_width = 20;
$max_stories = 5;
$welcome = $LANG03[1] . ":<p>";
$shout_out .= $welcome;
if($_POST["shout_submit"])
{
$shout_name=COM_checkWords(strip_tags($_POST["shout_name"]));
$shout_message=COM_checkWords(strip_tags($_POST["shout_message"]));
$shout_remote_address=COM_checkWords(strip_tags($_POST["shout_remote_address"]));
$result = DB_query("INSERT INTO shoutbox (name,message,time,remote_address)"."VALUES (\"$shout_name\", \"$shout_message\",now(), \"$shout_remote_address\" )");
}
$count = DB_query("select count(*) as count from shoutbox");
$A = DB_fetchArray($count);
$shout_out .= '<b>' . $A['count'] . '</b> shouts already<p>';
$result = DB_query("select * from shoutbox order by id desc limit $max_stories");
$nrows = DB_numrows($result);
for ($i =1; $i <= $nrows; $i++) {
$A = DB_fetchArray($result);
$shout_out .= '<a title="' . $A['remote_address'] . '"><font color=blue><u><b>' .
$A['name'] . '</b></u></font></a>';
$thetime = COM_getUserDateTimeFormat($A['time']);
$shout_time = $thetime[0];
$shout_out .= '<i> on ' . $shout_time . '</i><br>';
$shout_out .= wordwrap($A['message'],$wrap_width,"<br>", 1) . '<br><br>';
}
$shout_out .= "\n<form name='shoutform' action='" . $_SERVER['PHP_SELF'] . "' method='post'>";
$shout_out .= "\n<input name='shout_remote_address' type=hidden value='" . $_SERVER['REMOTE_ADDR'] . "'>\n";
$shout_out .= '<b>' . $LANG08[11] . ':';
if (!empty($_USER['uid'])) {
$shout_out .= " " . $_USER['username'];
$shout_out .= '</b><br><input type=hidden value=\'' . $_USER['username'];
}
else
{
$shout_out .= '</b><br>';
$shout_out .= "<input type=text value='Anonymous";
}
$shout_out .= "' name='shout_name' ><b>Message:<b>";
$shout_out .= "\n<input type='text' value='Your Message' name='shout_message' size=20 maxlength='100'><br>";
$shout_out .= "\n<input type='submit' name='shout_submit' value='" . $LANG03[11] . "'>";
$shout_out .= "\n</form>";
return $shout_out;
}
LWC
Furthermore, because of my improvements, unlike said plugin it's multilingual out of the box and register_globals/register_long_arrays free.
Page navigation
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content