Avatar billede plobber Nybegynder
23. juli 2003 - 18:50 Der er 8 kommentarer og
2 løsninger

Optimering af kode

Hej.. jeg har verdens næst længste kode.. nogen der gider optimere den.. gerne ud i flere filer..

<script type="text/javaScript">
<!--
if (window != window.top) top.location.href = location.href;
//-->
</script>
<%
if request ("mode") = "login" then
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/users.mdb")
Conn.Open DSN
Login = Trim(Replace(Request.Form("Login"),"'","''" ))
Password = Trim(Replace(Request.Form("Password"),"'","''" ))

rsSQL = "SELECT * FROM users where Login = '" & Login & "' and Password = '" & Password & "'"
set rs = Conn.execute(rsSQL)
If Not (rs.BOF Or rs.Eof) Then
Session("ID") = rs("ID")
session("login") = True
Session("username") = rs("login")
Session("admin") = rs("admin")
Else
response.redirect "default.asp?page=not"
End If
Conn.Close
Set Conn = Nothing
End if
%>
<%
if Request.Querystring("page")="" then page="news" else page=Request.Querystring("page")
%>
<%
if page = "logout" then
session.abandon()
Response.redirect "default.asp"
end if
%>
<%
if page = "news" then
pagetitle = "News"
end if
%>
<%
if page = "about" then
pagetitle = "Stuff bout us as clan"
end if
%>
<%
if page = "memberz" then
pagetitle = "The memberz of [2TL]"
end if
%>
<%
if page = "pcw" then
pagetitle = "Practice Clanwars"
end if
%>
<%
if page = "cw" then
pagetitle = "Clanwars outside a tournament"
end if
%>
<%
if page = "cbcw" then
pagetitle = "Clanbase Clanwars"
end if
%>
<%
if page = "tagwall" then
pagetitle = "Tagwall"
end if
%>
<%
if page = "usertagwall" then
pagetitle = "Memberz Tagwall"
end if
%>
<%
if page = "xcw" then
pagetitle = "XplayN Clanwars"
end if
%>
<%
if page = "challenge" then
pagetitle = "Challenge us"
end if
%>
<%
if page = "messages" then
pagetitle = "Messages from the Leaders"
end if
%>
<%
if page = "admin" then
pagetitle = "Administrator"
end if
%>
<%
if page = "not" then
pagetitle = "Not Logged In"
end if
%>
<html>

<head>
<link rel="stylesheet" href="2tl.css" type="text/css">
<link rel="shortcut icon" href="favicon.ico">
<title>Welcome  to [2TL] - Clan Too The Limit - [2TL] - We Are Pwning U</title>
</head>

<body bgcolor="#333333" text="#FF0000" link="#FFFF00" vlink="#FFFF00" alink="#FFFF00">
<center>
<table border="1" width="800" bordercolor="#FF0000" cellspacing="0" cellpadding="0" bordercolorlight="#FF0000" bordercolordark="#FF0000" bgcolor="#000000">
  <tr>
    <td width="100%" align="center" bgcolor="#000000"><img border="0" src="2tl.jpg"></td>
  </tr>
  <tr>
    <td width="100%">
      <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td width="170" valign="top" align="center"><br>
            <table border="1" width="140" cellspacing="0" cellpadding="0" bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000">
              <tr>
                <td width="100%" bgcolor="#333333">
                  <p align="center"><font color="#FFFFFF">-= The Clan =-</font></td>
              </tr>
              <tr>
                <td width="100%" align="center">
                <div align="center">
                  <center>
                  <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="100%" align="center" onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=news"><font size="2">News</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=about"><font size="2">About
                        Us</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'">
                <a href="default.asp?page=memberz"><font size="2">MemberZ</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=tagwall"><font size="2">Tagwall</font></a></td>
                    </tr>
                  </table>
                  </center>
                </div>
                </td>
              </tr>
            </table>&nbsp;
<table border="1" width="140" cellspacing="0" cellpadding="0" bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000">
              <tr>
                <td width="100%" bgcolor="#333333">
                  <p align="center"><font color="#FFFFFF">-= Wars =-</font></td>
              </tr>
              <tr>
                <td width="100%" align="center">
                <div align="center">
                  <center>
                  <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=pcw"><font size="2">PCW</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=cw"><font size="2">CW</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=cbcw"><font size="2">CBCW</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><a href="default.asp?page=xcw"><font size="2">XCW</font></a></td>
                    </tr>
                    <tr>
                      <td width="100%" align="center"onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'">
                  <a href="default.asp?page=challenge"><font size="2">Challenge Us</font></a></td>
                    </tr>
                  </table>
                  </center>
                </div>
                </td>
              </tr>
            </table>&nbsp;
<table border="1" width="140" cellspacing="0" cellpadding="0" bordercolor="#FF0000" bordercolorlight="#FF0000" bordercolordark="#FF0000">
              <tr>
                <td width="100%" bgcolor="#333333">
                  <p align="center"><font color="#FFFFFF">-= Login =-</font>
              </td></tr><tr><td align="center">

<%
If Session("login") <> True then
%>
             
<%
if page = "not" then
%>
<font size="2">
Not Logged In </font>
<%
end if
%>
                  <form method="POST" action="default.asp">
                    <p align="center"><input type="text" name="Login" size="16" id=Login value="Username" onFocus="this.value=''"><br><input type="hidden" name="mode" value="login">
                    <input type="password" name="Password" size="11" id=Password value="Password" onFocus="this.value=''">&nbsp;<input type="submit" value="Login" name="B1" id=knap></p>
                  </form>
<%
else
If Session("login") = True then
%>
<table bgcolor="black" border="0" width="100%" cellpadding="0" cellspacing="0">
              <tr>
                <td width="100%" align="center" onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'" align="center">
<font color="red" size='2'>Hi <%= session("username") %>
</td></tr><tr><td onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'" align="center">
<font color="red" size='2'><a href='default.asp?page=messages'>Messages</a>
</td></tr><tr><td onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'" align="center">
<font color="red" size='2'><a href='default.asp?page=usertagwall'>UserZ Tagwall</a>
</td></tr><tr><td onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'" align="center">
<font color="red" size='2'><a href='default.asp?page=logout'>Logout</a></font>
<%
If session("admin") = 1 then
%>
</td></tr><tr><td onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'" align="center">
<font color='red' size='2'><a href="default.asp?page=admin">Administrator</a></font>
<%
end If
%>
</td></tr>
</table>
<%
end If
end If
%>
         
           
                </td>
              </tr>
            </table>
<br><table border="1" width="140" cellspacing="0" cellpadding="0" bordercolor="#FF0000">
              <tr>
                <td width="100%" bgcolor="#333333" align="center"><font color="#FFFFFF">-=
                  MemberZ =-</font></td>
              </tr>
              <tr>
                <td width="100%" align="center">
                  <table border="0" width="100%" cellspacing="0" cellpadding="0">

<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/users.mdb")
Conn.Open DSN
strSQL = "Select * from users Where ID > 1 Order by ID"
Set rs = Conn.Execute(strSQL)
Do
%>
<tr><td width='100%' align='center' onMouseover="this.style.backgroundColor='#333333'" onMouseOut="this.style.backgroundColor='#000000'"><font size="2" color='red'><a href="default.asp?page=memberz&user=<%= rs("Login") %>"><%= rs("Login") %></a></font><br></td></tr>
<%
rs.MoveNext
Loop While Not rs.EOF
%>
</table>
</td>
              </tr>
            </table>&nbsp;

            <p>&nbsp;
          </td>
          <td valign="top" align="center">
<br>
      <table border="1" bordercolor="red" width="90%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="100%" bgcolor="#333333" align="center"><font color="white">-= <%= pagetitle %> =-</font></td>
        </tr>
        <tr>
          <td width="100%" align="center">
<%
if page = "news" then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/messages.mdb")
Conn.Open DSN
strSQL = "Select * from news order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">
      <table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#333333">
        <tr>
          <td align="center"><font color="white"><%= rs("Header") %></font></td>
          <td width="90" align="left"><font color="white"><%= FormatDateTime(rs("Dato"), vbShortDate) %></font></td>
          <td width="120" align="right"><font color="white"><%= rs("Author") %></font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" align="center"><%= rs("Tekst") %></td>
  </tr>
</table>

<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
end if
%>
<%
if page = "about" then
%>

<%
end if
%>
<%
if page = "memberz" then
%>
<%
if Request.Querystring("user")="" then
%>
<br>
Press on the Nick to get a detailed description about a player
<br><br>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/users.mdb")
Conn.Open DSN
strSQL = "Select * from users Where ID > 1 Order by ID"
Set rs = Conn.Execute(strSQL)
Do
Response.Write "<table border='0' width='500' cellspacing='0' cellpadding='0'><tr><td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0'>        <tr>          <td width='115'>            <table border='0' width='100%' cellspacing='0' cellpadding='0'>              <tr>                <td width='115' height='19'><font color='white'>Nick..:</font></td>              </tr>              <tr>                <td width='115' height='19'><font color='red'>Realname..:</font></td>              </tr>              <tr>    <td width='115' height='18'><font color='red'>Age..:</td>              </tr>              <tr>    <td width='115' height='19'><font color='red'>Rank..:</td>                  </tr><tr>    <td width='115' height='19'><font color='red'>Gaming Style..:</td>                  </tr>      <tr>    <td width='115' height='18'><font color='red'>Email..:</td>              </tr>  <tr><td><font color='black'>-</font></td></tr>    <tr>                <td width='100%'></td>              </tr>            </table>          </td>          <td>          <table border='0' width='100%' cellspacing='0' cellpadding='0'>              <tr>                <td height='19'><a href='default.asp?page=memberz&user=" & rs("Login") &"'><font color='white'>" & rs("Login") & "</a></font></td>              </tr>              <tr>                <td height='19'><font color='red'>" & rs("Navn") & "</font></td>                </tr>              <tr>                <td height='18'><font color='red'>" & rs("Alder") & "</td>                </tr>              <tr>    <td height='19'><font color='red'>" & rs("Rang") & "</td>                </tr><tr>    <td height='19'><font color='red'>" & rs("Gamingstyle") & "</td>                </tr>      <tr>    <td height='19'><font color='red'>" & rs("Email") & "</td>                </tr>  <tr><td><font color='black'>-</font></td></tr>    <tr>                <td width='100%'></td>              </tr>            </table>          </td>          <td></td>        </tr>      </table>    </td>  </tr>  </table>"
rs.MoveNext
Loop While Not rs.EOF
%>
<%
else
Username = Request.Querystring("user")
%>

<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/users.mdb")
Conn.Open DSN
strSQL = "Select * from users Where Login = '" & Username & "'"
Set rs = Conn.Execute(strSQL)
Do
Response.Write "<br><table border='0' width='500' cellspacing='0' cellpadding='0'><tr><td width='100%' colspan='2'><table border='0' width='100%' cellspacing='0' cellpadding='0'>        <tr>          <td width='115'>            <table border='0' width='100%' cellspacing='0' cellpadding='0'>              <tr>                <td width='115' height='19'><a name='" & rs("Login") & "'><font color='white'>Nick..:</font></a></td>              </tr>              <tr>                <td width='115' height='19'><font color='red'>Realname..:</font></td>              </tr>              <tr>    <td width='115' height='18'><font color='red'>Age..:</td>              </tr>              <tr>    <td width='115' height='19'><font color='red'>Rank..:</td>                  </tr><tr>    <td width='115' height='19'><font color='red'>Gaming Style..:</td>                  </tr>      <tr>    <td width='115' height='18'><font color='red'>Email..:</td>              </tr>  <tr><td><font color='black'>-</font></td></tr>    <tr>                <td width='100%'></td>              </tr>            </table>          </td>          <td>          <table border='0' width='100%' cellspacing='0' cellpadding='0'>              <tr>                <td height='19'><font color='white'>" & rs("Login") & "</td>              </tr>              <tr>                <td height='19'><font color='red'>" & rs("Navn") & "</font></td>                </tr>              <tr>                <td height='18'><font color='red'>" & rs("Alder") & "</td>                </tr>              <tr>    <td height='19'><font color='red'>" & rs("Rang") & "</td>                </tr><tr>    <td height='19'><font color='red'>" & rs("Gamingstyle") & "</td>                </tr>      <tr>    <td height='19'><font color='red'>" & rs("Email") & "</td>                </tr>  <tr><td><font color='black'>-</font></td></tr>    <tr>                <td width='100%'></td>              </tr>            </table>          </td>          <td></td>        </tr>      </table>    </td>  </tr>  <tr>    <td width='115'><font color='red'>Processor..:</td>    <td height='17' width='385'><font color='red'>" & rs("Processor") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Ram..:</td>    <td height='19' width='385'><font color='red'>" & rs("Ram") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Graphics..:</td>    <td height='19' width='385'><font color='red'>" & rs("Gfxkort") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Monitor..:</td>    <td height='19' width='385'><font color='red'>" & rs("Skærm") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Sound..:</td> <td height='19' width='385'><font color='red'>" & rs("Lydkort") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Mouse..:</td>    <td height='19' width='385'><font color='red'>" & rs("Mus") & "</td>    </tr> <tr>    <td width='115'><font color='red'>Mousepad..:</td>    <td height='19' width='385'><font color='red'>" & rs("Muspad") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Keyboard..:</td>    <td height='19' width='385'><font color='red'>" & rs("Tastatur") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Inet..:</td>    <td height='15' width='385'><font color='red'>" & rs("Inet") & "</td>    </tr>  <tr>    <td width='115'></td>    <td width='385'></td>  </tr><tr><td><font color='black'>-</font></td></tr>  <tr>    <td width='115'><font color='red'>Favorit Map..:</td>    <td height='19' width='385'><font color='red'>" & rs("Map") & "</td>    </tr>  <tr>    <td width='115'><font color='red'>Favorit Weapon..:</font></td>    <td height='19' width='385'><font color='red'>" & rs("Våben") & "</td>    </tr></table><br>"
rs.MoveNext
Loop While Not rs.EOF
%>
<% end if %>

<%
Conn.Close
Set Conn = Nothing
%>
<%
end if
%>

<%
if page = "tagwall" then
%>
<% response.buffer = true %>

<% if Request.QueryString("mode")="" then %><div align="center"><center>


<table border="0" cellpadding="0" cellspacing="0" width="90%">
    <tr>
        <td width="100%">
          <p align="center"><font face="Arial" size="2"><a href="default.asp?page=tagwall&mode=add">Add Tag</a><font
        size="1" face="Arial Black"><br><br>
          <%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/tagwall.mdb")
strSQL = "Select * From Tagwall"
set rs = Conn.execute(strSQL)

if rs.EOF then
Response.write "<font face=""Arial"" size=""2""><i>Theres no tags</i></font>"
else
Do Until rs.EOF%>

<table border="0" cellpadding="0" cellspacing="0" width="90%">
    <tr>
        <td width="100%" align="center" bgcolor="#333333"><font face="Arial" size="2" color="white">
          <font size="3" face="arial"><%=RS("forfatter")%>:</font></td></tr><tr><td><font size="3" face="arial"><center><%=RS("tekst")%></td>
    </tr>
</table>


<p><%RS.MoveNext
Loop
end if

Conn.Close
Set Conn = Nothing%></p>

<p><% elseif Request.QueryString("mode")="add" then %></p>

<font face="Arial Black" >Tagwall</font></h1>

<form action="default.asp?page=tagwall&mode=save" method="POST">
    <div align="center"><center><table border="0" cellpadding="2"
    cellspacing="0" width="50%">
        <tr>
            <td align="right" width="20%"><font face="Arial" size="2">Name:</font></td>
            <td colspan="2" width="80%"><font size="2"
            face="Arial"><input type="text" size="20"
            name="Forfatter"></font></td>
        </tr>

        <tr>
            <td align="right" valign="top" width="20%"><font face="Arial" size="2">Text:</font></td>
            <td valign="top" width="10%"><font size="2"
            face="Arial"><textarea name="Tekst" rows="4"
            cols="40"></textarea></font></td>
            <td valign="top" width="90%"><font size="2"
            face="Arial"></font></td>
        </tr>
    </table>
    </center></div><p align="center"><input type="submit"
    name="B1" value="Add"></p>
</form>

<p><% elseif Request.QueryString("mode")="save" then %> <%
response.buffer = true



Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db/tagwall.mdb") & ";UID=admin;PWD=;"

    Set rs = Server.CreateObject("ADODB.RecordSet")
    strSQL = "Select * From Tagwall"
    rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

      rs.AddNew
      rs("Forfatter") = Request.form("Forfatter")
      rs("Tekst") = Request.form("Tekst")
    rs("Dato") = date()
      rs.Update

    rs.Close
    Set rs = Nothing

Conn.Close
set Conn = Nothing
response.redirect "default.asp?page=tagwall"
%><%end if%></p>
<%
end if
%>
<%
if page = "usertagwall" then
If Session("login") = True then
%>
<% response.buffer = true %>

<% if Request.QueryString("mode")="" then %><div align="center"><center>


<table border="0" cellpadding="0" cellspacing="0" width="90%">
    <tr>
        <td width="100%">
          <p align="center"><font face="Arial" size="2"><a href="default.asp?page=usertagwall&mode=add">Add Tag</a><font
        size="1" face="Arial Black"><br><br>
          <%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/tagwall.mdb")
strSQL = "Select * From UserTagwall"
set rs = Conn.execute(strSQL)

if rs.EOF then
Response.write "<font face=""Arial"" size=""2""><i>Theres no tags</i></font>"
else
Do Until rs.EOF%>

<table border="0" cellpadding="0" cellspacing="0" width="90%">
    <tr>
        <td width="100%" align="center" bgcolor="#333333"><font face="Arial" size="2" color="white">
          <font size="3" face="arial"><%=RS("forfatter")%>:</font></td></tr><tr><td><font size="3" face="arial"><center><%=RS("tekst")%></td>
    </tr>
</table>


<p><%RS.MoveNext
Loop
end if

Conn.Close
Set Conn = Nothing%></p>

<p><% elseif Request.QueryString("mode")="add" then %></p>

<font face="Arial Black" >Tagwall</font></h1>

<form action="default.asp?page=usertagwall&mode=save" method="POST">
    <div align="center"><center><table border="0" cellpadding="2"
    cellspacing="0" width="50%">
        <tr>
            <td align="right" width="20%"><font face="Arial" size="2">Name:</font></td>
            <td colspan="2" width="80%"><font size="2"
            face="Arial"><input type="text" size="20"
            name="Forfatter"></font></td>
        </tr>

        <tr>
            <td align="right" valign="top" width="20%"><font face="Arial" size="2">Text:</font></td>
            <td valign="top" width="10%"><font size="2"
            face="Arial"><textarea name="Tekst" rows="4"
            cols="40"></textarea></font></td>
            <td valign="top" width="90%"><font size="2"
            face="Arial"></font></td>
        </tr>
    </table>
    </center></div><p align="center"><input type="submit"
    name="B1" value="Add"></p>
</form>

<p><% elseif Request.QueryString("mode")="save" then %> <%
response.buffer = true

Const adOpenKeyset = 1
Const adLockOptimistic = 3

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db/tagwall.mdb") & ";UID=admin;PWD=;"

    Set rs = Server.CreateObject("ADODB.RecordSet")
    strSQL = "Select * From UserTagwall"
    rs.Open strSQL, Conn, adOpenKeyset, adLockOptimistic

      rs.AddNew
      rs("Forfatter") = Request.form("Forfatter")
      rs("Tekst") = Request.form("Tekst")
    rs("Dato") = date()
      rs.Update

    rs.Close
    Set rs = Nothing

Conn.Close
set Conn = Nothing
response.redirect "default.asp?page=usertagwall"
%><%end if%></p>
<%
else
Response.redirect "default.asp"
end if
end if
%>

<%
if page = "pcw" then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/cws.mdb")
Conn.Open DSN
strSQL = "Select * from pcw order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">        <tr>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">HomeTeam</font></td>          <td width="5%" bgcolor="#333333" align="center"><font color="#FFFFFF">Versus</font></td>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">AwayTeam</font></td>          <td width="10%" bgcolor="#333333" align="center"><font color="#FFFFFF">Results</font></td>          <td width="5%" bgcolor="#333333" align="center">&nbsp;</td>        </tr>        <tr>          <td width="40%" align="center"><%= rs("Home") %></td>          <td width="5%" align="center">-</td>          <td width="40%" align="center"><%= rs("Away") %></td>          <td width="10%" align="center"><%= rs("Result") %></td>          <td width="5%" align="center"><%= rs("GoodBad") %></td>        </tr>      </table>
<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
end if
%>

<%
if page = "cw" then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/cws.mdb")
Conn.Open DSN
strSQL = "Select * from cw order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">        <tr>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">HomeTeam</font></td>          <td width="5%" bgcolor="#333333" align="center"><font color="#FFFFFF">Versus</font></td>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">AwayTeam</font></td>          <td width="10%" bgcolor="#333333" align="center"><font color="#FFFFFF">Results</font></td>          <td width="5%" bgcolor="#333333" align="center">&nbsp;</td>        </tr>        <tr>          <td width="40%" align="center"><%= rs("Home") %></td>          <td width="5%" align="center">-</td>          <td width="40%" align="center"><%= rs("Away") %></td>          <td width="10%" align="center"><%= rs("Result") %></td>          <td width="5%" align="center"><%= rs("GoodBad") %></td>        </tr>      </table>
<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
end if
%>

<%
if page = "cbcw" then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/cws.mdb")
Conn.Open DSN
strSQL = "Select * from cbcw order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">        <tr>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">HomeTeam</font></td>          <td width="5%" bgcolor="#333333" align="center"><font color="#FFFFFF">Versus</font></td>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">AwayTeam</font></td>          <td width="10%" bgcolor="#333333" align="center"><font color="#FFFFFF">Results</font></td>          <td width="5%" bgcolor="#333333" align="center">&nbsp;</td>        </tr>        <tr>          <td width="40%" align="center"><%= rs("Home") %></td>          <td width="5%" align="center">-</td>          <td width="40%" align="center"><%= rs("Away") %></td>          <td width="10%" align="center"><%= rs("Result") %></td>          <td width="5%" align="center"><%= rs("GoodBad") %></td>        </tr>      </table>
<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
end if
%>
<%
if page = "xcw" then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/cws.mdb")
Conn.Open DSN
strSQL = "Select * from xcw order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">        <tr>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">HomeTeam</font></td>          <td width="5%" bgcolor="#333333" align="center"><font color="#FFFFFF">Versus</font></td>          <td width="40%" bgcolor="#333333" align="center"><font color="#FFFFFF">AwayTeam</font></td>          <td width="10%" bgcolor="#333333" align="center"><font color="#FFFFFF">Results</font></td>          <td width="5%" bgcolor="#333333" align="center">&nbsp;</td>        </tr>        <tr>          <td width="40%" align="center"><%= rs("Home") %></td>          <td width="5%" align="center">-</td>          <td width="40%" align="center"><%= rs("Away") %></td>          <td width="10%" align="center"><%= rs("Result") %></td>          <td width="5%" align="center"><%= rs("GoodBad") %></td>        </tr>      </table>
<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
end if
%>

<%
if page = "challenge" then
%>

<%
end if
%>
<%
if page = "messages" then
If Session("login") = True then
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db/messages.mdb")
Conn.Open DSN
strSQL = "Select * from messages order by AutoID"
Set rs = Conn.Execute(strSQL)
Do
%>
<br>
<table border="0" width="90%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">
      <table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#333333">
        <tr>
          <td align="center"><font color="white"><%= rs("Header") %></font></td>
          <td width="90" align="left"><font color="white"><%= FormatDateTime(rs("Dato"), vbShortDate) %></font></td>
          <td width="120" align="right"><font color="white"><%= rs("Author") %></font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" align="center"><%= rs("Tekst") %></td>
  </tr>
</table>

<%
rs.MoveNext
Loop While Not rs.EOF
%>
<%
else
Response.redirect "default.asp"
end if
end if
%>

<%
if page = "admin" then
If session("admin") = 1 then
%>
Here u can change, add, end remove stuff<br>
<br>
<a href='dbadmin/default.asp' target="_red">Modify Databases</a>
<%
else
Response.redirect "default.asp"
end if
end if
%>

<br>
</td>
        </tr>
      </table>
<br>
</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</center>
</body>

</html>
Avatar billede plobber Nybegynder
23. juli 2003 - 18:51 #1
kan i se hva jeg mener ???
Jeg kan ikk selv finde ud af at lave noget der tager mindre tid at loade.... kan i ???
Avatar billede netro Nybegynder
23. juli 2003 - 19:40 #2
Lad først og fremmest være med at bruge <% og %> konstant. Det giver ingen mening overhovedet og sætter bare fortolkeren på ekstra, unødvendigt arbejde! Og lav så en select case, funktion, array eller brug "elseif" i stedet for alle dine "if - end if" sætninger.

FØR:
*********************************************
<%
if page = "logout" then
session.abandon()
Response.redirect "default.asp"
end if
%>
<%
if page = "news" then
pagetitle = "News"
end if
%>
<%
if page = "about" then
pagetitle = "Stuff bout us as clan"
end if
%>
<%
if pagetitle = "" then
pagetitle = "Ingen titel"
end if
%>
*********************************************

EFTER:
*********************************************
<%
Select Case page
  Case "logout"
      session.abandon()
      Response.redirect "default.asp"
  Case "news"
      pagetitle = "News"
  Case "about"
      pagetitle = "Stuff bout us as clan"
  Case Else
      pagetitle = "Ingen titel"
End Select
%>
*********************************************
Avatar billede netro Nybegynder
23. juli 2003 - 19:47 #3
Herefter kunne du overveje mulighederne for at anvende et par include-filer. Har en fornemmelse af, at meget af din kode går igen i flere filer.
Avatar billede plobber Nybegynder
23. juli 2003 - 19:48 #4
det gør den ikk... der er kun default.asp og så min databaseadmin......
Avatar billede plobber Nybegynder
23. juli 2003 - 19:49 #5
hvorfor kommer dette:
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'pagetitle'

/mycsclan/topdesign.asp, line 36
Avatar billede plobber Nybegynder
23. juli 2003 - 19:51 #6
ligemeget... fandt fejlen
Avatar billede netro Nybegynder
23. juli 2003 - 19:54 #7
Følgende beskriver lidt om optimering af kode:
http://www.webdevelopersjournal.com/articles/asp_performance.html
Avatar billede nmh Nybegynder
23. juli 2003 - 19:54 #8
Da din kode ikke har nogle løkker udover de steder, hvor du gennemløber et recordset, men blot en række if-sætninger er kan det ikke betale sig på at bruge ret megen tid på at optimere udover de forslag, som ntroe kommer med. Du skulle måske mere bruge tiden på at gøre din kode letlæselig.

Se f.eks. hvordan netro laver indrykninger i sin select-struktur. Nogle steder har du gjort det f.eks. i nogle table-html-koder.

Det skader heller ikke med nogle kommentarer.(Det tager selvfølgelig lidt ekstra tid for serveren at springe over dem, men det er ubetydeligt.
Avatar billede plobber Nybegynder
23. juli 2003 - 19:59 #9
Jeg syns ikk det var det helt store der kom ud af det, men du får halvdelen Netro... Tak for hjælpen
Avatar billede netro Nybegynder
23. juli 2003 - 20:06 #10
Eftersom det er en ubetalt opgave, skal du ikke regne med, at nogen (ink. mig selv) gider sidde og gå hver eneste linie i gennem. Derfor fik du blot lidt hjælp til selvhjælp. Og det er faktisk en særdeles lærerig fremgangsmåde.

Men jeg siger tak for points ;)
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