Topic Image Preview

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68699?pagenum=1
05 November 2025, 18:15

Topic


Carefree
Topic Image Preview
13 June 2009, 09:46


The Topic Image Preview MOD scans topics from allowed forums, then displays images and associated topic titles from the last 10 topics which included images. Each image thumbnail is linked to a full size version and each topic title is linked to the topic itself.
This mod includes a check of whether members are allowed access to a forum before displaying the images.
Guests are not allowed access. To allow access to guests, in "Topic_Images.asp", delete (or comment out) lines 50-52; or in "inc_topic_images.asp", delete (or comment out) lines 41-43.
"inc_topic_images.asp" is provided to enable the image display to appear in "active.asp" (if you want them displayed with the active topics page).
Get a copy at SnitzBitz.

Edit: Thanks to a suggestion by Etymon, in v1.1, I added a check to determine whether images are allowed at all, and another to check if there is an image path.

 

Replies ...


Classicmotorcycling
13 June 2009, 21:23


Not sure if it is me or what, but the topics do not match the images on my test site.
Etymon
13 June 2009, 22:46


I sent Carefree an e-mail asking him to make the MOD check for unmoderated posts. Before, it allowed them into the mix. He updated the MOD at Snitz Bitz. Maybe try downloading it again and see if that fixes the problem.
Carefree
14 June 2009, 00:19


Originally posted by Classicmotorcycling
Not sure if it is me or what, but the topics do not match the images on my test site.

Got a test login so I can see?
Classicmotorcycling
14 June 2009, 04:10


Not for the test site, sorry.

What I am getting is that there is an image in a topic, but when you click on the topic, there is no image in the actual topic. The image relates to a different topic when I do a search for for the image name in the search function I find they topic which is totally different.
Great concept but.
modifichicci
14 June 2009, 11:41


It works, but if a forum has a lot of topics i have a script timed error..
Carefree
15 June 2009, 18:55


... if a forum has a lot of topics i have a script timed error.
Does anyone see a method to speed up this script? Don't be bashful....bigsmile
Etymon
15 June 2009, 20:54


I made it work so it has one image per row. I like that better myself.
leatherlips
15 June 2009, 21:08


I'm curious as to how this mod is intended to be used? It's an interesting mod but I'm not quite sure what it does.
Carefree
15 June 2009, 22:02


Since men (more so than women) are visually stimulated creatures, I thought that perhaps images would catch their eye and generate more interest in topics that might otherwise have been passed over. This mod simply checks if photos are allowed, then displays images and links to topics from last 10 topics which include images and where access to forums was granted. It's just a form of topic advertising.
leatherlips
15 June 2009, 22:33


Thanks for the explaination! Great idea!
Andy Humm
16 June 2009, 05:52


Sounds a cool idea.. is there a working demo available?
Carefree
17 June 2009, 13:36


Andy, here's the main file - drop it on your forum (call it whatever you like) and run it.

Code:

<%
'###############################################################################
'##
'## Snitz Forums 2000 v3.4.07
'##
'###############################################################################
'##
'## Copyright © 2000-09 Michael Anderson, Pierre Gorissen,
'## Huw Reddick and Richard Kinser
'##
'## This program is free. You can redistribute and/or modify it under the
'## terms of the GNU General Public License as published by the Free Software
'## Foundation; either version 2 or (at your option) any later version. '##
'## All copyright notices regarding Snitz Forums 2000 must remain intact in
'## the scripts and in the HTML output. The "powered by" text/logo with a
'## link back to http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet. '##
'## This program is distributed in the hope that it will be useful but
'## WITHOUT ANY WARRANTY; without even an implied warranty of MERCHANTABILITY
'## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
'## for more details. '##
'## You should have received a copy of the GNU General Public License along
'## with this program; if not, write to:
'##
'## Free Software Foundation, Inc. '## 59 Temple Place, Suite 330
'## Boston, MA 02111-1307
'##
'## Support can be obtained from our support forums at:
'##
'## http://forum.snitz.com
'##
'## Correspondence and marketing questions can be sent to:
'##
'## manderson@snitz.com
'##
'###############################################################################
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_sha256.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<!--#INCLUDE FILE="inc_func_secure.asp" -->
<!--#INCLUDE FILE="inc_func_member.asp" -->
<!--#INCLUDE FILE="inc_func_posting.asp"-->
<%
if mLev<1 or (STRIMGINPOSTS<>"1" or STRIMAGEURL="") then
Response.Redirect "default.asp"
end if
Response.Write "<table border=""0"" width=""100%"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""33%"" align=""left"" nowrap><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" " & getCurrentIcon(strIconFolderOpen,"","") & " <a href=""default.asp"">All Forums</a><br />" & vbNewLine & _
" " & getCurrentIcon(strIconBlank,"","") & getCurrentIcon(strIconBar,"","") & getCurrentIcon(strIconFolderOpenTopic,"","") & " Topics Image Preview<br /></font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
"</table><br>" & vbNewLine & _
"<table align=""center"" bgcolor=""" & strTableBorderColor & """ border=""1"" width=""100%"" cellspacing=""1"" cellpadding=""1"">" & vbNewLine & _
" <tr valign=""middle""><br>" & vbNewLine & _
" <td colspan=""2"" width=""100%"" align=""center"" bgcolor=""" & strCategoryCellColor & """>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """ color=""" & strCategoryFontColor & """><b>Last 10 Topics Image Preview</b>" & vbNewLine & _
" </font>" & vbNewLine & _
" </td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strDefaultFontColor & """><b>" & vbNewLine
Call ChkAccess

strSql="SELECT FORUM_ID, T_STATUS, T_DATE, T_MESSAGE, T_SUBJECT, Topic_ID FROM " & strTablePrefix & "TOPICS WHERE"
if strPrivateForums = "1" and allAllowedForums <> "" and mLev < 4 then
strSql=strSql & " (FORUM_ID IN (" & allAllowedForums & ")) AND"
end if
strSql=strSql & " T_STATUS=1 AND T_MESSAGE LIKE '%[img]%' ORDER BY T_DATE DESC"
set rsDisplay=my_Conn.Execute(strSql)
if rsDisplay.EOF or (mLev < 4 AND allAllowedForums="")then
Response.Redirect "default.asp"
end if
if not rsDisplay.EOF then
rsDisplay.MoveFirst
ii=0
do until rsDisplay.EOF
strMsg=rsDisplay("T_MESSAGE")
if lcase(instr(strMsg,"[img]")) then
ii=ii+1
if ii=11 then
exit do
end if
for i=1 to len(strMsg)
if lcase(mid(strMsg,i,5))="[img]" then
intj=i+5
end if
if lcase(mid(strMsg,i,6))="[/img]" then
intk=i
strImgURL=mid(strMsg,intj,intk-intj)
end if
next
address = lcase(strForumURL&Trim(strImgURL))
end if
strTgtURL(ii)=address
strSubj(ii)=rsDisplay("T_Subject")
strTPID(ii)=rsDisplay("Topic_ID")
il=0
rsDisplay.MoveNext
Loop
for ij=1 to 5
Response.Write " <tr height=""275"" valign=""bottom"">" & vbNewLine
for ik=1 to 2
il=il+1
Response.Write " <td width=""50%"" align=""center"" bgcolor=""" & strForumCellColor & """>" & vbNewLine
if strTgtURL(il)>"" then
Response.Write "<a href=""" & strTgtURL(il) & """ target=""_blank"">" & vbNewLine & _
"<img src=""" & strTgtURL(il) & """ width=""298""></a><br>" & vbNewLine
end if
Response.Write "<a href=""topic.asp?topic_id="& cInt(strTPID(il)) & """ target=""_blank"">" & strSubj(il) & "</a>" & vbNewLine & _
"</td>" & vbNewLine
next
Response.Write " </tr>" & vbNewLine
next
rsDisplay.Close
end if
Set rsDisplay=Nothing
Response.Write " </table>" & vbNewLine
WriteFooter
Response.End


Sub ChkAccess
if mlev = 3 then
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
" WHERE MEMBER_ID = " & MemberID
Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if rsMod.EOF then
recModCount = ""
else
allModData = rsMod.GetRows(adGetRowsRest)
recModCount = UBound(allModData,2)
end if
RsMod.close
set RsMod = nothing
if recModCount <> "" then
for x = 0 to recModCount
if x = 0 then
ModOfForums = allModData(0,x)
else
ModOfForums = ModOfForums & "," & allModData(0,x)
end if
next
else
ModOfForums = ""
end if
else
ModOfForums = ""
end if
if strPrivateForums = "1" and mLev < 4 then
allAllowedForums = ""
allowSql = "SELECT FORUM_ID, F_SUBJECT, F_PRIVATEFORUMS, F_PASSWORD_NEW"
allowSql = allowSql & " FROM " & strTablePrefix & "FORUM"
allowSql = allowSql & " WHERE F_TYPE = 0"
allowSql = allowSql & " ORDER BY FORUM_ID"
set rsAllowed = Server.CreateObject("ADODB.Recordset")
rsAllowed.open allowSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if rsAllowed.EOF then
recAllowedCount = ""
else
allAllowedData = rsAllowed.GetRows(adGetRowsRest)
recAllowedCount = UBound(allAllowedData,2)
end if
rsAllowed.close
set rsAllowed = nothing
if recAllowedCount <> "" then
fFORUM_ID = 0
fF_SUBJECT = 1
fF_PRIVATEFORUMS = 2
fF_PASSWORD_NEW = 3
for RowCount = 0 to recAllowedCount
Forum_ID = allAllowedData(fFORUM_ID,RowCount)
Forum_Subject = allAllowedData(fF_SUBJECT,RowCount)
Forum_PrivateForums = allAllowedData(fF_PRIVATEFORUMS,RowCount)
Forum_FPasswordNew = allAllowedData(fF_PASSWORD_NEW,RowCount)
if mLev = 4 then
ModerateAllowed = "Y"
elseif mLev = 3 and ModOfForums <> "" then
if (strAuthType = "nt") then
if (chkForumModerator(Forum_ID, Session(strCookieURL & "username")) = "1") then ModerateAllowed = "Y" else ModerateAllowed = "N"
else
if (instr("," & ModOfForums & "," ,"," & Forum_ID & ",") > 0) then ModerateAllowed = "Y" else ModerateAllowed = "N"
end if
else
ModerateAllowed = "N"
end if
if chkForumAccessNew(Forum_PrivateForums,Forum_FPasswordNew,Forum_Subject,Forum_ID,MemberID) = true then
if allAllowedForums = "" then
allAllowedForums = Forum_ID
else
allAllowedForums = allAllowedForums & "," & Forum_ID
end if
end if
next
end if
if allAllowedForums = "" then allAllowedForums = 0
end if
End Sub
%>
Classicmotorcycling
17 June 2009, 16:12


Carefree, did you get my e-mail? I sent you a link to a demo so you could see what it was doing.
Carefree
18 June 2009, 14:33


Haven't checked my mail in a couple of days - will look now.
leatherlips
18 June 2009, 14:56


I was trying this out and noticed that if an image is posted in a private forum and a member is not allowed in that forum and the visit the topic_images.asp page, they will see this:

Carefree
22 June 2009, 00:45


I fixed that. Now empty cells will not have photo placeholders.
Carefree
22 June 2009, 00:48


Originally posted by Classicmotorcycling
Carefree, did you get my e-mail? I sent you a link to a demo so you could see what it was doing.
No email. Please resend.
Classicmotorcycling
22 June 2009, 00:56


Email sent again..
richfed
27 June 2009, 12:10


I am experiencing a problem ... well, maybe 2.
First of all, I cannot get the ReadMe to open in the .chm format. It does open, pardon me, but links don't work and the right-hand pane receives an "Navigation to web page was canceled" message.
I tried to install the MOD anyway. Uploaded the TWO new files and made ONE change each to THREE files: active, inc_header, and config.
When I log on, I see no reference to the MOD anywhere ... the link in inc_header does not show. No error messages or anything. NOTHING. Did I miss something?
Andy, here's the main file - drop it on your forum (call it whatever you like) and run it.

Just tried this and got this result:

All Forums
Topics Image Preview



Last 10 Topics Image Preview
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'chkForumAccessNew'

/messageboard/topic_images.asp, line 192


Is this MOD compatible with 3.4.07 only? I use 3.4.05 with fixes applied.

Carefree
27 June 2009, 15:45


Let me dig up a copy of 3.4.05 and see what needs to be changed to make it work. I'll make you a copy with individual copies of instructions in htm format.
richfed
27 June 2009, 19:07


That would be great ... thanks!
Carefree
28 June 2009, 01:22


OK - 3.4.05 is included.
richfed
28 June 2009, 15:27


Not there, yet, Carefree ...
After downloading and installing AND commenting out the appropriate lines so that guests can see the previews also, here's what I experience:

1 - When logged in as Admin, I see the images off of the inc_header link, BUT they do not correspond to the correct thread. [Looks like the same problem Classicmotorcycling experienced.]
2 - When logged out completely, I get the following error when clinking on the inc_header link [before commenting out, I got the desired loop back to default.asp]:

Microsoft VBScript compilation error '800a0411'

Name redefined

/messageboard/inc_topic_images.asp, line 44

Dim strTgtURL(10), strSubj(10), strTPID(10)
----^

I do not know the results when logged in as a normal user.
Carefree
28 June 2009, 17:32


When accessing the Active Topics Page, I get this error, logged in or not:

Microsoft VBScript compilation error '800a0411'

Name redefined

/messageboard/inc_topic_images.asp, line 44

Dim strTgtURL(10), strSubj(10), strTPID(10)
----^
Fixed. I had forgotten to delete this after moving it to "config.asp".
richfed
29 June 2009, 18:31


OK, I have it all straightened out with the exception of the mismatched photos. I tried to send you an e-mail; receieved an Earthlink reply about spam. What do you need, Carefree?
OH, also ... how could I make the whole photo table smaller with uniform thumbnails or something. I think it would look much neater.
Thanks!
Carefree
29 June 2009, 23:13


I received the EMail, replied.
I tried several approaches to get remote photo dimensions read (to allow for resizing to a uniform width or height), the .gifs were read fine, but .jpgs were not. Since the vast majority of posted images seem to be in the .jpg format, that made resizing worthless. If I could get the dimensions of remote images extracted, I can shrink the table & photos.
Carefree
01 July 2009, 04:06


Originally posted by Classicmotorcycling
Not for the test site, sorry.

What I am getting is that there is an image in a topic, but when you click on the topic, there is no image in the actual topic. The image relates to a different topic when I do a search for for the image name in the search function I find they topic which is totally different.
Great concept but.

Issue has been resolved. Enjoy
richfed
01 July 2009, 06:52


And, thank you Mr, Carefree ... this issue IS all resolved on my site!!!
Classicmotorcycling
01 July 2009, 15:05


Tested and now matches the topics and images on my site. Thanks Craig..
Carefree
01 July 2009, 15:55


You're welcome. Now, if only I can get the remote image dimensions to read properly, I can scale the table & images down some.
AnonJr
01 July 2009, 17:17


I needed something similar for a local .vbs to generate an XML file with image specs. I've used the following functions in that project - context is provided. Can't remember where I originaly got them though...
Code:
'collect the image information into an array
Dim blnGfxSpex, width, height, colors, strType
intCount = 0
For Each objFile In objFS.GetFolder(".\images").Files
'As per the readme, images need to be 'non-progressive' JPGs
If LCase(Right(objFile.Name, 4)) = ".jpg" and intCount <= intNumOfFiles Then
blnGfxSpex = gfxSpex((".\images\" & objFile.Name), width, height, colors, strType)
MsgIE Now() & " - Now getting information on " & (intCount + 1) & " of " & intNumOfFiles & "."
arrImages(intCount) = "<image>" & vbNewLine & _
"<filename>" & objFile.Name & "</filename>" & vbNewLine & _
"<caption></caption>" & vbNewLine & _
"<width>" & width & "</width>" & vbNewLine & _
"<height>" & height & "</height>" & vbNewLine & _
"</image>" & vbNewLine
intCount = intCount + 1
End If
Next

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: This routine will attempt to identify any filespec passed :::
'::: as a graphic file (regardless of the extension). This will :::
'::: work with BMP, GIF, JPG and PNG files. :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: Based on ideas presented by David Crowell :::
'::: (credit where due) :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
'::: blah blah Copyright *c* MM, Mike Shaffer blah blah :::
'::: blah blah ALL RIGHTS RESERVED WORLDWIDE blah blah :::
'::: blah blah Permission is granted to use this code blah blah :::
'::: blah blah in your projects, as long as this blah blah :::
'::: blah blah copyright notice is included blah blah :::
'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: This function gets a specified number of bytes from any :::
'::: file, starting at the offset (base 1) :::
'::: :::
'::: Passed: :::
'::: flnm => Filespec of file to read :::
'::: offset => Offset at which to start reading :::
'::: bytes => How many bytes to read :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function GetBytes(flnm, offset, bytes)

Dim objFSO
Dim objFTemp
Dim objTextStream
Dim lngSize

on error resume next

Set objFSO = CreateObject("Scripting.FileSystemObject")

' First, we get the filesize
Set objFTemp = objFSO.GetFile(flnm)
lngSize = objFTemp.Size
set objFTemp = nothing

fsoForReading = 1
Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading)

if offset > 0 then
strBuff = objTextStream.Read(offset - 1)
end if

if bytes = -1 then ' Get All!
GetBytes = objTextStream.Read(lngSize) 'ReadAll

else

GetBytes = objTextStream.Read(bytes)

end if

objTextStream.Close
set objTextStream = nothing
set objFSO = nothing

end function


':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: Functions to convert two bytes to a numeric value (long) :::
'::: (both little-endian and big-endian) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function lngConvert(strTemp)
lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))
end function

function lngConvert2(strTemp)
lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))
end function


':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: This function does most of the real work. It will attempt :::
'::: to read any file, regardless of the extension, and will :::
'::: identify if it is a graphical image. :::
'::: :::
'::: Passed: :::
'::: flnm => Filespec of file to read :::
'::: width => width of image :::
'::: height => height of image :::
'::: depth => color depth (in number of colors) :::
'::: strImageType=> type of image (e.g. GIF, BMP, etc.) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function gfxSpex(flnm, width, height, depth, strImageType)

dim strPNG
dim strGIF
dim strBMP
dim strType
strType = ""
strImageType = "(unknown)"

gfxSpex = False

strPNG = chr(137) & chr(80) & chr(78)
strGIF = "GIF"
strBMP = chr(66) & chr(77)

strType = GetBytes(flnm, 0, 3)

if strType = strGIF then ' is GIF

strImageType = "GIF"
Width = lngConvert(GetBytes(flnm, 7, 2))
Height = lngConvert(GetBytes(flnm, 9, 2))
Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)
gfxSpex = True

elseif left(strType, 2) = strBMP then ' is BMP

strImageType = "BMP"
Width = lngConvert(GetBytes(flnm, 19, 2))
Height = lngConvert(GetBytes(flnm, 23, 2))
Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))
gfxSpex = True

elseif strType = strPNG then ' Is PNG

strImageType = "PNG"
Width = lngConvert2(GetBytes(flnm, 19, 2))
Height = lngConvert2(GetBytes(flnm, 23, 2))
Depth = getBytes(flnm, 25, 2)

select case asc(right(Depth,1))
case 0
Depth = 2 ^ (asc(left(Depth, 1)))
gfxSpex = True
case 2
Depth = 2 ^ (asc(left(Depth, 1)) * 3)
gfxSpex = True
case 3
Depth = 2 ^ (asc(left(Depth, 1))) '8
gfxSpex = True
case 4
Depth = 2 ^ (asc(left(Depth, 1)) * 2)
gfxSpex = True
case 6
Depth = 2 ^ (asc(left(Depth, 1)) * 4)
gfxSpex = True
case else
Depth = -1
end select


else

strBuff = GetBytes(flnm, 0, -1) ' Get all bytes from file
lngSize = len(strBuff)
flgFound = 0

strTarget = chr(255) & chr(216) & chr(255)
flgFound = instr(strBuff, strTarget)

if flgFound = 0 then
exit function
end if

strImageType = "JPG"
lngPos = flgFound + 2
ExitLoop = false

do while ExitLoop = False and lngPos < lngSize

do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSize
lngPos = lngPos + 1
loop

if asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1)) > 195 then
lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))
lngPos = lngPos + lngMarkerSize + 1
else
ExitLoop = True
end if

loop
'
if ExitLoop = False then

Width = -1
Height = -1
Depth = -1

else

Height = lngConvert2(mid(strBuff, lngPos + 4, 2))
Width = lngConvert2(mid(strBuff, lngPos + 6, 2))
Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)
gfxSpex = True

end if

end if

end function
Carefree
01 July 2009, 17:45


I've tested that routine before for local files - there's a similar one for remote files, but the portion for .jpg fails.
AnonJr
02 July 2009, 11:25


I'd love to dig in and help trouble-shoot but I've overbooked myself a tad and have been working furiously to un-bury myself... blush
Carefree
02 July 2009, 12:32


No problem. It's not really necessary for the mod, just would improve it a bit.
© 2000-2021 Snitz™ Communications