Php+mysql's article Management system (i) _php tutorial

Source: Internet
Author: User
###############################################
This article is original, if quoted, please indicate the author's information.
Email:leo_cdp@yeah.net
http://www.cfeng.net/
This code is reproduced arbitrarily, use please keep this statement
###############################################
Last year I wrote a text management always feel a bit uncomfortable plus the application of the host so write a php+mysql of the article for the management of the test period
By the vast number of netizens support is now the code published
Function Description:
Basic operation of the article: Add, modify, lock, unlock, recommend, delete wait
and has a powerful function of the search, comment, recommend to friends and other functions, and security is focused on strengthening, beautiful interface humanized design.
Main file list:
setup.php installation program, can use this system after running!
index.php Display
manager.php Add, manage articles.
Change.php an action on an already existing article.
edit_article.php Article modification
Commend.php recommend articles to friends.
read_article.php article read.
Ping.php published a comment on the article.
search.php article Search
type_manager.php Type Management
login.php administrator Login.
config.php Primary configuration files
func.php function File
Footer.inc,header.inc,nav.inc contains files.
List.txt Type list
And some other peripheral programs
Management System Demo Address:
http://www.cfeng.net/article/
####################### #config. PHP Main configuration file ##########################
$host = "localhost"; #数据库主机
$database _usn= "Cfeng.net"; # #数据库用户
$database _pwd= "Cfeng.net"; # #数据库密码
$database = "Cfeng.net"; # #数据库
$table = "Cfeng.net"; # #要存放文章的表
$ping _tab= "PING_TAB1"; # #存放评论的表
$admin _usn= "Leo"; # #管理员用户名
$admin _pwd= "Leo"; # #管理员密码
$admin _mail= "Leo_cdp@yeah.net"; # #管理员信箱
$pagenum = "20"; # #每页显示文章数
$sess =md5 ($admin _usn. $admin _pwd); # #登陆认证采用MD5生成
?>
#################### #func. php function File ###################################
Require "./inc/config.php";
function Mscon () # #数据库链接
{
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 () # #本系统实行宽进严出所以添加文章部份显得略为简单!
{
Global $database, $table, $title, $cont, $type, $html;
$dat =date (y year m 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) # #添加浏览次数!
{
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) # #添加评论次数!
{
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 installation files ######################
Session_Start ();
Require "./inc/func.php";
Check_login ();
?>
if ($sub)
{
$file _cont= " $file _cont.= "\ $host =\" $host \ "; #your database Server address\n";
$file _cont.= "\ $database _usn=\" $database _usn\ "; \ n";
$file _cont.= "\ $database _pwd=\" $database _pwd\ "; \ n";
$file _cont.= "\ $database =\" $database \ "; \ n";
$file _cont.= "\ $table =\" $table \ "; \ n";
$file _cont.= "\ $ping _tab=\" $ping _tab\ "; \ n";
$file _cont.= "\ $admin _usn=\" $admin _usn\ "; \ n";
$file _cont.= "\ $admin _pwd=\" $admin _pwd\ "; \ n";
$file _cont.= "\ $admin _mail=\" $admin _mail\ "; \ n";
$file _cont.= "\ $pagenum =\" $pagenum \ "; \ n";
$file _cont.= "\ $sess =md5 (\ $admin _usn.\ $admin _pwd); \ n";
$file _cont.= "\ n";
$file _cont.= "?>";
$FP =fopen ("./inc/config.php", "w");
if (fputs ($fp, $file _cont))
echo "Configuration complete positive detection of the correctness of each option
";
else echo "File write error, check permissions for the directory where the files are located
";
Fclose ($FP);
ECHO is detecting data connection ......;
if (@mysql_connect ("$host", "$database _usn", "$database _pwd"))
{
echo "Success!"
" ;
$query = "CREATE TABLE $table (
ID int (4) not NULL auto_increment,
Title varchar (in) not NULL,
Cont text NOT NULL,
Time varchar (not NULL),
Type varchar () 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 "Database $table established successfully
". Mysql_error ();
Else
echo "Database $table build failed
";
$query = "CREATE TABLE $ping _tab (
ID int (4) not NULL auto_increment,
p_id Int (4) DEFAULT ' 0 ' not NULL,
Name varchar (not NULL),
Mail varchar (+) is not NULL,
P_cont Text Not NULL,
Time datetime DEFAULT ' 0000-00-00 00:00:00 ' not NULL,
IP varchar () is not NULL,
PRIMARY KEY (ID),
UNIQUE ID (ID),
KEY id_2 (ID)
)";
if (Mysql_db_query ($database, $query))
{
echo "User Review database $ping _tab Build success
Congratulations, the article Management system Installation Success! Please go this way. Basic Setup!
";
$FP =fopen ("setup.php", "R");
$file _cont=fread ($fp, FileSize ("setup.php"));
$file _cont= " \ n ". $file _cont;
$FP =fopen ("setup.php", "w");
Fputs ($fp, $file _cont);
Fclose ($FP);
}
Else
echo "User Comment database $ping_tab build failed
";
}
Else
echo "Database connection failed!" Please check the correctness of your username and password!
";
Exit ();
}
Require "./inc/header.inc";
?>





http://www.bkjia.com/PHPjc/315301.html www.bkjia.com true http://www.bkjia.com/PHPjc/315301.html techarticle ############################################### This article is original, if there is a reference, please indicate the author information. Email:leo_cdp@yeah.net http://www.cfeng.net/This code arbitrarily reproduced, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.