###############################################
This article is original. If there are any citations, please indicate the author's information.
Email: leo_cdp@
/
The code of this article is reprinted at will. Please keep this statement when using it.
###############################################
Last year I wrote a text management text and always felt a little unhappy. I applied for a host so I wrote a PHP+MYSQL to manage the article during the period of testing.
The code is now announced with support from netizens
Function description:
Basic operations of the article: add, modify, lock, unlock, recommend, delete and wait
It also has powerful functions such as search, comments, recommendations to friends, etc., and emphasizes security, and has a beautiful interface with a humanized design.
Main file list:
Install the program and you can use this system after running!
show
Add, manage articles.
Operations on existing articles.
edit_article.php article modification
Recommend articles to friends.
read_article.php article reading.
Post an article and comment.
Article Search
type_manager.php Type Management
Administrator login.
Main configuration files
Function File
,,Includes files.
Type list
and other peripheral programs
Management system demonstration address:
/article/
#############################################################################
<?
$host="localhost"; �
$database_usn=""; #Database User
$database_pwd=""; ##Database Password
$database=""; #Database
$table=""; �
$ping_tab="ping_tab1";
$admin_usn="leo";
$admin_pwd="leo"; �
$admin_mail="leo_cdp@"; ##Admin Mailbox
$pagenum="20";
$sess=md5($admin_usn.$admin_pwd); ##Log in authentication is generated using MD5
?>
########################## Function File #####################################################################################
<?
require "./inc/";
function mscon()##Database link
{
global $host,$database_usn,$database_pwd;
@mysql_connect("$host","$database_usn","$database_pwd") or die("Sorry, the database connection is incorrect! Please come back later, or contact the administrator");
}
function check_login()
{ global $sess;
if(!session_is_registered("sess_0230a09a07cab1df8112d00b1f9a9719"))
{
if($sess_0230a09a07cab1df8112d00b1f9a9719!=$sess)
{
redir("");
exit;
}
}
}
function redir($addr)
{
header("location:$addr");
}
function add_article()##This system implements slim 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 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 lock!
{
global $database,$table;
$query="update $table set locked=0 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_p_num($id)##Num 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);
}
##############################################################################
<?
session_start();
require"./inc/";
check_login();
?>
<?
if($sub)
{
$file_cont="<?\n #don't edit thisfile use the \n";
$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/","w");
if(fputs($fp,$file_cont))
echo "Configuration is being checked for the correctness of each option<BR>";
else echo "File writing error, please check the permissions in the directory where the file is located<br>";
fclose($fp);
echo "Detection of data connection......";
if(@mysql_connect("$host","$database_usn","$database_pwd"))
{
echo "Success!<BR>" ;
$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"Database $table was successfully established<BR>".mysql_error();
else
echo"Database $table failed to establish <BR>";
$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"User Comment Database $ping_tab was successfully established <BR>Congratulations, the article management system was successfully installed! Please <a href=>go here</a> for basic settings!<BR>";
$fp=fopen("","r");
$file_cont=fread($fp,filesize(""));
$file_cont="<? \nsession_start();\nrequire\"./inc/\";\n check_login();\n?>\n".$file_cont;
$fp=fopen("","w");
fputs($fp,$file_cont);
fclose($fp);
}
else
echo"User comment database $ping_tab failed to establish <BR>";
}
else
echo "The database connection failed! Please check the correctness of your username and password!<BR>";
exit();
}
require "./inc/";
?>
<script language="javascript">
function db_pwd()
{
var theResult = true;
var elem4 = null;
if ([0].elements[2].value == "" || [0].elements[2].value!=[0].elements[3].value)
{
alert("The database password you entered twice is inconsistent, or is empty!");
[0].elements[2].value="";
[0].elements[3].value="";
theResult = false;
}
return theResult;
}
function admin_pwd()
{
var theResult = true;
var elem4 = null;
if ([0].elements[8].value == "" || [0].elements[8].value!=[0].elements[9].value)
{
alert("The administrator password you entered twice is inconsistent, or is empty!");
[0].elements[8].value="";
[0].elements[9].value="";
theResult = false;
}
return theResult;
}
function go()
{
var theResult=true;
theResult =db_pwd()&&admin_pwd();
return theResult;
}
</script>
</head>
<body bgcolor="#FFFFFF">
<? require "./inc/";?>
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>" onsubmit="return go()";>
<table border="0" cellspacing="0" cellpadding="0" align="center" style=text-align:left;>
<tr>
<td colspan="3">
<div align="center">Blue Fox Article Management Installer<br>
(Please fill in the following content correctly, otherwise the program will not be available)</div>
</td>
</tr>
<tr>
<td>Database Server:</td>
<td colspan="2">
<input type="text" name="host" value="localhost" class="border" size="30">
</td>
</tr>
<tr>
<td>Database username: </td>
<td colspan="2">
<input type="text" name="database_usn" class="border" size="30">
</td>
</tr>
<tr>
<td>Database user password:</td>
<td colspan="2">
<input type="password" name="database_pwd" class="border" size="30">
</td>
</tr>
<tr>
<td>Database password confirmation:</td>
<td colspan="2">
<input type="password" name="database_pwd2" class="border" size="30">
</td>
</tr>
<tr>
<td>Database name:</td>
<td colspan="2">
<input type="text" name="database" class="border" size="30">
</td>
</tr>
<tr>
<td>Table of storing articles:</td>
<td colspan="2">
<input type="text" name="table" class="border" size="30">
</td>
</tr>
<tr>
<td>Storing comments table:</td>
<td colspan="2">
<input type="text" name="ping_tab" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin username:</td>
<td colspan="2">
<input type="text" name="admin_usn" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin Password:</td>
<td colspan="2">
<input type="password" name="admin_pwd" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin password confirmation:</td>
<td colspan="2">
<input type="password" name="admin_pwd2" class="border" size="30">
</td>
</tr>
<tr>
<td>Administrator email address:</td>
<td colspan="2">
<input type="text" name="admin_mail" class="border" size="30">
</td>
</tr>
<tr>
<td>Number of articles displayed per page:</td>
<td colspan="2">
<input type="text" name="pagenum" class="border" size="30">
</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/";?>
This article is original. If there are any citations, please indicate the author's information.
Email: leo_cdp@
/
The code of this article is reprinted at will. Please keep this statement when using it.
###############################################
Last year I wrote a text management text and always felt a little unhappy. I applied for a host so I wrote a PHP+MYSQL to manage the article during the period of testing.
The code is now announced with support from netizens
Function description:
Basic operations of the article: add, modify, lock, unlock, recommend, delete and wait
It also has powerful functions such as search, comments, recommendations to friends, etc., and emphasizes security, and has a beautiful interface with a humanized design.
Main file list:
Install the program and you can use this system after running!
show
Add, manage articles.
Operations on existing articles.
edit_article.php article modification
Recommend articles to friends.
read_article.php article reading.
Post an article and comment.
Article Search
type_manager.php Type Management
Administrator login.
Main configuration files
Function File
,,Includes files.
Type list
and other peripheral programs
Management system demonstration address:
/article/
#############################################################################
<?
$host="localhost"; �
$database_usn=""; #Database User
$database_pwd=""; ##Database Password
$database=""; #Database
$table=""; �
$ping_tab="ping_tab1";
$admin_usn="leo";
$admin_pwd="leo"; �
$admin_mail="leo_cdp@"; ##Admin Mailbox
$pagenum="20";
$sess=md5($admin_usn.$admin_pwd); ##Log in authentication is generated using MD5
?>
########################## Function File #####################################################################################
<?
require "./inc/";
function mscon()##Database link
{
global $host,$database_usn,$database_pwd;
@mysql_connect("$host","$database_usn","$database_pwd") or die("Sorry, the database connection is incorrect! Please come back later, or contact the administrator");
}
function check_login()
{ global $sess;
if(!session_is_registered("sess_0230a09a07cab1df8112d00b1f9a9719"))
{
if($sess_0230a09a07cab1df8112d00b1f9a9719!=$sess)
{
redir("");
exit;
}
}
}
function redir($addr)
{
header("location:$addr");
}
function add_article()##This system implements slim 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 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 lock!
{
global $database,$table;
$query="update $table set locked=0 where id=$id";
$res=mysql_db_query("$database",$query);
}
function add_p_num($id)##Num 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);
}
##############################################################################
<?
session_start();
require"./inc/";
check_login();
?>
<?
if($sub)
{
$file_cont="<?\n #don't edit thisfile use the \n";
$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/","w");
if(fputs($fp,$file_cont))
echo "Configuration is being checked for the correctness of each option<BR>";
else echo "File writing error, please check the permissions in the directory where the file is located<br>";
fclose($fp);
echo "Detection of data connection......";
if(@mysql_connect("$host","$database_usn","$database_pwd"))
{
echo "Success!<BR>" ;
$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"Database $table was successfully established<BR>".mysql_error();
else
echo"Database $table failed to establish <BR>";
$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"User Comment Database $ping_tab was successfully established <BR>Congratulations, the article management system was successfully installed! Please <a href=>go here</a> for basic settings!<BR>";
$fp=fopen("","r");
$file_cont=fread($fp,filesize(""));
$file_cont="<? \nsession_start();\nrequire\"./inc/\";\n check_login();\n?>\n".$file_cont;
$fp=fopen("","w");
fputs($fp,$file_cont);
fclose($fp);
}
else
echo"User comment database $ping_tab failed to establish <BR>";
}
else
echo "The database connection failed! Please check the correctness of your username and password!<BR>";
exit();
}
require "./inc/";
?>
<script language="javascript">
function db_pwd()
{
var theResult = true;
var elem4 = null;
if ([0].elements[2].value == "" || [0].elements[2].value!=[0].elements[3].value)
{
alert("The database password you entered twice is inconsistent, or is empty!");
[0].elements[2].value="";
[0].elements[3].value="";
theResult = false;
}
return theResult;
}
function admin_pwd()
{
var theResult = true;
var elem4 = null;
if ([0].elements[8].value == "" || [0].elements[8].value!=[0].elements[9].value)
{
alert("The administrator password you entered twice is inconsistent, or is empty!");
[0].elements[8].value="";
[0].elements[9].value="";
theResult = false;
}
return theResult;
}
function go()
{
var theResult=true;
theResult =db_pwd()&&admin_pwd();
return theResult;
}
</script>
</head>
<body bgcolor="#FFFFFF">
<? require "./inc/";?>
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>" onsubmit="return go()";>
<table border="0" cellspacing="0" cellpadding="0" align="center" style=text-align:left;>
<tr>
<td colspan="3">
<div align="center">Blue Fox Article Management Installer<br>
(Please fill in the following content correctly, otherwise the program will not be available)</div>
</td>
</tr>
<tr>
<td>Database Server:</td>
<td colspan="2">
<input type="text" name="host" value="localhost" class="border" size="30">
</td>
</tr>
<tr>
<td>Database username: </td>
<td colspan="2">
<input type="text" name="database_usn" class="border" size="30">
</td>
</tr>
<tr>
<td>Database user password:</td>
<td colspan="2">
<input type="password" name="database_pwd" class="border" size="30">
</td>
</tr>
<tr>
<td>Database password confirmation:</td>
<td colspan="2">
<input type="password" name="database_pwd2" class="border" size="30">
</td>
</tr>
<tr>
<td>Database name:</td>
<td colspan="2">
<input type="text" name="database" class="border" size="30">
</td>
</tr>
<tr>
<td>Table of storing articles:</td>
<td colspan="2">
<input type="text" name="table" class="border" size="30">
</td>
</tr>
<tr>
<td>Storing comments table:</td>
<td colspan="2">
<input type="text" name="ping_tab" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin username:</td>
<td colspan="2">
<input type="text" name="admin_usn" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin Password:</td>
<td colspan="2">
<input type="password" name="admin_pwd" class="border" size="30">
</td>
</tr>
<tr>
<td>Admin password confirmation:</td>
<td colspan="2">
<input type="password" name="admin_pwd2" class="border" size="30">
</td>
</tr>
<tr>
<td>Administrator email address:</td>
<td colspan="2">
<input type="text" name="admin_mail" class="border" size="30">
</td>
</tr>
<tr>
<td>Number of articles displayed per page:</td>
<td colspan="2">
<input type="text" name="pagenum" class="border" size="30">
</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/";?>