欢迎各位兄弟 发布技术文章
这里的技术是共享的
<?php
require_once '../php/config.php';
require_once(DEDEINC."/dedetag.class.php");
require_once(DEDEINC."/userlogin.class.php");
require_once(DEDEINC."/customfields.func.php");
require_once(DEDEMEMBER."/inc/inc_catalog_options.php");
require_once(DEDEMEMBER."/inc/inc_archives_functions.php");
require_once '../php/safe.php';
//$channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 1;
$mtypesid = isset($mtypesid) && is_numeric($mtypesid) ? $mtypesid : 0;
$menutype = 'content';
error_reporting(0);
/*-------------
function _ShowForm(){ }
--------------*/
if(empty($dopost))
{
$cInfos = $dsql->GetOne("Select * From `#@__channeltype` where id='$channelid'; ");
include(DEDETEMPLATE."/".$cfg_df_style."/"."yqlj-pre.htm");
}
/*------------------------------
function _SaveArticle(){ }
------------------------------*/
else if($dopost=='save')
{
//include(DEDEMEMBER.'/inc/archives_check_gonghui.php');
include(DEDEMEMBER.'/inc/archives_chech_zaixiangbaoming.php');
//分析处理附加表数据
$inadd_f = $inadd_v = '';
if(!empty($dede_addonfields))
{
$addonfields = explode(';',$dede_addonfields);
$inadd_f = '';
$inadd_v = '';
if(is_array($addonfields))
{
foreach($addonfields as $v)
{
if($v=='')
{
continue;
}else if($v == 'templet')
{
ShowMsg("你保存的字段有误,请检查!","-1");
exit();
}
$vs = explode(',',$v);
if(!isset(${$vs[0]}))
{
${$vs[0]} = '';
}
${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],0);
$inadd_f .= ','.$vs[0];
$inadd_v .= " ,'".${$vs[0]}."' ";
}
}
}
//处理图片文档的自定义属性
if($litpic!='')
{
$flag = 'p';
}
$body = AnalyseHtmlBody($body,$description);
$body = HtmlReplace($body,-1);
//生成文档ID
$arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
if(empty($arcID))
{
ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
exit();
}
//保存到主表
$inQuery = "INSERT INTO `#@__archives`(id,typeid,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
color,writer,source,litpic,pubdate,senddate,mid,description,keywords,mtype)
VALUES ('$arcID','$typeid','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money','$title','$shorttitle',
'$color','$writer','$source','$litpic','$pubdate','$senddate','$mid','$description','$keywords','$mtypesid'); ";
if(!$dsql->ExecuteNoneQuery($inQuery))
{
$gerr = $dsql->GetError();
$dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID' ");
ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请联系管理员。","javascript:;");
exit();
}
//保存到附加表
$addtable = trim($cInfos['addtable']);
if(empty($addtable))
{
$dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
$dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;");
exit();
}
else
{
$inquery = "INSERT INTO `{$addtable}`(aid,typeid,userip,redirecturl,templet,body{$inadd_f},user_net_id,user_net_name,
user_net_md5_pwd)
Values('$arcID','$typeid','$userip','','','$body'{$inadd_v},'$user_net_id','$user_net_name','$user_net_md5_pwd')";
if(!$dsql->ExecuteNoneQuery($inquery))
{
$gerr = $dsql->GetError();
$dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'");
$dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!","javascript:;");
exit();
}
}
//更新统计
countArchives($channelid);
//生成HTML
InsertTags($tags,$arcID);
$artUrl = MakeArt($arcID,true);
if($artUrl=='')
{
//$artUrl = $cfg_phpurl."/view.php?aid=$arcID";
}
header("location: $artUrl");
}
?>