Let users post Source on your site

Written by:dimport
Published by:dimport
Published on:2003-06-21 07:19:46

Ever wanted to let your users be able to post there problems on your site with the ability to add there source code so its readable?
Here's how using Microsoft ASP technology.

All you need to do is surround the text you wish to be made visible in the post with
 '============= CODE ============
 Function detect(Thecomment)
         Dim Temp
         Temp = int(Instr(1, Thecomment, "[/script]", 1))
 - int(Instr(1, Thecomment, "[Script]", 1) +8)
         Temp = Mid(Thecomment, int(Instr(1, Thecomment,
 "[Script]", 1) +8), Temp)
         Thecomment = Replace(Thecomment, Temp, server.HTMLEncode(Temp))
         Thecomment = Replace(Thecomment, "[script]", "")
         Thecomment = Replace(Thecomment, "[/script]", "")
         detect = Thecomment
 END Function
 '============== END ============

How To Use IT :
 <% @LANGUAGE=VBScript %>
 <% Option Explicit %>
 <!-- #Include file="Functions.asp" -->
 Dim Out_Source
 Out_Source = detect("<>[script]<HTML>BLAR BLAR<HTML>[/script]")

This article was originally written by Cadey

This is an article from http://www.osix.net - view the original at: http://www.osix.net/modules/article/?id=129