Compare Backup: topic_v20251111_0105_new_files_.asp

Against: Live Page: topic.asp

Unchanged Added in comparison file Removed from comparison file
<!--#include file="includes/backupHelper.asp" -->
<!--#include file="includes/ASPlib.asp" -->
<!--#include file="includes/BSW_DBConn.inc.asp" -->
<!--#include file="includes/stats_lib.inc.asp" -->
<%
<% BSW_LogPageView() %>
Response.Charset = "UTF-8"
<%
' ==========================================================
Response.Charset = "UTF-8"
' Variables
' ==========================================================
' ==========================================================
Dim fso, folderPath, folder, files, file
' Variables
Dim topicStream, topicTitle, topicBody, topicDate, topicCategories
' ==========================================================
Dim topics(), topicCount, i, j, temp
Dim fso, folderPath, folder, files, file
Dim searchTerm, categoryFilter, sortBy
Dim topicStream, topicTitle, topicBody, topicDate, topicCategories
Dim categories, catFilePath, catStream, catContent, catLines, catLine
Dim topics(), topicCount, i, j, temp
Dim searchTerm, categoryFilter, sortBy
' ==========================================================
Dim categories, catFilePath, catStream, catContent, catLines, catLine
' Initialize
' ==========================================================
' ==========================================================
Set fso = Server.CreateObject("Scripting.FileSystemObject")
' Initialize
folderPath = Server.MapPath("topics")
' ==========================================================
Set folder = fso.GetFolder(folderPath)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
topicCount = 0
folderPath = Server.MapPath("topics")
Set folder = fso.GetFolder(folderPath)
searchTerm = LCase(Trim(Request("search")))
topicCount = 0
categoryFilter = LCase(Trim(Request("category")))
If categoryFilter = "" Then categoryFilter = "all"
searchTerm = LCase(Trim(Request("search")))
sortBy = LCase(Trim(Request("sort")))
categoryFilter = LCase(Trim(Request("category")))
If sortBy = "" Then sortBy = "alpha"
If categoryFilter = "" Then categoryFilter = "all"
sortBy = LCase(Trim(Request("sort")))
If searchTerm <> "" Then searchTerm = Replace(searchTerm, "'", "''")
If sortBy = "" Then sortBy = "alpha"
' ==========================================================
If searchTerm <> "" Then searchTerm = Replace(searchTerm, "'", "''")
' Load Categories
' ==========================================================
' ==========================================================
Set categories = CreateObject("Scripting.Dictionary")
' Load Categories
catFilePath = folderPath & "\categories.txt"
' ==========================================================
Set categories = CreateObject("Scripting.Dictionary")
If fso.FileExists(catFilePath) Then
catFilePath = folderPath & "\categories.txt"
Set catStream = fso.OpenTextFile(catFilePath, 1, False)
catContent = catStream.ReadAll
If fso.FileExists(catFilePath) Then
catStream.Close
Set catStream = fso.OpenTextFile(catFilePath, 1, False)
catLines = Split(catContent, vbCrLf)
catContent = catStream.ReadAll
For Each catLine In catLines
catStream.Close
catLine = Trim(catLine)
catLines = Split(catContent, vbCrLf)
If catLine <> "" Then categories.Add catLine, True
For Each catLine In catLines
Next
catLine = Trim(catLine)
End If
If catLine <> "" Then categories.Add catLine, True
Next
' ==========================================================
End If
' Function: Linkify Bible References
' ==========================================================
' ==========================================================
Function LinkifyBibleRefs(ByVal text)
' Function: Linkify Bible References
Dim regEx, pattern
' ==========================================================
pattern = "([1-3]?\s?[A-Za-z]+)\s+(\d+):(\d+(-\d+)?)"
Function LinkifyBibleRefs(ByVal text)
Set regEx = New RegExp
Dim regEx, pattern
regEx.Global = True
pattern = "([1-3]?\s?[A-Za-z]+)\s+(\d+):(\d+(-\d+)?)"
regEx.IgnoreCase = True
Set regEx = New RegExp
regEx.Pattern = pattern
regEx.Global = True
LinkifyBibleRefs = regEx.Replace(text, "<a href='https://www.biblestudyworld.com/default.asp?st=$1%20$2:$3'>$1&nbsp;$2:$3</a>")
regEx.IgnoreCase = True
Set regEx = Nothing
regEx.Pattern = pattern
End Function
LinkifyBibleRefs = regEx.Replace(text, "<a href='https://www.biblestudyworld.com/default.asp?st=$1%20$2:$3'>$1&nbsp;$2:$3</a>")
Set regEx = Nothing
' ==========================================================
End Function
' Function: Escape special characters for RegExp
' ==========================================================
' ==========================================================
Function EscapeRegex(str)
' Function: Escape special characters for RegExp
Dim charsToEscape, ch
' ==========================================================
charsToEscape = Array("\","^","$",".","|","?","*","+","(",")","[","]","{","}")
Function EscapeRegex(str)
For Each ch In charsToEscape
Dim charsToEscape, ch
str = Replace(str, ch, "\" & ch)
charsToEscape = Array("\","^","$",".","|","?","*","+","(",")","[","]","{","}")
Next
For Each ch In charsToEscape
EscapeRegex = str
str = Replace(str, ch, "\" & ch)
End Function
Next
EscapeRegex = str
' ==========================================================
End Function
' Load Topics
' ==========================================================
' ==========================================================
For Each file In folder.Files
' Load Topics
If LCase(fso.GetExtensionName(file.Name)) = "txt" And LCase(file.Name) <> "categories.txt" Then
' ==========================================================
Set topicStream = fso.OpenTextFile(file.Path, 1, False)
For Each file In folder.Files
topicTitle = ""
If LCase(fso.GetExtensionName(file.Name)) = "txt" And LCase(file.Name) <> "categories.txt" Then
topicBody = ""
Set topicStream = fso.OpenTextFile(file.Path, 1, False)
topicCategories = ""
topicTitle = ""
topicDate = file.DateCreated
topicBody = ""
topicCategories = ""
Do Until topicStream.AtEndOfStream
topicDate = file.DateCreated
Dim line
line = topicStream.ReadLine
Do Until topicStream.AtEndOfStream
If LCase(Left(line, 6)) = "title:" Then
Dim line
topicTitle = Trim(Mid(line, 7))
line = topicStream.ReadLine
ElseIf LCase(Left(line, 11)) = "categories:" Then
If LCase(Left(line, 6)) = "title:" Then
topicCategories = Trim(Mid(line, 12))
topicTitle = Trim(Mid(line, 7))
Else
ElseIf LCase(Left(line, 11)) = "categories:" Then
topicBody = topicBody & line & vbCrLf
topicCategories = Trim(Mid(line, 12))
End If
Else
Loop
topicBody = topicBody & line & vbCrLf
topicStream.Close
End If
Loop
' ----------------------
topicStream.Close
' Apply Category Filter
' ----------------------
' ----------------------
Dim includeTopic
' Apply Category Filter
includeTopic = True
' ----------------------
If categoryFilter <> "all" Then
Dim includeTopic
includeTopic = False
includeTopic = True
Dim topicCatArray, tCat
If categoryFilter <> "all" Then
topicCatArray = Split(topicCategories, ",")
includeTopic = False
For Each tCat In topicCatArray
Dim topicCatArray, tCat
tCat = LCase(Trim(tCat)) ' Trim and lowercase
topicCatArray = Split(topicCategories, ",")
If tCat = categoryFilter Then
For Each tCat In topicCatArray
includeTopic = True
tCat = LCase(Trim(tCat)) ' Trim and lowercase
Exit For
If tCat = categoryFilter Then
End If
includeTopic = True
Next
Exit For
End If
End If
Next
' ----------------------
End If
' Apply Search Filter
' ----------------------
' ----------------------
If includeTopic And searchTerm <> "" Then
' Apply Search Filter
If InStr(1, LCase(topicTitle & topicBody), searchTerm) = 0 Then includeTopic = False
' ----------------------
End If
If includeTopic And searchTerm <> "" Then
If InStr(1, LCase(topicTitle & topicBody), searchTerm) = 0 Then includeTopic = False
' ----------------------
End If
' Add to Topics Array
' ----------------------
' ----------------------
If includeTopic Then
' Add to Topics Array
ReDim Preserve topics(topicCount)
' ----------------------
topics(topicCount) = Array(topicTitle, topicBody, file.Name, topicDate, topicCategories)
If includeTopic Then
topicCount = topicCount + 1
ReDim Preserve topics(topicCount)
End If
topics(topicCount) = Array(topicTitle, topicBody, file.Name, topicDate, topicCategories)
End If
topicCount = topicCount + 1
Next
End If
End If
' ==========================================================
Next
' Sort Topics
' ==========================================================
' ==========================================================
If topicCount > 1 Then
' Sort Topics
For i = 0 To topicCount - 2
' ==========================================================
For j = i + 1 To topicCount - 1
If topicCount > 1 Then
If sortBy = "alpha" Then
For i = 0 To topicCount - 2
If UCase(topics(i)(0)) > UCase(topics(j)(0)) Then
For j = i + 1 To topicCount - 1
temp = topics(i): topics(i) = topics(j): topics(j) = temp
If sortBy = "alpha" Then
End If
If UCase(topics(i)(0)) > UCase(topics(j)(0)) Then
ElseIf sortBy = "date" Then
temp = topics(i): topics(i) = topics(j): topics(j) = temp
If topics(i)(3) < topics(j)(3) Then
End If
temp = topics(i): topics(i) = topics(j): topics(j) = temp
ElseIf sortBy = "date" Then
End If
If topics(i)(3) < topics(j)(3) Then
End If
temp = topics(i): topics(i) = topics(j): topics(j) = temp
Next
End If
Next
End If
End If
Next
%>
Next
End If
<!DOCTYPE html>
%>
<html lang="en">
<head>
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<html lang="en">
<title>Study Topics</title>
<head>
<style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
body { font-family:Arial,sans-serif; margin:0; padding:0; background:#f7f7f7; }
<title>Study Topics</title>
.header { display:flex; align-items:center; background:#2a4d9c; color:white; padding:10px; }
<style>
.header img { height:60px; width:auto; margin-right:10px; }
body { font-family:Arial,sans-serif; margin:0; padding:0; background:#f7f7f7; }
.header h1 { margin:0; font-size:24px; }
.header { display:flex; align-items:center; background:#2a4d9c; color:white; padding:10px; }
.buttons { display:flex; flex-wrap:wrap; padding:10px; gap:8px; }
.header img { height:60px; width:auto; margin-right:10px; }
button, select { padding:6px 12px; border-radius:5px; border:none; cursor:pointer; }
.header h1 { margin:0; font-size:24px; }
button { background:#004080; color:white; }
.buttons { display:flex; flex-wrap:wrap; padding:10px; gap:8px; }
button:hover { background:#0059b3; }
button, select { padding:6px 12px; border-radius:5px; border:none; cursor:pointer; }
select { background:#eee; }
button { background:#004080; color:white; }
.search-bar { padding:10px; text-align:center; }
button:hover { background:#0059b3; }
.search-bar input[type="text"] { width:80%; padding:8px; border-radius:4px; border:1px solid #ccc; font-size:16px; }
select { background:#eee; }
.topic { background:white; margin:10px; padding:10px; border-radius:6px; box-shadow:0 1px 3px rgba(0,0,0,0.2); cursor:pointer; }
.search-bar { padding:10px; text-align:center; }
.topic h3 { margin:0; }
.search-bar input[type="text"] { width:80%; padding:8px; border-radius:4px; border:1px solid #ccc; font-size:16px; }
.highlight { background:#cce5ff; font-weight:bold; }
.topic { background:white; margin:10px; padding:10px; border-radius:6px; box-shadow:0 1px 3px rgba(0,0,0,0.2); cursor:pointer; }
.admin-link { text-align:center; margin:20px; font-size:14px; color:#999; }
.topic h3 { margin:0; }
.admin-link a { color:#999; text-decoration:none; }
.highlight { background:#cce5ff; font-weight:bold; }
.admin-link a:hover { text-decoration:underline; }
.admin-link { text-align:center; margin:20px; font-size:14px; color:#999; }
</style>
.admin-link a { color:#999; text-decoration:none; }
<script>
.admin-link a:hover { text-decoration:underline; }
function toggleBody(id){
</style>
var el = document.getElementById(id);
<script>
if(el.style.display==='block'){el.style.display='none';}
function toggleBody(id){
else{el.style.display='block';}
var el = document.getElementById(id);
}
if(el.style.display==='block'){el.style.display='none';}
</script>
else{el.style.display='block';}
</head>
}
<body>
</script>
</head>
<div class="header">
<body>
<a href="default.asp"><img src="images/logo.jpg" alt="Logo"></a>
<h1>Study Topics</h1>
<div class="header">
</div>
<a href="default.asp"><img src="images/logo.jpg" alt="Logo"></a>
<h1>Study Topics</h1>
<div class="buttons">
</div>
<form method="get" style="display:inline;">
<button type="submit" name="sort" value="alpha">A–Z</button>
<div class="buttons">
<button type="submit" name="sort" value="date">Newest</button>
<form method="get" style="display:inline;">
<button type="submit" name="sort" value="alpha">A–Z</button>
<select name="category" onchange="this.form.submit()">
<button type="submit" name="sort" value="date">Newest</button>
<%
' All option
<select name="category" onchange="this.form.submit()">
If categoryFilter = "all" Then
<%
Response.Write "<option value='All' selected>All</option>"
' All option
Else
If categoryFilter = "all" Then
Response.Write "<option value='All'>All</option>"
Response.Write "<option value='All' selected>All</option>"
End If
Else
Response.Write "<option value='All'>All</option>"
' Other categories
End If
Dim catKey, catValue
For Each catKey In categories.Keys
' Other categories
catValue = Trim(catKey)
Dim catKey, catValue
If catValue <> "" Then
For Each catKey In categories.Keys
Response.Write "<option value='" & catValue & "'"
catValue = Trim(catKey)
If LCase(catValue) = categoryFilter Then Response.Write " selected"
If catValue <> "" Then
Response.Write ">" & catValue & "</option>"
Response.Write "<option value='" & catValue & "'"
End If
If LCase(catValue) = categoryFilter Then Response.Write " selected"
Next
Response.Write ">" & catValue & "</option>"
%>
End If
</select>
Next
%>
<input type="hidden" name="search" value="<%=Server.HTMLEncode(searchTerm)%>">
</select>
<input type="hidden" name="sort" value="<%=Server.HTMLEncode(sortBy)%>">
</form>
<input type="hidden" name="search" value="<%=Server.HTMLEncode(searchTerm)%>">
</div>
<input type="hidden" name="sort" value="<%=Server.HTMLEncode(sortBy)%>">
</form>
<div class="search-bar">
</div>
<form method="get">
<input type="text" name="search" placeholder="Search topics..." value="<%=Server.HTMLEncode(Request("search"))%>">
<div class="search-bar">
<input type="hidden" name="sort" value="<%=Server.HTMLEncode(sortBy)%>">
<form method="get">
<input type="hidden" name="category" value="<%=Server.HTMLEncode(categoryFilter)%>">
<input type="text" name="search" placeholder="Search topics..." value="<%=Server.HTMLEncode(Request("search"))%>">
<button type="submit">Search</button>
<input type="hidden" name="sort" value="<%=Server.HTMLEncode(sortBy)%>">
</form>
<input type="hidden" name="category" value="<%=Server.HTMLEncode(categoryFilter)%>">
</div>
<button type="submit">Search</button>
</form>
<%
</div>
If topicCount = 0 Then
Response.Write "<p style='text-align:center;'>No topics found.</p>"
<%
Else
If topicCount = 0 Then
For i = 0 To topicCount - 1
Response.Write "<p style='text-align:center;'>No topics found.</p>"
Dim tTitle, tBody, bodyId
Else
tTitle = topics(i)(0)
For i = 0 To topicCount - 1
tBody = topics(i)(1)
Dim tTitle, tBody, bodyId
bodyId = "body_" & i
tTitle = topics(i)(0)
tBody = topics(i)(1)
' Highlight search terms safely
bodyId = "body_" & i
If searchTerm <> "" Then
Dim regex
' Highlight search terms safely
Set regex = New RegExp
If searchTerm <> "" Then
regex.IgnoreCase = True
Dim regex
regex.Global = True
Set regex = New RegExp
regex.Pattern = "(" & EscapeRegex(searchTerm) & ")"
regex.IgnoreCase = True
tTitle = regex.Replace(tTitle, "<span class='highlight'>$1</span>")
regex.Global = True
tBody = regex.Replace(tBody, "<span class='highlight'>$1</span>")
regex.Pattern = "(" & EscapeRegex(searchTerm) & ")"
Set regex = Nothing
tTitle = regex.Replace(tTitle, "<span class='highlight'>$1</span>")
End If
tBody = regex.Replace(tBody, "<span class='highlight'>$1</span>")
Set regex = Nothing
' Linkify Bible references
End If
tBody = LinkifyBibleRefs(tBody)
' Linkify Bible references
Response.Write "<div class='topic' onclick=""toggleBody('" & bodyId & "')"" style='cursor:pointer;'>"
tBody = LinkifyBibleRefs(tBody)
Response.Write "<h3>" & tTitle & "</h3>"
Response.Write "<pre id='" & bodyId & "' style='display:none; white-space:pre-wrap;'>" & tBody & "</pre>"
Response.Write "<div class='topic' onclick=""toggleBody('" & bodyId & "')"" style='cursor:pointer;'>"
Response.Write "</div>"
Response.Write "<h3>" & tTitle & "</h3>"
Next
Response.Write "<pre id='" & bodyId & "' style='display:none; white-space:pre-wrap;'>" & tBody & "</pre>"
End If
Response.Write "</div>"
%>
Next
End If
<div class="admin-link">
%>
<a href="admin.asp">Admin Login</a>
</div>
<div class="admin-link">
<a href="admin.asp">Admin Login</a>
</body>
</div>
</html>
</body>
</html>