博客系统文章的数据库存储方式
在通常的博客系统中,我们发表文章的时候,在数据库中存储的一般不仅仅是文章的文字,还包括文章的样式,而且很多时候都是所见即所得的效果。这就要求我们以html+文字这样存进数据库中,通过查找资料,可以用专门的文字编辑器可以实现,使用方法如下:
FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器。它志于轻量化,不需要太复杂的安装步骤即可使用。它可和PHP、JavaScript、ASP、ASP.NET、ColdFusion、Java、以及ABAP等不同的编程语言相结合。“FCKeditor”名称中的“FCK” 是这个编辑器的作者的名字Frederico Caldeira Knabben的缩写。
ContentLangDirection="ltr/rtl" 默认文字方向
CustomConfigurationsPath="" 自定义配置文件路径和名称
Debug=true/false 是否开启调试功能,这样,当调用FCKDebug.Output()时,会在调试窗中输出内容
EnableSourceXHTML=true/false 为TRUE时,当由可视化界面切换到代码页时,把HTML处理成XHTML
EnableXHTML=true/false 是否允许使用XHTML取代HTML
FillEmptyBlocks=true/false 使用这个功能,可以将空的块级元素用空格来替代
FontColors="" 设置显示颜色拾取器时文字颜色列表
FontFormats="" 设置显示在文字格式列表中的命名
ForcePasteAsPlainText=true/false 强制粘贴为纯文本
ForceSimpleAmpersand=true/false 是否不把&符号转换为XML实体
FormatIndentator="" 当在源码格式下缩进代码使用的字符
FormatOutput=true/false 当输出内容时是否自动格式化代码
FormatSource=true/false 在切换到代码视图时是否自动格式化代码
FullPage=true/false 是否允许编辑整个HTML文件,还是仅允许编辑BODY间的内容
GeckoUseSPAN=true/false 是否允许SPAN标记代替B,I,U标记
IeSpellDownloadUrl=""下载拼写检查器的网址
ImageBrowser=true/false 是否允许浏览服务器功能
ImageBrowserURL="" 浏览服务器时运行的URL
ImageBrowserWindowHeight="" 图像浏览器窗口高度
ImageBrowserWindowWidth="" 图像浏览器窗口宽度
LinkBrowser=true/false 是否允许在插入链接时浏览服务器
LinkBrowserURL="" 插入链接时浏览服务器的URL
LinkBrowserWindowHeight=""链接目标浏览器窗口高度
LinkBrowserWindowWidth=""链接目标浏览器窗口宽度
SpellChecker="ieSpell/Spellerpages" 设置拼写检查器
StartupFocus=true/false 开启时FOCUS到编辑器
StylesXmlPath="" 设置定义CSS样式列表的XML文件的位置
ToolBarCanCollapse=true/false 是否允许展开/折叠工具栏
ToolbarSets=object 允许使用TOOLBAR集合
ToolbarStartExpanded=true/false 开启是TOOLBAR是否展开
UseBROnCarriageReturn=true/false 当回车时是产生BR标记还是P或者DIV标记
在PHP中调用
<?php
function FCKeditor_IsCompatibleBrowser()
{
if ( isset( $_SERVER ) ) {
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
}
else {
global $HTTP_SERVER_VARS ;
if ( isset( $HTTP_SERVER_VARS ) ) {
$sAgent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ;
}
else {
global $HTTP_USER_AGENT ;
$sAgent = $HTTP_USER_AGENT ;
}
}
if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
{
$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
return ($iVersion >= 5.5) ;
}
else if ( strpos($sAgent, 'Gecko/') !== false )
{
$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
return ($iVersion >= 20030210) ;
}
else if ( strpos($sAgent, 'Opera/') !== false )
{
$fVersion = (float)substr($sAgent, strpos($sAgent, 'Opera/') + 6, 4) ;
return ($fVersion >= 9.5) ;
}
else if ( preg_match( "|AppleWebKit/(/d+)|i", $sAgent, $matches ) )
{
$iVersion = $matches[1] ;
return ( $matches[1] >= 522 ) ;
}
else
return false ;
}
class FCKeditor
{
public $InstanceName ;
public $BasePath ;
public $Width ;
public $Height ;
public $ToolbarSet ;
public $Value ;
public $Config ;
public function __construct( $instanceName )
{
$this->InstanceName = $instanceName ;
$this->BasePath = '../common/editor/' ;
$this->Width = '100%' ;
$this->Height = '400' ;
$this->ToolbarSet = 'Default' ;
$this->Value = '' ;
$this->Config = array() ;
}
public function Create()
{
echo $this->CreateHtml() ;
}
public function CreateHtml()
{
$HtmlValue = htmlspecialchars( $this->Value ) ;
$Html = '' ;
if ( $this->IsCompatible() )
{
if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
$File = 'fckeditor.original.html' ;
else
$File = 'fckeditor.html' ;
$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
if ( $this->ToolbarSet != '' )
$Link .= "&Toolbar={$this->ToolbarSet}" ;
$Html .= "<input type=/"hidden/" id=/"{$this->InstanceName}/" name=/"{$this->InstanceName}/" value=/"{$HtmlValue}/" style=/"display:none/" />" ;
$Html .= "<input type=/"hidden/" id=/"{$this->InstanceName}___Config/" value=/"" . $this->GetConfigFieldString() . "/" style=/"display:none/" />" ;
$Html .= "<iframe id=/"{$this->InstanceName}___Frame/" src=/"{$Link}/" width=/"{$this->Width}/" height=/"{$this->Height}/" frameborder=/"0/" scrolling=/"no/"></iframe>" ;
}
else
{
if ( strpos( $this->Width, '%' ) === false )
$WidthCSS = $this->Width . 'px' ;
else
$WidthCSS = $this->Width ;
if ( strpos( $this->Height, '%' ) === false )
$HeightCSS = $this->Height . 'px' ;
else
$HeightCSS = $this->Height ;
$Html .= "<textarea name=/"{$this->InstanceName}/" rows=/"4/" cols=/"40/" style=/"width: {$WidthCSS}; height: {$HeightCSS}/">{$HtmlValue}</textarea>" ;
}
return $Html ;
}
public function IsCompatible()
{
return FCKeditor_IsCompatibleBrowser() ;
}
public function GetConfigFieldString()
{
$sParams = '' ;
$bFirst = true ;
foreach ( $this->Config as $sKey => $sValue )
{
if ( $bFirst == false )
$sParams .= '&' ;
else
$bFirst = false ;
if ( $sValue === true )
$sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
else if ( $sValue === false )
$sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
else
$sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
}
return $sParams ;
}
public function EncodeConfig( $valueToEncode )
{
$chars = array(
'&' => '%26',
'=' => '%3D',
'"' => '%22' ) ;
return strtr( $valueToEncode, $chars ) ;
}
}
$editor = new FCKeditor('editor') ;//接收时$_POST['........']中的内容
$editor->BasePath = "../common/editor/";//FCKEDITOR的路径
?>
在需要调用的地方<?php $editor->Create();?>
接受的文件用$_POST['editor']调用(editor)可在$editor = new FCKeditor('editor')设置
<!--#include file="../fckeditor.asp"-->
Set oFCKeditor = New FCKeditor
oFCKeditor.ToolbarSet = "A" ’使用工具条
oFCKeditor.Create "content" ’文本框名称
<servlet-name>Connector</servlet-name>
net.fckeditor.connector.ConnectorServlet
<load-on-startup>1</load-on-startup>
<servlet-name>Connector</servlet-name>
/fckeditor/editor/filemanager/connectors/*
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<body style="text-align: center;">
<form action="ShowData.jsp" method="post">
<FCK:editor instanceName="test" height="400pt">
<jsp:attribute name="value"> 这里是http://baike.baidu.com/">数据测试
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
RemoveFormat="清除格式(清除现在文本的格式)"
找到第40行 FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ; 即在编辑器域内可以使用Tab键。
FCKConfig.ToolbarSets["Basic"] = [
这是我改过的Basic,把图像功能去掉,把添加链接功能去掉,因为图像和链接和flash和图像按钮添加功能都能让前台页直接访问和上传文件,要是这儿不改直接给你上传个木马还不马上玩完?
FCKConfig.ToolbarSets["Default"] = [//Default工具条的名称
[’Source’,’DocProps’,’-’,’Save’,’NewPage’,’Preview’,’-’,’Templates’],
[’Cut’,’Copy’,’Paste’,’PasteText’,’PasteWord’,’-’,’Print’,’SpellCheck’],
[’Undo’,’Redo’,’-’,’Find’,’Replace’,’-’,’SelectAll’,’RemoveFormat’],
[’Form’,’Checkbox’,’Radio’,’TextField’,’Textarea’,’Select’,’Button’,’ImageButton’,’HiddenField’],
[’Bold’,’Italic’,’Underline’,’StrikeThrough’,’-’,’Subscript’,’Superscript’],
[’OrderedList’,’UnorderedList’,’-’,’Outdent’,’Indent’],
[’JustifyLeft’,’JustifyCenter’,’JustifyRight’,’JustifyFull’],
[’Image’,’Flash’,’Table’,’Rule’,’Smiley’,’SpecialChar’,’PageBreak’],
[’Style’,’FontFormat’,’FontName’,’FontSize’],
目前FCKeditor已发展到3.0,并更名为CKEditor,最新版本是CKEditor 3.6。
CKEditor是FCKeditor的一个完全重写版本,加载更快更方便使用。
◆The integration pack is now managed by Maven 2 with complete documentation and reports.
◆Automatic creation of release distribution files (assemblies).
◆The library runs now from Servlet 2.4/JSP 2.0 and above.
◆The Server Side Integration requirements are completely fulfilled.
◆The SimpleUploaderServlet functionality has been merged into the ConnectorServlet.
◆The JSP tag library has been completely restructured.
◆A more complete and reliable browser detection code.
★No configuration settings in the web.xml anymore.
★The configuration properties can be set in a common properties file or programmatically.
★'Convention over conversion', just reset the properties which don't meet your requirements.
◆Introduced the state-of-the-art SLF4J logging facade.
◆JUnit test coverage on viable classes.
◆Clean and safe parameter handling and abstraction.
◆A lot of code performance improvements and tweaks.
博客系统文章的数据库存储方式相关推荐
- ***博客系统文章的数据库存储方式
在通常的博客系统中,我们发表文章的时候,在数据库中存储的一般不仅仅是文章的文字,还包括文章的样式,而且很多时候都是所见即所得的效果.这就要求我们以html+文字这样存进数据库中,通过查找资料,可以用专 ...
- [java手把手教程][第二季]java后端博客系统文章系统——No10
项目github地址:github.com/pc859107393- 实时项目同步的地址是国内的码云:git.oschina.net/859107393/m- 我的简书首页是:www.jianshu. ...
- php博客系统 加载评论,Yii实现单用户博客系统文章详情页插入评论表单的方法...
本文实例讲述了Yii实现单用户博客系统文章详情页插入评论表单的方法.分享给大家供大家参考,具体如下: action部分: function test($objs) { $objs->var=10 ...
- java网络文章博客抓取系统_java 后端博客系统文章系统——No3
工具 IDE为idea16* JDK环境为1.8 gradle构建,版本:2.14.1 Mysql版本为5.5.27 Tomcat版本为7.0.52 流程图绘制(xmind) 建模分析软件PowerD ...
- 在线博客系统——文章详情(redis incr自增实现增加阅读数和评论数)
目录 文章详情 接口说明 编码实现 Controller控制层 Service业务逻辑层 前端测试 redis incr自增实现浏览量 Redis配置类 Redis工具类 Dao持久层准备 Mappe ...
- java网络文章博客抓取系统_java 后端博客系统文章系统——No6
工具 IDE为idea16 JDK环境为1.8 gradle构建,版本:2.14.1 Mysql版本为5.5.27 Tomcat版本为7.0.52 流程图绘制(xmind) 建模分析软件PowerDe ...
- 02-大鸭梨博客系统数据库设计及Dapper的使用
毫无疑问,数据库的设计在一个系统中起了至关重要的作用.我们都知道,系统设计分为两部分,或者说是两个阶段,即数据库设计和功能设计.构建一个完善的系统需要这两个阶段的充分考量.周密设计.合理联接以及密切配 ...
- (附源码)springboot掌上博客系统 毕业设计 063131
Springboot掌上博客系统的设计与实现 摘 要 掌上博客系统是当今网络的热点,博客技术的出现使得每个人可以零成本.零维护地创建自己的网络媒体,Blog站点所形成的网状结构促成了不同于以往社区的B ...
- springboot基于vue.js的掌上博客系统的设计与实现毕业设计源码063131
Springboot掌上博客系统的设计与实现 摘 要 掌上博客系统是当今网络的热点,博客技术的出现使得每个人可以零成本.零维护地创建自己的网络媒体,Blog站点所形成的网状结构促成了不同于以往社区的B ...
最新文章
- selenium+Python(鼠标和键盘事件)
- hexdump——Linux系统的二进制文件查看工具
- .NET环境下每日集成
- linux系统利用可执行文件的Capabilities实现权限提升
- 在重复3次的数组中查找
- Eclipse MicroProfile:您需要了解的5件事
- [html] html如何启动本地的exe应用?
- 4-[函数]- 独立功能的代码块
- SRL——无人机区域定位系统
- Nvidia搞笑Intel:CPU vs GPU
- 电脑ping,怎么ping网速,详细教您ping网络的方法
- 我的四年大学生活总结
- SAP Fiori 的附件处理(Attachment handling)
- VTT到底需要多少个电容
- 携程 | 组织架构如何影响项目管理
- inaturalist昆虫数据集
- microduino实现红外线发送与接收
- 5G NR QC-LDPC MATLAB程序理解
- 操作系统64位和32位的区别。
- A-level Computer Science 计算机科学学习笔记/经验分享/教学 (1):考试流程和大纲
热门文章
- 《STK基础教程》首发
- ad15原理图中变压器种类_简单高效1.5v升压电路图大全(七款1.5v升压电路设计原理图详解)...
- html绘制坐标曲线,Word2010中怎么绘制曲线坐标图?
- 基于Https协议返回Jason字符串
- 企业经营数据分析非得BI不可吗?
- 阮一峰ES6读书笔记
- 安卓下的c语言ide,C语言编译器IDE安卓版下载-C语言编译器IDE下载v1.7 最新版-腾牛安卓网...
- 人工智能——DBSCAN密度聚类(Python)
- Axure原型创建折线、柱状等图形,引用echarts
- 接口测试要点及用例设计