The younger brother is a beginner in php (as the mainstream development language) and has compiled a message board program. He feels good about himself, so he put his face up. please correct me. The source program is as follows:
<? Php (as the mainstream development language)
// File name: guest. php (as the mainstream development language)
// Settings
$ Guestfile = "guest"; // record the text file of the message
$ Home = "index.html"; // return to the home page
$ Imagedir = "image"; // image file directory
$ Backimage = $ imagedir. "/bk.gif"; // background image
$ Backcolor = "# ceffff"; // background color, which takes effect when $ backimage = ""
?>
<Html>
<Head>
<? Php (as the mainstream development language)
If ($ QUERY_STRING! = ""){
$ Page = $ QUERY_STRING;
} Else {
$ Page = 1;
}
If ($ mode = "add "){
$ Name = htmlspecialchars (trim ($ name ));
$ Title = htmlspecialchars (trim ($ title ));
$ Data = nl2br (htmlspecialchars ($ data ));
$ Data = str_replace ("r", "", $ data );
$ Data = str_replace ("x0A", "", $ data );
$ Data = str_replace ("", "& nbsp;", $ data );
If ($ data = "") $ data = "";
$ E_mail = trim ($ e_mail );
If ($ e_mail = "") $ e_mail = 0;
$ Url = trim ($ url );
If ($ url = "http: //" | $ url = "") $ url = 0;
$ Time = date ("Y "). "year ". date ("m "). "month ". date ("d "). "Day [". date ("H "). ":". date ("I "). ":". date ("s "). "]";
If ($ name = "" | $ title = ""){
Echo "<script Language =" JavaScript "> n ";
Echo "alert (" Please enter at least the name and the message title. "); N ";
Echo "history. back ();";
Echo "</script> Exit;
}
$ Adddata = $ name. "t ". $ e_mail. "t ". $ url. "t ". $ title. "t ". $ data. "t ". $ icon. "t ". $ time. "n ";
If (file_exists ($ guestfile )){
$ Filebuffer = file ($ guestfile );
If (sizeof ($ filebuffer) & gt; 100 ){
For ($ I = 0; I I <100; $ I ++)
$ Newbuffer [I] = $ filebuffer [I];
}
Else {
$ Newbuffer = $ filebuffer;
}
$ Fp = fopen ($ guestfile, "w ");
Fputs ($ fp, $ adddata );
Fclose ($ fp );
$ Buffer = implode ("", $ newbuffer );
$ Fp = fopen ($ guestfile, "");
Fputs ($ fp, $ buffer );
Fclose ($ fp );
}
Else {
$ Fp = fopen ($ guestfile, "w ");
Fwrite ($ fp, $ adddata );
Fclose ($ fp );
}
}
?>
<Meta HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset = gb2312">
<Title> message board </title>
<Style>
A {text-decoration: none; font-size: 9pt; color: blue}
A: visited {text-decoration: none; color: 009999}
A: hover {color: red; text-decoration: underline}
Td {font-size: 9pt; line-height: 14pt}
P {font-size: 9pt}
</Style>
</Head>
<? Php (as the mainstream development language)
If ($ backimage! = "" & File_exists ($ backimage )){
Echo "<body background =" ". $ backimage." "bgproperties =" fixed "> n ";
}
Else {
Echo "<body bgcolor =" ". $ backcolor." "> n ";
}