upgradeprocedure_2005.sql
上传用户:wenllgg125
上传日期:2020-04-09
资源大小:7277k
文件大小:192k
源码类别:

SCSI/ASPI

开发平台:

Others

  1. IF OBJECT_ID('[dnt_checkemailandsecques]','P') IS NOT NULL
  2. DROP PROC [dnt_checkemailandsecques]
  3. GO
  4. CREATE PROCEDURE [dnt_checkemailandsecques]
  5. @username nchar(20),
  6. @email char(32),
  7. @secques char(8)
  8. AS
  9. SELECT TOP 1 [uid] FROM [dnt_users] WHERE [username]=@username AND [email]=@email AND [secques]=@secques
  10. GO
  11. IF OBJECT_ID('[dnt_checkpasswordandsecques]','P') IS NOT NULL
  12. DROP PROC [dnt_checkpasswordandsecques]
  13. GO
  14. CREATE PROCEDURE [dnt_checkpasswordandsecques]
  15. @username nchar(20),
  16. @password char(32),
  17. @secques char(8)
  18. AS
  19. SELECT TOP 1 [uid] FROM [dnt_users] WHERE [username]=@username AND [password]=@password AND [secques]=@secques
  20. GO
  21. IF OBJECT_ID('[dnt_checkpasswordbyuid]','P') IS NOT NULL
  22. DROP PROC [dnt_checkpasswordbyuid]
  23. GO
  24. CREATE PROCEDURE [dnt_checkpasswordbyuid]
  25. @uid int,
  26. @password char(32)
  27. AS
  28. SELECT TOP 1 [uid], [groupid], [adminid] FROM [dnt_users] WHERE [uid]=@uid AND [password]=@password
  29. GO
  30. IF OBJECT_ID('[dnt_checkpasswordbyusername]','P') IS NOT NULL
  31. DROP PROC [dnt_checkpasswordbyusername]
  32. GO
  33. CREATE PROCEDURE [dnt_checkpasswordbyusername]
  34. @username nchar(20),
  35. @password char(32)
  36. AS
  37. SELECT TOP 1 [uid], [groupid], [adminid] FROM [dnt_users] WHERE [username]=@username AND [password]=@password
  38. GO
  39. IF OBJECT_ID('[dnt_createadmingroup]','P') IS NOT NULL
  40. DROP PROC [dnt_createadmingroup]
  41. GO
  42. CREATE PROCEDURE [dnt_createadmingroup]
  43. @admingid smallint,
  44. @alloweditpost tinyint,
  45. @alloweditpoll tinyint,
  46. @allowstickthread tinyint,
  47. @allowmodpost tinyint,
  48. @allowdelpost tinyint,
  49. @allowmassprune tinyint,
  50. @allowrefund tinyint,
  51. @allowcensorword tinyint,
  52. @allowviewip tinyint,
  53. @allowbanip tinyint,
  54. @allowedituser tinyint,
  55. @allowmoduser tinyint,
  56. @allowbanuser tinyint,
  57. @allowpostannounce tinyint,
  58. @allowviewlog tinyint,
  59. @disablepostctrl tinyint,
  60. @allowviewrealname tinyint
  61. AS
  62. INSERT INTO dnt_admingroups 
  63. ([admingid],[alloweditpost],[alloweditpoll],[allowstickthread],[allowmodpost],[allowdelpost],[allowmassprune],[allowrefund],[allowcensorword],[allowviewip],[allowbanip],[allowedituser],[allowmoduser],[allowbanuser],[allowpostannounce],[allowviewlog],[disablepostctrl],[allowviewrealname])
  64. VALUES
  65. (@admingid,@alloweditpost,@alloweditpoll,@allowstickthread,@allowmodpost,@allowdelpost,@allowmassprune,@allowrefund,@allowcensorword,@allowviewip,@allowbanip,@allowedituser,@allowmoduser,@allowbanuser,@allowpostannounce,@allowviewlog,@disablepostctrl,@allowviewrealname)
  66. GO
  67. IF OBJECT_ID('[dnt_createattachment]','P') IS NOT NULL
  68. DROP PROC [dnt_createattachment]
  69. GO
  70. CREATE PROCEDURE [dnt_createattachment]
  71. @uid int,
  72. @tid int,
  73. @pid int,
  74. @postdatetime datetime,
  75. @readperm int,
  76. @filename nchar(200),
  77. @description nchar(200),
  78. @filetype nchar(100),
  79. @filesize int,
  80. @attachment nchar(200),
  81. @downloads int,
  82. @extname nvarchar(50),
  83. @attachprice int,
  84. @width int,
  85. @height int
  86. AS
  87. DECLARE @aid int
  88. INSERT INTO [dnt_attachments]([uid],[tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize],  [attachment], [downloads],[attachprice],[width],[height]) VALUES(@uid, @tid, @pid, @postdatetime, @readperm, @filename, @description, @filetype, @filesize,  @attachment, @downloads, @attachprice,@width,@height)
  89. SELECT SCOPE_IDENTITY()  AS 'aid'
  90. set @aid=(SELECT SCOPE_IDENTITY()  AS 'aid')
  91. UPDATE [dnt_posts1] SET [attachment]=1 WHERE [pid]=@pid
  92. INSERT INTO [dnt_myattachments]([aid],[uid],[attachment],[description],[postdatetime],[downloads],[filename],[pid],[tid],[extname]) VALUES(@aid,@uid,@attachment,@description,@postdatetime,@downloads,@filename,@pid,@tid,@extname)
  93. GO
  94. IF OBJECT_ID('[dnt_createdebatepostexpand]','P') IS NOT NULL
  95. DROP PROC [dnt_createdebatepostexpand]
  96. GO
  97. CREATE PROCEDURE [dnt_createdebatepostexpand]
  98. @tid int,
  99. @pid int,
  100. @opinion int,
  101. @diggs int
  102. AS
  103. BEGIN
  104. INSERT INTO [dnt_postdebatefields] VALUES(@tid, @pid, @opinion, @diggs)
  105. IF @opinion = 1
  106. UPDATE [dnt_debates] SET [positivediggs] = [positivediggs] + 1 WHERE [tid] = @tid
  107. ELSE IF @opinion = 2
  108. UPDATE [dnt_debates] SET [negativediggs] = [negativediggs] + 1 WHERE [tid] = @tid
  109. END
  110. GO
  111. IF OBJECT_ID('[dnt_createfavorite]','P') IS NOT NULL
  112. DROP PROC [dnt_createfavorite]
  113. GO
  114. CREATE PROCEDURE [dnt_createfavorite]
  115. @uid int,
  116. @tid int,
  117. @type tinyint
  118. AS
  119. INSERT INTO [dnt_favorites] ([uid],[tid],[typeid]) VALUES(@uid,@tid,@type)
  120. RETURN
  121. GO
  122. IF OBJECT_ID('[dnt_createpm]','P') IS NOT NULL
  123. DROP PROC [dnt_createpm]
  124. GO
  125. CREATE PROCEDURE [dnt_createpm]
  126. @pmid int,
  127. @msgfrom nvarchar(20),
  128. @msgto nvarchar(20),
  129. @msgfromid int,
  130. @msgtoid int,
  131. @folder smallint=0,
  132. @new int=0,
  133. @subject nvarchar(60),
  134. @postdatetime datetime,
  135. @message ntext,
  136. @savetosentbox smallint=1
  137. AS
  138. IF @folder<>0
  139. BEGIN
  140. SET @msgfrom=@msgto
  141. END
  142. ELSE
  143. BEGIN
  144. UPDATE [dnt_users] SET [newpmcount]=ABS(ISNULL([newpmcount],0)*1)+1,[newpm] = 1 WHERE [uid]=@msgtoid
  145. END
  146. INSERT INTO [dnt_pms] 
  147. ([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
  148. VALUES
  149. (@msgfrom,@msgfromid,@msgto,@msgtoid,@folder,@new,@subject,@postdatetime,@message)
  150. SELECT SCOPE_IDENTITY() AS 'pmid'
  151. IF @savetosentbox=1 AND @folder=0
  152. BEGIN
  153. INSERT INTO [dnt_pms]
  154. ([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
  155. VALUES
  156. (@msgfrom,@msgfromid,@msgto,@msgtoid,1,@new,@subject,@postdatetime,@message)
  157. END
  158. GO
  159. IF OBJECT_ID('dnt_createpost1','P') IS NOT NULL
  160. DROP PROC [dnt_createpost1]
  161. GO
  162. CREATE PROCEDURE [dnt_createpost1]
  163. @fid int,
  164. @tid int,
  165. @parentid int,
  166. @layer int,
  167. @poster varchar(20),
  168. @posterid int,
  169. @title nvarchar(60),
  170. @topictitle nvarchar(60),
  171. @postdatetime char(20),
  172. @message ntext,
  173. @ip varchar(15),
  174. @lastedit varchar(50),
  175. @invisible int,
  176. @usesig int,
  177. @htmlon int,
  178. @smileyoff int,
  179. @bbcodeoff int,
  180. @parseurloff int,
  181. @attachment int,
  182. @rate int,
  183. @ratetimes int
  184. AS
  185. DEClARE @postid int
  186. DELETE FROM [dnt_postid] WHERE DATEDIFF(n, postdatetime, GETDATE()) >5
  187. INSERT INTO [dnt_postid] ([postdatetime]) VALUES(GETDATE())
  188. SELECT @postid=SCOPE_IDENTITY()
  189. INSERT INTO [dnt_posts1]([pid], [fid], [tid], [parentid], [layer], [poster], [posterid], [title], [postdatetime], [message], [ip], [lastedit], [invisible], [usesig], [htmlon], [smileyoff], [bbcodeoff], [parseurloff], [attachment], [rate], [ratetimes]) VALUES(@postid, @fid, @tid, @parentid, @layer, @poster, @posterid, @title, @postdatetime, @message, @ip, @lastedit, @invisible, @usesig, @htmlon, @smileyoff, @bbcodeoff, @parseurloff, @attachment, @rate, @ratetimes)
  190. IF @parentid=0
  191. BEGIN
  192. UPDATE [dnt_posts1] SET [parentid]=@postid WHERE [pid]=@postid
  193. END
  194. IF @@ERROR=0
  195. BEGIN
  196. IF  @invisible = 0
  197. BEGIN
  198. UPDATE [dnt_statistics] SET [totalpost]=[totalpost] + 1
  199. DECLARE @fidlist AS VARCHAR(1000)
  200. DECLARE @strsql AS VARCHAR(4000)
  201. SET @fidlist = '';
  202. SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
  203. IF RTRIM(@fidlist)<>''
  204. BEGIN
  205. SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
  206. END
  207. ELSE
  208. BEGIN
  209. SET @fidlist = CAST(@fid AS VARCHAR(10))
  210. END
  211. UPDATE [dnt_forums] SET 
  212. [posts]=[posts] + 1, 
  213. [todayposts]=CASE 
  214. WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts] + 1 
  215.  ELSE 1 
  216.  END,
  217. [lasttid]=@tid,
  218. [lasttitle]=@topictitle,
  219. [lastpost]=@postdatetime,
  220. [lastposter]=@poster,
  221. [lastposterid]=@posterid 
  222. WHERE fid IN (SELECT [item] FROM
  223.  [dnt_split](@fidlist, ','))
  224. UPDATE [dnt_users] SET
  225. [lastpost] = @postdatetime,
  226. [lastpostid] = @postid,
  227. [lastposttitle] = @title,
  228. [posts] = [posts] + 1,
  229. [lastactivity] = GETDATE()
  230. WHERE [uid] = @posterid
  231. IF @layer<=0
  232. BEGIN
  233. UPDATE [dnt_topics] SET [replies]=0,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
  234. END
  235. ELSE
  236. BEGIN
  237. UPDATE [dnt_topics] SET [replies]=[replies] + 1,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
  238. END
  239. END
  240. UPDATE [dnt_topics] SET [lastpostid]=@postid WHERE [tid]=@tid
  241. IF @posterid <> -1
  242. BEGIN
  243. INSERT [dnt_myposts]([uid], [tid], [pid], [dateline]) VALUES(@posterid, @tid, @postid, @postdatetime)
  244. END
  245. END
  246. SELECT @postid AS postid
  247. GO
  248. IF OBJECT_ID('[dnt_createsearchcache]','P') IS NOT NULL
  249. DROP PROC [dnt_createsearchcache]
  250. GO
  251. CREATE PROCEDURE [dnt_createsearchcache]
  252. @keywords varchar(255),
  253. @searchstring varchar(255),
  254. @ip varchar(15),
  255. @uid int,
  256. @groupid int,
  257. @postdatetime varchar(19),
  258. @expiration varchar(19),
  259. @topics int,
  260. @tids text
  261. AS
  262. INSERT INTO dnt_searchcaches 
  263. ([keywords],[searchstring],[ip],[uid],[groupid],[postdatetime],[expiration],[topics],[tids])
  264. VALUES
  265. (@keywords,@searchstring,@ip,@uid,@groupid,@postdatetime,@expiration,@topics,@tids)
  266. SELECT SCOPE_IDENTITY()  AS 'searchid'
  267. GO
  268. IF OBJECT_ID('[dnt_createtags]','P') IS NOT NULL
  269. DROP PROC [dnt_createtags]
  270. GO
  271. CREATE PROCEDURE [dnt_createtags]
  272. @tags nvarchar(55),
  273. @userid int,
  274. @postdatetime datetime
  275. AS
  276. BEGIN
  277. INSERT INTO [dnt_tags]([tagname], [userid], [postdatetime], [orderid], [color], [count], [fcount], [pcount], [scount], [vcount]) 
  278. SELECT [item], @userid, @postdatetime, 0, '', 0, 0, 0, 0, 0 FROM [dnt_split](@tags, ' ') AS [newtags] 
  279. WHERE NOT EXISTS (SELECT [tagname] FROM [dnt_tags] WHERE [newtags].[item] = [tagname])
  280. END
  281. GO
  282. IF OBJECT_ID('[dnt_createtopic]','P') IS NOT NULL
  283. DROP PROC [dnt_createtopic]
  284. GO
  285. CREATE PROCEDURE [dnt_createtopic]
  286. @fid smallint,
  287. @iconid smallint,
  288. @title nchar(80),
  289. @typeid smallint,
  290. @readperm int,
  291. @price smallint,
  292. @poster char(20),
  293. @posterid int,
  294. @postdatetime smalldatetime,
  295. @lastpost smalldatetime,
  296. @lastpostid int,
  297. @lastposter char(20),
  298. @views int,
  299. @replies int,
  300. @displayorder int,
  301. @highlight varchar(500),
  302. @digest int,
  303. @rate int,
  304. @hide int,
  305. @attachment int,
  306. @moderated int,
  307. @closed int,
  308. @magic int,
  309. @special tinyint,
  310. @attention int
  311. AS
  312. DECLARE @topicid int
  313. DELETE FROM [dnt_topics] WHERE [tid]>(SELECT ISNULL(max(tid),0)-100 FROM [dnt_topics]) AND [lastpostid]=0
  314. INSERT INTO [dnt_topics]([fid], [iconid], [title], [typeid], [readperm], [price], [poster], [posterid], [postdatetime], [lastpost], [lastpostid], [lastposter], [views], [replies], [displayorder], [highlight], [digest], [rate], [hide], [attachment], [moderated], [closed], [magic], [special],[attention]) VALUES(@fid, @iconid, @title, @typeid, @readperm, @price, @poster, @posterid, @postdatetime, @lastpost, @lastpostid, @lastposter, @views, @replies, @displayorder, @highlight, @digest, @rate, @hide, @attachment, @moderated, @closed, @magic, @special,@attention)
  315. SET @topicid=SCOPE_IDENTITY()
  316. IF @@ERROR=0 AND @displayorder=0
  317. BEGIN
  318. UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] + 1
  319. UPDATE [dnt_forums] SET [topics] = [topics] + 1,[curtopics] = [curtopics] + 1 WHERE [fid] = @fid
  320. IF @posterid <> -1
  321. BEGIN
  322. INSERT INTO [dnt_mytopics]([tid],[uid],[dateline]) VALUES(@topicid,  @posterid,  @postdatetime)
  323. END
  324. END
  325. SELECT @topicid as topicid
  326. GO
  327. IF OBJECT_ID('[dnt_createuser]','P') IS NOT NULL
  328. DROP PROC [dnt_createuser]
  329. GO
  330. CREATE PROCEDURE [dnt_createuser]
  331. @username nchar(20),
  332. @nickname nchar(20),
  333. @password char(32),
  334. @secques char(8),
  335. @gender int,
  336. @adminid int,
  337. @groupid smallint,
  338. @groupexpiry int,
  339. @extgroupids char(60),
  340. @regip char(15),
  341. @joindate char(19),
  342. @lastip char(15),
  343. @lastvisit char(19),
  344. @lastactivity char(19),
  345. @lastpost char(19),
  346. @lastpostid int,
  347. @lastposttitle nchar(60),
  348. @posts int,
  349. @digestposts smallint,
  350. @oltime int,
  351. @pageviews int,
  352. @credits int,
  353. @extcredits1 float,
  354. @extcredits2 float,
  355. @extcredits3 float,
  356. @extcredits4 float,
  357. @extcredits5 float,
  358. @extcredits6 float,
  359. @extcredits7 float,
  360. @extcredits8 float,
  361. @avatarshowid int,
  362. @email char(50),
  363. @bday char(19),
  364. @sigstatus int,
  365. @salt nchar(6),
  366. @tpp int,
  367. @ppp int,
  368. @templateid smallint,
  369. @pmsound int,
  370. @showemail int,
  371. @newsletter int,
  372. @invisible int,
  373. @newpm int,
  374. @accessmasks int,
  375. @website varchar(80),
  376. @icq varchar(12),
  377. @qq varchar(12),
  378. @yahoo varchar(40),
  379. @msn varchar(40),
  380. @skype varchar(40),
  381. @location nvarchar(30),
  382. @customstatus varchar(30),
  383. @avatar varchar(255),
  384. @avatarwidth int,
  385. @avatarheight int,
  386. @medals varchar(300),
  387. @bio nvarchar(500),
  388. @signature nvarchar(500),
  389. @sightml nvarchar(1000),
  390. @authstr varchar(20),
  391. @realname nvarchar(10),
  392. @idcard varchar(20),
  393. @mobile varchar(20),
  394. @phone varchar(20)
  395. AS
  396. DECLARE @uid int
  397. INSERT INTO [dnt_users]([username],[nickname], [password], [secques], [gender], [adminid], [groupid], [groupexpiry], [extgroupids], [regip], [joindate], [lastip], [lastvisit], [lastactivity], [lastpost], [lastpostid], [lastposttitle], [posts], [digestposts], [oltime], [pageviews], [credits], [extcredits1], [extcredits2], [extcredits3], [extcredits4], [extcredits5], [extcredits6], [extcredits7], [extcredits8], [avatarshowid], [email], [bday], [sigstatus], [salt], [tpp], [ppp], [templateid], [pmsound], [showemail], [newsletter], [invisible], [newpm], [accessmasks]) VALUES(@username,@nickname, @password, @secques, @gender, @adminid, @groupid, @groupexpiry, @extgroupids, @regip, @joindate, @lastip, @lastvisit, @lastactivity, @lastpost, @lastpostid, @lastposttitle, @posts, @digestposts, @oltime, @pageviews, @credits, @extcredits1, @extcredits2, @extcredits3, @extcredits4, @extcredits5, @extcredits6, @extcredits7, @extcredits8, @avatarshowid, @email, @bday, @sigstatus, @salt, @tpp, @ppp, @templateid, @pmsound, @showemail, @newsletter, @invisible, @newpm, @accessmasks)
  398. SELECT SCOPE_IDENTITY()  AS 'userid'
  399. SET @uid = SCOPE_IDENTITY()
  400. IF @@ERROR=0
  401. BEGIN
  402. UPDATE [dnt_statistics] SET [totalusers]=[totalusers] + 1,[lastusername]=@username,[lastuserid]=@uid
  403. END
  404. INSERT INTO dnt_userfields 
  405. ([uid],[website],[icq],[qq],[yahoo],[msn],[skype],[location],[customstatus],[avatar],[avatarwidth],[avatarheight],[medals],[bio],[signature],[sightml],[authstr],[realname],[idcard],[mobile],[phone])
  406. VALUES
  407. (@uid,@website,@icq,@qq,@yahoo,@msn,@skype,@location,@customstatus,@avatar,@avatarwidth,@avatarheight,@medals,@bio,@signature,@sightml,@authstr,@realname,@idcard,@mobile,@phone)
  408. GO
  409. IF OBJECT_ID('[dnt_deletepost1bypid]','P') IS NOT NULL
  410. DROP PROC [dnt_deletepost1bypid]
  411. GO
  412. CREATE PROCEDURE [dnt_deletepost1bypid]
  413.                         @pid int,
  414. @chanageposts AS BIT
  415.                     AS
  416.                         DECLARE @fid int
  417.                         DECLARE @tid int
  418.                         DECLARE @posterid int
  419.                         DECLARE @lastforumposterid int
  420.                         DECLARE @layer int
  421.                         DECLARE @postdatetime smalldatetime
  422.                         DECLARE @poster varchar(50)
  423.                         DECLARE @postcount int
  424.                         DECLARE @title nchar(60)
  425.                         DECLARE @lasttid int
  426.                         DECLARE @postid int
  427.                         DECLARE @todaycount int
  428.                     
  429.                     
  430.                         SELECT @fid = [fid],@tid = [tid],@posterid = [posterid],@layer = [layer], @postdatetime = [postdatetime] FROM [dnt_posts1] WHERE pid = @pid
  431.                         DECLARE @fidlist AS VARCHAR(1000)
  432.                     
  433.                         SET @fidlist = '';
  434.                     
  435.                         SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
  436.                         IF RTRIM(@fidlist)<>''
  437.                             BEGIN
  438.                                 SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
  439.                             END
  440.                         ELSE
  441.                             BEGIN
  442.                                 SET @fidlist = CAST(@fid AS VARCHAR(10))
  443.                             END
  444.                         IF @layer<>0
  445.                             BEGIN
  446.                     
  447. IF @chanageposts = 1
  448. BEGIN
  449. UPDATE [dnt_statistics] SET [totalpost]=[totalpost] - 1
  450. UPDATE [dnt_forums] SET 
  451. [posts]=[posts] - 1, 
  452. [todayposts]=CASE 
  453. WHEN DATEPART(yyyy, @postdatetime)=DATEPART(yyyy,GETDATE()) AND DATEPART(mm, @postdatetime)=DATEPART(mm,GETDATE()) AND DATEPART(dd, @postdatetime)=DATEPART(dd,GETDATE()) THEN [todayposts] - 1
  454. ELSE [todayposts]
  455. END
  456. WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
  457. (SELECT @fidlist AS [fid]) + ',') > 0)
  458.                     
  459. UPDATE [dnt_users] SET [posts] = [posts] - 1 WHERE [uid] = @posterid
  460. UPDATE [dnt_topics] SET [replies]=[replies] - 1 WHERE [tid]=@tid
  461. END
  462.                     
  463.                                 DELETE FROM [dnt_posts1] WHERE [pid]=@pid
  464.                     
  465.                             END
  466.                         ELSE
  467.                             BEGIN
  468.                     
  469.                                 SELECT @postcount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid
  470.                                 SELECT @todaycount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid AND DATEDIFF(d, [postdatetime], GETDATE()) = 0
  471.                     
  472. IF @chanageposts = 1
  473. BEGIN
  474. UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] - 1, [totalpost]=[totalpost] - @postcount
  475.                     
  476. UPDATE [dnt_forums] SET [posts]=[posts] - @postcount, [topics]=[topics] - 1,[todayposts]=[todayposts] - @todaycount WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +(SELECT @fidlist AS [fid]) + ',') > 0)
  477.                     
  478. UPDATE [dnt_users] SET [posts] = [posts] - @postcount WHERE [uid] = @posterid
  479.                     
  480. END
  481.                                 DELETE FROM [dnt_posts1] WHERE [tid] = @tid
  482.                     
  483.                                 DELETE FROM [dnt_topics] WHERE [tid] = @tid
  484.                     
  485.                             END
  486.                     
  487.                         IF @layer<>0
  488.                             BEGIN
  489.                                 SELECT TOP 1 @pid = [pid], @posterid = [posterid], @postdatetime = [postdatetime], @title = [title], @poster = [poster] FROM [dnt_posts1] WHERE [tid]=@tid ORDER BY [pid] DESC
  490.                                 UPDATE [dnt_topics] SET [lastposter]=@poster,[lastpost]=@postdatetime,[lastpostid]=@pid,[lastposterid]=@posterid WHERE [tid]=@tid
  491.                             END
  492.                         SELECT @lasttid = [lasttid] FROM [dnt_forums] WHERE [fid] = @fid
  493.                     
  494.                         IF @lasttid = @tid
  495.                             BEGIN
  496.                     
  497.                     
  498.                                 SELECT TOP 1 @pid = [pid], @tid = [tid],@lastforumposterid = [posterid], @title = [title], @postdatetime = [postdatetime], @poster = [poster] FROM [dnt_posts1] WHERE [fid] = @fid ORDER BY [pid] DESC
  499.                     
  500.                             
  501.                             
  502.                                 UPDATE [dnt_forums] SET 
  503.                     
  504.                                 [lastpost]=@postdatetime,
  505.                                 [lastposter]=ISNULL(@poster,''),
  506.                                 [lastposterid]=ISNULL(@lastforumposterid,'0')
  507.                                 WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
  508.                                 (SELECT @fidlist AS [fid]) + ',') > 0)
  509.                     
  510.                                 SELECT TOP 1 @pid = [pid], @tid = [tid],@posterid = [posterid], @postdatetime = [postdatetime], @title = [title], @poster = [poster] FROM [dnt_posts1] WHERE [posterid]=@posterid ORDER BY [pid] DESC
  511.                     
  512.                                 UPDATE [dnt_users] SET
  513.                     
  514.                                 [lastpost] = @postdatetime,
  515.                                 [lastpostid] = @pid,
  516.                                 [lastposttitle] = ISNULL(@title,'')
  517.                     
  518.                                 WHERE [uid] = @posterid
  519.                     
  520.                             END
  521. GO
  522. IF OBJECT_ID('[dnt_deletetopictags]','P') IS NOT NULL
  523. DROP PROC [dnt_deletetopictags]
  524. GO
  525. CREATE PROCEDURE [dnt_deletetopictags]
  526. @tid int
  527.  AS
  528. BEGIN       
  529. UPDATE [dnt_tags] SET [count]=[count]-1,[fcount]=[fcount]-1 
  530. WHERE EXISTS (SELECT [tagid] FROM [dnt_topictags] WHERE [tid] = @tid AND [tagid] = [dnt_tags].[tagid])
  531.     DELETE FROM [dnt_topictags] WHERE [tid] = @tid
  532. END
  533. GO
  534. IF OBJECT_ID('[dnt_getalltopiccount]','P') IS NOT NULL
  535. DROP PROC [dnt_getalltopiccount]
  536. GO
  537. CREATE PROCEDURE [dnt_getalltopiccount]
  538. @fid int
  539. AS
  540. SELECT COUNT(tid) FROM [dnt_topics] WHERE ([fid]=@fid   OR   [fid]  IN (  SELECT fid  FROM [dnt_forums]  WHERE  CHARINDEX(',' + RTRIM(@fid) + ',', ',' + parentidlist + ',') > 0))  AND [displayorder]>=0
  541. GO
  542. IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(N'[dnt_getdebatepostlist1]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  543. DROP PROCEDURE [dnt_getdebatepostlist1]
  544. GO
  545. CREATE PROCEDURE [dnt_getdebatepostlist1] 
  546. @tid int,
  547. @opinion int,
  548. @pagesize int,
  549. @pageindex int
  550. AS
  551. DECLARE @startRow int,
  552. @endRow int
  553. SET @startRow = (@pageindex - 1) * @pagesize + 1
  554. SET @endRow = @startRow + @pagesize - 1
  555. SELECT 
  556. [DEBATEPOST].[attachment],
  557. [DEBATEPOST].[bbcodeoff],
  558. [DEBATEPOST].[fid],
  559. [DEBATEPOST].[htmlon],
  560. [DEBATEPOST].[invisible],
  561. [DEBATEPOST].[ip],
  562. [DEBATEPOST].[lastedit],
  563. [DEBATEPOST].[layer],
  564. [DEBATEPOST].[message],
  565. [DEBATEPOST].[parentid],
  566. [DEBATEPOST].[parseurloff],
  567. [DEBATEPOST].[pid],
  568. [DEBATEPOST].[postdatetime],
  569. [DEBATEPOST].[poster],
  570. [DEBATEPOST].[posterid],
  571. [DEBATEPOST].[rate],
  572. [DEBATEPOST].[ratetimes],
  573. [DEBATEPOST].[smileyoff],
  574. [DEBATEPOST].[tid],
  575. [DEBATEPOST].[title],
  576. [DEBATEPOST].[usesig],
  577. [DEBATEPOST].[accessmasks], 
  578. [DEBATEPOST].[adminid],
  579. [DEBATEPOST].[avatarshowid],
  580. [DEBATEPOST].[bday],
  581. [DEBATEPOST].[credits],
  582. [DEBATEPOST].[digestposts],
  583. [DEBATEPOST].[email],
  584. [DEBATEPOST].[extcredits1],
  585. [DEBATEPOST].[extcredits2],
  586. [DEBATEPOST].[extcredits3],
  587. [DEBATEPOST].[extcredits4],
  588. [DEBATEPOST].[extcredits5],
  589. [DEBATEPOST].[extcredits6],
  590. [DEBATEPOST].[extcredits7],
  591. [DEBATEPOST].[extcredits8],
  592. [DEBATEPOST].[extgroupids],
  593. [DEBATEPOST].[gender],
  594. [DEBATEPOST].[groupexpiry],
  595. [DEBATEPOST].[groupid],
  596. [DEBATEPOST].[joindate],
  597. [DEBATEPOST].[lastactivity],
  598. [DEBATEPOST].[lastip],
  599. [DEBATEPOST].[lastpost],
  600. [DEBATEPOST].[lastpostid],
  601. [DEBATEPOST].[lastposttitle],
  602. [DEBATEPOST].[lastvisit],
  603. [DEBATEPOST].[newpm],
  604. [DEBATEPOST].[newpmcount],
  605. [DEBATEPOST].[newsletter],
  606. [DEBATEPOST].[nickname],
  607. [DEBATEPOST].[oltime],
  608. [DEBATEPOST].[onlinestate],
  609. [DEBATEPOST].[pageviews],
  610. [DEBATEPOST].[password],
  611. [DEBATEPOST].[pmsound],
  612. [DEBATEPOST].[posts],
  613. [DEBATEPOST].[ppp],
  614. [DEBATEPOST].[regip],
  615. [DEBATEPOST].[secques],
  616. [DEBATEPOST].[showemail],
  617. [DEBATEPOST].[sigstatus],
  618. [DEBATEPOST].[spaceid],
  619. [DEBATEPOST].[templateid],
  620. [DEBATEPOST].[tpp],
  621. [DEBATEPOST].[uid],
  622. [DEBATEPOST].[username],
  623. [DEBATEPOST].[authflag],
  624. [DEBATEPOST].[authstr],
  625. [DEBATEPOST].[authtime],
  626. [DEBATEPOST].[avatar],
  627. [DEBATEPOST].[avatarheight],
  628. [DEBATEPOST].[avatarwidth],
  629. [DEBATEPOST].[bio],
  630. [DEBATEPOST].[customstatus],
  631. [DEBATEPOST].[icq],
  632. [DEBATEPOST].[idcard],
  633. [DEBATEPOST].[ignorepm],
  634. [DEBATEPOST].[location],
  635. [DEBATEPOST].[medals],
  636. [DEBATEPOST].[mobile],
  637. [DEBATEPOST].[msn],
  638. [DEBATEPOST].[phone],
  639. [DEBATEPOST].[qq],
  640. [DEBATEPOST].[realname],
  641. [DEBATEPOST].[sightml],
  642. [DEBATEPOST].[signature],
  643. [DEBATEPOST].[skype],
  644. [DEBATEPOST].[website],
  645. [DEBATEPOST].[yahoo] 
  646. FROM ( SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  647. [dnt_posts1].[attachment],
  648. [dnt_posts1].[bbcodeoff],
  649. [dnt_posts1].[fid],
  650. [dnt_posts1].[htmlon],
  651. [dnt_posts1].[invisible],
  652. [dnt_posts1].[ip],
  653. [dnt_posts1].[lastedit],
  654. [dnt_posts1].[layer],
  655. [dnt_posts1].[message],
  656. [dnt_posts1].[parentid],
  657. [dnt_posts1].[parseurloff],
  658. [dnt_posts1].[pid],
  659. [dnt_posts1].[postdatetime],
  660. [dnt_posts1].[poster],
  661. [dnt_posts1].[posterid],
  662. [dnt_posts1].[rate],
  663. [dnt_posts1].[ratetimes],
  664. [dnt_posts1].[smileyoff],
  665. [dnt_posts1].[tid],
  666. [dnt_posts1].[title],
  667. [dnt_posts1].[usesig],
  668. [dnt_users].[accessmasks], 
  669. [dnt_users].[adminid],
  670. [dnt_users].[avatarshowid],
  671. [dnt_users].[bday],
  672. [dnt_users].[credits],
  673. [dnt_users].[digestposts],
  674. [dnt_users].[email],
  675. [dnt_users].[extcredits1],
  676. [dnt_users].[extcredits2],
  677. [dnt_users].[extcredits3],
  678. [dnt_users].[extcredits4],
  679. [dnt_users].[extcredits5],
  680. [dnt_users].[extcredits6],
  681. [dnt_users].[extcredits7],
  682. [dnt_users].[extcredits8],
  683. [dnt_users].[extgroupids],
  684. [dnt_users].[gender],
  685. [dnt_users].[groupexpiry],
  686. [dnt_users].[groupid],
  687. [dnt_users].[joindate],
  688. [dnt_users].[lastactivity],
  689. [dnt_users].[lastip],
  690. [dnt_users].[lastpost],
  691. [dnt_users].[lastpostid],
  692. [dnt_users].[lastposttitle],
  693. [dnt_users].[lastvisit],
  694. [dnt_users].[newpm],
  695. [dnt_users].[newpmcount],
  696. [dnt_users].[newsletter],
  697. [dnt_users].[nickname],
  698. [dnt_users].[oltime],
  699. [dnt_users].[onlinestate],
  700. [dnt_users].[pageviews],
  701. [dnt_users].[password],
  702. [dnt_users].[pmsound],
  703. [dnt_users].[posts],
  704. [dnt_users].[ppp],
  705. [dnt_users].[regip],
  706. [dnt_users].[secques],
  707. [dnt_users].[showemail],
  708. [dnt_users].[sigstatus],
  709. [dnt_users].[spaceid],
  710. [dnt_users].[templateid],
  711. [dnt_users].[tpp],
  712. [dnt_users].[uid],
  713. [dnt_users].[username],
  714. [dnt_userfields].[authflag],
  715. [dnt_userfields].[authstr],
  716. [dnt_userfields].[authtime],
  717. [dnt_userfields].[avatar],
  718. [dnt_userfields].[avatarheight],
  719. [dnt_userfields].[avatarwidth],
  720. [dnt_userfields].[bio],
  721. [dnt_userfields].[customstatus],
  722. [dnt_userfields].[icq],
  723. [dnt_userfields].[idcard],
  724. [dnt_userfields].[ignorepm],
  725. [dnt_userfields].[location],
  726. [dnt_userfields].[medals],
  727. [dnt_userfields].[mobile],
  728. [dnt_userfields].[msn],
  729. [dnt_userfields].[phone],
  730. [dnt_userfields].[qq],
  731. [dnt_userfields].[realname],
  732. [dnt_userfields].[sightml],
  733. [dnt_userfields].[signature],
  734. [dnt_userfields].[skype],
  735. [dnt_userfields].[website],
  736. [dnt_userfields].[yahoo]
  737. FROM [dnt_posts1] 
  738. LEFT JOIN [dnt_users] ON [dnt_users].[uid] = [dnt_posts1].[posterid] 
  739. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_posts1].[posterid]
  740. WHERE [dnt_posts1].invisible=0 
  741. AND [dnt_posts1].pid IN (SELECT pid FROM dnt_postdebatefields WHERE opinion=@opinion AND tid=@tid)) AS DEBATEPOST
  742. WHERE ROWID BETWEEN @startRow AND @endRow
  743. GO
  744. IF OBJECT_ID('[dnt_getfavoritescount]','P') IS NOT NULL
  745. DROP PROC [dnt_getfavoritescount]
  746. GO
  747. CREATE PROCEDURE [dnt_getfavoritescount]
  748. @uid int,
  749. @typeid smallint
  750. AS
  751.      SELECT COUNT(uid)  FROM [dnt_favorites] WHERE [uid]=@uid AND [typeid]=@typeid
  752. GO
  753. IF OBJECT_ID ('dnt_getfavoriteslist','P') IS NOT NULL
  754. DROP PROCEDURE [dnt_getfavoriteslist]
  755. GO
  756. CREATE PROCEDURE [dnt_getfavoriteslist]
  757. @uid int,
  758. @pagesize int,
  759. @pageindex int
  760. AS
  761. --SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid
  762. IF @pageindex = 1
  763. BEGIN
  764. SELECT TOP(@pagesize) [uid],[tid],[title],[poster],[postdatetime],[replies],[views],[posterid]  
  765. FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) favorites ORDER BY [tid] DESC
  766. END
  767. ELSE
  768. BEGIN
  769. SELECT TOP(@pagesize) [uid],[tid],[title],[poster],[postdatetime],[replies],[views],[posterid] 
  770.     FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) f1 WHERE [tid] < (SELECT MIN([tid]) FROM (SELECT TOP((@pageindex-1)*@pagesize) [tid] 
  771.     FROM (SELECT [f].[uid],[f].[tid],[topics].[title],[topics].[poster],[topics].[postdatetime],[topics].[replies],[topics].[views],[topics].[posterid] FROM [dnt_favorites] [f] LEFT JOIN [dnt_topics] [topics]  ON   [f].[tid]=[topics].[tid] WHERE  [f].[typeid]=0 AND [f].[uid]=@uid) f2 ORDER BY [tid] DESC) AS tblTmp)  ORDER BY [tid] DESC
  772. END
  773. GO
  774. IF OBJECT_ID('[dnt_getlastexecutescheduledeventdatetime]','P') IS NOT NULL
  775. DROP PROC [dnt_getlastexecutescheduledeventdatetime]
  776. GO
  777. CREATE PROCEDURE [dnt_getlastexecutescheduledeventdatetime]
  778. (
  779. @key VARCHAR(100),
  780. @servername VARCHAR(100),
  781. @lastexecuted DATETIME OUTPUT
  782. )
  783. AS
  784. SELECT @lastexecuted = MAX([lastexecuted]) FROM [dnt_scheduledevents] WHERE [key] = @key AND [servername] = @servername
  785. IF(@lastexecuted IS NULL)
  786. BEGIN
  787. SET @lastexecuted = DATEADD(YEAR,-1,GETDATE())
  788. END
  789. GO
  790. IF OBJECT_ID ('dnt_getlastpostlist1','P') IS NOT NULL
  791. DROP PROCEDURE [dnt_getlastpostlist1]
  792. GO
  793. CREATE PROCEDURE [dnt_getlastpostlist1]
  794. @tid int,
  795. @pageindex int,
  796. @postnum int
  797. --@posttablename varchar(20)
  798. AS
  799. DECLARE @startRow int,
  800. @endRow int
  801. SET @startRow = (@pageIndex - 1) * @postnum +1
  802. SET @endRow = @startRow + @postnum -1
  803. SELECT 
  804. [POST].[pid],
  805. [POST].[fid], 
  806. [POST].[layer],
  807. [POST].[posterid],
  808. [POST].[title], 
  809. [POST].[message], 
  810. [POST].[postdatetime], 
  811. [POST].[attachment], 
  812. [POST].[poster], 
  813. [POST].[invisible], 
  814. [POST].[usesig], 
  815. [POST].[htmlon], 
  816. [POST].[smileyoff], 
  817. [POST].[parseurloff], 
  818. [POST].[bbcodeoff], 
  819. [POST].[rate], 
  820. [POST].[ratetimes], 
  821. [POST].[username], 
  822. [POST].[email], 
  823. [POST].[showemail], 
  824. [POST].[avatar], 
  825. [POST].[avatarwidth], 
  826. [POST].[avatarheight], 
  827. [POST].[signature], 
  828. [POST].[location], 
  829. [POST].[customstatus] 
  830. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  831. [dnt_posts1].[pid],
  832. [dnt_posts1].[fid], 
  833. [dnt_posts1].[layer],
  834. [dnt_posts1].[posterid],
  835. [dnt_posts1].[title], 
  836. [dnt_posts1].[message], 
  837. [dnt_posts1].[postdatetime], 
  838. [dnt_posts1].[attachment], 
  839. [dnt_posts1].[poster], 
  840. [dnt_posts1].[invisible], 
  841. [dnt_posts1].[usesig], 
  842. [dnt_posts1].[htmlon], 
  843. [dnt_posts1].[smileyoff], 
  844. [dnt_posts1].[parseurloff], 
  845. [dnt_posts1].[bbcodeoff], 
  846. [dnt_posts1].[rate], 
  847. [dnt_posts1].[ratetimes], 
  848. [dnt_users].[username], 
  849. [dnt_users].[email], 
  850. [dnt_users].[showemail], 
  851. [dnt_userfields].[avatar], 
  852. [dnt_userfields].[avatarwidth], 
  853. [dnt_userfields].[avatarheight], 
  854. [dnt_userfields].[sightml] AS [signature], 
  855. [dnt_userfields].[location], 
  856. [dnt_userfields].[customstatus] 
  857. FROM [dnt_posts1] 
  858. LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid]
  859. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
  860. WHERE [dnt_posts1].[tid] = @tid AND [dnt_posts1].[invisible] <=0 AND [dnt_posts1].layer <> 0) AS POST
  861. WHERE ROWID BETWEEN @startRow AND @endRow
  862. GO
  863. IF OBJECT_ID ('dnt_getmyattachments','P') IS NOT NULL
  864. DROP PROCEDURE [dnt_getmyattachments]
  865. GO
  866. CREATE PROCEDURE [dnt_getmyattachments]
  867. @uid int,
  868. @pageindex int,
  869. @pagesize int
  870.  AS
  871. DECLARE @startRow int,
  872. @endRow int
  873. SET @startRow=(@pageindex-1) * @pagesize + 1
  874. SET @endRow = @startRow + @pagesize - 1
  875. SELECT 
  876. [ATTACHMENTS].[aid],
  877. [ATTACHMENTS].[uid],
  878. [ATTACHMENTS].[attachment],
  879. [ATTACHMENTS].[description],
  880. [ATTACHMENTS].[downloads],
  881. [ATTACHMENTS].[extname],
  882. [ATTACHMENTS].[filename],
  883. [ATTACHMENTS].[pid],
  884. [ATTACHMENTS].[postdatetime],
  885. [ATTACHMENTS].[tid]
  886. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [aid] DESC) AS ROWID,
  887. [dnt_myattachments].[aid],
  888. [dnt_myattachments].[uid],
  889. [dnt_myattachments].[attachment],
  890. [dnt_myattachments].[description],
  891. [dnt_myattachments].[downloads],
  892. [dnt_myattachments].[extname],
  893. [dnt_myattachments].[filename],
  894. [dnt_myattachments].[pid],
  895. [dnt_myattachments].[postdatetime],
  896. [dnt_myattachments].[tid]
  897. FROM [dnt_myattachments]
  898. WHERE [dnt_myattachments].[uid] = @uid ) AS ATTACHMENTS
  899. WHERE ROWID BETWEEN @startRow AND @endRow
  900. GO
  901. IF OBJECT_ID ('dnt_getmyattachmentsbytype','P') IS NOT NULL
  902. DROP PROCEDURE [dnt_getmyattachmentsbytype]
  903. GO
  904. CREATE PROCEDURE [dnt_getmyattachmentsbytype]
  905. @uid int,
  906. @pageindex int,
  907. @pagesize int,
  908. @extlist as nvarchar(100)
  909. AS
  910. DECLARE @startRow int,
  911. @endRow int
  912. SET @startRow=(@pageindex - 1) * @pagesize + 1
  913. SET @endRow = @startRow + @pagesize - 1
  914. SELECT 
  915. [ATTACHMENTS].[aid],
  916. [ATTACHMENTS].[uid],
  917. [ATTACHMENTS].[attachment],
  918. [ATTACHMENTS].[description],
  919. [ATTACHMENTS].[downloads],
  920. [ATTACHMENTS].[extname],
  921. [ATTACHMENTS].[filename],
  922. [ATTACHMENTS].[pid],
  923. [ATTACHMENTS].[postdatetime],
  924. [ATTACHMENTS].[tid]
  925. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [aid] DESC) AS ROWID,
  926. [dnt_myattachments].[aid],
  927. [dnt_myattachments].[uid],
  928. [dnt_myattachments].[attachment],
  929. [dnt_myattachments].[description],
  930. [dnt_myattachments].[downloads],
  931. [dnt_myattachments].[extname],
  932. [dnt_myattachments].[filename],
  933. [dnt_myattachments].[pid],
  934. [dnt_myattachments].[postdatetime],
  935. [dnt_myattachments].[tid]
  936. FROM [dnt_myattachments]
  937. WHERE [uid] = @uid AND CHARINDEX([dnt_myattachments].[extname], @extlist) > 0) AS ATTACHMENTS
  938. WHERE ROWID BETWEEN @startRow AND @endRow
  939. GO
  940. IF OBJECT_ID ('dnt_getmyposts','P') IS NOT NULL
  941. DROP PROCEDURE [dnt_getmyposts]
  942. GO
  943. CREATE PROCEDURE [dnt_getmyposts]
  944. @uid int,
  945. @pageindex int,
  946. @pagesize int
  947.  AS
  948. DECLARE @startRow int,
  949. @endRow int
  950. SET @startRow = ( @pageindex - 1 ) * @pagesize + 1
  951. SET @endRow = @startRow + @pagesize - 1
  952. SELECT 
  953. [MYPOST].[tid], 
  954. [MYPOST].[fid], 
  955. [MYPOST].[iconid], 
  956. [MYPOST].[typeid], 
  957. [MYPOST].[readperm], 
  958. [MYPOST].[price], 
  959. [MYPOST].[poster], 
  960. [MYPOST].[posterid], 
  961. [MYPOST].[title], 
  962. [MYPOST].[postdatetime], 
  963. [MYPOST].[lastpost], 
  964. [MYPOST].[lastpostid], 
  965. [MYPOST].[lastposter], 
  966. [MYPOST].[lastposterid], 
  967. [MYPOST].[views], 
  968. [MYPOST].[replies], 
  969. [MYPOST].[displayorder], 
  970. [MYPOST].[highlight], 
  971. [MYPOST].[digest], 
  972. [MYPOST].[rate], 
  973. [MYPOST].[hide], 
  974. [MYPOST].[special], 
  975. [MYPOST].[attachment], 
  976. [MYPOST].[moderated], 
  977. [MYPOST].[closed], 
  978. [MYPOST].[magic] 
  979. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_myposts].[tid] DESC) AS ROWID,
  980. [dnt_topics].[tid], 
  981. [dnt_topics].[fid], 
  982. [dnt_topics].[iconid], 
  983. [dnt_topics].[typeid], 
  984. [dnt_topics].[readperm], 
  985. [dnt_topics].[price], 
  986. [dnt_topics].[poster], 
  987. [dnt_topics].[posterid], 
  988. [dnt_topics].[title], 
  989. [dnt_topics].[postdatetime], 
  990. [dnt_topics].[lastpost], 
  991. [dnt_topics].[lastpostid], 
  992. [dnt_topics].[lastposter], 
  993. [dnt_topics].[lastposterid], 
  994. [dnt_topics].[views], 
  995. [dnt_topics].[replies], 
  996. [dnt_topics].[displayorder], 
  997. [dnt_topics].[highlight], 
  998. [dnt_topics].[digest], 
  999. [dnt_topics].[rate], 
  1000. [dnt_topics].[hide], 
  1001. [dnt_topics].[special], 
  1002. [dnt_topics].[attachment], 
  1003. [dnt_topics].[moderated], 
  1004. [dnt_topics].[closed], 
  1005. [dnt_topics].[magic]
  1006. FROM [dnt_topics] 
  1007. INNER JOIN [dnt_myposts] ON ([dnt_topics].[tid] = [dnt_myposts].[tid] AND [dnt_myposts].[uid] = @uid)) AS MYPOST
  1008. WHERE ROWID BETWEEN @startRow AND @endRow
  1009. GO
  1010. IF OBJECT_ID ('dnt_getmytopics','P') IS NOT NULL
  1011. DROP PROCEDURE [dnt_getmytopics]
  1012. GO
  1013. CREATE PROCEDURE [dnt_getmytopics]
  1014. @uid int,
  1015. @pageindex int,
  1016. @pagesize int
  1017. AS
  1018. DECLARE @startRow int,
  1019. @endRow int
  1020. SET @startRow = ( @pageindex - 1 ) * @pagesize + 1 
  1021. SET @endRow = @startRow + @pagesize - 1
  1022. SELECT 
  1023. [MYTOPIC].[tid], 
  1024. [MYTOPIC].[fid], 
  1025. [MYTOPIC].[iconid], 
  1026. [MYTOPIC].[typeid], 
  1027. [MYTOPIC].[readperm], 
  1028. [MYTOPIC].[price], 
  1029. [MYTOPIC].[poster], 
  1030. [MYTOPIC].[posterid], 
  1031. [MYTOPIC].[title], 
  1032. [MYTOPIC].[postdatetime], 
  1033. [MYTOPIC].[lastpost], 
  1034. [MYTOPIC].[lastpostid], 
  1035. [MYTOPIC].[lastposter], 
  1036. [MYTOPIC].[lastposterid], 
  1037. [MYTOPIC].[views], 
  1038. [MYTOPIC].[replies], 
  1039. [MYTOPIC].[displayorder], 
  1040. [MYTOPIC].[highlight], 
  1041. [MYTOPIC].[digest], 
  1042. [MYTOPIC].[rate], 
  1043. [MYTOPIC].[hide], 
  1044. [MYTOPIC].[special], 
  1045. [MYTOPIC].[attachment], 
  1046. [MYTOPIC].[moderated], 
  1047. [MYTOPIC].[closed], 
  1048. [MYTOPIC].[magic]
  1049. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_topics].[lastpost] DESC) AS ROWID,
  1050. [dnt_topics].[tid], 
  1051. [dnt_topics].[fid], 
  1052. [dnt_topics].[iconid], 
  1053. [dnt_topics].[typeid], 
  1054. [dnt_topics].[readperm], 
  1055. [dnt_topics].[price], 
  1056. [dnt_topics].[poster], 
  1057. [dnt_topics].[posterid], 
  1058. [dnt_topics].[title], 
  1059. [dnt_topics].[postdatetime], 
  1060. [dnt_topics].[lastpost], 
  1061. [dnt_topics].[lastpostid], 
  1062. [dnt_topics].[lastposter], 
  1063. [dnt_topics].[lastposterid], 
  1064. [dnt_topics].[views], 
  1065. [dnt_topics].[replies], 
  1066. [dnt_topics].[displayorder], 
  1067. [dnt_topics].[highlight], 
  1068. [dnt_topics].[digest], 
  1069. [dnt_topics].[rate], 
  1070. [dnt_topics].[hide], 
  1071. [dnt_topics].[special], 
  1072. [dnt_topics].[attachment], 
  1073. [dnt_topics].[moderated], 
  1074. [dnt_topics].[closed], 
  1075. [dnt_topics].[magic]
  1076. FROM [dnt_topics] 
  1077. INNER JOIN [dnt_mytopics] ON ([dnt_topics].[tid] = [dnt_mytopics].[tid] AND [dnt_mytopics].[uid] = @uid)) AS MYTOPIC
  1078. WHERE ROWID BETWEEN @startRow AND @endRow
  1079. GO
  1080. IF OBJECT_ID('[dnt_getpmcount]','P') IS NOT NULL
  1081. DROP PROC [dnt_getpmcount]
  1082. GO
  1083. CREATE PROCEDURE [dnt_getpmcount]
  1084. @userid int,
  1085. @folder int=0,
  1086. @state int=-1
  1087. AS
  1088. IF @folder=-1
  1089. BEGIN
  1090.   SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE ([msgtoid] = @userid AND [folder]=0) OR ([msgfromid] = @userid AND [folder] = 1) OR ([msgfromid] = @userid AND [folder] = 2)
  1091. END
  1092. ELSE
  1093.     BEGIN
  1094. IF @folder=0
  1095. BEGIN
  1096. IF @state=-1
  1097. BEGIN
  1098. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder
  1099. END
  1100. ELSE IF @state=2
  1101. BEGIN
  1102. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder AND [new]=1 AND GETDATE()-[postdatetime]<3
  1103. END
  1104. ELSE
  1105. BEGIN
  1106. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgtoid] = @userid AND [folder] = @folder AND [new] = @state
  1107. END
  1108. END
  1109. ELSE
  1110. BEGIN
  1111. IF @state=-1
  1112. BEGIN
  1113. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder
  1114. END
  1115. ELSE IF @state=2
  1116. BEGIN
  1117. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder AND [new]=1 AND GETDATE()-[postdatetime]<3
  1118. END
  1119. ELSE
  1120. BEGIN
  1121. SELECT COUNT(pmid) AS [pmcount] FROM [dnt_pms] WHERE [msgfromid] = @userid AND [folder] = @folder AND [new] = @state
  1122. END
  1123. END
  1124. END
  1125. GO
  1126. IF OBJECT_ID('[dnt_getnoticecount]','P') IS NOT NULL
  1127. DROP PROC [dnt_getnoticecount]
  1128. GO
  1129. CREATE PROCEDURE [dnt_getnoticecount]
  1130. @userid int,
  1131. @type int = -1,
  1132. @state int=-1
  1133. AS
  1134. IF @type = -1
  1135. BEGIN
  1136. IF @state = -1
  1137. BEGIN
  1138. SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid
  1139. END
  1140. ELSE
  1141. BEGIN
  1142. SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [new]=@state
  1143. END
  1144. END
  1145. ELSE
  1146. BEGIN
  1147. IF @state = -1
  1148. BEGIN
  1149. SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [type]=@type
  1150. END
  1151. ELSE
  1152. BEGIN
  1153. SELECT COUNT(nid) AS [pmcount] FROM [dnt_notices] WHERE [uid]=@userid AND [new]=@state AND [type]=@type
  1154. END
  1155. END
  1156. GO
  1157. IF OBJECT_ID('dnt_getpmlist','P') IS NOT NULL
  1158. DROP PROC [dnt_getpmlist]
  1159. GO
  1160. CREATE PROCEDURE [dnt_getpmlist]
  1161. @userid int,
  1162. @folder int,
  1163. @pagesize int,
  1164. @pageindex int,
  1165. @inttype int
  1166. AS
  1167. DECLARE @startRow int,
  1168. @endRow int
  1169. SET @startRow = (@pageindex - 1) * @pagesize + 1
  1170. SET @endRow = @startRow + @pagesize - 1
  1171. IF (@folder <> 0)
  1172. BEGIN
  1173. IF (@inttype <> 1)
  1174. BEGIN
  1175. SELECT 
  1176. [PMS].[pmid],
  1177. [PMS].[msgfrom],
  1178. [PMS].[msgfromid],
  1179. [PMS].[msgto],
  1180. [PMS].[msgtoid],
  1181. [PMS].[folder],
  1182. [PMS].[new],
  1183. [PMS].[subject],
  1184. [PMS].[postdatetime],
  1185. [PMS].[message]
  1186. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
  1187. [pmid],
  1188. [msgfrom],
  1189. [msgfromid],
  1190. [msgto],
  1191. [msgtoid],
  1192. [folder],
  1193. [new],
  1194. [subject],
  1195. [postdatetime],
  1196. [message]
  1197. FROM [dnt_pms]
  1198. WHERE [msgfromid] = @userid AND [folder] = @folder) AS PMS
  1199. WHERE ROWID BETWEEN @startRow AND @endRow
  1200. END
  1201. ELSE
  1202. BEGIN
  1203. SELECT 
  1204. [PMS].[pmid],
  1205. [PMS].[msgfrom],
  1206. [PMS].[msgfromid],
  1207. [PMS].[msgto],
  1208. [PMS].[msgtoid],
  1209. [PMS].[folder],
  1210. [PMS].[new],
  1211. [PMS].[subject],
  1212. [PMS].[postdatetime],
  1213. [PMS].[message]
  1214. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
  1215. [pmid],
  1216. [msgfrom],
  1217. [msgfromid],
  1218. [msgto],
  1219. [msgtoid],
  1220. [folder],
  1221. [new],
  1222. [subject],
  1223. [postdatetime],
  1224. [message]
  1225. FROM [dnt_pms]
  1226. WHERE [msgfromid] = @userid AND [folder] = @folder AND [new] = 1) AS PMS
  1227. WHERE ROWID BETWEEN @startRow AND @endRow
  1228. END
  1229. END
  1230. ELSE
  1231. BEGIN
  1232. IF (@inttype <> 1)
  1233. BEGIN
  1234. SELECT 
  1235. [PMS].[pmid],
  1236. [PMS].[msgfrom],
  1237. [PMS].[msgfromid],
  1238. [PMS].[msgto],
  1239. [PMS].[msgtoid],
  1240. [PMS].[folder],
  1241. [PMS].[new],
  1242. [PMS].[subject],
  1243. [PMS].[postdatetime],
  1244. [PMS].[message] 
  1245. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
  1246. [pmid],
  1247. [msgfrom],
  1248. [msgfromid],
  1249. [msgto],
  1250. [msgtoid],
  1251. [folder],
  1252. [new],
  1253. [subject],
  1254. [postdatetime],
  1255. [message]
  1256. FROM [dnt_pms]
  1257. WHERE [msgtoid] = @userid AND [folder] = @folder) AS PMS
  1258. WHERE ROWID BETWEEN @startRow AND @endRow
  1259. END
  1260. ELSE
  1261. BEGIN
  1262. SELECT 
  1263. [PMS].[pmid],
  1264. [PMS].[msgfrom],
  1265. [PMS].[msgfromid],
  1266. [PMS].[msgto],
  1267. [PMS].[msgtoid],
  1268. [PMS].[folder],
  1269. [PMS].[new],
  1270. [PMS].[subject],
  1271. [PMS].[postdatetime],
  1272. [PMS].[message] 
  1273. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pmid] DESC) AS ROWID,
  1274. [pmid],
  1275. [msgfrom],
  1276. [msgfromid],
  1277. [msgto],
  1278. [msgtoid],
  1279. [folder],
  1280. [new],
  1281. [subject],
  1282. [postdatetime],
  1283. [message]
  1284. FROM [dnt_pms]
  1285. WHERE [msgtoid] = @userid AND [folder] = @folder AND [new] = 1) AS PMS
  1286. WHERE ROWID BETWEEN @startRow AND @endRow
  1287. END
  1288. END
  1289. GO
  1290. IF OBJECT_ID('[dnt_getpost1count]','P') IS NOT NULL
  1291. DROP PROC [dnt_getpost1count]
  1292. GO
  1293. CREATE PROCEDURE [dnt_getpost1count]
  1294. @tid int
  1295. AS
  1296. SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid] = @tid AND [invisible]=0 AND layer>0
  1297. GO
  1298. IF OBJECT_ID('dnt_getpost1tree','P') IS NOT NULL
  1299. DROP PROC dnt_getpost1tree
  1300. GO
  1301. CREATE PROCEDURE dnt_getpost1tree
  1302. @tid int
  1303. AS
  1304. SELECT [pid], [layer], [title], [poster], [posterid],[postdatetime],[message] FROM [dnt_posts1] WHERE [tid] = @tid AND [invisible]=0 ORDER BY [parentid];
  1305. GO
  1306. IF OBJECT_ID('dnt_getpostcountbycondition1','P') IS NOT NULL
  1307. DROP PROC [dnt_getpostcountbycondition1]
  1308. GO
  1309. CREATE PROCEDURE [dnt_getpostcountbycondition1]
  1310. @tid int,
  1311. @posterid int
  1312. AS
  1313. SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid] = @tid AND [posterid] = @posterid  AND [layer]>=0
  1314. GO
  1315. IF OBJECT_ID('[dnt_getshortuserinfo]','P') IS NOT NULL
  1316. DROP PROC [dnt_getshortuserinfo]
  1317. GO
  1318. CREATE PROCEDURE [dnt_getshortuserinfo]
  1319. @uid int
  1320. AS
  1321. SELECT TOP 1 * FROM [dnt_users] WHERE [uid]=@uid
  1322. GO
  1323. if exists (select * from sysobjects where id = object_id(N'[dnt_getsinglepost1]') and OBJECTPROPERTY(id,N'IsProcedure') = 1)
  1324. drop procedure [dnt_getsinglepost1]
  1325. GO
  1326. CREATE PROCEDURE [dnt_getsinglepost1]
  1327.                     @tid int,
  1328.                     @pid int
  1329.                     AS
  1330.                     SELECT [aid], [tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize], [attachment], [downloads], [attachprice], [uid], [width], [height] FROM [dnt_attachments] WHERE [tid]=@tid
  1331.                     SELECT TOP 1 
  1332.                                 [dnt_posts1].[pid], 
  1333.                                 [dnt_posts1].[fid], 
  1334.                                 [dnt_posts1].[title], 
  1335.                                 [dnt_posts1].[layer],
  1336.                                 [dnt_posts1].[message], 
  1337.                                 [dnt_posts1].[ip], 
  1338.                                 [dnt_posts1].[lastedit], 
  1339.                                 [dnt_posts1].[postdatetime], 
  1340.                                 [dnt_posts1].[attachment], 
  1341.                                 [dnt_posts1].[poster], 
  1342.                                 [dnt_posts1].[invisible], 
  1343.                                 [dnt_posts1].[usesig], 
  1344.                                 [dnt_posts1].[htmlon], 
  1345.                                 [dnt_posts1].[smileyoff], 
  1346.                                 [dnt_posts1].[parseurloff], 
  1347.                                 [dnt_posts1].[bbcodeoff], 
  1348.                                 [dnt_posts1].[rate], 
  1349.                                 [dnt_posts1].[ratetimes], 
  1350.                                 [dnt_posts1].[posterid], 
  1351.                                 [dnt_users].[nickname],  
  1352.                                 [dnt_users].[username], 
  1353.                                 [dnt_users].[groupid],
  1354.                                     [dnt_users].[spaceid],
  1355. [dnt_users].[gender],
  1356. [dnt_users].[bday], 
  1357.                                 [dnt_users].[email], 
  1358.                                 [dnt_users].[showemail], 
  1359.                                 [dnt_users].[digestposts], 
  1360.                                 [dnt_users].[credits], 
  1361.                                 [dnt_users].[extcredits1], 
  1362.                                 [dnt_users].[extcredits2], 
  1363.                                 [dnt_users].[extcredits3], 
  1364.                                 [dnt_users].[extcredits4], 
  1365.                                 [dnt_users].[extcredits5], 
  1366.                                 [dnt_users].[extcredits6], 
  1367.                                 [dnt_users].[extcredits7], 
  1368.                                 [dnt_users].[extcredits8], 
  1369.                                 [dnt_users].[posts], 
  1370.                                 [dnt_users].[joindate], 
  1371.                                 [dnt_users].[onlinestate], 
  1372.                                 [dnt_users].[lastactivity], 
  1373.                                 [dnt_users].[invisible],
  1374.                                 [dnt_users].[oltime],
  1375.                                 [dnt_users].[lastvisit],
  1376.                                 [dnt_userfields].[avatar], 
  1377.                                 [dnt_userfields].[avatarwidth], 
  1378.                                 [dnt_userfields].[avatarheight], 
  1379.                                 [dnt_userfields].[medals], 
  1380.                                 [dnt_userfields].[sightml] AS signature, 
  1381.                                 [dnt_userfields].[location], 
  1382.                                 [dnt_userfields].[customstatus], 
  1383.                                 [dnt_userfields].[website], 
  1384.                                 [dnt_userfields].[icq], 
  1385.                                 [dnt_userfields].[qq], 
  1386.                                 [dnt_userfields].[msn], 
  1387.                                 [dnt_userfields].[yahoo], 
  1388.                                 [dnt_userfields].[skype] 
  1389.                     FROM [dnt_posts1] LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid] WHERE [dnt_posts1].[pid]=@pid
  1390. GO
  1391. IF OBJECT_ID('dnt_getsitemapnewtopics','P') IS NOT NULL
  1392. DROP PROC [dnt_getsitemapnewtopics]
  1393. GO
  1394. CREATE PROCEDURE [dnt_getsitemapnewtopics]
  1395. @fidlist VARCHAR(500)
  1396. AS
  1397. IF @fidlist<>''
  1398.      BEGIN
  1399.       DECLARE @strSQL VARCHAR(5000)
  1400.       SET @strSQL = 'SELECT TOP 20 [tid], [fid], [title], [poster], [postdatetime], [lastpost], [replies], [views], [digest] FROM [dnt_topics] WHERE [fid] 
  1401. NOT IN ('+@fidlist +') ORDER BY [tid] DESC' 
  1402.      END
  1403. ELSE
  1404.      BEGIN
  1405.       SET @strSQL = 'SELECT TOP 20 [tid], [fid], [title], [poster], [postdatetime], [lastpost], [replies], [views], [digest] FROM [dnt_topics] ORDER BY [tid] 
  1406. DESC'
  1407.      END
  1408.   EXEC(@strSQL)
  1409. GO
  1410. IF OBJECT_ID('[dnt_gettopiccount]','P') IS NOT NULL
  1411. DROP PROC [dnt_gettopiccount]
  1412. GO
  1413. CREATE PROCEDURE [dnt_gettopiccount]
  1414. @fid int
  1415. AS
  1416. SELECT [curtopics] FROM [dnt_forums] WHERE [fid] = @fid
  1417. GO
  1418. IF OBJECT_ID('dnt_gettopiccountbycondition','P') IS NOT NULL
  1419. DROP PROC [dnt_gettopiccountbycondition]
  1420. GO
  1421. CREATE PROCEDURE [dnt_gettopiccountbycondition]
  1422. @fid int,
  1423. @state int=0,
  1424. @condition varchar(80)=null
  1425. AS
  1426. DECLARE @sql varchar(500)
  1427. IF @state=-1
  1428. BEGIN
  1429. set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [fid]='+str(@fid)+' AND [displayorder]>-1 AND [closed]<=1'+@condition
  1430. END
  1431. ELSE
  1432. BEGIN
  1433. set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [fid]='+str(@fid)+' AND [displayorder]>-1 AND [closed]='+str(@state)+' AND [closed]<=1'+@condition
  1434. END
  1435. exec(@sql)
  1436. GO
  1437. IF OBJECT_ID('[dnt_gettopiccountbytype]','P') IS NOT NULL
  1438. DROP PROC [dnt_gettopiccountbytype]
  1439. GO
  1440. CREATE PROCEDURE [dnt_gettopiccountbytype]
  1441. @condition varchar(4000)
  1442. AS
  1443. DECLARE @sql varchar(4100)
  1444. set @sql ='SELECT COUNT(tid) FROM [dnt_topics] WHERE [displayorder]>-1 AND [closed]<=1 '+@condition
  1445. exec(@sql)
  1446. GO
  1447. IF OBJECT_ID('dnt_gettopiclistbycondition','P') IS NOT NULL
  1448. DROP PROC [dnt_gettopiclistbycondition]
  1449. GO
  1450. CREATE PROCEDURE [dnt_gettopiclistbycondition]
  1451. @fid int,
  1452. @pagesize int,
  1453. @pageindex int,
  1454. @startnum int,
  1455. @condition varchar(80)
  1456. AS
  1457. DECLARE @strSQL varchar(5000)
  1458. IF @pageindex = 1
  1459. BEGIN
  1460. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [rate],[tid],[iconid],[typeid],[title],[price],[hide],[readperm],
  1461. [special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
  1462. [lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM 
  1463. [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC'
  1464. END
  1465. ELSE
  1466. BEGIN
  1467. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'[rate], [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
  1468. [special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
  1469. [lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[special] FROM 
  1470. [dnt_topics] WHERE [lastpostid] < (SELECT min([lastpostid])  FROM (SELECT TOP ' + STR
  1471. ((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE [fid]=' +STR
  1472. (@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC) AS tblTmp ) 
  1473. AND [fid]=' +STR(@fid) + ' AND [displayorder]=0' + @condition + ' ORDER BY [lastpostid] DESC'
  1474. END
  1475. EXEC(@strSQL)
  1476. GO
  1477. IF OBJECT_ID('dnt_gettopiclist','P') IS NOT NULL
  1478. DROP PROC [dnt_gettopiclist]
  1479. GO
  1480. CREATE PROCEDURE [dnt_gettopiclist]
  1481. @fid int,
  1482. @pagesize int,
  1483. @startnum int,
  1484. @pageindex int
  1485. AS
  1486. DECLARE @startRow int,
  1487. @endRow int
  1488. SET @startRow = (@pageindex - 1) * @pagesize + 1 - @startnum
  1489. SET @endRow = @startRow + @pagesize -1
  1490. SELECT 
  1491. [TOPICS].[rate], 
  1492. [TOPICS].[tid],
  1493. [TOPICS].[iconid],
  1494. [TOPICS].[typeid],
  1495. [TOPICS].[title],
  1496. [TOPICS].[price],
  1497. [TOPICS].[hide],
  1498. [TOPICS].[readperm],
  1499. [TOPICS].[poster],
  1500. [TOPICS].[posterid],
  1501. [TOPICS].[replies],
  1502. [TOPICS].[views],
  1503. [TOPICS].[postdatetime],
  1504. [TOPICS].[lastpost],
  1505. [TOPICS].[lastposter],
  1506. [TOPICS].[lastpostid],
  1507. [TOPICS].[lastposterid],
  1508. [TOPICS].[highlight],
  1509. [TOPICS].[digest],
  1510. [TOPICS].[displayorder],
  1511. [TOPICS].[attachment],
  1512. [TOPICS].[closed],
  1513. [TOPICS].[magic],
  1514. [TOPICS].[special] 
  1515. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [lastpostid] DESC)AS ROWID,
  1516. [dnt_topics].[rate], 
  1517. [dnt_topics].[tid],
  1518. [dnt_topics].[iconid],
  1519. [dnt_topics].[typeid],
  1520. [dnt_topics].[title],
  1521. [dnt_topics].[price],
  1522. [dnt_topics].[hide],
  1523. [dnt_topics].[readperm],
  1524. [dnt_topics].[poster],
  1525. [dnt_topics].[posterid],
  1526. [dnt_topics].[replies],
  1527. [dnt_topics].[views],
  1528. [dnt_topics].[postdatetime],
  1529. [dnt_topics].[lastpost],
  1530. [dnt_topics].[lastposter],
  1531. [dnt_topics].[lastpostid],
  1532. [dnt_topics].[lastposterid],
  1533. [dnt_topics].[highlight],
  1534. [dnt_topics].[digest],
  1535. [dnt_topics].[displayorder],
  1536. [dnt_topics].[attachment],
  1537. [dnt_topics].[closed],
  1538. [dnt_topics].[magic],
  1539. [dnt_topics].[special] 
  1540. FROM [dnt_topics]
  1541. WHERE [fid]=@fid AND [displayorder]=0) AS TOPICS
  1542. WHERE ROWID BETWEEN @startRow AND @endRow
  1543. GO
  1544. IF OBJECT_ID('dnt_gettopiclistbydate','P') IS NOT NULL
  1545. DROP PROC [dnt_gettopiclistbydate]
  1546. GO
  1547. CREATE  PROCEDURE [dnt_gettopiclistbydate]
  1548. @fid int,
  1549. @pagesize int,
  1550. @pageindex int,
  1551. @startnum int,
  1552. @condition varchar(100),
  1553. @orderby varchar(100),
  1554. @ascdesc int
  1555. AS
  1556. DECLARE @strsql varchar(5000)
  1557. DECLARE @sorttype varchar(5)
  1558. IF @ascdesc=0
  1559.    SET @sorttype='ASC'
  1560. ELSE
  1561.    SET @sorttype='DESC'
  1562. IF @pageindex = 1
  1563. BEGIN
  1564. SET @strsql = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[typeid],[readperm],[hide],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
  1565. END
  1566. ELSE
  1567.            IF @sorttype='DESC'
  1568. BEGIN
  1569. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[typeid],[hide],[readperm],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] < (SELECT min(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+']  FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype
  1570. END
  1571.       ELSE
  1572.              BEGIN
  1573. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[title],[price],[hide],[typeid],[readperm],[special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] > (SELECT MAX(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+'] FROM [dnt_topics] WHERE [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [fid]=' +STR(@fid) + ' AND [displayorder]=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
  1574.             END
  1575. EXEC(@strsql)
  1576. GO
  1577. IF OBJECT_ID('dnt_gettopiclistbytag','P') IS NOT NULL
  1578. DROP PROC [dnt_gettopiclistbytag]
  1579. GO
  1580. CREATE PROCEDURE [dnt_gettopiclistbytag]
  1581. @tagid int,
  1582. @pageindex int,
  1583. @pagesize int
  1584. AS
  1585. DECLARE @startRow int,
  1586. @endRow int
  1587. SET @startRow = (@pageindex - 1) * @pagesize + 1
  1588. SET @endRow = @startRow + @pagesize -1
  1589. SELECT 
  1590. [TOPICTAGS].[tid], 
  1591. [TOPICTAGS].[title],
  1592. [TOPICTAGS].[poster],
  1593. [TOPICTAGS].[posterid],
  1594. [TOPICTAGS].[fid],
  1595. [TOPICTAGS].[postdatetime],
  1596. [TOPICTAGS].[replies],
  1597. [TOPICTAGS].[views],
  1598. [TOPICTAGS].[lastposter],
  1599. [TOPICTAGS].[lastposterid],
  1600. [TOPICTAGS].[lastpost] 
  1601. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [lastpostid]) AS ROWID,
  1602. [t].[tid], 
  1603. [t].[title],
  1604. [t].[poster],
  1605. [t].[posterid],
  1606. [t].[fid],
  1607. [t].[postdatetime],
  1608. [t].[replies],
  1609. [t].[views],
  1610. [t].[lastposter],
  1611. [t].[lastposterid],
  1612. [t].[lastpost]
  1613. FROM [dnt_topictags] AS [tt], [dnt_topics] AS [t]
  1614. WHERE [t].[tid] = [tt].[tid] AND [t].[displayorder] >=0 AND [tt].[tagid] = @tagid) AS TOPICTAGS
  1615. WHERE ROWID BETWEEN @startRow AND @endRow
  1616. GO
  1617. IF OBJECT_ID('[dnt_gettopiclistbytype]','P') IS NOT NULL
  1618. DROP PROC [dnt_gettopiclistbytype]
  1619. GO
  1620. CREATE PROCEDURE [dnt_gettopiclistbytype]
  1621. @pagesize int,
  1622. @pageindex int,
  1623. @startnum int,
  1624. @condition varchar(1000),
  1625. @ascdesc int
  1626. AS
  1627. DECLARE @strSQL varchar(5000)
  1628. DECLARE @sorttype varchar(5)
  1629. IF @ascdesc=0
  1630.    SET @sorttype='ASC'
  1631. ELSE
  1632.    SET @sorttype='DESC'
  1633. IF @pageindex = 1
  1634. BEGIN
  1635. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
  1636. [special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
  1637. [lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM 
  1638. [dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
  1639. END
  1640. ELSE
  1641. BEGIN
  1642. IF @sorttype='DESC'
  1643. BEGIN
  1644. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
  1645. [special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
  1646. [lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic],[rate] FROM 
  1647. [dnt_topics] WHERE [lastpostid] < (SELECT min([lastpostid])  FROM (SELECT TOP ' + STR
  1648. ((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [tid] ' + @sorttype + ' , [lastpostid] ' + @sorttype + ') AS tblTmp ) 
  1649. AND  [displayorder]>=0' + @condition +' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
  1650. END
  1651. ELSE
  1652. BEGIN
  1653. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[price],[hide],[readperm],
  1654. [special],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],
  1655. [lastpostid],[lastposterid],[replies],[highlight],[digest],[displayorder],[attachment],[closed],[magic] FROM 
  1656. [dnt_topics] WHERE [lastpostid] > (SELECT MAX([lastpostid])  FROM (SELECT TOP ' + STR
  1657. ((@pageindex-1)*@pagesize-@startnum) + ' [lastpostid] FROM [dnt_topics] WHERE  [displayorder]>=0' + @condition + ' ORDER BY [tid] ' + @sorttype + ' , [lastpostid] ' + @sorttype + ') AS tblTmp ) 
  1658. AND  [displayorder]>=0' + @condition +' ORDER BY [lastpostid] '+@sorttype +',  [tid] '+@sorttype
  1659. END
  1660. END
  1661. EXEC(@strSQL)
  1662. GO
  1663. IF OBJECT_ID('[dnt_gettopiclistbytypedate]','P') IS NOT NULL
  1664. DROP PROC [dnt_gettopiclistbytypedate]
  1665. GO
  1666. CREATE PROCEDURE [dnt_gettopiclistbytypedate]
  1667. @pagesize int,
  1668. @pageindex int,
  1669. @startnum int,
  1670. @condition varchar(1000),
  1671. @orderby varchar(100),
  1672. @ascdesc int
  1673. AS
  1674. DECLARE @strsql varchar(5000)
  1675. DECLARE @sorttype varchar(5)
  1676. IF @ascdesc=0
  1677.    SET @sorttype='ASC'
  1678. ELSE
  1679.    SET @sorttype='DESC'
  1680. IF @pageindex = 1
  1681. BEGIN
  1682. SET @strsql = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE [displayorder]>=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
  1683. END
  1684. ELSE
  1685.            IF @sorttype='DESC'
  1686. BEGIN
  1687. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] < (SELECT min(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+']  FROM [dnt_topics] WHERE  [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype
  1688. END
  1689.       ELSE
  1690.              BEGIN
  1691. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +' [tid],[iconid],[typeid],[title],[special],[price],[hide],[readperm],[poster],[posterid],[replies],[views],[postdatetime],[lastpost],[lastposter],[lastpostid],[lastposterid],[highlight],[digest],[displayorder],[closed],[attachment],[magic],[rate] FROM [dnt_topics] WHERE ['+@orderby+'] > (SELECT MAX(['+@orderby+']) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize-@startnum) + ' ['+@orderby+'] FROM [dnt_topics] WHERE [displayorder]>=0'+@condition+' ORDER BY  '+@orderby+' '+@sorttype+')AS tblTmp ) AND [displayorder]>=0'+@condition+' ORDER BY '+@orderby+' '+@sorttype
  1692.             END
  1693. EXEC(@strsql)
  1694. GO
  1695. IF OBJECT_ID('dnt_gettoptopiclist','P') IS NOT NULL
  1696. DROP PROCEDURE [dnt_gettoptopiclist]
  1697. GO
  1698. CREATE PROCEDURE [dnt_gettoptopiclist]
  1699. @fid int,
  1700. @pagesize int,
  1701. @pageindex int,
  1702. @tids varchar(500)
  1703. AS
  1704. DECLARE @startRow int,
  1705. @endRow int
  1706. SET @startROW = ( @pageindex - 1 ) * @pagesize + 1
  1707. SET @endRow = @startRow +  @pagesize -1
  1708. SELECT 
  1709. [TOPICS].[rate], 
  1710. [TOPICS].[tid],
  1711. [TOPICS].[fid],
  1712. [TOPICS].[typeid],
  1713. [TOPICS].[iconid],
  1714. [TOPICS].[title],
  1715. [TOPICS].[price],
  1716. [TOPICS].[hide],
  1717. [TOPICS].[readperm], 
  1718. [TOPICS].[special],
  1719. [TOPICS].[poster],
  1720. [TOPICS].[posterid],
  1721. [TOPICS].[views],
  1722. [TOPICS].[postdatetime],
  1723. [TOPICS].[lastpost],
  1724. [TOPICS].[lastposter],
  1725. [TOPICS].[lastpostid],
  1726. [TOPICS].[lastposterid],
  1727. [TOPICS].[replies],
  1728. [TOPICS].[highlight],
  1729. [TOPICS].[digest],
  1730. [TOPICS].[displayorder],
  1731. [TOPICS].[closed],
  1732. [TOPICS].[attachment],
  1733. [TOPICS].[magic] 
  1734. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_topics].[displayorder] DESC,[dnt_topics].[lastpost] DESC) AS ROWID,
  1735. [dnt_topics].[rate], 
  1736. [dnt_topics].[tid],
  1737. [dnt_topics].[fid],
  1738. [dnt_topics].[typeid],
  1739. [dnt_topics].[iconid],
  1740. [dnt_topics].[title],
  1741. [dnt_topics].[price],
  1742. [dnt_topics].[hide],
  1743. [dnt_topics].[readperm], 
  1744. [dnt_topics].[special],
  1745. [dnt_topics].[poster],
  1746. [dnt_topics].[posterid],
  1747. [dnt_topics].[views],
  1748. [dnt_topics].[postdatetime],
  1749. [dnt_topics].[lastpost],
  1750. [dnt_topics].[lastposter],
  1751. [dnt_topics].[lastpostid],
  1752. [dnt_topics].[lastposterid],
  1753. [dnt_topics].[replies],
  1754. [dnt_topics].[highlight],
  1755. [dnt_topics].[digest],
  1756. [dnt_topics].[displayorder],
  1757. [dnt_topics].[closed],
  1758. [dnt_topics].[attachment],
  1759. [dnt_topics].[magic]
  1760. FROM [dnt_topics]
  1761. WHERE [displayorder]>0 AND CHARINDEX(','+RTRIM([dnt_topics].[tid])+',', ','+@tids+',')>0)AS TOPICS
  1762. WHERE ROWID BETWEEN @startRow AND @endRow 
  1763. GO
  1764. IF OBJECT_ID ('dnt_getuserinfo','P') IS NOT NULL
  1765. DROP PROCEDURE [dnt_getuserinfo]
  1766. GO
  1767. CREATE PROCEDURE [dnt_getuserinfo]
  1768. @uid int
  1769. AS
  1770. SELECT TOP 1 
  1771. [dnt_users].[accessmasks], 
  1772. [dnt_users].[adminid],
  1773. [dnt_users].[avatarshowid],
  1774. [dnt_users].[bday],
  1775. [dnt_users].[credits],
  1776. [dnt_users].[digestposts],
  1777. [dnt_users].[email],
  1778. [dnt_users].[extcredits1],
  1779. [dnt_users].[extcredits2],
  1780. [dnt_users].[extcredits3],
  1781. [dnt_users].[extcredits4],
  1782. [dnt_users].[extcredits5],
  1783. [dnt_users].[extcredits6],
  1784. [dnt_users].[extcredits7],
  1785. [dnt_users].[extcredits8],
  1786. [dnt_users].[extgroupids],
  1787. [dnt_users].[gender],
  1788. [dnt_users].[groupexpiry],
  1789. [dnt_users].[groupid],
  1790. [dnt_users].[invisible],
  1791. [dnt_users].[joindate],
  1792. [dnt_users].[lastactivity],
  1793. [dnt_users].[lastip],
  1794. [dnt_users].[lastpost],
  1795. [dnt_users].[lastpostid],
  1796. [dnt_users].[lastposttitle],
  1797. [dnt_users].[lastvisit],
  1798. [dnt_users].[newpm],
  1799. [dnt_users].[newpmcount],
  1800. [dnt_users].[newsletter],
  1801. [dnt_users].[nickname],
  1802. [dnt_users].[oltime],
  1803. [dnt_users].[onlinestate],
  1804. [dnt_users].[pageviews],
  1805. [dnt_users].[password],
  1806. [dnt_users].[pmsound],
  1807. [dnt_users].[posts],
  1808. [dnt_users].[ppp],
  1809. [dnt_users].[regip],
  1810. [dnt_users].[secques],
  1811. [dnt_users].[showemail],
  1812. [dnt_users].[sigstatus],
  1813. [dnt_users].[spaceid],
  1814. [dnt_users].[templateid],
  1815. [dnt_users].[tpp],
  1816. [dnt_users].[uid],
  1817. [dnt_users].[username],
  1818. [dnt_users].[salt],
  1819. [dnt_userfields].[authflag],
  1820. [dnt_userfields].[authstr],
  1821. [dnt_userfields].[authtime],
  1822. [dnt_userfields].[avatar],
  1823. [dnt_userfields].[avatarheight],
  1824. [dnt_userfields].[avatarwidth],
  1825. [dnt_userfields].[bio],
  1826. [dnt_userfields].[customstatus],
  1827. [dnt_userfields].[icq],
  1828. [dnt_userfields].[idcard],
  1829. [dnt_userfields].[ignorepm],
  1830. [dnt_userfields].[location],
  1831. [dnt_userfields].[medals],
  1832. [dnt_userfields].[mobile],
  1833. [dnt_userfields].[msn],
  1834. [dnt_userfields].[phone],
  1835. [dnt_userfields].[qq],
  1836. [dnt_userfields].[realname],
  1837. [dnt_userfields].[sightml],
  1838. [dnt_userfields].[signature],
  1839. [dnt_userfields].[skype],
  1840. [dnt_userfields].[uid],
  1841. [dnt_userfields].[website],
  1842. [dnt_userfields].[yahoo]
  1843. FROM [dnt_users] LEFT JOIN [dnt_userfields] ON [dnt_users].[uid]=[dnt_userfields].[uid] 
  1844. WHERE [dnt_users].[uid]=@uid
  1845. GO
  1846. IF OBJECT_ID('dnt_getuserlist','P') IS NOT NULL
  1847. DROP PROCEDURE [dnt_getuserlist]
  1848. GO
  1849. CREATE PROCEDURE [dnt_getuserlist]
  1850. @pagesize int,
  1851. @pageindex int,
  1852. @column varchar(20),
  1853. @ordertype AS varchar(5)
  1854. AS
  1855. DECLARE @startRow int,
  1856. @endRow int
  1857. SET @startRow = (@pageindex - 1) * @pagesize + 1
  1858. SET @endRow = @startRow + @pagesize - 1
  1859. IF (@ordertype = 'DESC')
  1860. BEGIN
  1861. IF (@column = 'username')
  1862. BEGIN
  1863. SELECT 
  1864. [USERS].[uid], 
  1865. [USERS].[groupid], 
  1866. [USERS].[username], 
  1867. [USERS].[nickname], 
  1868. [USERS].[joindate], 
  1869. [USERS].[credits], 
  1870. [USERS].[posts], 
  1871. [USERS].[email], 
  1872. [USERS].[lastactivity], 
  1873. [USERS].[oltime], 
  1874. [USERS].[location] 
  1875. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[username] DESC ) AS ROWID,
  1876. [dnt_users].[uid], 
  1877. [dnt_users].[groupid], 
  1878. [dnt_users].[username], 
  1879. [dnt_users].[nickname], 
  1880. [dnt_users].[joindate], 
  1881. [dnt_users].[credits], 
  1882. [dnt_users].[posts], 
  1883. [dnt_users].[email], 
  1884. [dnt_users].[lastactivity], 
  1885. [dnt_users].[oltime], 
  1886. [dnt_userfields].[location]
  1887. FROM [dnt_users]
  1888. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  1889. WHERE ROWID BETWEEN @startRow AND @endRow
  1890. END
  1891. ELSE IF (@column = 'credits')
  1892. BEGIN
  1893. SELECT 
  1894. [USERS].[uid], 
  1895. [USERS].[groupid], 
  1896. [USERS].[username], 
  1897. [USERS].[nickname], 
  1898. [USERS].[joindate], 
  1899. [USERS].[credits], 
  1900. [USERS].[posts], 
  1901. [USERS].[email], 
  1902. [USERS].[lastactivity], 
  1903. [USERS].[oltime], 
  1904. [USERS].[location] 
  1905. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[credits] DESC ) AS ROWID,
  1906. [dnt_users].[uid], 
  1907. [dnt_users].[groupid], 
  1908. [dnt_users].[username], 
  1909. [dnt_users].[nickname], 
  1910. [dnt_users].[joindate], 
  1911. [dnt_users].[credits], 
  1912. [dnt_users].[posts], 
  1913. [dnt_users].[email], 
  1914. [dnt_users].[lastactivity], 
  1915. [dnt_users].[oltime], 
  1916. [dnt_userfields].[location]
  1917. FROM [dnt_users]
  1918. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  1919. WHERE ROWID BETWEEN @startRow AND @endRow
  1920. END
  1921. ELSE IF (@column = 'posts')
  1922. BEGIN
  1923. SELECT 
  1924. [USERS].[uid], 
  1925. [USERS].[groupid], 
  1926. [USERS].[username], 
  1927. [USERS].[nickname], 
  1928. [USERS].[joindate], 
  1929. [USERS].[credits], 
  1930. [USERS].[posts], 
  1931. [USERS].[email], 
  1932. [USERS].[lastactivity], 
  1933. [USERS].[oltime], 
  1934. [USERS].[location] 
  1935. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[posts] DESC ) AS ROWID,
  1936. [dnt_users].[uid], 
  1937. [dnt_users].[groupid], 
  1938. [dnt_users].[username], 
  1939. [dnt_users].[nickname], 
  1940. [dnt_users].[joindate], 
  1941. [dnt_users].[credits], 
  1942. [dnt_users].[posts], 
  1943. [dnt_users].[email], 
  1944. [dnt_users].[lastactivity], 
  1945. [dnt_users].[oltime], 
  1946. [dnt_userfields].[location]
  1947. FROM [dnt_users]
  1948. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  1949. WHERE ROWID BETWEEN @startRow AND @endRow
  1950. END
  1951. ELSE IF (@column = 'admin')
  1952. BEGIN
  1953. SELECT 
  1954. [USERS].[uid], 
  1955. [USERS].[groupid], 
  1956. [USERS].[username], 
  1957. [USERS].[nickname], 
  1958. [USERS].[joindate], 
  1959. [USERS].[credits], 
  1960. [USERS].[posts], 
  1961. [USERS].[email], 
  1962. [USERS].[lastactivity], 
  1963. [USERS].[oltime], 
  1964. [USERS].[location] 
  1965. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[adminid] ASC ) AS ROWID,
  1966. [dnt_users].[uid], 
  1967. [dnt_users].[groupid], 
  1968. [dnt_users].[username], 
  1969. [dnt_users].[nickname], 
  1970. [dnt_users].[joindate], 
  1971. [dnt_users].[credits], 
  1972. [dnt_users].[posts], 
  1973. [dnt_users].[email], 
  1974. [dnt_users].[lastactivity], 
  1975. [dnt_users].[oltime], 
  1976. [dnt_userfields].[location]
  1977. FROM [dnt_users]
  1978. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid] WHERE [dnt_users].[adminid] > 0) AS USERS
  1979. WHERE ROWID BETWEEN @startRow AND @endRow
  1980. END
  1981. ELSE IF (@column = 'lastactivity')
  1982. BEGIN
  1983. SELECT 
  1984. [USERS].[uid], 
  1985. [USERS].[groupid], 
  1986. [USERS].[username], 
  1987. [USERS].[nickname], 
  1988. [USERS].[joindate], 
  1989. [USERS].[credits], 
  1990. [USERS].[posts], 
  1991. [USERS].[email], 
  1992. [USERS].[lastactivity], 
  1993. [USERS].[oltime], 
  1994. [USERS].[location] 
  1995. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[lastactivity] DESC ) AS ROWID,
  1996. [dnt_users].[uid], 
  1997. [dnt_users].[groupid], 
  1998. [dnt_users].[username], 
  1999. [dnt_users].[nickname], 
  2000. [dnt_users].[joindate], 
  2001. [dnt_users].[credits], 
  2002. [dnt_users].[posts], 
  2003. [dnt_users].[email], 
  2004. [dnt_users].[lastactivity], 
  2005. [dnt_users].[oltime], 
  2006. [dnt_userfields].[location]
  2007. FROM [dnt_users]
  2008. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2009. WHERE ROWID BETWEEN @startRow AND @endRow
  2010. END
  2011. ELSE IF (@column = 'joindate')
  2012. BEGIN
  2013. SELECT 
  2014. [USERS].[uid], 
  2015. [USERS].[groupid], 
  2016. [USERS].[username], 
  2017. [USERS].[nickname], 
  2018. [USERS].[joindate], 
  2019. [USERS].[credits], 
  2020. [USERS].[posts], 
  2021. [USERS].[email], 
  2022. [USERS].[lastactivity], 
  2023. [USERS].[oltime], 
  2024. [USERS].[location] 
  2025. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[joindate] DESC ) AS ROWID,
  2026. [dnt_users].[uid], 
  2027. [dnt_users].[groupid], 
  2028. [dnt_users].[username], 
  2029. [dnt_users].[nickname], 
  2030. [dnt_users].[joindate], 
  2031. [dnt_users].[credits], 
  2032. [dnt_users].[posts], 
  2033. [dnt_users].[email], 
  2034. [dnt_users].[lastactivity], 
  2035. [dnt_users].[oltime], 
  2036. [dnt_userfields].[location]
  2037. FROM [dnt_users]
  2038. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2039. WHERE ROWID BETWEEN @startRow AND @endRow
  2040. END
  2041. ELSE IF (@column = 'oltime')
  2042. BEGIN
  2043. SELECT 
  2044. [USERS].[uid], 
  2045. [USERS].[groupid], 
  2046. [USERS].[username], 
  2047. [USERS].[nickname], 
  2048. [USERS].[joindate], 
  2049. [USERS].[credits], 
  2050. [USERS].[posts], 
  2051. [USERS].[email], 
  2052. [USERS].[lastactivity], 
  2053. [USERS].[oltime], 
  2054. [USERS].[location] 
  2055. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[oltime] DESC ) AS ROWID,
  2056. [dnt_users].[uid], 
  2057. [dnt_users].[groupid], 
  2058. [dnt_users].[username], 
  2059. [dnt_users].[nickname], 
  2060. [dnt_users].[joindate], 
  2061. [dnt_users].[credits], 
  2062. [dnt_users].[posts], 
  2063. [dnt_users].[email], 
  2064. [dnt_users].[lastactivity], 
  2065. [dnt_users].[oltime], 
  2066. [dnt_userfields].[location]
  2067. FROM [dnt_users]
  2068. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2069. WHERE ROWID BETWEEN @startRow AND @endRow
  2070. END
  2071. ELSE
  2072. BEGIN
  2073. SELECT 
  2074. [USERS].[uid], 
  2075. [USERS].[groupid], 
  2076. [USERS].[username], 
  2077. [USERS].[nickname], 
  2078. [USERS].[joindate], 
  2079. [USERS].[credits], 
  2080. [USERS].[posts], 
  2081. [USERS].[email], 
  2082. [USERS].[lastactivity], 
  2083. [USERS].[oltime], 
  2084. [USERS].[location] 
  2085. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[uid] DESC ) AS ROWID,
  2086. [dnt_users].[uid], 
  2087. [dnt_users].[groupid], 
  2088. [dnt_users].[username], 
  2089. [dnt_users].[nickname], 
  2090. [dnt_users].[joindate], 
  2091. [dnt_users].[credits], 
  2092. [dnt_users].[posts], 
  2093. [dnt_users].[email], 
  2094. [dnt_users].[lastactivity], 
  2095. [dnt_users].[oltime], 
  2096. [dnt_userfields].[location]
  2097. FROM [dnt_users]
  2098. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2099. WHERE ROWID BETWEEN @startRow AND @endRow
  2100. END
  2101. END
  2102. ELSE
  2103. BEGIN
  2104. IF (@column = 'username')
  2105. BEGIN
  2106. SELECT 
  2107. [USERS].[uid], 
  2108. [USERS].[groupid], 
  2109. [USERS].[username], 
  2110. [USERS].[nickname], 
  2111. [USERS].[joindate], 
  2112. [USERS].[credits], 
  2113. [USERS].[posts], 
  2114. [USERS].[email], 
  2115. [USERS].[lastactivity], 
  2116. [USERS].[oltime], 
  2117. [USERS].[location] 
  2118. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[username] ASC ) AS ROWID,
  2119. [dnt_users].[uid], 
  2120. [dnt_users].[groupid], 
  2121. [dnt_users].[username], 
  2122. [dnt_users].[nickname], 
  2123. [dnt_users].[joindate], 
  2124. [dnt_users].[credits], 
  2125. [dnt_users].[posts], 
  2126. [dnt_users].[email], 
  2127. [dnt_users].[lastactivity], 
  2128. [dnt_users].[oltime], 
  2129. [dnt_userfields].[location]
  2130. FROM [dnt_users]
  2131. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2132. WHERE ROWID BETWEEN @startRow AND @endRow
  2133. END
  2134. ELSE IF (@column = 'credits')
  2135. BEGIN
  2136. SELECT 
  2137. [USERS].[uid], 
  2138. [USERS].[groupid], 
  2139. [USERS].[username], 
  2140. [USERS].[nickname], 
  2141. [USERS].[joindate], 
  2142. [USERS].[credits], 
  2143. [USERS].[posts], 
  2144. [USERS].[email], 
  2145. [USERS].[lastactivity], 
  2146. [USERS].[oltime], 
  2147. [USERS].[location] 
  2148. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[credits] ASC ) AS ROWID,
  2149. [dnt_users].[uid], 
  2150. [dnt_users].[groupid], 
  2151. [dnt_users].[username], 
  2152. [dnt_users].[nickname], 
  2153. [dnt_users].[joindate], 
  2154. [dnt_users].[credits], 
  2155. [dnt_users].[posts], 
  2156. [dnt_users].[email], 
  2157. [dnt_users].[lastactivity], 
  2158. [dnt_users].[oltime], 
  2159. [dnt_userfields].[location]
  2160. FROM [dnt_users]
  2161. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2162. WHERE ROWID BETWEEN @startRow AND @endRow
  2163. END
  2164. ELSE IF (@column = 'posts')
  2165. BEGIN
  2166. SELECT 
  2167. [USERS].[uid], 
  2168. [USERS].[groupid], 
  2169. [USERS].[username], 
  2170. [USERS].[nickname], 
  2171. [USERS].[joindate], 
  2172. [USERS].[credits], 
  2173. [USERS].[posts], 
  2174. [USERS].[email], 
  2175. [USERS].[lastactivity], 
  2176. [USERS].[oltime], 
  2177. [USERS].[location] 
  2178. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[posts] ASC ) AS ROWID,
  2179. [dnt_users].[uid], 
  2180. [dnt_users].[groupid], 
  2181. [dnt_users].[username], 
  2182. [dnt_users].[nickname], 
  2183. [dnt_users].[joindate], 
  2184. [dnt_users].[credits], 
  2185. [dnt_users].[posts], 
  2186. [dnt_users].[email], 
  2187. [dnt_users].[lastactivity], 
  2188. [dnt_users].[oltime], 
  2189. [dnt_userfields].[location]
  2190. FROM [dnt_users]
  2191. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2192. WHERE ROWID BETWEEN @startRow AND @endRow
  2193. END
  2194. ELSE IF (@column = 'admin')
  2195. BEGIN
  2196. SELECT 
  2197. [USERS].[uid], 
  2198. [USERS].[groupid], 
  2199. [USERS].[username], 
  2200. [USERS].[nickname], 
  2201. [USERS].[joindate], 
  2202. [USERS].[credits], 
  2203. [USERS].[posts], 
  2204. [USERS].[email], 
  2205. [USERS].[lastactivity], 
  2206. [USERS].[oltime], 
  2207. [USERS].[location] 
  2208. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[adminid] DESC ) AS ROWID,
  2209. [dnt_users].[uid], 
  2210. [dnt_users].[groupid], 
  2211. [dnt_users].[username], 
  2212. [dnt_users].[nickname], 
  2213. [dnt_users].[joindate], 
  2214. [dnt_users].[credits], 
  2215. [dnt_users].[posts], 
  2216. [dnt_users].[email], 
  2217. [dnt_users].[lastactivity], 
  2218. [dnt_users].[oltime], 
  2219. [dnt_userfields].[location]
  2220. FROM [dnt_users]
  2221. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid] WHERE [dnt_users].[adminid] > 0) AS USERS
  2222. WHERE ROWID BETWEEN @startRow AND @endRow
  2223. END
  2224. ELSE IF (@column = 'lastactivity')
  2225. BEGIN
  2226. SELECT 
  2227. [USERS].[uid], 
  2228. [USERS].[groupid], 
  2229. [USERS].[username], 
  2230. [USERS].[nickname], 
  2231. [USERS].[joindate], 
  2232. [USERS].[credits], 
  2233. [USERS].[posts], 
  2234. [USERS].[email], 
  2235. [USERS].[lastactivity], 
  2236. [USERS].[oltime], 
  2237. [USERS].[location] 
  2238. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[lastactivity] ASC ) AS ROWID,
  2239. [dnt_users].[uid], 
  2240. [dnt_users].[groupid], 
  2241. [dnt_users].[username], 
  2242. [dnt_users].[nickname], 
  2243. [dnt_users].[joindate], 
  2244. [dnt_users].[credits], 
  2245. [dnt_users].[posts], 
  2246. [dnt_users].[email], 
  2247. [dnt_users].[lastactivity], 
  2248. [dnt_users].[oltime], 
  2249. [dnt_userfields].[location]
  2250. FROM [dnt_users]
  2251. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2252. WHERE ROWID BETWEEN @startRow AND @endRow
  2253. END
  2254. ELSE IF (@column = 'joindate')
  2255. BEGIN
  2256. SELECT 
  2257. [USERS].[uid], 
  2258. [USERS].[groupid], 
  2259. [USERS].[username], 
  2260. [USERS].[nickname], 
  2261. [USERS].[joindate], 
  2262. [USERS].[credits], 
  2263. [USERS].[posts], 
  2264. [USERS].[email], 
  2265. [USERS].[lastactivity], 
  2266. [USERS].[oltime], 
  2267. [USERS].[location] 
  2268. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[joindate] ASC ) AS ROWID,
  2269. [dnt_users].[uid], 
  2270. [dnt_users].[groupid], 
  2271. [dnt_users].[username], 
  2272. [dnt_users].[nickname], 
  2273. [dnt_users].[joindate], 
  2274. [dnt_users].[credits], 
  2275. [dnt_users].[posts], 
  2276. [dnt_users].[email], 
  2277. [dnt_users].[lastactivity], 
  2278. [dnt_users].[oltime], 
  2279. [dnt_userfields].[location]
  2280. FROM [dnt_users]
  2281. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2282. WHERE ROWID BETWEEN @startRow AND @endRow
  2283. END
  2284. ELSE IF (@column = 'oltime')
  2285. BEGIN
  2286. SELECT 
  2287. [USERS].[uid], 
  2288. [USERS].[groupid], 
  2289. [USERS].[username], 
  2290. [USERS].[nickname], 
  2291. [USERS].[joindate], 
  2292. [USERS].[credits], 
  2293. [USERS].[posts], 
  2294. [USERS].[email], 
  2295. [USERS].[lastactivity], 
  2296. [USERS].[oltime], 
  2297. [USERS].[location] 
  2298. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[oltime] ASC ) AS ROWID,
  2299. [dnt_users].[uid], 
  2300. [dnt_users].[groupid], 
  2301. [dnt_users].[username], 
  2302. [dnt_users].[nickname], 
  2303. [dnt_users].[joindate], 
  2304. [dnt_users].[credits], 
  2305. [dnt_users].[posts], 
  2306. [dnt_users].[email], 
  2307. [dnt_users].[lastactivity], 
  2308. [dnt_users].[oltime], 
  2309. [dnt_userfields].[location]
  2310. FROM [dnt_users]
  2311. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2312. WHERE ROWID BETWEEN @startRow AND @endRow
  2313. END
  2314. ELSE
  2315. BEGIN
  2316. SELECT 
  2317. [USERS].[uid], 
  2318. [USERS].[groupid], 
  2319. [USERS].[username], 
  2320. [USERS].[nickname], 
  2321. [USERS].[joindate], 
  2322. [USERS].[credits], 
  2323. [USERS].[posts], 
  2324. [USERS].[email], 
  2325. [USERS].[lastactivity], 
  2326. [USERS].[oltime], 
  2327. [USERS].[location] 
  2328. FROM (SELECT ROW_NUMBER() OVER(ORDER BY [dnt_users].[uid] ASC ) AS ROWID,
  2329. [dnt_users].[uid], 
  2330. [dnt_users].[groupid], 
  2331. [dnt_users].[username], 
  2332. [dnt_users].[nickname], 
  2333. [dnt_users].[joindate], 
  2334. [dnt_users].[credits], 
  2335. [dnt_users].[posts], 
  2336. [dnt_users].[email], 
  2337. [dnt_users].[lastactivity], 
  2338. [dnt_users].[oltime], 
  2339. [dnt_userfields].[location]
  2340. FROM [dnt_users]
  2341. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_users].[uid]) AS USERS
  2342. WHERE ROWID BETWEEN @startRow AND @endRow
  2343. END
  2344. END
  2345. GO
  2346. IF OBJECT_ID('[dnt_neatenrelatetopic]','P') IS NOT NULL
  2347. DROP PROC [dnt_neatenrelatetopic]
  2348. GO
  2349. CREATE PROCEDURE [dnt_neatenrelatetopic]
  2350. AS
  2351. BEGIN
  2352. DECLARE @tagid int
  2353. DECLARE [tag_cursor] CURSOR FOR
  2354. SELECT DISTINCT [tagid] FROM [dnt_topictags]
  2355. OPEN [tag_cursor]
  2356. FETCH NEXT FROM [tag_cursor] INTO @tagid
  2357. WHILE @@FETCH_STATUS = 0
  2358. BEGIN
  2359. INSERT INTO [dnt_topictagcaches] 
  2360. SELECT [t1].[tid],[t2].[tid],[t2].[title] FROM (SELECT [tid] FROM [dnt_topictags]
  2361. WHERE [tagid] = @tagid) AS [t1],(SELECT [t].[tid],[t].[title] FROM [dnt_topics] AS [t],[dnt_topictags] AS [tt] 
  2362. WHERE [tt].[tagid] = @tagid AND [t].[tid] = [tt].[tid] AND [t].[displayorder] >=0) AS [t2] 
  2363. WHERE [t1].[tid] <> [t2].[tid] AND NOT EXISTS (SELECT 1 FROM [dnt_topictagcaches] WHERE [tid]=[t1].[tid] AND [linktid]=[t2].[tid])
  2364. FETCH NEXT FROM [tag_cursor] INTO @tagid
  2365. END
  2366. CLOSE [tag_cursor]
  2367. DEALLOCATE [tag_cursor]
  2368. END
  2369. GO
  2370. IF OBJECT_ID('[dnt_revisedebatetopicdiggs]','P') IS NOT NULL
  2371. DROP PROC [dnt_revisedebatetopicdiggs]
  2372. GO
  2373. CREATE PROCEDURE [dnt_revisedebatetopicdiggs]
  2374. @tid int,
  2375. @opinion int,
  2376. @count int out
  2377. AS
  2378. BEGIN
  2379. SELECT @count=COUNT(1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion
  2380. IF @opinion=1
  2381. BEGIN
  2382. UPDATE [dnt_debates] SET [positivediggs]=(SELECT SUM(diggs + 1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion) WHERE [tid] = @tid
  2383. END
  2384. ELSE
  2385. BEGIN
  2386. UPDATE [dnt_debates] SET [negativediggs]=(SELECT SUM(diggs + 1) FROM [dnt_postdebatefields] WHERE [tid] = @tid AND [opinion] = @opinion) WHERE [tid] = @tid
  2387. END
  2388. END
  2389. GO
  2390. IF OBJECT_ID('[dnt_setlastexecutescheduledeventdatetime]','P') IS NOT NULL
  2391. DROP PROC [dnt_setlastexecutescheduledeventdatetime]
  2392. GO
  2393. CREATE PROCEDURE [dnt_setlastexecutescheduledeventdatetime]
  2394. (
  2395. @key VARCHAR(100),
  2396. @servername VARCHAR(100),
  2397. @lastexecuted DATETIME
  2398. )
  2399. AS
  2400. DELETE FROM [dnt_scheduledevents] WHERE ([key]=@key) AND ([lastexecuted] < DATEADD([day], - 7, GETDATE()))
  2401. INSERT [dnt_scheduledevents] ([key], [servername], [lastexecuted]) Values (@key, @servername, @lastexecuted)
  2402. GO
  2403. IF OBJECT_ID('[dnt_shrinklog]','P') IS NOT NULL
  2404. DROP PROC [dnt_shrinklog]
  2405. GO
  2406. CREATE PROCEDURE [dnt_shrinklog]  
  2407. @DBName  nchar(50) 
  2408. AS
  2409. Begin
  2410. exec('BACKUP LOG ['+@DBName+']  WITH NO_LOG')
  2411. exec('DBCC  SHRINKDATABASE(['+@DBName+'])')
  2412. End
  2413. GO
  2414. IF OBJECT_ID('[dnt_updateadmingroup]','P') IS NOT NULL
  2415. DROP PROC [dnt_updateadmingroup]
  2416. GO
  2417. CREATE PROCEDURE [dnt_updateadmingroup]
  2418. @admingid smallint,
  2419. @alloweditpost tinyint,
  2420. @alloweditpoll tinyint,
  2421. @allowstickthread tinyint,
  2422. @allowmodpost tinyint,
  2423. @allowdelpost tinyint,
  2424. @allowmassprune tinyint,
  2425. @allowrefund tinyint,
  2426. @allowcensorword tinyint,
  2427. @allowviewip tinyint,
  2428. @allowbanip tinyint,
  2429. @allowedituser tinyint,
  2430. @allowmoduser tinyint,
  2431. @allowbanuser tinyint,
  2432. @allowpostannounce tinyint,
  2433. @allowviewlog tinyint,
  2434. @disablepostctrl tinyint,
  2435. @allowviewrealname tinyint
  2436. AS
  2437. UPDATE [dnt_admingroups] SET 
  2438. [alloweditpost]=@alloweditpost,
  2439. [alloweditpoll]=@alloweditpoll,
  2440. [allowstickthread]=@allowstickthread,
  2441. [allowmodpost]=@allowmodpost,
  2442. [allowdelpost]=@allowdelpost,
  2443. [allowmassprune]=@allowmassprune,
  2444. [allowrefund]=@allowrefund,
  2445. [allowcensorword]=@allowcensorword,
  2446. [allowviewip]=@allowviewip,
  2447. [allowbanip]=@allowbanip,
  2448. [allowedituser]=@allowedituser,
  2449. [allowmoduser]=@allowmoduser,
  2450. [allowbanuser]=@allowbanuser,
  2451. [allowpostannounce]=@allowpostannounce,
  2452. [allowviewlog]=@allowviewlog,
  2453. [disablepostctrl]=@disablepostctrl,
  2454. [allowviewrealname]=@allowviewrealname
  2455. WHERE [admingid]=@admingid
  2456. GO
  2457. IF OBJECT_ID('[dnt_updatepost1]','P') IS NOT NULL
  2458. DROP PROC [dnt_updatepost1]
  2459. GO
  2460. CREATE PROCEDURE [dnt_updatepost1]
  2461. @pid int,
  2462. @title nvarchar(160),
  2463. @message ntext,
  2464. @lastedit nvarchar(50),
  2465. @invisible int,
  2466. @usesig int,
  2467. @htmlon int,
  2468. @smileyoff int,
  2469. @bbcodeoff int,
  2470. @parseurloff int
  2471. AS
  2472. UPDATE [dnt_posts1] SET 
  2473. [title]=@title,
  2474. [message]=@message,
  2475. [lastedit]=@lastedit,
  2476. [invisible]=@invisible,
  2477. [usesig]=@usesig,
  2478. [htmlon]=@htmlon,
  2479. [smileyoff]=@smileyoff,
  2480. [bbcodeoff]=@bbcodeoff,
  2481. [parseurloff]=@parseurloff WHERE [pid]=@pid
  2482. GO
  2483. IF OBJECT_ID('[dnt_updatetopic]','P') IS NOT NULL
  2484. DROP PROC [dnt_updatetopic]
  2485. GO
  2486. CREATE PROCEDURE [dnt_updatetopic]
  2487. @tid int,
  2488. @fid smallint,
  2489. @iconid smallint,
  2490. @title nchar(60),
  2491. @typeid smallint,
  2492. @readperm int,
  2493. @price smallint,
  2494. @poster char(20),
  2495. @posterid int,
  2496. @postdatetime smalldatetime,
  2497. @lastpostid int,
  2498. @lastpost smalldatetime,
  2499. @lastposter char(20),
  2500. @replies int,
  2501. @displayorder int,
  2502. @highlight varchar(500),
  2503. @digest int,
  2504. @rate int,
  2505. @hide int,
  2506. @special int,
  2507. @attachment int,
  2508. @moderated int,
  2509. @closed int,
  2510. @magic int
  2511. AS
  2512. UPDATE [dnt_topics] SET
  2513. [fid]=@fid,
  2514. [iconid]=@iconid,
  2515. [title]=@title,
  2516. [typeid]=@typeid,
  2517. [readperm]=@readperm,
  2518. [price]=@price,
  2519. [poster]=@poster,
  2520. [posterid]=@posterid,
  2521. [postdatetime]=@postdatetime,
  2522. [lastpostid]=@lastpostid,
  2523. [lastpost]=@lastpost,
  2524. [lastposter]=@lastposter,
  2525. [replies]=@replies,
  2526. [displayorder]=@displayorder,
  2527. [highlight]=@highlight,
  2528. [digest]=@digest,
  2529. [rate]=@rate,
  2530. [hide]=@hide,
  2531. [special]=@special,
  2532. [attachment]=@attachment,
  2533. [moderated]=@moderated,
  2534. [closed]=@closed,
  2535. [magic]=@magic WHERE [tid]=@tid 
  2536. GO
  2537. IF OBJECT_ID('[dnt_updatetopicviewcount]','P') IS NOT NULL
  2538. DROP PROC [dnt_updatetopicviewcount]
  2539. GO
  2540. CREATE PROCEDURE [dnt_updatetopicviewcount]
  2541. @tid int,
  2542. @viewcount int
  2543. AS
  2544. UPDATE [dnt_topics]  SET [views]= [views] + @viewcount WHERE [tid]=@tid
  2545. GO
  2546. IF OBJECT_ID('[dnt_updateuserauthstr]','P') IS NOT NULL
  2547. DROP PROC [dnt_updateuserauthstr]
  2548. GO
  2549. CREATE PROCEDURE [dnt_updateuserauthstr]
  2550. @uid int,
  2551. @authstr char(20),
  2552. @authflag int =1
  2553. AS
  2554. UPDATE [dnt_userfields] SET [authstr]=@authstr, [authtime] = GETDATE(), [authflag]=@authflag WHERE [uid]=@uid
  2555. GO
  2556. IF OBJECT_ID('[dnt_updateuserforumsetting]','P') IS NOT NULL
  2557. DROP PROC [dnt_updateuserforumsetting]
  2558. GO
  2559. CREATE PROCEDURE [dnt_updateuserforumsetting]
  2560. @uid int,
  2561. @tpp int,
  2562. @ppp int,
  2563. @invisible int,
  2564. @customstatus varchar(30)
  2565. AS
  2566. UPDATE [dnt_users] SET [tpp]=@tpp, [ppp]=@ppp, [invisible]=@invisible WHERE [uid]=@uid
  2567. UPDATE [dnt_userfields] SET [customstatus]=@customstatus WHERE [uid]=@uid
  2568. GO
  2569. IF OBJECT_ID('[dnt_updateuserpassword]','P') IS NOT NULL
  2570. DROP PROC [dnt_updateuserpassword]
  2571. GO
  2572. CREATE PROCEDURE [dnt_updateuserpassword]
  2573. @uid int,
  2574. @password char(44)
  2575. AS
  2576. UPDATE [dnt_users] SET [password]=@password WHERE [uid]=@uid
  2577. GO
  2578. IF OBJECT_ID('[dnt_updateuserpreference]','P') IS NOT NULL
  2579. DROP PROC [dnt_updateuserpreference]
  2580. GO
  2581. CREATE PROCEDURE [dnt_updateuserpreference]
  2582. @uid int,
  2583. @avatar varchar(255),
  2584. @avatarwidth int,
  2585. @avatarheight int,
  2586. @templateid int
  2587. AS
  2588. UPDATE [dnt_userfields] SET [avatar]=@avatar, [avatarwidth]=@avatarwidth, [avatarheight]=@avatarheight WHERE [uid]=@uid
  2589. UPDATE [dnt_users] SET [templateid]=@templateid WHERE [uid]=@uid
  2590. GO
  2591. IF OBJECT_ID('[dnt_updateuserprofile]','P') IS NOT NULL
  2592. DROP PROC [dnt_updateuserprofile]
  2593. GO
  2594. CREATE PROCEDURE [dnt_updateuserprofile]
  2595. @uid int,
  2596. @nickname nchar(20),
  2597. @gender int,
  2598. @email char(50),
  2599. @bday char(10),
  2600. @showemail int,
  2601. @website nvarchar(80),
  2602. @icq varchar(12),
  2603. @qq varchar(12),
  2604. @yahoo varchar(40),
  2605. @msn varchar(40),
  2606. @skype varchar(40),
  2607. @location nvarchar(30),
  2608. @bio nvarchar(500),
  2609. @signature nvarchar(500),
  2610. @sigstatus int,
  2611. @sightml nvarchar(1000),
  2612. @realname nvarchar(10),
  2613. @idcard varchar(20),
  2614. @mobile varchar(20),
  2615. @phone varchar(20)
  2616. AS
  2617. UPDATE [dnt_users] SET [nickname]=@nickname, [gender]=@gender , [email]=@email , [bday]=@bday, [sigstatus]=@sigstatus, [showemail]=@showemail WHERE [uid]=@uid
  2618. UPDATE [dnt_userfields] SET [website]=@website , [icq]=@icq , [qq]=@qq , [yahoo]=@yahoo , [msn]=@msn , [skype]=@skype , [location]=@location , [bio]=@bio, [signature]=@signature, [sightml]=@sightml, [realname]=@realname,[idcard]=@idcard,[mobile]=@mobile,[phone]=@phone  WHERE [uid]=@uid
  2619. GO
  2620. IF OBJECT_ID('dnt_getforumnewtopics','P') IS NOT NULL
  2621. DROP PROC dnt_getforumnewtopics
  2622. GO
  2623. CREATE PROCEDURE dnt_getforumnewtopics
  2624. @fid int
  2625. AS
  2626. DECLARE @strSQL VARCHAR(5000)
  2627. DECLARE @strMaxPostTableId VARCHAR(3)
  2628. SELECT @strMaxPostTableId=max([id]) FROM [dnt_tablelist]
  2629. SET @strSQL = 'SELECT TOP 20 [dnt_topics].[tid],[dnt_topics].[title],[dnt_topics].[poster],[dnt_topics].[postdatetime],[dnt_posts'+@strMaxPostTableId+'].[message] FROM [dnt_topics] LEFT JOIN [dnt_posts'+@strMaxPostTableId+'] ON [dnt_topics].[tid]=[dnt_posts'+@strMaxPostTableId+'].[tid]  WHERE [dnt_posts'+@strMaxPostTableId+'].[layer]=0 AND  [dnt_topics].[fid]='+LTRIM(STR(@fid))+' ORDER BY [lastpost] DESC'
  2630. EXEC(@strSQL)
  2631. GO
  2632. IF OBJECT_ID('[dnt_createtopictags]','P') IS NOT NULL
  2633. DROP PROC [dnt_createtopictags]
  2634. GO
  2635. CREATE PROCEDURE [dnt_createtopictags]
  2636. @tags nvarchar(55),
  2637. @tid int,
  2638. @userid int,
  2639. @postdatetime datetime
  2640. AS
  2641. BEGIN
  2642. EXEC [dnt_createtags] @tags, @userid, @postdatetime
  2643. UPDATE [dnt_tags] SET [fcount]=[fcount]+1,[count]=[count]+1
  2644. WHERE EXISTS (SELECT [item] FROM [dnt_split](@tags, ' ') AS [newtags] WHERE [newtags].[item] = [tagname])
  2645. INSERT INTO [dnt_topictags] (tagid, tid)
  2646. SELECT tagid, @tid FROM [dnt_tags] WHERE EXISTS (SELECT [item] FROM [dnt_split](@tags, ' ') WHERE [item] = [dnt_tags].[tagname])
  2647. END
  2648. GO
  2649. IF OBJECT_ID('[dnt_getfavoriteslistbyalbum]','P') IS NOT NULL
  2650. DROP PROC [dnt_getfavoriteslistbyalbum]
  2651. GO
  2652. CREATE PROCEDURE [dnt_getfavoriteslistbyalbum]
  2653. @uid int,
  2654. @pagesize int,
  2655. @pageindex int
  2656. AS
  2657. DECLARE @strSQL varchar(5000)
  2658. SET @strSQL='SELECT [f].[tid], [f].[uid], [albumid], [albumcateid], [userid] AS [posterid], [username] AS [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [createdatetime] AS [postdatetime] FROM [dnt_favorites] [f],[dnt_albums] [albums] WHERE [f].[tid]=[albums].[albumid] AND [f].[typeid]=1 AND [f].[uid]=' + STR(@uid)
  2659. IF @pageindex = 1
  2660. BEGIN
  2661. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'  [tid], [uid], [albumid], [albumcateid], [posterid], [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [postdatetime]  FROM (' + @strSQL + ') f' + '  ORDER BY [tid] DESC'
  2662. END
  2663. ELSE
  2664. BEGIN
  2665. SET @strSQL = 'SELECT TOP ' + STR(@pagesize) +'  [tid], [uid], [albumid], [albumcateid], [posterid], [poster], [title], [description], [logo], [password], [imgcount], [views], [type], [postdatetime]  FROM (' + @strSQL + ') f1 WHERE [tid] < (SELECT MIN([tid]) FROM (SELECT TOP ' + STR((@pageindex-1)*@pagesize) + ' [tid] FROM (' + @strSQL + ') f2' + '  ORDER BY [tid] DESC) AS tblTmp)' + '  ORDER BY [tid] DESC'
  2666. END
  2667. EXEC(@strSQL)
  2668. GO
  2669. IF OBJECT_ID('dnt_getnewtopics1','P') IS NOT NULL
  2670. DROP PROCEDURE [dnt_getnewtopics1]
  2671. GO
  2672. CREATE PROCEDURE [dnt_getnewtopics1]
  2673. @fidlist VARCHAR(500)
  2674. AS
  2675. IF @fidlist <> ''
  2676. BEGIN
  2677. SELECT TOP(20) 
  2678. [dnt_posts1].[tid], 
  2679.         [dnt_posts1].[title], 
  2680.         [dnt_posts1].[poster], 
  2681.         [dnt_posts1].[postdatetime], 
  2682.         [dnt_posts1].[message],
  2683.         [dnt_forums].[name] 
  2684.         FROM [dnt_posts1]  
  2685.         LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
  2686.         LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
  2687.         WHERE CHARINDEX(','+RTRIM([dnt_forums].[fid])+',', ','+@fidlist+',') > 0 
  2688.         AND [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
  2689.         ORDER BY [dnt_posts1].[tid] DESC
  2690.     END 
  2691.     ELSE
  2692.     BEGIN
  2693. SELECT TOP(20) 
  2694. [dnt_posts1].[tid], 
  2695.         [dnt_posts1].[title], 
  2696.         [dnt_posts1].[poster], 
  2697.         [dnt_posts1].[postdatetime], 
  2698.         [dnt_posts1].[message],
  2699.         [dnt_forums].[name] 
  2700.         FROM [dnt_posts1]
  2701.         LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
  2702.         LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
  2703.         WHERE [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
  2704.         ORDER BY [dnt_posts1].[tid] DESC
  2705.     END
  2706. GO
  2707. IF OBJECT_ID('dnt_getpostlistbycondition1','P') IS NOT NULL
  2708. DROP PROC [dnt_getpostlistbycondition1]
  2709. GO
  2710. CREATE PROCEDURE [dnt_getpostlistbycondition1]
  2711. @tid int,
  2712. @pagesize int,
  2713. @pageindex int,
  2714. @posterid int
  2715. AS
  2716. DECLARE @startRow int,
  2717. @endRow int
  2718. SET @startRow = (@pageindex-1)*@pagesize
  2719. SET @endRow = @startRow + @pagesize - 1
  2720. SELECT 
  2721. POSTS.[pid], 
  2722. POSTS.[fid], 
  2723. POSTS.[title], 
  2724. POSTS.[layer],
  2725. POSTS.[message], 
  2726. POSTS.[ip], 
  2727. POSTS.[lastedit], 
  2728. POSTS.[postdatetime], 
  2729. POSTS.[attachment], 
  2730. POSTS.[poster], 
  2731. POSTS.[posterid], 
  2732. POSTS.[invisible], 
  2733. POSTS.[usesig], 
  2734. POSTS.[htmlon], 
  2735. POSTS.[smileyoff], 
  2736. POSTS.[parseurloff], 
  2737. POSTS.[bbcodeoff], 
  2738. POSTS.[rate], 
  2739. POSTS.[ratetimes], 
  2740. POSTS.[nickname],  
  2741. POSTS.[username], 
  2742. POSTS.[groupid], 
  2743. POSTS.[spaceid],
  2744. POSTS.[gender],
  2745. POSTS.[bday],
  2746. POSTS.[email], 
  2747. POSTS.[showemail], 
  2748. POSTS.[digestposts], 
  2749. POSTS.[credits], 
  2750. POSTS.[extcredits1], 
  2751. POSTS.[extcredits2], 
  2752. POSTS.[extcredits3], 
  2753. POSTS.[extcredits4], 
  2754. POSTS.[extcredits5], 
  2755. POSTS.[extcredits6], 
  2756. POSTS.[extcredits7], 
  2757. POSTS.[extcredits8], 
  2758. POSTS.[posts], 
  2759. POSTS.[joindate], 
  2760. POSTS.[onlinestate],
  2761. POSTS.[lastactivity],  
  2762. POSTS.[invisible] AS usersinvisible, 
  2763. POSTS.[avatar], 
  2764. POSTS.[avatarwidth],
  2765. POSTS.[avatarheight],
  2766. POSTS.[medals],
  2767. POSTS.[signature], 
  2768. POSTS.[location], 
  2769. POSTS.[customstatus], 
  2770. POSTS.[website], 
  2771. POSTS.[icq], 
  2772. POSTS.[qq], 
  2773. POSTS.[msn], 
  2774. POSTS.[yahoo],
  2775. POSTS.[oltime],
  2776. POSTS.[lastvisit],
  2777. POSTS.[skype] 
  2778. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  2779. [dnt_posts1].[pid], 
  2780. [dnt_posts1].[fid], 
  2781. [dnt_posts1].[title], 
  2782. [dnt_posts1].[layer],
  2783. [dnt_posts1].[message], 
  2784. [dnt_posts1].[ip], 
  2785. [dnt_posts1].[lastedit], 
  2786. [dnt_posts1].[postdatetime], 
  2787. [dnt_posts1].[attachment], 
  2788. [dnt_posts1].[poster], 
  2789. [dnt_posts1].[posterid], 
  2790. [dnt_posts1].[invisible], 
  2791. [dnt_posts1].[usesig], 
  2792. [dnt_posts1].[htmlon], 
  2793. [dnt_posts1].[smileyoff], 
  2794. [dnt_posts1].[parseurloff], 
  2795. [dnt_posts1].[bbcodeoff], 
  2796. [dnt_posts1].[rate], 
  2797. [dnt_posts1].[ratetimes], 
  2798. [dnt_users].[nickname],  
  2799. [dnt_users].[username], 
  2800. [dnt_users].[groupid], 
  2801. [dnt_users].[spaceid],
  2802. [dnt_users].[gender],
  2803. [dnt_users].[bday],
  2804. [dnt_users].[email], 
  2805. [dnt_users].[showemail], 
  2806. [dnt_users].[digestposts], 
  2807. [dnt_users].[credits], 
  2808. [dnt_users].[extcredits1], 
  2809. [dnt_users].[extcredits2], 
  2810. [dnt_users].[extcredits3], 
  2811. [dnt_users].[extcredits4], 
  2812. [dnt_users].[extcredits5], 
  2813. [dnt_users].[extcredits6], 
  2814. [dnt_users].[extcredits7], 
  2815. [dnt_users].[extcredits8], 
  2816. [dnt_users].[posts], 
  2817. [dnt_users].[joindate], 
  2818. [dnt_users].[onlinestate],
  2819. [dnt_users].[lastactivity],
  2820. [dnt_users].[oltime],
  2821. [dnt_users].[lastvisit],
  2822. [dnt_users].[invisible] AS usersinvisible, 
  2823. [dnt_userfields].[avatar], 
  2824. [dnt_userfields].[avatarwidth],
  2825. [dnt_userfields].[avatarheight],
  2826. [dnt_userfields].[medals],
  2827. [dnt_userfields].[sightml] AS signature, 
  2828. [dnt_userfields].[location], 
  2829. [dnt_userfields].[customstatus], 
  2830. [dnt_userfields].[website], 
  2831. [dnt_userfields].[icq], 
  2832. [dnt_userfields].[qq], 
  2833. [dnt_userfields].[msn], 
  2834. [dnt_userfields].[yahoo], 
  2835. [dnt_userfields].[skype]
  2836. FROM [dnt_posts1] 
  2837. LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] 
  2838. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
  2839. WHERE [dnt_posts1].[tid]=@tid AND [dnt_posts1].[invisible]=0 AND [posterid]=@posterid) AS POSTS
  2840. WHERE ROWID BETWEEN @startROW AND @endROW
  2841. GO
  2842. IF OBJECT_ID('[dnt_getattentiontopics]','P') IS NOT NULL
  2843. DROP PROC [dnt_getattentiontopics]
  2844. GO
  2845. CREATE PROCEDURE [dnt_getattentiontopics] 
  2846. @fid varchar(255)='',
  2847. @tpp int,
  2848. @pageid int,
  2849. @condition nvarchar(255)=''
  2850. AS
  2851. DECLARE @pagetop int,@strSQL varchar(5000)
  2852. SET @pagetop = (@pageid-1)*@tpp
  2853. IF @pageid = 1
  2854. BEGIN
  2855. SET @strSQL = 'SELECT TOP  ' +STR( @tpp) + '  * FROM [dnt_topics] WHERE [displayorder]>=0  AND [attention]=1'
  2856.                      
  2857. IF @fid<>'0'
  2858.                             SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'
  2859.                             IF @condition<>''
  2860.                             SELECT  @strSQL=@strSQL+@condition
  2861.                            SELECT @strSQL=@strSQL+'  ORDER BY [lastpost] DESC'
  2862.                             
  2863.       
  2864. END
  2865. ELSE
  2866. BEGIN
  2867. SET @strSQL = 'SELECT TOP  ' +STR( @tpp) + '  * FROM [dnt_topics]  WHERE [tid] < (SELECT MIN([tid])  FROM (SELECT TOP '+STR(@pagetop)+' [tid] FROM [dnt_topics]   WHERE [displayorder]>=0  AND [attention]=1'
  2868.  IF @fid<>'0'
  2869.  
  2870.                             SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'
  2871.                           
  2872.                             IF @condition<>''
  2873.                             SELECT  @strSQL=@strSQL+@condition
  2874.                      
  2875.                           SELECT @strSQL=@strSQL+'   ORDER BY [tid] DESC'
  2876.                           SELECT @strSQL=@strSQL+'  )  AS T) '
  2877.  IF @fid<>'0'
  2878.  
  2879.                            SELECT  @strSQL=@strSQL+'  AND [fid] IN ('+@fid+')'
  2880.     IF @condition<>''
  2881.                             SELECT  @strSQL=@strSQL+@condition
  2882.                            SELECT @strSQL=@strSQL+'  AND [displayorder]>=0  AND [attention]=1 ORDER BY [tid] DESC'
  2883.                                  
  2884. END
  2885. EXEC(@strSQL)
  2886. GO
  2887. IF OBJECT_ID('[dnt_updateuser]','P') IS NOT NULL
  2888. DROP PROC [dnt_updateuser]
  2889. GO
  2890. CREATE PROCEDURE [dnt_updateuser]
  2891. @username nchar(20),
  2892. @nickname nchar(20),
  2893. @password char(32),
  2894. @secques char(8),
  2895. @spaceid int,
  2896. @gender int,
  2897. @adminid int,
  2898. @groupid smallint,
  2899. @groupexpiry int,
  2900. @extgroupids char(60),
  2901. @regip char(15),
  2902. @joindate char(19),
  2903. @lastip char(15),
  2904. @lastvisit char(19),
  2905. @lastactivity char(19),
  2906. @lastpost char(19),
  2907. @lastpostid int,
  2908. @lastposttitle nchar(60),
  2909. @posts int,
  2910. @digestposts smallint,
  2911. @oltime int,
  2912. @pageviews int,
  2913. @credits int,
  2914. @extcredits1 float,
  2915. @extcredits2 float,
  2916. @extcredits3 float,
  2917. @extcredits4 float,
  2918. @extcredits5 float,
  2919. @extcredits6 float,
  2920. @extcredits7 float,
  2921. @extcredits8 float,
  2922. @avatarshowid int,
  2923. @email char(50),
  2924. @bday char(19),
  2925. @sigstatus int,
  2926. @tpp int,
  2927. @ppp int,
  2928. @templateid smallint,
  2929. @pmsound int,
  2930. @showemail int,
  2931. @newsletter int,
  2932. @invisible int,
  2933. @newpm int,
  2934. @newpmcount int,
  2935. @accessmasks int,
  2936. @onlinestate int,
  2937. @website varchar(80),
  2938. @icq varchar(12),
  2939. @qq varchar(12),
  2940. @yahoo varchar(40),
  2941. @msn varchar(40),
  2942. @skype varchar(40),
  2943. @location nvarchar(30),
  2944. @customstatus varchar(30),
  2945. @avatar varchar(255),
  2946. @avatarwidth int,
  2947. @avatarheight int,
  2948. @medals varchar(300),
  2949. @bio nvarchar(500),
  2950. @signature nvarchar(500),
  2951. @sightml nvarchar(1000),
  2952. @authstr varchar(20),
  2953. @authtime smalldatetime,
  2954. @authflag tinyint,
  2955. @realname nvarchar(10),
  2956. @idcard varchar(20),
  2957. @mobile varchar(20),
  2958. @phone varchar(20),
  2959. @ignorepm nvarchar(1000),
  2960. @uid int
  2961. AS
  2962. UPDATE [dnt_users] SET [username]=@username,[nickname]=@nickname, [password]=@password, [secques]=@secques, [spaceid]=@spaceid, [gender]=@gender, [adminid]=@adminid, [groupid]=@groupid, [groupexpiry]=@groupexpiry, 
  2963. [extgroupids]=@extgroupids, [regip]= @regip, [joindate]= @joindate, [lastip]=@lastip, [lastvisit]=@lastvisit, [lastactivity]=@lastactivity, [lastpost]=@lastpost, 
  2964. [lastpostid]=@lastpostid, [lastposttitle]=@lastposttitle, [posts]=@posts, [digestposts]=@digestposts, [oltime]=@oltime, [pageviews]=@pageviews, [credits]=@credits, 
  2965. [extcredits1]=@extcredits1, [extcredits2]=@extcredits2, [extcredits3]=@extcredits3, [extcredits4]=@extcredits4, [extcredits5]=@extcredits5, [extcredits6]=@extcredits6, 
  2966. [extcredits7]=@extcredits7, [extcredits8]=@extcredits8, [avatarshowid]=@avatarshowid, [email]=@email, [bday]=@bday, [sigstatus]=@sigstatus, [tpp]=@tpp, [ppp]=@ppp, 
  2967. [templateid]=@templateid, [pmsound]=@pmsound, [showemail]=@showemail, [newsletter]=@newsletter, [invisible]=@invisible, [newpm]=@newpm, [newpmcount]=@newpmcount, [accessmasks]=@accessmasks, [onlinestate]=@onlinestate 
  2968. WHERE [uid]=@uid
  2969. UPDATE [dnt_userfields] SET [website]=@website,[icq]=@icq,[qq]=@qq,[yahoo]=@yahoo,[msn]=@msn,[skype]=@skype,[location]=@location,[customstatus]=@customstatus,
  2970. [avatar]=@avatar,[avatarwidth]=@avatarwidth,[avatarheight]=@avatarheight,[medals]=@medals,[bio]=@bio,[signature]=@signature,[sightml]=@sightml,[authstr]=@authstr,
  2971. [authtime]=@authtime,[authflag]=@authflag,[realname]=@realname,[idcard]=@idcard,[mobile]=@mobile,[phone]=@phone,[ignorepm]=@ignorepm 
  2972. WHERE [uid]=@uid
  2973. GO
  2974. IF OBJECT_ID('[dnt_split]') IS NOT NULL
  2975. DROP FUNCTION [dnt_split]
  2976. GO
  2977. CREATE FUNCTION [dnt_split]
  2978. (
  2979.  @splitstring NVARCHAR(4000),
  2980.  @separator CHAR(1) = ','
  2981. )
  2982. RETURNS @splitstringstable TABLE
  2983. (
  2984.  [item] NVARCHAR(200)
  2985. )
  2986. AS
  2987. BEGIN
  2988.     DECLARE @currentindex INT
  2989.     DECLARE @nextindex INT
  2990.     DECLARE @returntext NVARCHAR(200)
  2991.     SELECT @currentindex=1
  2992.     WHILE(@currentindex<=datalength(@splitstring)/2)
  2993.     BEGIN
  2994.         SELECT @nextindex=charindex(@separator,@splitstring,@currentindex)
  2995.         IF(@nextindex=0 OR @nextindex IS NULL)
  2996.             SELECT @nextindex=datalength(@splitstring)/2+1
  2997.         
  2998.         SELECT @returntext=substring(@splitstring,@currentindex,@nextindex-@currentindex)
  2999.         INSERT INTO @splitstringstable([item])
  3000.         VALUES(@returntext)
  3001.         
  3002.         SELECT @currentindex=@nextindex+1
  3003.     END
  3004.     RETURN
  3005. END
  3006. GO
  3007. if exists (select * from sysobjects where id = object_id(N'[dnt_getindexforumlist]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3008. drop procedure [dnt_getindexforumlist]
  3009. GO
  3010. if exists (select * from sysobjects where id = object_id(N'[dnt_getonlineuser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3011. drop procedure [dnt_getonlineuser]
  3012. GO
  3013. if exists (select * from sysobjects where id = object_id(N'[dnt_getonlineuserlist]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3014. drop procedure [dnt_getonlineuserlist]
  3015. GO
  3016. if exists (select * from sysobjects where id = object_id(N'[dnt_getonlineuserlistbyfid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3017. drop procedure [dnt_getonlineuserlistbyfid]
  3018. GO
  3019. if exists (select * from sysobjects where id = object_id(N'[dnt_getrelatedtopics]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3020. drop procedure [dnt_getrelatedtopics]
  3021. GO
  3022. if exists (select * from sysobjects where id = object_id(N'[dnt_gettopicinfo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3023. drop procedure [dnt_gettopicinfo]
  3024. GO
  3025. if exists (select * from sysobjects where id = object_id(N'[dnt_createonlineuser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3026. drop procedure [dnt_createonlineuser]
  3027. GO
  3028. if exists (select * from sysobjects where id = object_id(N'[dnt_deleteonlineusers]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3029. drop procedure [dnt_deleteonlineusers]
  3030. GO
  3031. if exists (select * from sysobjects where id = object_id(N'[dnt_updateonlineaction]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3032. drop procedure [dnt_updateonlineaction]
  3033. GO
  3034. CREATE PROCEDURE [dnt_updateonlineaction] 
  3035. @action smallint,
  3036. @lastupdatetime datetime,