0)); if($_GET[action]=='edit' or $_POST[action]=='editannc'){ $annc=mysql_fetch_array(mysql_query("SELECT * FROM announcements WHERE id=$id")); if($annc[forum]>0 && $ismod) $canpost=true; } $smilies=readsmilies(); if(!$action){ loadtlayout(); $ppp=($log?$loguser[postsperpage]:20); $min=$ppp*$page; $anncs=mysql_query("SELECT a.*,u.*,a.title atitle,u.id uid FROM announcements a,users u WHERE forum=$f AND a.user=u.id ORDER BY a.id DESC LIMIT $min,$ppp"); $annctotal=@mysql_result(mysql_query("SELECT count(*) FROM announcements WHERE forum=$f"),0,0); $pagelinks=$smallfont.'Pages:'; for($i=0;$i<($annctotal/$ppp);$i++){ if($i==$page) $pagelinks.=' '.($i+1); else $pagelinks.=" ".($i+1).''; } $annclist="$tccellh width=150>User$tccellh colspan=2>Announcement"; while($annc=mysql_fetch_array($anncs)){ if($annccount) $annclist.=''; $annccount++; $bg=$bg%2+1; $edit=' '; if($isadmin or ($ismod && $f)){ $edit="Edit | Delete"; if($isadmin) $ip=" | IP: $annc[3]"; } if($loguser[viewsig]==2){ $annc[headtext]=$annc[postheader]; $annc[signtext]=$annc[signature]; } $annc[text]="
$annc[atitle]

$annc[text]"; $annclist.=threadpost($annc,$bg); } } if($canpost){ if($_GET[action]=='delete'){ mysql_query("DELETE FROM announcements WHERE id=$id"); $annclist.=" $tccell1>Announcement deleted.
".redirect("announcement.php?f=$f",'return to the announcements',0); } if($_GET[action]=='new'){ if($log){ $username=htmlspecialchars($loguser[name]); $password=$logpassword; } $annclist="
$tccellh width=150> $tccellh>  $tccell1>User name: $tccell2l>$inpt=username VALUE=\"$username\" SIZE=25 MAXLENGTH=25> $tccell1>Password: $tccell2l>$inpp=password VALUE=\"$password\" SIZE=13 MAXLENGTH=32> $tccell1>Announcement title:$tccell2l>$inpt=subject SIZE=70 MAXLENGTH=100> $tccell1>Announcement: $tccell2l>$txta=message ROWS=20 COLS=$numcols> $tccell1>  $tccell2l>$inph=action VALUE=postannc>$inph=f VALUE=$f> $inps=submit VALUE=\"Post announcement\"> $inps=preview VALUE=\"Preview announcement\">
"; } if($_GET[action]=='edit'){ if(!$annc[headid]) $head=$annc[headtext]; else $head=mysql_result(mysql_query("SELECT text FROM postlayouts WHERE id=$annc[headid]"),0,0); if(!$annc[signid]) $sign=$annc[signtext]; else $sign=mysql_result(mysql_query("SELECT text FROM postlayouts WHERE id=$annc[signid]"),0,0); sbr(1,$annc[text]); sbr(1,$head); sbr(1,$sign); $annclist="
$tccellh width=150> $tccellh>  $tccell1>Announcement title:$tccell2l>$inpt=subject VALUE=\"$annc[title]\" SIZE=70 MAXLENGTH=100> $tccell1>Header: $tccell2l>$txta=head ROWS=8 COLS=$numcols>$head $tccell1>Announcement: $tccell2l>$txta=message ROWS=12 COLS=$numcols>$annc[text] $tccell1>Signature: $tccell2l>$txta=sign ROWS=8 COLS=$numcols>$sign $tccell1>  $tccell2l> $inph=action VALUE=editannc> $inph=f VALUE=$annc[forum]> $inph=id VALUE=$id> $inph=edited VALUE=\"$annc[edited]\"> $inps=submit VALUE=\"Edit announcement\"> $inps=preview VALUE=\"Preview announcement\">
"; } if($_POST[action]=='postannc'){ $userid=checkuser($username,$password); $user=@mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id=$userid")); if($userid!=-1){ $sign=$user[signature]; $head=$user[postheader]; if($user[postbg]) $head="
$head"; $numposts=$user[posts]; $numdays=(ctime()-$user[regdate])/86400; $message=doreplace($message,$numposts,$numdays,$username); $rsign=doreplace($sign,$numposts,$numdays,$username); $rhead=doreplace($head,$numposts,$numdays,$username); squot(0,$subject); $currenttime=ctime(); if($submit){ if(!$f) $f=0; $headid=getpostlayoutid($head); $signid=getpostlayoutid($sign); mysql_query("INSERT INTO `announcements` (`user`, `date`, `ip`, `title`, `forum`, `text`, `headid`, `signid`, `tagval`) VALUES ('$userid', '$currenttime', '$userip', '$subject', '$f', '$message', '$headid', '$signid', '$tagval')"); $annclist=" $tccell1>Thank you, $user[name], for posting your announcement.
".redirect("announcement.php?f=$f","the announcements",0).""; }else{ loadtlayout(); $ppost=$user; $ppost[uid]=$userid; $ppost[date]=$currenttime; $ppost[headtext]=$rhead; $ppost[signtext]=$rsign; $ppost[text]="
". stripslashes($subject) ."

". stripslashes($message); if($isadmin) $ip=$userip; $annclist=" $tccellh>Announcement preview $tblend$tblstart ".threadpost($ppost,1)." $tblend
$tblstart
$tccellh width=150> $tccellh>  $tccell1>Announcement title:$tccell2l>$inpt=subject SIZE=70 MAXLENGTH=100 VALUE=\"". stripslashes($subject) ."\"> $tccell1>Announcement: $tccell2l>$txta=message ROWS=10 COLS=$numcols>". stripslashes($message) ." $tccell1> $tccell2l> $inps=submit VALUE=\"Submit announcement\"> $inps=preview VALUE=\"Preview announcement\"> $inph=username VALUE=\"".htmlspecialchars($username)."\"> $inph=password VALUE=\"$password\"> $inph=action VALUE=postannc> $inph=f VALUE=$f> "; } }else $annclist=" $tccell1>Couldn't enter the announcement. You haven't entered the right username or password. ".redirect('announcement.php','return to the announcements',0); } if($_POST[action]=='editannc'){ print $tblstart; $numposts=$loguser[posts]; $numdays=(ctime()-$loguser[regdate])/86400; $message=doreplace($message,$numposts,$numdays,$loguser[name]); if($submit){ $edited.="(edited by $loguser[name] on ".date("m-d-y h:i A",ctime()).")
"; $headid=@mysql_result(mysql_query("SELECT id FROM postlayouts WHERE text='$head' LIMIT 1"),0,'id'); $signid=@mysql_result(mysql_query("SELECT id FROM postlayouts WHERE text='$sign' LIMIT 1"),0,'id'); if($headid) $head=''; else $headid=0; if($signid) $sign=''; else $signid=0; mysql_query("UPDATE announcements SET title='$subject', text='$message', headtext='$head', signtext='$sign', edited='$edited',headid=$headid,signid=$signid WHERE id=$id"); $annclist=" $tccell1>Thank you, ".$loguser[name].", for editing the announcement.
".redirect("announcement.php?f=$f","go to the announcements",0); }else{ loadtlayout(); $annc=mysql_fetch_array(mysql_query("SELECT * FROM announcements WHERE id=$id")); $ppost=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id=$annc[user]")); $subject = stripslashes($subject); $message = stripslashes($message); $head = stripslashes($head); $sign = stripslashes($sign); $ppost[uid]=$annc[user]; $ppost[date]=$annc[date]; $ppost[tagval]=$annc[tagval]; $ppost[headtext]=$head; $ppost[signtext]=$sign; $ppost[text]="
$subject

$message"; if($isadmin) $ip=$annc[ip]; $annclist=" $tccellh>Announcement preview $tblend$tblstart ".threadpost($ppost,1)." $tblend
$tblstart
$tccellh width=150> $tccellh>  $tccell1>Announcement title:$tccell2l>$inpt=subject VALUE=\"$subject\" SIZE=70 MAXLENGTH=100> $tccell1>Header: $tccell2l>$txta=head ROWS=4 COLS=$numcols>$head $tccell1>Announcement: $tccell2l>$txta=message ROWS=6 COLS=$numcols>$message $tccell1>Signature: $tccell2l>$txta=sign ROWS=4 COLS=$numcols>$sign $tccell1> $tccell2l> $inps=submit VALUE=\"Edit announcement\"> $inps=preview VALUE=\"Preview announcement\"> $inph=action VALUE=editannc> $inph=id VALUE=$id> $inph=f VALUE=$f> "; } } $postnew="Post new announcement"; } print "$header
$fonttag$boardname - Announcements$smallfont$postnew
$pagelinks$tblstart$annclist$tblend$pagelinks$footer "; printtimedif($startingtime); ?>