Copy CodeThe code is as follows:
Session_Start ();
//==========================
Author: Biyuan
Time: 2006.07
Contact: QQ6010707
//==========================
?>
<title>Bi-yuan Network php+access article management system</title>
//==================================
Connecting to a database
//==================================
@ $conn = new COM ("ADODB. Connection ");
$conn->open ("Driver={microsoft Access DRIVER (*.mdb)}; Dbq= ". Realpath ("Article.mdb"));
//==================================
Article Navigation
//==================================
function Article_menu () {
Global $conn;
@ $sql = "SELECT * from List";
@ $rs = $conn->execute ($sql);
while (! $rs->eof) {
echo "| Fields[2]->value. "\" > ". $rs->fields[1]->value. " ";
$rs->movenext ();
}
echo "| Background management \ r \ n ";
$rs->close ();
if (@$_session["articleadmin"] = = "By_php_article") {
echo "
Management Options | Classification Management | Published articles | List of articles | Exit login ";
}
}
//==================================
Article List: article_list (article category 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 "
\ r \ n ". "
\ r \ n ". "
Article title |
Article author |
Publication time |
Browse Times | \ r \ n ". "
\ r \ n "; while (! $rs->eof) {echo]
\ r \ n ". "
Fields[0]->value. "\" > ". $rs->fields[1]->value. " |
" . $rs->fields[2]->value. " |
" . Date ("Y-m-d h:i:s", $rs->fields[3]->value). " |
" . $rs->fields[4]->value. " | \ r \ n ". "
\ r \ n "; $rs->movenext (); } echo "
\ r \ n ";
}
else {
echo "
The category does not exist or has no articles for the time being! ";
}
$rs->close ();
}
//==================================
Article details: article_look (article 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 "
\ r \ n ". "
\ r \ n ". "
" . $rs->fields[1]->value. " | \ r \ n ". "
\ r \ n ". "
\ r \ n ". "
Article author: ". $rs->fields[2]->value. " | Publication time: ". Date ("Y-m-d h:i:s", $rs->fields[3]->value). " | Browse Times: ". $rs->fields[4]->value. " | \ r \ n ". "
\ r \ n ". "
\ r \ n ". "
" . $body. " | \ r \ n ". "
\ r \ n ". "
\ r \ n ". "
"Back" "Print" "Close" | \ r \ n ". "
\ r \ n ". "
\ r \ n "
. "\ r \ n";
}
else {
echo "
The article does not exist or has been deleted by the administrator! ";
}
$rs->close ();
}
//==================================
Backstage: Classification Management
//==================================
function Admin_class () {
Global $conn;
@ $sql = "SELECT * from List";
@ $rs = $conn->execute ($sql);
echo "\ r \ n";
Add a Category
if (@$_get["class"] = = "Add") {
if (@$_post["class_name"] = = "" | | @$_post["class_cid"] = = "") {
echo "
Complete incomplete! ";
echo "";
Exit ();
}
else {
@ $sql = "Insert into List (by_list,by_cid) Values ('". $_post["Class_name"]. "' , '" . $_post["Class_cid"]. "')";
$conn->execute ($sql);
echo "
Add success! ";
echo "";
}
}
Modify a Category
if (@$_get["class"] = = "edit") {
if (@$_post["Class_". $_get["id"]] = = "" | | @$_post["Class_cid_". $_get["id"]] = = "") {
echo "
Complete incomplete! ";
echo "";
Exit ();
}
else {
@ $sql = "Update List Set by_list = '". $_post["Class_". $_get["id"]. "', By_cid = '". $_post["Class_cid_". $_get["id"]. "' Where id = '. $_get["id"];
$conn->execute ($sql);
echo "
Modification succeeded! ";
echo "";
}
}
Delete a category
if (@$_get["class"] = = "Del") {
@ $sql = "Delete from List Where id =". $_get["id"];
$conn->execute ($sql);
echo "
Delete succeeded! ";
echo "";
}
}
//==================================
Backstage: Post article (HTML supported)
//==================================
function Admin_insert () {
Global $conn;
if (@$_get["innert"] = = "Add") {
if (@$_post["title"] = = "" | | @$_post["name"] = = "" | | @$_post["class"] = = "" | | @$_post["body"] = = "") {
echo "
Complete incomplete! ";
echo "";
Exit ();
}
else {
@ $body = $_post["Body"];
$body = Str_replace ("'", "'", $body);
$body = Str_replace ("\ r \ n", "
", $body);
@ $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"]. "')";
$conn->execute ($sql);
echo "
Add success! ";
echo "";
}
}
else {
echo "\ r \ n"
. "\ r \ n"
. "\ r \ n";
}
}
//==================================
Backstage: List of articles
//==================================
function Admin_list () {
Global $conn;
@ $sql = "Select Id,by_title,by_name,by_time,by_count,by_class from article Order by id DESC";
@ $rs = $conn->execute ($sql);
if (! $rs->eof) {
echo "
\ r \ n ". "
\ r \ n".
article title |
article category |
article author |
publish time |
views |
action | \ r \ n. "
\ r \ n"; while (! $rs->eof) {@ $sql = ' SELECT * from List Where by_cid = '. $rs->fields[5]->value; @ $crs = $conn->execute ($sql); @ $cid = $crs->fields[1]->value; echo "
\ r \ n". "
fields[0]->value." \ ">". $rs->fields[1]->value. " |
". $cid. " |
". $rs->fields[2]->value. " |
". $rs->fields[3]->value. " |
". $rs->fields[4]->value. " |
fields[0]->value." \ "> Edit | Fields[0]->value. "\" > Delete | \ r \ n. "
\ r \ n"; $crs->close (); $rs->movenext (); } echo "
\ r \ n ";
}
else {
echo "
The category does not exist or has no articles for the time being! ";
}
$rs->close ();
Modify article
if (@$_get["list"] = = "edit") {
if (@$_get["edit"] = = "true") {
if (@$_post["title"] = = "" | | @$_post["name"] = = "" | | @$_post["class"] = = "" | | @$_post["body"] = = "") {
echo "
Complete incomplete! ";
echo "";
Exit ();
}
else {
@ $body = $_post["Body"];
$body = Str_replace ("'", "'", $body);
$body = Str_replace ("\ r \ n", "
", $body);
@ $sql = "Update article Set by_title = '". $_post["title"]. "', By_name = '". $_post["Name"]. "', By_count =". $_post["Count"]. ", By_body = '". $body. "', By_class = '". $_post["Class"]. "' Where id = '. $_get["id"];
$conn->execute ($sql);
echo "
Modification succeeded! ";
echo "";
}
}
else {
@ $sql = "SELECT * from article Where id =". $_get["id"];
@ $rs = $conn->execute ($sql);
echo "\ r \ n"
. "\ r \ n"
. "\ r \ n";
}
}
Delete Article
if (@$_get["list"] = = "Del") {
@ $sql = "Delete from article Where id =". $_get["id"];
$conn->execute ($sql);
echo "
Delete succeeded! ";
echo "";
}
}
//==================================
Permission validation
//==================================
function Admin_session () {
if (@$_session["Articleadmin"]! = "By_php_article") {
echo "
Please login first! ";
echo "";
Exit ();
}
}
//==================================
Background login
//==================================
function Admin_login () {
if (@$_session["articleadmin"] = = "By_php_article") {
echo "";
}
else{
echo "
\ r \ n ". "
\ r \ n ". "
Admin Login | \ r \ n ". "
\ r \ n ". "
\ r \ n ". "\ r \ n". "
\ r \ n ". "
\ r \ n ";
}
}
//==================================
Login Verification
//==================================
function Admin_check () {
if (Trim ($_post["AdminPass"])! = "Admin") {
echo "
Wrong password! ";
echo "";
}
else {
echo "
Landed successfully! ";
@$_session["articleadmin"] = "by_php_article";
echo "";
}
}
//==================================
URL parameter list
//==================================
function Page_Load () {
@ $classid = $_get["ClassID"];
if ($classid! = "") {
if (!is_numeric ($classid)) {
echo "
Wrong argument! ";
return false;
}
else {
Article_list ($CLASSID);
}
}
@ $artid = $_get["ArtID"];
if ($artid! = "") {
if (!is_numeric ($artid)) {
echo "
Wrong argument! ";
return false;
}
else {
Article_look ($artid);
}
}
@ $admin = $_get["admin"];
if ($admin = = "Login") {
Admin_login ();
}
if ($admin = = "Check") {
Admin_check ();
}
if ($admin = = "Admin") {
Admin_session ();
echo "
Login Successful! Please select the function menu to operate. ";
}
if ($admin = = "Logout") {
Session_destroy ();
echo "
Successfully exited! ";
echo "";
}
if ($admin = = "Class") {
Admin_session ();
Admin_class ();
}
if ($admin = = "Insert") {
Admin_session ();
Admin_insert ();
}
if ($admin = = "List") {
Admin_session ();
Admin_list ();
}
if ($classid = = "" && $artid = = "" && $admin = = "") {
echo "";
}
}
?>
Article category
$conn->close ();
?>
http://www.bkjia.com/PHPjc/322147.html www.bkjia.com true http://www.bkjia.com/PHPjc/322147.html techarticle Copy the code as follows: PHP session_start ();//==========================//Author: Biyuan//Time: 2006.07//Contact: QQ6010707//========== ================ ? HTML head tit ...