以下是主文件index.php的内容:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <BR><?php <BR>require('./global.php'); <BR>require('./smarty/libs/Smarty.class.php'); <BR>require('./mysql.php'); <BR>require('./FCKeditor/fckeditor.php'); <BR>$action=$_REQUEST['action']; <BR>//定义一个函数用于调用FCK <BR>function editor($input_name, $input_value) <BR>{ <BR>global $smarty; <BR>$editor = new FCKeditor($input_name) ; <BR>$editor->BasePath = "./FCKeditor/";//指定编辑器路径 <br><br>$editor->ToolbarSet = "Default";//编辑器工具栏有Basic(基本工具),Default(所有工具)选择 <BR>$editor->Width = "100%"; <BR>$editor->Height = "320"; <BR>$editor->Value = $input_value; <BR>$editor->Config['AutoDetectLanguage'] = true ; <BR>$editor->Config['DefaultLanguage'] = 'en' ;//语言 <BR>$FCKeditor = $editor->CreateHtml(); <br><br>$smarty->assign("editor", $FCKeditor);//指定区域 <BR>} <br><br>switch ($action){ <br><br>case 'addnewsview': <br><br> $smarty= new Smarty(); <BR> $smarty->template_dir = './template'; <BR> $smarty->compile_dir = './smarty/templates_c'; <BR> $smarty->assign('page_title','新建新闻'); <BR> $smarty->assign('actionvalue','addnews'); <BR> editor('content','');//调用编辑器,并定义文本域名为content(与下面addnews中的$_REQUEST['content']对应 <BR> $smarty->display('addnews.htm'); <BR>break; <br><br>case 'addnews': <BR> $title=$_REQUEST['title']; <BR> $content=$_REQUEST['content']; <BR> $db=new mysql(); <BR> $button=$_REQUEST['Submit']; <br><br> if(empty($title) || empty($content)){ <BR> echo "请填写完成!<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=./index.php?action=addnewsview\">"; <BR> }else{ <BR> $sql="insert into news values(id,'admin','$title','$content',NOW())"; <BR> $db->query_exec($sql); <BR> echo "操作成功!<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=./index.php\">"; <BR> } <BR>break; <br><br>case 'editnewsview': <BR> $smarty= new Smarty(); <BR> $smarty->template_dir = './template'; <BR> $smarty->compile_dir = './smarty/templates_c'; <BR> $smarty->assign('page_title','修改新闻'); <BR> $smarty->assign('actionvalue','addnews'); <BR> $id=$_REQUEST['id']; <br><br> $query="select * from news where id=$id"; <BR> $db=new mysql(); <BR> $result = $db->query_exec($query); <BR> $rs = $result-> fetch_assoc(); <br><br> $smarty->assign('title',$rs['title']); <BR> //$smarty->assign('content',$rs['content']); <BR> $smarty->assign('actionvalue','editnews'); <BR> $smarty->assign('id',$rs['id']); <BR> editor('content',$rs['content']); <BR> $smarty->display('addnews.htm'); <BR>break; <br><br>case 'editnews': <BR> $title=$_REQUEST['title']; <BR> $content=$_REQUEST['content']; <BR> $id=$_REQUEST['id']; <br><br> $button=$_REQUEST['Submit']; <BR> $db=new mysql(); <BR> if ($button=='提交'){ <BR> $sql="update news set title='$title',content='$content',date=NOW() where id=$id"; <BR> $db->query_exec($sql); <BR> echo "操作成功!<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=./index.php\">"; <BR> } <BR>break; <br><br>case 'delnews': <BR> $db=new mysql(); <BR> if ($checkbox!="" or count($checkbox)!=0) { <BR> for ($i=0;$i<count($checkbox);$i++){ <BR> $db->query_exec("delete from news where id='$checkbox[$i]'"); <BR> } <BR> } <BR> echo "操作成功!<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"<p style="color:transparent">本文来源gao!%daima.com搞$代*!码$网3</p><strong>搞代gaodaima码</strong>1; URL=./index.php\">"; <BR>break; <br><br>default: <BR> $smarty= new Smarty(); <BR> $smarty->template_dir = './template'; <BR> $smarty->compile_dir = './smarty/templates_c'; <BR> $smarty->assign('page_title','新闻管理'); <BR> $smarty->assign('actionvalue','delnews'); <br><br> $query="select * from news"; <BR> $db=new mysql(); <BR> $result = $db->query_exec($query); <br><br> while ($rs = $result-> fetch_assoc()) { <BR> $array[]= array("id"=>$rs['id'], "title"=>$rs['title'],"date"=>$rs['date']); <BR> $smarty->assign('news',$array); <BR> } <br><br> $smarty->display('index.htm'); <br><br>} <BR>?> <br><br>以下是模板文件index.htm的内容 <BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" <BR>"http://www.w3.org/TR/html4/loose.dtd"> <BR> <BR> <BR><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <BR><title>{$page_title}</title> <br><br> <br><br><body> <BR><p class="style1">新闻管理</p> <BR><hr> <BR><table width="771" border="0"> <BR> <tr> <BR> <td height="62"><div align="center">系统管理
标题 | 日期 | 选择 |
{$news[news].title} | {$news[news].date} |