post.php 讀檔案並顯示日誌內容的php程式。
page.html 顯示日誌文章的html文檔。
style.css教程 頁面顯示效果的css代碼。
add.php 添加blog文章的php程式。
config/auth.php 使用者名稱和密碼設定檔。
index.php blog首頁程式。
edit.php 編輯blog文章的程式。
delete.php 刪除blog文章的程式。
archives.php 歸檔顯示blog文章的程式。
logout.php 退出登入的程式。
*/
//post.php 讀檔案並顯示日誌內容的php程式。
| 代碼如下 |
複製代碼 |
<?php if(!isset($_get['entry'])) { echo '請求參數錯誤'; exit; } $post_data = array(); $path = substr($_get['entry'],0,6); //日誌儲存目錄 $entry = substr($_get['entry'],7,9); //記錄檔名稱 $file_name = 'contents/'.$path.'/'.$entry.'.txt'; if(file_exists($file_name)) { $fp = @fopen($file_name, 'r'); if($fp) { flock($fp, lock_sh); $result = fread($fp, filesize($file_name)*100); } flock($fp, lock_un); fclose($fp); } $content_array = explode('|', $result); $post_data['subject'] = $content_array[0]; $post_data['date'] = date('y-m-d h:i:s',$content_array[1]); $post_data['content'] = $content_array[2]; //print_r($post_data); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title>基於文本的簡易blog</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="container"> <div id="header"> <h1>我的blog</h1> </div> <div id="title"> ----i have dream.... </div> <div id="left"> <div id="blog_entry"> <div id="blog_title"><? echo $post_data['subject'];?></div> <div id="blog_body"> <div id="blog_date"><? echo $post_data['date'];?></div> <? echo $post_data['content'];?> </div><!--blog_body--> </div><!--blog_entry--> </div> <div id="right"> <div id="sidebar"> <div id="menu_title">關於我</div> <div id="menu_body">www.111cn.net</div> </div> </div> <div id="footer"> copyright 2007 </div> </div> <body> </html> |
//page.html 顯示日誌文章的html文檔。
| 代碼如下 |
複製代碼 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title>blog</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="container"> <div id="header"> <h1>我的blog</h1> </div> <div id="title"> ----i have a dream.... </div> <div id="left"> <div id="blog_entry"> <div id="blog_title">日誌文章標題</div> <div id="blog_body"> <div id="blog_date">2007-12-01</div> 日誌文章內容 </div> </div> </div> <div id="right"> <div id="sidebar"> <div id="menu_title">關於我</div> <div id="menu_body">www.111cn.net</div> </div> </div> <div id="footer"> copyright 2007 </div> </div> <body> </html> |