Home  >  Article  >  Backend Development  >  PHP article management, _PHP tutorial

PHP article management, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:19:58907browse

PHP article management,


Function description:
Basic operations of articles: add, modify, lock, unlock, recommend, delete and wait
It also has powerful functions such as searching, commenting, and recommending to friends. It also focuses on enhancing security and has a beautiful interface with a user-friendly design.
Main file list:
setup.php installation program, you can use this system after running it!
index.php display
manager.php adds and manages articles.
change.php operates on existing articles.
edit_article.php Article modification
commend.php recommends articles to friends.
read_article.php article reading.
ping.php Post comments on articles.
search.php article search
type_manager.php type management
login.php Administrator login.
config.php main configuration file
func.php function file
footer.inc, header.inc, nav.inc include files.
list.txt type list
And some other peripheral programs
Management system demonstration address:
http://www.cfeng.net/article/
#######################config.php Main configuration file#################### ######
$host="localhost"; #Database host
$database_usn="cfeng.net"; ##Database User
$database_pwd="cfeng.net"; ##Database password
$database="cfeng.net"; ##Database
$table="cfeng.net"; ##Table to store articles
$ping_tab="ping_tab1"; ##Table to store comments
$admin_usn="leo"; ##Administrator username
$admin_pwd="leo"; ##Administrator password
$admin_mail="leo_cdp@yeah.net"; ##Administrator's mailbox
$pagenum="20"; ##Display the number of articles per page
$sess=md5($admin_usn.$admin_pwd); ##Login authentication is generated using MD5
?>
#####################func.php function file ##################################
require "./inc/config.php";
function mscon()##Database link
{
global $host,$database_usn,$database_pwd;
@mysql_connect("$host","$database_usn","$database_pwd") or die("Sorry, database connection error! Please come back later, or contact the administrator");
}
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()##This system implements wide entry and strict exit, so adding articles seems a little simple!
{
global $database,$table,$title,$cont,$type,$html;
$dat=date(Y year m month d day);
$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)##Add the number of views!
{
global $database,$table;
$query="update $table set hits=hits+1 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_comm($id)##Add this article as a recommended article
{
global $database,$table;
$query="update $table set comm=1 where id=$id";
$res=mysql_db_query("$database",$query);
}
function un_comm($id)##Clear recommendation!
{
global $database,$table;
$query="update $table set comm='0' where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_lock($id)##Lock article
{
global $database,$table;
$query="update $table set locked='1' where id=$id";
$res=mysql_db_query("$database",$query);
}

function un_lock($id)##Clear the lock!
{
global $database,$table;
$query="update $table set locked=0 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_p_num($id)##Number of comments added!
{
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)##Delete article!
{
global $database,$table;
$query="delete from $table where id='$id'";
$res=mysql_db_query("$database",$query);
}
#######################setup.php installation file##################### #
session_start(); 
require"./inc/func.php"; 
check_login(); 
?> 
if($sub) 

$file_cont=" $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 "文件写入错误,请检测文件所在目录的权限
"; 
fclose($fp); 
echo "正在检测数据连接.........." ; 
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"数据库 $table 建立成功
".mysql_error(); 
else 
echo"数据库 $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"用户评论数据库 $ping_tab 建立成功
恭喜,文章管理系统安装成功!请这边走进行基本设置!
"; 
$fp=fopen("setup.php","r"); 
$file_cont=fread($fp,filesize("setup.php")); 
$file_cont=" ".$file_cont; 
$fp=fopen("setup.php","w"); 
fputs($fp,$file_cont); 
fclose($fp); 

else 
echo"用户评论数据库$ping_tab建立失败
"; 

else 
echo "数据库连接失败!请检测你用户名密码的正确性!
"; 
exit(); 

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

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
蓝狐文章管理安装程序
 
(请正确填写以下内容否则程序将无法使用)
 
数据库服务器:  
 
数据库用户名:  
 
数据库用户密码:  
 
数据库密码确认:  
 
数据库名:  
 
存放文章的表:  
 
存放评论的表:  
 
管理员用户名:  
 
管理员密码:  
 
管理员密码确认:  
 
管理员邮件地址:  
 
每页显示文章数:  
 
 

 
 
 

 
 
 
 


 



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/870652.htmlTechArticlePHP article management, function description: Basic operations of articles: add, modify, lock, unlock, recommend, delete and wait And it has powerful functions such as search, comment, recommend to friends, etc...
Statement:
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