La version orginale:
<?php /**** * * Shout box test * * * 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, * PRIMARY KEY (`id`) * ) TYPE=MyISAM; * */ function phpblock_shoutblock() { global $_TABLES,$_USER,$HTTP_COOKIE_VARS,$HTTP_POST_VARS,$PHP_SELF,$REMOTE_ADDR,$LANG01,$_CONF; $shout_out = ""; $wrap_width = 20; $max_stories = 5; $welcome = "Welcome to shoutbox.<p>"; $shout_out .= $welcome; if($HTTP_POST_VARS["shout_submit"]) { $shout_name=COM_checkWords(strip_tags($HTTP_POST_VARS["shout_name"])); $shout_message=COM_checkWords(strip_tags($HTTP_POST_VARS["shout_message"])); $result = DB_query("INSERT INTO shoutbox (name,message,time)"."VALUES (\"$shout_name\", \"$shout_message\",now() )"); } $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 .= '<b>' . $A['name'] . '</b>'; $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='$PHP_SELF' method='post'>"; if (!empty($_USER['uid'])) { $shout_out .= '<b>Name: '; $shout_out .= $_USER['username']; $shout_out .= '</b><br><input type=hidden value=\'' . $_USER['username']; } else { $shout_out .= '<b>Name: Anonymous</b><br>'; $shout_out .= "<input type=hidden 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='Shout it!'>"; $shout_out .= "\n</form>"; return $shout_out; }
Et la version de LWC:
<?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; } </php>