| px | top | add code | search | signup | login | help |
<!-------------------- topics.php -------------------->
<html>
<?php
# EK_Forum v1.0 by Patrick Tou 7/25/2001
include "forum.cfg\";
echo \"<head>\";
echo \"<title>$FORUMTITLE</title>\";
echo \"</head>\";
echo \"<body bgcolor=$COLOR_TPBGCOLOR text=$COLOR_TPTEXT link=$COLOR_TPLINK vlink=$COLOR_TPVLINK alink=$COLOR_TPALINK>\";
?>
<?php
if (!file_exists($FORUMFILE)) touch($FORUMFILE);
//
// function thread_save()
//
{
@$name = $HTTP_POST_VARS[\'username\'];
@$email = $HTTP_POST_VARS[\'email\'];
@$message = $HTTP_POST_VARS[\'message\'];
@$topic = $HTTP_POST_VARS[\'topic\'];
$time = time();
if ( ($name != \"\") &&
($topic != \"\") &&
($message != \"\") )
{
$file = fopen($FORUMFILE, \"a\");
if ($file) {
$thread = tempnam(\".\", $THREADHEAD);
//
// Append thread info into thread data file.
//
set_file_buffer($file,0); // write operations are unbuffered
fputs ($file,\"$REMOTE_ADDR\\n\");
fputs ($file,\"$time\\n\");
fputs ($file,\"$name\\n\");
fputs ($file,\"$email\\n\");
fputs ($file,\"$topic\\n\");
fputs ($file,\"$thread\\n\");
fputs ($file,$DELIMITER);
//
// Create thread file
//
$tfile = fopen(\"$thread\", \"w\");
set_file_buffer($tfile,0); // write operations are unbuffered
fputs ($tfile,\"$topic\\n\");
fputs ($tfile,\"$REMOTE_ADDR\\n\");
fputs ($tfile,\"$time\\n\");
fputs ($tfile,\"$name\\n\");
fputs ($tfile,\"$email\\n\");
fputs ($tfile,\"$message\\n\");
fputs ($tfile,$DELIMITER);
fclose($tfile);
//
// Done saving. Go to next state
//
echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url=$THREADMOD?$thread\\\">\";
}
fclose($file);
}
} /* end function thread_save() */
echo \"<CENTER>\";
echo \"<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=3 width=100%>\\n\";
echo \" <TR align=center><TD></TD>\\n\";
echo \" <td bgcolor=$COLOR_TPN width=65%><B><font $FORUMNAMEFONT>$FORUMNAME</FONT></B></td>\\n\";
echo \" <TD></TD></TR>\\n\";
$coloridx = 0;
$file = fopen($FORUMFILE, \"r\");
if ($file)
while (!feof ($file)) {
//
// Read the threads from the file.
//
$trash = trim(fgets ($file,1024));
$time = trim(fgets ($file,1024));
$name = trim(fgets ($file,1024));
$email = trim(fgets ($file,1024));
$topic = trim(fgets ($file,1024));
$thread = trim(fgets ($file,1024));
// Get EOM line
$temp = \"go\";
while ($temp != \"\") {
$temp = fgetss ($file,1024);
if ($temp == $DELIMITER)
$temp = \"\";
}
if (feof($file)) break;
//
// Display the thread info.
//
$coloridx++;
$color = ($coloridx % 2) ? $COLOR_TP1 : $COLOR_TP2;
echo \" <TR VALIGN=top bgcolor=$color>\\n\";
echo \" <TD width=15%><FONT $FORUMTEXTFONT><a href=\\\"mailto:$email\\\">$name</a></FONT></TD>\\n\";
echo \" <TD width=65%><FONT $FORUMTEXTFONT><a href=\\\"$THREADMOD?$thread\\\">$topic </a></FONT></TD>\\n\";
echo \" <TD width=20%><FONT $FORUMTEXTFONT>\"; print(date(\"m/d g:ia\", $time)); echo \"</FONT></TD>\\n\";
echo \" </TR>\\n\";
}
echo \"</TABLE>\";
echo \"</CENTER>\\n\";
fclose($file);
?>
<?php
echo \"<form action=\\\"$PHP_SELF\\\" METHOD=POST>\\n\\n\";
echo \"<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>\\n\";
echo \" <TR>\\n\";
echo \" <TD>Name:</TD><TD><input type=\\\"text\\\" name=\\\"username\\\"></TD>\\n\";
echo \" <TD>Email:</TD><TD><input type=\\\"text\\\" name=\\\"email\\\"></TD>\\n\";
echo \" </TR>\\n\";
echo \" <TR><TD>Topic:</TD><TD COLSPAN=3><input type=\\\"text\\\" name=\\\"topic\\\" SIZE=50 MAXLENGTH=50></TD></TR>\\n\";
echo \" <TR VALIGN=TOP> <TD ALIGN=CENTER>Message:</TD>\\n\";
echo \" <TD COLSPAN=3><TEXTAREA ROWS=10 COLS=50 WRAP=SOFT name=\\\"message\\\"></TEXTAREA><BR>\\n\";
echo \" <INPUT TYPE=SUBMIT VALUE=\\\"Submit New Topic\\\"></TD>\\n\";
echo \" </TR>\\n\";
echo \"</TABLE></FORM>\\n\\n\";
echo \"</body>\\n\";
?>
</html>
<!-------------------- topics.php end ---------------->
<!-------------------- threads.php ------------------->
<html>
<?php
# EK_Forum v1.0 by Patrick Tou 7/25/2001
include \"forum.cfg\";
echo \"<head>\\n\";
echo \"<title>$FORUMTITLE</title>\\n\";
echo \"</head>\\n\";
echo \"<body bgcolor=$COLOR_THBGCOLOR text=$COLOR_THTEXT link=$COLOR_THLINK vlink=$COLOR_THVLINK alink=$COLOR_THALINK>\\n\";
if ($argc > 0)
$thread = $argv[0];
else
echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url=$FORUMMOD\\\">\";
echo \"<a href=$FORUMMOD>$THREADBACKTEXT</a><p>\\n\";
?>
<?php
//
// function thread_save()
//
{
@$name = $HTTP_POST_VARS[\'username\'];
@$email = $HTTP_POST_VARS[\'email\'];
@$message = $HTTP_POST_VARS[\'message\'];
@$topic = $HTTP_POST_VARS[\'topic\'];
$time = time();
if ( ($name != \"\") &&
($message != \"\") )
{
$file = fopen(\"$thread\", \"a\");
if ($file) {
//
// Append thread info into thread data file.
//
set_file_buffer($file,0); // write operations are unbuffered
fputs ($file,\"$REMOTE_ADDR\\n\");
fputs ($file,\"$time\\n\");
fputs ($file,\"$name\\n\");
fputs ($file,\"$email\\n\");
fputs ($file,\"$message\\n\");
fputs ($file,$DELIMITER);
//
// Done saving. Go to next state
//
echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url=$PHP_SELF?$thread\\\">\";
}
fclose($file);
}
} // end function thread_save()
$file = fopen(\"$thread\", \"r\");
if ($file){
$topic = fgets ($file,1024);
echo \"<CENTER>\";
echo \"<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=3 width=100%>\\n\";
echo \" <TR align=center><TD></TD>\\n\";
echo \" <TD bgcolor=$COLOR_THN width=65%><B><FONT $THREADNAMEFONT>$topic</FONT></B></TD>\\n\";
echo \" <TD></TD></TR>\";
$coloridx = 0;
while (!feof ($file)) {
//
// Read the threads from the file.
//
$trash = trim(fgets ($file,1024));
$time = trim(fgets ($file,1024));
$name = trim(fgets ($file,1024));
$email = trim(fgets ($file,1024));
// Get message
$message = \"\";
$temp = \"go\";
while ($temp != \"\") {
$temp = fgets ($file,80);
if ($temp == $DELIMITER)
$temp = \"\";
else
if ($message == \"\") $message = trim(strip_tags($temp));
else $message = $message . \"\\n\" . trim(strip_tags($temp));
}
if (feof($file)) break;
$message = trim($message);
$message = nl2br($message);
$message = stripslashes($message);
if ($message == \"\") $message = \" \";
//
// Display the thread info.
//
$coloridx++;
$color = ($coloridx % 2) ? $COLOR_TH1 : $COLOR_TH2;
echo \" <TR VALIGN=top bgcolor=$color>\\n\";
echo \" <TD width=15%><FONT $THREADTEXTFONT><a href=\\\"mailto:$email\\\">$name</a></FONT></TD>\\n\";
echo \" <TD width=65%><FONT $THREADTEXTFONT>$message</FONT></TD>\\n\";
echo \" <TD width=20%><FONT $THREADTEXTFONT>\"; print(date(\"m/d g:ia\", $time)); echo \"</FONT></TD>\\n\";
echo \" </TR>\\n\";
}
echo \"</TABLE>\";
echo \"</CENTER>\\n\";
}
fclose($file);
?>
<?php
echo \"<P><a href=$FORUMMOD>$THREADBACKTEXT</a><P>\\n\\n\";
echo \"<FORM action=\\\"$PHP_SELF?$thread\\\" METHOD=POST>\\n\";
echo \"<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>\\n\";
echo \" <TR>\\n\";
echo \" <TD>Name:</TD><TD><input type=\\\"text\\\" name=\\\"username\\\"></TD>\\n\";
echo \" <TD>Email:</TD><TD><input type=\\\"text\\\" name=\\\"email\\\"></TD>\\n\";
echo \" </TR>\\n\";
echo \" <TR VALIGN=TOP> <TD ALIGN=CENTER>Message:</TD>\\n\";
echo \" <TD COLSPAN=3><TEXTAREA ROWS=10 COLS=50 WRAP=SOFT name=\\\"message\\\"></TEXTAREA><BR>\\n\";
echo \" <INPUT TYPE=SUBMIT VALUE=\\\"Submit New Message\\\"></TD>\\n\";
echo \" </TR>\\n\";
echo \"</TABLE></FORM>\\n\\n\";
echo \"</body>\\n\";
?>
</html>
<!-------------------- threads.php end --------------->
<!-------------------- forum.cfg --------------------->
<?php
#
# EK_Forum v1.0 by Patrick Tou 7/25/2001
# This is the configuration file for the Forum
#
# The file name of the Topic server file.
$FORUMMOD = \"topics.php\";
# The HTML title for the Forum. Both the Title and Thread share this.
$FORUMTITLE = \"Patrick\'s PHP forum test\";
# The Forum title for the Topics
$FORUMNAME = \"PATRICK\'s Forum\";
# HTML <body> colors for the Topics
$COLOR_TPALINK = \"#FF0000\";
$COLOR_TPBGCOLOR = \"#FFFFFF\";
$COLOR_TPLINK = \"#0000FF\";
$COLOR_TPTEXT = \"#000000\";
$COLOR_TPVLINK = \"#000080\";
# HTML font specs for the Topics title <FONT xxx>
$FORUMNAMEFONT = \"face=verdana\";
# Background color for Topics title
$COLOR_TPN = \"gray\";
# HTML font specs for the Topics body <FONT xxx>
$FORUMTEXTFONT = \"face=verdana\";
# Background colors for Topics body
$COLOR_TP1 = \"darkgray\";
$COLOR_TP2 = \"gray\";
# The file name of the Threads server file.
$THREADMOD = \"threads.php\";
# HTML <body> colors for the Threads
$COLOR_THALINK = \"#FF0000\";
$COLOR_THBGCOLOR = \"#FFFFFF\";
$COLOR_THLINK = \"#0000FF\";
$COLOR_THTEXT = \"#000000\";
$COLOR_THVLINK = \"#000080\";
# HTML font specs for the Threads topic <FONT xxx>
$THREADNAMEFONT = \"face=verdana\";
# Background color for Threads topic
$COLOR_THN = \"gray\";
# HTML font specs for the Threads body <FONT xxx>
$THREADTEXTFONT = \"face=verdana\";
# Background colors for Threads body
$COLOR_TH1 = \"darkgray\";
$COLOR_TH2 = \"gray\";
# HTML text for to go back to Topics from Threads
$THREADBACKTEXT = \"<font>Back to Forum</font>\";
#
# Data file specs
#
# File name to store topics
$FORUMFILE = \"topics.txt\";
# File name prefix to store threads
$THREADHEAD = \"data\";
# Delimiter in data files between each record.
$DELIMITER = \"==µµ== END ==µµ==\\n\";
?>
<!-------------------- forum.cfg end ----------------->
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.