:::

MarkDown

發布日期 是否公開 否 排序 $token "; /* 所屬分類 cate_sn 文章標題 note_title 文章內容 note_content 發布日期 note_date 是否公開 note_public 排序 note_sort */ return $main; } //儲存文章 function save(){ global $xoopsDB , $xoopsUser; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("
" , $GLOBALS['xoopsSecurity']->getErrors()); redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $_POST['note_title'] = $myts->addSlashes($_POST['note_title']); $_POST['note_content'] = $myts->addSlashes($_POST['note_content']); $_POST['note_date'] = $myts->addSlashes($_POST['note_date']); $_POST['note_sort'] = $myts->addSlashes($_POST['note_sort']); $uid = empty($xoopsUser)? 0 : $xoopsUser->uid(); $sql="insert into ".$xoopsDB->prefix("tad_notes")." (`cate_sn`, `note_title`, `note_content`, `note_date`, `note_public`, `note_count`, `uid`, `note_sort`) values('{$_POST['cate_sn']}' , '{$_POST['note_title']}' , '{$_POST['note_content']}' , '{$_POST['note_date']}' , '{$_POST['note_public']}' , '0' , '{$uid}' , '{$_POST['note_sort']}')"; $xoopsDB->query($sql) or redirect_header('index.php', 3, mysql_error()); } //工具列 function toolbar(){ $main="新增記事"; return $main; } //取得最大排序 function get_max_sort(){ global $xoopsDB; $sql="select max(`note_sort`) from ".$xoopsDB->prefix("tad_notes")." where `note_public`='1'"; $result=$xoopsDB->query($sql) or redirect_header('index.php', 3, mysql_error()); list($max_sort)=$xoopsDB->fetchRow($result); return ++$max_sort; } //顯示文章列表或單一文章 function show_doc($note_sn=''){ global $xoopsDB,$xoopsUser,$xoopsModuleConfig; $now_uid=($xoopsUser)?$xoopsUser->uid():""; $myts =& MyTextSanitizer::getInstance(); if(empty($note_sn)){ $sql="select * from ".$xoopsDB->prefix("tad_notes")." where `note_public`='1' order by note_sort"; //PageBar(資料數, 每頁顯示幾筆資料, 最多顯示幾個頁數選項); $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error()); $total=$xoopsDB->getRowsNum($result); $navbar = new PageBar($total,$xoopsModuleConfig['show_num'], 10); $mybar = $navbar->makeBar(); $bar= sprintf(_BP_TOOLBAR,$mybar['total'],$mybar['current'])."{$mybar['left']}{$mybar['center']}{$mybar['right']}"; $sql.=$mybar['sql']; //分頁工具列為 $bar $result=$xoopsDB->query($sql) or redirect_header('index.php', 3, mysql_error()); $main=""; while($doc=$xoopsDB->fetchArray($result)){ $doc['note_title'] = $myts->htmlSpecialChars($doc['note_title']); $doc['note_date'] = $myts->htmlSpecialChars($doc['note_date']); $tool=($doc['uid']==$now_uid)?"刪除 | 修改":""; $main.=""; } $main.="
{$doc['note_title']} {$doc['note_date']} {$tool}
$bar
"; }else{ $sql="select * from ".$xoopsDB->prefix("tad_notes")." where `note_sn`='$note_sn' and `note_public`='1'"; $result=$xoopsDB->query($sql) or redirect_header('index.php', 3, mysql_error()); $doc=$xoopsDB->fetchArray($result); $doc['note_title'] = $myts->htmlSpecialChars($doc['note_title']); $doc['note_date'] = $myts->htmlSpecialChars($doc['note_date']); $doc['note_content'] = $myts->displayTarea($doc['note_content'], 1, 1, 0, 1, 0); $main="

{$doc['note_title']}

".sprintf(_MD_TADNOTE_POST_DATE,$doc['note_date'])."
{$doc['note_content']}
"; } return $main; } //刪除函數 function del_note($note_sn=null){ global $xoopsDB; $sql="delete from ".$xoopsDB->prefix("tad_notes")." where note_sn='$note_sn'"; $xoopsDB->queryF($sql) or redirect_header('index.php', 3, mysql_error()); } function update(){ global $xoopsDB , $xoopsUser; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("
" , $GLOBALS['xoopsSecurity']->getErrors()); redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $_POST['note_title'] = $myts->addSlashes($_POST['note_title']); $_POST['note_content'] = $myts->addSlashes($_POST['note_content']); $_POST['note_date'] = $myts->addSlashes($_POST['note_date']); $_POST['note_sort'] = $myts->addSlashes($_POST['note_sort']); $uid = empty($xoopsUser)? 0 : $xoopsUser->uid(); $sql="update ".$xoopsDB->prefix("tad_notes")." set `cate_sn`='{$_POST['cate_sn']}' , `note_title`='{$_POST['note_title']}', `note_content`='{$_POST['note_content']}', `note_date`='{$_POST['note_date']}', `note_public`='{$_POST['note_public']}', `note_sort`='{$_POST['note_sort']}' where `note_sn`='{$_POST['note_sn']}'"; $xoopsDB->queryF($sql) or redirect_header('index.php', 3, mysql_error()); } /*** 流程判斷 ***/ $op = empty($_REQUEST['op'])? "" : $_REQUEST['op']; $note_sn = empty($_REQUEST['note_sn'])? "" : intval($_REQUEST['note_sn']); switch($op){ case "del": del_note($note_sn); header("location:index.php"); break; case "modify": $main=add_form($note_sn); break; case "save": save(); header("location:index.php"); break; case "update": update(); header("location:index.php"); break; case "add_form": $main=add_form(); break; default: $main=show_doc($note_sn); break; } /*** 輸出 ***/ $current1=($_SERVER['REQUEST_URI']=="/~tad0616/modules/tad_note/index.php")?"class='current'":""; $current2=($_SERVER['REQUEST_URI']=="/~tad0616/modules/tad_note/index.php?op=add_form")?"class='current'":""; echo " "; echo $main; include_once XOOPS_ROOT_PATH.'/footer.php'; ?> ```
:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fmarkdown.php%3Ftbdsn%3D629

書籍目錄

展開 | 闔起

線上使用者

52人線上 (6人在瀏覽線上書籍)

會員: 0

訪客: 52

更多…