:::

6-6 function.php

<?php
//引入TadTools的函式庫
if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php")) {
    redirect_header("http://www.tad0616.net/modules/tad_uploader/index.php?of_cat_sn=50", 3, _TAD_NEED_TADTOOLS);
}
include_once XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php";
include_once XOOPS_ROOT_PATH . "/modules/snews/function_block.php";

include_once XOOPS_ROOT_PATH . "/modules/tadtools/TadUpFiles.php";
$TadUpFiles = new TadUpFiles("snews");

//其他自訂的共同的函數

function mk_html($sn)
{
    global $xoopsDB;
    $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']);

    $content = "<h1>{$snews['title']}</h1>";
    $content .= "<p>{$snews['content']}</p>";

    $html = html5($content);

    file_put_contents(XOOPS_ROOT_PATH . "/uploads/snews/{$sn}.html", $html);
    return $html;
}

function mk_json()
{
    global $xoopsDB, $TadUpFiles;

    $myts = MyTextSanitizer::getInstance();

    $tbl       = $xoopsDB->prefix('snews');
    $sql       = "SELECT * FROM `$tbl` where `focus`=1 ORDER BY `update_time` DESC";
    $result    = $xoopsDB->query($sql) or web_error($sql);
    $all_focus = array();
    while ($snews = $xoopsDB->fetchArray($result)) {
        $content          = str_replace(array("\n", "\r"), '', strip_tags($snews['content']));
        $snews['content'] = word_cut($content, 600);
        $snews['summary'] = word_cut($content, 40);

        $snews['title'] = $myts->htmlSpecialChars($snews['title']);
        $TadUpFiles->set_col('sn', $snews['sn']);
        $snews['cover'] = $TadUpFiles->get_pic_file();
        $all_focus[]    = $snews;
    }

    $json = json_encode($all_focus, JSON_UNESCAPED_UNICODE);

    file_put_contents(XOOPS_ROOT_PATH . "/uploads/snews/focus.json", $json);
    return $html;
}

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1471%26tbsn%3D44

書籍目錄

展開 | 闔起

線上使用者

47人線上 (21人在瀏覽線上書籍)

會員: 0

訪客: 47

更多…