costodiaMedlem sedan aug. 2000864 inlägg jag kör Linkmentor på http://www.costodia.com (sajten är nere nu just pga linkmentor).
Problemet är att nu när jag kommit upp i över 2000 länkar så sänker scriptet servern med jämna mellanrum.
Eftersom jag hyr in mig på ett webhotell är inte det allt för lyckat.
Jag har funderat på att byta script men som jag fattar det på han som äger webhotellet så är det inte egentligen scriptet utan accessdatabasen som orsakar problemet.
Min webplats ligger på Sajthotellet.
Så det jag undrar över är om jag är tvingad att byta till ett phpscript med mysql-databas, ett asp-script med mysql-databas (det finns väl knappt sådanna) eller om jag kan modifiera i koden på något sätt så att scriptet och databsen inte hela tiden tar för mycket kraft från webhotellet.
De gångerna min webplats blivit av stängd har jag enligt webhotellet haft över två gigabyte i minnesanvändning.
costodiaMedlem sedan aug. 2000864 inlägg självfallet vill jag göra det, jag tänkte vbara att innan har jag fått kritik för att jag postat all kod, fast det var nog för att stor del av koden inte var relvant, nu vet jag inte vilken del av koden som är relevant.
goto.asp ser ut så här:
<%
OPTION EXPLICIT
%>
<!--#include file="inclink.asp"-->
<%
'Some before doings...
Dim oConn, oRS, sRedir, nID
Set oConn = IncLink_GetDatabaseConn()
nID = Request.QueryString("id")
Set oRS = oConn.Execute( "select outurl from " & FAQ_GetTablePrefix() & "ref_site where id=" & nID )
sRedir = oRS("outurl").Value
oRS.Close
Set oRS = Nothing
oConn.Execute "update " & FAQ_GetTablePrefix() & "ref_site set outcount=outcount+1 where id=" & nID
oConn.Close
Set oConn = Nothing
Response.Redirect sRedir
%>
inclink.asp
<%
'''TODO for you! Configuration:
''''2. Database connection
Function IncLink_GetDatabaseConn()
Dim oRet
Dim strDSN
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath(".") & "/lm2000.mdb"
Set oRet = Server.CreateObject ("ADODB.Connection")
oRet.Open strDSN
Set IncLink_GetDatabaseConn = oRet
End Function
'''TODO for you! Configuration:
''''Table prefix in database. Blank by default
Function FAQ_GetTablePrefix()
FAQ_GetTablePrefix = ""
End Function
'''TODO for you! Configuration:
''''3. Some ads if you'd like
Function FAQ_GetAd(nNumber)
Select Case nNumber
Case 1
FAQ_GetAd = ""
Case 2
FAQ_GetAd = ""
Case 3
FAQ_GetAd = ""
End Select
End Function
%>
showlinks.asp
<%
OPTION EXPLICIT
Response.Buffer = True
%>
<!--#include file="inclink.asp"-->
<%
'Some before doings...
Dim oConn, sRubrik
Set oConn = IncLink_GetDatabaseConn()
Dim nPageNo, nLastPage
nPageNo = Request.QueryString("pageno")
If nPageNo = "" Then
nPageNo = 1
End If
'Lets get the links
Dim oRS
Set oRS = Server.CreateObject("ADODB.Recordset")
Set oRS.ActiveConnection = oConn
oRS.CursorLocation = 3
oRS.PageSize=10
oRS.Open "select id, sitename, sitedescription, bannerurl from " & FAQ_GetTablePrefix() & "ref_site order by firstordering desc",,3,1
If oRS.EOF = False Then
nLastPage=oRS.PageCount
oRS.AbsolutePage = nPageNo
End If
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>LinkMentor demo</title>
<style type="text/css">
<!--
body { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
td { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
th { font-family: Verdana,Arial,Helvetica; font-size: smaller; color: #000000}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: underline;}
-->
</style>
</head>
<body>
<table border="0" width="100%">
<tr>
<td width="50%"><font color="#660000" face="Tahoma,Verdana,Arial" size="+3"><b>LinkMentor</b></font><BR><b><font size="3">Demo</font></b></td>
<td width="50%"><%=FAQ_GetAd( 1 )%></td>
</tr>
</table>
<table border="0" width="100%">
<tr>
<td valign="top">
<br>
<font size="4">Some links</font>
<hr>
<table border="0" width="100%">
<tr>
<td width="50%"><%WritePrev%></td>
<td width="50%">
<p align="left"><%WriteNext%></td>
</tr>
</table>
<br><br>
<table border="0" width="100%">
<%
Dim sButton, sSiteName, sSiteDescription, nCount
For nCount=1 To oRS.PageSize
sButton = ""
sSiteName = ""
sSiteDescription = ""
If oRS.EOF = False Then
If IsNull(oRS("bannerurl")) Or Trim(oRS("bannerurl")) = "" Then
Else
sButton = "<a href=" & """" & "goto.asp?p=aspcode.net&id=" & oRS("id") & """" & " target=_blank><img src=" & """" & oRS("bannerurl") & """" & "></a>"
End If
sSiteName = "<a href=" & """" & "goto.asp?p=aspcode.net&id=" & oRS("id") & """" & " target=_blank>" & oRS("sitename") & "</a>"
sSiteDescription = oRS("sitedescription")
%>
<tr>
<td width="100"><%=sButton%></td>
<td><b><%=sSiteName%></b><br>
<font size="1"><%=sSiteDescription%></font><br><br></td>
</tr>
<%
oRS.MoveNext
End If
Next
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
Sub WritePrev()
'
If CInt(nPageNo) <> 1 Then
Response.Write "<a href=""showlinks.asp?pageno=" & nPageNo-1 & """><b><<Previous Page</b></a>"
End If
End Sub
Sub WriteNext()
'
If CInt(nPageNo) <> CInt(nLastPage) Then
Response.Write "<a href=""showlinks.asp?pageno=" & nPageNo+1 & """><b>Next Page>></b></a>"
End If
End Sub
%>
</table>
<p>
<br>
</p>
<table border="0" width="100%">
<tr>
<td width="50%"><%WritePrev%></td>
<td width="50%">
<p align="left"><%WriteNext%></td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table>
<table border="0" width="100%">
<tr>
<td width="50%"><FONT face="Arial,sans serif" size=2>© </FONT> <font size="1" face="Arial,sans serif">2000
Stefan Holmberg</font></td>
<td width="50%"><%=FAQ_GetAd( 2 )%></td>
</tr>
<br>
<br>
<%=FAQ_GetAd( 3 )%>
</table>
<p align="center"> </p>
</body>
</html>
costodiaMedlem sedan aug. 2000864 inlägg admin_site.asp
<!--#include file="admin_includelogin.asp"-->
<!--#include file="inclink.asp"-->
<%
Dim oConn
Set oConn = IncLink_GetDatabaseConn()
Dim oRS
If Request.QueryString("save")="yes" Then
Set oRS = Server.CreateObject("ADODB.Recordset")
Dim sID
sID = Request.QueryString("fldAuto")
If sID = "" Then
sID = 0
Else
sID = CInt( sID)
End If
oRS.Open "select * from " & FAQ_GetTablePrefix() & "ref_site where id = " & sID, oConn, 1, 3
Select Case Request.QueryString("action")
Case "new"
oRS.AddNew
oRS("sitename") = Request.Form("sitename")
oRS("sitedescription") = Request.Form("sitedescription")
oRS("bannerurl") = Request.Form("bannerurl")
oRS("outcount") = Request.Form("outcount")
If Request.Form("firstordering") = "" Then
oRS("firstordering") = 0
Else
oRS("firstordering") = Request.Form("firstordering")
End If
oRS("outurl") = Request.Form("outurl")
Case "edit"
oRS("sitename") = Request.Form("sitename")
oRS("sitedescription") = Request.Form("sitedescription")
oRS("bannerurl") = Request.Form("bannerurl")
oRS("outcount") = Request.Form("outcount")
If Request.Form("firstordering") = "" Then
oRS("firstordering") = 0
Else
oRS("firstordering") = Request.Form("firstordering")
End If
oRS("outurl") = Request.Form("outurl")
Case "del"
oRS.Delete
End Select
oRS.Update
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
Response.Redirect "admin_default.asp"
End If
%>
<html>
<head>
<%
''''''''''' (C) Stefan Holmberg 1999
''''''''''' Free to use if these sourcecode lines is not deleted
''''''''''' Contact me at [email]webmaster@sqlexperts.com[/email]
''''''''''' [url]http://www.sqlexperts.com[/url]
''''''''''' AdMentor homepage at [url]http://www.create-a-webshop.com[/url]
Dim id, sitename, sitedescription, bannerurl
Dim outurl, outcount, firstordering
If Request.QueryString("action") = "edit" Then
Dim oRS2
Set oRS2 = oConn.Execute( "select * from " & FAQ_GetTablePrefix() & "ref_site where id = " & Request.QueryString("fldAuto") )
id = oRS2("id")
sitename = oRS2("sitename")
sitedescription = oRS2("sitedescription")
bannerurl = oRS2("bannerurl")
outurl = oRS2("outurl")
outcount = oRS2("outcount")
firstordering = oRS2("firstordering")
oRS2.Close
Set oRS2 = Nothing
Else
End If
oConn.Close
Set oConn = Nothing
%>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>PostcardMentor - Admin interface</title>
<style type="text/css">
<!--
body { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
td { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
th { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: underline;}
-->
</style>
</head>
<body>
<table align="center" bgColor="#ECECD9" border="0" cellPadding="3" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td vAlign="top" width="50%" height="60">
<b><a href="http://www.aspcode.net"><font face="verdana,arial,helvetica" size="1">[url]http://www.aspcode.net[/url]</font></a></b>
</td>
<td vAlign="top" width="468" height="60">
<b><font face="verdana,arial,helvetica" size="+2">Admin
interface</font></b>
<table border="0" width="100%">
<tr>
<td width="50%">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="100%" vAlign="top" width="100%" colspan="2">
<table align="center" bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td height="100%" vAlign="top" width="85%">
<table bgColor="#ffffff" border="0" cellPadding="10" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td align="left" height="100%" vAlign="top" width="65%">
<table border="0" width="100%">
<tr>
<td width="50%"><b><font color="#aa3333" face="verdana,arial,helvetica" size="4">LinkMentor <%=Session("fullname")%></font></b>
</td>
<td width="50%">
<%=FAQ_GetAd(1)
%>
</td>
</tr>
</table>
<hr color="#000066" noShade SIZE="1">
<p><font size="+1"></font></p>
<table border="0" width="100%">
<tr>
<td width="70%">
<p align="left"><b>Site</b><br>
<%
Dim sURL
sURL = "admin_site.asp?save=yes&action=" & Request.QueryString("action")
sURL = sURL & "&fldAuto=" & Request.QueryString("fldAuto")
%>
<form method="POST" action="<%=sURL%>">
<p align="left">Name: <input type="text" name="sitename" size="40" value="<%=sitename%>"></p>
<p align="left">Site url: <input type="text" name="outurl" size="20" value="<%=outurl%>"></p>
<p align="left">Description:<textarea rows="4" name="sitedescription" cols="35"><%=sitedescription%></textarea></p>
<p align="left">Banner url: <input type="text" name="bannerurl" size="20" value="<%=bannerurl%>">
( url to picture - leave blank if none )</p>
<p align="left">Out hits: <input type="text" name="outcount" size="20" value="<%=outcount%>">
( NUMERIC- REQUIRED )</p>
<p align="left">Firstordering: <input type="text" name="firstordering" size="20" value="<%=firstordering%>">
( NUMERIC - REQUIRED ) Higher value means it will be
shown on first pages. </p>
<p align="left"> </p>
<p align="left"><input type="submit" value="Submit" name="B1"></p>
</form>
<p><font face="helvetica, arial" size="2">LinkMentor is
developed by <a href="http://www.aspcode.net">ASPCode.net</a>. Usage of it is totally free.</font></p>
<br>
<table border="0" width="100%">
<tr>
<td width="50%">
<%=FAQ_GetAd(3)
%>
</td>
<td width="50%">
<%=FAQ_GetAd(2)
%>
</td>
</tr>
</table>
</tr>
<tr>
<td width="70%">
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
costodiaMedlem sedan aug. 2000864 inlägg admin_includelogin.asp
<%
Response.Buffer = True
Function ValidateLogin( sId, sPwd )
' For you to validate ID and PASSWORD
' Maybe against a database
' Here we have hardcoded some OK id:s and passwords
'
ValidateLogin = False
If sId = "test" AND sPwd="secret" Then
ValidateLogin = True
End If
If sId = "user2" AND sPwd="pwd2" Then
ValidateLogin = True
End If
End Function
Dim sText, fBack
fBack = False
If Request.Form("dologin") = "yes" Then
'Try to login
If ValidateLogin( Request.Form("id"),Request.Form("pwd") ) = True Then
'It is OK!!!
'We are logged in so lets go back to the file that included us
fBack = True
Session("logonid") = Request.Form("id")
Else
sText = "Wrong password or user id"
End If
Else
'We are not trying to login...
If Session("logonid") <> "" Then
'
fBack = True
'We are logged in so lets go back to the file that included us
Else
sText = "Please login"
End If
End If
If fBack = False Then %>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>You need to login</title>
</head>
<body>
<%=FAQ_GetAd( 1 )%>
<br>
<br>
<%=sText%>
<%
Dim sIncURL
sIncURL = Request.ServerVariables("SCRIPT_NAME")
If Request.ServerVariables("QUERY_STRING") <> "" Then
'
sIncURL = sIncURL & "?" & Request.ServerVariables("QUERY_STRING")
End If
%>
<form method="POST" action="<%=sIncURL%>">
<input type="hidden" name="dologin" value="yes">
<table border="0" width="100%">
<tr>
<td>Loginname:</td>
<td><input name="id" size="20"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pwd" size="20"></td>
</tr>
</table>
<p><input type="submit" value="Login" name="B1"></p>
</form>
<br>
<%=FAQ_GetAd( 2 )%>
<br>
<%=FAQ_GetAd( 3 )%>
</body>
</html>
<%
Response.End
End If
%>
costodiaMedlem sedan aug. 2000864 inlägg admin_default.asp
<!--#include file="inclink.asp"-->
<!--#include file="admin_includelogin.asp"-->
<html>
<head>
<%
''''''''''' (C) Stefan Holmberg 1999
''''''''''' Free to use if these sourcecode lines is not deleted
''''''''''' Contact me at [email]webmaster@sqlexperts.com[/email]
''''''''''' [url]http://www.sqlexperts.com[/url]
''''''''''' AdMentor homepage at [url]http://www.create-a-webshop.com[/url]
Set oConn = IncLink_GetDatabaseConn()
Dim strSort
strSort = Request.QueryString("sort")
If strSort = "" Then
strSort = " firstordering desc"
Else
strSort = strSort & " desc"
End If
%>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>FAQMentor - Admin interface</title>
<style type="text/css">
<!--
body { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
td { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
th { font-family: Arial, Geneva, Helvetica, Verdana; font-size: smaller; color: #000000}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: underline;}
-->
</style>
</head>
<body>
<table align="center" bgColor="#ECECD9" border="0" cellPadding="3" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td vAlign="top" width="50%" height="60">
<b><a href="http://www.aspcode.net/"><font face="verdana,arial,helvetica" size="1">[url]http://www.aspcode.net[/url]</font></a></b>
</td>
<td vAlign="top" width="468" height="60">
<b><font face="verdana,arial,helvetica" size="+2">Admin
interface</font></b>
<table border="0" width="100%">
<tr>
<td width="50%">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="100%" vAlign="top" width="100%" colspan="2">
<table align="center" bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td height="100%" vAlign="top" width="85%">
<table bgColor="#ffffff" border="0" cellPadding="10" cellSpacing="0" height="100%" width="100%">
<tbody>
<tr>
<td align="left" height="100%" vAlign="top" width="65%">
<table border="0" width="100%">
<tr>
<td width="50%"><b><font color="#aa3333" face="verdana,arial,helvetica" size="4">LinkMentor <%=Session("fullname")%></font></b>
</td>
<td width="50%">
<%
Response.Write FAQ_GetAd(1)
%> banner1 </td>
</tr>
</table>
<font color="#aa3333" face="verdana,arial,helvetica" size="+2">
<hr color="#000066" noShade SIZE="1">
</font>
<table border="0" width="100%">
<tr>
<td width="70%">
<font face="helvetica, arial" size="2"><b><i>These links
are available </i></b></font>
<table border="0" width="100%">
<tr>
<td><b><a href="admin_default.asp?sort=sitename">Sitename</a></b></td>
<td><b><a href="admin_default.asp?sort=outcount">Clickcount</a></b></td>
<td><b><a href="admin_default.asp?sort=firstordering">Ordering</a></b></td>
<td width="100"><b>Action</b></td>
</tr>
<%
Dim oRS
Set oRS = oConn.Execute("select * from " & FAQ_GetTablePrefix() & "ref_site order by " & strSort)
Dim bgcolor
bgcolor = "#ECECD9"
while not oRS.EOF
%>
<tr>
<td bgcolor="<%=bgcolor%>"><b><%=Trim(oRS("sitename"))%></b></td>
<td bgcolor="<%=bgcolor%>"><b><%=oRS("outcount")%></b></td>
<td bgcolor="<%=bgcolor%>"><b><%=oRS("firstordering")%></b></td>
<td width="100" bgcolor="<%=bgcolor%>"><b><a href="admin_site.asp?fldAuto=<%=oRS("id")%>&action=edit">Modify</a>
- <a href="admin_site.asp?fldAuto=<%=oRS("id")%>&save=yes&action=del">Delete</a></b></td>
</tr>
<%
If bgcolor="#ECECD9" Then
bgcolor = "#FFFFFF"
Else
bgcolor="#ECECD9"
End if
oRS.MoveNext
Wend
oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing
%>
</table>
<p><font face="helvetica, arial" size="2"><a href="admin_site.asp?action=new">Add
new link</a></font></p>
<p><font face="helvetica, arial" size="2">LinkMentor is
developed by <a href="http://www.aspcode.net">ASPCode.net</a>. Usage of it is totally free.</font></p>
<br>
<table border="0" width="100%">
<tr>
<td width="50%">
<%=FAQ_GetAd(3)
%>
</td>
<td width="50%">
<%=FAQ_GetAd(2)
%>
</td>
</tr>
</table>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
costodiaMedlem sedan aug. 2000864 inlägg sqlserver7.txt
if exists (select * from sysobjects where id = object_id(N'[dbo].[ref_site]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ref_site]
GO
CREATE TABLE [dbo].[ref_site] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[sitename] [nvarchar] (100) NULL ,
[sitedescription] [nvarchar] (255) NULL ,
[bannerurl] [nvarchar] (255) NULL ,
[outcount] [int] NULL ,
[outurl] [nvarchar] (255) NULL ,
[firstordering] [int] NULL
) ON [PRIMARY]
GO
CREATE UNIQUE INDEX [ix1] ON [dbo].[ref_site]([id]) ON [PRIMARY]
och en bild på databasen
@ndersMedlem sedan juni 200032 969 inlägg Wow.
Jag tänkte att du skulle posta relevant kod, dvs den som är upphov till problemet, men man kanske måste ha hela sammanhanget.
Vi får se om någon orkar kolla på allt det där... ;)
costodiaMedlem sedan aug. 2000864 inlägg det är det första kod-inlägget om är relevant
resten är sådan som bara används av adminen, och jag tror inte det är där felet ligger.
Jag fudnerar på en sak, kan de ta onödigt mycket på databasen att dne måste loopa ut 2000 poster varje gång jag ladddar adminsidan?
costodiaMedlem sedan aug. 2000864 inlägg men kan jag fråga dig ialla fall om sannlikheten att det är accessdatbasen som orkar bekymmret är överhängade elelr om det är ganska ovanligt att access blir instabilt?
@ndersMedlem sedan juni 200032 969 inlägg Eftersom du riktar frågan till mig (antar jag ;) ) så får jag väl lov att svara:
Har inte en susning. Jag använder aldrig Access, så jag vet inte.
Nu är ordet fritt för andra aspirerande svarare! :D