001.
if
(
$id
) {
002.
//读取日志
003.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT bf.*, b.* FROM "
.tname(
'blog'
).
" b LEFT JOIN "
.tname(
'blogfield'
).
" bf ON bf.blogid=b.blogid WHERE b.blogid='$id' AND b.uid='$space[uid]'"
);
004.
005.
$blog
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
);
006.
007.
//日志不存在
008.
if
(
empty
(
$blog
)) {
009.
showmessage(
'view_to_info_did_not_exist'
);
//出问题了,您要查看的信息不存在或者已经被删除
010.
}
011.
//检查好友权限
012.
if
(!ckfriend(
$blog
[
'uid'
],
$blog
[
'friend'
],
$blog
[
'target_ids'
])) {
013.
//没有权限
014.
include
template(
'space_privacy'
);
015.
exit
();
016.
}
elseif
(!
$space
[
'self'
] &&
$blog
[
'friend'
] == 4) {
017.
/*
018.
$blog['friend']:0:全站用户可见;
019.
1:全好友可见;
020.
2:仅指定的好友可见;
021.
3:仅自己可见;
022.
4:凭密码查看;
023.
*/
024.
//密码输入问题
025.
//在显示日志详细之前,先显示输入密码窗口
026.
$cookiename
=
"view_pwd_blog_$blog[blogid]"
;
027.
$cookievalue
=
empty
(
$_SCOOKIE
[
$cookiename
])?
''
:
$_SCOOKIE
[
$cookiename
];
028.
//判断是否有输入过密码,如果你是第一次访问此篇日志,则先输入密码,并将密码储存到cookie,
029.
//如果是第二次查看该文章时,先判断cookie是否存在,如果存在则直接查看日志
030.
if
(
$cookievalue
!= md5(md5(
$blog
[
'password'
]))) {
031.
$invalue
=
$blog
;
032.
include
template(
'do_inputpwd'
);
033.
exit
();
034.
}
035.
}
036.
037.
//整理
038.
$blog
[
'tag'
] =
empty
(
$blog
[
'tag'
])?
array
():unserialize(
$blog
[
'tag'
]);
039.
//如果tag不为空,则将序列化的字符串转换成数组
040.
041.
//处理视频标签
042.
include_once
(S_ROOT.
'./source/function_blog.php'
);
//引入日志处理函数文件
043.
$blog
[
'message'
] = blog_bbcode(
$blog
[
'message'
]);
044.
//通过正则,获取flash的url与类型
045.
046.
$otherlist
=
$newlist
=
array
();
047.
048.
//有效期
049.
if
(
$_SCONFIG
[
'uc_tagrelatedtime'
] && (
$_SGLOBAL
[
'timestamp'
] -
$blog
[
'relatedtime'
] >
$_SCONFIG
[
'uc_tagrelatedtime'
])) {
050.
$blog
[
'related'
] =
array
();
051.
}
052.
053.
if
(
$blog
[
'tag'
] &&
empty
(
$blog
[
'related'
])) {
054.
//如果数据库中不存在related,则引入缓存文件
055.
@
include_once
(S_ROOT.
'./data/data_tagtpl.php'
);
056.
057.
$b_tagids
=
$b_tags
=
$blog
[
'related'
] =
array
();
058.
$tag_count
= -1;
059.
foreach
(
$blog
[
'tag'
]
as
$key
=>
$value
) {
060.
$b_tags
[] =
$value
;
061.
$b_tagids
[] =
$key
;
062.
$tag_count
++;
063.
}
064.
065.
if
(!
empty
(
$_SCONFIG
[
'uc_tagrelated'
]) &&
$_SCONFIG
[
'uc_status'
]) {
066.
if
(!
empty
(
$_SGLOBAL
[
'tagtpl'
][
'limit'
])) {
067.
include_once
(S_ROOT.
'./uc_client/client.php'
);
068.
$tag_index
= mt_rand(0,
$tag_count
);
069.
$blog
[
'related'
] = uc_tag_get(
$b_tags
[
$tag_index
],
$_SGLOBAL
[
'tagtpl'
][
'limit'
]);
070.
}
071.
}
else
{
072.
//自身TAG
073.
$tag_blogids
=
array
();
074.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT DISTINCT blogid FROM "
.tname(
'tagblog'
).
" WHERE tagid IN ("
.simplode(
$b_tagids
).
") AND blogid<>'$blog[blogid]' ORDER BY blogid DESC LIMIT 0,10"
);
075.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
076.
$tag_blogids
[] =
$value
[
'blogid'
];
077.
}
078.
if
(
$tag_blogids
) {
079.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT uid,username,subject,blogid FROM "
.tname(
'blog'
).
" WHERE blogid IN ("
.simplode(
$tag_blogids
).
")"
);
080.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
081.
realname_set(
$value
[
'uid'
],
$value
[
'username'
]);
//实名
082.
$value
[
'url'
] =
"space.php?uid=$value[uid]&amp;do=blog&amp;id=$value[blogid]"
;
083.
$blog
[
'related'
][UC_APPID][
'data'
][] =
$value
;
084.
}
085.
$blog
[
'related'
][UC_APPID][
'type'
] =
'UCHOME'
;
086.
}
087.
}
088.
if
(!
empty
(
$blog
[
'related'
]) &amp;&amp;
is_array
(
$blog
[
'related'
])) {
089.
foreach
(
$blog
[
'related'
]
as
$appid
=>
$values
) {
090.
if
(!
empty
(
$values
[
'data'
]) &amp;&amp;
$_SGLOBAL
[
'tagtpl'
][
'data'
][
$appid
][
'template'
]) {
091.
foreach
(
$values
[
'data'
]
as
$itemkey
=>
$itemvalue
) {
092.
if
(!
empty
(
$itemvalue
) &amp;&amp;
is_array
(
$itemvalue
)) {
093.
$searchs
=
$replaces
=
array
();
094.
foreach
(
array_keys
(
$itemvalue
)
as
$key
) {
095.
$searchs
[] =
'{'
.
$key
.
'}'
;
096.
$replaces
[] =
$itemvalue
[
$key
];
097.
}
098.
$blog
[
'related'
][
$appid
][
'data'
][
$itemkey
][
'html'
] =
stripslashes
(
str_replace
(
$searchs
,
$replaces
,
$_SGLOBAL
[
'tagtpl'
][
'data'
][
$appid
][
'template'
]));
099.
}
else
{
100.
unset(
$blog
[
'related'
][
$appid
][
'data'
][
$itemkey
]);
101.
}
102.
}
103.
}
else
{
104.
$blog
[
'related'
][
$appid
][
'data'
] =
''
;
105.
}
106.
if
(
empty
(
$blog
[
'related'
][
$appid
][
'data'
])) {
107.
unset(
$blog
[
'related'
][
$appid
]);
108.
}
109.
}
110.
}
111.
updatetable(
'blogfield'
,
array
(
'related'
=>
addslashes
(serialize(sstripslashes(
$blog
[
'related'
]))),
'relatedtime'
=>
$_SGLOBAL
[
'timestamp'
]),
array
(
'blogid'
=>
$blog
[
'blogid'
]));
//更新
112.
}
else
{
113.
114.
$blog
[
'related'
] =
empty
(
$blog
[
'related'
])?
array
():unserialize(
$blog
[
'related'
]);
115.
116.
}
117.
118.
//作者的其他最新日志
119.
$otherlist
=
array
();
120.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT * FROM "
.tname(
'blog'
).
" WHERE uid='$space[uid]' ORDER BY dateline DESC LIMIT 0,6"
);
121.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
122.
if
(
$value
[
'blogid'
] !=
$blog
[
'blogid'
] &amp;&amp;
empty
(
$value
[
'friend'
])) {
123.
//如果不是显示的文件或是为全站可见的
124.
$otherlist
[] =
$value
;
125.
}
126.
}
127.
128.
//最新的日志
129.
$newlist
=
array
();
130.
//热度大于3的
131.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT * FROM "
.tname(
'blog'
).
" WHERE hot>=3 ORDER BY dateline DESC LIMIT 0,6"
);
132.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
133.
if
(
$value
[
'blogid'
] !=
$blog
[
'blogid'
] &amp;&amp;
empty
(
$value
[
'friend'
])) {
134.
realname_set(
$value
[
'uid'
],
$value
[
'username'
]);
//获取实名
135.
$newlist
[] =
$value
;
136.
}
137.
}
138.
139.
//评论
140.
$perpage
= 30;
141.
$perpage
= mob_perpage(
$perpage
);
142.
143.
$start
= (
$page
-1)*
$perpage
;
144.
145.
//检查开始数
146.
ckstart(
$start
,
$perpage
);
147.
148.
$count
=
$blog
[
'replynum'
];
//获取日志的评论数
149.
150.
$list
=
array
();
151.
if
(
$count
) {
//如果评论数大于0,则读取评论信息
152.
$cid
=
empty
(
$_GET
[
'cid'
])?0:
intval
(
$_GET
[
'cid'
]);
//获取日志的id
153.
$csql
=
$cid
?
"cid='$cid' AND"
:
''
;
154.
155.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT * FROM "
.tname(
'comment'
).
" WHERE $csql id='$id' AND idtype='blogid' ORDER BY dateline LIMIT $start,$perpage"
);
156.
157.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
158.
realname_set(
$value
[
'authorid'
],
$value
[
'author'
]);
//实名
159.
160.
$list
[] =
$value
;
161.
}
162.
}
163.
164.
//分页
165.
$multi
= multi(
$count
,
$perpage
,
$page
,
"space.php?uid=$blog[uid]&amp;do=$do&amp;id=$id"
,
''
,
'content'
);
166.
167.
//访问统计
168.
//如果不是自己访问并且是第一次访问
169.
if
(!
$space
[
'self'
] &amp;&amp;
$_SCOOKIE
[
'view_blogid'
] !=
$blog
[
'blogid'
]) {
170.
$_SGLOBAL
[
'db'
]->query(
"UPDATE "
.tname(
'blog'
).
" SET viewnum=viewnum+1 WHERE blogid='$blog[blogid]'"
);
171.
//更新日志的浏览量
172.
inserttable(
'log'
,
array
(
'id'
=>
$space
[
'uid'
],
'idtype'
=>
'uid'
));
//延迟更新
173.
//访问之后设置cookie,目的是为了不断地刷新访问数
174.
ssetcookie(
'view_blogid'
,
$blog
[
'blogid'
]);
175.
}
176.
177.
//表态
178.
$hash
= md5(
$blog
[
'uid'
].
"\t"
.
$blog
[
'dateline'
]);
179.
$id
=
$blog
[
'blogid'
];
180.
$idtype
=
'blogid'
;
181.
182.
foreach
(
$clicks
as
$key
=>
$value
) {
183.
$value
[
'clicknum'
] =
$blog
[
"click_$key"
];
184.
$value
[
'classid'
] = mt_rand(1, 4);
185.
if
(
$value
[
'clicknum'
] >
$maxclicknum
)
$maxclicknum
=
$value
[
'clicknum'
];
186.
$clicks
[
$key
] =
$value
;
187.
}
188.
189.
//点评
190.
//获取表态过的人
191.
$clickuserlist
=
array
();
192.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT * FROM "
.tname(
'clickuser'
)."
193.
WHERE id=
'$id'
AND idtype=
'$idtype'
194.
ORDER BY dateline DESC
195.
LIMIT 0,18");
196.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
197.
realname_set(
$value
[
'uid'
],
$value
[
'username'
]);
//实名
198.
$value
[
'clickname'
] =
$clicks
[
$value
[
'clickid'
]][
'name'
];
199.
$clickuserlist
[] =
$value
;
200.
}
201.
202.
//热点
203.
$topic
= topic_get(
$blog
[
'topicid'
]);
//获取热点,看看这篇文章是否属于哪一热点
204.
205.
//实名
206.
realname_get();
207.
208.
$_TPL
[
'css'
] =
'blog'
;
//设置页面样式
209.
include_once
template(
"space_blog_view"
);
210.
211.
}
else
{
212.
//分页
213.
$perpage
= 10;
214.
$perpage
= mob_perpage(
$perpage
);
215.
216.
$start
= (
$page
-1)*
$perpage
;
217.
218.
//检查开始数
219.
ckstart(
$start
,
$perpage
);
220.
221.
//摘要截取
222.
$summarylen
= 300;
223.
224.
$classarr
=
array
();
225.
$list
=
array
();
226.
$userlist
=
array
();
227.
$count
=
$pricount
= 0;
228.
229.
$ordersql
=
'b.dateline'
;
//按发布时间进行排序
230.
231.
if
(
empty
(
$_GET
[
'view'
]) &amp;&amp; (
$space
[
'friendnum'
]<
$_SCONFIG
[
'showallfriendnum'
])) {
232.
$_GET
[
'view'
] =
'all'
;
//默认显示
233.
}
234.
235.
//处理查询
236.
$f_index
=
''
;
237.
if
(
$_GET
[
'view'
] ==
'click'
) {
//我表过态的日志
238.
//踩过的日志
239.
$theurl
=
"space.php?uid=$space[uid]&amp;do=$do&amp;view=click"
;
240.
$actives
=
array
(
'click'
=>
' class="active"'
);
//设置样式
241.
242.
$clickid
=
intval
(
$_GET
[
'clickid'
]);
243.
if
(
$clickid
) {
//如果动作存在,则按动作进行排序
244.
$theurl
.=
"&amp;clickid=$clickid"
;
245.
$wheresql
=
" AND c.clickid='$clickid'"
;
246.
$click_actives
=
array
(
$clickid
=>
' class="current"'
);
247.
}
else
{
248.
$wheresql
=
''
;
249.
$click_actives
=
array
(
'all'
=>
' class="current"'
);
250.
}
251.
252.
$count
=
$_SGLOBAL
[
'db'
]->result(
$_SGLOBAL
[
'db'
]->query(
"SELECT COUNT(*) FROM "
.tname(
'clickuser'
).
" c WHERE c.uid='$space[uid]' AND c.idtype='blogid' $wheresql"
),0);
253.
if
(
$count
) {
254.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT b.*, bf.message, bf.target_ids, bf.magiccolor FROM "
.tname(
'clickuser'
)." c
255.
LEFT JOIN
".tname('blog')."
b ON b.blogid=c.id
256.
LEFT JOIN
".tname('blogfield')."
bf ON bf.blogid=c.id
257.
WHERE c.uid=
'$space[uid]'
AND c.idtype=
'blogid'
$wheresql
258.
ORDER BY c.dateline DESC LIMIT
$start
,
$perpage
");
259.
}
260.
}
else
{
261.
262.
if
(
$_GET
[
'view'
] ==
'all'
) {
//查看大家的日志
263.
//大家的日志
264.
$wheresql
=
'1'
;
265.
266.
$actives
=
array
(
'all'
=>
' class="active"'
);
//将all样式设置为激活
267.
268.
//排序
269.
$orderarr
=
array
(
'dateline'
,
'replynum'
,
'viewnum'
,
'hot'
);
270.
271.
foreach
(
$clicks
as
$value
) {
272.
$orderarr
[] =
"click_$value[clickid]"
;
273.
}
274.
275.
if
(!in_array(
$_GET
[
'orderby'
],
$orderarr
))
$_GET
[
'orderby'
] =
''
;
//是否选定按什么进行排序
276.
277.
//时间
278.
$_GET
[
'day'
] =
intval
(
$_GET
[
'day'
]);
//用于列表右侧的操行榜
279.
$_GET
[
'hotday'
] = 7;
280.
281.
if
(
$_GET
[
'orderby'
]) {
//如果有按**来排序
282.
$ordersql
=
'b.'
.
$_GET
[
'orderby'
];
283.
284.
$theurl
=
"space.php?uid=$space[uid]&amp;do=blog&amp;view=all&amp;orderby=$_GET[orderby]"
;
285.
$all_actives
=
array
(
$_GET
[
'orderby'
]=>
' class="current"'
);
286.
287.
if
(
$_GET
[
'day'
]) {
288.
$_GET
[
'hotday'
] =
$_GET
[
'day'
];
289.
$daytime
=
$_SGLOBAL
[
'timestamp'
] -
$_GET
[
'day'
]*3600*24;
290.
$wheresql
.=
" AND b.dateline>='$daytime'"
;
291.
292.
$theurl
.=
"&amp;day=$_GET[day]"
;
293.
$day_actives
=
array
(
$_GET
[
'day'
]=>
' class="active"'
);
294.
}
else
{
295.
$day_actives
=
array
(0=>
' class="active"'
);
296.
}
297.
}
else
{
298.
299.
$theurl
=
"space.php?uid=$space[uid]&amp;do=$do&amp;view=all"
;
300.
301.
$wheresql
.=
" AND b.hot>='$minhot'"
;
302.
$all_actives
=
array
(
'all'
=>
' class="current"'
);
303.
$day_actives
=
array
();
304.
}
305.
306.
}
else
{
307.
308.
if
(
empty
(
$space
[
'feedfriend'
]) ||
$classid
)
$_GET
[
'view'
] =
'me'
;
309.
310.
if
(
$_GET
[
'view'
] ==
'me'
) {
311.
//查看个人的
312.
$wheresql
=
"b.uid='$space[uid]'"
;
313.
$theurl
=
"space.php?uid=$space[uid]&amp;do=$do&amp;view=me"
;
314.
$actives
=
array
(
'me'
=>
' class="active"'
);
315.
//日志分类
316.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT classid, classname FROM "
.tname(
'class'
).
" WHERE uid='$space[uid]'"
);
317.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
318.
$classarr
[
$value
[
'classid'
]] =
$value
[
'classname'
];
319.
}
320.
}
else
{
321.
$wheresql
=
"b.uid IN ($space[feedfriend])"
;
322.
$theurl
=
"space.php?uid=$space[uid]&amp;do=$do&amp;view=we"
;
323.
$f_index
=
'USE INDEX(dateline)'
;
324.
325.
$fuid_actives
=
array
();
326.
327.
//查看指定好友的
328.
$fusername
= trim(
$_GET
[
'fusername'
]);
329.
$fuid
=
intval
(
$_GET
[
'fuid'
]);
330.
if
(
$fusername
) {
331.
$fuid
= getuid(
$fusername
);
332.
}
333.
if
(
$fuid
&amp;&amp; in_array(
$fuid
,
$space
[
'friends'
])) {
334.
$wheresql
=
"b.uid = '$fuid'"
;
335.
$theurl
=
"space.php?uid=$space[uid]&amp;do=$do&amp;view=we&amp;fuid=$fuid"
;
336.
$f_index
=
''
;
337.
$fuid_actives
=
array
(
$fuid
=>
' selected'
);
338.
}
339.
340.
$actives
=
array
(
'we'
=>
' class="active"'
);
341.
342.
//好友列表
343.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT * FROM "
.tname(
'friend'
).
" WHERE uid='$space[uid]' AND status='1' ORDER BY num DESC, dateline DESC LIMIT 0,500"
);
344.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
345.
realname_set(
$value
[
'fuid'
],
$value
[
'fusername'
]);
346.
$userlist
[] =
$value
;
347.
}
348.
}
349.
}
350.
351.
//分类
352.
if
(
$classid
) {
353.
$wheresql
.=
" AND b.classid='$classid'"
;
354.
$theurl
.=
"&amp;classid=$classid"
;
355.
}
356.
357.
//设置权限
358.
$_GET
[
'friend'
] =
intval
(
$_GET
[
'friend'
]);
359.
if
(
$_GET
[
'friend'
]) {
360.
$wheresql
.=
" AND b.friend='$_GET[friend]'"
;
361.
$theurl
.=
"&amp;friend=$_GET[friend]"
;
362.
}
363.
364.
//搜索
365.
if
(
$searchkey
= stripsearchkey(
$_GET
[
'searchkey'
])) {
366.
$wheresql
.=
" AND b.subject LIKE '%$searchkey%'"
;
367.
$theurl
.=
"&amp;searchkey=$_GET[searchkey]"
;
368.
cksearch(
$theurl
);
369.
}
370.
371.
$count
=
$_SGLOBAL
[
'db'
]->result(
$_SGLOBAL
[
'db'
]->query(
"SELECT COUNT(*) FROM "
.tname(
'blog'
).
" b WHERE $wheresql"
),0);
372.
//更新统计
373.
if
(
$wheresql
==
"b.uid='$space[uid]'"
&amp;&amp;
$space
[
'blognum'
] !=
$count
) {
374.
updatetable(
'space'
,
array
(
'blognum'
=>
$count
),
array
(
'uid'
=>
$space
[
'uid'
]));
375.
}
376.
if
(
$count
) {
377.
$query
=
$_SGLOBAL
[
'db'
]->query(
"SELECT bf.message, bf.target_ids, bf.magiccolor, b.* FROM "
.tname(
'blog'
)." b
$f_index
378.
LEFT JOIN
".tname('blogfield')."
bf ON bf.blogid=b.blogid
379.
WHERE
$wheresql
380.
ORDER BY
$ordersql
DESC LIMIT
$start
,
$perpage
");
381.
}
382.
}
383.
384.
if
(
$count
) {
385.
while
(
$value
=
$_SGLOBAL
[
'db'
]->fetch_array(
$query
)) {
386.
if
(ckfriend(
$value
[
'uid'
],
$value
[
'friend'
],
$value
[
'target_ids'
])) {
387.
realname_set(
$value
[
'uid'
],
$value
[
'username'
]);
388.
if
(
$value
[
'friend'
] == 4) {
389.
$value
[
'message'
] =
$value
[
'pic'
] =
''
;
390.
}
else
{
391.
$value
[
'message'
] = getstr(
$value
[
'message'
],
$summarylen
, 0, 0, 0, 0, -1);
392.
}
393.
if
(
$value
[
'pic'
])
$value
[
'pic'
] = pic_cover_get(
$value
[
'pic'
],
$value
[
'picflag'
]);
394.
$list
[] =
$value
;
395.
}
else
{
396.
$pricount
++;
397.
}
398.
}
399.
}
400.
401.
//分页
402.
$multi
= multi(
$count
,
$perpage
,
$page
,
$theurl
);
403.
404.
//实名
405.
realname_get();
406.
407.
$_TPL
[
'css'
] =
'blog'
;
408.
include_once
template(
"space_blog_list"
);
409.
}
410.
411.
?>