archives_sg_add.php
9.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
/**
* 单表模型发布器
*
* @version $Id: archives_sg_add.php 1 13:52 2010年7月9日Z tianya $
* @package DedeCMS.Member
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(dirname(__FILE__)."/config.php");
require_once(DEDEINC."/dedetag.class.php");
require_once(DEDEINC."/userlogin.class.php");
require_once(DEDEINC."/customfields.func.php");
require_once(dirname(__FILE__)."/inc/inc_catalog_options.php");
require_once(dirname(__FILE__)."/inc/inc_archives_functions.php");
$channelid = isset($channelid) && is_numeric($channelid) ? $channelid : 1;
$typeid = isset($typeid) && is_numeric($typeid) ? $typeid : 0;
$mtypesid = isset($mtypesid) && is_numeric($mtypesid) ? $mtypesid : 0;
$menutype = 'content';
/*-------------
function _ShowForm(){ }
--------------*/
if(empty($dopost))
{
$cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid'; ");
if(!is_array($cInfos))
{
ShowMsg('模型不存在', '-1');
exit();
}
//如果限制了会员级别或类型,则允许游客投稿选项无效
if($cInfos['sendrank']>0 || $cInfos['usertype']!='')
{
CheckRank(0,0);
}
//检查会员等级和类型限制
if($cInfos['sendrank'] > $cfg_ml->M_Rank)
{
$row = $dsql->GetOne("SELECT membername FROM `#@__arcrank` WHERE rank='".$cInfos['sendrank']."' ");
ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
exit();
}
if($cInfos['usertype']!='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
{
ShowMsg("对不起,需要[".$cInfos['usertype']."帐号]才能在这个频道发布文档!","-1","0",5000);
exit();
}
include(DEDEMEMBER."/templets/archives_sg_add.htm");
exit();
}
/*------------------------------
function _SaveArticle(){ }
------------------------------*/
else if($dopost=='save')
{
include_once(DEDEINC."/image.func.php");
include_once(DEDEINC."/oxwindow.class.php");
$svali = GetCkVdValue();
if(preg_match("/3/", $safe_gdopen)){
if(strtolower($vdcode)!=$svali || $svali=='')
{
ResetVdValue();
ShowMsg('验证码错误!', '-1');
exit();
}
}
$faqkey = isset($faqkey) && is_numeric($faqkey) ? $faqkey : 0;
if($safe_faq_send == '1')
{
if($safefaqs[$faqkey]['answer'] != $safeanswer || $safeanswer=='')
{
ShowMsg('验证问题答案错误', '-1');
exit();
}
}
$flag = '';
$autokey = $remote = $dellink = $autolitpic = 0;
$userip = GetIP();
if($typeid==0)
{
ShowMsg('请指定文档隶属的栏目!','-1');
exit();
}
$query = "SELECT tp.ispart,tp.channeltype,tp.issend,ch.issend AS cissend,ch.sendrank,ch.arcsta,ch.addtable,ch.fieldset,ch.usertype
FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype WHERE tp.id='$typeid' ";
$cInfos = $dsql->GetOne($query);
//检测栏目是否有投稿权限
if($cInfos['issend']!=1 || $cInfos['ispart']!=0 || $cInfos['channeltype']!=$channelid || $cInfos['cissend']!=1)
{
ShowMsg("你所选择的栏目不支持投稿!","-1");
exit();
}
//检查频道设定的投稿许可权限
if($cInfos['sendrank'] > $cfg_ml->M_Rank )
{
$row = $dsql->GetOne("Select membername From #@__arcrank where rank='".$cInfos['sendrank']."' ");
ShowMsg("对不起,需要[".$row['membername']."]才能在这个频道发布文档!","-1","0",5000);
exit();
}
if($cInfos['usertype'] !='' && $cInfos['usertype'] != $cfg_ml->M_MbType)
{
ShowMsg("对不起,需要[".$cInfos['usertype']."]才能在这个频道发布文档!","-1","0",5000);
exit();
}
//文档的默认状态
if($cInfos['arcsta']==0)
{
$arcrank = 0;
}
else if($cInfos['arcsta']==1)
{
$arcrank = 0;
}
else
{
$arcrank = -1;
}
//对保存的内容进行处理
$sortrank = $senddate = $pubdate = time();
$title = cn_substrR(HtmlReplace($title,1),$cfg_title_maxlen);
$mid = $cfg_ml->M_ID;
$description=empty($description)? "" : $description;
//处理上传的缩略图
$litpic = MemberUploads('litpic','',$cfg_ml->M_ID,'image','',$cfg_ddimg_width,$cfg_ddimg_height,false);
if($litpic!='') SaveUploadInfo($title,$litpic,1);
//分析处理附加表数据
$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;
}
$vs = explode(',',$v);
if(!isset(${$vs[0]}))
{
${$vs[0]} = '';
}
//自动摘要和远程图片本地化
if($vs[1]=='htmltext'||$vs[1]=='textdata')
{
${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$vs[1]);
}
${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],0);
$inadd_f .= ',`'.$vs[0].'`';
$inadd_v .= " ,'".${$vs[0]}."' ";
}
}
if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))
{
showMsg('数据校验不对,程序返回', '-1');
exit();
}
// 这里对前台提交的附加数据进行一次校验
$fontiterm = PrintAutoFieldsAdd($cInfos['fieldset'],'autofield', FALSE);
if ($fontiterm != str_replace('`', '', $inadd_f))
{
ShowMsg("提交表单同系统配置不相符,请重新提交!", "-1");
exit();
}
}
//生成文档ID
$arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$mid);
if(empty($arcID))
{
ShowMsg("无法获得主键,因此无法进行后续操作!","-1");
exit();
}
//保存到附加表
$addtable = trim($cInfos['addtable']);
if(empty($addtable))
{
$dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作。","javascript:;");
exit();
}
else
{
$inquery = "INSERT INTO `{$addtable}`(aid,typeid,arcrank,mid,channel,title,senddate,litpic,userip{$inadd_f}) Values('$arcID','$typeid','$arcrank','$mid','$channelid','$title','$senddate','$litpic','$userip'{$inadd_v})";
if(!$dsql->ExecuteNoneQuery($inquery))
{
$gerr = $dsql->GetError();
$dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'");
ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请联系管理员!","javascript:;");
exit();
}
}
//增加积分
$dsql->ExecuteNoneQuery("Update `#@__member` set scores=scores+{$cfg_sendarc_scores} where mid='".$cfg_ml->M_ID."' ; ");
//生成HTML
$artUrl = MakeArt($arcID,true);
if($artUrl=='') $artUrl = $cfg_phpurl."/view.php?aid=$arcID";
#api{{
if(defined('UC_API') && @include_once DEDEROOT.'/api/uc.func.php')
{
//推送事件
$feed['icon'] = 'thread';
$feed['title_template'] = '<b>{username} 在网站发布了一篇内容</b>';
$feed['title_data'] = array('username' => $cfg_ml->M_UserName);
$feed['body_template'] = '<b>{subject}</b><br>{message}';
$url = !strstr($artUrl,'http://') ? ($cfg_basehost.$artUrl) : $artUrl;
$feed['body_data'] = array('subject' => "<a href=\"".$url."\">$title</a>", 'message' => cn_substr(strip_tags(preg_replace("/\[.+?\]/is", '', $description)), 150));
$feed['images'][] = array('url' => $cfg_basehost.'/images/scores.gif', 'link'=> $cfg_basehost);
uc_feed_note($cfg_ml->M_LoginID,$feed);
//同步积分
$row = $dsql->GetOne("SELECT `scores`,`userid` FROM `#@__member` WHERE `mid`='".$cfg_ml->M_ID."'");
uc_credit_note($row['userid'],$cfg_sendarc_scores);
}
#/aip}}
//会员动态记录
$cfg_ml->RecordFeeds('add', $title, $description, $arcID);
ClearMyAddon($arcID, $title);
//返回成功信息
$msg = "
请选择你的后续操作:
<a href='archives_sg_add.php?channelid=$channelid'><u>继续发布内容</u></a>
<a href='$artUrl' target='_blank'><u>查看内容</u></a>
<a href='archives_sg_edit.php?channelid=$channelid&aid=$arcID'><u>更改内容</u></a>
<a href='content_sg_list.php?channelid={$channelid}'><u>已发布内容管理</u></a>
";
$wintitle = "成功发布内容!";
$wecome_info = "内容管理::发布内容";
$win = new OxWindow();
$win->AddTitle("成功发布内容:");
$win->AddMsgItem($msg);
$winform = $win->GetWindow("hand"," ",false);
$win->Display();
}