php blog網站開發執行個體教程(1/8)

來源:互聯網
上載者:User

  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>
 

 

首頁 1 2 3 4 5 6 7 8 末頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.