001.
//权限检查
002.
if
(
empty
(
$blog
)) {
003.
if
(!checkperm(
'allowblog'
)) {
004.
ckspacelog();
005.
showmessage(
'no_authority_to_add_log'
);
006.
}
007.
008.
//实名认证
009.
ckrealname(
'blog'
);
010.
011.
//视频认证
012.
ckvideophoto(
'blog'
);
013.
014.
//新用户见习
015.
cknewuser();
016.
017.
//判断是否发布太快
018.
$waittime
= interval_check(
'post'
);
019.
if
(
$waittime
> 0) {
020.
showmessage(
'operating_too_fast'
,
''
,1,
array
(
$waittime
));
021.
}
022.
023.
//接收外部标题
024.
$blog
[
'subject'
] =
empty
(
$_GET
[
'subject'
])?
''
:getstr(
$_GET
[
'subject'
], 80, 1, 0);
025.
$blog
[
'message'
] =
empty
(
$_GET
[
'message'
])?
''
:getstr(
$_GET
[
'message'
], 5000, 1, 0);
026.
027.
}
else
{
028.
029.
if
(
$_SGLOBAL
[
'supe_uid'
] !=
$blog
[
'uid'
] && !checkperm(
'manageblog'
)) {
030.
showmessage(
'no_authority_operation_of_the_log'
);
031.
}
032.
}
033.
034.
//添加编辑操作
035.
if
(submitcheck(
'blogsubmit'
)) {
036.
037.
if
(
empty
(
$blog
[
'blogid'
])) {
038.
$blog
=
array
();
039.
}
else
{
040.
if
(!checkperm(
'allowblog'
)) {
041.
ckspacelog();
042.
showmessage(
'no_authority_to_add_log'
);
043.
}
044.
}
045.
046.
//验证码
047.
if
(checkperm(
'seccode'
) && !ckseccode(
$_POST
[
'seccode'
])) {
048.
showmessage(
'incorrect_code'
);
049.
}
050.
051.
include_once
(S_ROOT.
'./source/function_blog.php'
);
052.
//引入发布日志文件
053.
if
(
$newblog
= blog_post(
$_POST
,
$blog
)) {
054.
if
(
empty
(
$blog
) &&
$newblog
[
'topicid'
]) {
055.
$url
=
'space.php?do=topic&topicid='
.
$newblog
[
'topicid'
].
'&view=blog'
;
056.
}
else
{
057.
$url
=
'space.php?uid='
.
$newblog
[
'uid'
].
'&do=blog&id='
.
$newblog
[
'blogid'
];
058.
}
059.
showmessage(
'do_success'
,
$url
, 0);
060.
}
else
{
061.
showmessage(
'that_should_at_least_write_things'
);
062.
}
063.
}
064.
065.
if
(
$_GET
[
'op'
] ==
'delete'
) {
066.
//删除
067.
if
(submitcheck(
'deletesubmit'
)) {
068.
include_once
(S_ROOT.
'./source/function_delete.php'
);
069.
if
(deleteblogs(
array
(
$blogid
))) {
070.
showmessage(
'do_success'
,
"space.php?uid=$blog[uid]&do=blog&view=me"
);
071.
}
else
{
072.
showmessage(
'failed_to_delete_operation'
);
073.
}
074.
}
075.
076.
}
elseif
(
$_GET
[
'op'
] ==
'goto'
) {
077.
078.
$id
=
intval
(
$_GET
[
'id'
]);
079.
$uid
=
$id
?getcount(
'blog'
,
array
(
'blogid'
=>
$id
),
'uid'
):0;
080.
081.
showmessage(
'do_success'
,
"space.php?uid=$uid&do=blog&id=$id"
, 0);
082.
083.
}
elseif
(
$_GET
[
'op'
] ==
'edithot'
) {
//编辑热度
084.
//是否有编辑日志的权限
085.
if
(!checkperm(
'manageblog'
)) {
086.
showmessage(
'no_privilege'
);
087.
}
088.
089.
if
(submitcheck(
'hotsubmit'
)) {
090.
$_POST
[
'hot'
] =
intval
(
$_POST
[
'hot'
]);
091.
092.
//数据库中关于hot字段为UNSIGNED,所以更新数据库时,如果为负值时,自动设为0
093.
updatetable(
'blog'
,
array
(
'hot'
=>
$_POST
[
'hot'
]),
array
(
'blogid'
=>
$blog
[
'blogid'
]));
//更新日志热度
094.
if
(
$_POST
[
'hot'
]>0) {
//如果热度大于0,则添加事件
095.
include_once
(S_ROOT.
'./source/function_feed.php'
);
096.
feed_publish(
$blog
[
'blogid'
],
'blogid'
);
097.
}
else
{
098.
updatetable(
'feed'
,
array
(
'hot'
=>
$_POST
[
'hot'
]),
array
(
'id'
=>
$blog
[
'blogid'
],
'idtype'
=>
'blogid'
));
099.
}
100.
101.
showmessage(
'do_success'
,
"space.php?uid=$blog[uid]&do=blog&id=$blog[blogid]"
, 0);
102.
}
103.
104.
}
else
{
105.
//添加编辑日志
106.
//获取个人分类
107.
$classarr
=
$blog
[
'uid'
]?getclassarr(
$blog
[
'uid'
]):getclassarr(
$_SGLOBAL
[
'supe_uid'
]);
108.
//如果不存在发布日志的uid,则取现登录用户的uid
109.
110.
//获取当前登录用户的相册
111.
$albums
= getalbums(
$_SGLOBAL
[
'supe_uid'
]);
112.
113.
$tags
=
empty
(
$blog
[
'tag'
])?
array
():unserialize(
$blog
[
'tag'
]);
//主要是编辑日志时使用
114.
$blog
[
'tag'
] = implode(
' '
,
$tags
);
//将数组转换成字符串,中间以空格作为分隔符
115.
116.
$blog
[
'target_names'
] =
''
;
117.
118.
$friendarr
=
array
(
$blog
[
'friend'
] =>
' selected'
);
119.
120.
$passwordstyle
=
$selectgroupstyle
=
'display:none'
;
121.
if
(
$blog
[
'friend'
] == 4) {
122.
$passwordstyle
=
''
;
123.
}
elseif
(
$blog
[
'friend'
] == 2) {
//仅指定的好友可见
124.
$selectgroupstyle
=
''
;
125.
if
(
$blog
[
'target_ids'
]) {
//是否有设置过哪些好友可以看
126.
$names
=
array
();
127.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT username FROM "
.tname(
'space'
).
" WHERE uid IN ($blog[target_ids])"
);
128.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
129.
$names
[] =
$value
[
'username'
];
130.
}
131.
$blog
[
'target_names'
] = implode(
' '
,
$names
);
//将数组转换成字符串,中间以空格空开
132.
}
133.
}
134.
135.
$blog
[
'message'
] =
str_replace
(
'&'
,
'&'
,
$blog
[
'message'
]);
136.
$blog
[
'message'
] = shtmlspecialchars(
$blog
[
'message'
]);
//将转义字符又重新还原
137.
138.
$allowhtml
= checkperm(
'allowhtml'
);
//检查是否允许插入html代码
139.
140.
//好友组
141.
$groups
= getfriendgroup();
142.
143.
//参与热点
144.
$topic
=
array
();
145.
$topicid
=
$_GET
[
'topicid'
] =
intval
(
$_GET
[
'topicid'
]);
146.
if
(
$topicid
) {
147.
$topic
= topic_get(
$topicid
);
148.
}
149.
if
(
$topic
) {
150.
$actives
=
array
(
'blog'
=>
' class="active"'
);
151.
}
152.
153.
//菜单激活
154.
$menuactives
=
array
(
'space'
=>
' class="active"'
);
155.
}
156.
157.
include_once
template(
"cp_blog"
);
158.
159.
?>