ホームページ  >  記事  >  バックエンド開発  >  PHP記事管理_PHPチュートリアル

PHP記事管理_PHPチュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:49:121151ブラウズ

/**
*記事
* 2011/9/21
*kcj
**/
「isLogin.php」を含めます
「../conn/config.inc.php」を含めます
include_once("../FCKeditor/fckeditor.php"); $oFCKeditor = new FCKeditor("content") ; //FCKeditor インスタンスを作成します。複数のインスタンスを作成できます
$oFCKeditor->BasePath = '../FCKeditor/' //FCKeditor ディレクトリのアドレスを設定します
; /*アクション操作の初期化*/
if(emptyempty($_REQUEST['action'])){
$_REQUEST['アクション']='リスト'; }その他{
$_REQUEST['アクション']=トリム($_REQUEST['アクション']); }
if($_REQUEST['アクション']=='追加'){

$oFCKeditor = new FCKeditor("content") ; // FCKeditor インスタンスを作成します。複数のインスタンスを作成できます
$oFCKeditor->BasePath = '../FCKeditor/'; $oFCKeditor->BasePath = '../FCKeditor/' // FCKeditor ディレクトリのアドレスを設定します

$tpl->assign('fck',$oFCKeditor->Create()); $tpl->assign('tmess','記事を追加'); $tpl->assign('act','insert'); $tpl->assign('submitButton','Add'); $tpl->display('admin/addArticle.tpl'); }
/*記事を追加*/
elseif ($_REQUEST['アクション']=='挿入'){
$title=$_POST['タイトル']
$zhaiyao=$_POST['zhaiyao']
$author=$_POST['著者']
$ライユアン=$_POST['ライユアン']
$キーワード=$_POST['キーワード']
$is_tuijian=$_POST['is_tuijian']
$content=$_POST['コンテンツ']
$sql="記事(タイトル、zhaiyao、著者、laiyuan、キーワード、is_tuijian、content、addtime)の値を挿入します
('$title','$zhaiyao','$author','$laiyuan','$keyword','$is_tuijian','$content',now())";
$rs=$db->クエリ($sql); If($rs){
echo header("location:/admin/article.php?action=list"); }その他{
エコー「失敗しました!」 }
}
/*記事一覧*/
elseif ($_REQUEST['アクション']=='リスト'){
$total=getAllArticle(); $curpage=isset($_GET['ページ'])?$_GET['ページ']:1; $pageObj=新しいページ($total,$curpage); $pageInfo=$pageObj->getPageInfo(); $arts=getArticlePage($pageInfo['row_offset'],$pageInfo['row_num']); $tpl->assign("tmess","記事リスト"); $tpl->assign("芸術",$芸術)
$tpl->assign("ページ情報",$ページ情報); $tpl->display("admin/editArticle.tpl"); }
/*記事を修正*/
elseif ($_REQUEST['アクション']=='編集'){
$id=$_GET['id']; $post=editArticle($id);
$tpl->assign("tmess","記事を変更する"); $tpl->assign('post',$post); $oFCKeditor->Value=$post["content"] //編集時に記事の内容を表示します
; If($post['is_tuijian']==1||$_POST["recommend"]==1){ //
を推奨するかどうかを決定 $tpl->assign('recommend','checked'); }その他{
        $tpl->assign('no_recommend','checked'); 
    }
    $tpl->assign('fck',$oFCKeditor->Create()); 
    $tpl->assign("act","update"); 
    $tpl->assign('submitButton','修正'); 
    $tpl->display('admin/addArticle.tpl'); 
}elseif ($_REQUEST['アクション']=='更新'){
    $id=$_POST['id']; 
    $title=$_POST['タイトル']; 
    $zhaiyao=$_POST['zhaiyao']; 
    $author=$_POST['著者']; 
    $laiyuan=$_POST['laiyuan']; 
    $keyword=$_POST['キーワード']; 
    $is_tuijian=$_POST['is_tuijian']; 
    $content=$_POST['コンテンツ']; 
    $sql="記事セットを更新 title='$title',zhaiyao='$zhaiyao',author='$author',laiyuan='$laiyuan',keyword='$keyword',is_tuijian='$is_tuijian',
    content='$content' where id ='$id'";
    $rs=$db->クエリ($sql); 
    if($rs){
        echo header("location:/admin/article.php?action=list"); 
    }else {
        echo "修正失败!"; 
    }
}
/*删除*/
elseif ($_REQUEST['action']=='del'){
    $id=$_GET['id']; 
    del($id); 
}
/*审核文章*/
elseif ($_REQUEST['action']=='シェンヘ'){
    $id=$_GET['id']; 
    シェンヘ($id); 
}
/*锁定文章*/
elseif ($_REQUEST['アクション']=='ロック'){
    $id=$_GET['id']; 
    ロック($id); 
}
/*批量删除*/
/*批量审核*/
elseif (isset($_REQUEST['shenhe_x'])||isset($_REQUEST['shenhe_y'])){
    $del=$_POST['del']; 
    シェンヘ($del); 
}
/*大量锁定*/
elseif (isset($_REQUEST['lock_x'])||isset($_REQUEST['lock_y'])){
    $del=$_POST['del']; 
    ロック($del); 
}
 
 
 
/*=======文章模块相关関数==========*/
 
/**
* ページング用のすべての記事を取得します
**/
関数 getAllArticle(){
    グローバル $db; 
    $sql="記事から * を選択"; 
    $rs=$db->クエリ($sql); 
    $total=$db->num_rows($rs); 
    $total を返します。 
}
/*文章分页相关関数数*/
関数 getArticlePage($offset,$num){
    グローバル $db; 
    $sql="選択*ID による記事の順序から制限 $offset,$num"; 
    $rs=$db->クエリ($sql); 
    while ($row=$db->fetch_array($rs)){
        $data[]=$row; 
    }
    $data を返します。 
}
/*文章修正*/
関数 editArticle($id){
    グローバル $db; 
    $sql="id = '$id' の記事から * を選択"; 
    $rs=$db->クエリ($sql); 
    return $row=$db->fetch_array($rs,MYSQL_ASSOC); 
 
}
/*删除文章*/
関数 del($id){
    グローバル $db; 
    $sql="id の記事から削除"; 
    if(is_array($id)){
        $sql.="IN (".implode(",","$id").")"; 
    }else {
        $sql.="=$id"; 
    }
    $rs=$db->クエリ($sql); 
If($rs){
echo header("location:/admin/article.php?action=list"); }その他{
echo "削除に失敗しました!"; }
}
関数 shenhe($id){
グローバル $db
$sql="記事セットステータスを更新='1' ここでID"; If(is_array($id)){
$sql.="IN (".join(",",$id).")"; //$id が配列の場合、結合関数を使用して $id を部分に分割します。
}その他{
$sql.="=$id"; }
$rs=$db->クエリ($sql); If($rs){
echo header("location:/admin/article.php?action=list"); }その他{
エコー「監査に失敗しました!」
}

}

関数ロック($id){
グローバル $db
$sql="記事の更新セットステータス='0' ここでID "; If(is_array($id)){
$sql.="IN (".implode(",","$id").")"; }その他{
$sql.="=$id"; }
$rs=$db->クエリ($sql); If($rs){
echo header("location:/admin/article.php?action=list"); }その他{
エコー「ロックに失敗しました!」
}
}
?>
/**
*記事
* 2011/9/21
*kcj
**/
「isLogin.php」を含める;
"../conn/config.inc.php" を含めます;
include_once("../FCKeditor/fckeditor.php");
$oFCKeditor = new FCKeditor("content") ; // FCKeditor インスタンスを作成します。複数のインスタンスを作成できます
$oFCKeditor->BasePath = '../FCKeditor/' //FCKeditor ディレクトリのアドレスを設定します
; /*アクション操作の初期化*/
if(empty($_REQUEST['action'])){
$_REQUEST['アクション']='リスト';
}その他{
$_REQUEST['アクション']=trim($_REQUEST['アクション']);
}
if($_REQUEST['アクション']=='追加'){

$oFCKeditor = new FCKeditor("content") // FCKeditor インスタンスを作成します。複数のインスタンスを作成できます
$oFCKeditor->BasePath = '../FCKeditor/'; $oFCKeditor->BasePath = '../FCKeditor/' //FCKeditor ディレクトリのアドレスを設定します

$tpl->assign('fck',$oFCKeditor->Create());
$tpl->assign('tmess','記事を追加');
$tpl->assign('act','insert');
$tpl->assign('submitButton','Add');
$tpl->display('admin/addArticle.tpl');
}
/*記事を追加*/
elseif ($_REQUEST['アクション']=='挿入'){
$title=$_POST['タイトル'];
$zhaiyao=$_POST['zhaiyao'];
$author=$_POST['著者'];
$laiyuan=$_POST['laiyuan'];
$keyword=$_POST['キーワード'];
$is_tuijian=$_POST['is_tuijian'];
$content=$_POST['コンテンツ'];
$sql="記事(タイトル,zhaiyao,著者,laiyuan,キーワード,is_tuijian,content,addtime)の値を挿入
('$title','$zhaiyao','$author','$laiyuan','$keyword','$is_tuijian','$content',now())";
$rs=$db->クエリ($sql);
if($rs){
echo header("location:/admin/article.php?action=list");
}その他{
echo "失敗!";
}
}
/*記事一覧*/
elseif ($_REQUEST['アクション']=='リスト'){
$total=getAllArticle();
$curpage=isset($_GET['ページ'])?$_GET['ページ']:1;
$pageObj=新しいページ($total,$curpage);
$pageInfo=$pageObj->getPageInfo();
$arts=getArticlePage($pageInfo['row_offset'],$pageInfo['row_num']);
$tpl->assign("tmess","記事リスト");
$tpl->assign("芸術",$芸術);
$tpl->assign("pageInfo",$pageInfo);
$tpl->display("admin/editArticle.tpl");
}
/*記事を修正*/
elseif ($_REQUEST['アクション']=='編集'){
$id=$_GET['id'];
$post=editArticle($id);

$tpl->assign("tmess","記事を修正");
$tpl->assign('post',$post);
$oFCKeditor->Value=$post["content"] //編集時に記事の内容を表示します
; if($post['is_tuijian']==1||$_POST["recommend"]==1){ //推奨するかどうかを決定します
$tpl->assign('推奨','チェック済み');
}その他{
$tpl->assign('no_recommend','checked');
}
$tpl->assign('fck',$oFCKeditor->Create());
$tpl->assign("act","update");
$tpl->assign('submitButton','Modify');
$tpl->display('admin/addArticle.tpl');
}elseif ($_REQUEST['アクション']=='更新'){
$id=$_POST['id'];
$title=$_POST['タイトル'];
$zhaiyao=$_POST['zhaiyao'];
$author=$_POST['著者'];
$laiyuan=$_POST['laiyuan'];
$keyword=$_POST['キーワード'];
$is_tuijian=$_POST['is_tuijian'];
$content=$_POST['コンテンツ'];
$sql="記事セットを更新 title='$title',zhaiyao='$zhaiyao',author='$author',laiyuan='$laiyuan',keyword='$keyword',is_tuijian='$is_tuijian',
content='$content' where id ='$id'";
$rs=$db->クエリ($sql);
if($rs){
echo header("location:/admin/article.php?action=list");
}その他{
echo "変更に失敗しました!";
}
}
/*削除*/
elseif ($_REQUEST['action']=='del'){
$id=$_GET['id'];
del($id);
}
/*レビュー記事*/
elseif ($_REQUEST['アクション']=='シェンヘ'){
$id=$_GET['id'];
シェンヘ($id);
}
/*記事をロック*/
elseif ($_REQUEST['アクション']=='ロック'){
$id=$_GET['id'];
ロック($id);
}
/*一括削除*/
/*バッチレビュー*/
elseif (isset($_REQUEST['shenhe_x'])||isset($_REQUEST['shenhe_y'])){
$del=$_POST['del'];
シェンヘ($del);
}
/*バッチロック*/
elseif (isset($_REQUEST['lock_x'])||isset($_REQUEST['lock_y'])){
$del=$_POST['del'];
ロック($del);
}

/*========記事モジュール関連機能==========*/

/**
* ページング用のすべての記事を取得します
**/
関数 getAllArticle(){
グローバル $db;
$sql="記事から * を選択";
$rs=$db->クエリ($sql);
$total=$db->num_rows($rs);
$total を返します;
}
/*記事のページネーション関連機能*/
function getArticlePage($offset,$num){
グローバル $db;
$sql="選択*ID による記事の順序から制限 $offset,$num";
$rs=$db->クエリ($sql);
while ($row=$db->fetch_array($rs)){
$data[]=$row;
}
$data を返します;
}
/*記事修正*/
関数 editArticle($id){
グローバル $db;
$sql="id = '$id' の記事から * を選択";
$rs=$db->クエリ($sql);
return $row=$db->fetch_array($rs,MYSQL_ASSOC);

}
/*記事を削除*/
関数 del($id){
グローバル $db;
$sql="ID の記事から削除";
if(is_array($id)){
$sql.="IN (".implode(",","$id").")";
}その他{
$sql.="=$id";
}
$rs=$db->クエリ($sql);
if($rs){
echo header("location:/admin/article.php?action=list");
}その他{
echo "削除に失敗しました!";
}
}
関数 shenhe($id){
グローバル $db;
$sql="記事の更新セットステータス='1' ここでID";
if(is_array($id)){
$sql.="IN (".join(",",$id).")"; //$id が配列の場合、結合関数を使用して $id を部分に分割します。
}その他{
$sql.="=$id";
}
$rs=$db->クエリ($sql);
if($rs){
echo header("location:/admin/article.php?action=list");
}その他{
echo "監査に失敗しました!";
}

}

機能ロック($id){
グローバル $db;
$sql="記事の更新 set status='0' where id ";
if(is_array($id)){
$sql.="IN (".implode(",","$id").")";
}その他{
$sql.="=$id";
}
$rs=$db->クエリ($sql);
if($rs){
echo header("location:/admin/article.php?action=list");
}その他{
echo "ロックに失敗しました!";
}
}
?>

chaojie2009 さんのコラムより抜粋

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/478371.html技術記事 ?php /***記事*2011/9/21*kcj**/ include isLogin.php; include_once(../FCKeditor/fckeditor.php); //作成...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。