<%If Session("admin") = "ok" Then If Request.Querystring("mess") = "bort" Then mess = "alert('Posten borttaget!');return true;" End If If Request.Querystring("mess") = "andra" Then mess = "alert('Posten ändrat!');return true;" End If%> <%Public Function FixSQL(ByVal sString) ' As String If Len("" & sString) = 0 Then Exit Function sString = Replace(sString, "'","''") sString = Replace(sString, "\","\\") FixSQL = sString End Function%> Admin BYLA

Admin BYLA

<% Set Connha = Server.CreateObject("ADODB.Connection") Connha.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/byla.mdb")%> <%With RecSetha .MoveFirst .PageSize = foha .AbsolutePage = sidaha End With Sidorha = RecSetha.PageCount Countha = 0 Do While Not RecSetha.EOF And Countha < RecSetha.PageSize%> <%Countha = Countha + 1 RecSetha.MoveNext Loop If Sidorha >= 1 Then%> <%Else%> <%End If End If%>
<%If Request.Querystring("action")= "" Then%> <%Set RecSetha = Server.CreateObject("ADODB.Recordset") Const foha = 10 Sidanha = Request.QueryString("sidaha") If Sidanha = "" then sidaha = 1 Else sidaha = Sidanha End If With RecSetha .CursorLocation = 3 .CacheSize = foha End With SQLha = "SELECT tjanster.rubrik, tjanster.texten, tjanster.bild, tjanster.id FROM tjanster Order By id asc" RecSetha.Open SQLha, Connha If RecSetha.EOF Then%>
Inga Händelser inlagd
<%Else%>

Hantera Händelser

Rubrik: Texten: Bild:  
<%=RecSetha("rubrik")%> <%=RecSetha("texten")%> "width="80%" height="40%" > &#tab1">Ändra   &#tab1')">Ta bort
<%If Sidorha <> 1 Then For Sidha = 1 To Sidorha If (Int(Sidha)) = (Int(sidaha)) Then%><%=Sidha%><%Else%> <%=Sidha%> <%End If%> <%Next%> Lägg till
Lägg till
<% RecSetha.Close Set RecSetha = Nothing End If End If If Request.QueryString("action") = "change_ha" Then Set RecSetha = Connha.Execute("SELECT * FROM tjanster WHERE id="& Request.Querystring("id"))%> &#tab1" name="change" enctype="multipart/form-data" onSubmit="return add()">
Rubrk:
">
Text:
bild:
">
<%RecSetha.Close Set RecSetha = Nothing End If If Request.QueryString("action") = "andrat_ha" Then byteCount = Request.TotalBytes RequestBin = Request.BinaryRead(byteCount) Set UploadRequest = CreateObject("Scripting.Dictionary") BuildUploadRequest RequestBin contentType = UploadRequest.Item("bild").Item("ContentType") filepathname = UploadRequest.Item("bild").Item("FileName") filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) value = UploadRequest.Item("bild").Item("Value") bilden = filename rubrik = FixSQL(UploadRequest.Item("rubrik").Item("Value")) texten = FixSQL(UploadRequest.Item("texten").Item("Value")) Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject") pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14 if bilden = "" then Set RecSetha = Connha.Execute("SELECT * FROM tjanster WHERE id="& Request.Querystring("id")) bilden = RecSetha("bild") else Set MyFile = ScriptObject.CreateTextFile(Server.mappath("bild/"&filename)) 'Response.write filename bilden = "bild/"&filename For i = 1 to LenB(value) MyFile.Write chr(AscB(MidB(value,i,1))) Next MyFile.Close end if 'response.write bilden Connha.execute("Update tjanster Set rubrik='" & rubrik & "', texten='" & texten & "', bild='" & bilden & "' Where id = "& Request.Querystring("id")) Response.Redirect "Fradminha.asp?visa=cp&#tab1" Sub BuildUploadRequest(RequestBin) PosBeg = 1 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) boundaryPos = InstrB(1,RequestBin,boundary) Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--"))) Dim UploadControl Set UploadControl = CreateObject("Scripting.Dictionary") Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition")) Pos = InstrB(Pos,RequestBin,getByteString("name=")) PosBeg = Pos+6 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename=")) PosBound = InstrB(PosEnd,RequestBin,boundary) If PosFile<>0 AND (PosFile <%laggtill = "check" %>
Lägg till ny Bild:
Rubrik:
Text:
Bild:
<%End If If Request.Querystring("action") = "spara_ha" Then rubrik = FixSQL(Request.Form("rubrik")) texten = FixSQL(Request.Form("texten")) bild = FixSQL(Request.Form("bild")) blid = "janne" Connha.Execute("Insert Into tjanster (rubrik,texten,bild) Values('" & rubrik & "','" & texten & "','" & bild & "')") Response.Redirect "Fradminha.asp?visa=cp&#tab1" End If%>
<%End If%>