:::

8-3 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 snews_focus()
{
    global $xoopsTpl, $xoopsDB, $TadUpFiles;

    $json = file_get_contents(XOOPS_URL . "/uploads/snews/focus.json");
    // $json      = file_get_contents("http://stu.tncomu.tn.edu.tw/~cie/uploads/snews/focus.json");
    $all_focus = json_decode($json, true);
    $xoopsTpl->assign('all_focus', $all_focus);
}



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 `sort`,`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%2Fmail.tad0616.cp27.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1491%26tbsn%3D44

書籍目錄

展開 | 闔起

線上使用者

322人線上 (128人在瀏覽線上書籍)

會員: 0

訪客: 322

更多…