線上書籍

Home

1041 XOOPS模組開發

<?php /*-----------引入檔案區--------------*/ include_once "header.php"; $xoopsOption['template_main'] = set_bootstrap("tad_ebook_verify.html"); include_once XOOPS_ROOT_PATH."/header.php"; if(!is_verify()){ redirect_header("index.php",3, "您沒有使用此功能權限。"); } /*-----------function區--------------*/ //顯示預設頁面內容 function verify_page($page_sn=""){ global $xoopsTpl ,$xoopsDB; $tbl=$xoopsDB->prefix('tad_ebook_page'); $sql="select * from `{$tbl}` where `page_sn` = '{$page_sn}'"; $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error()); $page=$xoopsDB->fetchArray($result); $xoopsTpl->assign('page',$page); $xoopsTpl->assign('op', 'verify_page'); } //顯示所有可審核期數列表 function verify_all(){ global $xoopsTpl ,$xoopsDB; $today=date("Y-m-d"); $tbl=$xoopsDB->prefix('tad_ebook'); $sql="select * from `{$tbl}` where `ebook_post_date` < '{$today}' and `ebook_publish_date` > '{$today}'"; $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error()); while($ebook=$xoopsDB->fetchArray($result)){ $all_ebook[]=$ebook; } $xoopsTpl->assign('all_ebook',$all_ebook); $xoopsTpl->assign('op', 'verify_all'); } //顯示某期文章列表 function verify_ebook($ebook_sn=""){ global $xoopsTpl ,$xoopsDB; $tbl=$xoopsDB->prefix('tad_ebook_page'); $sql="select * from `{$tbl}` where `ebook_sn` = '{$ebook_sn}'"; $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error()); while($page=$xoopsDB->fetchArray($result)){ $all_page[]=$page; } $xoopsTpl->assign('all_page',$all_page); $xoopsTpl->assign('op', 'verify_ebook'); } //審核文章 function verify($page_sn="",$status=""){ global $xoopsDB; $tbl=$xoopsDB->prefix('tad_ebook_page'); $sql="update `{$tbl}` set `page_status` = '{$status}' where `page_sn` = '{$page_sn}'"; $xoopsDB->queryF($sql) or redirect_header("index.php",3, mysql_error()); } /*-----------執行動作判斷區----------*/ $op=empty($_REQUEST['op'])?"":$_REQUEST['op']; $page_sn=empty($_REQUEST['page_sn'])?"":intval($_REQUEST['page_sn']); $ebook_sn=empty($_REQUEST['ebook_sn'])?"":intval($_REQUEST['ebook_sn']); $status=isset($_REQUEST['status'])?$_REQUEST['status']:""; switch($op){ case "verify": verify($page_sn,$status); header("location:{$_SERVER['PHP_SELF']}?ebook_sn=$ebook_sn"); exit; break; default: if($page_sn){ verify_page($page_sn); }elseif($ebook_sn){ verify_ebook($ebook_sn); }else{ verify_all(); } break; } /*-----------秀出結果區--------------*/ $xoopsTpl->assign( "toolbar" , toolbar_bootstrap($interface_menu)) ; include_once XOOPS_ROOT_PATH.'/footer.php'; ?>