亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 php手冊 PHP+MYSQL的文章管理系統(tǒng)(一)

PHP+MYSQL的文章管理系統(tǒng)(一)

Jun 21, 2016 am 09:15 AM
database gt lt query quot

mysql

此篇文章屬原創(chuàng),如有引用,請標明作者信息。
Email: leo_cdp@yeah.net
http://www.cfeng.net/
本文代碼任意轉(zhuǎn)載,使用請保留此聲明
###############################################
去年寫了個文本管理總覺得有些不爽再加上申請了主機所以寫個PHP+MYSQL的對文章進行管理測試期間
受到廣大網(wǎng)友的支持現(xiàn)將代碼公布
功能說明:
文章的基本操作:添加,修改,鎖定,解鎖,推薦,刪除等待
并有強大功能的搜索,評論,推薦給朋友等功能,并對安全性進行著重加強,漂亮的界面人性化的設(shè)計。
主要文件列表:
setup.php 安裝程序,運行后即可使用本系統(tǒng)!
index.php 顯示
manager.php 添加,管理文章。
change.php 對已存在文章的操作。
edit_article.php 文章修改
commend.php 推薦文章給朋友。
read_article.php 文章閱讀。
ping.php 發(fā)表文章評論。
search.php 文章搜索
type_manager.php 類型管理
login.php 管理員登陸。
config.php 主要配置文件
func.php 函數(shù)文件
footer.inc,header.inc,nav.inc包含文件。
list.txt 類型列表
以及其它一些周邊程序
管理系統(tǒng)演示地址:
http://www.cfeng.net/article/
########################config.php 主要配置文件##########################

$host="localhost"; #數(shù)據(jù)庫主機
$database_usn="cfeng.net"; ##數(shù)據(jù)庫用戶
$database_pwd="cfeng.net"; ##數(shù)據(jù)庫密碼
$database="cfeng.net"; ##數(shù)據(jù)庫
$table="cfeng.net"; ##要存放文章的表
$ping_tab="ping_tab1"; ##存放評論的表
$admin_usn="leo"; ##管理員用戶名
$admin_pwd="leo"; ##管理員密碼
$admin_mail="leo_cdp@yeah.net"; ##管理員信箱
$pagenum="20"; ##每頁顯示文章數(shù)
$sess=md5($admin_usn.$admin_pwd); ##登陸認證采用MD5生成
?>
#####################func.php 函數(shù)文件 ###################################

require "./inc/config.php";
function mscon()##數(shù)據(jù)庫鏈接
{
global $host,$database_usn,$database_pwd;
@mysql_connect("$host","$database_usn","$database_pwd") or die("對不起,數(shù)據(jù)庫連接錯誤!請稍候再來,或與管理員聯(lián)系");
}
function check_login()
{ global $sess;
if(!session_is_registered("sess_0230a09a07cab1df8112d00b1f9a9719"))
{
if($sess_0230a09a07cab1df8112d00b1f9a9719!=$sess)
{
redir("login.php");
exit;
}
}
}
function redir($addr)
{
header("location:$addr");
}
function add_article()##本系統(tǒng)實行寬進嚴出所以添加文章部份顯得略為簡單!
{
global $database,$table,$title,$cont,$type,$html;
$dat=date(Y年m月d日);
$title=htmlspecialchars($title);
$query="insert into $table(title,cont,type,time,html) values('$title','$cont','$type','$dat','$html')";
$res=mysql_db_query("$database",$query);
if(!$res)
echo mysql_error();
}
function add_hits($id)##添加瀏覽次數(shù)!
{
global $database,$table;
$query="update $table set hits=hits+1 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_comm($id)##把本文加為推薦文章
{
global $database,$table;
$query="update $table set comm=1 where id=$id";
$res=mysql_db_query("$database",$query);
}
function un_comm($id)##清除推薦!
{
global $database,$table;
$query="update $table set comm='0' where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_lock($id)##鎖定文章
{
global $database,$table;
$query="update $table set locked='1' where id=$id";
$res=mysql_db_query("$database",$query);
}

function un_lock($id)##清除鎖定!
{
global $database,$table;
$query="update $table set locked=0 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_p_num($id)##添加評論次數(shù)!
{
global $database,$table;
$query="update $table set p_num=p_num+1 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_del($id)##刪除文章!
{
global $database,$table;
$query="delete from $table where id='$id'";
$res=mysql_db_query("$database",$query);
}
########################setup.php 安裝文件######################

session_start();
require"./inc/func.php";
check_login();
?>

if($sub)
{
$file_cont=" #don't edit thisfile use the setup.php ";
$file_cont.="$host="$host";#your database server address ";
$file_cont.="$database_usn="$database_usn"; ";
$file_cont.="$database_pwd="$database_pwd"; ";
$file_cont.="$database="$database"; ";
$file_cont.="$table="$table"; ";
$file_cont.="$ping_tab="$ping_tab"; ";
$file_cont.="$admin_usn="$admin_usn"; ";
$file_cont.="$admin_pwd="$admin_pwd"; ";
$file_cont.="$admin_mail="$admin_mail"; ";
$file_cont.="$pagenum="$pagenum"; ";
$file_cont.="$sess=md5($admin_usn.$admin_pwd); ";
$file_cont.=" ";
$file_cont.="?>";
$fp=fopen("./inc/config.php","w");
if(fputs($fp,$file_cont))
echo "配置完成正檢測各選項的正確性
";
else echo "文件寫入錯誤,請檢測文件所在目錄的權(quán)限
";
fclose($fp);
echo "正在檢測數(shù)據(jù)連接.........." ;
if(@mysql_connect("$host","$database_usn","$database_pwd"))
{
echo "成功!
" ;
$query="CREATE TABLE $table(
id int(4) NOT NULL auto_increment,
title varchar(55) NOT NULL,
cont text NOT NULL,
time varchar(14) NOT NULL,
type varchar(20) NOT NULL,
comm int(1) DEFAULT '0' NOT NULL,
p_num int(2) DEFAULT '0' NOT NULL,
locked int(1) DEFAULT '0' NOT NULL,
hits int(4) DEFAULT '0' NOT NULL,
html int(1) DEFAULT '1' NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id),
KEY id_2 (id)
) " ;
if(mysql_db_query($database,$query))
echo"數(shù)據(jù)庫 $table 建立成功
".mysql_error();
else
echo"數(shù)據(jù)庫 $table 建立失敗
";
$query="CREATE TABLE $ping_tab (
id int(4) NOT NULL auto_increment,
p_id int(4) DEFAULT '0' NOT NULL,
name varchar(50) NOT NULL,
mail varchar(200) NOT NULL,
p_cont text NOT NULL,
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
ip varchar(15) NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id),
KEY id_2 (id)
)";
if(mysql_db_query($database,$query))
{
echo"用戶評論數(shù)據(jù)庫 $ping_tab 建立成功
恭喜,文章管理系統(tǒng)安裝成功!請這邊走進行基本設(shè)置!
";
$fp=fopen("setup.php","r");
$file_cont=fread($fp,filesize("setup.php"));
$file_cont=" session_start(); require"./inc/func.php"; check_login(); ?> ".$file_cont;
$fp=fopen("setup.php","w");
fputs($fp,$file_cont);
fclose($fp);
}
else
echo"用戶評論數(shù)據(jù)庫$ping_tab建立失敗
";
}
else
echo "數(shù)據(jù)庫連接失敗!請檢測你用戶名密碼的正確性!
";
exit();
}
require "./inc/header.inc";
?>



require "./inc/nav.inc";?>


























































藍狐文章管理安裝程序

(請正確填寫以下內(nèi)容否則程序?qū)o法使用)

數(shù)據(jù)庫服務(wù)器:

數(shù)據(jù)庫用戶名:

數(shù)據(jù)庫用戶密碼:

數(shù)據(jù)庫密碼確認:

數(shù)據(jù)庫名:

存放文章的表:

存放評論的表:

管理員用戶名:

管理員密碼:

管理員密碼確認:

管理員郵件地址:

每頁顯示文章數(shù):









??



?





Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
How to solve discuz database error How to solve discuz database error Nov 20, 2023 am 10:10 AM

The solutions to discuz database error are: 1. Check the database configuration; 2. Make sure the database server is running; 3. Check the database table status; 4. Back up the data; 5. Clear the cache; 6. Reinstall Discuz; 7. Check the server resources ; 8. Contact Discuz official support. Solving Discuz database errors requires starting from multiple aspects, gradually identifying the cause of the problem, and taking corresponding measures to repair it.

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Jun 15, 2024 pm 09:49 PM

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Can't drop database 'database_name'; database doesn't exist - How to solve MySQL error: Can't drop database, database doesn't exist Can't drop database 'database_name'; database doesn't exist - How to solve MySQL error: Can't drop database, database doesn't exist Oct 05, 2023 am 11:46 AM

How to solve MySQL error: Unable to delete database, database does not exist Overview: MySQL is a commonly used relational database management system. When using MySQL, we often need to manage the database, including creating databases, deleting databases and other operations. However, when deleting a database, sometimes you will encounter the error message "Can'tdropdatabase'database_name';databasedoesn'texist", that is, you cannot delete it.

How to reorder multiple columns in Power Query via drag and drop How to reorder multiple columns in Power Query via drag and drop Mar 14, 2024 am 10:55 AM

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

React Query database plug-in: how to import and export data React Query database plug-in: how to import and export data Sep 26, 2023 pm 05:37 PM

ReactQuery database plug-in: Methods to implement data import and export, specific code examples are required. With the widespread application of ReactQuery in front-end development, more and more developers are beginning to use it to manage data. In actual development, we often need to export data to local files or import data from local files into the database. In order to implement these functions more conveniently, you can use the ReactQuery database plug-in. The ReactQuery database plugin provides a series of methods

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

See all articles