復制代碼 代碼如下:
<?php
session_start();
//==========================
//作者:biyuan
//時間:2006.07
//聯系:QQ6010707
//==========================
?>
<html>
<head>
<title>碧原網絡PHP+ACCESS文章管理系統</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<style type="text/css">
body {
margin:0px;
text-align:center;
font-size:12px;
font-family:verdana;
}
td {
font-size:12px;
height:28px;
padding:4px;
font-family:verdana;
}
A:link,
A:visited,
A:active {
color: #005a17; text-decoration: none;
}
A:hover {
color: #ff5a00; text-decoration: underline;
}
</style>
</head>
<body>
<?php
//==================================
//連接數據庫
//==================================
@$conn = new com("ADODB.Connection");
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("article.mdb"));
//==================================
//文章導航
//==================================
function article_menu(){
global $conn;
@$sql = "Select * From List";
@$rs = $conn->Execute($sql);
while(!$rs->Eof){
echo "| <a href=\"?classid=" . $rs->Fields[2]->value . "\">" . $rs->Fields[1]->value . "</a> ";
$rs->MoveNext();
}
echo "| <a href=\"?admin=login\">後台管理</a>\r\n";
$rs->Close();
if(@$_SESSION["ARTICLEADMIN"] == "BY_PHP_ARTICLE"){
echo "<br />管理選項-> | <a href=\"?admin=class\">分類管理</a> | <a href=\"?admin=insert\">發表文章</a> | <a href=\"?admin=list\">文章列表</a> | <a href=\"?admin=logout\">退出登陸</a>";
}
}
//==================================
//文章列表:article_list(文章分類ID)
//==================================
function article_list($str){
global $conn;
@$sql = "Select id,by_title,by_name,by_time,by_count From Article Where by_class = " . $str . " Order By id desc";
@$rs = $conn->Execute($sql);
if(!$rs->Eof){
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#cccccc\">\r\n"
. " <tr bgcolor=\"#F3F3F3\" align=\"center\">\r\n"
. " <td>文章標題</td><td>文章作者</td><td>發表時間</td><td>浏覽次數</td>\r\n"
. " </tr>\r\n";
while(!$rs->Eof){
echo " <tr bgcolor=\"#FFFFFF\">\r\n"
. " <td><a href=\"?artid=" . $rs->Fields[0]->value . "\">" . $rs->Fields[1]->value . "</a></td><td>" . $rs->Fields[2]->value . "</td><td>" . date("Y-m-d H:i:s",$rs->Fields[3]->value) . "</td><td>" . $rs->Fields[4]->value . "</td>\r\n"
. " </tr>\r\n";
$rs->MoveNext();
}
echo "</table>\r\n";
}
else {
echo "<br />該分類不存在或暫時沒有任何文章!";
}
$rs->Close();
}
//==================================
//文章詳細:article_look(文章ID)
//==================================
function article_look($str){
global $conn;
@$sql = "Select * From Article Where id = " . $str;
@$rs = $conn->Execute($sql);
@$usql= "Update Article Set by_count = (by_count + 1) Where id = " . $str;
$conn->Execute($usql);
if(!$rs->Eof){
@$body = $rs->Fields[5]->value;
$body = str_replace("[url=file://%22,%22%22,$body/]\\","",$body[/url]);
echo "<table border=\"0\" width=\"60%\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#cccccc\">\r\n"
. " <tr bgcolor=\"#F3F3F3\" align=\"center\">\r\n"
. " <td style=\"font-size:14px;font-weight:bold\">" . $rs->Fields[1]->value . "</td>\r\n"
. " </tr>\r\n"
. " <tr bgcolor=\"#F3F3F3\" align=\"center\">\r\n"
. " <td>文章作者:" . $rs->Fields[2]->value . " | 發表