:::

3-1 index.php

<?php
/*-----------引入檔案區--------------*/
include_once "header.php";
$xoopsOption['template_main'] = "snews_index.tpl";
include_once XOOPS_ROOT_PATH . "/header.php";

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

//顯示內容
function snews_show($sn)
{
    global $xoopsTpl, $xoopsDB, $TadUpFiles;

    $myts = MyTextSanitizer::getInstance();

    $tbl    = $xoopsDB->prefix('snews');
    $sql    = "SELECT * FROM `$tbl` WHERE `sn` = '{$sn}'";
    $result = $xoopsDB->query($sql) or web_error($sql);
    $snews  = $xoopsDB->fetchArray($result);

    $snews['content']  = $myts->displayTarea($snews['content'], 1, 0, 0, 0, 0);
    $snews['title']    = $myts->htmlSpecialChars($snews['title']);
    $snews['username'] = $myts->htmlSpecialChars($snews['username']);

    $TadUpFiles->set_col('sn', $sn);
    $snews['cover'] = $TadUpFiles->show_files('pic', false, '', true, null, null, null, true);

    $TadUpFiles->set_col('snews', $sn);
    $TadUpFiles->set_hash(false);
    $snews['files'] = $TadUpFiles->show_files();

    // die(var_dump($snews));
    $xoopsTpl->assign('snews', $snews);
}

//顯示列表
function snews_list()
{
    global $xoopsTpl, $xoopsDB, $TadUpFiles;

    $myts = MyTextSanitizer::getInstance();

    $tbl    = $xoopsDB->prefix('snews');
    $sql    = "SELECT * FROM `$tbl` ORDER BY `update_time` DESC";
    $result = $xoopsDB->query($sql) or web_error($sql);
    $all    = array();
    while ($snews = $xoopsDB->fetchArray($result)) {
        $snews['content']  = $myts->displayTarea($snews['content'], 1, 0, 0, 0, 0);
        $snews['title']    = $myts->htmlSpecialChars($snews['title']);
        $snews['username'] = $myts->htmlSpecialChars($snews['username']);

        $TadUpFiles->set_col('sn', $snews['sn']);
        $snews['cover'] = $TadUpFiles->get_pic_file('thumb', null, null, true);
        $all[]          = $snews;
    }
    $xoopsTpl->assign('all', $all);
}

/*-----------執行動作判斷區----------*/
include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php');
$op = system_CleanVars($_REQUEST, 'op', '', 'string');
$sn = system_CleanVars($_REQUEST, 'sn', 0, 'int');

switch ($op) {

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

    default:
        if ($sn) {
            snews_show($sn);
            $op = "snews_show";
        } else {
            snews_list();
            $op = "snews_list";
        }
        break;
}

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

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Fmail.tad0616.cp27.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1440%26tbsn%3D44

書籍目錄

展開 | 闔起

線上使用者

341人線上 (139人在瀏覽線上書籍)

會員: 0

訪客: 341

更多…