Author: piscdong Time: 2004-4-8 Document Type: Original from: Blue ideal view statistics total: 4273 | year: 89 | Quarter: 89 | Month: 89 | Week: 7 | today: 3
I have been developing Blog in PHP DBFILE, I have learned a lot during the development process, so I try to write a small message. This message uses PHP DBFILE, does not need to use the database, can be used in Blog, such as http://www.customyze.com, the Tag Board in this blog is this message. The entire message requires four files, namely: Board.php, index.php, config.php, admin.php. Board.php is used to store data and you can add a message record in it. Code copy box PHP
$ Board = array (
Array (1081410332, 'test', 'test message ",' http://www.piscdong.com ')
);
?> [Ctrl A All options and copy] Index.php is a message display and submission page. Code copy box PHP
Require_once ('Board.php');
Function HTMLENCODE ($ Content) {
$ Content = HTMLSpecialchars ($ Content);
$ Content = preg_replace ("// r / i", "
", $ 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 -] ) $ / 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 $ 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_WRILENAME) ||! file_exists ($ filename)) { IF (! $ handle = fopen ($ filename, 'w')) { Return False; } IF (! fwrite ($ handle, $ content) { Return False; } Fclose ($ handle); } else { Return False; } HEADER ('location :.'); } else { ?>
hEAD>