TinyPortal
Development => Resources => Topic started by: kanga on July 07, 2007, 10:45:13 AM
Hey guys, i recently swapped from PHPBB2 to Smf...love the SMF and the TP. I am really missing on thing that ive looked for and cant find. That is the ability to broadcast a message over the whole site. I have the code that i used on the phpbb forums. If anyone can convert this to work on SMF/TP ill be eternally greatful.
<?php
/***************************************************************************
* last.php
* ---------
* begin : 04/15/2006
* copyright : -=RAM=-
* email : admin@ram-clan.com
*
* version : 1.0.0 - 15/04/2006
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path.'includes/functions_color_groups.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$page_title = "Broadcast a Message";
include ($phpbb_root_path . 'includes/page_header.'.$phpEx);
#echo "<pre>";
#print_r($userdata);
#echo "</pre>";
$who = $userdata['username'];
$op = $_POST['op'];
$the_message = $_POST['the_message'];
$the_time = $_POST['the_time'];
switch($op) {
case broadcast:
//echo $who;
$numrows = $db->sql_numrows($db->sql_query("SELECT * FROM phpbb_public_messages WHERE who='$who'"));
$the_message = htmlspecialchars($the_message);
if ($the_message != "" AND $numrows < 500) {
$the_time = time();
$db->sql_query("INSERT INTO phpbb_public_messages VALUES (NULL, '$the_message', '$the_time', '$who')");
echo "<center>Broadcast Sent<br><br>[ <a href=/>Return to Portal</a> ]</center>";
} else {
echo "<center>Broadcast NOT sent <br>ERROR: Blank message or too many broadcasts<br><br>[ <a href=/>Return to Portal</a> ]</center>";
}
break;
default:
if ($userdata['user_id'] > 1) {
echo "<center>Send a broadcast message to all registered users visiting the site.<br>";
echo "<form action=\"/broadcast.php\" method=\"post\"><br>";
echo "<input type=\"hidden\" name=\"who\" value=\"". $userdata['username'] . "\">";
echo "<input type=\"hidden\" name=\"op\" value=\"broadcast\">";
echo "<input type=\"text\" size=\"60\" maxlength=\"255\" name=\"the_message\">  ";
echo "<input type=\"submit\" value=\"Send\"></form></center>";
}
else
{
echo "<center>You are not allowed to do that, please log in first.</center>";
}
break;
}
include ($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Well that code grabs information from the database and is customized to use in phpBB. Why don't you just use the news feature of SMF? Or you can add any custom code you want to a center/right/left block to announce stuff.