Php+dbfile Development of Small message book _php Foundation

Source: Internet
Author: User

Recently has been using Php+dbfile development blog, the development process to learn a lot of things, so I tried to write a small message book.
This message used Php+dbfile, do not need to use the database, you can put in the blog, such as http://www.customyze.com, this blog tag board is this message.

The whole message needs four files, namely: board.php, index.php, config.php, admin.php.

Board.php is used to store data, you can add a message record in it first. Code Copy Box
<?php $Board =array (Array (1081410332, ' Test ', ' Test message book ', ' http://www.piscdong.com '));?>
[Ctrl + a All select and copy]

index.php is the message display and submission page. Code Copy Box
<?php require_once (' board.php '); function HTMLEncode ($content) {$content =htmlspecialchars ($content); $content =preg_replace ("/\r/i", "<br/>", $ 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://'. Htmlspecialchars (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 <count ($Board); $i + +) {$ Bd=current ($Board); $s []=] \tarray (". $BD [0].", ' "$bd [1]." ', ' "$bd [2]." ', ' ". $BD [3]. Next ($Board); $content = "<?php\n\ $Board =array (\ n". Join ($s, ", \ n"). " \ n);\n?> "; $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{?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> [Ctrl + a All select and copy]

config.php is stored in the management of the message of the password, put the password in a separate file for easy modification. Code Copy Box
<?php $password = ' 123456 ';?>
[Ctrl + a All select and copy]

admin.php is the admin page, the function is very simple, can only delete the message. When you delete, you need to enter the admin password and the admin password is stored in the config.php. Code Copy Box
<?php require_once (' board.php '); Require_once (' config.php '); if (isset ($HTTP _post_vars[' id ']) && $HTTP _post_vars[' id ']!= ' && addslashes ($HTTP _post_vars[') Password '] = = $password) {if (count ($Board) >1) {unset ($Board [Intval ($HTTP _post_vars[' id]]); for ($i =0; $i < Count ($Board); $i + +) {$bd =current ($Board); $s []=] \tarray (". $BD [0].", ' "$bd [1]." ', ' $BD [2]. "', '". $BD [3]. ($Board); $content = "<?php\n\ $Board =array (\ n". Join ($s, ", \ n"). " \ n);\n?> "; $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{?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> [Ctrl + a All select and copy]

This message is also very simple, functional is not sound, such as no paging, but also can continue to improve. :-)

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.