All Credits go to djhowarth (Mostvotedplaya) for making the mod.
CREATE TABLE IF NOT EXISTS `shoutannounce` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL DEFAULT '',
`descr` text NOT NULL,
`added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` enum('yes','no') NOT NULL DEFAULT 'yes',
`time` int(11) unsigned NOT NULL DEFAULT '0',
`last_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
Make new link in admincp.php for navigation
<td align="center"><a href="admincp.php?action=shoutannounce"><img src="images/admin/blocked.gif" border="0" width="32" height="32"><br />Shoutbox Announce<br /></a></td>
Now add the code below to bottom of admincp.php
if ($action == "shoutannounce")
{
if (@count($_POST['id'])) {
foreach ($_POST['id'] as $id) {
mysql_query("DELETE FROM `shoutannounce` WHERE `id` = $id");
}
show_error_msg("Success", "Announcement Removed.", 1);
}
stdhead("Shoutbox Announce");
navmenu();
begin_frame("Shoutbox Announce");
echo("<center>[<a href='admincp.php?action=shoutannouncecreate'>Create Announcement</a>]</center><br />");
$sql = mysql_query("SELECT * FROM `shoutannounce` ORDER BY `id` DESC");
if (mysql_num_rows($sql) > 0)
{
echo("<form method='post' action='admincp.php?action=shoutannounce'>");
echo("<table border='0' cellpadding='5' cellspacing='3' align='center' width='100%' class='ttable_headinner'>");
echo("<tr>");
echo("<td class='ttable_head'><strong>Title</strong></td>");
echo("<td class='ttable_head'><strong>Message</strong></td>");
echo("<td class='ttable_head'><strong>Added</strong></td>");
echo("<td class='ttable_head'><strong>Run at</strong></td>");
echo("<td class='ttable_head'><strong>Last Run</strong></td>");
echo("<td class='ttable_head'><strong>Enabled</strong></td>");
echo("<td class='ttable_head'><strong>Delete</strong></td>");
echo("</tr>");
while ($row = mysql_fetch_array($sql))
{
echo("<tr>");
echo("<td class='ttable_col1' align='center'><a href='admincp.php?action=shouteditannounce&id=" . $row['id'] . "'>" . htmlspecialchars($row['title']) . "</a></td>");
echo("<td class='ttable_col2' align='center'>" . format_comment($row['descr']) . "</td>");
echo("<td class='ttable_col1' align='center'>" . utc_to_tz($row['added']) . "</td>");
echo("<td class='ttable_col1' align='center'>" . $row['time'] . "</td>");
echo("<td class='ttable_col2' align='center'>" . utc_to_tz(date('Y-m-d H:i:s', $row['last_time'])) . "</td>");
echo("<td class='ttable_col1' align='center'>" . htmlspecialchars($row['active']) . "</td>");
echo("<td class='ttable_col2' align='center'><input type='checkbox' name='id[]' value='".$row['id']."'/></td>");
echo("</tr>");
}
echo("</table>");
echo("<div align='right'><input type='submit' value='Remove'/></div>");
echo("</form>");
}
else {
echo("<center>No Current announcements.</center>");
}
end_frame();
stdfoot();
}
if ($action == "shoutannouncecreate")
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (empty($_POST['title']) || empty($_POST['descr']) || !is_valid_id($_POST['time']))
show_error_msg("Error", "Form not completed. <a href='admincp.php?action=shoutannouncecreate'>return</a>?", 1);
mysql_query("INSERT INTO `shoutannounce` (`title`, `descr`, `added`, `time`) VALUES (" . sqlesc($_POST['title']) . ", " . sqlesc($_POST['descr']) . ", " . sqlesc(get_date_time()) . ", " . sqlesc($_POST['time']) . ")");
show_error_msg("Success", "Announcement Created. <a href='admincp.php?action=shoutannounce'>return</a>?", 1);
}
stdhead("Create New Announcement");
navmenu();
begin_frame("Create New Announcement");
echo("<form name='shoutannouncecreate' method='post' action='admincp.php?action=shoutannouncecreate'>");
echo("<table border='0' cellpadding='5' cellspacing='0' align='center'>");
echo("<tr>");
echo("<td><strong>Title:</strong></td>");
echo("<td><input type='text' name='title' size='30' /></td>");
echo("</tr>");
echo("<tr>");
echo("<td><strong>Time:</strong></td>");
echo("<td><select name='time'><option value='1800'>30 Mins</option><option value='3600'>1 Hour</option></select></td>");
echo("</tr>");
echo("</table>");
require_once("backend/bbcode.php");
echo(textbbcode("shoutannouncecreate","descr","$descr"));
echo("<input type='reset' value='Reset' /><input type='submit' value='Submit' />");
echo("</form>");
end_frame();
stdfoot();
}
if ($action == 'shouteditannounce')
{
$id = isset($_GET['id']) ? $_GET['id'] : '';
if (!is_valid_id($id))
show_error_msg("Error", "Thats an Invalid ID O_o", 1);
$sql = mysql_query("SELECT * FROM `shoutannounce` WHERE `id` = $id");
$row = mysql_fetch_array($sql);
if (!$row)
show_error_msg("Error", "Invalid ID.", 1);
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST['title']) || empty($_POST['descr']) || !is_valid_id($_POST['time']))
show_error_msg("Error", "Form not completed. <a href='admincp.php?action=shouteditannounce&id=$id'>return</a>?", 1);
mysql_query("UPDATE `shoutannounce` SET `title` = " . sqlesc($_POST['title']) . ", `descr` = " . sqlesc($_POST['descr']) . ", `time` = " . sqlesc($_POST['time']) . ", `active` = " . sqlesc($_POST['active']) . " WHERE `id` = $id");
show_error_msg("Success", "Announcement edited. <a href='admincp.php?action=shoutannounce'>return</a>?", 1);
}
stdhead("Edit Announcement");
navmenu();
begin_frame("Edit Announcement");
echo("<form name='shouteditcreate' method='post' action='admincp.php?action=shouteditannounce&id=$id'>");
echo("<table border='0' cellpadding='5' cellspacing='0' align='center'>");
echo("<tr>");
echo("<td><strong>Title:</strong></td>");
echo("<td><input type='text' name='title' size='30' value='" . htmlspecialchars($row['title']) . "' /></td>");
echo("</tr>");
echo("<tr>");
echo("<td><strong>Time:</strong></td>");
echo("<td><select name='time'><option value='1800' " . ($row['time'] == '1800' ? 'selected="selected"' : '' ). ">30 Mins</option><option value='3600' " . ($row['time'] == '3600' ? 'selected="selected"' : ''). ">1 Hour</option></select></td>");
echo("</tr>");
echo("<tr>");
echo("<td><strong>Enabled:</strong></td>");
echo("<td><select name='active'><option value='yes' " . ($row['active'] == 'yes' ? 'selected="selected"' : '' ). ">Yes</option><option value='no' " . ($row['active'] == 'no' ? 'selected="selected"' : ''). ">No</option></select></td>");
echo("</tr>");
echo("</table>");
require_once("backend/bbcode.php");
echo(textbbcode("shouteditcreate","descr", $row['descr']));
echo("<input type='reset' value='Reset' /><input type='submit' value='Submit' />");
echo("</form>");
end_frame();
stdfoot();
}
Open backend/cleanup.php FIND
mysql_query("OPTIMIZE TABLE `peers` , `torrents` , `tasks` , `guests` , `users` , `messages`; ");
Above Add
$query = mysql_query("SELECT `id`, `descr`, `time`, `last_time` FROM `shoutannounce` WHERE `active` = 'yes'");
while ($row = mysql_fetch_array($query)) {
if ($row['last_time'] + $row['time'] > gmtime())
continue;
mysql_query("INSERT INTO `shoutbox` (`user`, `message`, `date`, `userid`) VALUES ('System', " . sqlesc($row['descr']) . ", '" . get_date_time() . "', '0')");
mysql_query("UPDATE `shoutannounce` SET `last_time` = '" . gmtime() . "' WHERE `id` = " . $row['id'] . "");
}
Note....! if your using cooly's shoutbox u need to replace
mysql_query("INSERT INTO `shoutbox` (`user`, `message`, `date`, `userid`) VALUES ('System', '" . $row['descr'] . "', '" . get_date_time() . "', '0')");
with
mysql_query("INSERT INTO ajshoutbox (uid, date, name, text) VALUES(0,NOW(), 'System', " . sqlesc($row['descr']) . ")");
If you have thib's bbcode image set changer then u will need to make changes after if installed this mod
Find
echo(textbbcode("shoutannouncecreate","descr","$descr"));
Replace with
echo(textbbcode("shoutannouncecreate","descr", $CURUSER['bbcode'], "$descr"));
Find
echo(textbbcode("shouteditcreate","descr", $row['descr']));
replace by
echo(textbbcode("shouteditcreate","descr", $CURUSER['bbcode'], $row['descr']));