Develop a small message book using php + dbfile

Source: Internet
Author: User
Recently, I have been using php + dbfile to develop blogs. I learned a lot during the development process, so I tried to write a small message book. This message book using php + dbfile, do not need to use the database, can be used in the blog, such as http://www.customyze.com, the TagBoard in this blog is the message book. The entire message book requires four files:
Recently, I have been using php + dbfile to develop blogs. I learned a lot during the development process, so I tried to write a small message book.
This message book using php + dbfile, do not need to use the database, can be used in the blog, such as http://www.customyze.com, this blog in the Tag Board is the message book.

The entire message book requires four files: board. php, index. php, config. php, and admin. php.

Board. php is used to store data. you can add a message record in it first. Code copy box

[Ctrl + A Select All and copy]

Index. php is the page for message display and submission. Code copy box
", $ Content); return $ content;} if ($ HTTP_SERVER_VARS ['request _ method'] = 'post') {$ configpath_parts1 = pathinfo ($ SCRIPT_FILENAME ); $ time = time (); $ name = $ HTTP_POST_VARS ['name']; $ url = (preg_match ("/^ [\ w-] + (\\. [\ w-] +) * @ [\ w-] + (\\. [\ w-] +) + $/I ", $ HTTP_POST_VARS ['URL'])
$ HTTP_POST_VARS ['URL'] = ')? $ HTTP_POST_VARS ['URL']: 'http: // '.html specialchars (preg_replace ("/https? \: \ // I ", ', $ HTTP_POST_VARS ['URL']), ENT_QUOTES); $ info = htmlencode ($ HTTP_POST_VARS ['info']); if ($ name! = '& $ Info! = ') {$ Board [] = array ($ time, $ name, $ info, $ url);} for ($ I = 0; $ I "; $ Filename = $ configpath_parts1 ['dirname']. '/'. 'board. php'; if (is_writable ($ filename)
! File_exists ($ filename) {if (! $ Handle = fopen ($ filename, 'w') {return false;} if (! Fwrite ($ handle, $ content) {return false;} fclose ($ handle);} else {return false;} header ('Location :. ');} else {?> Message book
[Ctrl + A Select All and copy]

Config. php stores the password for managing the message book, and stores the password in a separate file for ease of modification. Code copy box

[Ctrl + A Select All and copy]

Admin. php is used to manage pages. It has simple functions and can only delete messages. You need to enter the management password when deleting the password and store it in config. php. Code copy box
1) {unset ($ Board [intval ($ HTTP_POST_VARS ['id']); for ($ I = 0; $ I "; $ Configpath_parts1 = pathinfo ($ SCRIPT_FILENAME); $ filename = $ configpath_parts1 ['dirname']. '/'. 'board. php'; if (is_writable ($ filename)
! File_exists ($ filename) {if (! $ Handle = fopen ($ filename, 'w') {return false;} if (! Fwrite ($ handle, $ content) {return false;} fclose ($ handle);} else {return false ;}} header ('Location: admin. php ');} else {?> Manage message Books '. (Count ($ Board)> 1? ' ':').' '; Next ($ Board);} echo join ($ s,');?>
'. ($ Bd [3]! = '? '': '). $ Bd [1]. ($ bd [3]! = '? '':').':'. $ Bd [2].'
-'. Date ("G: I, M j, Y", $ bd [0]).'

[Ctrl + A Select All and copy]

This message book is still very simple and its functions are not perfect. for example, it can be improved without paging. :-)

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.