<% '********************************************************************************************** ' Application Name: webCore (project Lotsadew) Version: 0.1.1 '********************************************************************************************** %> <% '********************************************************************************************** ' Site Engine made by Sean M. Raymond, 10-30-2001 ' ' Last modified: 12-07-2001 By: Sean M. Raymond ' ' Enhanced By: ' Kevin Drake 12-07-2001 Section(s): xxxx, xxxx ' ... ' ' This is basically a centralized frame site without frames. Although, the centralized ' concept can be used for any type of design plugged into this. The code below also allows for ' filtering tags / content to enhance browser compatibility and control over public posting. ' Use it, fix it, expand it, but please give and receive due credit as it evolves... ' ' As portions are fixed, added, etc.. please send code copies to: ' sraymond@cmtc.net, rboucher@cmtc.net and webmaster@cmtc.net ' '********************************************************************************************** %> <% '********************************************************************************************** ' Notes: ' ' -Work Needed ' *) Add error trap for missing / broken links ' *) Fix ASPTear issue that requires all Request.QueryString to Request.Form ' *) Complete coding for filtering of browsers that won't work with engine ' *) Port code beyond Win2K/IIS5.0 and into PHP if possible ' *) Allow for error pages to appear within the site's basic design (defined below) ' *) Add ability to email webmaster / dev contact the error, ref page, interesting ' info to alert of and help fix issues within the site ' *) Work on condensing code, rewriting portions that were coded oddly because the initial ' dev (Sean) didn't know better at the time, also writing sections to improve function ' and options to other people ' *) Find out and comment what 'strRedirPathFix =' was used to specifically fix ' *) Work on browser compatibility filters section ' ' ' -ASPTear ' The ASPTear component (http://www.alphasierrapapa.com/iisdev/components/asptear/) is used ' to process all pages with ASP content and return the response back for further ' modification by this engine as a varianble. There are a couple conditions created that ' the web developer must currently (12-07-2001) keep in mind. ' 1) All pages that use ASP links must have the standard tag set located somewhere in the ' page, so the engine can detect ASP content in the page, even if no actual code other ' than the redirect exists ' 2) All pages that use Request.QueryString to pull passed variables must be changed to ' Request.Form. This is something that I did to fixed a null variable issue with the ' ASPTear component. It may be fixable with changes in the ASPTear usage (GET/POST), ' or with future versions of ASPTear (version at original development is 1.0 ' 3) An issue occurred with the "&" QueryString delimeter because the second QS sent to ' the page would lose the invalid "&var=", but everything after would be passed to the ' engine asp, instead of the variable I wanted it to go to. This was fixed by ' dynamically changing all links with QS to "?" as the delimeter for all variables, and ' then changing all after the initial "?" back to "&" in the variable. It may be ' necessary to manually use "?" to delimit the variables if you use scripting to ' generate a QS outside of the standard "var=x&" filtering string format. ' '********************************************************************************************** %> <% '============================================================================================== '| Detect Worthless Browsers and redirect to incompatibility explanation / browser upgrade '============================================================================================== strBrowserApp = Request.ServerVariables("HTTP_USER_AGENT") If strBrowserApp = "UNUSED-FOR-NOW" Then 'Response.Redirect "$$incompatible/index.html" End If %> <% '============================================================================================== '| Set Browser specific options for static portion of pages (designed in html towards bottom '============================================================================================== strBrowserVersion = Request.ServerVariables("HTTP_USER_AGENT") strIECheck = Instr(1, strBrowserVersion, "MSIE") strNetscape6Check = Instr(1, strBrowserVersion, "Netscape6") strLynxCheck = Instr(1, strBrowserVersion, "Lynx") strKonquerorCheck = Instr(1, strBrowserVersion, "Konqueror") If (strIECheck OR strNetscape6Check OR strKonquerorCheck) Then strPageWidth = "100%" strLogoRemainder = "" strMenuRemainder = "" strStylesEnabled = "" strStylesClassSideMenu = "class='sideMenu'" strStylesClassTopMenu = "class='topMenu'" strStylesInvertedScheme = "class='invertedScheme'" Else strPageWidth = "780" strLogoRemainder = "450" strMenuRemainder = "675" strStylesEnabled = "" strStylesClassSideMenu = "" strStylesClassTopMenu = "" strStyledInvertedScheme = "" End If If (strLynxCheck) Then strPhraseBreak = "" strPhraseBreakClose = "" strTableSpace = "

" Else strPhraseBreak = "
" strPhraseBreakClose = "
" strTableSpace = "" End If If (strIECheck) Then strMarqueeOpen = "" strMarqueeClose = "" strMarqueeText = "Update: CMTC has a new Website! - Please enjoy the changes that are occurring and respond with questions, suggestions, or complaints... Something missing? Can't find what you're looking for? Please email the webmaster at sraymond@cmtc.net - For a limited time, CMTC's old website can still be viewed at http://www.cmtc.net/website" Else strMarqueeOpen = "" strMarqueeClose = "" strMarqueeText = "" End If strCatalogFontFix = "" strPageHeaderOutput = "" strPageHeight = "100%" %> <% '============================================================================================== '| Define default constants and variables used by code within the engine (not design mods) '============================================================================================== Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateTrue = -1, TristateFalse = 0, TristateUseDefault = -2 Const strSysRoot = "E:\" Const strSysWebRoot = "public-websites\www-cmtc-net\" Const strOSDelimeter = "\" Const strProtocol = "http://" Const strSiteRoot = "63.82.76.100/" Const strDocumentRoot = "$$content/" Const strErrorRoot = "$$errors/" Const strProfileRoot = "$$profiles/" Const strAllowedRoots = "$$content/, $$errors/, $$profiles/" Const strQuote = "" Const strASPOpen = "" Const strASPClose = "" strRedirPathFix = "X" strRefQueryString = "" %> <% '============================================================================================== '| Process Ref URL for use in engine '============================================================================================== strSiteBase = strProtocol & strSiteRoot strSysBase = strSysRoot & strSysWebRoot If Request.QueryString("refPage") > "" Then strRefPage = Request.QueryString("refPage") '-= [Verify valid URLS sent to engine and refine URL to ideal structure] =-' If Left(strRefPage, 2) <> "$$" Then intExtractPoint = Instr(1, strRefPage, "$$") If intExtractPoint < 1 Then Response.Redirect (strPageBase & strErrorRoot & "invalid_url.asp?def=no-root-start") End If strRefPage = Replace(strRefPage, Left(strRefPage, intExtractPoint - 1), "") End If intExtractEnd = Instr(1, strRefPage, "/") If intExtractEnd < 1 Then Response.Redirect (strPageBase & strErrorRoot & "invalid_url.asp?def=no-root-end") End If strRequestedRoot = Left(strRefPage, intExtractEnd) If Instr(1, strAllowedRoots, strRequestedRoot) < 1 Then Response.Redirect (strPageBase & strErrorRoot & "invalid_url.asp?def=no-root-valid") End If strRefPage = Replace(strRefPage, strRequestedRoot, "") strMarqueeOpen = "" strMarqueeClose = "" strMarqueeText = "" Else '-= [Set default page content loaded with initial visit] =-' strRequestedRoot = "$$profiles/" strRefPage = "index.asp" End If %> <% '============================================================================================== '| Allow for page filtering based on the raw URL / user location in website '============================================================================================== '-= [URL QueryString Passing fix for ASP content, see ASPTear note at top] =-' intQueryStringStart = Instr(1, strRefPage, "?") If intQueryStringStart > 0 Then strRefQueryString = Right(strRefPage, Len(strRefPage) - intQueryStringStart) strRefQueryString = Replace(strRefQueryString, "?", "&") strRefPage = Replace(strRefPage, Right(strRefPage, Len(strRefPage) - intQueryStringStart + 1), "") End If strRefExt = Right(strRefPage, 3) '-= [Redirection of links that refer to objects that would be processed and returned oddly] =-' If (strRefExt = "pdf") OR (strRefExt = "gif") OR (strRefExt = "jpg") OR (strRefExt = "bmp") OR (strRefExt = "exe") OR (strRefExt = "zip") Then Response.Redirect strRequestedRoot & strRefPage End If '-= [Page Adjustments based on location within the site] =-' ' '-= UNIQUE to whomever uses this engine until the end of this section intExistingMenu = 0 If Instr(1, strRefPage, "catalog") > 0 AND Instr(1, strRefPage, "catalog") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "catalog") If (strIECheck OR strNetscape6Check) Then strCatalogAlignmentOpen = "" strCatalogAlignmentClose = "" strMenuRemainder = "820" strPageHeight = "1000" intNumberOfCategories = 9 Dim arrayStartLimits(), arrayEndLimits(), Directories() ReDim arrayStartLimits(intNumberOfCategories) ReDim arrayEndLimits(intNumberOfCategories) ReDim arrayDirectories(intNumberOfCategories) intPlaceFlag = 1 strDisplayPrev = "x" strDisplayNext = "x" strThisPage = strSiteBase & strRequestedRoot & strRefPage strCatalogFontFixOpen = "" strCatalogFontFixClose = "" arrayDirectories(1) = "general_information" arrayStartLimits(1) = 2 arrayEndLimits(1) = 5 arrayDirectories(2) = "admissions" arrayStartLimits(2) = 8 arrayEndLimits(2) = 12 arrayDirectories(3) = "tuition_and_fees" arrayStartLimits(3) = 14 arrayEndLimits(3) = 15 arrayDirectories(4) = "financial_aid" arrayStartLimits(4) = 18 arrayEndLimits(4) = 20 arrayDirectories(5) = "student_services" arrayStartLimits(5) = 22 arrayEndLimits(5) = 25 arrayDirectories(6) = "academic_affairs" arrayStartLimits(6) = 28 arrayEndLimits(6) = 36 arrayDirectories(7) = "programs_of_study" arrayStartLimits(7) = 38 arrayEndLimits(7) = 87 arrayDirectories(8) = "course_descriptions" arrayStartLimits(8) = 90 arrayEndLimits(8) = 131 arrayDirectories(9) = "people_and_personnel" arrayStartLimits(9) = 134 arrayEndLimits(9) = 147 strPageHeaderOutput = "" strPageHeaderOutput = strPageHeaderOutput & "Index of CMTC's Catalog -   A - L    M - Z   " If Instr(1, strThisPage, "college_catalog_") > 0 Then intCurrentPageNumber = CInt( Mid( strThisPage, Instr(1, strThisPage, "college_catalog_") + 16, Len(strThisPage) - (Instr(1, strThisPage, "college_catalog_") + 16) - 4 ) ) Do While (intPlaceFlag <> intNumberOfCategories + 1) If (intCurrentPageNumber >= arrayStartLimits(intPlaceFlag)) AND (intCurrentPageNumber <= arrayEndLimits(intPlaceFlag)) Then If (intCurrentPageNumber > arrayStartLimits(intPlaceFlag)) Then strDisplayPrev = "index.asp?refPage=$$content/catalog/" & arrayDirectories(intPlaceFlag) & "/college_catalog_" & (intCurrentPageNumber - 1) & ".html" End If If (intCurrentPageNumber < arrayEndLimits(intPlaceFlag)) Then strDisplayNext = "index.asp?refPage=$$content/catalog/" & arrayDirectories(intPlaceFlag) & "/college_catalog_" & (intCurrentPageNumber + 1) & ".html" End If End If intPlaceFlag = intPlaceFlag + 1 Loop If (strDisplayPrev <> "x") OR (strDisplayNext <> "x") Then strPageHeaderOutput = strPageHeaderOutput & " [ " If (strDisplayPrev <> "x") Then strPageHeaderOutput = strPageHeaderOutput & " << Prev  " Else strPageHeaderOutput = strPageHeaderOutput & "        " End If strPageHeaderOutput = strPageHeaderOutput & " | " If (strDisplayNext <> "x") Then strPageHeaderOutput = strPageHeaderOutput & "  Next >> " Else strPageHeaderOutput = strPageHeaderOutput & "        " End If strPageHeaderOutput = strPageHeaderOutput & " ]" End If strPageHeaderOutput = strPageHeaderOutput & "" End If Else Response.Redirect ("$$incompatible/index.html") End If Else strCatalogAlignmentOpen = "" strCatalogAlignmentClose = "" End If If Instr(1, strRefPage, "career_connection") > 0 AND Instr(1, strRefPage, "career_connection") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "career_connection") strPageHeaderOutput = "Job Listing" & " · " & _ "Company Links" & " · " & _ "List A Job" End If If Instr(1, strRefPage, "corporate_community") > 0 AND Instr(1, strRefPage, "corporate_community") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "corporate_community") strPageHeaderOutput = "Services" & " · " & _ "Courses / Workshops" & " · " & _ "Oxford Hills Center" & " · " & _ "Certificate Programs" End If If Instr(1, strRefPage, "distance_learning") > 0 AND Instr(1, strRefPage, "distance_learning") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "distance_learning") strPageHeaderOutput = "Online Courses" & " · " & _ "FAQs" & " · " & _ "Tutorials" & " · " & _ "Support" End If If Instr(1, strRefPage, "employment_opportunities") > 0 AND Instr(1, strRefPage, "employment_opportunities") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "employment_opportunities") strPageHeaderOutput = "Current Listing" & " · " & _ "Recent Jobs" End If If Instr(1, strRefPage, "news") > 0 AND Instr(1, strRefPage, "news") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "news") strPageHeaderOutput = "Press Releases" & " · " & _ "Upcoming Events" End If If Instr(1, strRefPage, "course_schedule") > 0 AND Instr(1, strRefPage, "course_schedule") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "course_schedule") strPageHeaderOutput = "Current Semester" & " · " & _ "Next Semester" & " · " & _ "Course Descriptions" & " · " & _ "Registering" End If If Instr(1, strRefPage, "athletics") > 0 AND Instr(1, strRefPage, "athletics") > intExistingMenu Then intExistingMenu = Instr(1, strRefPage, "athletics") strPageHeaderOutput = "Men's Basketball" & " · " & _ "Baseball" & " · " & _ "Soccer" & " · " & _ "Hockey" & " · " & _ "Women's Basketball" & " · " & _ "Summer Camp" & " · " & _ "Tournament" End If %> <% '============================================================================================== '| Break down raw URL into Path / File, concatenate into generic System / Web paths '============================================================================================== intExtractStart = 1 intExtractTemp = 1 intExtractPoint = 0 Do While intExtractTemp > 0 intExtractTemp = Instr(intExtractStart, strRefPage, "/") If intExtractTemp > 0 Then intExtractPoint = intExtractTemp intExtractStart = intExtractTemp + 1 End If Loop If intExtractPoint > 0 Then strRefPath = Left(strRefPage, intExtractPoint) strRefPage = Replace(strRefPage, strRefPath, "") Else strRefPath = "" End If strRequestedURL = strSiteBase & strRequestedRoot & strRefPath & strRefPage strSystemURL = strSysBase & Replace(strRequestedRoot, "/", strOSDelimeter) & Replace(strRefPath, "/", strOSDelimeter) & Replace(strRefPage, "/", strOSDelimeter) %> <% '============================================================================================== '| Open File into FSO for determination of ASP code, or processing of plain HTML page '============================================================================================== Set fso = CreateObject("Scripting.FileSystemObject") Set fsoPage = fso.OpenTextFile(strSystemURL, ForReading, TristateUseDefault) strPageContent = fsoPage.ReadAll() strPageContent = Replace(strPageContent, Chr(34) , strQuote) strPageContent = Replace(strPageContent, Chr(60) & Chr(37), strASPOpen) strPageContent = Replace(strPageContent, Chr(37) & Chr(62), strASPClose) %> <% '============================================================================================== '| Detect and process pages that have ASP content in them, return for adjustments '============================================================================================== If Instr(1, strPageContent, strASPOpen) > 0 Then If Instr(1, strPageContent, "strRedirPathFix = ") > 0 Then '-= I think I used this IfThen to fix ASP redirect pages that had URL issues in subfolders, ' but at this point of commenting can't really remember for sure, see notes section strPageContent = Replace(strPageContent, Chr(34) , strQuote) intPathFixFound = Instr(1, strPageContent, "strRedirPathFix = ") intPathFixStart = intPathFixFound + Len("strRedirPathFix = " & strQuote) strRedirPathFix = Mid(strPageContent, intPathFixStart, Instr(intPathFixStart + 1, strPageContent, strQuote) - intPathFixStart) End If Set objDynPage = CreateObject("SOFTWING.ASPTear") Response.ContentType = "text/html" On Error Resume Next ' URL, Action (1=Post,2=Get), Vars, U/N, PWD strPageContent = objDynPage.Retrieve(strRequestedURL, 1, strRefQueryString, "", "") End If strPageContent = Replace(strPageContent, Chr(34) , strQuote) %> <% '============================================================================================== '| Dynamically fix all relative links in pages to static locations within the site '============================================================================================== Function fncLinkFilter(strKeyName, strKeyMode) strKeyUsed = "" strKeyUsed = strKeyName & strQuote intExtractStart = 1 intExtractTemp = 1 intExtractPoint = 0 If strRedirPathFix <> "X" Then strSkew = strRedirPathFix Else strSkew = "" End If Do While intExtractTemp > 0 strWorkingURL = "" intExtractTemp = Instr(intExtractStart, strPageContent, strKeyUsed) If intExtractTemp > 0 Then intExtractPoint = intExtractTemp intExtractStart = intExtractTemp + 1 strRefURL = Mid(strPageContent, intExtractPoint + Len(strKeyUsed), Instr(intExtractPoint + Len(strKeyUsed), strPageContent, strQuote) - (intExtractPoint + Len(strKeyUsed))) If Left(strRefURL, 7) <> "mailto:" AND Left(strRefURL, 7) <> "http://" AND Left(strRefURL, 1) <> "#" Then intRootCheckPoint = Instr(1, strRefURL, "$$") If intRootCheckPoint > 0 Then strRootCheck = Mid(strRefURL, intRootCheckPoint, Instr(intRootCheckPoint + 1, strRefURL, "/") - intRootCheckPoint) If Instr(1, strAllowedRoots, strRootCheck) > 0 Then strWorkingURL = Mid(strRefURL, intRootCheckPoint, Len(strRefURL) - intRootCheckPoint + 1) Else strWorkingURL = "" End If Else strWorkingURL = "" End If If strWorkingURL = "" Then strWorkingURL = strRequestedRoot & strRefPath & strSkew & strRefURL End If If strKeyMode = "PAGE" Then strWorkingURL = "index.asp?refPage=" & strWorkingURL ElseIf strKeyMode = "OBJ" Then strWorkingURL = strSiteBase & strWorkingURL End If strWorkingURL = Replace(strWorkingURL, "&", "?") If (Instr(1, strWorkingURL, "../") > 0) Then Do intRelativeStart = Instr(1, strWorkingURL, "../") intRelativeRootFindStart = 1 intRelativeRootFindLast = 0 intRelativeRootFindCurrent = 0 Do intRelativeRootFindCurrent = Instr(intRelativeRootFindStart, strWorkingURL, "/") If (intRelativeRootFindCurrent > intRelativeRootFindLast) AND (intRelativeRootFindCurrent < intRelativeStart - 1) Then intRelativeRootFindLast = intRelativeRootFindCurrent End If If (intRelativeRootFindCurrent > 0) Then intRelativeRootFindStart = intRelativeRootFindCurrent + 1 End If Loop Until (intRelativeRootFindCurrent = 0) OR (intRelativeRootFindCurrent > intRelativeStart) strRelativeRemove = Mid(strWorkingURL, intRelativeRootFindLast + 1, intRelativeStart + 3 - intRelativeRootFindLast - 1) strWorkingURL = Replace(strWorkingURL, strRelativeRemove, "") Loop Until (Instr(1, strWorkingURL, "../") = 0) End If strPageContent = Replace(strPageContent, strKeyUsed & strRefURL, strKeyUsed & strWorkingURL) End If End If Loop End Function Call fncLinkFilter("src=", "OBJ") Call fncLinkFilter("SRC=", "OBJ") Call fncLinkFilter(".src = ", "OBJ") Call fncLinkFilter(".location = ", "PAGE") Call fncLinkFilter("href=", "PAGE") Call fncLinkFilter("action=", "PAGE") '>> I would suggest sticking to a convention, such as "=" is filtered, but " = " isn't, in the case '>> of wanted to put an unfiltered link like "JavaScript:" etc... for all purposes in this engine, '>> the convention has followed "x=x" is filtered, any other variations "x =x" "x = x" etc is left '>> untouched. This can vary depending on the style you used to make all the existing pages... %> <% '============================================================================================== '| Find and clear any ASP code within a page, UNUSED with ASPTear running, but necessary if '| the pages are not processed and opened within the FSO and displayed as plain HTML. Not '| overly useful now that ASPTear accomplishes what I couldn't before, but I figured the code '| may benefit ..someone? '============================================================================================== strKeyAlt = "=" intExtractStart = 1 intExtractTemp = 1 intExtractPoint = 0 Do While intExtractTemp > 0 strASPBlock = "" intExtractTemp = Instr(intExtractStart, strPageContent, strASPOpen) If intExtractTemp > 0 Then intExtractPoint = intExtractTemp intExtractStart = intExtractTemp + 1 strASPBlock = Mid(strPageContent, intExtractPoint + Len(strASPOpen), Instr(intExtractPoint + Len(strASPOpen), strPageContent, strASPClose) - (intExtractPoint + Len(strASPOpen))) If Left(strASPBlock, 1) = "=" Then strProcessASP = Replace(Right(strASPBlock, Len(strASPBlock) - 1), strQuote , Chr(34)) Else strProcessASP = Replace(strASPBlock, strQuote , Chr(34)) End If strPageContent = Replace(strPageContent, strASPOpen & strASPBlock & strASPClose, "") intExtractStart = 1 End If Loop %> <% '============================================================================================== '| Browser Compatibility Filters '============================================================================================== '>> Write Filter tags en mas or one by one to accomodate problems '>> '>> Not sure how this will integrate / function, although I initially pictured it similar to '>> the Relative Link filtering performed above. The trick is filtering of what _ tags, '>> propteries, etc depending on which _ browsers, and possibly for where _ in the web that '>> the filtering is done. '>> '>> For example, cmtc.net used the Magellan plugin to Acrobat for converting our PDF catalog '>> into a series of .html documents that would be easily, nearly exact replicas of the viewed '>> PDF document. However, CSS styles and absolute positioning are used to accomplish this. '>> One challenge is to process these pages so that all s are replaced into something '>> that is compatible with other browsers, such as Netscape 4.x. This would only be done to '>> fix those specific pages, and not general to all uses of within the site.... %> <% '============================================================================================== '| Respond processed page to user within the graphical structure you design '============================================================================================== '-= [Replace All Temp Tags for Quotes, ASP, etc] =- strPageContent = Replace(strPageContent, strQuote , Chr(34)) %> Central Maine Technical College · ©1996-2002 · All Rights Reserved <%= strStylesEnabled %>
Central Maine Technical College
>

Home | News | College Catalog | Search | Site Index | Help


colspan="2" align="center"> <%= strMarqueeOpen %>  <%= strMarqueeText %><%= strMarqueeClose %><%= strPageHeaderOutput %>

> Library

> Athletics

> Career Connection

> Course Schedule

> Distance Learning

> Corporate & <%= strPhraseBreak %>Community<%= strPhraseBreakClose %>

> Organizational <%= strPhraseBreak %>Information<%= strPhraseBreakClose %>

> Employment <%= strPhraseBreak %>Opportunities<%= strPhraseBreakClose %>

> Departments

<%= strCatalogFontFixOpen %><%= strTableSpace %> <%= strCatalogAlignmentOpen %>  <%= strPageContent %> <%= strCatalogAlignmentClose %> <%= strCatalogFontFixClose %>
colspan="2" align="center"> <%= strPageHeaderOutput %>

<% '============================================================================================== '| Close all open objects (for security, resource, etc reasons '============================================================================================== fsoPage.Close Set fsoPage = Nothing Set objDynPage = Nothing Set fso = Nothing %>