:::

8-8 /index.php

<?php
/*-----------引入檔案區--------------*/
include_once "header.php";
$xoopsOption['template_main'] = set_bootstrap("tad_ebook_index.html");
include_once XOOPS_ROOT_PATH."/header.php";

/*-----------function區--------------*/

//顯示預設頁面內容
function show_page($page_sn=""){
  global $xoopsTpl ,$xoopsDB;

  $tbl=$xoopsDB->prefix('tad_ebook_page');

  //新增計數器
  $sql="update {$tbl} set `page_counter`= `page_counter` + 1 where `page_sn`='{$page_sn}'";
  $xoopsDB->queryF($sql) or redirect_header("index.php",3, mysql_error());

  $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', 'show_page');
}

//顯示所有期數列表
function show_all(){
  global $xoopsTpl ,$xoopsDB;
  //單一檔案真實路徑:
  include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ;
  $TadUpFiles=new TadUpFiles("tad_ebook");


  $today=date("Y-m-d");
  $tbl=$xoopsDB->prefix('tad_ebook');
  $sql="select * from `{$tbl}` where `ebook_publish_date` <= '{$today}'  order by `ebook_publish_date` desc";

  $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error());

  $i=0;
  while($ebook=$xoopsDB->fetchArray($result)){

    $all_ebook[$i]=$ebook;

    $TadUpFiles->set_col('ebook_sn',$ebook['ebook_sn']);
    $all_ebook[$i]['ebook_pic']=$TadUpFiles->get_pic_file('thumb');

    $i++;
  }

  //die(var_export($all_ebook));
  $xoopsTpl->assign('all_ebook',$all_ebook);
  $xoopsTpl->assign('op', 'show_all');
}


//顯示某期文章列表
function show_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', 'show_ebook');
}


/*-----------執行動作判斷區----------*/
$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']);

switch($op){

  // case "xxx":
  // xxx();
  // header("location:{$_SERVER['PHP_SELF']}");

  default:
  if($page_sn){
    show_page($page_sn);
  }elseif($ebook_sn){
    show_ebook($ebook_sn);
  }else{
    show_all();
  }

  break;
}

/*-----------秀出結果區--------------*/
$xoopsTpl->assign( "toolbar" , toolbar_bootstrap($interface_menu)) ;
include_once XOOPS_ROOT_PATH.'/footer.php';
?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D37%26tbdsn%3D1179

書籍目錄

展開 | 闔起

線上使用者

45人線上 (14人在瀏覽線上書籍)

會員: 0

訪客: 45

更多…