Php+mysql's article Management system (i)

Source: Internet
Author: User
Tags add exit comments empty header mysql net unique id
MySQL This article is original, if there are references, please indicate the author 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, I always feel a little uncomfortable plus the application of the host so write a php+mysql to the article Management test period
By the broad masses of netizens support is now the code published
Function Description:
The basic operation of the article: Add, modify, lock, unlock, recommend, delete wait
and has a powerful function of search, comments, recommended to friends and other functions, and security focused on strengthening, beautiful interface humanized design.
Main file list:
setup.php installation program, you can use the system after running!
index.php Display
manager.php Add, manage articles.
Change.php an action on an existing article.
edit_article.php Article modification
Commend.php recommend articles to friends.
read_article.php article reading.
Ping.php published an article comment.
search.php article Search
type_manager.php Type Management
login.php Admin Login.
config.php Main configuration file
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 your 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-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) # #添加浏览次数!
{
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= ". #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 "Configuration complete positive detection of the correctness of each option <BR>";
else echo "File write error, please detect the file directory of permissions <br>";
Fclose ($FP);
echo "is detecting data connections ....."
if (@mysql_connect ("$host", "$database _usn", "$database _pwd"))
{
echo "Success!<br>";
$query = "CREATE TABLE $table (
ID int (4) not NULL auto_increment,
Title varchar not NULL,
Cont text NOT NULL,
Time varchar () is 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 Build Success <BR>". Mysql_error ();
Else
echo "Database $table build Failure <BR>";
$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 not NULL,
P_cont Text Not NULL,
Time datetime DEFAULT ' 0000-00-00 00:00:00 ' is not NULL,
IP varchar not NULL,
PRIMARY KEY (ID),
UNIQUE ID (ID),
KEY id_2 (ID)
)";
if (Mysql_db_query ($database, $query))
{
echo "User Review database $ping _tab Success <BR> Congratulations, Article Management system Installation Success! Please <a href=login.php> this way </a> make Basic settings!<br>";
$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 "User Comment database $ping_tab build failure <BR>";
}
Else
echo Database connection failed! Please check the correctness of your username password!<br> ";
Exit ();
}
Require "./inc/header.inc";
?>
<script language= "JavaScript" >
function Db_pwd ()
{
var theresult = true;
var elem4 = null;

if (Document.forms[0].elements[2].value = = "" | | Document.forms[0].elements[2].value!=document.forms[0].elements[3].value)
{
Alert ("The database password you entered two times is inconsistent or empty!");
Document.forms[0].elements[2].value= "";
Document.forms[0].elements[3].value= "";
Theresult = false;

}
return theresult;
}
function Admin_pwd ()
{
var theresult = true;
var elem4 = null;
if (Document.forms[0].elements[8].value = = "" | | Document.forms[0].elements[8].value!=document.forms[0].elements[9].value)
{
Alert ("The administrator password you entered two times is inconsistent, or empty!");
Document.forms[0].elements[8].value= "";
Document.forms[0].elements[9].value= "";
Theresult = false;

}
return theresult;
}
function Go ()
{
var theresult=true;
Theresult =db_pwd () &&admin_pwd ();
return theresult;
}
</script>
<body bgcolor= "#FFFFFF" >
? Require "./inc/nav.inc";? >
<form name= "Form1" method= "Post" action= " echo $PHP _self?> "onsubmit=" Return to Go ();>
<table border= "0" cellspacing= "0" cellpadding= "0" align= "center" style=text-align:left;>
<tr>
&LT;TD colspan= "3" >
<div align= "center" > Blue Fox article admin installer <br>
(please complete the following correctly otherwise the program will not be available) </div>
</td>
</tr>
<tr>
<td> Database Server:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "host" value= "localhost" class= "border" size= ">"
</td>
</tr>
<tr>
<td> database user name: </td>
&LT;TD colspan= "2" >
<input type= "text" name= "Database_usn" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Database user Password:</td>
&LT;TD colspan= "2" >
<input type= "Password" name= "database_pwd" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Database Password Confirmation:</td>
&LT;TD colspan= "2" >
<input type= "Password" name= "database_pwd2" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Database name:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "database" class= "border" size= ">"
</td>
</tr>
<tr>
<td> table for storing articles:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "table" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> store comments on the table:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "Ping_tab" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Administrator user name:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "Admin_usn" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Admin Password:</td>
&LT;TD colspan= "2" >
<input type= "Password" name= "admin_pwd" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Admin Password Confirmation:</td>
&LT;TD colspan= "2" >
<input type= "Password" name= "admin_pwd2" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> Administrator Email Address:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "Admin_mail" class= "Border" size= ">"
</td>
</tr>
<tr>
<td> show the number of articles per page:</td>
&LT;TD colspan= "2" >
<input type= "text" name= "pagenum" class= "Border" size= ">"
</td>
</tr>
<tr>
<td>
<div align= "center" ><br>
</div>
</td>
<td>
<div align= "left" ><br>
<input type= "Submit" Name= "sub" value= "Submit" class= "Border" >

<input type= "reset" name= "reset" value= "reset" class= "Border" >
</div>
</td>
</tr>
</table>
<p> </p>
</form>
<?require "./inc/footer.inc";? >

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.