MarkDown
設定密碼:
是否發布?
";
return $main;
}
//執行儲存動作
function insert_article(){
//過濾姓名
$stud_name=trim($_POST['stud_name']);
$stud_name=strip_tags($stud_name);
$stud_name = (! get_magic_quotes_gpc()) ? addslashes($stud_name) : $stud_name;
$stud_name=htmlspecialchars($stud_name);
//過濾內容
$_POST['content'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['content']) : $_POST['content'];
$_POST['content']=htmlspecialchars($_POST['content']);
//過濾密碼
$_POST['text_passwd'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['text_passwd']) : $_POST['text_passwd'];
$class_sn=intval($_POST['class_sn']);
$sql="INSERT INTO `tncomu_article`(`stud_name`, `content`, `post_time`, `enable`, `class_sn`, `mode`, `text_passwd`) VALUES ('{$stud_name}' , '{$_POST['content']}' , now(), '{$_POST['enable']}', '{$class_sn}', '文字', '{$_POST['text_passwd']}')";
mysql_query($sql) or die(mysql_error().$sql);
return "儲存完畢";
}
//執行更新動作
function update_article($sn=''){
if($sn){
//設定SQL語法
$sql="select text_passwd from `tncomu_article` where sn='{$sn}'";
//執行SQL語法
$result=mysql_query($sql) or die("無法執行:".mysql_error());
//擷取資料回來存到 $data
list($text_passwd)=mysql_fetch_row($result);
if($text_passwd!=$_POST['text_passwd'] or empty($_POST['text_passwd'])){
return;
}
}
//過濾姓名
$stud_name=trim($_POST['stud_name']);
$stud_name=strip_tags($stud_name);
$stud_name = (! get_magic_quotes_gpc()) ? addslashes($stud_name) : $stud_name;
$stud_name=htmlspecialchars($stud_name);
//過濾內容
$_POST['content'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['content']) : $_POST['content'];
$_POST['content']=htmlspecialchars($_POST['content']);
//過濾密碼
$_POST['text_passwd'] = (! get_magic_quotes_gpc()) ? addslashes($_POST['text_passwd']) : $_POST['text_passwd'];
$class_sn=intval($_POST['class_sn']);
$sql="update `tncomu_article` set `stud_name`='{$stud_name}', `content`='{$_POST['content']}', `post_time`=now(), `enable`='{$_POST['enable']}', `class_sn`='{$_POST['class_sn']}' where `sn`='{$sn}'";
mysql_query($sql) or die(mysql_error().$sql);
return "儲存完畢";
}
//刪除文章資料
function delete_article($sn=null){
//設定SQL語法
$sql="delete from `tncomu_article` where sn='{$sn}'";
//執行SQL語法
mysql_query($sql) or die("無法執行:".mysql_error());
//執行完轉向
header("location: {$_SERVER['PHP_SELF']}");
}
?>
```