最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP access简单实用的文章管理程序代码
时间:2022-11-14 23:01:07 编辑:袖梨 来源:一聚教程网
session_start();
//==========================
//作者:biyuan
//时间:2006.07
//联系:qq6010707
//==========================
?>
//==================================
//连接数据库教程
//==================================
@$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 "| fields[2]->value . "">" . $rs->fields[1]->value . " ";
$rs->movenext();
}
echo "| 后台管理 ";
$rs->close();
if(@$_session["articleadmin"] == "by_php_article"){
echo "
管理选项-> | 分类管理 | 发表文章 | 文章列表 | 退出登陆";
}
}
//==================================
//文章列表: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 "
文章标题 | 文章作者 | 发表时间 | 浏览次数 | "
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 . " | "
}
else {
echo "
该分类不存在或暂时没有任何文章!";
}
$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 "
" . $rs->fields[1]->value . " | "
文章作者:" . $rs->fields[2]->value . " | 发表时间:" . date("y-m-d h:i:s",$rs->fields[3]->value) . " | 浏览次数:" . $rs->fields[4]->value . " | "
" . $body . " | "
【 javascript教程:history.back();">返 回 】 【 javascript教程:print();">打 印 】 【 关 闭 】 | "
. " ";
}
else {
echo "
该文章不存在或已被管理员删除!";
}
$rs->close();
}
//==================================
//后台:分类管理
//==================================
function admin_class(){
global $conn;
@$sql = "select * from list";
@$rs = $conn->execute($sql);
echo " ";
//增加一个类别
if(@$_get["class"] == "add"){
if(@$_post["class_name"] == "" || @$_post["class_cid"] == ""){
echo "
填写不完整!";
echo "";
exit();
}
else {
@$sql = "insert into list(by_list,by_cid) values('" . $_post["class_name"] . "' , '" . $_post["class_cid"] . "')";
$conn->execute($sql);
echo "
添加成功!";
echo "";
}
}
//修改一个类别
if(@$_get["class"] == "edit"){
if(@$_post["class_" . $_get["id"]] == "" || @$_post["class_cid_" . $_get["id"]] == ""){
echo "
填写不完整www.111com.net!";
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 "
修改成功!";
echo "";
}
}
//删除一个类别
if(@$_get["class"] == "del"){
@$sql = "delete from list where id = " . $_get["id"];
$conn->execute($sql);
echo "
删除成功!";
echo "";
}
}
//==================================
//后台:发表文章(支持html)
//==================================
function admin_insert(){
global $conn;
if(@$_get["innert"] == "add"){
if(@$_post["title"] == "" || @$_post["name"] == "" || @$_post["class"] == "" || @$_post["body"] == ""){
echo "
填写不完整!";
echo "";
exit();
}
else {
@$body = $_post["body"];
$body = str_replace("'", "''", $body);
$body = str_replace(" ", "
", $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 "
添加成功!";
echo "";
}
}
else {
echo "
"
. " "
. "
"; . " "
. "
}
}
//==================================
//后台:文章列表
//==================================
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 "
文章标题 | 文章分类 | 文章作者 | 发表时间 | 浏览次数 | 操作 | "
fields[0]->value . "">" . $rs->fields[1]->value . " | " . $cid . " | " . $rs->fields[2]->value . " | " . $rs->fields[3]->value . " | " . $rs->fields[4]->value . " | fields[0]->value . "">编辑 | fields[0]->value . "">删除 | "
}
else {
echo "
该分类不存在或暂时没有任何文章!";
}
$rs->close();
//修改文章
if(@$_get["list"] == "edit"){
if(@$_get["edit"] == "true"){
if(@$_post["title"] == "" || @$_post["name"] == "" || @$_post["class"] == "" || @$_post["body"] == ""){
echo "
填写不完整!";
echo "";
exit();
}
else {
@$body = $_post["body"];
$body = str_replace("'", "''", $body);
$body = str_replace(" ", "
", $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 "
修改成功!";
echo "";
}
}
else {
@$sql = "select * from article where id = " . $_get["id"];
@$rs = $conn->execute($sql);
echo "
"
. " "
. "
"; . " "
. "
}
}
//删除文章
if(@$_get["list"] == "del"){
@$sql = "delete from article where id = " . $_get["id"];
$conn->execute($sql);
echo "
删除成功!";
echo "";
}
}
//==================================
//权限验证
//==================================
function admin_session(){
if(@$_session["articleadmin"] != "by_php_article"){
echo "
请先登陆!";
echo "";
exit();
}
}
//==================================
//后台登陆
//==================================
function admin_login(){
if(@$_session["articleadmin"] == "by_php_article"){
echo "";
}
else{
echo "
管理员登陆 | ">www.111com.net "
}
}
//==================================
//登陆验证
//==================================
function admin_check(){
if(trim($_post["adminpass"]) != "adminwww.111com.net"){
echo "
错误的密码!";
echo "";
}
else {
echo "
登陆成功!";
@$_session["articleadmin"] = "by_php_article";
echo "";
}
}
//==================================
//url参数列表
//==================================
function page_load(){
@$classid = $_get["classid"];
if($classid != ""){
if(!is_numeric($classid)){
echo "
错误的参数!";
return false;
}
else {
article_list($classid);
}
}
@$artid = $_get["artid"];
if($artid != ""){
if(!is_numeric($artid)){
echo "
错误的参数!";
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 "
登陆成功!请选择功能菜单进行操作.";
}
if($admin == "logout"){
session_destroy();
echo "
已成功退出!";
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_menu();?>
=page_load();?>
$conn->close();
?>
相关文章
- 《无限暖暖》织衣蛛获得方法 12-26
- 《无限暖暖》美食家蜜蜂获得方法 12-26
- 《无限暖暖》泳镜蝽获得方法 12-26
- 《无限暖暖》芭蕾豆娘获得方法 12-26
- 《无限暖暖》刺绣蛾获得方法 12-26
- 《无限暖暖》尖帽仙获得方法 12-26