News: Welcome to the TinyPortal Support site.

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

October 16, 2019, 10:41:38 AM

Login with username, password and session length

Recent

Members
  • Total Members: 3756
  • Latest: Ocean
Stats
  • Total Posts: 189087
  • Total Topics: 20763
  • Online Today: 57
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 40
Total: 40

Author Topic: Forum Broadcast  (Read 3846 times)

0 Members and 1 Guest are viewing this topic.

kanga

  • Guest
Forum Broadcast
« on: July 07, 2007, 03: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.

Code: [Select]
<?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_ipPAGE_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\">&nbsp;&nbsp";
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);

?>

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Forum Broadcast
« Reply #1 on: July 07, 2007, 08:32:40 AM »
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.