-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patharticle.asp
More file actions
296 lines (265 loc) · 9.42 KB
/
article.asp
File metadata and controls
296 lines (265 loc) · 9.42 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!--#include file="config.asp" -->
<%
try{
pageCustomParams.tempModules.cache = require("cache");
pageCustomParams.tempModules.dbo = require("DBO");
pageCustomParams.tempModules.connect = require("openDataBase");
pageCustomParams.tempModules.fns = require("fn");
pageCustomParams.tempModules.tags = require("tags");
pageCustomParams.tempModules.sap = require("sap");
pageCustomParams.tempModules.GRA = require("gra");
pageCustomParams.tempCaches.globalCache = require("cache_global");
if ( !pageCustomParams.tempCaches.globalCache.webstatus ){
ConsoleClose("抱歉,网站暂时被关闭。");
}
if ( pageCustomParams.tempModules.connect !== true ){
ConsoleClose("连接数据库失败");
}
require("status")();
pageCustomParams.page = http.get("page");
if ( pageCustomParams.page.length === 0 ){
pageCustomParams.page = 1;
}else{
if ( !isNaN( pageCustomParams.page ) ){
pageCustomParams.page = Number(pageCustomParams.page);
if ( pageCustomParams.page < 1 ){
pageCustomParams.page = 1;
}
}else{
ConsoleClose("page params error.");
}
}
pageCustomParams.id = http.get("id");
if ( pageCustomParams.id.length === 0 ){
console.end("article id error.");
}else{
if ( !isNaN( pageCustomParams.id ) ){
pageCustomParams.id = Number(pageCustomParams.id);
if ( pageCustomParams.id < 1 ){
ConsoleClose("article id can not find");
}
}else{
ConsoleClose("article ids type error.");
}
}
pageCustomParams.tempParams.category = require("cache_category");
pageCustomParams.article = {};
pageCustomParams.comments = {
lists: [],
pages: []
};
function getCategoryName( id ){
var rets = {},
categoryJSON = pageCustomParams.tempParams.category;
if ( categoryJSON[id + ""] !== undefined ){
rets.id = id;
rets.name = categoryJSON[id + ""].name;
rets.info = categoryJSON[id + ""].info;
rets.icon = categoryJSON[id + ""].icon;
rets.url = "default.asp?c=" + id;
}
return rets;
}
function getTags( tagStr ){
var tagsCacheData = pageCustomParams.tempModules.tags,
tagStrArrays = tagsCacheData.reFormatTags(tagStr),
keeper = [];
for ( var j = 0 ; j < tagStrArrays.length ; j++ ){
var rets = tagsCacheData.readTagFromCache( Number(tagStrArrays[j]) );
if ( rets !== undefined ){
keeper.push({
id: Number(tagStrArrays[j]),
name: rets.name,
url: "tags.asp?id=" + tagStrArrays[j],
count: rets.count
});
}
}
return keeper;
}
var getUserPhoto = pageCustomParams.tempModules.fns.getUserInfo;
function str2Array(str){
return (new Function("return " + str))();
}
(function(dbo){
dbo.trave({
conn: config.conn,
sql: "Select * From blog_article Where id=" + pageCustomParams.id,
callback: function( rs ){
if ( rs.Bof || rs.Eof ){
}else{
pageCustomParams.article.id = pageCustomParams.id;
pageCustomParams.article.title = rs("log_title").value;
pageCustomParams.article.category = getCategoryName(rs("log_category").value);
pageCustomParams.article.content = rs("log_content").value.replace(/&/g, "&");
pageCustomParams.article.tags = getTags(rs("log_tags").value);
pageCustomParams.article.postDate = rs("log_posttime").value;
pageCustomParams.article.editDate = rs("log_updatetime").value;
pageCustomParams.global.seotitle = pageCustomParams.article.title;
pageCustomParams.article.user = getUserPhoto(rs("log_uid").value);
pageCustomParams.article.comments = rs("log_comments").value;
pageCustomParams.article.views = rs("log_views").value;
pageCustomParams.article.cover = rs("log_cover").value;
}
}
});
var seArticleId = str2Array(Session("readArticles") + "");
if ( !seArticleId ){ seArticleId = []; }
if ( seArticleId.indexOf(pageCustomParams.article.id) === -1 ){
config.conn.Execute("UPDATE blog_article SET log_views=log_views+1 Where id=" + pageCustomParams.article.id);
seArticleId.push(pageCustomParams.article.id);
pageCustomParams.article.views++;
Session("readArticles") = JSON.stringify(seArticleId);
}
pageCustomParams.article.other = {};
dbo.trave({
conn: config.conn,
sql: "Select top 1 * From blog_article Where id<" + pageCustomParams.article.id + " Order By log_posttime DESC",
callback: function(rs){
if ( rs.Bof || rs.Eof ){
}else{
pageCustomParams.article.other.prev = {
title: rs("log_title").value,
id: rs("id").value,
url: "article.asp?id=" + rs("id").value,
cover: rs("log_cover").value
}
}
}
});
dbo.trave({
conn: config.conn,
sql: "Select top 1 * From blog_article Where id>" + pageCustomParams.article.id + " Order By log_posttime ASC",
callback: function(rs){
if ( rs.Bof || rs.Eof ){
}else{
pageCustomParams.article.other.next = {
title: rs("log_title").value,
id: rs("id").value,
url: "article.asp?id=" + rs("id").value,
cover: rs("log_cover").value
}
}
}
});
})(pageCustomParams.tempModules.dbo);
(function(dbo){
var totalSum = Number(String(config.conn.Execute("Select count(id) From blog_comment Where commentid=0 And commentlogid=" + pageCustomParams.article.id)(0))),
perpage = pageCustomParams.tempCaches.globalCache.commentperpagecount,
_mod = 0,
_pages = 0,
totalPages = 0,
sql = "",
globalCommentAduit = pageCustomParams.tempCaches.globalCache.commentaduit === true;
if ( totalSum === 0 ){
return;
}
if ( totalSum < perpage ){ perpage = totalSum; }
_mod = totalSum % perpage;
_pages = Math.floor(totalSum / perpage);
if ( _mod > 0 ){ totalPages = _pages + 1; }else{ totalPages = _pages; }
if ( pageCustomParams.page > totalPages ){ pageCustomParams.page = totalPages;}
if ( pageCustomParams.page > _pages ){
sql = "Select top "
+ (pageCustomParams.page * perpage)
+ " * From blog_comment Where commentid=0 And commentlogid=" + pageCustomParams.article.id + " Order By commentpostdate DESC";
sql = "Select * From (Select top " + _mod + " * From (" + sql + ")) Order By commentpostdate ASC";
}else{
sql = "Select top "
+ (pageCustomParams.page * perpage)
+ " * From blog_comment Where commentid=0 And commentlogid=" + pageCustomParams.article.id + " Order By commentpostdate ASC";
sql = "Select * From (Select top " + perpage + " * From (" + sql + ") Order By commentpostdate DESC) Order By commentpostdate ASC";
}
function getCommentReplyList(root){
var commentReplyList = [];
dbo.trave({
conn: config.conn,
sql: "Select * From blog_comment Where commentid=" + root + " And commentlogid=" + pageCustomParams.article.id + " Order By commentpostdate ASC",
callback: function(){
this.each(function(){
var canpush = true;
if ( globalCommentAduit === true ){
if ( this("commentaudit").value !== true ){
if ( (config.user.id !== this("commentuserid").value) || (this("commentuserid").value === 0) ){
canpush = false;
}
}
}
if ( canpush === false ){
if ( config.user.admin === true ){
canpush = true;
}
}
if ( canpush === true ){
commentReplyList.push({
id: this("id").value,
commid: this("commentid").value,
content: this("commentcontent").value,
date: this("commentpostdate").value,
ip: this("commentpostip").value,
user: getUserPhoto(this("commentuserid").value, this("commentusername").value, this("commentusermail").value),
website: this("commentwebsite").value
});
}
});
}
});
return commentReplyList;
}
dbo.trave({
conn: config.conn,
sql: sql,
callback: function(){
this.each(function(){
var canpush = true;
if ( globalCommentAduit === true ){
if ( this("commentaudit").value !== true ){
if ( (config.user.id !== this("commentuserid").value) || (this("commentuserid").value === 0) ){
canpush = false;
}
}
}
if ( canpush === false ){
if ( config.user.admin === true ){
canpush = true;
}
}
if ( canpush === true ){
pageCustomParams.comments.lists.push({
id: this("id").value,
commid: this("commentid").value,
content: this("commentcontent").value,
date: this("commentpostdate").value,
ip: this("commentpostip").value,
user: getUserPhoto(this("commentuserid").value, this("commentusername").value, this("commentusermail").value),
website: this("commentwebsite").value,
childrens: getCommentReplyList(this("id").value)
});
}
});
}
});
pageCustomParams.tempParams.pages = pageCustomParams.tempModules.fns.pageAnalyze(pageCustomParams.page, totalPages);
if (
( pageCustomParams.comments.lists.length > 0 ) &&
( (pageCustomParams.tempParams.pages.to - pageCustomParams.tempParams.pages.from) > 0 )
){
for ( i = pageCustomParams.tempParams.pages.from ; i <= pageCustomParams.tempParams.pages.to ; i++ ){
var url = "article.asp?id=" + pageCustomParams.id + "&page=" + i;
if ( pageCustomParams.tempParams.pages.current === i ){
pageCustomParams.comments.pages.push({ key: i });
}else{
pageCustomParams.comments.pages.push({ key: i, url : url });
}
}
}
})(pageCustomParams.tempModules.dbo);
delete pageCustomParams.tempCaches;
delete pageCustomParams.tempModules;
delete pageCustomParams.tempParams;
include("profile/themes/" + pageCustomParams.global.theme + "/article.asp");
CloseConnect();
}catch(e){
ConsoleClose(e.message);
}
%>