The secure CMS.

Welcome to Geeklog
Monday, September 06 2010 @ 12:19 AM EDT


 Forum Index > Extensions > PHP Blocks New Topic Post Reply
 Shout it out!
 |  Printable Version
dreamscape
 January 25 2002 06:02 AM (Read 9999 times)  
Forum Junior
Junior

Status: offline

Registered: 01/22/02
Posts: 30

This started out as an innocent question this morning in #geeklog (yes, people do chat there). Tane asked if I knew of a decent shout box that could be easily converted to a php block for geeklog. Well I didn't.Falkware has a pretty good custom one written by John Holmes. He provided some insight into problems mine might have on the geeklog-devel list. Maybe if you bug him he'll release his super version.


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.


 
Profile Email Website PM
Quote
Tony
 January 25 2002 07:36 AM  
Forum Admin
Admin

Status: offline

Registered: 12/17/01
Posts: 405

If you grabbed the source for this before the time I posted this comment then you will want to update it...we now pass the shout text through COM_checkWords which censors the text and removes any invalid HTML

-----
The reason people blame things on previous generations is that there's only one other choice.


The reason people blame things on previous generations is that there's only one other choice.
 
Profile Email Website PM
Quote
dreamscape
 January 25 2002 08:02 AM  
Forum Junior
Junior

Status: offline

Registered: 01/22/02
Posts: 30

we\'ll keep updating the source as we make changes in both performance and functionality. So you can always come back and see if it\'s different or not. Smile


 
Profile Email Website PM
Quote
dreamscape
 January 31 2002 13:54 PM  
Forum Junior
Junior

Status: offline

Registered: 01/22/02
Posts: 30

I've included the sql you need to create the database in the comments of the source file.


 
Profile Email Website PM
Quote
dreamscape
 January 31 2002 14:04 PM  
Forum Junior
Junior

Status: offline

Registered: 01/22/02
Posts: 30

i also put the count near the top, to show how many shouts you've gotten already.


 
Profile Email Website PM
Quote
Anonymous: Anonymous
 February 02 2002 21:12 PM  


OK, silly question time. What is a "shoutbox"? Is it just a BBS/chat hybrid? Sort of a Usenet/IRC blend that goes on a web site? Or is it something more than that?


 
Quote
Anonymous: Anonymous
 April 24 2002 20:42 PM  


It's just like a minichat room where people can leave you small messages or "shouts" on the main page.


 
Quote
lasttime
 April 25 2002 08:27 AM  
Forum Junior
Junior

Status: offline

Registered: 04/25/02
Posts: 15

Where is the source file. The link http://www.geeklog.net/phpblocks/shoutbox.phps simply does not work.


 
Profile Email Website PM
Quote
isol8
 May 18 2002 08:45 AM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 05/14/02
Posts: 73

How do you configure Shoutbox to show up after installing it? Something is wrong with the way I set up the phpblock. Anybody know how to set it up?

Here's my error
"Shoutbox
Error in PHP Block. Function, , does not exist. "

What is the correct block function and block content?


 
Profile Email Website PM
Quote
Tony
 May 18 2002 19:46 PM  
Forum Admin
Admin

Status: offline

Registered: 12/17/01
Posts: 405

Read the text in the admin/block.php. Your shoutbox code needs to be named with the phpblock_ prefix (e.g. function phpblock_shoutbox())

From there you need to create a new PHP Block in admin/block.php (be sure to select PHP as the type of block) and then it should start working. If you function doesn't hsave the phpblock_ prefix you get the error you are having. This is a security feature...if we didnt' force the use of the phpblock_ prefix you could do some nasty things.


The reason people blame things on previous generations is that there's only one other choice.
 
Profile Email Website PM
Quote
isol8
 May 20 2002 09:08 AM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 05/14/02
Posts: 73

another stupid mistake on my part.

the function is called shoutblock, not shoutbox
so it should be phpblock_shoutblock

thanks tony


 
Profile Email Website PM
Quote
kemal
 May 03 2006 15:16 PM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 04/05/05
Posts: 103

good but i have a little question..

how can i ignore Anonymous posts?


_KEMAL_
 
Profile Email Website PM
Quote
Dirk
 May 08 2006 15:08 PM  
Forum Admin
Admin

Status: offline

Registered: 01/12/02
Posts: 12713

Quote by kemal: how can i ignore Anonymous posts?

You could do what we do here on geeklog.net: Hide the block from anonymous users entirely.

bye, Dirk


 
Profile Email Website PM
Quote
LWC
 May 09 2006 09:36 AM  
Forum Full Member
Full Member

Status: offline

Registered: 02/19/04
Posts: 781

I've stumbled across this topic because it was updated and decided to improve this block.

I've:

  1. Removed many unused variables.
  2. Added IP address' support (note for upgraders: you'd need to add the correct row to the table!).
  3. Made it multilingual (using global enough strings from the official language files, not the hack...).
  4. 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 Formatted Code

<?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;

}


 


 
Profile Email PM
Quote
kemal
 June 23 2006 11:03 AM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 04/05/05
Posts: 103

my register globals is off and nut running soutbox or chatter block!
is there a way?

(i added
extract( $_POST );
extract( $_GET );
to lib-common.php but working again)

what can i do?


_KEMAL_
 
Profile Email Website PM
Quote
LWC
 June 24 2006 04:11 AM  
Forum Full Member
Full Member

Status: offline

Registered: 02/19/04
Posts: 781

[QUOTE lwc]
And most importantly - made it register_globals/register_long_arrays free![/QUOTE]
What part wasn't understood (it's from my post above yours)? Just use my version (and report back).


 
Profile Email PM
Quote
kemal
 June 24 2006 15:53 PM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 04/05/05
Posts: 103

i am using your version but messages not send!

is mysql version a problem??


_KEMAL_
 
Profile Email Website PM
Quote
LWC
 June 24 2006 17:26 PM  
Forum Full Member
Full Member

Status: offline

Registered: 02/19/04
Posts: 781

First of all, it's just a guess but did you run my commented out MySQL command in PHPMyAdmin?

Secondly, if you want more than guesses no one would be able to help you unless you provide your error log.


 
Profile Email PM
Quote
scroff
 June 25 2006 21:29 PM  
Forum Regular Poster
Regular Poster

Status: offline

Registered: 02/19/03
Posts: 111

Hate to sound stupid (so why post, I know )

But what's the difference between this and the chatterblock?


 
Profile Email PM
Quote
LWC
 June 26 2006 04:48 AM  
Forum Full Member
Full Member

Status: offline

Registered: 02/19/04
Posts: 781

I guess it's much more simple and doesn't require you to install a whole plugin (although some may argue creating a database table, editing system/lib_custom.php and creating the block compete with installing a plugin).

Furthermore, because of my improvements, unlike said plugin it's multilingual out of the box and register_globals/register_long_arrays free.


 
Profile Email PM
Quote
Content generated in: 1.22 seconds
New Topic Post Reply



 All times are EDT. The time is now 12:19 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content