<% '#FILE: updated.asp - Version 1.0 '# '# This asp script will automatically determine and print an '#"updated" image and/or the date a specified file was last "updated". '# '#INSTALLATION: '# There are many ways this script can be installed and used. The procedure '#is what I recommend for ASP beginners. If you're more advanced and know '#what you're doing, by all means feel free to install this script however '#you wish. '# '# 1) Save the ASP code in a separate file entitled "updated.asp" '#in your root web directory '# '# 2) In your ASP files where you will have the "updated" information '#displayed, be sure to "include" the "updated.asp" file. '# EXAMPLE: '# '# 3) Set the value for UPDATED_IMAGE_URL to be the URL to the '#"updated" image you wish to have displayed. '# '# 4) Call the function "PrintUpdatedInfo" with the appropriate '#parameters as described below wherever you wish to have the "updated" '#notification displayed. '# EXAMPLES: '# PrintUpdatedInfo ("F:/Inetpub/wwwroot/test.asp",3,2) '# PrintUpdatedInfo ("F:/Inetpub/wwwroot/test.asp|F:/Inetpub/wwwroot/default.asp",7,0) '# '#RUNNING: '# The function "PrintUpdatedInfo" requires 3 parameters: '# PrintUpdatedInfo (files,days,mode) '# described below: '# '# 1) files '# the actual file or files to test for their last modification date. This parameter '#should be the FULL OPERATING SYSTEM PATH, AND NOT A URL!!! The file(s) to test can '#be ANY file. '# To test multiple files, separate each file with a pipe "|" character. This is especially '#useful for HTML "frame" pages. That is, suppose you have a table of contents page and the main '#information page, and you want "updated" printed whenever either one of those two pages is updated. '# EXAMPLES: '# F:/Inetpub/wwwroot/scripts/some_file.php '# F:/Inetpub/wwwroot/images/myself.jpg|F:/Inetpub/wwwroot/index.html '# F:/Inetpub/wwwroot/default.asp '# '# 2) days '# the number of days previous to today's date "files" should have been updated '# to have the "updated" info displayed. Specifying "-1" means no limit and the '# "updated" info will always be printed. '# EXAMPLES: '# i) If "today" is the 27th, the file "test.html" was updated on the 21st, and $days '#is specified to be 4, the "updated" would NOT be displayed because test.html was not '#updated within the last 4 days. '# ii) If "today" is the 27th, the file "test.html" was updated on the 21st, and $days '#is specified to be 7, the "updated" WOULD be displayed because test.html was '#updated within the last 7 days. '# iii) If "today" is the 27th, the file "test.html" was updated on the 21st, and $days '#is specified to be -1, the "updated" WOULD always be displayed. '# '# 3) mode '# Can only be one of three integer values: '# 0 : Print both the "updated" image and the textual date '# 1 : Print the "updated" image only '# 2 : Print the textual date only of the file's last update '# '#EXAMPLE USES (last two show testing of multiple files) : '#PrintUpdatedInfo("F:/Inetpub/wwwroot/scripts/updated/updated.php",3,1) '#PrintUpdatedInfo("/usr/local/public_html/menu.html",-1,1) '#PrintUpdatedInfo("F:/Inetpub/wwwroot/default.asp|F:/Inetpub/wwwroot/info/index.html|F:/Inetpub/wwwroot/whatever.html",5,0) '#PrintUpdatedInfo("/var/usr/public_html/images/logo.gif|/var/usr/public_html/images/me.jpg",8,2) '# '#LICENSE: '# Finally, this "basic" code is free, and comes with absolutely NO '#warranties, either expressed or implied. Feel free to do what you want '#with it. Feel free to build upon it. If you did not get this code '#from http://www.davelozinski.com, you don't have the original. '# '#REVISION HISTORY: '# 05/29/01 Original Version '# '#CONTACT INFORMATION: '# http://www.davelozinski.com/cgi-bin/email_lozinski.pl '######################################################## Sub PrintUpdatedInfo (files,days,mode) '#the URL to the "updated" image you wish to have displayed. Const UPDATED_IMAGE_URL = "/gfx/updated.gif" Dim fso, fileobject, updated_date, filedate, file_arr, error, x Set fso = Server.CreateObject("Scripting.FileSystemObject") error = False file_arr = Array() file_arr = Split(files,"|") For x = 0 to UBound(file_arr) If (NOT fso.FileExists(file_arr(x))) Then Response.Write ("ERROR! File """ & file_arr(x) & """ does not exist!
") error = True End If Next If (VarType(days) <> vbInteger) Then Response.Write ("ERROR! The 2nd parameter must be a whole number greater than or equal to -1!
") error = True ElseIf (Cint(days) < -1) Then Response.Write ("ERROR! The 2nd parameter must be a whole number greater than or equal to -1!
") error = True End If If (mode <> 0 AND mode <> 1 AND mode <> 2) Then Response.Write ("ERROR! The 3rd parameter can only be 0, 1, or 2!
") error = True End If If (NOT error) Then For x = 0 to UBound(file_arr) Set fileobject = fso.GetFile(file_arr(x)) updated_date = CDate(Month(CDate(fileobject.DateLastModified)) & "/" & Day(CDate(fileobject.DateLastModified)) & "/" & Year(CDate(fileobject.DateLastModified))) filedate = CDate(Month(Date) & "/" & Day(Date) & "/" & Year(Date)) If (days = -1 OR (DateDiff("d",updated_date,filedate) < days)) Then If (mode = 0 OR mode = 1) Then '#Print the "updated" image Response.Write ("") End If If (mode = 0 OR mode = 2) Then '#Print the "updated" date Response.Write (updated_date) End If Exit For End If Next End If '#!error Set fileobject = Nothing Set fso = Nothing End Sub '#PrintUpdatedInfo '######################################################## %>