-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdefault.asp
More file actions
209 lines (181 loc) · 6.21 KB
/
default.asp
File metadata and controls
209 lines (181 loc) · 6.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
<!--#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.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.cateID = http.get("c");
if ( pageCustomParams.cateID.length === 0 ){
pageCustomParams.cateID = 0;
}else{
if ( !isNaN(pageCustomParams.cateID) ){
pageCustomParams.cateID = Number(pageCustomParams.cateID);
if ( pageCustomParams.cateID < 1 ){
pageCustomParams.cateID = 0;
}
}else{
pageCustomParams.cateID = 0;
}
};
pageCustomParams.tempParams.category = require("cache_category");
pageCustomParams.articles = {
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(dbo){
var sql = "",
perpage = pageCustomParams.tempCaches.globalCache.articleperpagecount,
totalSum = 0,
_pages = 0,
_mod = 0,
totalPages = 0,
scondCategory = ["log_category=" + pageCustomParams.cateID];
if ( pageCustomParams.cateID > 0 ){
if ( pageCustomParams.tempParams.category[pageCustomParams.cateID + ""] !== undefined ){
var childs = pageCustomParams.tempParams.category[pageCustomParams.cateID + ""].childrens;
for ( var c in childs ){
if ( !isNaN(c) ){
scondCategory.push("log_category=" + childs[c].id);
}
}
}
totalSum = Number(String(config.conn.Execute("Select count(id) From blog_article Where " + scondCategory.join(" OR "))(0)));
}else{
totalSum = Number(String(config.conn.Execute("Select count(id) From blog_article")(0)));
}
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;}
var BaseCategorySQL = scondCategory.join(" OR ");
if ( pageCustomParams.page > _pages ){
if ( pageCustomParams.cateID > 0 ){
sql = "Select top " + _mod + " * From blog_article Where " + BaseCategorySQL + " Order By id ASC, log_istop DESC";
}else{
sql = "Select top " + _mod + " * From blog_article Order By id ASC, log_istop DESC";
}
sql = "Select * From (" + sql + ") Order By id DESC";
}else{
if ( pageCustomParams.cateID > 0 ){
sql = "Select top "
+ (pageCustomParams.page * perpage)
+ " * From blog_article Where "
+ BaseCategorySQL
+ " Order By id DESC";
}else{
sql = "Select top "
+ (pageCustomParams.page * perpage)
+ " * From blog_article Order By id DESC";
}
sql = "Select * From (Select top " + perpage + " * From (" + sql + ") Order By id) Order By id DESC";
}
dbo.trave({
conn: config.conn,
sql: sql,
callback: function(){
this.each(function(){
pageCustomParams.articles.lists.push({
id: this("id").value,
title: this("log_title").value,
postDate: this("log_posttime").value,
editDate: this("log_updatetime").value,
category: getCategoryName(this("log_category").value),
tags: getTags(this("log_tags").value),
content: this("log_shortcontent").value,
url: "article.asp?id=" + this("id").value,
views: this("log_views").value,
uid: getUserPhoto(this("log_uid").value),
istop: this("log_istop").value,
cover: this("log_cover").value,
comments: this("log_comments").value
});
});
}
});
pageCustomParams.articles.lists = pageCustomParams.articles.lists.sort(function(A, B){
var a = A.istop ? 1 : 0,
b = B.istop ? 1 : 0;
return b - a;
});
pageCustomParams.tempParams.pages = pageCustomParams.tempModules.fns.pageAnalyze(pageCustomParams.page, totalPages);
if (
( pageCustomParams.articles.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 = "default.asp?c=" + pageCustomParams.cateID + "&page=" + i;
if ( pageCustomParams.tempParams.pages.current === i ){
pageCustomParams.articles.pages.push({ key: i });
}else{
pageCustomParams.articles.pages.push({ key: i, url : url });
}
}
}
})(pageCustomParams.tempModules.dbo);
delete pageCustomParams.tempCaches;
delete pageCustomParams.tempModules;
delete pageCustomParams.tempParams;
include("profile/themes/" + pageCustomParams.global.theme + "/default.asp");
CloseConnect();
}catch(e){
ConsoleClose(e.message);
}
%>