Avatar billede hallum Nybegynder
17. juni 2003 - 11:31 Der er 1 kommentar og
1 løsning

AspForum med administration

Jeg har hentet aspforum på http://activedeveloper.dk/download/default.asp?mode=download&id=36
Men mangler en side til administration:
- Oprette kategori, og tilhørende beskrivelse
- Slette kategori
- Slette indlæg

Databasen har følgende felter:

tabel: Forums med felterne: Forum og Description
tabel: Entries hvor alle indlæg er med relation til Forum id'er

Jeg har følgende sider, er absolut newbee:
Hurtigt og præcist svar med komplet forslag til en
admin.asp giver points.

forumthreads.asp
<!--#include file="functions.inc"-->
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN

strSQL = "SELECT * FROM Forums WHERE (ID = " & Request("ForumID") & ")"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    strForum = rs("Forum")
    strDescription = rs("Description")
    intForumID = rs("ID")
End If

strSQL = "SELECT *, Format$([date],'dd/mm/yyyy') AS FormDate, Format$([date],'hh:mm') AS FormTime FROM Entries WHERE (ForumID = " & Request("ForumID") & ")"
strSQL = strSQL & " AND (OrgThread = True) ORDER BY ID DESC"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    Do While Not rs.EOF
        strSQL = "SELECT Count(*) AS ItemCount FROM Entries WHERE (ReplyID = " & rs("Id") & ") AND (OrgThread <> TRUE)"
        Set recordCount = myConn.Execute(strSQL)
        strHTML = strHTML & "<tr><td bgcolor=#BBBB88><font face=Verdana size=2><a href=""viewmsg.asp?id=" & rs("ID") & "&ForumID=" & intForumID & """>" & Server.HTMLEncode(rs("Subject")) & "</font></a></td>"
        strHTML = strHTML & "<td bgcolor=#BBBB88 valign=top><font face=Verdana size=2>" & recordCount("ItemCount") & "</font></td>"
        strHTML = strHTML & "<td bgcolor=#BBBB88 valign=top><font face=Verdana size=2>" & rs("FormDate") & "</font></td></tr>"
        rs.MoveNext
    Loop
End If
myConn.Close
Set myConn = Nothing
%>
<html>

<head>
<title>ASPForum [ Threads ]</title>
</head>

<body bgcolor="#999966" text="#000000" link="#000000" vlink="#000000" alink="#FFFFFF"
topmargin="2" leftmargin="0" marginwidth="0" marginheight="2">
<div align="center"><center>

<table border="0" width="600" cellspacing="1" cellpadding="0" bgcolor="#CCCC99">
  <tr>
    <td width="596" colspan="2" bgcolor="#000000"><font face="Verdana" color="#CCCC99"
    size="2"><strong>Forum:</strong> <strong><%=strForum%></strong></font></td>
  </tr>
  <tr>
    <td valign="top" align="left" width="70%"><font face="Verdana" size="2"><%=strDescription%></font></td>
    <td valign="top" align="left" nowrap width="30%"><ul type="square">
      <li><a href="default.asp"><font face="Verdana"><b><small>Til oversigt</small></b></font></a></li>
      <li><font face="Verdana"><strong><a href="forumpost.asp?ForumId=<%=intForumID%>"><small>Opret
        indlæg</small></a><br>
        &nbsp;&nbsp; </strong></font></li>
    </ul>
    </td>
  </tr>
  <tr>
    <td width="598" colspan="2"><table border="0" width="100%" cellspacing="1" cellpadding="0">
      <tr>
        <td width="234" bgcolor="#000000"><font face="Verdana" color="#CCCC99" size="2"><strong>Threads</strong></font></td>
        <td width="37" bgcolor="#000000"><font face="Verdana" color="#CCCC99" size="2"><strong>Svar</strong></font></td>
        <td width="117" bgcolor="#000000"><font face="Verdana" color="#CCCC99" size="2"><strong>Seneste
        indlæg</strong></font></td>
      </tr>
<%=strHTML%>
    </table>
    </td>
  </tr>
</table>
</center></div>
</body>
</html>
----------
Viewmessage.asp
<!--#include file="functions.inc"-->
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN

strSQL = "SELECT * FROM Forums WHERE (ID = " & Request("ForumId") & ")"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    intForumID = rs("ID")
    strForum = rs("Forum")
    strDescription = rs("Description")
End If

strSQL = "SELECT *, Format$([date],'dd/mm/yyyy') AS FormDate, Format$([date],'hh:mm') AS FormTime FROM Entries WHERE (ID = " & Request("Id") & ") AND (OrgThread = True)"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    intMessageID = rs("ID")
    strSubject = Server.HTMLEncode(rs("Subject"))
    strName = Server.HTMLEncode(rs("Name"))
    strEmail = Server.HTMLEncode(rs("Email"))
    dtmFormDate = rs("FormDate")
    dtmFormTime = rs("FormTime")
    strComment = Replace(Server.HTMLEncode(rs("Comment")),vbCrLf,"<br>")
End If

strSQL = "SELECT *, Format$([date],'dd/mm/yyyy') AS FormDate, Format$([date],'hh:mm') AS FormTime FROM Entries WHERE (ReplyId = " & Request("Id") & ") AND (OrgThread = False) ORDER BY ID DESC"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    Do While Not rs.EOF
        strSvar = strSvar & "<li><font face=Verdana size=1><strong><a href=""viewmsg.asp?Id=" & intMessageID & "&ForumID=" & intForumID & "&Showsub=" & rs("ID") & """>Re: " & strSubject & "</a> <em>(" & Server.HTMLEncode(rs("Name")) & ", " & rs("FormDate") & " " & rs("FormTime") & ")</em></strong></font></li>"
        If Len(Request("Showsub")) > 0 And Clng(Request.QueryString("Showsub")) = Clng(rs("ID")) Then
            strSvar = strSvar & "<br><font face=Verdana size=1>" & Replace(Server.HTMLEncode(rs("Comment")),vbCrLf,"<br>") & "</font><br>&nbsp;"
        End If
        rs.MoveNext
    Loop
End If
rs.Close
myConn.Close
Set myConn = Nothing
%>
<html>

<head>
<title>ASPForum [ Læs besked ]</title>
</head>

<body bgcolor="#999966" text="#000000" link="#000000" vlink="#000000" alink="#FFFFFF"
topmargin="2" leftmargin="0" marginwidth="0" marginheight="2">
<div align="center"><center>

<table border="0" width="600" cellspacing="1" cellpadding="0" bgcolor="#CCCC99">
  <tr>
    <td width="598" bgcolor="#000000" colspan="2"><strong><font face="Verdana" size="2"
    color="#CCCC99">Forum: <%=strForum%> </font></strong></td>
  </tr>
  <tr>
    <td valign="top" width="70%"><font face="verdana" size="2"><%=strDescription%> </font></td>
    <td width="30%"><ul type="square">
      <li><a href="default.asp"><font face="Verdana"><small><strong>Til oversigt</strong></small></font></a></li>
      <li><a href="forumthreads.asp?ForumId=<%=intForumID%>"><font face="Verdana"><small><strong>Til
        threads</strong></small></font></a></li>
      <li><strong><a href="forumpost.asp?ForumId=<%=intForumID%>&amp;MessageId=<%=intMessageID%>"><font
        face="Verdana"><small>Besvar</small></font></a><font face="Verdana"><br>
        <small>&nbsp; </small></font></strong></li>
    </ul>
    </td>
  </tr>
  <tr>
    <td width="598" colspan="2"><table border="0" width="100%" cellspacing="1" cellpadding="0">
      <tr>
        <td width="57" bgcolor="#000000" align="left"><font face="Verdana" size="2"
        color="#CCCC99"><strong>Emne:</strong></font></td>
        <td width="339" bgcolor="#000000"><font face="Verdana" size="2" color="#CCCC99"><strong><%=strSubject%></strong></font></td>
      </tr>
      <tr>
        <td width="57" bgcolor="#000000" align="left"><font face="Verdana" size="2"
        color="#CCCC99"><strong>Navn:</strong></font></td>
        <td width="339" bgcolor="#000000"><font face="Verdana" size="2" color="#CCCC99"><%=strName%></font></td>
      </tr>
      <tr>
        <td width="57" bgcolor="#000000" align="left"><font face="Verdana" size="2"
        color="#CCCC99"><strong>E-mail:</strong></font></td>
        <td width="339" bgcolor="#000000"><font face="Verdana" size="2" color="#CCCC99"><%=strEmail%></font></td>
      </tr>
      <tr>
        <td width="57" bgcolor="#000000" align="left"><font face="Verdana" size="2"
        color="#CCCC99"><strong>Dato:</strong></font></td>
        <td width="339" bgcolor="#000000"><font face="Verdana" size="2" color="#CCCC99"><%=dtmFormDate%>&nbsp; <%=dtmFormTime%></font></td>
      </tr>
      <tr>
        <td width="396" bgcolor="#BBBB88" align="left" colspan="2"><small><font face="Verdana"><%=strComment%></font></small></td>
      </tr>
      <tr>
        <td bgcolor="#CCCC99" align="left" colspan="2"><hr noshade size="1" color="#000000">
        </td>
      </tr>
      <tr>
        <td bgcolor="#000000" align="left" colspan="2"><font face="Verdana" color="#CCCC99"><strong><small>Svar:</small></strong></font></td>
      </tr>
      <tr>
        <td bgcolor="#BBBB88" align="left" colspan="2"><small><font face="Verdana"><ul
        type="square">
<%=strSvar%>
        </ul>
        </font></small></td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</center></div>
</body>
</html>
-----
forumpost.asp
<!--#include file="functions.inc"-->
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN
Posted = 0

If Len(Trim(Request.Form("Subject"))) = 0 AND Len(Trim(Request.Form("Comment"))) = 0 Then
    strSQL = "SELECT * FROM Forums WHERE (ID = " & Request("ForumID") & ")"
    Set rs = myConn.Execute(strSQL)
    If Not (rs.BOF Or rs.EOF) Then
        intForumID = rs("ID")
        strForum = rs("Forum")
    End If
Else
    strSQL = "INSERT INTO Entries"
    If Len(Trim(Request.Form("MessageId"))) = 0 Then
        strSQL = strSQL & " (Name, Email, Subject, Comment, ForumId, Orgthread)"
        strSQL = strSQL & " VALUES('" & DBFix(Trim(Request.Form("Name"))) & "', '" & DBFix(Trim(Request.Form("Email"))) & "', '" & DBFix(Trim(Request.Form("Subject"))) & "', '" & DBFix(Trim(Request.Form("Comment"))) & "', '" & DBFix(Trim(Request("ForumId"))) & "', TRUE);"
    Else
        tempSQL = "SELECT Subject FROM Entries WHERE (Id = " & Request("MessageId") & ")"
        Set tempRS = myConn.Execute(tempSQL)
        strSQL = strSQL & " (Name, Email, Comment, ForumId, ReplyId, Subject)"
        strSQL = strSQL & " VALUES('" & DBFix(Trim(Request.Form("Name"))) & "', '" & DBFix(Trim(Request.Form("Email"))) & "', '" & DBFix(Trim(Request.Form("Comment"))) & "', '" & DBFix(Trim(Request("ForumId"))) & "','" & DBFix(Trim(Request("MessageId"))) & "','" & DBFix(Trim(tempRS("Subject"))) & "' );"
        tempRS.Close
    End If
    myConn.Execute(strSQL)
    Posted = 1
End If
myConn.Close
%>
<html>

<head>
<title>ASPForum [ Post en besked ]</title>
</head>

<body bgcolor="#999966" text="#000000" link="#000000" vlink="#000000" alink="#FFFFFF"
topmargin="2" leftmargin="0" marginwidth="0" marginheight="2">
<div align="center"><center>

<table border="0" width="600" cellspacing="1" cellpadding="0" bgcolor="#CCCC99">
  <tr>
    <td width="100%" bgcolor="#000000"><strong><font face="Verdana" color="#CCCC99"><small>Forum:
<% If Posted = 0 Then Response.Write strForum%>    </small></font></strong></td>
  </tr>
  <tr>
    <td width="100%"><% If Posted = 0 Then %>
<p align="left"><font face="Verdana"><b><small><a href="default.asp">Til
    oversigt</a></small></b></font> <%End If%> </td>
  </tr>
  <tr>
    <td width="100%"><%
If Len(Trim(Request.Form("Subject"))) = 0 AND Len(Trim(Request.Form("Comment"))) = 0 Then
%>
<form method="POST" action="forumpost.asp">
      <input type="hidden" name="ForumID" value="<%=intForumID%>"><input type="hidden"
      name="MessageID" value="<%=Trim(Request("MessageID"))%>"><table border="0" width="100%"
      cellspacing="1" cellpadding="0">
        <tr>
          <td align="left" bgcolor="#BBBB88"><small><font face="Verdana">Navn:</font></small></td>
          <td align="left" bgcolor="#BBBB88"><font face="Verdana"><small><input type="text"
          name="name" size="20"></small></font></td>
        </tr>
        <tr>
          <td align="left" bgcolor="#BBBB88"><small><font face="Verdana">E-mail:</font></small></td>
          <td align="left" bgcolor="#BBBB88"><small><font face="Verdana"><input type="text"
          name="email" size="20"></font></small></td>
        </tr>
        <tr>
          <td align="left" bgcolor="#BBBB88"><small><font face="Verdana">Emne:</font></small></td>
          <td align="left" bgcolor="#BBBB88"><small><font face="Verdana"><input type="text"
          name="Subject" size="30"></font></small></td>
        </tr>
        <tr>
          <td valign="top" align="left" bgcolor="#BBBB88"><font face="Verdana"><small>Besked:</small></font></td>
          <td align="left" bgcolor="#BBBB88"><textarea rows="8" name="Comment" cols="50"></textarea></td>
        </tr>
      </table>
      <p><input type="submit" value="Send" name="Action"></p>
    </form>
<% Else %>
    <p align="center"><font face="Verdana"><small>&nbsp;</p>
    </small></font><p align="center"><font face="Verdana"><small>Dit indlæg er nu optaget i
    forumet</small></font></p>
    <p align="center"><font face="Verdana"><a href="default.asp"><small>Til oversigt</small></a></p>
    </font><p><%  End If %> </td>
  </tr>
</table>
</center></div>
</body>
</html>
Avatar billede hallum Nybegynder
17. juni 2003 - 12:09 #1
Her er siden man kommer til med oversigt osv.
default.asp
<!--#include file="functions.inc"-->
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open strDSN

strSQL = "SELECT * FROM Forums"
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
    Do While Not rs.EOF
        strSQL = "SELECT *, Format$([date],'dd/mm/yyyy') AS FormDate, Format$([date],'hh:mm') AS FormTime FROM Entries WHERE (ForumID =" & rs("Id") & ") ORDER BY ID DESC"
        Set formatDate = myConn.Execute(strSQL)
        If (formatDate.BOF Or formatDate.EOF) Then
            dtmFormatDate = "Ingen indlæg"
        Else
            dtmFormatDate = formatDate("FormDate")
        End If
        strSQL = "SELECT Count(*) AS ItemCount FROM Entries Where (ForumID = " & rs("Id") & ")"
        Set recordCount = myConn.Execute(strSQL)
        strHTML = strHTML & "<tr><td bgcolor=#BBBB88><strong><font face=Verdana size=2><a href=""forumthreads.asp?forumid=" & rs("ID") & """>" & rs("Forum") & "</a></strong><br>" & rs("Description") & "</font></td>"
        strHTML = strHTML & "<td bgcolor=#BBBB88 valign=top><font face=Verdana size=2>" & recordCount("ItemCount") & "</font></td>"
        strHTML = strHTML & "<td bgcolor=#BBBB88 valign=top><font face=Verdana size=2>" & dtmFormatDate & "</font></td></tr>"
        rs.MoveNext
    Loop
End If
myConn.Close
Set myConn = Nothing
%>
<html>

<head>
<title>ASPForum [ Oversigt ]</title>
</head>

<body bgcolor="#999966" text="#000000" link="#000000" vlink="#000000" alink="#FFFFFF"
topmargin="2" leftmargin="0" marginwidth="0" marginheight="2">
<div align="center"><center>

<table border="0" width="600" cellspacing="1" cellpadding="0" bgcolor="#CCCC99">
  <tr>
    <td valign="top" width="608"><table border="0" width="101%" cellspacing="1"
    cellpadding="0">
      <tr>
        <td width="55%" bgcolor="#000000"><strong><font face="Verdana" size="2" color="#CCCC99">Forums</font></strong></td>
        <td width="16%" bgcolor="#000000"><strong><font face="Verdana" size="2" color="#CCCC99">Antal
        indlæg</font></strong></td>
        <td width="26%" bgcolor="#000000"><strong><font face="Verdana" size="2" color="#CCCC99">Seneste
        indlæg</font></strong></td>
      </tr>
<%=strHTML%>
    </table>
    </td>
  </tr>
</table>
</center></div>
</body>
</html>
Avatar billede hallum Nybegynder
01. september 2003 - 10:26 #2
Spørgsmål lukkes, da ingen svar ;-(
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester