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

SCSI/ASPI

开发平台:

Others

  1.                     if exists (select * from sysobjects where id = object_id(N'[dnt_createpost]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2.                     drop procedure [dnt_createpost]
  3.                     ~
  4.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getfirstpostid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  5.                     drop procedure [dnt_getfirstpostid]
  6.                     ~
  7.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getpostcount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  8.                     drop procedure [dnt_getpostcount]
  9.                     ~
  10.                     if exists (select * from sysobjects where id = object_id(N'[dnt_deletepostbypid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  11.                     drop procedure [dnt_deletepostbypid]
  12.                     ~
  13.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getposttree]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  14.                     drop procedure [dnt_getposttree]
  15.                     ~
  16.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getsinglepost]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  17.                     drop procedure [dnt_getsinglepost]
  18.                     ~
  19.                     if exists (select * from sysobjects where id = object_id(N'[dnt_updatepost]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  20.                     drop procedure [dnt_updatepost]
  21.                     ~
  22.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getpostlist1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  23.                     drop procedure [dnt_getpostlist1]
  24.                     ~
  25.                     if exists (select * from sysobjects where id = object_id(N'[dnt_deletetopicbytidlist1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  26.                     drop procedure [dnt_deletetopicbytidlist1]
  27.                     
  28.                     ~
  29.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getreplypid1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  30.                     drop procedure [dnt_getreplypid1]
  31.                     
  32.                     ~
  33.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getnewtopics1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  34.                     drop procedure [dnt_getnewtopics1]
  35.                     
  36.                     ~
  37.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getlastpostlist1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  38.                     drop procedure [dnt_getlastpostlist1] 
  39.                     
  40.                     ~
  41.                     if exists (select * from sysobjects where id = object_id(N'[dnt_getdebatepostlist1]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  42.                     drop procedure [dnt_getdebatepostlist1]
  43.                     ~
  44.                     
  45.                     CREATE PROCEDURE dnt_createpost
  46.                     @fid int,
  47.                     @tid int,
  48.                     @parentid int,
  49.                     @layer int,
  50.                     @poster varchar(20),
  51.                     @posterid int,
  52.                     @title nvarchar(60),
  53.                     @topictitle nvarchar(60),
  54.                     @postdatetime char(20),
  55.                     @message ntext,
  56.                     @ip varchar(15),
  57.                     @lastedit varchar(50),
  58.                     @invisible int,
  59.                     @usesig int,
  60.                     @htmlon int,
  61.                     @smileyoff int,
  62.                     @bbcodeoff int,
  63.                     @parseurloff int,
  64.                     @attachment int,
  65.                     @rate int,
  66.                     @ratetimes int
  67.                     AS
  68.                     DEClARE @postid int
  69.                     DELETE FROM [dnt_postid] WHERE DATEDIFF(n, postdatetime, GETDATE()) >5
  70.                     INSERT INTO [dnt_postid] ([postdatetime]) VALUES(GETDATE())
  71.                     SELECT @postid=SCOPE_IDENTITY()
  72.                     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)
  73.                     IF @parentid=0
  74.                         BEGIN
  75.                     
  76.                             UPDATE [dnt_posts1] SET [parentid]=@postid WHERE [pid]=@postid
  77.                         END
  78.                     IF @@ERROR=0
  79.                         BEGIN
  80.                             IF  @invisible = 0
  81.                             BEGIN
  82.                     
  83.                                 UPDATE [dnt_statistics] SET [totalpost]=[totalpost] + 1
  84.                     
  85.                     
  86.                     
  87.                                 DECLARE @fidlist AS VARCHAR(1000)
  88.                                 DECLARE @strsql AS VARCHAR(4000)
  89.                     
  90.                                 SET @fidlist = '';
  91.                     
  92.                                 SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
  93.                                 IF RTRIM(@fidlist)<>''
  94.                                 BEGIN
  95.                                 SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
  96.                                 END
  97.                                 ELSE
  98.                                 BEGIN
  99.                                 SET @fidlist = CAST(@fid AS VARCHAR(10))
  100.                                 END
  101.                             
  102.                     
  103.                                 UPDATE [dnt_forums] SET 
  104.                                 [posts]=[posts] + 1, 
  105.                                 [todayposts]=CASE 
  106.                                 WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts] + 1 
  107.                                  ELSE 1 
  108.                                  END,
  109.                                 [lasttid]=@tid,
  110.                                             [lasttitle]=@topictitle,
  111.                                 [lastpost]=@postdatetime,
  112.                                 [lastposter]=@poster,
  113.                                 [lastposterid]=@posterid 
  114.                     
  115.                                  WHERE fid IN (SELECT [item] FROM [dnt_split](@fidlist, ','))
  116.                     
  117.                     
  118.                                 UPDATE [dnt_users] SET
  119.                                 [lastpost] = @postdatetime,
  120.                                 [lastpostid] = @postid,
  121.                                 [lastposttitle] = @title,
  122.                                 [posts] = [posts] + 1,
  123.                                 [lastactivity] = GETDATE()
  124.                                 WHERE [uid] = @posterid
  125.                             
  126.                             
  127.                                 IF @layer<=0
  128.                                 BEGIN
  129.                                 UPDATE [dnt_topics] SET [replies]=0,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
  130.                                 END
  131.                                 ELSE
  132.                                 BEGIN
  133.                                 UPDATE [dnt_topics] SET [replies]=[replies] + 1,[lastposter]=@poster,[lastpost]=@postdatetime,[lastposterid]=@posterid WHERE [tid]=@tid
  134.                                 END
  135.                             END
  136.                             UPDATE [dnt_topics] SET [lastpostid]=@postid WHERE [tid]=@tid
  137.                             
  138.                         IF @posterid <> -1
  139.                             BEGIN
  140.                                 INSERT [dnt_myposts]([uid], [tid], [pid], [dateline]) VALUES(@posterid, @tid, @postid, @postdatetime)
  141.                             END
  142.                         END
  143.                     
  144.                     SELECT @postid AS postid
  145.                     ~
  146.                     CREATE PROCEDURE dnt_getfirstpostid
  147.                     @tid int
  148.                     AS
  149.                     SELECT TOP 1 [pid] FROM [dnt_posts1] WHERE [tid]=@tid ORDER BY [pid]
  150.                     ~
  151.                     CREATE PROCEDURE dnt_getpostcount
  152.                     @tid int
  153.                     AS
  154.                     SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid]=@tid AND [invisible]=0 AND layer>0
  155.                     ~
  156.                     CREATE  PROCEDURE dnt_deletepostbypid
  157.                         @pid int,
  158. @chanageposts AS BIT
  159.                     AS
  160.                         DECLARE @fid int
  161.                         DECLARE @tid int
  162.                         DECLARE @posterid int
  163.                         DECLARE @lastforumposterid int
  164.                         DECLARE @layer int
  165.                         DECLARE @postdatetime smalldatetime
  166.                         DECLARE @poster varchar(50)
  167.                         DECLARE @postcount int
  168.                         DECLARE @title nchar(60)
  169.                         DECLARE @lasttid int
  170.                         DECLARE @postid int
  171.                         DECLARE @todaycount int
  172.                     
  173.                     
  174.                         SELECT @fid = [fid],@tid = [tid],@posterid = [posterid],@layer = [layer], @postdatetime = [postdatetime] FROM [dnt_posts1] WHERE pid = @pid
  175.                         DECLARE @fidlist AS VARCHAR(1000)
  176.                     
  177.                         SET @fidlist = '';
  178.                     
  179.                         SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
  180.                         IF RTRIM(@fidlist)<>''
  181.                             BEGIN
  182.                                 SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
  183.                             END
  184.                         ELSE
  185.                             BEGIN
  186.                                 SET @fidlist = CAST(@fid AS VARCHAR(10))
  187.                             END
  188.                         IF @layer<>0
  189.                             BEGIN
  190.                     
  191. IF @chanageposts = 1
  192. BEGIN
  193. UPDATE [dnt_statistics] SET [totalpost]=[totalpost] - 1
  194. UPDATE [dnt_forums] SET 
  195. [posts]=[posts] - 1, 
  196. [todayposts]=CASE 
  197. WHEN DATEPART(yyyy, @postdatetime)=DATEPART(yyyy,GETDATE()) AND DATEPART(mm, @postdatetime)=DATEPART(mm,GETDATE()) AND DATEPART(dd, @postdatetime)=DATEPART(dd,GETDATE()) THEN [todayposts] - 1
  198. ELSE [todayposts]
  199. END
  200. WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
  201. (SELECT @fidlist AS [fid]) + ',') > 0)
  202.                     
  203. UPDATE [dnt_users] SET [posts] = [posts] - 1 WHERE [uid] = @posterid
  204. UPDATE [dnt_topics] SET [replies]=[replies] - 1 WHERE [tid]=@tid
  205. END
  206.                     
  207.                                 DELETE FROM [dnt_posts1] WHERE [pid]=@pid
  208.                     
  209.                             END
  210.                         ELSE
  211.                             BEGIN
  212.                     
  213.                                 SELECT @postcount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid
  214.                                 SELECT @todaycount = COUNT([pid]) FROM [dnt_posts1] WHERE [tid] = @tid AND DATEDIFF(d, [postdatetime], GETDATE()) = 0
  215.                     
  216. IF @chanageposts = 1
  217. BEGIN
  218. UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] - 1, [totalpost]=[totalpost] - @postcount
  219.                     
  220. UPDATE [dnt_forums] SET [posts]=[posts] - @postcount, [topics]=[topics] - 1,[todayposts]=[todayposts] - @todaycount WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +(SELECT @fidlist AS [fid]) + ',') > 0)
  221.                     
  222. UPDATE [dnt_users] SET [posts] = [posts] - @postcount WHERE [uid] = @posterid
  223.                     
  224. END
  225.                                 DELETE FROM [dnt_posts1] WHERE [tid] = @tid
  226.                     
  227.                                 DELETE FROM [dnt_topics] WHERE [tid] = @tid
  228.                     
  229.                             END
  230.                     
  231.                         IF @layer<>0
  232.                             BEGIN
  233.                                 SELECT TOP 1 @pid = [pid], @posterid = [posterid], @postdatetime = [postdatetime], @title = [title], @poster = [poster] FROM [dnt_posts1] WHERE [tid]=@tid ORDER BY [pid] DESC
  234.                                 UPDATE [dnt_topics] SET [lastposter]=@poster,[lastpost]=@postdatetime,[lastpostid]=@pid,[lastposterid]=@posterid WHERE [tid]=@tid
  235.                             END
  236.                         SELECT @lasttid = [lasttid] FROM [dnt_forums] WHERE [fid] = @fid
  237.                     
  238.                         IF @lasttid = @tid
  239.                             BEGIN
  240.                     
  241.                     
  242.                                 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
  243.                     
  244.                             
  245.                             
  246.                                 UPDATE [dnt_forums] SET 
  247.                     
  248.                                 [lastpost]=@postdatetime,
  249.                                 [lastposter]=ISNULL(@poster,''),
  250.                                 [lastposterid]=ISNULL(@lastforumposterid,'0')
  251.                                 WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
  252.                                 (SELECT @fidlist AS [fid]) + ',') > 0)
  253.                     
  254.                                 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
  255.                     
  256.                                 UPDATE [dnt_users] SET
  257.                     
  258.                                 [lastpost] = @postdatetime,
  259.                                 [lastpostid] = @pid,
  260.                                 [lastposttitle] = ISNULL(@title,'')
  261.                     
  262.                                 WHERE [uid] = @posterid
  263.                     
  264.                             END
  265.                     ~
  266.                     CREATE PROCEDURE dnt_getposttree
  267.                     @tid int
  268.                     AS
  269.                     SELECT [pid], [layer], [title], [poster], [posterid],[postdatetime],[message] FROM [dnt_posts1] WHERE [tid]=@tid AND [invisible]=0 ORDER BY [parentid];
  270.                     ~
  271.                     CREATE PROCEDURE dnt_getsinglepost
  272.                     @tid int,
  273.                     @pid int
  274.                     AS
  275.                     SELECT [aid], [tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize], [attachment], [downloads], [attachprice], [width], [height], [uid]  FROM [dnt_attachments] WHERE [tid]=@tid
  276.                     SELECT TOP 1 
  277.                                 [dnt_posts1].[pid], 
  278.                                 [dnt_posts1].[fid], 
  279.                                 [dnt_posts1].[title], 
  280.                                 [dnt_posts1].[layer],
  281.                                 [dnt_posts1].[message], 
  282.                                 [dnt_posts1].[ip], 
  283.                                 [dnt_posts1].[lastedit], 
  284.                                 [dnt_posts1].[postdatetime], 
  285.                                 [dnt_posts1].[attachment], 
  286.                                 [dnt_posts1].[poster], 
  287.                                 [dnt_posts1].[invisible], 
  288.                                 [dnt_posts1].[usesig], 
  289.                                 [dnt_posts1].[htmlon], 
  290.                                 [dnt_posts1].[smileyoff], 
  291.                                 [dnt_posts1].[parseurloff], 
  292.                                 [dnt_posts1].[bbcodeoff], 
  293.                                 [dnt_posts1].[rate], 
  294.                                 [dnt_posts1].[ratetimes], 
  295.                                 [dnt_posts1].[posterid], 
  296.                                 [dnt_users].[nickname],  
  297.                                 [dnt_users].[username], 
  298.                                 [dnt_users].[groupid],
  299.                                     [dnt_users].[spaceid],
  300.                                     [dnt_users].[gender],
  301. [dnt_users].[bday], 
  302.                                 [dnt_users].[email], 
  303.                                 [dnt_users].[showemail], 
  304.                                 [dnt_users].[digestposts], 
  305.                                 [dnt_users].[credits], 
  306.                                 [dnt_users].[extcredits1], 
  307.                                 [dnt_users].[extcredits2], 
  308.                                 [dnt_users].[extcredits3], 
  309.                                 [dnt_users].[extcredits4], 
  310.                                 [dnt_users].[extcredits5], 
  311.                                 [dnt_users].[extcredits6], 
  312.                                 [dnt_users].[extcredits7], 
  313.                                 [dnt_users].[extcredits8], 
  314.                                 [dnt_users].[posts], 
  315.                                 [dnt_users].[joindate], 
  316.                                 [dnt_users].[onlinestate], 
  317.                                 [dnt_users].[lastactivity],
  318. [dnt_users].[oltime],
  319. [dnt_users].[lastvisit],
  320.                                 [dnt_users].[invisible], 
  321.                                 [dnt_userfields].[avatar], 
  322.                                 [dnt_userfields].[avatarwidth], 
  323.                                 [dnt_userfields].[avatarheight], 
  324.                                 [dnt_userfields].[medals], 
  325.                                 [dnt_userfields].[sightml] AS signature, 
  326.                                 [dnt_userfields].[location], 
  327.                                 [dnt_userfields].[customstatus], 
  328.                                 [dnt_userfields].[website], 
  329.                                 [dnt_userfields].[icq], 
  330.                                 [dnt_userfields].[qq], 
  331.                                 [dnt_userfields].[msn], 
  332.                                 [dnt_userfields].[yahoo], 
  333.                                 [dnt_userfields].[skype] 
  334.                     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
  335.                     ~
  336.                     CREATE PROCEDURE dnt_updatepost
  337.                         @pid int,
  338.                         @title nvarchar(160),
  339.                         @message ntext,
  340.                         @lastedit nvarchar(50),
  341.                         @invisible int,
  342.                         @usesig int,
  343.                         @htmlon int,
  344.                         @smileyoff int,
  345.                         @bbcodeoff int,
  346.                         @parseurloff int
  347.                     AS
  348.                     UPDATE dnt_posts1 SET 
  349.                         [title]=@title,
  350.                         [message]=@message,
  351.                         [lastedit]=@lastedit,
  352.                         [invisible]=@invisible,
  353.                         [usesig]=@usesig,
  354.                         [htmlon]=@htmlon,
  355.                         [smileyoff]=@smileyoff,
  356.                         [bbcodeoff]=@bbcodeoff,
  357.                         [parseurloff]=@parseurloff WHERE [pid]=@pid
  358.                     ~
  359. CREATE PROCEDURE [dnt_getpostlist1]
  360. @tid int,
  361. @pagesize int,
  362. @pageindex int
  363. AS
  364. DECLARE @startRow int,
  365. @endRow int
  366. SET @startRow = (@pageIndex - 1) * @pageSize +1
  367. SET @endRow = @startRow + @pageSize -1 
  368. SELECT 
  369. [POSTS].[pid],
  370. [POSTS].[fid], 
  371. [POSTS].[title], 
  372. [POSTS].[layer],
  373. [POSTS].[message], 
  374. [POSTS].[ip], 
  375. [POSTS].[lastedit], 
  376. [POSTS].[postdatetime], 
  377. [POSTS].[attachment], 
  378. [POSTS].[poster], 
  379. [POSTS].[posterid], 
  380. [POSTS].[invisible], 
  381. [POSTS].[usesig], 
  382. [POSTS].[htmlon], 
  383. [POSTS].[smileyoff], 
  384. [POSTS].[parseurloff], 
  385. [POSTS].[bbcodeoff], 
  386. [POSTS].[rate], 
  387. [POSTS].[ratetimes],  
  388. [POSTS].[nickname],  
  389. [POSTS].[username], 
  390. [POSTS].[groupid], 
  391. [POSTS].[spaceid],
  392. [POSTS].[gender],
  393. [POSTS].[bday],
  394. [POSTS].[email], 
  395. [POSTS].[showemail], 
  396. [POSTS].[digestposts], 
  397. [POSTS].[credits], 
  398. [POSTS].[extcredits1], 
  399. [POSTS].[extcredits2], 
  400. [POSTS].[extcredits3], 
  401. [POSTS].[extcredits4], 
  402. [POSTS].[extcredits5], 
  403. [POSTS].[extcredits6], 
  404. [POSTS].[extcredits7], 
  405. [POSTS].[extcredits8], 
  406. [POSTS].[posts], 
  407. [POSTS].[joindate], 
  408. [POSTS].[onlinestate],
  409. [POSTS].[lastactivity],  
  410. [POSTS].[userinvisible], 
  411. [POSTS].[avatar], 
  412. [POSTS].[avatarwidth], 
  413. [POSTS].[avatarheight], 
  414. [POSTS].[medals],
  415. [POSTS].[signature], 
  416. [POSTS].[location], 
  417. [POSTS].[customstatus], 
  418. [POSTS].[website], 
  419. [POSTS].[icq], 
  420. [POSTS].[qq], 
  421. [POSTS].[msn], 
  422. [POSTS].[yahoo],
  423. [POSTS].[oltime],
  424. [POSTS].[lastvisit],
  425. [POSTS].[skype] 
  426. FROM (SELECT ROW_NUMBER() OVER(ORDER BY pid)AS ROWID,
  427. [dnt_posts1].[pid],
  428. [dnt_posts1].[fid], 
  429. [dnt_posts1].[title], 
  430. [dnt_posts1].[layer],
  431. [dnt_posts1].[message], 
  432. [dnt_posts1].[ip], 
  433. [dnt_posts1].[lastedit], 
  434. [dnt_posts1].[postdatetime], 
  435. [dnt_posts1].[attachment], 
  436. [dnt_posts1].[poster], 
  437. [dnt_posts1].[posterid], 
  438. [dnt_posts1].[invisible], 
  439. [dnt_posts1].[usesig], 
  440. [dnt_posts1].[htmlon], 
  441. [dnt_posts1].[smileyoff], 
  442. [dnt_posts1].[parseurloff], 
  443. [dnt_posts1].[bbcodeoff], 
  444. [dnt_posts1].[rate], 
  445. [dnt_posts1].[ratetimes],  
  446. [dnt_users].[nickname],  
  447. [dnt_users].[username], 
  448. [dnt_users].[groupid], 
  449. [dnt_users].[spaceid],
  450. [dnt_users].[gender],
  451. [dnt_users].[bday],
  452. [dnt_users].[email], 
  453. [dnt_users].[showemail], 
  454. [dnt_users].[digestposts], 
  455. [dnt_users].[credits], 
  456. [dnt_users].[extcredits1], 
  457. [dnt_users].[extcredits2], 
  458. [dnt_users].[extcredits3], 
  459. [dnt_users].[extcredits4], 
  460. [dnt_users].[extcredits5], 
  461. [dnt_users].[extcredits6], 
  462. [dnt_users].[extcredits7], 
  463. [dnt_users].[extcredits8], 
  464. [dnt_users].[posts], 
  465. [dnt_users].[joindate], 
  466. [dnt_users].[onlinestate],
  467. [dnt_users].[lastactivity],
  468. [dnt_users].[oltime],
  469. [dnt_users].[lastvisit],
  470. [dnt_users].[invisible] AS [userinvisible], 
  471. [dnt_userfields].[avatar], 
  472. [dnt_userfields].[avatarwidth], 
  473. [dnt_userfields].[avatarheight], 
  474. [dnt_userfields].[medals],
  475. [dnt_userfields].[sightml] AS [signature], 
  476. [dnt_userfields].[location], 
  477. [dnt_userfields].[customstatus], 
  478. [dnt_userfields].[website], 
  479. [dnt_userfields].[icq], 
  480. [dnt_userfields].[qq], 
  481. [dnt_userfields].[msn], 
  482. [dnt_userfields].[yahoo], 
  483. [dnt_userfields].[skype]
  484. 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] 
  485. WHERE [tid] = @tid AND [dnt_posts1].[invisible] <=0) AS POSTS 
  486. WHERE ROWID BETWEEN @startRow AND @endRow
  487. ~
  488. CREATE PROCEDURE [dnt_deletetopicbytidlist1]
  489.     @tidlist AS VARCHAR(2000),
  490.     @chanageposts AS BIT
  491. AS
  492.     DECLARE @postcount int
  493.     DECLARE @topiccount int
  494.     DECLARE @todaycount int
  495.     DECLARE @sqlstr nvarchar(4000)
  496.     DECLARE @fid varchar(2000)
  497.     DECLARE @posterid varchar(200)
  498.     DECLARE @tempFid int
  499.     DECLARE @tempPosterid int
  500.     DECLARE @tempLayer int
  501.     DECLARE @temppostdatetime datetime
  502.     DECLARE @tempfidlist AS VARCHAR(1000)
  503.     SET @fid = ''
  504.     SET @posterid = ''
  505.     SET @postcount=0
  506.     SET @topiccount=0
  507.     SET @todaycount=0
  508.     SET @tempfidlist = '';
  509.     IF @tidlist<>''
  510.         BEGIN
  511.             EXEC('DECLARE cu_dnt_posts CURSOR FOR SELECT [fid],[posterid],[layer],[postdatetime] FROM [dnt_posts1] WHERE [dnt_posts1].[tid] IN ('+@tidlist+')')
  512.             OPEN cu_dnt_posts
  513.             FETCH NEXT FROM cu_dnt_posts into @tempFid,@tempPosterid,@tempLayer,@temppostdatetime
  514.             WHILE @@FETCH_STATUS = 0
  515.                 BEGIN
  516.                     SET @postcount = @postcount + 1
  517.                     IF @tempLayer = 0
  518.                     BEGIN
  519.                     SET @topiccount = @topiccount + 1
  520.                     END
  521.                     IF DATEDIFF(d,@temppostdatetime,GETDATE()) = 0
  522.                     BEGIN
  523.                     SET @todaycount = @todaycount + 1
  524.                     END
  525.                     IF CHARINDEX(',' + LTRIM(STR(@tempFid)) + ',',@fid + ',') = 0
  526.                     BEGIN
  527.                     --SET @fid = @fid + ',' + LTRIM(STR(@tempFid))
  528.                     SELECT @tempfidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @tempFid
  529.                     IF RTRIM(@tempfidlist)<>''
  530.                     BEGIN
  531.                     SET @fid = RTRIM(@fid) + ',' +  RTRIM(@tempfidlist) + ',' + CAST(@tempFid AS VARCHAR(10))
  532.                     END
  533.                     ELSE
  534.                     BEGIN
  535.                     SET @fid =RTRIM(@fid) + ',' +  CAST(@tempFid AS VARCHAR(10))
  536.                     END
  537.                     END
  538.                     IF @chanageposts = 1
  539.                     BEGIN
  540.                     UPDATE [dnt_users] SET [posts] = [posts] - 1 WHERE [uid] = @tempPosterid
  541.                     END
  542.                     FETCH NEXT FROM cu_dnt_posts into @tempFid,@tempPosterid,@tempLayer,@temppostdatetime
  543.                 END
  544.             CLOSE cu_dnt_posts
  545.             DEALLOCATE cu_dnt_posts
  546.             IF LEN(@fid)>0
  547.                 BEGIN
  548.                     SET @fid = SUBSTRING(@fid,2,LEN(@fid)-1)
  549.                     IF @chanageposts = 1
  550.                     BEGIN
  551.                     UPDATE [dnt_statistics] SET [totaltopic]=[totaltopic] - @topiccount, [totalpost]=[totalpost] - @postcount
  552.                     EXEC('UPDATE [dnt_forums] 
  553.                     SET [posts]=[posts] - ' + @postcount + ',  
  554.                     [topics]=[topics] - ' + @topiccount + ', 
  555.                     [todayposts] = [todayposts] - ' + @todaycount + ' 
  556.                     WHERE [fid] IN ('+@fid+')')
  557.                     END
  558.                     EXEC('DELETE FROM [dnt_favorites] WHERE [tid] IN ('+@tidlist+') AND [typeid]=0')
  559.                     EXEC('DELETE FROM [dnt_polls] WHERE [tid] IN ('+@tidlist+')')
  560.                     EXEC('DELETE FROM [dnt_posts1] WHERE [tid] IN ('+@tidlist+')')
  561.                     EXEC('DELETE FROM [dnt_mytopics] WHERE [tid] IN ('+@tidlist+')')
  562.                 END
  563.             EXEC('DELETE FROM [dnt_topics] WHERE [closed] IN ('+@tidlist+') OR [tid] IN ('+@tidlist+')')
  564.             EXEC('UPDATE [dnt_tags] SET [count]=[count]-1, [fcount]=[fcount]-1 WHERE [tagid] IN (SELECT [tagid] FROM [dnt_topictags] WHERE [tid] IN ('+@tidlist+'))') 
  565.             EXEC('DELETE FROM [dnt_topictags] WHERE [tid] IN ('+@tidlist+')')
  566.             EXEC('DELETE FROM [dnt_topictagcaches] WHERE [tid] IN ('+@tidlist+') OR [linktid] IN ('+@tidlist+')')
  567. END   
  568. ~
  569.                     CREATE PROCEDURE [dnt_getreplypid1]
  570.                     @uid int,
  571.                     @tid int
  572.                     AS
  573.                     SELECT TOP 1 [pid] FROM [dnt_posts1] WHERE [tid] =@tid AND [posterid]=@uid
  574.                     
  575.                     ~
  576. CREATE PROCEDURE [dnt_getnewtopics1]
  577. @fidlist VARCHAR(500)
  578. AS
  579. IF @fidlist <> ''
  580. BEGIN
  581. SELECT TOP(20) 
  582. [dnt_posts1].[tid], 
  583. [dnt_posts1].[title], 
  584. [dnt_posts1].[poster], 
  585. [dnt_posts1].[postdatetime], 
  586. [dnt_posts1].[message],
  587. [dnt_forums].[name] 
  588. FROM [dnt_posts1]  
  589. LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
  590. LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
  591. WHERE CHARINDEX(','+RTRIM([dnt_forums].[fid])+',', ','+@fidlist+',') > 0 
  592. AND [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
  593. ORDER BY [dnt_posts1].[tid] DESC
  594. END 
  595. ELSE
  596. BEGIN
  597. SELECT TOP(20) 
  598. [dnt_posts1].[tid], 
  599. [dnt_posts1].[title], 
  600. [dnt_posts1].[poster], 
  601. [dnt_posts1].[postdatetime], 
  602. [dnt_posts1].[message],
  603. [dnt_forums].[name] 
  604. FROM [dnt_posts1]
  605. LEFT JOIN [dnt_forums] ON [dnt_posts1].[fid]=[dnt_forums].[fid]
  606. LEFT JOIN [dnt_topics] ON [dnt_posts1].[tid]=[dnt_topics].[tid]
  607. WHERE [dnt_posts1].[layer]=0 AND [dnt_topics].[displayorder] >= 0
  608. ORDER BY [dnt_posts1].[tid] DESC
  609. END
  610.                     ~
  611.                     CREATE PROCEDURE [dnt_getlastpostlist1]
  612.                     @tid int,
  613.                     @pageindex int,
  614.                     @postnum int,
  615.                     @posttablename varchar(20)
  616.                     AS
  617.                     DECLARE @startRow int,
  618.                     @endRow int
  619.                     SET @startRow = (@pageIndex - 1) * @postnum +1
  620.                     SET @endRow = @startRow + @postnum -1
  621.                     SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  622.                     [dnt_posts1].[pid],
  623.                     [dnt_posts1].[fid], 
  624.                     [dnt_posts1].[layer],
  625.                     [dnt_posts1].[posterid],
  626.                     [dnt_posts1].[title], 
  627.                     [dnt_posts1].[message], 
  628.                     [dnt_posts1].[postdatetime], 
  629.                     [dnt_posts1].[attachment], 
  630.                     [dnt_posts1].[poster], 
  631.                     [dnt_posts1].[invisible], 
  632.                     [dnt_posts1].[usesig], 
  633.                     [dnt_posts1].[htmlon], 
  634.                     [dnt_posts1].[smileyoff], 
  635.                     [dnt_posts1].[parseurloff], 
  636.                     [dnt_posts1].[bbcodeoff], 
  637.                     [dnt_posts1].[rate], 
  638.                     [dnt_posts1].[ratetimes], 
  639.                     [dnt_users].[username], 
  640.                     [dnt_users].[email], 
  641.                     [dnt_users].[showemail], 
  642.                     [dnt_userfields].[avatar], 
  643.                     [dnt_userfields].[avatarwidth], 
  644.                     [dnt_userfields].[avatarheight], 
  645.                     [dnt_userfields].[sightml] AS [signature], 
  646.                     [dnt_userfields].[location], 
  647.                     [dnt_userfields].[customstatus] 
  648.                     FROM [dnt_posts1] 
  649.                     LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid]
  650.                     LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
  651.                     WHERE [dnt_posts1].[tid] = @tid AND [dnt_posts1].[invisible] <=0 AND [dnt_posts1].layer <> 0) AS POST
  652.                     WHERE ROWID BETWEEN @startRow AND @endRow
  653.                     ~
  654.                     CREATE PROCEDURE [dnt_getdebatepostlist1] 
  655.                      @tid int,
  656.                      @opinion int,
  657.                      @pagesize int,
  658.                      @pageindex int
  659.                     AS
  660.                      DECLARE @startRow int,
  661.                                 @endRow int
  662.                      SET @startRow = (@pageindex - 1) * @pagesize + 1
  663.                      SET @endRow = @startRow + @pagesize - 1
  664.                     SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  665.                     [dnt_posts1].[attachment],
  666.                     [dnt_posts1].[bbcodeoff],
  667.                     [dnt_posts1].[fid],
  668.                     [dnt_posts1].[htmlon],
  669.                     [dnt_posts1].[invisible],
  670.                     [dnt_posts1].[ip],
  671.                     [dnt_posts1].[lastedit],
  672.                     [dnt_posts1].[layer],
  673.                     [dnt_posts1].[message],
  674.                     [dnt_posts1].[parentid],
  675.                     [dnt_posts1].[parseurloff],
  676.                     [dnt_posts1].[pid],
  677.                     [dnt_posts1].[postdatetime],
  678.                     [dnt_posts1].[poster],
  679.                     [dnt_posts1].[posterid],
  680.                     [dnt_posts1].[rate],
  681.                     [dnt_posts1].[ratetimes],
  682.                     [dnt_posts1].[smileyoff],
  683.                     [dnt_posts1].[tid],
  684.                     [dnt_posts1].[title],
  685.                     [dnt_posts1].[usesig],
  686.                     [dnt_users].[accessmasks], 
  687.                     [dnt_users].[adminid],
  688.                     [dnt_users].[avatarshowid],
  689.                     [dnt_users].[bday],
  690.                     [dnt_users].[credits],
  691.                     [dnt_users].[digestposts],
  692.                     [dnt_users].[email],
  693.                     [dnt_users].[extcredits1],
  694.                     [dnt_users].[extcredits2],
  695.                     [dnt_users].[extcredits3],
  696.                     [dnt_users].[extcredits4],
  697.                     [dnt_users].[extcredits5],
  698.                     [dnt_users].[extcredits6],
  699.                     [dnt_users].[extcredits7],
  700.                     [dnt_users].[extcredits8],
  701.                     [dnt_users].[extgroupids],
  702.                     [dnt_users].[gender],
  703.                     [dnt_users].[groupexpiry],
  704.                     [dnt_users].[groupid],
  705.                     [dnt_users].[joindate],
  706.                     [dnt_users].[lastactivity],
  707.                     [dnt_users].[lastip],
  708.                     [dnt_users].[lastpost],
  709.                     [dnt_users].[lastpostid],
  710.                     [dnt_users].[lastposttitle],
  711.                     [dnt_users].[lastvisit],
  712.                     [dnt_users].[newpm],
  713.                     [dnt_users].[newpmcount],
  714.                     [dnt_users].[newsletter],
  715.                     [dnt_users].[nickname],
  716.                     [dnt_users].[oltime],
  717.                     [dnt_users].[onlinestate],
  718.                     [dnt_users].[pageviews],
  719.                     [dnt_users].[password],
  720.                     [dnt_users].[pmsound],
  721.                     [dnt_users].[posts],
  722.                     [dnt_users].[ppp],
  723.                     [dnt_users].[regip],
  724.                     [dnt_users].[secques],
  725.                     [dnt_users].[showemail],
  726.                     [dnt_users].[sigstatus],
  727.                     [dnt_users].[spaceid],
  728.                     [dnt_users].[templateid],
  729.                     [dnt_users].[tpp],
  730.                     [dnt_users].[uid],
  731.                     [dnt_users].[username],
  732.                     [dnt_userfields].[authflag],
  733.                     [dnt_userfields].[authstr],
  734.                     [dnt_userfields].[authtime],
  735.                     [dnt_userfields].[avatar],
  736.                     [dnt_userfields].[avatarheight],
  737.                     [dnt_userfields].[avatarwidth],
  738.                     [dnt_userfields].[bio],
  739.                     [dnt_userfields].[customstatus],
  740.                     [dnt_userfields].[icq],
  741.                     [dnt_userfields].[idcard],
  742.                     [dnt_userfields].[ignorepm],
  743.                     [dnt_userfields].[location],
  744.                     [dnt_userfields].[medals],
  745.                     [dnt_userfields].[mobile],
  746.                     [dnt_userfields].[msn],
  747.                     [dnt_userfields].[phone],
  748.                     [dnt_userfields].[qq],
  749.                     [dnt_userfields].[realname],
  750.                     [dnt_userfields].[sightml],
  751.                     [dnt_userfields].[signature],
  752.                     [dnt_userfields].[skype],
  753.                     [dnt_userfields].[website],
  754.                     [dnt_userfields].[yahoo]
  755.                     FROM [dnt_posts1] 
  756.                     LEFT JOIN [dnt_users] ON [dnt_users].[uid] = [dnt_posts1].[posterid] 
  757.                     LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid] = [dnt_posts1].[posterid]
  758.                     WHERE [dnt_posts1].invisible=0 
  759.                     AND [dnt_posts1].pid IN (SELECT pid FROM dnt_postdebatefields WHERE opinion=@opinion AND tid=@tid)) AS DEBATEPOST
  760.                     WHERE ROWID BETWEEN @startRow AND @endRow
  761.                     ~
  762. IF OBJECT_ID('dnt_getpostcountbycondition1','P') IS NOT NULL
  763. DROP PROC [dnt_getpostcountbycondition1]
  764. ~
  765. CREATE PROCEDURE [dnt_getpostcountbycondition1]
  766. @tid int,
  767. @posterid int
  768. AS
  769. SELECT COUNT(pid) FROM [dnt_posts1] WHERE [tid] = @tid AND [posterid] = @posterid  AND [layer]>=0
  770. ~
  771. IF OBJECT_ID('dnt_getpostlistbycondition1','P') IS NOT NULL
  772. DROP PROC [dnt_getpostlistbycondition1]
  773. ~
  774. CREATE PROCEDURE [dnt_getpostlistbycondition1]
  775. @tid int,
  776. @pagesize int,
  777. @pageindex int,
  778. @posterid int
  779. AS
  780. DECLARE @startRow int,
  781. @endRow int
  782. SET @startRow = (@pageindex-1)*@pagesize
  783. SET @endRow = @startRow + @pagesize - 1
  784. SELECT 
  785. POSTS.[pid], 
  786. POSTS.[fid], 
  787. POSTS.[title], 
  788. POSTS.[layer],
  789. POSTS.[message], 
  790. POSTS.[ip], 
  791. POSTS.[lastedit], 
  792. POSTS.[postdatetime], 
  793. POSTS.[attachment], 
  794. POSTS.[poster], 
  795. POSTS.[posterid], 
  796. POSTS.[invisible], 
  797. POSTS.[usesig], 
  798. POSTS.[htmlon], 
  799. POSTS.[smileyoff], 
  800. POSTS.[parseurloff], 
  801. POSTS.[bbcodeoff], 
  802. POSTS.[rate], 
  803. POSTS.[ratetimes], 
  804. POSTS.[nickname],  
  805. POSTS.[username], 
  806. POSTS.[groupid], 
  807. POSTS.[spaceid],
  808. POSTS.[gender],
  809. POSTS.[bday],
  810. POSTS.[email], 
  811. POSTS.[showemail], 
  812. POSTS.[digestposts], 
  813. POSTS.[credits], 
  814. POSTS.[extcredits1], 
  815. POSTS.[extcredits2], 
  816. POSTS.[extcredits3], 
  817. POSTS.[extcredits4], 
  818. POSTS.[extcredits5], 
  819. POSTS.[extcredits6], 
  820. POSTS.[extcredits7], 
  821. POSTS.[extcredits8], 
  822. POSTS.[posts], 
  823. POSTS.[joindate], 
  824. POSTS.[onlinestate],
  825. POSTS.[lastactivity],  
  826. POSTS.[invisible] AS usersinvisible, 
  827. POSTS.[avatar], 
  828. POSTS.[avatarwidth],
  829. POSTS.[avatarheight],
  830. POSTS.[medals],
  831. POSTS.[signature], 
  832. POSTS.[location], 
  833. POSTS.[customstatus], 
  834. POSTS.[website], 
  835. POSTS.[icq], 
  836. POSTS.[qq], 
  837. POSTS.[msn], 
  838. POSTS.[yahoo],
  839. POSTS.[oltime],
  840. POSTS.[lastvisit],
  841. POSTS.[skype] 
  842. FROM(SELECT ROW_NUMBER() OVER(ORDER BY [pid]) AS ROWID,
  843. [dnt_posts1].[pid], 
  844. [dnt_posts1].[fid], 
  845. [dnt_posts1].[title], 
  846. [dnt_posts1].[layer],
  847. [dnt_posts1].[message], 
  848. [dnt_posts1].[ip], 
  849. [dnt_posts1].[lastedit], 
  850. [dnt_posts1].[postdatetime], 
  851. [dnt_posts1].[attachment], 
  852. [dnt_posts1].[poster], 
  853. [dnt_posts1].[posterid], 
  854. [dnt_posts1].[invisible], 
  855. [dnt_posts1].[usesig], 
  856. [dnt_posts1].[htmlon], 
  857. [dnt_posts1].[smileyoff], 
  858. [dnt_posts1].[parseurloff], 
  859. [dnt_posts1].[bbcodeoff], 
  860. [dnt_posts1].[rate], 
  861. [dnt_posts1].[ratetimes], 
  862. [dnt_users].[nickname],  
  863. [dnt_users].[username], 
  864. [dnt_users].[groupid], 
  865. [dnt_users].[spaceid],
  866. [dnt_users].[gender],
  867. [dnt_users].[bday],
  868. [dnt_users].[email], 
  869. [dnt_users].[showemail], 
  870. [dnt_users].[digestposts], 
  871. [dnt_users].[credits], 
  872. [dnt_users].[extcredits1], 
  873. [dnt_users].[extcredits2], 
  874. [dnt_users].[extcredits3], 
  875. [dnt_users].[extcredits4], 
  876. [dnt_users].[extcredits5], 
  877. [dnt_users].[extcredits6], 
  878. [dnt_users].[extcredits7], 
  879. [dnt_users].[extcredits8], 
  880. [dnt_users].[posts], 
  881. [dnt_users].[joindate], 
  882. [dnt_users].[onlinestate],
  883. [dnt_users].[lastactivity],
  884. [dnt_users].[oltime],
  885. [dnt_users].[lastvisit],
  886. [dnt_users].[invisible] AS usersinvisible, 
  887. [dnt_userfields].[avatar], 
  888. [dnt_userfields].[avatarwidth],
  889. [dnt_userfields].[avatarheight],
  890. [dnt_userfields].[medals],
  891. [dnt_userfields].[sightml] AS signature, 
  892. [dnt_userfields].[location], 
  893. [dnt_userfields].[customstatus], 
  894. [dnt_userfields].[website], 
  895. [dnt_userfields].[icq], 
  896. [dnt_userfields].[qq], 
  897. [dnt_userfields].[msn], 
  898. [dnt_userfields].[yahoo], 
  899. [dnt_userfields].[skype]
  900. FROM [dnt_posts1] 
  901. LEFT JOIN [dnt_users] ON [dnt_users].[uid]=[dnt_posts1].[posterid] 
  902. LEFT JOIN [dnt_userfields] ON [dnt_userfields].[uid]=[dnt_users].[uid]
  903. WHERE [dnt_posts1].[tid]=@tid AND [dnt_posts1].[invisible]=0 AND [posterid]=@posterid) AS POSTS
  904. WHERE ROWID BETWEEN @startROW AND @endROW