<?
include ('template.inc');
include ('variable.inc');
/*
------------------------------------------------------------------------
* Nanou Morgan Web http://www.vmedia.com.au
* NoticeBoard version 1.1 Personal Web http://www.nanou.com.au
* January 2001 Email: nanou@nanou.com.au
________________________________________________________________________
*/
/* first call to page */
if (($submit =="")&&(!$Pix)){
$title ="Post an entry";
$content .="<P><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
<P><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">To add a picture to illustrate your post, go <a href=\"picture.html\">here</a> now.
<br><br>
If do not want to use a picture.. <b>Proceed to step 1</b></FONT><br>
<FORM ACTION=\"$PHP_SELF\" METHOD=POST onSubmit=\"MM_validateForm('Name','','R','Email','','RisEmail','Title_Ad','','R','Description','','R');return document.MM_returnValue\">
<TABLE BORDER=0 CELLSPACING=4 CELLPADDING=0 width=\"100%\">
<TR>
<TD NOWRAP width=\"5%\">
<P><b>1 -</b> *</P>
</TD>
<TD width=\"50%\">
<P><FONT SIZE=\"2\" FACE=\"Arial\">Name:</FONT></P>
</TD>
<TD width=\"45%\">
<P><INPUT TYPE=text NAME=Name VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Email:</FONT></P>
</TD>
<TD>
<P><INPUT TYPE=text NAME=Email VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD>
<P></P>
</TD>
<TD VALIGN=top>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Contact Details <br><i>(ie:Phone Number or Address)</i></FONT></P>
</TD>
<TD>
<P><TEXTAREA NAME=Contact ROWS=3 COLS=30 WRAP=virtual></TEXTAREA></P>
</TD>
</TR>
<TR>
<TD valign=\"top\" align=\"right\">
<P>*</P>
</TD>
<TD valign=\"top\">
<P><FONT SIZE=\"2\" FACE=\"Arial\">Category:<br><br>
<i>You can choose more than one by using the Control key on a PC or the apple key on an Apple Mac</i></FONT></P>
</TD>
<TD>
<P><SELECT NAME=Category[] SIZE=5 MULTIPLE>";
$mylist = file ($cat_file);
for ($L=0; $L< count ($mylist);$L++){
$mylist[$L] = ereg_replace( "\r\n", "", $mylist[$L]);
$my_list[$L] = strtr($mylist[$L], " ", "_");
$content .="<OPTION VALUE=\"$my_list[$L]\">$mylist[$L]\n";
}
$content .="</SELECT></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Title:</FONT></P>
</TD>
<TD>
<P><INPUT TYPE=text NAME=\"Title_Ad\" VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Description:</FONT></P>
</TD>
<TD>
<P><TEXTAREA NAME=Description ROWS=3 COLS=30 WRAP=virtual></TEXTAREA></P>
</TD>
</TR>
<TR>
<TD>
<P></P>
</TD>
<TD colspan=2><br><br>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Url: http:// <INPUT TYPE=text NAME=Url VALUE=\"\" SIZE=40><br>
<FONT SIZE=\"2\" FACE=\"Arial\"><i>Or if you prefer you can give the url of a picture from your site or just direct people to a web page for more information)</i></FONT></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P><br><br>*</P>
</TD>
<TD>
<P><br><br><FONT SIZE=\"2\" FACE=\"Arial\">Length of
Posting:</FONT></P>
</TD>
<TD>
<P><br><br><FONT SIZE=\"2\" FACE=\"Arial\"><SELECT NAME=Length>
<OPTION VALUE=1 SELECTED>1 Month
<OPTION VALUE=2>2 Months
<OPTION VALUE=3>3 Months
</SELECT></FONT></P>
</TD>
</TR>
</TABLE><center><input type=\"reset\" name=\"reset\" value=\"Clear Form\"><input type=\"submit\" name=\"submit\" value=\"Proceed\"></center></FORM></p>
";
}
/* Need a Category */
else if (($submit =="Proceed") && (!$Category)){
$content .="<center><font face=\"Helvetica,Arial,Geneva\"><font size=\"3\"><b>You need to enter one or more category
<br>
<FORM><INPUT TYPE=\"button\" VALUE=\"Back 1 step\" onClick=\"history.go(-1)\"></font> </center></p>
</FORM>";
}
/* if pix is uploaded */
else if (($Pix)&&($submit !="Proceed")&&($submit !="Post Notice Now")) {
$title =" Enter your details";
$content .="<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
<FORM ACTION=\"$PHP_SELF\" METHOD=POST onSubmit=\"MM_validateForm('Name','','R','Email','','RisEmail','Title_Ad','','R','Description','','R');return document.MM_returnValue\">
<TABLE BORDER=0 CELLSPACING=4 CELLPADDING=0>
<TR>
<TD NOWRAP>
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Name:</FONT></P>
</TD>
<TD>
<P><INPUT TYPE=text NAME=Name VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Email:</FONT></P>
</TD>
<TD>
<P><INPUT TYPE=text NAME=Email VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD>
<P></P>
</TD>
<TD VALIGN=top>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Contact Details <br><i>(ie:Phone Number or Address)</i></FONT></P>
</TD>
<TD>
<P><TEXTAREA NAME=Contact ROWS=3 COLS=30 WRAP=virtual></TEXTAREA></P>
</TD>
</TR>
<TR>
<TD valign=\"top\" align=\"right\">
<P>*</P>
</TD>
<TD valign=\"top\">
<P><FONT SIZE=\"2\" FACE=\"Arial\">Category:<br><br>
<i>You can choose more than one by using the apple key on an Apple Mac or the Control key on a PC</i></FONT></P>
</TD>
<TD>
<P><SELECT NAME=Category[] SIZE=5 MULTIPLE>";
$mylist = file ($cat_file);
for ($L=0; $L< count ($mylist);$L++){
$mylist[$L] = ereg_replace( "\r\n", "", $mylist[$L]);
$my_list[$L] = strtr($mylist[$L], " ", "_");
$content .="<OPTION VALUE=\"$my_list[$L]\">$mylist[$L]\n";
}
$content .="</SELECT></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Title:</FONT></P>
</TD>
<TD>
<P><INPUT TYPE=text NAME=\"Title_Ad\" VALUE=\"\" SIZE=30></P>
</TD>
</TR>
<TR>
<TD align=\"right\">
<P>*</P>
</TD>
<TD>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Description:</FONT></P>
</TD>
<TD>
<P><TEXTAREA NAME=Description ROWS=3 COLS=30 WRAP=virtual></TEXTAREA></P>
</TD>
</TR>
<TR>
<TD>
<P></P>
</TD>
<TD colspan=2><br><br>
<P><FONT SIZE=\"2\" FACE=\"Arial\">You are using this picture
<FONT SIZE=\"2\" FACE=\"Arial\"><a href=\"$view_pix/$Pix\">$Pix</a> width=$width height=$height</FONT></P>
</TD>
</TR>
<TR>
<TD>
<P></P>
</TD>
<TD colspan=2><br><br>
<P><FONT SIZE=\"2\" FACE=\"Arial\">Url: http:// <INPUT TYPE=text NAME=Url VALUE=\"\" SIZE=40><br>
<FONT SIZE=\"2\" FACE=\"Arial\"><i>You could also give the url of a web page for more information</i></FONT></P>
<input type=\"hidden\" name=\"width\" value=\"$width\">
<input type=\"hidden\" name=\"height\" value=\"$height\">
<input type=\"hidden\" name=\"Pix\" value=\"$Pix\">
</TD>
</TR>
<TR>
<TD align=\"right\">
<P><br><br>*</P>
</TD>
<TD>
<P><br><br><FONT SIZE=\"2\" FACE=\"Arial\">Length of
Posting:</FONT></P>
</TD>
<TD>
<P><br><br><FONT SIZE=\"2\" FACE=\"Arial\"><SELECT NAME=Length>
<OPTION VALUE=1 SELECTED>1 month
<OPTION VALUE=2>2 months
<OPTION VALUE=3>3 months
</SELECT></FONT></P>
</TD>
</TR>
</TABLE><center><input type=\"reset\" name=\"reset\" value=\"Clear Form\"><input type=\"submit\" name=\"submit\" value=\"Proceed\"></center></FORM></p>
";
}
/* Preview if nopix to upload or already uploaded */
else if ($submit =="Proceed"){
$title =" Preview your Details";
$Description= ereg_replace( '\$(([[:space:]]|[[:alnum:]])*)', '\\$ \\1', $Description);
//$Description= ereg_replace( "\\$$", "", $Description);
$Description= ereg_replace( "\r\n", "<br>", $Description);
$Description= ereg_replace( "\"", "``", $Description);
$Description= ereg_replace( "\'", "`", $Description);
$Title_Ad= ereg_replace( "\"", "``", $Title_Ad);
$Title_Ad= ereg_replace( "\'", "`", $Title_Ad);
$Contact= ereg_replace( "\r\n", "<br>", $Contact);
$content .="<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
<FORM ACTION=\"$PHP_SELF\" METHOD=POST>
<center><table border=2 cellpadding=5 cellspacing=3 width=100% background=\"/images/l2_left_menus.gif\"><tr><td><center><table border=0 cellpadding=4 cellspacing=0 width=100% background=\"/images/BBcream.gif\">
<tr><td colspan=2> <font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Category: ";
$count=count($Category);
for ($i=0; $i<$count; $i++) { $content .="<font color=\"#993333\">$Category[$i] - </font>";}
if ($Pix) {$content .="</b></font></td><td rowspan=7><img src=\"$view_pix/$Pix\" width=\"$width\" height=\"$height\" align=\"right\"></td></tr>";} else {$content .="</b></font></td></tr>";}
$content .="
<tr><td colspan=2><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>";
$content .= stripslashes($Title_Ad);
$content .="</b></font></td></tr>
<tr><td colspan=2><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Description:</b></font><br><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">";
$content .= stripslashes($Description);
$content .="</font>
<br><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><a href=\"http://$Url\" target=\"New\">$Url</a></font></td></tr>
<tr><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Name:</b></font></td><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">$Name</font></td></tr>
<tr><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Email:</b></font></td><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><a href=\"mailto:$Email\">$Email</a></font></td></tr>
<tr><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Contact:</b></font></td><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">$Contact </font></td></tr>
<tr><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>Length:</b></font></td><td><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">$Length Month(s)</font></td></tr>
</table></center></td></tr></table>
<input type=\"hidden\" name=\"Name\" value=\"$Name\">
<input type=\"hidden\" name=\"Email\" value=\"$Email\">
<input type=\"hidden\" name=\"Contact\" value=\"$Contact\">
<input type=\"hidden\" name=\"Category\" value=\"";
$count=count($Category);
for ($i=0; $i<$count; $i++) { $content .="$Category[$i],";}
$content .="\">
<input type=\"hidden\" name=\"Title_Ad\" value=\"$Title_Ad\">
<input type=\"hidden\" name=\"Description\" value=\"$Description\">
<input type=\"hidden\" name=\"Pix\" value=\"$Pix\">
<input type=\"hidden\" name=\"width\" value=\"$width\">
<input type=\"hidden\" name=\"height\" value=\"$height\">
<input type=\"hidden\" name=\"Url\" value=\"$Url\">
<input type=\"hidden\" name=\"Length\" value=\"$Length\">
<p><INPUT TYPE=\"button\" VALUE=\"Make Changes\" onClick=\"history.go(-1)\"> Or <input type=\"submit\" name=\"submit\" value=\"Post Notice Now\"></center></p>
</FORM>
";
}
/* Commit Entry */
else if ($submit =="Post Notice Now"){
$Category = ereg_replace( "\,$", "", $Category);
$date = date("Ymd");
$ID = time();
if ($Length ==1){$Length =100;}
if ($Length ==2){$Length =200;}
if ($Length ==3){$Length =300;}
$Title_Ad=stripslashes($Title_Ad);
$Description=stripslashes($Description);
$entry ="$date\t$ID\t$Category\t$Name\t$Email\t$Contact\t$Title_Ad\t$Description\t$Pix\t$width\t$height\t$Url\t$Length\n";
$title ="Your entry has been added";
$content .= "<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\">Please check your posting under the relevant category using the search page above.<br>
If you find that you have made a mistake, please email us <a href=\"$mail_address\">here</a>, giving details of your entry, so we can delete the posting. <br>
<b>\"We Cannot correct or change postings\"</b>. You will then have to re-post your entry.</font><br><br>";
//Dummy initial filehandle to obtain lock via
$fd = fopen($noticeB_file,"a");
$locked = flock($fd,2); #Exclusive blocking lock
if (!$locked) {
print "Error: timeout obtaining lock"; exit;
}
//Second (actually used) filehandle
$database = fopen($noticeB_file ,"a");
if (!($database)){
print ("Error:\n");
print ("File '$database' could not be opened\n");
exit;
}
fputs($database, "$entry");
//fputs($database, "\n");
fclose($database);
fclose($fd);
/* Mail Entry to Admin*/
$today = date("l jS F Y");
$time = date("H:i A");
/* subject */
$subject = "A New Entry has been made in the Community Notice Board";
/* message */
$message .= "This entry was done by $Name, $Email on $date\n";
$message .="TITLE ";
$message .=stripslashes($Title_Ad);
$message .=".\n
CONTENT ";$message .=stripslashes($Description);
$message .=".\n";
if ($Pix)
{$message .="PICTURE $http_pix/$Pix.\n";}
else {$message .="";}
if ($Url)
{$message .="URL http://$Url.\n";}
else {$message .="";}
$message .="LENGTH $Length.\n\n\n";
$message .="Note: It is a good idea to check picture and url as well.\n";
/* you can add a stock signature */
$message .= "----------------------------------------------------------------------\r\n"; //Signature delimiter
$message .= "Today 's date is $today and the Time is $time";
/* additional header pieces for errors, From cc's, bcc's, etc */
$headers .= "From: Community Notice Board <$mail_address\>n";
$headers .= "X-Sender: <$mail_address>\n";
$headers .= "X-Mailer: Our Community\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: <$mail_address>\n"; // Return path for errors
/* If you want to send html mail, uncomment the following line */
$headers .= "Content-Type: multipart/mixed;\n"; // Mime type
/* and now mail it */
mail($webmaster, $subject, $message, $headers);
}
/* parse to template */
$t = new Template( $path);
// create a template object named $t
$t->set_file( "MyFileHandle", "$template");
// set MyFileHandle = our template file
$t->set_var(array( "TITLE" => $title,
"FOOTER" => $bot,
"CONTENT" => $content));
// set template variable
$t->parse( "MyOutput", "MyFileHandle");
// set template variable MyOutput = parsed file
$t->p( "MyOutput"); // output the value of MyOutput (our parsed data)
?>
|