<% response.buffer = true %>
<html>
<head>
<title>:: WMA Links ::</title>
<style type=\"text/css\">
<!--
body {margin: 5;font-family:verdana}
a.menuitem {text-decoration:none;color:#000000}
a.menuitem:hover {text-decoration:none;color:#FF0000}
a {text-decoration:none;color:#800000}
a:hover {text-decoration:underline;color:#800000}
INPUT
{
BACKGROUND-COLOR: #FFFFFF;
COLOR: #000000;
FONT-FAMILY: verdana, helvetica, sans-serif;
FONT-SIZE: 12px;
FONT-STYLE: normal;
border: 1 solid #000000;
}
Textarea
{
BACKGROUND-COLOR: #FFFFFF;
COLOR: #000000;
FONT-FAMILY: verdana, helvetica, sans-serif;
FONT-SIZE: 12px;
FONT-STYLE: normal;
border: 1 solid #000000;
}
-->
</style>
</head>
<body>
<%
strMode = Request.Querystring(\"mode\")
select case strMode
case \"id\"
Response.Buffer = True
\' Her opdateres hits når brugeren bliver sendt til et link
Set myConn = Server.CreateObject(\"ADODB.Connection\")
myConn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & Server.MapPath(\"links.mdb\")
If Request.QueryString(\"id\") <> \"\" Then
Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT * FROM links WHERE (ID = \" & Request.QueryString(\"id\") & \")\"
rs.Open strSQL, myConn, 1, 3
If Not (rs.BOF Or rs.EOF) Then
rs(\"Hits\") = rs(\"Hits\") + 1
strURL = rs(\"URL\")
rs.Update
rs.Close
myConn.Close
Set rs = Nothing
Set myConn = Nothing
Response.Clear
Response.Redirect(strURL)
End If
End If
%>
<% case \"search\"
\' Siden med søgeresultater
\' Database connection
Set myConn = Server.CreateObject(\"ADODB.Connection\")
myConn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & Server.MapPath(\"links.mdb\")
\' Henter søgeorden fra formularen
strKeyword = Trim(Request.Form(\"søgeord\"))
If Len(strKeyword) = 0 Then
\' Hvis der ikke er skrevet i formularen sendes brugeren tilbage
Response.Clear
Response.Redirect (\"links.asp?mode=søg\")
Else
strKeyword = Replace(strKeyword,\"\'\",\"\'\'\")
End If
\' Opbygger en dynamisk SQL streng
strSQL = \"SELECT id, navn, url, beskrivelse, hits, søgeord FROM links WHERE\"
strSQL = strSQL & \" (id LIKE \'%\" & strKeyword & \"%\')\"
strSQL = strSQL & \" OR (navn LIKE \'%\" & strKeyword & \"%\')\"
strSQL = strSQL & \" OR (url LIKE \'%\" & strKeyword & \"%\')\"
strSQL = strSQL & \" OR (beskrivelse LIKE \'%\" & strKeyword & \"%\')\"
strSQL = strSQL & \" OR (hits LIKE \'%\" & strKeyword & \"%\')\"
strSQL = strSQL & \" OR (søgeord LIKE \'%\" & strKeyword & \"%\')\"
\' Skaber et recordset udfra SQL strengen
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
\' Hvis søgningen gav resultat
Response.Write \"<table width=\'602\' cellspacing=1 cellpadding=1 style=\'border-bottom: 1 solid #C0C0C0\'>\"
Response.Write \"<tr><td align=left width=\'100%\' colspan=2><font size=2>Søgeresultater for <b>\" & strKeyword & \"</b></font></td></tr>\"
Do While Not rs.EOF
Response.Write \"<tr><td valign=top width=\'100%\' colspan=2 bgcolor=#ffcc00><font size=2><b><a href=links.asp?mode=id&id=\" & rs(\"ID\") & \"target=\'_blank\'>\" & rs(\"Navn\") & \"</b></font></a></td></tr>\"
Response.Write \"<tr><td valign=top width=\'85%\' bgcolor=#ffffff><font size=2>\" & rs(\"Beskrivelse\") & \"</font></a></td>\"
Response.Write \"<td valign=top width=\'15%\' bgcolor=#FFFFFF><font size=2> Hits: \" & rs(\"Hits\") & \"</font></td></tr>\"
Response.Write \"<tr><td width=\'100%\' colspan=2 bgcolor=#FFFFFF> </td></tr>\"
rs.MoveNext
Loop
Response.Write \"<tr><td width=\'100%\' colspan=2 align=right style=\'border-top: 1 solid #C0C0C0\'><font size=\'2\'><a href=\'links.asp\'>Oversigt</a> | <a href=\'links.asp?mode=søg\'>Søg igen</a> | <a href=\'links.asp?mode=add\'>Tilføj links</a></font></td></tr>\"
Response.Write \"</table><br><br>\"
Else
\' Hvis ingen poster passede på søgordene
Response.Write \"<table width=\'602\' cellspacing=1 cellpadding=1 style=\'border-bottom: 1 solid #C0C0C0\'>\"
Response.Write \"<tr><td align=left width=\'100%\'><font size=2>Søgeresultater for <b>\" & strKeyword & \"</b></font></td></tr>\"
Response.Write \"<tr><td align=left width=\'100%\' bgcolor=#ffffff><font size=2>Ingen sider passede på søgeordet</font></a></td></tr>\"
Response.Write \"<tr><td width=\'100%\' colspan=2 align=right style=\'border-top: 1 solid #C0C0C0\'><font size=\'2\'><a href=\'links.asp\'>Oversigt</a> | <a href=\'links.asp?mode=søg\'>Søg igen</a> | <a href=\'links.asp?mode=add\'>Tilføj links</a></font></td></tr></table><br><br>\"
End If %>
<% case \"søg\"
\' Søgeformularen
Response.write \"<table width=\'602\' style=\'border-bottom: 1 solid #C0C0C0\'><tr><td><img border=\'0\' src=\'../picture/banner/soeg.gif\'></td></tr>\"
Response.write \"<tr><td><form method=POST action=links.asp?mode=search><input type=text name=søgeord size=30></td></tr>\"
Response.write \"<tr><td><input type=submit value=\' Søg \' name=send> <input type=button onclick=\'history.go(-1)\' value=Tilbage name=tilbage></td></tr>\"
Response.Write \"<tr><td width=\'100%\' align=right style=\'border-top: 1 solid #C0C0C0\'><font size=\'2\'><a href=\'links.asp\'>Oversigt</a> | <a href=\'links.asp?mode=add\'>Tilføj links</a></font></td></tr></table></form>\"
%>
<% case \"update\"
\' Sender resultaterne fra tilføj links til databasen
\' Database connection
Set Conn = Server.CreateObject(\"ADODB.Connection\")
Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.MapPath(\"links.mdb\")
\' Opbygger SQL streng
SQLstmt = \"INSERT INTO links (navn,url,beskrivelse,hits,søgeord,kategori,godkendt)\"
SQLstmt = SQLstmt & \" VALUES (\'\" & request.form(\"navn\") & \"\',\'\" & request.form(\"url\") & \"\',\'\" & request.form(\"beskrivelse\") & \"\',\'\" & request.form(\"hits\") & \"\',\'\" & request.form(\"søgeord\") & \"\',\'\" & request.form(\"kategori\") & \"\',\'nej\')\"
response.write sqlstmt
Conn.Execute (SQLstmt)
conn.Close
Set conn = nothing
Set SQLstmt = nothing
\' Sender brugeren tilbage til links når databasen er opdateret
response.redirect (\"links.asp?mode=søg\")
%>
<% case \"add\"
\' tilføj links
%>
<form method=\"POST\" action=\"links.asp?mode=update\">
<table border=\"0\" width=\"602\" cellpadding=\"0\" style=\'border-bottom: 1 solid #C0C0C0\'>
<tr><td colspan=\"2\"><img border=\"0\" src=\"../picture/banner/tilfojlink.gif\"></td></tr>
<tr><td colspan=\"2\"> </td></tr>
<tr>
<td width=\"35%\"><font face=\"Verdana\" size=\"2\" color=\"#800000\"><b>Navn:</b></font></td>
<td width=\"65%\">
<p><font color=\"#800000\"><input type=\"text\" name=\"navn\" size=\"32\"></font></p>
</td>
</tr>
<tr>
<td width=\"35%\"><font face=\"Verdana\" size=\"2\" color=\"#800000\"><b>URL:</b></font></td>
<td width=\"65%\"><font color=\"#800000\"><input type=\"text\" name=\"url\" value=\"
http://\" size=\"32\"></font></td>
</tr>
<tr>
<td width=\"35%\" valign=\"top\"><font face=\"Verdana\" size=\"2\" color=\"#800000\"><b>Beskrivelse:</b></font></td>
<td width=\"65%\"><font color=\"#800000\"><textarea name=\"beskrivelse\" cols=\"32\" rows=\"1\"></textarea></font></td>
</tr>
<tr>
<td width=\"35%\" valign=\"top\"><font face=\"Verdana\" size=\"2\" color=\"#800000\"><b>Kategori:</b></font></td>
<td width=\"65%\"><font color=\"#800000\"><select name=\"kategori\">
<%
Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT * FROM kategorier ORDER BY kategori\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"links.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
Do until rs.EOF = True
Response.Write \"<option value=\'\" & rs(\"kategori\") & \"\'>\" & rs(\"kategori\") & vbCrLf
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
%></select></font></td>
</tr>
<tr>
<td width=\"35%\" valign=\"top\"><font color=\"#800000\" face=\"Verdana\" size=\"2\"><b>Søgeord:<br></b>Adskilles med komma!</font></td>
<td width=\"65%\"><font color=\"#800000\"><input type=\"text\" name=\"søgeord\" size=\"32\"></font></td>
</tr>
<tr>
<td width=\"35%\" valign=\"top\"><font color=\"#800000\"> </font></td>
<td width=\"65%\"></td>
</tr>
<tr>
<td width=\"100%\" colspan=\"2\"><font color=\"#800000\"><input type=\"hidden\" value=\"0\" name=\"hits\"><input type=\"submit\" value=\"Send\" name=\"send\">
<input type=\"reset\" value=\"Annuller\" name=\"anuller\"> <input type=\"button\" onclick=\"history.go(-1)\" value=\"Tilbage\" name=\"Tilbage\"></font></td>
</tr>
<tr><td width=\'100%\' colspan=2 align=right style=\'border-top: 1 solid #C0C0C0\'><font size=\'2\'><a href=\'links.asp\'>Oversigt</a> | <a href=\'links.asp?mode=søg\'>Søg i links</a></font></td></tr></table>
</form>
<% case \"vis\"
\' Hvis der ikke er valgt noget mode vises alle links
\' Paging
intPage = Request(\"page\")
If isNumeric(intPage) = False Or intPage < 1 Then
intPage = 1
End If
\' Database connection
Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT * FROM links WHERE kategori=\'\" & request(\"kat\") & \"\' AND godkendt=\'ja\' ORDER BY navn\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"links.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
rs.PageSize = 10
rs.AbsolutePage = intPage
intRecCount = rs.PageSize
intPageCount = rs.PageCount
Response.Write \"<table width=\'602\' cellspacing=\'2\' cellpadding=\'0\'>\"
Do While Not rs.EOF And intRecCount > 0
Response.Write \"<tr><td valign=top width=\'100%\' colspan=2 bgcolor=#FFFFFF><font size=2><b><a href=links.asp?mode=id&id=\" & rs(\"ID\") & \"target=\'_blank\'>\" & rs(\"Navn\") & \"</a></b></font></td></tr>\"
Response.Write \"<tr><td valign=top width=\'85%\' bgcolor=#FFFFFF><font size=2>\" & rs(\"Beskrivelse\") & \"</font></a></td>\"
Response.Write \"<td valign=top width=\'15%\' bgcolor=#FFFFFF><font size=2> Hits: \" & rs(\"Hits\") & \"</font></td></tr>\"
Response.Write \"<tr><td width=\'100%\' colspan=2 bgcolor=#FFFFFF> </td></tr>\"
intRecCount = intRecCount - 1
rs.MoveNext
Loop
End If
Response.Write \"</table>\"
rs.Close
Set rs = Nothing
\' Navigering mellem siderne med paging
Response.Write \"<table width=\'602\' style=\'border-top: 1 solid #C0C0C0;border-bottom: 1 solid #C0C0C0\'><tr>\"
If Clng(intPage) > 1 Then
Response.Write \"<td><font size=\'2\'><a href=links.asp?mode=vis&kat=\" & request(\"kat\") & \"&page=\" & intPage - 1 & \" class=paging>[<<]</a></td>\"
Else
Response.Write \"<td></td>\"
End If
Response.Write \"\"
For intNum = 1 To intPageCount
Response.Write \"<td valign=\'top\'><font size=\'2\'><a href=links.asp?mode=vis&kat=\" & request(\"kat\") & \"&page=\" & intNum & \">\" & intNum & \"</a></font></td> \"
Next
If Clng(intPage) < Clng(intPageCount) Then
Response.Write \"<td><font size=\'2\'><a href=links.asp?mode=vis&kat=\" & request(\"kat\") & \"&page=\" & intPage + 1 & \" class=paging>[>>]</a></td>\"
Else
Response.Write \"<td></td>\"
End If
Response.write \"<td><font size=\'2\'>Side <b>\" & intPage & \"</b> af \" & intPageCount & \"</font></td><td><p align=\'right\'><font size=\'2\'><a href=\'links.asp\'>Oversigt</a> | <a href=\'links.asp?mode=søg\'>Søg i links</a> | <a href=\'links.asp?mode=add\'>Tilføj links</a></font></p></td></tr></table>\"
case else
\' Database connection
Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT * FROM kategorier ORDER BY kategori\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"links.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
Response.Write \"<table width=\'602\' cellspacing=\'2\' cellpadding=\'0\'>\"
Do until rs.EOF = True
Response.Write \"<tr><td width=\'100%\' colspan=2 bgcolor=#ffffff><a href=\'links.asp?mode=vis&kat=\" & rs(\"kategori\") & \"\'>\" & rs(\"kategori\") & \"</a></td></tr>\"
rs.MoveNext
Loop
End If
Response.Write \"</table>\"
rs.Close
Set rs = Nothing
end select %>
</body>
</html>