If it has a plug, it's IT stuff

Sep 10 2008   3:21PM GMT

[TLBAT] Intranet : The home page

alessandro.panzetta Alessandro Panzetta Profile: alessandro.panzetta

In this post I’ll present the home page and will explain how this works….so let’s play J

First in order to have this working we need a file called adovbs.inc that can be downloaded here, this file contains all instructions for connecting to the database via ADO.The we need to download some images that will be used in the pages, the images are available here. So now go to the directorywhere your site will be hosted (E.g. c:\inetpub\wwwroot) and unzip images in a directory called images. Also create a folder named dbwhere you will save the downloads.mdb file that you created as in my previous post so in the end you will have a folder structure as follows:

c:\inetpub\wwwroot\Download_Center

c:\inetpub\wwwroot\Download_Center\images

c:\inetpub\wwwroot\Download_Center\db

Now we need to create our default.asp page, the code is at the bottom of this post. let’s discuss on this code.

It consists of some basic HTML that uses some internal subroutines to build 4 tables (see screen shot) that contain: the software available to everyone, the software for users in given groups, the patches and the goodies.

In order to dynamically build these tables a subroutine called  DoTD is called, this subroutine accepts an option that specifies whic table must be built; possible values are  STANDARD, SPECIAL,PATCH, GOODIE.

In addition to this procedure there’s also a Counter subroutine that is called by the DoTD and that shows how many times the given package has been downloaded. In order fr this to work you need a hits.mdb file (available here) where the hits will be recorded; remember to save this file in the db directory.

Once you have finished downloading the files described above, create a new default.asp page  with the following code andsave it in the root folder of your website.

For now this is enough, in the next post I’ll describe the download_special.asp file  that is the one that checks if the user visiting the page is allowed to download a certain file or not….stay tuned!!!

‘======================

 <%
Session.Timeout=10
USERID = split(Request.ServerVariables(“LOGON_USER”),”\”)
%>
<title>..:: Download Center ::..</title>
<body bgcolor=”#B1C9E9″>

<div align=”center”>
<center>

<table border=”0″ cellpadding=”0″ cellspacing=”0″ style=”border-collapse: collapse” bordercolor=”#111111″ width=”90%”>
<tr>
<td width=”100%” background=”images/tile_sub.gif”>
<p align=”center”><b><font face=”Tahoma” color=”#006699″ size=”5″>..:: Download Center ::..</font></b></p>
</td>
</tr>
</table>

<center><font color=”#006699″ size=”2″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”> </font><font size=”2″ face=”Tahoma”>
<a style=”text-decoration: none” title=”Click to see all the packages you have downloaded from this site” href=”MY_downloads.asp”><font color=”#006699″>
Click here to view your Download History</font></a><font color=”#006699″>
<img border=”0″ src=”images/dot.gif”></font></font></center><br>

<table border=”0″ cellspacing=”1″ style=”border-collapse: collapse” bordercolor=”#111111″ width=”90%” id=”AutoNumber2″>
<tr>
<td width=”100%”><font face=”Tahoma” color=”#006699″ size=”2″>By clicking the <b>DOWNLOAD</b> button you are automatically
rerouted to the closest software distribution server. <br>
Please try to avoid
software downloads through RAS.</font></td>
</tr>
</table>
</center>
</div> <table border=0 align=center cellspacing=10>
<tr><td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”>
No License Required <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b>
<font size=”2″ color=”#006699″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
</font></b><font size=”2″><b>
<font face=Tahoma color=#006699>Download</font></b></font><b><font size=”2″ color=”#006699″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”></font></b></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b>
<font size=”2″ color=”#006699″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
</font></b><font size=”2″><b>
<font face=Tahoma color=#006699>Hits</font></b></font><b><font size=”2″ color=”#006699″ face=”Tahoma”> <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Standard”
DoTD
%>
</table>
</td>
<td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”>
License Required <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Download <img border=”0″ src=”images/dot.gif”></font></b></td><td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Hits <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Special”
DoTD
%>
</table>
</td></tr>
<tr><td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> <b>Patches
</b><img border=”0″ src=”images/dot.gif”></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> </font><b>
<font face=Tahoma color=#006699 size=2>Download </font></b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> </font><b>
<font face=Tahoma color=#006699 size=2>Hits </font></b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”></font></td></tr>
<%
Which = “Patch”
DoTD
%>
</table>
</td>
<td valign=top>
<table border=2 bordercolor=#006699 cellspacing=3 cellpadding=3 align=center>
<tr><td bgcolor=#006699 align=center background=”images/tile_sub.gif”>
<font color=”#006699″ size=”2″ face=”Tahoma”><b><img border=”0″ src=”images/dot.gif”> Goodies <img border=”0″ src=”images/dot.gif”></b></font></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”> Download <img border=”0″ src=”images/dot.gif”></font></b></td>
<td bgcolor=#006699 align=center background=”images/tile_sub.gif”><b><font color=”#006699″ size=”2″ face=”Tahoma”><img border=”0″ src=”images/dot.gif”>
Hits <img border=”0″ src=”images/dot.gif”></font></b></td></tr>
<%
Which = “Goodie”
DoTD
%>
</table>
</td></tr>
</table>

<%
Sub DoTD()
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch
Set cnnSearch = Server.CreateObject(“ADODB.Connection”)
cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/downloads.mdb”) & “;”
strSQL = “SELECT * FROM Packages WHERE (((Packages.PackageType)=’” & WHICH & “‘)) ORDER BY Packages.PackageName;”

Set rstSearch = cnnSearch.Execute(strSQL)
Do While Not rstSearch.EOF
Package = rstSearch.Fields(“PackageDesc”).Value
File =  rstSearch.Fields(“PackageName”).Value

If WHICH = “Special” then
response.write “<tr><td><font face=tahoma color=#006699 size=1><b>” & Package  & “</td><td><a href=download_special.asp?File=” & File & “&UserName=” & USERID(1) & “><img border=0 src=images/downloadnow.gif alt=’This page may take some time to load due to the license checking procedures, please be patient.’></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext

ElseIf WHICH = “Patch” then
response.write “<tr><td><font face=tahoma color=#006699 size=1><img src=images/alert.gif> <b>” & Package  & “</td><td><a href=download.asp?File=” & File & “><img  border=0 src=images/downloadnow.gif alt=Please download/apply this Patch asap!></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext
Else
response.write “<tr><td><font face=tahoma color=#006699 size=1><b>” & Package  & “</td><td align=center><a href=download.asp?File=” & File & “><img  border=0 src=images/downloadnow.gif alt=’This software is approved by EIT.’></a></td>”
response.write Counter(File) & “</tr>”
rstSearch.MoveNext
End if
Loop

Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End Sub

Function Counter(FILENAME)
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch
Set cnnSearch = Server.CreateObject(“ADODB.Connection”)
cnnSearch.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & Server.Mappath(“db/hits.mdb”) & “;”
strSQL = “SELECT Count(downloads.Package) AS HITS FROM downloads WHERE (((downloads.Package)=’” & FILENAME & “‘));”
Set rstSearch = cnnSearch.Execute(strSQL)

Do While Not rstSearch.EOF
response.write “<td align=center><b><font face=tahoma size=1 color=006699>” & rstSearch.Fields(“HITS”).Value & “</font></td>”
rstSearch.MoveNext
Loop

Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End Function

%>

‘======================

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: