Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[ADDON] Announcements
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2009-04-27 21:33:19
SQL:


      CREATE TABLE `announcements` (
 
`id` int(10) unsigned NOT NULL auto_increment,

`subject` varchar(64) NOT NULL,

`message` text NOT NULL,

`by` varchar(16) NOT NULL default 'Admin',

`added` datetime NOT NULL default '0000-00-00 00:00:00',

`minclassread` tinyint(3) unsigned NOT NULL,

PRIMARY KEY (`id`),

KEY `subject` (`subject`)

) TYPE=MyISAM;

ALTER TABLE `users` ADD `announce_read` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no';

ALTER TABLE `users` ADD INDEX ( `announce_read` ) ;

add to index.php (or header.php after middleblocks):

if ($CURUSER && $CURUSER["announce_read"] == "no" && $arr = announcement()) {

?>

<script type="text/javascript" src="scripts/announcement.js"></script>

<script type="text/javascript" src="scripts/preview.js"></script>

<!-- annoucement start #<?=$arr[id];?> -->

<div id="dropin" style="position:absolute;visibility:hidden;left:300px;top:100px;width:500px;height:100px">

<table border="0" cellpadding="0" cellspacing="0" width="650" class="error">

<tbody><tr><td class="none" style="padding: 2px 0 0 10px; background: red">

<font color=black><b>Title:</b> <?=$arr["subject"]?> -- <b>Created on"</b> <?=$arr["added"]?> -- <b>By:</b> <?=$arr["by"]?></b></font></td>

<td width="50" align="right" class="none" style="padding: 2px; background: red"><a href="#" onClick="dismissbox();return false"><img src="images/close.jpg" border="0"></a></td></tr>

<tr><td colspan="2" class=none width="650" style="padding: 0 0 0 10px;" bgcolor="#ffffff">

<p>

<?=format_comment($arr["message"])?>

</p>



<img id="loading" style=" visibility: hidden" src="images/load.gif">

<span style="color:red" name="preview" id="previewr" align="left">

<a href="#" onclick="java script:clearannouncement(this.parentNode,'clear_ann.php')">Click here to mark announcement read.</a>

</span><br><br></form>

</td></tr></tbody></table>

</div>

<!-- annoucement end #<?=$arr[id];?>-->

<span id="new_ann" style="visibility: visible"><table border=0 cellspacing=0 cellpadding=10 bgcolor=red width=100% align=center><tr><td style='padding: 10px; background: red' align='center'>

<b><a href="java script:show_announcement()"><font color=white>New announcement! Please click here to read!</font></a></b></td></tr></table></span><br />

<?php

}
You will need to replace "java script" with javascript"



add to functions.php:


function announcement () {

   GLOBAL $CURUSER;

   if ($CURUSER && $CURUSER['announce_read'] == "no") {

       $res = mysql_query("SELECT * FROM announcements WHERE minclassread <= $CURUSER[class] ORDER by added DESC LIMIT 1");

       $ret = mysql_fetch_array($res);

   }

   return $ret;

}





announcements.php:



<?

require("backend/functions.php");

dbconn();

loggedinonly();

if ($CURUSER["control_panel"] != "yes")

   show_error_msg("Access Denied!", "You dont have any permission to view this page!");

unset ($action,$do);

$action = isset($_POST['action']) ? htmlspecialchars($_POST['action']) : (isset($_GET['action']) ? htmlspecialchars($_GET['action']) : 'show');

$do = isset($_POST['do']) ? htmlspecialchars($_POST['do']) : (isset($_GET['do']) ? htmlspecialchars($_GET['do']) : '');

function show ($subject, $message, $added, $by, $class) {

global $site_config;

ob_start();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" />

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title><?php echo $site_config["SITENAME"];?> - Preview Annoucement: <?php echo $subject;?> Added: <?php echo $added;?> By <?php echo $by;?></title>



<script language="JavaScript1.2">



// Drop-in content box- By Dynamic Drive

// For full source code and more DHTML scripts, visit http://www.dynamicdrive.com

// This credit MUST stay intact for use



var ie=document.all

var dom=document.getElementById

var ns4=document.layers

var calunits=document.layers? "" : "px"



var bouncelimit=32 //(must be divisible by 8)

var direction="up"



function initbox(){

if (!dom&&!ie&&!ns4)

return

crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin

scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

crossobj.top=scroll_top-250+calunits

crossobj.visibility=(dom||ie)? "visible" : "show"

dropstart=setInterval("dropin()",50)

}



function dropin(){

scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

if (parseInt(crossobj.top)<100+scroll_top)

crossobj.top=parseInt(crossobj.top)+40+calunits

else{

clearInterval(dropstart)

bouncestart=setInterval("bouncein()",50)

}

}



function bouncein(){

crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits

if (bouncelimit<0)

bouncelimit+=8

bouncelimit=bouncelimit*-1

if (bouncelimit==0){

clearInterval(bouncestart)

}

}



function dismissbox(){

if (window.bouncestart) clearInterval(bouncestart)

crossobj.visibility="hidden"

window.location="<?php echo $site_config["SITEURL"];?>/announcements.php";

}



function redo(){

bouncelimit=32

direction="up"

initbox()

}



function truebody(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

window.onload=initbox

</script>



</head>



<body>

<div id="dropin" style="position:absolute;visibility:hidden;left:300px;top:100px;width:500px;height:100px;">

<table class=main width=600 border=0 cellpadding=0 cellspacing=0><tr><td class=embedded>

<table width=600 align=center border=1 cellspacing=0 cellpadding=5><td class=colhead><div style=float:left; width:49%; height:100px; ><?=$subject?> -- <b>CREATED ON:</b> <?=$added;?> -- <b>BY:</b> <?=$by;?></b> -- <b>TO CLASS:</b> <?=$class;?></div><div style=float:right; width:49%; height:100px; ><a href="#" onClick="dismissbox();return false"><img border=0 src=/images/warned2.gif></a></div></td><tr><td><?=format_comment($message);?></td></tr></table></td></tr></table>

</div>

</body>

</html>

<?

ob_end_flush();

}



if ($action == 'see') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

$res = mysql_query('SELECT * FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

$arr = mysql_fetch_array($res);

show ($arr['subject'], $arr['message'], $arr['added'], $arr['by'], get_user_class_name($arr['minclassread']));

die;

}

elseif ($action == 'delete') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

$sure = (string)$_GET['sure'];

if (!$sure) {

show_error_msg('DELETE ANNOUCEMENT!','Sanity check: You are about to delete an annoucement. Click <a href=?action=delete&id='.$id.'&sure=yes>here</a> if you are sure. (<a href="announcements.php">cancel</a>)');

}else

mysql_query('DELETE FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");

}

elseif ($action == 'add') {

if ($do == 'save') {

$added = get_date_time();

$subject = trim(htmlspecialchars($_POST['subject']));

$message = trim($_POST['message']);

$minclassread = $_POST['minclassread'];

if (empty($subject) OR empty($message))

show_error_msg("Error!", "Dont leave any fields blank!");

mysql_query('INSERT INTO announcements (subject, message, added, minclassread) VALUES ('.sqlesc($subject).', '.sqlesc($message).', '.sqlesc($added).', '.sqlesc($minclassread).')') or sqlerr(__FILE__, __LINE__);

mysql_query('UPDATE users SET announce_read = \'no\' WHERE announce_read = \'yes\' AND class >= '.$minclassread) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");



}else{



$maxclass = get_user_class();

for ($i = 1; $i <= $maxclass; ++$i)

$value .= "<option value=$i" . ($row["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n";

stdhead("Add a new announcement!");

echo '<form method=post action="'.$_SERVER['SCRIPT_NAME'].'">

<input type=hidden name=action value=add>

<input type=hidden name=do value=save>';

echo '<table border=1 cellspacing=0 cellpadding=5 align=center>';

echo '<tr><td class=rowhead>Subject: </td><td><input type=text name=subject id=specialboxg maxlength=64></tr></td>';

echo '<tr><td class=rowhead>Message: </td><td><textarea name=message rows=8 id=specialboxg></textarea></tr></td>';

echo '<tr><td class=rowhead>Min.Class Read: </td><td>

<select name=minclassread>'.$value.'</select> <input type=submit value=save class=btn></form></tr></td</table>';

stdfoot();

die;

}

}

elseif ($action == 'edit') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

if ($do == 'save'){

$by = trim($_POST['by']);

$subject = trim($_POST['subject']);

$message = trim($_POST['message']);

$minclassread = $_POST['minclassread'];

$allow = array(1,2,3,4,5,6,7);

if (empty($subject) OR empty($message) OR empty($by) OR !in_array($minclassread, $allow))

show_error_msg("Error!", "Dont leave any fields blank!");

mysql_query('UPDATE announcements SET `by` = '.sqlesc($by).', subject = '.sqlesc($subject).', message = '.sqlesc($message).', minclassread = '.sqlesc($minclassread).' WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

if ($_POST['reset'] == 'yes')

mysql_query('UPDATE users SET announce_read = \'no\' WHERE announce_read = \'yes\' AND class >= '.$minclassread) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");

}else{

$res = mysql_query('SELECT * FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) == 0)

show_error_msg('Error','Invalid Link!');

else

$arr = mysql_fetch_array($res);

$maxclass = get_user_class();

for ($i = 0; $i <= $maxclass; ++$i)

$value .= "<option value=$i" . ($arr["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n";

stdhead("Edit Announcement!");

echo '<form method=post action="'.$_SERVER['SCRIPT_NAME'].'">

<input type=hidden name=action value=edit>

<input type=hidden name=do value=save>

<input type=hidden name=id value='.$id.'>';

echo '<table border=1 cellspacing=0 cellpadding=5 align=center>';

echo '<tr><td class=rowhead>Subject: </td><td><input type=text name=subject id=specialboxg maxlength=64 value="'.$arr['subject'].'"></tr></td>';

echo '<tr><td class=rowhead>Message: </td><td><textarea name=message rows=8 id=specialboxg>'.$arr['message'].'</textarea></tr></td>';

echo '<tr><td class=rowhead>Creator: </td><td><input type=text name=by id=specialboxg maxlength=64 value="'.$arr['by'].'"></tr></td>';

echo '<tr><td class=rowhead>Min.Class Read: </td><td>

<select name=minclassread>'.$value.'</select> <input type=checkbox name=reset value=yes> check this to mark all users as unread. <input type=submit value=save class=btn></form></tr></td></table>';

stdfoot();

die;

}

}



//===Show All Announcements

stdhead("Annoucements");

$res = mysql_query("SELECT * FROM announcements ORDER by added DESC");

print("<h2>Annoucements</h2>".

"<br><table border=1 cellspacing=0 cellpadding=5 width=600>\n".

"<tr><td class=colhead align=left>ID</td><td class=colhead align=left>Subject</td><td class=colhead align=left>Message"."</td><td class=colhead align=center>Added</td><td class=colhead align=center>Min.Class</td><td class=colhead align=center".">Action</td></tr>\n");

if (mysql_num_rows($res) >= 1) {

while ($arr = mysql_fetch_array($res)) {

print("<tr><td>".htmlspecialchars($arr[id])."</td><td>".htmlspecialchars($arr[subject])."</td>".

"<td>".htmlspecialchars($arr[message])."</td><td align=center>".htmlspecialchars($arr[added])."<br><b>By&nbsp;".

"".htmlspecialchars($arr[by])."</b></td><td align=center>".get_user_class_name(htmlspecialchars($arr[minclassread]))."</td><td align=center><a href=?action=see&id=$arr[id]>Show</a>&nbsp;/&nbsp;<a href=?action=edit&id=$arr[id]>Edit</a>&nbsp;/&nbsp;<a href=?action=delete&id=$arr[id]>Delete</a></td></tr>");

}

}else

print("<tr><td colspan=6>Nothing Found..</td></tr>");

print("<tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";

stdfoot();

//===End Show All Announcements

?>





clear_ann.php:



<?php

require_once("backend/functions.php");

dbconn();

if (!$CURUSER) die;



if ($CURUSER['announce_read'] == "no")

   mysql_query("UPDATE users SET announce_read = 'yes' WHERE id = $CURUSER[id]");

die("Announcement cleared");

?>





Attached files go in scripts/.

[url='http://devscorner.xyz/applications/core/interface/file/attachment.php?id=3703']preview.js[/url][url='http://devscorner.xyz/applications/core/interface/file/attachment.php?id=3702']announcement.js[/url]

Images go in images/.

close.jpg

load.gif
announcement.js
Download
preview.js
Download
close.jpg
close.jpg
load.gif
load.gif
announcements.png
announcements.png
Unknown User
2009-04-30 18:54:04
Did a few changes to add frames etc around the options. Here is the new annnouncements.php - Nothing major just makes it look neater.   :)

Great mod Thanks

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=3708"]announcements.php[/url]
announcements.php
Download
Unknown User
2009-07-13 23:44:45
in announcements.php change:

}else

print("<tr><td colspan=6>Nothing Found..</td></tr><tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";



to:



}else

print("<tr><td colspan=6>Nothing Found..</td></tr>");

print("<tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";
Unknown User
2010-03-10 11:33:16
how to fix the previw announcements to show in middle and not on left side?
Unknown User
2010-03-10 22:54:58
works great..thx ts
Unknown User
2010-04-12 17:25:48
"TorrentialStorm, post: 56989":
Taken from [url="http://www.torrenttrader.org/index.php?showtopic=9329"]here[/url]. I just updated the code to work correctly.
SQL:

CREATE TABLE `announcements` (
`id` int(10) unsigned NOT NULL auto_increment,

`subject` varchar(64) NOT NULL,

`message` text NOT NULL,

`by` varchar(16) NOT NULL default 'Admin',

`added` datetime NOT NULL default '0000-00-00 00:00:00',

`minclassread` tinyint(3) unsigned NOT NULL,

PRIMARY KEY (`id`),

KEY `subject` (`subject`)

) TYPE=MyISAM;

ALTER TABLE `users` ADD `announce_read` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no';

ALTER TABLE `users` ADD INDEX ( `announce_read` ) ;

add to index.php (or header.php after middleblocks):

if ($CURUSER && $CURUSER["announce_read"] == "no" && $arr = announcement()) {

?>

<script type="text/javascript" src="scripts/announcement.js"></script>

<script type="text/javascript" src="scripts/preview.js"></script>

<!-- annoucement start #<?=$arr[id];?> -->

<div id="dropin" style="position:absolute;visibility:hidden;left:300px;top:100px;width:500px;height:100px">

<table border="0" cellpadding="0" cellspacing="0" width="650" class="error">

<tbody><tr><td class="none" style="padding: 2px 0 0 10px; background: red">

<font color=black><b>Title:</b> <?=$arr["subject"]?> -- <b>Created on"</b> <?=$arr["added"]?> -- <b>By:</b> <?=$arr["by"]?></b></font></td>

<td width="50" align="right" class="none" style="padding: 2px; background: red"><a href="#" onClick="dismissbox();return false"><img src="images/close.jpg" border="0"></a></td></tr>

<tr><td colspan="2" class=none width="650" style="padding: 0 0 0 10px;" bgcolor="#ffffff">

<p>

<?=format_comment($arr["message"])?>

</p>



<img id="loading" style=" visibility: hidden" src="images/load.gif">

<span style="color:red" name="preview" id="previewr" align="left">

<a href="#" onclick="java script:clearannouncement(this.parentNode,'clear_ann.php')">Click here to mark announcement read.</a>

</span><br><br></form>

</td></tr></tbody></table>

</div>

<!-- annoucement end #<?=$arr[id];?>-->

<span id="new_ann" style="visibility: visible"><table border=0 cellspacing=0 cellpadding=10 bgcolor=red width=100% align=center><tr><td style='padding: 10px; background: red' align='center'>

<b><a href="java script:show_announcement()"><font color=white>New announcement! Please click here to read!</font></a></b></td></tr></table></span><br />

<?php

}
You will need to replace "java script" with javascript"



add to functions.php:


function announcement () {

GLOBAL $CURUSER;

if ($CURUSER && $CURUSER['announce_read'] == "no") {

$res = mysql_query("SELECT * FROM announcements WHERE minclassread <= $CURUSER[class] ORDER by added DESC LIMIT 1");

$ret = mysql_fetch_array($res);

}

return $ret;

}





announcements.php:



<?

require("backend/functions.php");

dbconn();

loggedinonly();

if ($CURUSER["control_panel"] != "yes")

show_error_msg("Access Denied!", "You dont have any permission to view this page!");

unset ($action,$do);

$action = isset($_POST['action']) ? htmlspecialchars($_POST['action']) : (isset($_GET['action']) ? htmlspecialchars($_GET['action']) : 'show');

$do = isset($_POST['do']) ? htmlspecialchars($_POST['do']) : (isset($_GET['do']) ? htmlspecialchars($_GET['do']) : '');

function show ($subject, $message, $added, $by, $class) {

global $SITENAME,$SITEURL;

ob_start();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" />

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link rel="stylesheet" href="<?=$SITEURL;?>/default.css" type="text/css" media="screen" />

<title><?=$SITENAME;?> - Preview Annoucement: <?=$subject;?> Added: <?=$added;?> By <?=$by;?></title>



<script language="JavaScript1.2">



// Drop-in content box- By Dynamic Drive

// For full source code and more DHTML scripts, visit http://www.dynamicdrive.com

// This credit MUST stay intact for use



var ie=document.all

var dom=document.getElementById

var ns4=document.layers

var calunits=document.layers? "" : "px"



var bouncelimit=32 //(must be divisible by 8)

var direction="up"



function initbox(){

if (!dom&&!ie&&!ns4)

return

crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin

scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

crossobj.top=scroll_top-250+calunits

crossobj.visibility=(dom||ie)? "visible" : "show"

dropstart=setInterval("dropin()",50)

}



function dropin(){

scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

if (parseInt(crossobj.top)<100+scroll_top)

crossobj.top=parseInt(crossobj.top)+40+calunits

else{

clearInterval(dropstart)

bouncestart=setInterval("bouncein()",50)

}

}



function bouncein(){

crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits

if (bouncelimit<0)

bouncelimit+=8

bouncelimit=bouncelimit*-1

if (bouncelimit==0){

clearInterval(bouncestart)

}

}



function dismissbox(){

if (window.bouncestart) clearInterval(bouncestart)

crossobj.visibility="hidden"

window.location="<?=$SITEURL;?>/announcements.php";

}



function redo(){

bouncelimit=32

direction="up"

initbox()

}



function truebody(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

window.onload=initbox

</script>



</head>



<body>

<div id="dropin" style="position:absolute;visibility:hidden;left:300px;top:100px;width:500px;height:100px;">

<table class=main width=600 border=0 cellpadding=0 cellspacing=0><tr><td class=embedded>

<table width=600 align=center border=1 cellspacing=0 cellpadding=5><td class=colhead><div style=float:left; width:49%; height:100px; ><?=$subject?> -- <b>CREATED ON:</b> <?=$added;?> -- <b>BY:</b> <?=$by;?></b> -- <b>TO CLASS:</b> <?=$class;?></div><div style=float:right; width:49%; height:100px; ><a href="#" onClick="dismissbox();return false"><img border=0 src=/images/warned2.gif></a></div></td><tr><td><?=format_comment($message);?></td></tr></table></td></tr></table>

</div>

</body>

</html>

<?

ob_end_flush();

}



if ($action == 'see') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

$res = mysql_query('SELECT * FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

$arr = mysql_fetch_array($res);

show ($arr['subject'], $arr['message'], $arr['added'], $arr['by'], get_user_class_name($arr['minclassread']));

die;

}

elseif ($action == 'delete') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

$sure = (string)$_GET['sure'];

if (!$sure) {

show_error_msg('DELETE ANNOUCEMENT!','Sanity check: You are about to delete an annoucement. Click <a href=?action=delete&id='.$id.'&sure=yes>here</a> if you are sure. (<a href="announcements.php">cancel</a>)');

}else

mysql_query('DELETE FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");

}

elseif ($action == 'add') {

if ($do == 'save') {

$added = get_date_time();

$subject = trim(htmlspecialchars($_POST['subject']));

$message = trim($_POST['message']);

$minclassread = $_POST['minclassread'];

if (empty($subject) OR empty($message))

show_error_msg("Error!", "Dont leave any fields blank!");

mysql_query('INSERT INTO announcements (subject, message, added, minclassread) VALUES ('.sqlesc($subject).', '.sqlesc($message).', '.sqlesc($added).', '.sqlesc($minclassread).')') or sqlerr(__FILE__, __LINE__);

mysql_query('UPDATE users SET announce_read = \'no\' WHERE announce_read = \'yes\' AND class >= '.$minclassread) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");



}else{



$maxclass = get_user_class();

for ($i = 1; $i <= $maxclass; ++$i)

$value .= "<option value=$i" . ($row["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n";

stdhead("Add a new announcement!");

echo '<form method=post action="'.$_SERVER['SCRIPT_NAME'].'">

<input type=hidden name=action value=add>

<input type=hidden name=do value=save>';

echo '<table border=1 cellspacing=0 cellpadding=5 align=center>';

echo '<tr><td class=rowhead>Subject: </td><td><input type=text name=subject id=specialboxg maxlength=64></tr></td>';

echo '<tr><td class=rowhead>Message: </td><td><textarea name=message rows=8 id=specialboxg></textarea></tr></td>';

echo '<tr><td class=rowhead>Min.Class Read: </td><td>

<select name=minclassread>'.$value.'</select> <input type=submit value=save class=btn></form></tr></td</table>';

stdfoot();

die;

}

}

elseif ($action == 'edit') {

$id = (isset($_GET['id']) ? (int)$_GET['id'] : (int)$_POST['id']);

if (!is_valid_id($id))

die;

if ($do == 'save'){

$by = trim($_POST['by']);

$subject = trim($_POST['subject']);

$message = trim($_POST['message']);

$minclassread = $_POST['minclassread'];

$allow = array(1,2,3,4,5,6,7);

if (empty($subject) OR empty($message) OR empty($by) OR !in_array($minclassread, $allow))

show_error_msg("Error!", "Dont leave any fields blank!");

mysql_query('UPDATE announcements SET `by` = '.sqlesc($by).', subject = '.sqlesc($subject).', message = '.sqlesc($message).', minclassread = '.sqlesc($minclassread).' WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

if ($_POST['reset'] == 'yes')

mysql_query('UPDATE users SET announce_read = \'no\' WHERE announce_read = \'yes\' AND class >= '.$minclassread) or sqlerr(__FILE__, __LINE__);

header("Refresh: 0; url=announcements.php");

}else{

$res = mysql_query('SELECT * FROM announcements WHERE id = '.sqlesc($id)) or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) == 0)

show_error_msg('Error','Invalid Link!');

else

$arr = mysql_fetch_array($res);

$maxclass = get_user_class();

for ($i = 0; $i <= $maxclass; ++$i)

$value .= "<option value=$i" . ($arr["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n";

stdhead("Edit Announcement!");

echo '<form method=post action="'.$_SERVER['SCRIPT_NAME'].'">

<input type=hidden name=action value=edit>

<input type=hidden name=do value=save>

<input type=hidden name=id value='.$id.'>';

echo '<table border=1 cellspacing=0 cellpadding=5 align=center>';

echo '<tr><td class=rowhead>Subject: </td><td><input type=text name=subject id=specialboxg maxlength=64 value="'.$arr['subject'].'"></tr></td>';

echo '<tr><td class=rowhead>Message: </td><td><textarea name=message rows=8 id=specialboxg>'.$arr['message'].'</textarea></tr></td>';

echo '<tr><td class=rowhead>Creator: </td><td><input type=text name=by id=specialboxg maxlength=64 value="'.$arr['by'].'"></tr></td>';

echo '<tr><td class=rowhead>Min.Class Read: </td><td>

<select name=minclassread>'.$value.'</select> <input type=checkbox name=reset value=yes> check this to mark all users as unread. <input type=submit value=save class=btn></form></tr></td></table>';

stdfoot();

die;

}

}



//===Show All Announcements

stdhead("Annoucements");

$res = mysql_query("SELECT * FROM announcements ORDER by added DESC");

print("<h2>Annoucements</h2>".

"<br><table border=1 cellspacing=0 cellpadding=5 width=600>\n".

"<tr><td class=colhead align=left>ID</td><td class=colhead align=left>Subject</td><td class=colhead align=left>Message"."</td><td class=colhead align=center>Added</td><td class=colhead align=center>Min.Class</td><td class=colhead align=center".">Action</td></tr>\n");

if (mysql_num_rows($res) >= 1) {

while ($arr = mysql_fetch_array($res)) {

print("<tr><td>".htmlspecialchars($arr[id])."</td><td>".htmlspecialchars($arr[subject])."</td>".

"<td>".htmlspecialchars($arr[message])."</td><td align=center>".htmlspecialchars($arr[added])."<br><b>By&nbsp;".

"".htmlspecialchars($arr[by])."</b></td><td align=center>".get_user_class_name(htmlspecialchars($arr[minclassread]))."</td><td align=center><a href=?action=see&id=$arr[id]>Show</a>&nbsp;/&nbsp;<a href=?action=edit&id=$arr[id]>Edit</a>&nbsp;/&nbsp;<a href=?action=delete&id=$arr[id]>Delete</a></td></tr>");

}

}else

print("<tr><td colspan=6>Nothing Found..</td></tr>");

print("<tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";

stdfoot();

//===End Show All Announcements

?>





clear_ann.php:



<?php

require_once("backend/functions.php");

dbconn();

if (!$CURUSER) die;



if ($CURUSER['announce_read'] == "no")

mysql_query("UPDATE users SET announce_read = 'yes' WHERE id = $CURUSER[id]");

die("Announcement cleared");

?>





Attached files go in scripts/.

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=3703"]preview.js[/url][url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=3702"]announcement.js[/url]

Images go in images/.

close.jpg

load.gif
Please download announce post configured to work here  <_<
Unknown User
2010-08-21 18:22:48
"TorrentialStorm, post: 59021":
in announcements.php change:

}else

print("<tr><td colspan=6>Nothing Found..</td></tr><tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";
to:


}else

print("<tr><td colspan=6>Nothing Found..</td></tr>");

print("<tr><td colspan=6 align=left>Click <a href=?action=add>here</a> to generate new annoucement.</tr></td></tr>");

echo "</table>";



Hi TorrentialStorm,

Thank you for the mod,

I am getting this in the index page

function announcement () { GLOBAL $CURUSER; if ($CURUSER && $CURUSER['announce_read'] == "no") { $res = mysql_query("SELECT * FROM announcements WHERE minclassread <= $CURUSER[class] ORDER by added DESC LIMIT 1"); $ret = mysql_fetch_array($res); } return $ret; }


Warning: Cannot modify header information - headers already sent by (output started at /home/content/72/6557972/html/torrents/backend/functions.php:1374) in /home/content/72/6557972/html/torrents/backend/functions.php on line 37


Please Help
Unknown User
2010-08-30 03:46:37
You will need to replace "java script" with javascript"<<<<<< where do you make those changes at?
Unknown User
2010-08-30 10:27:42
"jr200747, post: 65138":
You will need to replace "java script" with javascript"<<<<<< where do you make those changes at?

in the first post were you added the part to index.php and all other files you added just run a find and replace (most editors have it)

for java script to javascript
Unknown User
2010-08-31 03:08:49
"ZakoLB, post: 65040":
Hi TorrentialStorm,
Thank you for the mod,

I am getting this in the index page

function announcement () { GLOBAL $CURUSER; if ($CURUSER && $CURUSER['announce_read'] == "no") { $res = mysql_query("SELECT * FROM announcements WHERE minclassread <= $CURUSER[class] ORDER by added DESC LIMIT 1"); $ret = mysql_fetch_array($res); } return $ret; }


Warning: Cannot modify header information - headers already sent by (output started at /home/content/72/6557972/html/torrents/backend/functions.php:1374) in /home/content/72/6557972/html/torrents/backend/functions.php on line 37


Please Help

Move it to before the last ?> in functions.php.
Unknown User
2010-09-18 10:35:12
in index.php where?
Unknown User
2010-09-18 16:50:18
"Lakicevic Boris, post: 65351":
in index.php where?

i have it after

if($CURUSER[id]<1){

moveme("account-login.php");

}else{
Unknown User
2010-11-24 09:25:21
I have done all of the above and announcement shows above shoutbox but when I or any of my users click on it nothing happens, please help  :huh:

Sorry my own fault lol I had stuck the .js files in the js folder in my root so just had to edit the code and redirect to there, gr8 work as always with this works 100% now :)
Unknown User
2010-12-14 22:40:56
when i click on read announcement i get for Forbidden

You don't have permission to access /torrent/javascript/ on this server  using santrex  tt 2.06

both the js files are in the /javascript folder ..............:rolleyes:
Unknown User
2010-12-15 00:01:28
the answer is probably in the post above yours m8 :rolleyes:
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728