Ec (2); & lt ;? Phpif ($ _ GET [& quot; action & quot;]! 1 ){? & Gt; & lt; formmethod & quot; post & quot; action & quot; index. php? Action1 & quot; & gt; & lt; tableborder & quot; 1 & quot; & gt; & lt; tr & gt; & lt; td & gt; script ec (2); script
If ($ _ GET ["action"]! = 1)
{
?>
} Else {
@ Set_time_limit (1000 );
$ Lockfile = "install. lock ";
$ Host = "localhost ";
$ User = "root ";
$ Password = "";
$ Database = "ruizhi_messageboard ";
$ Pagenum = 10;
$ Admin_name = "admin ";
$ Admin_password = "123456 ";
$ Boardname = "RUIZHINET message book ";
If ($ _ POST ["host"]! = ""){
$ Host = $ _ POST ["host"];
}
If ($ _ POST ["user"]! = ""){
$ User = $ _ POST ["user"];
}
If ($ _ POST ["password"]! = ""){
$ Password = $ _ POST ["password"];
}
If ($ _ POST ["database"]! = ""){
$ Database = $ _ POST ["database"];
}
If ($ _ POST ["pagenum"]! = ""){
$ Pagenum = $ _ POST ["pagenum"];
}
If ($ _ POST ["admin_name"]! = ""){
$ Admin_name = $ _ POST ["admin_name"];
}
If ($ _ POST ["admin_password"]! = ""){
$ Admin_password = $ _ POST ["admin_password"];
}
If ($ _ POST ["boardname"]! = ""){
$ Boardname = $ _ POST ["boardname"];
}
If (file_exists ($ lockfile )){
Exit ("already installed. If you want to reinstall it, delete install/install. lock ");
}
$ Conn = mysql_connect ($ host, $ user, $ password );
If ($ conn ){
$ SQL _drop_database = "DROP DATABASE IF EXISTS" '. $ database .""';
$ SQL _create_database = "CREATE DATABASE" '. $ database .""';
$ SQL _create_table_messageboard = "CREATE TABLE 'messageboard '(
'Id' int (11) not null auto_increment,
'Author' varchar (15) not null,
'Title' varchar (30) not null,
'Smiles 'varchar (30) not null,
'Content' mediumtext,
'Photo' varchar (30) not null,
'Addtime' int (11) default NULL,
Primary key ('id ')
) ENGINE = MyISAM default charset = gbk AUTO_INCREMENT = 1 ";
$ SQL _create_table_reply = "CREATE TABLE 'reply '(
'Id' int (11) not null auto_increment,
'Msgid' int (11) not null,
'Content' mediumtext,
'Addtime' int (11) default NULL,
Primary key ('id ')
) ENGINE = MyISAM default charset = gbk AUTO_INCREMENT = 1 ";
If (mysql_query ($ SQL _drop_database, $ conn )){
If (mysql_query ($ SQL _create_database, $ conn )){
Mysql_select_db ($ database, $ conn );
If (mysql_query ($ SQL _create_table_messageboard, $ conn) & mysql_query ($ SQL _create_table_reply, $ conn )){
$ Config_file = "../config. php ";
$ Config_strings =" $ Config_strings. = "$ boardname =" ". $ boardname." "; n ";
$ Config_strings. = "$ host =" ". $ host." "; n ";
$ Config_strings. = "$ user =" ". $ user." "; n ";
$ Config_strings. = "$ password =" ". $ password." "; n ";
$ Config_strings. = "$ database =" ". $ database." "; n ";
$ Config_strings. = "$ pagenum =" ". $ pagenum." "; n ";
$ Config_strings. = "$ admin_name =" ". $ admin_name." "; n ";
$ Config_strings. = "$ admin_password =" ". $ admin_password." "; n ";
$ Config_strings. = "$ conn = mysql_connect ($ host, $ user, $ password); n ";
$ Config_strings. = "mysql_select_db ($ database, $ conn); n ";
$ Config_strings. = "?> ";
If ($ fp = fopen ($ config_file, "wb ")){
If (fwrite ($ fp, $ config_strings )){
If ($ fp2 = fopen ($ lockfile, 'w '))
{
Fwrite ($ fp2, '20140901 ');
Fclose ($ fp2 );
}
Echo "installation successful! The configuration file is config. php. You can manually modify the file ";
Echo "n go to the system Homepage ";
} Else {
Exit ("file write failed ");
}
Fclose ($ fp );
}
} Else {
Exit ("the create table statement cannot be executed:". $ SQL _create_table );
}
} Else {
Exit ("the create database statement cannot be executed:". $ SQL _create_database );
}
} Else {
Exit ("the drop database statement cannot be executed:". $ SQL _drop_database );
}
} Else {
Exit ("failed to connect to the database. Check the MySQL host name, user name, and password ");
}
}
$ Boardname = "RUIZHINET message book ";
$ Host = "localhost ";
$ User = "root ";
$ Password = "";
$ Database = "ruizhi_messageboard ";
$ Pagenum = "10 ";
$ Admin_name = "admin ";
$ Admin_password = "admin ";
$ Conn = mysql_connect ($ host, $ user, $ password );
Mysql_select_db ($ database, $ conn );
?>
If (! $ _ GET ["page"]) {
$ Page = 1;
} Else {
$ Page = $ _ GET ["page"];
}
$ SQL = "SELECT id FROM messageboard ";
$ Result = mysql_query ($ SQL, $ conn );
$ Row_num = mysql_num_rows ($ result );
$ Page_count = ceil ($ row_num/$ pagenum );
Echo "A total of". $ row_num. "messages ";
Echo "divided into". $ page_count. "Page display ";
Echo "current". $ page. "page ";
?>
If ($ row_num = 0 ){
Echo "no message ";
} Else {
?>
$ Offset = ($ page-1) * $ pagenum;$ Sql2 = "SELECT * FROM messageboard order by id desc limit $ offset, $ pagenum ";$ Result2 = mysql_query ($ sql2, $ conn );While ($ row = mysql_fetch_array ($ result2 )){$ Offset ++;Echo"
";Echo"
"; Echo $ offset ."."; Echo base64_decode ($ row [title]). "-". base64_decode ($ row [author]). "[". date ("Y, m, D", $ row [addtime]). "]"; If (isset ($ _ SESSION ["admin_name"]) & $ _ SESSION ["admin_name"]! = ""){ Echo "delete | "; Echo "reply "; } Echo" |
";Echo"
". Base64_decode ($ row [" content "])." |
";If ($ row ["photo"]! = "NONE "){Echo"
|
";}$ Sql3 = "SELECT * FROM reply WHERE msgid = $ row [id] order by id DESC ";$ Result3 = mysql_query ($ sql3, $ conn );While ($ row3 = mysql_fetch_array ($ result3 )){Echo"
Reply: ". date (" Y, m, D ", $ row3 [addtime]); If (isset ($ _ SESSION ["admin_name"]) & $ _ SESSION ["admin_name"]! = ""){ Echo "delete "; } Echo" |
";Echo"
". Base64_decode ($ row3 [content])." |
";}}?> If ($ page_count> 1 ){$ Prev_page = $ page-1;$ Next_page = $ page + 1;If ($ page <= 1 ){Echo "Page 1 | ";} Else {Echo "Page 1 | ";}If ($ prev_page <1 ){Echo "Previous Page | ";} Else {Echo "Previous Page | ";}If ($ next_page> $ page_count ){Echo "next page | ";} Else {Echo "next page | ";}If ($ page >=$ page_count ){Echo "last page ";} Else {Echo "last page ";}}?>
}
?>
If (isset ($ _ SESSION ["admin_name"]) & $ _ SESSION ["admin_name"]! = ""){
?>
Exit Management
} Else {
?>
Login Management
}
?>
If (! $ _ POST ["author"] |! $ _ POST ["content"])
{
Echo" N ";
Echo "You did not fill in the message name or content, 2 seconds back to the home page ";
Exit ();
} Else {
$ Imgflag = 0;
Function random ($ length)
{
$ Hash = 'img -';
$ Chars = 'abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxy ';
$ Max = strlen ($ chars)-1;
Echo (double) microtime () * 1000000;
For ($ I = 0; $ I <$ length; $ I ++)
{
$ Hash. = $ chars [mt_rand (0, $ max)];
}
Return $ hash;
}
Function fileext ($ filename)
{
Return substr (strrchr ($ filename, '.'), 1 );
}
If ($ _ FILES ["upfile"] ["name"]! = ""){
$ Uploaddir = "upfile /";
$ Type = array ("jpg", "gif", "bmp", "jpeg", "png ");
If (! In_array (strtolower (fileext ($ _ FILES ['upfile'] ['name']), $ type ))
{
Echo" N ";
$ Text = implode (",", $ type );
Echo "You can only upload the following types of files:", $ text ,"
";
Exit ();
}
Else
{
$ Filename = explode (".", $ _ FILES ['upfile'] ['name']);
Do
{
$ Filename [0] = random (10 );
$ Randname = implode (".", $ filename );
$ Uploadfile = $ uploaddir. $ randname;
} While (file_exists ($ uploadfile ));
If (move_uploaded_file ($ _ FILES ['upfile'] ['tmp _ name'], $ uploadfile )){
Echo "image uploaded ";
$ Imgflag = 1;
}
Else {
Echo "An error occurred while uploading the image! ";
$ Imgflag = 0;
}
}
}
$ Author = base64_encode ($ _ POST ["author"]);
$ Content = base64_encode (ereg_replace ("rn ","
", Htmlspecialchars ($ _ POST [" content "]);
$ Smiles = base64_encode ($ _ POST ["smiles"]);
If ($ _ POST ["title"]) {
$ Title = base64_encode ($ _ POST ["title"]);
} Else {
$ Title = base64_encode ("No title ");
}
$ Addtime = time ();
If ($ imgflag = 1 ){
$ Photo = base64_encode ($ randname );
} Else {
$ Photo = "NONE ";
}
// Save data
$ SQL = "INSERT INTO messageboard (author, title, smiles, content, photo, addtime) VALUES ('$ author',' $ title', '$ smiles ', '$ content',' $ photo ', $ addtime )";
Mysql_query ($ SQL, $ conn );
Echo" N ";
Echo "thank you for your message. Return to the homepage in 2 seconds ";
}
?>
Savereply. php: Save the reply
If (isset ($ _ SESSION ["admin_name"]) & $ _ SESSION ["admin_name"]! = "")
{
If (! $ _ POST ["content"])
{
Echo" N ";
Echo "You did not fill in the reply content, 2 seconds back to the home page ";
Exit ();
} Else {
$ Msgid = $ _ POST ["msgid"];
$ Content = base64_encode (ereg_replace ("rn ","
", Htmlspecialchars ($ _ POST [" content "]);
$ Addtime = time ();
// Save data
$ SQL = "INSERT INTO reply (msgid, content, addtime) VALUES ($ msgid, '$ content', $ addtime )";
Mysql_query ($ SQL, $ conn );
Echo" N ";
Echo "thank you for your message. Return to the homepage in 2 seconds ";
}
}
?>