
D:\EmpireServer\web\e\data\ecmseditor\infoeditor

D:\EmpireServer\web\e\data\ecmseditor\infoeditor\epage

后台增加新闻时的界面

查看源代码如上图
<div style="background-color:#D0D0D0"><input type="hidden" id="newstext" name="newstext" value="" style="display:none" /><input type="hidden" id="newstext___Config" value="" style="display:none" /><iframe id="newstext___Frame" src="ecmseditor/infoeditor/editor/fckeditor.html?InstanceName=newstext&classid=6&filepass=1365855227&infoid=0&modtype=0&sinfo=1&Toolbar=Default" width="100%" height="300" frameborder="0" scrolling="no"></iframe><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5">
<tr>
<td bgcolor="#FFFFFF"> <input name="dokey" type="checkbox" value="1" checked>
关键字替换 <input name="copyimg" type="checkbox" id="copyimg" value="1">
远程保存图片(
<input name="mark" type="checkbox" id="mark" value="1">
<a href="SetEnews.php" target="_blank">加水印</a>)
<input name="copyflash" type="checkbox" id="copyflash" value="1">
远程保存FLASH(地址前缀:
<input name="qz_url" type="text" id="qz_url" size="">
)</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><input name="repimgnexturl" type="checkbox" id="repimgnexturl" value="1"> 图片链接转为下一页 <input name="autopage" type="checkbox" id="autopage" value="1"> 自动分页
,每
<input name="autosize" type="text" id="autosize" value="5000" size="5">
个字节为一页 取第
<input name="getfirsttitlepic" type="text" id="getfirsttitlepic" value="" size="1">
张上传图为标题图片(
<input name="getfirsttitlespic" type="checkbox" id="getfirsttitlespic" value="1">
缩略图: 宽
<input name="getfirsttitlespicw" type="text" id="getfirsttitlespicw" size="3" value="105">
*高
<input name="getfirsttitlespich" type="text" id="getfirsttitlespich" size="3" value="118">
)</td>
</tr>
</table>
</div> </div>
修改字段,newstext
在输入表单替换html代码中,会看到
<?=ECMS_ShowEditorVar("newstext",$ecmsfirstpost==1?"":stripSlashes($r[newstext]),"Default","","300","100%")?>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5">
<tr>
<td bgcolor="#FFFFFF"> <input name="dokey" type="checkbox" value="1"<?=$r[dokey]==1?' checked':''?>>
关键字替换 <input name="copyimg" type="checkbox" id="copyimg" value="1">
远程保存图片(
<input name="mark" type="checkbox" id="mark" value="1">
<a href="SetEnews.php" target="_blank">加水印</a>)
<input name="copyflash" type="checkbox" id="copyflash" value="1">
远程保存FLASH(地址前缀:
<input name="qz_url" type="text" id="qz_url" size="">
)</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><input name="repimgnexturl" type="checkbox" id="repimgnexturl" value="1"> 图片链接转为下一页 <input name="autopage" type="checkbox" id="autopage" value="1"> 自动分页
,每
<input name="autosize" type="text" id="autosize" value="5000" size="5">
个字节为一页 取第
<input name="getfirsttitlepic" type="text" id="getfirsttitlepic" value="" size="1">
张上传图为标题图片(
<input name="getfirsttitlespic" type="checkbox" id="getfirsttitlespic" value="1">
缩略图: 宽
<input name="getfirsttitlespicw" type="text" id="getfirsttitlespicw" size="3" value="<?=$public_r[spicwidth]?>">
*高
<input name="getfirsttitlespich" type="text" id="getfirsttitlespich" size="3" value="<?=$public_r[spicheight]?>">
)</td>
</tr>
</table>
<?=ECMS_ShowEditorVar("newstext",$ecmsfirstpost==1?"":stripSlashes($r[newstext]),"Default","","300","100%")?>在输出时自夸替换为
<input type="hidden" id="newstext" name="newstext" value="" style="display:none" /><input type="hidden" id="newstext___Config" value="" style="display:none" /><iframe id="newstext___Frame" src="ecmseditor/infoeditor/editor/fckeditor.html?InstanceName=newstext&classid=6&filepass=1365855227&infoid=0&modtype=0&sinfo=1&Toolbar=Default" width="100%" height="300" frameborder="0" scrolling="no"></iframe>
表格的那段基本未变,只是用了一些配置用的变量。
投稿表单替换html代码
<?=ECMS_ShowEditorVar("newstext",$ecmsfirstpost==1?"":DoReqValue($mid,'newstext',stripSlashes($r[newstext])),"Default","","300","100%")?>
所以,要找到上面两处红色代码对应的函数进行查看,才能进一步理解内部是如何进行替换的。
另外,查看表单的提交目标:
<form name="add" method="post" enctype="multipart/form-data" action="ecmsinfo.php" onsubmit="return EmpireCMSInfoPostFun(document.add,'6');">
找到http://localhost/e/admin/ecmsinfo.php

if($enews=="AddNews")//增加信息
{
$navtheid=(int)$_POST['filepass'];
AddNews($_POST,$logininid,$loginin);
}
elseif($enews=="EditNews")//修改信息
{
$navtheid=(int)$_POST['id'];
EditNews($_POST,$logininid,$loginin);
}
require("../class/hinfofun.php");//即D:\EmpireServer\web\e\class\hinfofun.php
//增加信息
function AddNews($add,$userid,$username){
//修改信息
function EditNews($add,$userid,$username){
因为newstext为新增字段,所以在AddNews中看不到此newstext明文,实际是在此处处理的
$ret_r=ReturnAddF($add,$class_r[$add[classid]][modid],$userid,$username,0,0,1);//返回自定义字段
//主表
$infosql=$empire->query("insert into ".$infotbr['tbname']."(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard".$ret_r['fields'].") values('$id','$add[classid]','$add[ttid]','$add[onclick]',0,'$add[totaldown]','$newspath','$filename','$userid','".addslashes($username)."','$add[firsttitle]','$add[isgood]','$add[ispic]','$add[istop]','$isqf',0,'$add[isurl]','$truetime','$lastdotime','$havehtml','$add[groupid]','$add[userfen]','".addslashes($add[my_titlefont])."','".addslashes($add[titleurl])."','$ret_r[tb]','$public_r[filedeftb]','$public_r[pldeftb]','".addslashes($add[keyboard])."'".$ret_r['values'].");");
//副表
$finfosql=$empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r['datafields'].") values('$id','$add[classid]','$keyid','$add[dokey]','$add[newstempid]','$add[closepl]',0,'".addslashes($add[infotags])."'".$ret_r['datavalues'].");");
$ret_r['datafields']是自定义字段,是用逗号分隔的字段名
$ret_r['datavalues']应该就是用逗号分隔的表单提交的值
中间应该可能会有一项对应newstext和$newstext/ _POST['newstext']
D:\EmpireServer\web\e\class\functions.php中
//返回自定义字段
function ReturnAddF($add,$modid,$userid,$username,$do=0,$rdata=0,$ch=0){
ECMS_ShowEditorVar的位置:
D:\EmpireServer\web\e\data\ecmseditor\infoeditor\fckeditor.php
//变量名,变量值,工具条模式,编辑器目录,高度,宽度
function ECMS_ShowEditorVar($varname,$varvalue,$toolbar='Default',$basepath='',$height='300',$width='100%'){
if(empty($basepath))
{
$basepath='../data/ecmseditor/infoeditor/';
}
if(empty($height))
{
$height='300';
}
if(empty($width))
{
$width='100%';
}
//设置区域
$oFCKeditor=new FCKeditor($varname);
$oFCKeditor->BasePath=$basepath;
$oFCKeditor->Value=$varvalue;
$oFCKeditor->Height=$height;
$oFCKeditor->Width=$width;
$oFCKeditor->ToolbarSet=$toolbar;
//区域的模板变量
$area=$oFCKeditor->CreateHtml();
return $area;
}
这个函数是如何生成如下代码
<input type="hidden" id="newstext" name="newstext" value="" style="display:none" /><input type="hidden" id="newstext___Config" value="" style="display:none" /><iframe id="newstext___Frame" src="ecmseditor/infoeditor/editor/fckeditor.html?InstanceName=newstext&classid=6&filepass=1365855227&infoid=0&modtype=0&sinfo=1&Toolbar=Default" width="100%" height="300" frameborder="0" scrolling="no"></iframe>
<?=ECMS_ShowEditorVar("newstext",$ecmsfirstpost==1?"":DoReqValue($mid,'newstext',stripSlashes($r[newstext])),"Default","","300","100%")?>
变量名,变量值,工具条模式,编辑器目录,高度,宽度