コードをコピー コードは次のとおりです: session_start(); //======================== //著者: biyuan //時間: 2006.07 //連絡先: QQ6010707 //======================= = === ?> Biyuan Network PHP ACCESS 記事管理システム equiv="content-type" content="text/html; charset=gb2312" /> <br>margin:0px; >text-align:center; <br>font-family:verdana; <br>td { <br>font-size:12px; <br>padding:4px; <br>font-family:verdana; <br>A:link, <br>A:visited, <br>A:active { <br>color: #005a17; -装飾: なし; <br>} <br>色: #ff5a00; テキスト装飾: <br>} <br></head> <br><body> <br><?php <BR>//============================= = ==== <BR>//データベースに接続します <BR>//=============================== ===== <BR>@$conn = new com("ADODB.Connection"); <BR>$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ= . realpath("article.mdb")); <BR>//================================= = <BR>//記事ナビゲーション<BR>//================================== <BR> functionarticle_menu(){ <BR>global $conn; <BR>@$sql = "リストから選択"; <BR>@$rs = $conn->while(! $rs->Eof) { <br>echo "| <a href="?classid=" . $rs->Fields[2]->value . "">"フィールド[1]-> 値 . "<br>$rs->MoveNext(); <br>echo "| <a href="?admin=login" >バックエンド管理</ a>rn"; <br>$rs->Close(); <br>if(@$_SESSION["ARTICLEADMIN"] == "BY_PHP_ARTICLE"){ <br>echo "< br />管理オプション -<a href="?admin=class">カテゴリ管理</a> <a href="?admin=list">記事リスト</a><a href="?admin=logout">ログアウト</a>"; <br>} <br>} <br> //================================== <br>//記事リスト:article_list (記事カテゴリID) <br>//================================== <br>関数article_list($str) { <br>global $conn; <br>@$sql = "記事から id,by_title,by_time,by_count を選択します。 by_class = " . $str . " ID desc で並べ替えます"; $conn ->Execute($sql); <br>if(!$rs->Eof){ <br>echo "<table border="0" cellpadding="1" cellpadding="0" bgcolor= "# cccccc">rn" <br>. " <tr bgcolor="#F3F3F3" align="center">rn" <br>. " <td>記事タイトル</td><td>記事著者</td><td>公開時刻</td><td>閲覧数</td>rn" <br>. " </tr>rn"; <BR>while(!$ rs ->Eof){ <br>echo " <tr bgcolor="#FFFFFF">rn" <br>. " <td><a href="?artid=" . $rs-> フィールド[0]->値 . ""> . $rs->フィールド[1]-> 値 . "</a></td><td>" . $rs->フィールド[2]->値 . "</p> <td>" .date("Y-m-d H:i:s",$rs->フィールド[3]->値) . /td>gt;</td> <td>" . $rs->Fields[4]->value . "</td>rn" <BR>. " </tr>rn"; <BR>$rs - >MoveNext(); <br>} <br>echo "</table>rn"; <BR>else { <BR>echo "<br />このカテゴリは存在しないか、一時的に記事がありません!"; <br>} <br>$rs->Close(); <br>}<br>//================================== <br>//文章详细:article_look(文章ID) <br>//================================== <br>関数article_look($str) { <br>グローバル $conn; <br>@$sql = "ID = " の記事から * を選択します。 $str; <br>@$rs = $conn->Execute($sql); <br>@$usql= "記事セットを更新 by_count = (by_count 1) Where id = " . $str; <br>$conn->実行($usql); <br>if(!$rs->Eof){ <br>@$body = $rs->Fields[5]->value; <br>$body = str_replace("[url=file://","",$body/]\","",$body[/url]); <br>echo "<table border=" 0" width="60%" cellpacing="1" cellpadding="0" bgcolor="#cccccc">rn" <br> " <tr bgcolor="#F3F3F3" align="center">rn " <br>. " <td style="font-size:14px;font-weight:bold">" . $rs->Fields[1]->value . "</td>rn" <br>. " </tr>rn" <br>. " <tr bgcolor="#F3F3F3" align="center">rn" <br>. " <td> rs->フィールド[2]->値 " | 公開時刻:" . date("Y-m-d H:i:s",$rs->Fields[3]->value) . " | 浏览次数:" . $rs->Fields[4]->value . "</td>rn" <BR>. " </tr>rn" <BR>. " <tr bgcolor=" #FFFFFF">rn" <br>." <td>rn" <br> " <tr bgcolor ="#F3F3F3">rn" <br>. " <td align="right">【 <a href="javascript:history.back();">返し</a> 】 【 <a href="javascript:print();">打印</a> 】 【 <a href="javascript:close();">关闭</a> ]</td>rn" <br>. " </tr>rn" <BR>. " </table>rn" <BR>. " <script language="JavaScript">document.title = "--" 。 $rs->Fields[1]->value 。 "";</script>rn"; <br>} <br>else { <br>echo "<br />该文章不存在または已被管理员删除!"; <BR>} <BR>$rs->Close(); <br>} <br>//============================== === <br>//後台:分类管理 <br>//================================= = <br>function admin_class(){ <br>global $conn; <br>@$sql = "リストから * を選択" <br>@$rs = $conn->Execute($sql); >echo "<form action="" method="post" name="frm">rn"; <br>while(!$rs->Eof){ <br>echo "类别:<入力タイプ="テキスト" 値="" 。 $rs->Fields[1]->value 。 "" name="class_" 。 $rs->Fields[0]->value 。 "" /> 编号:<input type="text" value="" 。 $rs->Fields[2]->value 。 "" name="class_cid_" 。 $rs->Fields[0]->value 。 "" /> <input type="button" value="修正" onclick="frm.action='?admin=class&class=edit&id=" 。 $rs->Fields[0]->value 。 "';提出する();" /> <input type="button" value="删除" onclick="frm.action='?admin=class&class=del&id=" 。 $rs->Fields[0]->value 。 "';提出する();" /><br />rn"; <br>$rs->MoveNext(); <br>} <br>echo "类别:<input type="text" name="class_name" /> ; 编号:<input type="text" name="class_cid" /> <input type="button" value="增加" onclick="frm.action='?admin=class&class=add';submit();" /> <input type="button" value="闲置" 無効 />rn" <br>. "</form>rn"; <br>//增加一个类别 <br>if(@$_GET[" class"] == "add"){ <br>if(@$_POST["class_name"] == "" || @$_POST["class_cid"] == ""){ <br>echo "< br />充填写不完整!"; <br>echo "<script language="JavaScript">setTimeout("history.back();", 2000);</script>"; <br>exit (); <br>} <br>else { <br>@$sql = "List(by_list,by_cid) Values('" . $_POST["class_name"] . "' , '" . $_POST[ "class_cid"] . "')"; <br>$conn->Execute($sql); <br>echo "<br />追加成功!"; "JavaScript">setTimeout("window.location.href='?admin=class';", 2000);</script>"; <br>} <br>} <br>//修改一个类别 <br>if(@$_GET["class"] == "編集"){ <br>if(@$_POST["class_" . $_GET["id"]] == "" || @$_POST[ "class_cid_" . $_GET["id"]] == ""){ <br>echo "<br />充填写不完整!" <br>echo "<script language="JavaScript"> setTimeout("history.back();", 2000);</script>"; <br>exit(); <br>} <br>else { <br>@$sql = "Update List Set by_list = '" . $_POST["class_" . $_GET["id"]] . "' , by_cid = '" . $_POST["class_cid_" . $_GET["id"]] . "' Where id = " . $_GET["id"]; <br>$conn->Execute($sql); <br>echo "<br />修改成功!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=class';\", 2000);</script>"; <br>} <br>} <br>//删除一个类别 <br>if(@$_GET["class"] == "del"){ <br>@$sql = "Delete From List Where id = " . $_GET["id"]; <br>$conn->Execute($sql); <br>echo "<br />删除成功!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=class';\", 100);</script>"; <br>} <br>} <br>//================================== <br>//后台:发表文章(支持HTML) <br>//================================== <br>function admin_insert(){ <br>global $conn; <br>if(@$_GET["innert"] == "add"){ <br>if(@$_POST["title"] == "" || @$_POST["name"] == "" || @$_POST["class"] == "" || @$_POST["body"] == ""){ <br>echo "<br />填写不完整!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"history.back();\", 2000);</script>"; <br>exit(); <br>} <br>else { <br>@$body = $_POST["body"]; <br>$body = str_replace("'", "''", $body); <br>$body = str_replace("\r\n", "<br />", $body); <br>@$sql = "Insert into article(by_title,by_name,by_time,by_count,by_body,by_class) Values('" . $_POST["title"] . "' , '" . $_POST["name"] . "' , #" . date("Y-m-d G:i:s") . "# , 0 , '" . $body . "' , '" . $_POST["class"] . "')"; <br>$conn->Execute($sql); <br>echo "<br />添加成功!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=insert';\", 2000);</script>"; <br>} <br>} <br>else { <br>echo "<div style=\"width:590px;text-align:left\">\r\n" <br>. "<form action=\"?admin=insert&innert=add\" method=\"post\">\r\n" <br>. "文章标题:<input type=\"text\" name=\"title\" /><br />\r\n" <br>. "文章作者:<input type=\"text\" name=\"name\" /><br />\r\n" <br>. "文章类别:<select name=\"class\">\r\n"; <br>@$sql = "Select * From List"; <br>@$rs = $conn->Execute($sql); <br>while(!$rs->Eof){ <br>echo "<option value=\"" . $rs->Fields[2]->value . "\">" . $rs->Fields[1]->value . "</option>\r\n"; <br>$rs->MoveNext(); <br>} <br>echo "</select><br />\r\n" <br>. "文章正文:<textarea cols=\"70\" rows=\"14\" name=\"body\"></textarea><br />\r\n" <br>. "<center><input type=\"submit\" value=\"提交\" /> <input type=\"reset\" value=\"重置\" /></center>\r\n" <br>. "</form>\r\n" <br>. "</div>rn"; <br>} <br>} <br>//================================= = = <br>//バックエンド: 記事リスト<br>//================================== == <br>function admin_list(){ <br>global $conn; <br>@$sql = "ID 説明による記事順序から ID、タイトル別、名前別、時間別、カウント別、クラス別を選択します"; rs = $ conn->Execute($sql); <br>if(!$rs->Eof){ <br>echo "<table border="0" cellpacing="1" cellpadding="0" bgcolor=" #cccccc">rn" <br>. " <tr bgcolor="#F3F3F3" align="center">rn" <br>. " <td>記事タイトル</td>< td> 記事カテゴリ<td>記事著者</td><td>公開時間</td><td>閲覧数</td><td>操作</td>rn" <br> . " </tr>rn"; <br>while(!$rs->Eof){ <br>@$sql = "Select * From List Where by_cid = " . $rs->Fields[5] -> ;値; <br>@$crs = $conn->実行($sql); <br>@$cid = $crs->フィールド[1]->値; <br> bgcolor="#FFFFFF">rn" <br>. " <td><a href="?artid=" . $rs->Fields[0]->value . $rs->フィールド[1]->値 . "</td><td>" ;フィールド[2]->値 .$rs->フィールド[3]->$rs ->フィールド[4]->値 . "</td><td<a href="?admin=list&list=edit&id=" . $rs->フィールド[0]-> ;値. "">編集<a href="?admin=list&list=del&id=" . "">削除< ;/td>rn" <BR>. " </tr>rn"; <BR>$crs->Close(); <BR>$rs->MoveNext(); <BR> } <BR> echo "</table>rn"; <br>} <br>else { <br>echo "<br />このカテゴリは存在しないか、現在記事がありません!"; >$rs->Close(); <br>//記事を変更<br>if(@$_GET["list"] == "edit"){ <br>if(@$_GET["edit "] == "true"){ <br>if(@$_POST["title"] == "" || @$_POST["name"] == "" || @$_POST["class"] == "" || @$_POST["body"] == ""){ <br>echo "<br />不完全!"; <br>echo "<script language="JavaScript" >setTimeout( "history.back();", 2000);</script>"; <br>exit(); <br>} <br>else { <br>@$body = $_POST[" body"]; <br>$body = str_replace("'", "''", $body); <br>$body = str_replace("rn", "<br />", $body); $sql = "記事を更新 by_title = '" . $_POST["title"] . "' , by_name = '" . $_POST[ "count" . . " , by_body = '" . $body = '" . $_POST["id"] ; Execute($sql); <br>echo "<br />変更が成功しました!"; <br>echo "<script language="JavaScript">setTimeout("window.location.href= '?admin= list';", 2000);</script>"; <br>} <br>} <br>else { <br>@$sql = "Select * From Article Where id = " . "]; <br>@$rs = $conn->Execute($sql); <br>echo "<div style="width:590px;text-align:left">rn" <br>。 "<form action="?admin=list&list=edit&edit=true&id=" . $rs->fields[0]->value . "" method="post">rn" <br> "記事のタイトル:<input type="text" name="title" value="" . $rs->fields[1]->value . "" /><br>rn" <br>。 "記事著者:<input type="text" name="name" value="" . $rs->fields[2]->value . "" /><br /> ;rn" <BR>. "閲覧数:<input type="text" name="count" value="" . $rs->fields[4]->value . "" />< br /> ;rn" <BR>. "記事カテゴリ: <select name="class" id="class">rn"; <br>@$sql = "リストから * を選択"; <br>@ $crs = $conn->Execute($sql); <br>while(!$crs->Eof){ <br>echo "<option value="" . $crs->Fields[2] ->値 . ""> . $crs->Fields[1]->value . "</option>rn"; <BR>$crs->MoveNext(); <BR>} <BR>$crs->close(); <br>@$body = $rs->Fields[5]->value; <br>$body = str_replace("<br />","\r\n",$body); <br>echo "</select><br />\r\n" <br>. "<script language=\"JavaScript\">\r\n" <br>. "document.getElementById(\"class\").selectedIndex = " . $rs->fields[6]->value . " - 1;\r\n" <br>. "</script>\r\n" <br>. "文章正文:<textarea cols=\"70\" rows=\"14\" name=\"body\">" . $body . "</textarea><br />\r\n" <br>. "<center><input type=\"submit\" value=\"提交\" /> <input type=\"reset\" value=\"重置\" /></center>\r\n" <br>. "</form>\r\n" <br>. "</div>\r\n"; <br>} <br>} <br>//删除文章 <br>if(@$_GET["list"] == "del"){ <br>@$sql = "Delete From Article Where id = " . $_GET["id"]; <br>$conn->Execute($sql); <br>echo "<br />删除成功!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=list';\", 100);</script>"; <br>} <br>} <br>//================================== <br>//权限验证 <br>//================================== <br>function admin_session(){ <br>if(@$_SESSION["ARTICLEADMIN"] != "BY_PHP_ARTICLE"){ <br>echo "<br />请先登陆!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=login';\", 2000);</script>"; <br>exit(); <br>} <br>} <br>//================================== <br>//后台登陆 <br>//================================== <br>function admin_login(){ <br>if(@$_SESSION["ARTICLEADMIN"] == "BY_PHP_ARTICLE"){ <br>echo "<script language=\"JavaScript\">window.location.href='?admin=admin';</script>"; <br>} <br>else{ <br>echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"#cccccc\">\r\n" <br>. " <tr bgcolor=\"#F3F3F3\" align=\"center\">\r\n" <br>. " <td><strong>管理员登陆</strong></td>\r\n" <br>. " </tr>\r\n" <br>. " <tr bgcolor=\"#FFFFFF\">\r\n" <br>. " <form method=\"post\" action=\"?admin=check\">\r\n" <br>. " <td><input type=\"password\" name=\"adminPass\" /><input type=\"submit\" value=\"确定\" /></td>\r\n" <br>. " </form>\r\n" <br>. " </tr>\r\n" <br>. "</table>\r\n"; <br>} <br>} <br>//================================== <br>//登陆验证 <br>//================================== <br>function admin_check(){ <br>if(trim($_POST["adminPass"]) != "admin"){ <br>echo "<br />错误的密码!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"history.back();\", 2000);</script>"; <br>} <br>else { <br>echo "<br />登陆成功!"; <br>@$_SESSION["ARTICLEADMIN"] = "BY_PHP_ARTICLE"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=admin';\", 2000);</script>"; <br>} <br>} <br>//================================== <br>//URL参数列表 <br>//================================== <br>function page_load(){ <br>@$classid = $_GET["classid"]; <br>if($classid != ""){ <br>if(!is_numeric($classid)){ <br>echo "<br />错误的参数!"; <br>return false; <br>} <br>else { <br>article_list($classid); <br>} <br>} <br>@$artid = $_GET["artid"]; <br>if($artid != ""){ <br>if(!is_numeric($artid)){ <br>echo "<br />错误的参数!"; <br>return false; <br>} <br>else { <br>article_look($artid); <br>} <br>} <br>@$admin = $_GET["admin"]; <br>if($admin == "login"){ <br>admin_login(); <br>} <br>if($admin == "check"){ <br>admin_check(); <br>} <br>if($admin == "admin"){ <br>admin_session(); <br>echo "<br />登陆成功!请选择功能菜单进行操作."; <br>} <br>if($admin == "logout"){ <br>session_destroy(); <br>echo "<br />已成功退出!"; <br>echo "<script language=\"JavaScript\">setTimeout(\"window.location.href='?admin=login';\", 2000);</script>"; <br>} <br>if($admin == "class"){ <br>admin_session(); <br>admin_class(); <br>} <br>if($admin == "insert"){ <br>admin_session(); <br>admin_insert(); <br>} <br>if($admin == "list"){ <br>admin_session(); <br>admin_list(); <br>} <br>if($classid == "" && $artid == "" && $admin == ""){ <br>echo "<script language=\"JavaScript\">window.location.href='?classid=1';</script>"; <br>} <br>} <br>?> <br><div style="width:100%;text-align:left;background:#cccccc;line-height:20px;"> <br><br /><br /><br />文章分类-> <?=article_menu();?> <br></div> <br><?=page_load();?> <br><?php <BR>$conn->Close(); <BR>?> <BR></body> <br></html> <br> </td>