CREATE PROCEDURE dnt_createadmingroup
@admingid smallint,
@alloweditpost int,
@alloweditpoll int,
@allowstickthread int,
@allowmodpost int,
@allowdelpost int,
@allowmassprune int,
@allowrefund int,
@allowcensorword int,
@allowviewip int,
@allowbanip int,
@allowedituser int,
@allowmoduser int,
@allowbanuser int,
@allowpostannounce int,
@allowviewlog int,
@disablepostctrl int
AS
INSERT INTO dnt_admingroups
([admingid],[alloweditpost],[alloweditpoll],[allowstickthread],[allowmodpost],[allowdelpost],[allowmassprune],[allowrefund],[allowcensorword],[allowviewip],[allowbanip],[allowedituser],[allowmoduser],[allowbanuser],[allowpostannounce],[allowviewlog],[disablepostctrl])
VALUES
(@admingid,@alloweditpost,@alloweditpoll,@allowstickthread,@allowmodpost,@allowdelpost,@allowmassprune,@allowrefund,@allowcensorword,@allowviewip,@allowbanip,@allowedituser,@allowmoduser,@allowbanuser,@allowpostannounce,@allowviewlog,@disablepostctrl)
~
CREATE PROCEDURE dnt_createattachment
@uid int,
@tid int,
@pid int,
@postdatetime datetime,
@readperm int,
@filename nchar(200),
@description nchar(200),
@filetype nchar(100),
@filesize int,
@attachment nchar(200),
@downloads int
AS
DECLARE @aid int
INSERT INTO [dnt_attachments]([uid],[tid], [pid], [postdatetime], [readperm], [filename], [description], [filetype], [filesize], [attachment], [downloads]) VALUES(@uid, @tid, @pid, @postdatetime, @readperm, @filename, @description, @filetype, @filesize, @attachment, @downloads)
SELECT SCOPE_IDENTITY() AS 'aid'
UPDATE [dnt_posts1] SET [attachment]=1 WHERE [pid]=@pid
~
CREATE PROCEDURE dnt_createfavorite
@uid int,
@tid int
AS
INSERT INTO [dnt_favorites] ([uid],[tid]) VALUES(@uid,@tid)
RETURN
~
CREATE PROCEDURE dnt_createpm
@pmid int,
@msgfrom nvarchar(20),
@msgto nvarchar(20),
@msgfromid int,
@msgtoid int,
@folder smallint=0,
@new int=0,
@subject nvarchar(80),
@postdatetime datetime,
@message ntext,
@savetosentbox smallint=1
AS
IF @folder<>0
BEGIN
SET @msgfrom=@msgto
END
ELSE
BEGIN
UPDATE [dnt_users] SET [newpmcount]=ABS(ISNULL([newpmcount],0)*1)+1,[newpm] = 1 WHERE [uid]=@msgtoid
END
INSERT INTO [dnt_pms]
([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
VALUES
(@msgfrom,@msgfromid,@msgto,@msgtoid,@folder,@new,@subject,@postdatetime,@message)
SELECT SCOPE_IDENTITY() AS 'pmid'
IF @savetosentbox=1 AND @folder=0
BEGIN
INSERT INTO [dnt_pms]
([msgfrom],[msgfromid],[msgto],[msgtoid],[folder],[new],[subject],[postdatetime],[message])
VALUES
(@msgfrom,@msgfromid,@msgto,@msgtoid,1,@new,@subject,@postdatetime,@message)
END
~
CREATE PROCEDURE dnt_createpoll
@tid int,
@polltype tinyint,
@itemcount smallint,
@itemnamelist ntext,
@itemvaluelist text,
@usernamelist ntext,
@enddatetime smalldatetime,
@userid int
AS
INSERT INTO [dnt_polls]([tid], [polltype], [itemcount], [itemnamelist], [itemvaluelist], [usernamelist], [enddatetime], [userid]) VALUES(@tid, @polltype, @itemcount, @itemnamelist, @itemvaluelist, @usernamelist, @enddatetime, @userid)
UPDATE [dnt_topics] SET [poll]=1 WHERE [tid]=@tid
~
CREATE PROCEDURE dnt_createpost1
@fid int,
@tid int,
@parentid int,
@layer int,
@poster varchar(20),
@posterid int,
@title nvarchar(80),
@postdatetime char(20),
@message ntext,
@ip varchar(15),
@lastedit varchar(50),
@invisible int,
@usesig int,
@htmlon int,
@smileyoff int,
@bbcodeoff int,
@parseurloff int,
@attachment int,
@rate int,
@ratetimes int
AS
DEClARE @postid int
DELETE FROM [dnt_postid] WHERE DATEDIFF(n, postdatetime, GETDATE()) >5
INSERT INTO [dnt_postid] ([postdatetime]) VALUES(GETDATE())
SELECT @postid=SCOPE_IDENTITY()
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)
IF @parentid=0
BEGIN
UPDATE [dnt_posts1] SET [parentid]=@postid WHERE [pid]=@postid
END
IF @@ERROR=0 AND @invisible = 0
BEGIN
UPDATE [dnt_statistics] SET [totalpost]=[totalpost] + 1
DECLARE @fidlist AS VARCHAR(1000)
DECLARE @strsql AS VARCHAR(4000)
SET @fidlist = '';
SELECT @fidlist = ISNULL([parentidlist],'') FROM [dnt_forums] WHERE [fid] = @fid
IF RTRIM(@fidlist)<>''
BEGIN
SET @fidlist = RTRIM(@fidlist) + ',' + CAST(@fid AS VARCHAR(10))
END
ELSE
BEGIN
SET @fidlist = CAST(@fid AS VARCHAR(10))
END
----DATEPART(yyyy, lastpost)=DATEPART(yyyy,GETDATE()) AND DATEPART(mm, lastpost)=DATEPART(mm,GETDATE()) AND DATEPART(dd, lastpost)=DATEPART(dd,GETDATE())
--SET @strsql ='UPDATE [dnt_forums] SET [posts]=[posts] + 1, [todayposts]=CASE WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts]*1 + 1 ELSE 1 END,[lasttid]=' + CAST(@tid AS VARCHAR(10)) + ', [lasttitle]=''' + @title + ''',[lastpost]=''' + @postdatetime + ''',[lastposter]=''' + @poster + ''',[lastposterid]=' + CAST(@posterid AS VARCHAR(10)) + ' WHERE [fid] IN (' + @fidlist + ')'
UPDATE [dnt_forums] SET
[posts]=[posts] + 1,
[todayposts]=CASE
WHEN DATEDIFF(day, [lastpost], GETDATE())=0 THEN [todayposts]*1 + 1
ELSE 1
END,
[lasttid]=@tid,
[lasttitle]=@title,
[lastpost]=@postdatetime,
[lastposter]=@poster,
[lastposterid]=@posterid
WHERE (CHARINDEX(',' + RTRIM([fid]) + ',', ',' +
(SELECT @fidlist AS [fid]) + ',') > 0)
--EXEC(@strsql)
UPDATE [dnt_users] SET
[lastpost] = @postdatetime,
[lastpostid] = @postid,
[lastposttitle] = @title,
[posts] = [posts] + 1
WHERE [uid] = @posterid
IF @layer<=0
BEGIN
UPDATE [dnt_topics] SET [replies]=0,[lastposter]=@poster,[lastpost]=@postdatetime,[lastpostid]=@postid,[lastposterid]=@posterid WHERE [tid]=@tid
END
ELSE
BEGIN
UPDATE [dnt_topics] SET [replies]=[replies] + 1,[lastposter]=@poster,[lastpost]=@postdatetime,[lastpostid]=@postid,[lastposterid]=@posterid WHERE [tid]=@tid
END
END
SELECT @postid AS postid
~
CREATE PROCEDURE [dnt_createsearchcache]
@keywords varchar(255),
@searchstring varchar(255),
@ip varchar(15),
@uid int,
@groupid int,
@postdatetime varchar(19),
@expiration varchar(19),
@topics int,
@tids text
AS
INSERT INTO dnt_searchcaches
([keywords],[searchstring],[ip],[uid],[groupid],[postdatetime],[expiration],[topics],[tids])
VALUES
(@keywords,@searchstring,@ip,@uid,@groupid,@postdatetime,@expiration,@topics,@tids)
SELECT SCOPE_IDENTITY() AS 'searchid'
~
CREATE PROCEDURE dnt_createtopic
@fid smallint,
@iconid smallint,
@title nchar(80),
@typeid smallint,
@readperm int,
@price smallint,
@poster char(20),
@posterid int,
@postdatetime smalldatetime,
@lastpost smalldatetime,
@lastposter char(20),
@views int,
@replies int,
@displayorder int,
@highlight varchar(500),
@digest int,
@rate int,
@hide int,
@poll int,
@attachment int,
@moderated int,
@closed int,
@magic int
AS
DECLARE @topicid int
DELETE FROM [dnt_topics] WHERE [lastpostid]=0
INSERT INTO [dnt_topics]([fid], [iconid], [title], [typeid], [readperm], [price], [poster], [posterid], [postdatetime], [lastpost], [lastposter], [views], [replies], [displayorder], [highlight], [digest], [rate], [hide], [poll], [attachment], [moderated], [closed], [magic]) VALUES(@fid, @iconid, @title, @typeid, @readperm, @price, @poster, @posterid, @postdatetime