%'@ LANGUAGE = VBScript.Encode %><% ' Infolink Page Content Manager for IIAs - content.asp ' ' This file is the main PCM engine for Infolink Industry Applications. Currently, ' it can read and save content files (*.INC) and view, delete and upload images. ' ' José Natividad Dévora Espino ' Infolink ' ' Version: 1.1.4 (06/22/2004) ' Multiple languages support. Meta data and Content stored in data base. ' ' Carlos A. Madrigal ' Infolink ' ' Version: 1.1.3 (09/13/2002) ' I left open a minor glitch. Code wasn't handling ../images relative reference. ' Now it converts ../images to images/. ' ' Version: 1.1.2 (09/13/2002) ' Image path bug fix didn't behave consistently. I used regular expressions ' to find current URL while writing content files. With regular expressions ' I search and delete any absolute references. Please see the Initializaction ' phase of the script to see how I build the pattern for the regular expressions ' and the "save" case to see how I applied to the saving process. ' ' Version: 1.1.1 (09/04/2002) ' Image path in HTML Editor bug fixed. The bug consisted in that the engine ' wasn't correcting the image path difference (normal site vs administration ' site) and therefore, you can always look the image in the admin system but ' not in the front-end. ' ' Content configuration was split to another page. In the past, to configure ' content was easier than the first version. However, when we started to ' encode our scripts, content configuration become a pain on the back because ' we had to use the unencoded file version, make our changes, and then encode ' it again. %> <%sDBExtraPath = "../"%> <% Const INCLUDE_FOLDER = "../include/content/" Const IMAGE_FOLDER = "../images/" Const IMAGE_FOLDER_TRANSFORMED = "images/" Dim asPages, dicTables, asImages, asImageCaptions, sItem, iItem Dim dicPageBeingEdited Dim sHEImagePath Dim objFSO, objMetaFile, objFile, sPageContent, sMetaContentVariables Dim sCmd, UploadRequest Dim iImgW, iImgH, iImgDepth, sImgType, sImgData Dim sPathToTrimPattern ' Initialize script Set dicPageBeingEdited = Server.CreateObject("Scripting.Dictionary") dicPageBeingEdited.Add "Name", Request("page") & "" Set dicTables = Server.CreateObject("Scripting.Dictionary") sHEImagePath = "common/htmleditor2/" Set objFSO = Server.CreateObject("Scripting.FileSystemObject") sCmd = Request("cmd") ' !!!!!! IMPORTANT, PLEASE READ !!!!!!! ' The following code determines the current path and it substracts the admin ' folder. It does this to trim all reference to absolute images or links. ' The reason why this comment is so important is because this code assumes ' that the admin subdirectory is just below the root. If this is not true, ' please adjust the code to your needs. ' ' Here is how it works, the code tries to create a regular expression that ' matches the URL that the user has on her browser. sPathToTrimPattern = Request.ServerVariables("PATH_INFO") sPathToTrimPattern = Left(sPathToTrimPattern, InStr(1, sPathToTrimPattern, "/admin", 1)) sPathToTrimPattern = "https?://" & Request.ServerVariables("SERVER_NAME") & "(:" & Request.ServerVariables("SERVER_PORT") & ")?" & sPathToTrimPattern ' Load content configuration %> <% ' Transforms the HTML string into a valid Javascript string. ' sContent Content to be transformed Function HtmlToJSString(sContent) HtmlToJSString = Replace(sContent, vbCr, "") HtmlToJSString = Replace(HtmlToJSString, vbLf, "") HtmlToJSString = Replace(HtmlToJSString, """", "\""") HtmlToJSString = Replace(HtmlToJSString, "'", "\'") End Function Select Case sCmd Case "del" DeleteFile Request("file") ' Reload page Response.Redirect "content.asp?page=" & Server.URLEncode(dicPageBeingEdited("Name")) Case "save" ' Parse request (for file uploads) Set UploadRequest = Server.CreateObject("Scripting.Dictionary") BuildUploadRequest Request.BinaryRead(Request.TotalBytes) ' Get data sPageTitle = URequest("title") sPageKeywords = URequest("keywords") sPageDescription = URequest("description") sPageContent = URequest("content") sPageHeading = URequest("heading") ' Write content page Set re = New RegExp re.IgnoreCase = True re.Multiline = True re.Global = True re.Pattern = "http[^""]+/admin/content.asp[^#]+#" sPageContent = re.Replace(sPageContent, "#") re.Pattern = "http[^""]+/admin/" sPageContent = re.Replace(sPageContent, "") re.Pattern = sPathToTrimPattern sPageContent = re.Replace(sPageContent, "") re.Pattern = "admin/" sPageContent = re.Replace(sPageContent, "") sPageContent = Replace(sPageContent, IMAGE_FOLDER, IMAGE_FOLDER_TRANSFORMED) With rsData sSQL = "SELECT * FROM PCMPages WHERE PageID='" & dicPageBeingEdited("Name") & "' AND LangID=" & iContentLang .Open sSQL,,1,2,1 .Fields("Title") = sPageTitle .Fields("Keywords") = sPageKeywords .Fields("Description") = sPageDescription .Fields("Content") = sPageContent .Fields("Heading") = sPageHeading .Update .Close End With ' Save images for this page asImageCaptions = Split(dicPageBeingEdited("ImageCaptions"), ";") asImages = Split(dicPageBeingEdited("ImageFiles"), ";") For iItem = LBound(asImages) To UBound(asImages) sImgData = URequest(asImageCaptions(iItem)) BinaryWriteFile IMAGE_FOLDER + asImages(iItem), sImgData Next ' Reload page Response.Redirect "content.asp?page=" & Server.URLEncode(dicPageBeingEdited("Name")) Case Else ' Load page variables If Len(dicPageBeingEdited("Name")) > 0 Then Set rsPCM = conDB.Execute("SELECT Title, Description, Keywords, Content, Heading FROM PCMPages WHERE PageID='" & dicPageBeingEdited("Name") & "' AND LangID=" & iContentLang) If Not IsRSEmpty(rsPCM) Then sPageTitle = rsPCM("Title") sPageKeywords = rsPCM("Keywords") sPageDescription = rsPCM("Description") sPageHeading = rsPCM("Heading") sPageContent = rsPCM("Content") & " " sPageContent = Replace(sPageContent, IMAGE_FOLDER_TRANSFORMED, IMAGE_FOLDER) End If End If End Select %> <% If Len(dicPageBeingEdited("Name")) = 0 Then %>
<%=langMgr.GetContent("CM_CONTENT_INTRO", "BackEndMessages", iInterfaceLang)%>
| ><%=langMgr.GetContent("CM_PGCONTENT_SECTION", "BackEndMessages", iInterfaceLang)%> | ||
| >
<%
Set rsPCM = conDB.Execute("SELECT DISTINCT PageID FROM PCMPages ORDER BY PageID")
If Not IsRSEmpty(rsPCM) Then
While Not rsPCM.EOF
Response.Write "" & langMgr.GetContent(rsPCM("PageID"), "BackEndMessages", iContentLang) & " " rsPCM.MoveNext Wend End If %> |
||
| ><%=langMgr.GetContent("CM_DBCONTENT_SECTION", "BackEndMessages", iInterfaceLang)%> | ||
| >
<%
For Each sItem In dicTables
Response.Write "" & dicTables(sItem) & " " Next %> |
||
| > <%=langMgr.GetContentWithParams("CM_PG_TITLE", Array("scurrpage"), Array(langMgr.GetContent(dicPageBeingEdited("Name"), "BackEndMessages", iContentLang)), "BackEndMessages", iInterfaceLang)%> | ><%=langMgr.GetContent("CM_PCM_TITLE", "BackEndMessages", iInterfaceLang)%> | |
|
|
||