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); $TadUpFiles->set_col('snews', $sn); $snews['files'] = $TadUpFiles->show_files(); // die(var_dump($snews)); $xoopsTpl->assign('snews', $snews); if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php")) { redirect_header("index.php", 3, _MA_NEED_TADTOOLS); } include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php"; $sweet_alert = new sweet_alert(); $sweet_alert->render("snews_del", "index.php?op=snews_delete&sn=", 'sn'); } //顯示列表 function snews_list() { global $xoopsTpl, $xoopsDB, $TadUpFiles; $myts = MyTextSanitizer::getInstance(); $tbl = $xoopsDB->prefix('snews'); $sql = "SELECT * FROM `$tbl` ORDER BY `update_time` DESC"; //getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項); $PageBar = getPageBar($sql, 3, 10); $bar = $PageBar['bar']; $sql = $PageBar['sql']; $total = $PageBar['total']; $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'); $all[] = $snews; } $xoopsTpl->assign('all', $all); $xoopsTpl->assign('bar', $bar); $xoopsTpl->assign('total', $total); } //刪除內容 function snews_delete($sn) { global $xoopsTpl, $xoopsDB, $TadUpFiles; $tbl = $xoopsDB->prefix('snews'); $sql = "DELETE FROM `$tbl` WHERE `sn` = '{$sn}'"; $xoopsDB->queryF($sql) or web_error($sql); $TadUpFiles->set_col('sn', $sn); $TadUpFiles->del_files(); $TadUpFiles->set_col('snews', $sn); $TadUpFiles->del_files(); } /*-----------執行動作判斷區----------*/ 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 "tufdl": $files_sn = isset($_GET['files_sn']) ? intval($_GET['files_sn']) : ""; $TadUpFiles->add_file_counter($files_sn, false, true); exit; case "snews_delete": snews_delete($sn); header("location: index.php"); 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'; ```
進階搜尋
61人線上 (16人在瀏覽線上書籍)
會員: 0
訪客: 61