A paging text-based PHP message board

Source: Internet
Author: User

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 ";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.