Php document management_php tutorial-PHP Tutorial

Source: Internet
Author: User
Php article management .? Php *** article * 2011921 * kcj ** extends deislogin. php; include... connconfig. inc. php; include_once (.. FCKeditorfckeditor. php); $ oFCKeditornewFCKeditor (content); create /**
* Article
* 2011/9/21
* Kcj
**/
Include "isLogin. php ";
Include "../conn/config. inc. php ";
Include_once ("../FCKeditor/fckeditor. php ");
$ OFCKeditor = new FCKeditor ("content"); // you can create multiple FCKeditor instances.
$ OFCKeditor-> BasePath = '../FCKeditor/'; // Set the FCKeditor directory address
/* Initialize the action */
If (emptyempty ($ _ REQUEST ['action']) {
$ _ REQUEST ['action'] = 'list ';
} Else {
$ _ REQUEST ['action'] = trim ($ _ REQUEST ['action']);
}
If ($ _ REQUEST ['action'] = 'ADD '){

$ OFCKeditor = new FCKeditor ("content"); // you can create multiple FCKeditor instances.
$ OFCKeditor-> BasePath = '../FCKeditor/'; // Set the FCKeditor directory address

$ Tpl-> assign ('fck ', $ oFCKeditor-> Create ());
$ Tpl-> assign ('tmess', 'Add topic ');
$ Tpl-> assign ('Act ', 'insert ');
$ Tpl-> assign ('submitclick', 'ADD ');
$ Tpl-> display ('admin/addArticle. tpl ');
}
/* Add an article */
Elseif ($ _ REQUEST ['action'] = 'insert '){
$ Title = $ _ POST ['title'];
$ Zhaiyao =$ _ POST ['zhaiao'];
$ Author = $ _ POST ['author'];
$ Laiyuan =$ _ POST ['laiyuan '];
$ Keyword = $ _ POST ['keyword'];
$ Is_tuijian =$ _ POST ['is _ tuijian '];
$ Content = $ _ POST ['content'];
$ SQL = "insert into article (title, zhaiyao, author, laiyuan, keyword, is_tuijian, content, addtime) values
('$ Title',' $ zhaiao', '$ author',' $ laiyuan ',' $ keyword', '$ is_tuijian', '$ content', now ()) ";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed! ";
}
}
/* Article list */
Elseif ($ _ REQUEST ['action'] = 'list '){
$ Total = getAllArticle ();
$ Curpage = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 1;
$ PageObj = new Page ($ total, $ curpage );
$ PageInfo = $ pageObj-> getPageInfo ();
$ Arts = getArticlePage ($ pageInfo ['row _ offset'], $ pageInfo ['row _ num']);
$ Tpl-> assign ("tmess", "article list ");
$ Tpl-> assign ("arts", $ arts );
$ Tpl-> assign ("pageInfo", $ pageInfo );
$ Tpl-> display ("admin/editArticle. tpl ");
}
/* Modify the article */
Elseif ($ _ REQUEST ['action'] = 'edit '){
$ Id = $ _ GET ['id'];
$ Post = editArticle ($ id );

$ Tpl-> assign ("tmess", "modify article ");
$ Tpl-> assign ('post', $ post );
$ OFCKeditor-> Value = $ post ["content"]; // The content of the article is displayed during editing.
If ($ post ['is _ tuijian '] = 1 | $ _ POST ["recommend"] = 1) {// determine whether to recommend
$ Tpl-> assign ('referend', 'checked ');
} Else {
$ Tpl-> assign ('no _ recommend', 'checked ');
}
$ Tpl-> assign ('fck ', $ oFCKeditor-> Create ());
$ Tpl-> assign ("act", "update ");
$ Tpl-> assign ('submitclick', 'modify ');
$ Tpl-> display ('admin/addArticle. tpl ');
} Elseif ($ _ REQUEST ['action'] = 'update '){
$ Id = $ _ POST ['id'];
$ Title = $ _ POST ['title'];
$ Zhaiyao =$ _ POST ['zhaiao'];
$ Author = $ _ POST ['author'];
$ Laiyuan =$ _ POST ['laiyuan '];
$ Keyword = $ _ POST ['keyword'];
$ Is_tuijian =$ _ POST ['is _ tuijian '];
$ Content = $ _ POST ['content'];
$ SQL = "update article set title = '$ title', zhaiyao =' $ zhaiyao ', author =' $ author', laiyuan = '$ laiyuan ', keyword = '$ keyword', is_tuijian =' $ is_tuijian ',
Content = '$ content' where id =' $ ID '";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to modify! ";
}
}
/* Delete */
Elseif ($ _ REQUEST ['action'] = 'Del '){
$ Id = $ _ GET ['id'];
Del ($ id );
}
/* Review the article */
Elseif ($ _ REQUEST ['action'] = 'shenhes '){
$ Id = $ _ GET ['id'];
Shenhe ($ id );
}
/* Lock the article */
Elseif ($ _ REQUEST ['action'] = 'lock '){
$ Id = $ _ GET ['id'];
Lock ($ id );
}
/* Batch delete */
/* Batch review */
Elseif (isset ($ _ REQUEST ['shenhe _ X']) | isset ($ _ REQUEST ['shenhe _ Y']) {
$ Del = $ _ POST ['Del '];
Shenhe ($ del );
}
/* Batch lock */
Elseif (isset ($ _ REQUEST ['lock _ X']) | isset ($ _ REQUEST ['lock _ Y']) {
$ Del = $ _ POST ['Del '];
Lock ($ del );
}



/* ======= Related functions of the article module ============= */

/**
* Retrieve all articles for paging
**/
Function getAllArticle (){
Global $ db;
$ SQL = "select * from article ";
$ Rs = $ db-> query ($ SQL );
$ Total = $ db-> num_rows ($ rs );
Return $ total;
}
/* Article paging related functions */
Function getArticlePage ($ offset, $ num ){
Global $ db;
$ SQL = "select * from article order by id desc limit $ offset, $ num ";
$ Rs = $ db-> query ($ SQL );
While ($ row = $ db-> fetch_array ($ rs )){
$ Data [] = $ row;
}
Return $ data;
}
/* Modify the article */
Function editArticle ($ id ){
Global $ db;
$ SQL = "select * from article where id = '$ ID '";
$ Rs = $ db-> query ($ SQL );
Return $ row = $ db-> fetch_array ($ rs, MYSQL_ASSOC );

}
/* Delete an article */
Function del ($ id ){
Global $ db;
$ SQL = "delete from article where id ";
If (is_array ($ id )){
$ SQL. = "IN (". implode (",", "$ id ").")";
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to delete! ";
}
}
Function shenhe ($ id ){
Global $ db;
$ SQL = "update article set status = '1' where id ";
If (is_array ($ id )){
$ SQL. = "IN (". join (",", $ id ). ")"; // if $ id is an array, use the join function to divide $ id into use. the connected string join is the alias of implode.
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "review failed! ";
}

}

Function lock ($ id ){
Global $ db;
$ SQL = "update article set status = '0' where id ";
If (is_array ($ id )){
$ SQL. = "IN (". implode (",", "$ id ").")";
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to lock! ";
}
}
?>
/**
* Article
* 2011/9/21
* Kcj
**/
Include "isLogin. php ";
Include "../conn/config. inc. php ";
Include_once ("../FCKeditor/fckeditor. php ");
$ OFCKeditor = new FCKeditor ("content"); // you can create multiple FCKeditor instances.
$ OFCKeditor-> BasePath = '../FCKeditor/'; // Set the FCKeditor directory address
/* Initialize the action */
If (empty ($ _ REQUEST ['action']) {
$ _ REQUEST ['action'] = 'list ';
} Else {
$ _ REQUEST ['action'] = trim ($ _ REQUEST ['action']);
}
If ($ _ REQUEST ['action'] = 'ADD '){

$ OFCKeditor = new FCKeditor ("content"); // you can create multiple FCKeditor instances.
$ OFCKeditor-> BasePath = '../FCKeditor/'; // Set the FCKeditor directory address

$ Tpl-> assign ('fck ', $ oFCKeditor-> Create ());
$ Tpl-> assign ('tmess', 'Add topic ');
$ Tpl-> assign ('Act ', 'insert ');
$ Tpl-> assign ('submitclick', 'ADD ');
$ Tpl-> display ('admin/addArticle. tpl ');
}
/* Add an article */
Elseif ($ _ REQUEST ['action'] = 'insert '){
$ Title = $ _ POST ['title'];
$ Zhaiyao =$ _ POST ['zhaiao'];
$ Author = $ _ POST ['author'];
$ Laiyuan =$ _ POST ['laiyuan '];
$ Keyword = $ _ POST ['keyword'];
$ Is_tuijian =$ _ POST ['is _ tuijian '];
$ Content = $ _ POST ['content'];
$ SQL = "insert into article (title, zhaiyao, author, laiyuan, keyword, is_tuijian, content, addtime) values
('$ Title',' $ zhaiao', '$ author',' $ laiyuan ',' $ keyword', '$ is_tuijian', '$ content', now ()) ";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed! ";
}
}
/* Article list */
Elseif ($ _ REQUEST ['action'] = 'list '){
$ Total = getAllArticle ();
$ Curpage = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 1;
$ PageObj = new Page ($ total, $ curpage );
$ PageInfo = $ pageObj-> getPageInfo ();
$ Arts = getArticlePage ($ pageInfo ['row _ offset'], $ pageInfo ['row _ num']);
$ Tpl-> assign ("tmess", "article list ");
$ Tpl-> assign ("arts", $ arts );
$ Tpl-> assign ("pageInfo", $ pageInfo );
$ Tpl-> display ("admin/editArticle. tpl ");
}
/* Modify the article */
Elseif ($ _ REQUEST ['action'] = 'edit '){
$ Id = $ _ GET ['id'];
$ Post = editArticle ($ id );

$ Tpl-> assign ("tmess", "modify article ");
$ Tpl-> assign ('post', $ post );
$ OFCKeditor-> Value = $ post ["content"]; // The content of the article is displayed during editing.
If ($ post ['is _ tuijian '] = 1 | $ _ POST ["recommend"] = 1) {// determine whether to recommend
$ Tpl-> assign ('referend', 'checked ');
} Else {
$ Tpl-> assign ('no _ recommend', 'checked ');
}
$ Tpl-> assign ('fck ', $ oFCKeditor-> Create ());
$ Tpl-> assign ("act", "update ");
$ Tpl-> assign ('submitclick', 'modify ');
$ Tpl-> display ('admin/addArticle. tpl ');
} Elseif ($ _ REQUEST ['action'] = 'update '){
$ Id = $ _ POST ['id'];
$ Title = $ _ POST ['title'];
$ Zhaiyao =$ _ POST ['zhaiao'];
$ Author = $ _ POST ['author'];
$ Laiyuan =$ _ POST ['laiyuan '];
$ Keyword = $ _ POST ['keyword'];
$ Is_tuijian =$ _ POST ['is _ tuijian '];
$ Content = $ _ POST ['content'];
$ SQL = "update article set title = '$ title', zhaiyao =' $ zhaiyao ', author =' $ author', laiyuan = '$ laiyuan ', keyword = '$ keyword', is_tuijian =' $ is_tuijian ',
Content = '$ content' where id =' $ ID '";
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to modify! ";
}
}
/* Delete */
Elseif ($ _ REQUEST ['action'] = 'Del '){
$ Id = $ _ GET ['id'];
Del ($ id );
}
/* Review the article */
Elseif ($ _ REQUEST ['action'] = 'shenhes '){
$ Id = $ _ GET ['id'];
Shenhe ($ id );
}
/* Lock the article */
Elseif ($ _ REQUEST ['action'] = 'lock '){
$ Id = $ _ GET ['id'];
Lock ($ id );
}
/* Batch delete */
/* Batch review */
Elseif (isset ($ _ REQUEST ['shenhe _ X']) | isset ($ _ REQUEST ['shenhe _ Y']) {
$ Del = $ _ POST ['Del '];
Shenhe ($ del );
}
/* Batch lock */
Elseif (isset ($ _ REQUEST ['lock _ X']) | isset ($ _ REQUEST ['lock _ Y']) {
$ Del = $ _ POST ['Del '];
Lock ($ del );
}

/* ======= Related functions of the article module ============= */

/**
* Retrieve all articles for paging
**/
Function getAllArticle (){
Global $ db;
$ SQL = "select * from article ";
$ Rs = $ db-> query ($ SQL );
$ Total = $ db-> num_rows ($ rs );
Return $ total;
}
/* Article paging related functions */
Function getArticlePage ($ offset, $ num ){
Global $ db;
$ SQL = "select * from article order by id desc limit $ offset, $ num ";
$ Rs = $ db-> query ($ SQL );
While ($ row = $ db-> fetch_array ($ rs )){
$ Data [] = $ row;
}
Return $ data;
}
/* Modify the article */
Function editArticle ($ id ){
Global $ db;
$ SQL = "select * from article where id = '$ ID '";
$ Rs = $ db-> query ($ SQL );
Return $ row = $ db-> fetch_array ($ rs, MYSQL_ASSOC );

}
/* Delete an article */
Function del ($ id ){
Global $ db;
$ SQL = "delete from article where id ";
If (is_array ($ id )){
$ SQL. = "IN (". implode (",", "$ id ").")";
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to delete! ";
}
}
Function shenhe ($ id ){
Global $ db;
$ SQL = "update article set status = '1' where id ";
If (is_array ($ id )){
$ SQL. = "IN (". join (",", $ id ). ")"; // if $ id is an array, use the join function to divide $ id into use. the connected string join is the alias of implode.
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "review failed! ";
}

}

Function lock ($ id ){
Global $ db;
$ SQL = "update article set status = '0' where id ";
If (is_array ($ id )){
$ SQL. = "IN (". implode (",", "$ id ").")";
} Else {
$ SQL. = "= $ id ";
}
$ Rs = $ db-> query ($ SQL );
If ($ rs ){
Echo header ("location:/admin/article. php? Action = list ");
} Else {
Echo "failed to lock! ";
}
}
?>

From chaojie2009

Http://www.bkjia.com/PHPjc/478371.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478371.htmlTechArticle? Php/*** article * 2011/9/21 * kcj **/include isLogin. php; include .. /conn/config. inc. php; include_once (.. /FCKeditor/fckeditor. php); $ oFCKeditor = new FCKeditor (content); // create...

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.