Det her er den komplette side
--------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/connDongklubben.asp" -->
<!--#include file="../ScriptLibrary/incPUAddOn.asp" -->
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="../login/fejl_login.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<!--#include file="../ScriptLibrary/incPureUpload.asp" -->
<%
'*** Pure ASP File Upload -----------------------------------------------------
' Copyright (c) 2001-2002 George Petrov,
www.UDzone.com' Process the upload
' Version: 2.0.8
'------------------------------------------------------------------------------
'*** File Upload to: """oploadbilleder""", Extensions: "GIF,JPG,JPEG", Form: nyheder1, Redirect: "", "path", "300", "over", "false", "", "" , "200", "", "", "", "600", "", "", ""
Dim GP_redirectPage, RequestBin, UploadQueryString, GP_uploadAction, UploadRequest
PureUploadSetup
If (CStr(Request.QueryString("GP_upload")) <> "") Then
on error resume next
Dim reqPureUploadVersion, foundPureUploadVersion
reqPureUploadVersion = 2.08
foundPureUploadVersion = getPureUploadVersion()
if err or reqPureUploadVersion > foundPureUploadVersion then
Response.Write "<b>You don't have latest version of ScriptLibrary/incPureUpload.asp uploaded on the server.</b><br>"
Response.Write "This library is required for the current page. It is fully backwards compatible so old pages will work as well.<br>"
Response.End
end if
on error goto 0
GP_redirectPage = ""
Server.ScriptTimeout = 600
RequestBin = Request.BinaryRead(Request.TotalBytes)
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin, """oploadbilleder""", "path", "300", "over"
If (GP_redirectPage <> "" and not (CStr(UploadFormRequest("MM_insert")) <> "" or CStr(UploadFormRequest("MM_update")) <> "")) Then
If (InStr(1, GP_redirectPage, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
GP_redirectPage = GP_redirectPage & "?" & UploadQueryString
End If
Response.Redirect(GP_redirectPage)
end if
else
if UploadQueryString <> "" then
UploadQueryString = UploadQueryString & "&GP_upload=true"
else
UploadQueryString = "GP_upload=true"
end if
end if
' End Pure Upload
'------------------------------------------------------------------------------
%>
<%
' *** Edit Operations: (Modified for File Upload) declare variables
MM_editAction = CStr(Request.ServerVariables("URL")) 'MM_editAction = CStr(Request("URL"))
If (UploadQueryString <> "") Then
MM_editAction = MM_editAction & "?" & UploadQueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
MM_editConnection = MM_connDongklubben_STRING
MM_editTable = "Nyheder"
MM_editRedirectUrl = ""
MM_fieldsStr = "Dato|value|klokken|value|Maneder|value|PersonID|value|Overskrift|value|Brodtekst|value|Billede|value|Billedetekst|value"
MM_columnsStr = "Dato|',none,''|klokken|',none,''|ManederID|none,none,NULL|PersonID|none,none,NULL|Overskrift|',none,''|Brodtekst|',none,''|Billede|',none,''|Billedetekst|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(i+1) = CStr(UploadFormRequest(MM_fields(i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For i = LBound(MM_fields) To UBound(MM_fields) Step 2
FormVal = MM_fields(i+1)
MM_typeArray = Split(MM_columns(i+1),",")
Delim = MM_typeArray(0)
If (Delim = "none") Then Delim = ""
AltVal = MM_typeArray(1)
If (AltVal = "none") Then AltVal = ""
EmptyVal = MM_typeArray(2)
If (EmptyVal = "none") Then EmptyVal = ""
If (FormVal = "") Then
FormVal = EmptyVal
Else
If (AltVal <> "") Then
FormVal = AltVal
ElseIf (Delim = "'") Then ' escape quotes
FormVal = "'" & Replace(FormVal,"'","''") & "'"
Else
FormVal = Delim + FormVal + Delim
End If
End If
If (i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End if
MM_tableValues = MM_tableValues & MM_columns(i)
MM_dbValues = MM_dbValues & FormVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
set rsNyheder = Server.CreateObject("ADODB.Recordset")
rsNyheder.ActiveConnection = MM_connDongklubben_STRING
rsNyheder.Source = "SELECT * FROM Nyheder"
rsNyheder.CursorType = 0
rsNyheder.CursorLocation = 2
rsNyheder.LockType = 3
rsNyheder.Open()
rsNyheder_numRows = 0
%>
<%
Dim rsPersoner__MMColParam
rsPersoner__MMColParam = "1"
if (Session("MM_Username") <> "") then rsPersoner__MMColParam = Session("MM_Username")
%>
<%
set rsPersoner = Server.CreateObject("ADODB.Recordset")
rsPersoner.ActiveConnection = MM_connDongklubben_STRING
rsPersoner.Source = "SELECT * FROM Personer WHERE Username = '" + Replace(rsPersoner__MMColParam, "'", "''") + "'"
rsPersoner.CursorType = 0
rsPersoner.CursorLocation = 2
rsPersoner.LockType = 3
rsPersoner.Open()
rsPersoner_numRows = 0
%>
<%
set rsLogin = Server.CreateObject("ADODB.Recordset")
rsLogin.ActiveConnection = MM_connDongklubben_STRING
rsLogin.Source = "SELECT * FROM Personer"
rsLogin.CursorType = 0
rsLogin.CursorLocation = 2
rsLogin.LockType = 3
rsLogin.Open()
rsLogin_numRows = 0
%>
<%
set rsManeder = Server.CreateObject("ADODB.Recordset")
rsManeder.ActiveConnection = MM_connDongklubben_STRING
rsManeder.Source = "SELECT * FROM Maneder"
rsManeder.CursorType = 0
rsManeder.CursorLocation = 2
rsManeder.LockType = 3
rsManeder.Open()
rsManeder_numRows = 0
%>
<%
Dim rsMail
Dim rsMail_numRows
Set rsMail = Server.CreateObject("ADODB.Recordset")
rsMail.ActiveConnection = MM_connDongklubben_STRING
rsMail.Source = "SELECT Emailadresse, Personer FROM Personer"
rsMail.CursorType = 0
rsMail.CursorLocation = 2
rsMail.LockType = 1
rsMail.Open()
Response.write rsMail.recordCount
rsMail_numRows = 0
%>
<%
' *** Mail Uploaded Files 1.5.0
If (CStr(Request.QueryString("GP_upload")) <> "") Then
Dim MUF_path, MUF_FromName, MUF_FromEmail, MUF_ToName, MUF_ToEmail, MUF_Bcc, MUF_Subject, MUF_Body, MUF_SendHtml, MUF_checkErrors, MUF_RedirectURL, MUF_SmtpServer, MUF_MailerType
MUF_path = ""
MUF_FromName = rsPersoner.Fields.Item("Personer").Value
MUF_FromEmail = rsPersoner.Fields.Item("Emailadresse").Value
MUF_ToName = "Dongklubben"
MUF_ToEmail = rsMail.Fields.Item("Emailadresse").Value
MUF_Bcc = ""
MUF_Subject = "Ny nyhed"
MUF_Body = "Tjek her"
MUF_SendHtml = false
MUF_checkErrors = false
MUF_RedirectURL = "databasen_er _opdateret.asp"
MUF_SmtpServer = "mail.rackserv.com"
MUF_MailerType = "JMail"
do while not rsMail.eof
'on error resume next
MUF_ToEmail = rsMail("Emailadresse")
MailUploadedFiles MUF_path, MUF_FromName, MUF_FromEmail, MUF_ToName, MUF_ToEmail, MUF_Bcc, MUF_Subject, MUF_Body, MUF_SendHtml, MUF_checkErrors, MUF_RedirectURL, MUF_SmtpServer, MUF_MailerType
rsMail.movenext
response.write "Mail send til: " & MUF_ToEmail & "<br>"
loop
end if
%>
<html>
<head>
<script language="JavaScript">
<!--
function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.08
document.MM_returnValue = true;
for (var i = 0; i<form.elements.length; i++) {
field = form.elements[i];
if (field.type.toUpperCase() != 'FILE') continue;
checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.08
document.MM_returnValue = true;
if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/s/gi,"") + ")$","i");
if (field.value == '') {
if (requireUpload) {alert('File is required!');document.MM_returnValue = false;field.focus();return;}
} else {
if(extensions != '' && !re.test(field.value)) {
alert('This file type is not allowed for uploading.\nOnly the following file extensions are allowed: ' + extensions + '.\nPlease select another file and try again.');
document.MM_returnValue = false;field.focus();return;
}
document.PU_uploadForm = field.form;
re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");
if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }
}
function showImageDimensions(fieldImg) { //v2.08
var isNS6 = (!document.all && document.getElementById ? true : false);
var img = (fieldImg && !isNS6 ? fieldImg : this);
if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) {
alert('Uploaded Image is too small!\nShould be at least ' + img.minWidth + ' x ' + img.minHeight); return;}
if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) {
alert('Uploaded Image is too big!\nShould be max ' + img.maxWidth + ' x ' + img.maxHeight); return;}
if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {
alert('Uploaded Image File Size is too big!\nShould be max ' + (img.sizeLimit/1024) + ' KBytes'); return;}
if (img.saveWidth != '') document.PU_uploadForm[img.saveWidth].value = img.width;
if (img.saveHeight != '') document.PU_uploadForm[img.saveHeight].value = img.height;
document.MM_returnValue = true;
}
function checkImageDimensions(field,sizeL,minW,minH,maxW,maxH,saveW,saveH) { //v2.08
if (!document.layers) {
var isNS6 = (!document.all && document.getElementById ? true : false);
document.MM_returnValue = false; var imgURL = '
file:///' + field.value.replace(/\\/gi,'/');
if (!field.gp_img || (field.gp_img && field.gp_img.src != imgURL) || isNS6) {field.gp_img = new Image();
with (field) {gp_img.sizeLimit = sizeL*1024; gp_img.minWidth = minW; gp_img.minHeight = minH; gp_img.maxWidth = maxW; gp_img.maxHeight = maxH;
gp_img.saveWidth = saveW; gp_img.saveHeight = saveH; gp_img.onload = showImageDimensions; gp_img.src = imgURL; }
} else showImageDimensions(field.gp_img);}
}
//-->
</script>
<title>NyhedNy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/dongklubben/stylesheet/dong.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000<%=MM_editAction%>"center">
<p class="sideoverskrift" align="center">Indtast nyhed </p>
<form name="nyheder1" enctype="multipart/form-data" action="<%=MM_editAction%>" method="POST" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG',false,300,'','',200,'','','');return document.MM_returnValue">
<table align="center" width="400">
<tr valign="baseline">
<td nowrap align="right" width="120"> <div align="left">Dato:</div></td>
<td width="280"> <input type="text" name="Dato" value="<%=Date%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120"> <div align="left">Klokken:</div></td>
<td width="280"> <input type="text" name="klokken" value="<%=FORMATDATETIME(TIME,vbShortTIME)%>" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top" width="120"> <div align="left">Måneder:</div></td>
<td valign="top" width="280"> <select name="Maneder">
<option value="<%=(rsManeder.Fields.Item("ManederID").Value)%>"><%= MonthName( Month( Date ) ) %> </option>
</select> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120"> <div align="left">PersonID:</div></td>
<td width="280"> <select name="PersonID">
<%
While (NOT rsPersoner.EOF)
%>
<option value="<%=(rsPersoner.Fields.Item("PersonerID").Value)%>" <%if (CStr(rsPersoner.Fields.Item("PersonerID").Value) = CStr(rsNyheder.Fields.Item("PersonID").Value)) then Response.Write("SELECTED") : Response.Write("")%>><%=(rsPersoner.Fields.Item("Personer").Value)%></option>
<%
rsPersoner.MoveNext()
Wend
If (rsPersoner.CursorType > 0) Then
rsPersoner.MoveFirst
Else
rsPersoner.Requery
End If
%>
</select> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120"> <div align="left">Overskrift:</div></td>
<td width="280"> <input type="text" name="Overskrift" value="" size="40">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top" width="120"> <div align="left">Artikel:</div></td>
<td width="280"> <textarea name="Brodtekst" cols="60" rows="8"></textarea>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120"> <div align="left">Billede:</div></td>
<td width="280"> <input type="file" name="Billede" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG',false,300,'','',200,'','','')">
<br>
Max: B 200 X H 75</td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120">Billedetekst:</td>
<td width="280"> <input type="text" name="Billedetekst" size="45"> </td>
</tr>
<tr valign="baseline">
<td nowrap align="right" width="120"> </td>
<td width="280"> <input type="submit" value="Indsæt Nyheden" name="submit">
<input type="hidden" name="NyhederID" value="true"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="nyheder1">
</form>
</body>
</html>
<%
rsPersoner.Close()
%>
<%
rsLogin.Close()
%>
<%
rsManeder.Close()
%>
<%
rsMail.Close()
Set rsMail = Nothing
%>
<%
rsNyheder.Close()
%>
------------------