• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

实例(Smarty+FCKeditor新闻系统)_php实例

php 搞代码 4年前 (2022-01-26) 27次浏览 已收录 0个评论

以下是主文件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">系统管理









{section name=news loop=$news}






{/section}

标题 日期 选择
{$news[news].title} {$news[news].date}



搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:实例(Smarty+FCKeditor新闻系统)_php实例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址