Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Using a Wiki for knowledge sharing and SQL Server database documentation

, 7 Feb 2004
This article describes using a Wiki for knowledge sharing and database schema documentation.
wiki_src.zip
attachments
images
Help
edit_comment.gif
Thumbs.db
Wiki
DatabaseSchema.gif
DeprecatedBanner.gif
FindPage.gif
HelpBanner.gif
Key.gif
NoTick.gif
Thumbs.db
Tick.gif
UserPreferences.gif
ow
css
images
banner_logo.gif
banner_search.gif
banner_title.gif
breadcrumb_divider.gif
dashed_line.gif
delico.gif
edit_icon.gif
find_icon.gif
grey_box_left.gif
grey_box_line.gif
grey_box_right.gif
hidden_off.gif
hidden_on.gif
icons
doc
asp.gif
avi.gif
bmp.gif
chm.gif
doc.gif
empty.gif
gif.gif
gz.gif
htm.gif
html.gif
jpeg.gif
jpg.gif
mov.gif
mp3.gif
mpeg.gif
mpg.gif
pdf.gif
png.gif
ppt.gif
Thumbs.db
txt.gif
wav.gif
xls.gif
xml.gif
xsl.gif
zip.gif
emoticon-8.gif
emoticon-ambivalent.gif
emoticon-b.gif
emoticon-c.gif
emoticon-cat.gif
emoticon-d.gif
emoticon-e.gif
emoticon-f.gif
emoticon-g.gif
emoticon-h.gif
emoticon-i.gif
emoticon-k.gif
emoticon-l.gif
emoticon-laugh.gif
emoticon-m.gif
emoticon-n.gif
emoticon-p.gif
emoticon-s.gif
emoticon-sad.gif
emoticon-smile.gif
emoticon-star.gif
emoticon-surprised.gif
emoticon-t.gif
emoticon-tongue-in-cheek.gif
emoticon-u.gif
emoticon-unsure.gif
emoticon-wink.gif
emoticon-wink_old.gif
emoticon-y.gif
icon-error.gif
icon-info.gif
icon-warning.gif
Thumbs.db
wiki-ftp.gif
wiki-http.gif
wiki-mailto.gif
wiki-news.gif
wiki-telnet.gif
wiki-wiki.gif
icon_edit.gif
icon_print.gif
icon_revisions.gif
logo.gif
logo_aggregator.gif
logo_tiny.gif
popup.gif
popup2.gif
poweredby.gif
revs.gif
rss_button.gif
Thumbs.db
undo.gif
valid-css.gif
valid-xhtml10.gif
xml.gif
my
xsl
mystyle.xsl
ow.xsl
owattach.xsl
owinc.xsl
owrss09.xsl
owrss091.xsl
owrss10.xsl
owrss10aggr.xsl
owrss10export.xsl
owscriptingnews.xsl
xmldisplay.xsl
data
wiki.mdb
wikidb.mdf
<%
'
' ---------------------------------------------------------------------------
' Copyright(c) 2000-2002, Laurens Pit
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without
' modification, are permitted provided that the following conditions
' are met:
'
'   * Redistributions of source code must retain the above copyright
'     notice, this list of conditions and the following disclaimer.
'   * Redistributions in binary form must reproduce the above
'     copyright notice, this list of conditions and the following
'     disclaimer in the documentation and/or other materials provided
'     with the distribution.
'   * Neither the name of OpenWiki nor the names of its contributors
'     may be used to endorse or promote products derived from this
'     software without specific prior written permission.
'
' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
' "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
' LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
' FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
' REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
' INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
' BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
' CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
' ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
' POSSIBILITY OF SUCH DAMAGE.
'
' ---------------------------------------------------------------------------
'      $Source: /usr/local/cvsroot/openwiki/dist/owbase/ow/owattach.asp,v $
'    $Revision: 1.2 $
'      $Author: pit $
' ---------------------------------------------------------------------------
'
'
'
'
'
'       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'       !!! WARNING: YOU ARE POTENTIALLY RUNNING A SECURITY RISK !!!
'       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'
'
'
'
' Potentially people can upload files to your server that will be executed
' on your server when they point their browser to the uploaded file.
'
' This is possible because in IIS executables are mapped to file extensions.
' So for example, potentially someone can upload an .asp file, then point their
' browser to that file, after which the file is executed on your server, possibly
' wiping out your entire file system.
'
' In IIS you can view the application mappings by going to the properties of
' your website, choose tab "Home Directory", click on button "Configuration"
' and choose tab "App Mappings".
'
' Besides running a security risk on your server, by allowing people to upload
' files your users might unsuspectedly run into a mallicious file that is
' executed on their machines. For example, it's easy to upload an html file
' with very nasty javascript code; when your users view the html page as is,
' the javascript code will get executed on their machine, and your users might
' get very angry with you. ;)
'
' So in general: it's a bad idea to allow uploads on public websites. Only
' allow it when you trust your users.
'
' ---------------------------------------------------------------------------
'
' PLEASE READ THE BIG LETTERS OF THE OPENWIKI LICENSE AGAIN !
'
' It's printed above for your convenience. ;-)
'
' ---------------------------------------------------------------------------
'
' By default all files uploaded will get the extension .safe, except for files
' with extensions that are defined in the variable gDocExtensions (see file
' owpatterns.asp).
'
' If the variable gNotAcceptedExtensions is defined (see file owpattern.asp),
' then all files uploaded will keep their extensions, except the ones defined
' in the variable; they will still get the .safe extension. When you use this
' method you are advised to add all the extensions for which an application
' mapping is defined for the website in IIS.
'
' ---------------------------------------------------------------------------
'
' The is version 1 of the upload feature.
'
' This version of the upload feature assumes that you have installed the
' upload component ABC Upload version 4 from WebSupergoo. It's "free" and
' easy to install. See http://www.websupergoo.com/abcupload-1.htm.
'
' Using a different component would be quite easy if you know a bit of ASP.
' You'd only have to modify the sub ActionUpload below. Future versions of
' OpenWiki will probably support various upload components.
'
' This version saves the files to the file system. Saving to the database
' is again quite easy if you know a bit of ASP and databases, see comments
' inline the code below (note: you'd also need a separate script to retrieve
' the files). Future versions of OpenWiki will probably support storing
' files as BLOB's in the database.
'
' ---------------------------------------------------------------------------
'

Sub ActionAttach
    ActionView()
End Sub


Sub ActionUpload
    Response.Expires = -10000
    Server.ScriptTimeOut = OPENWIKI_UPLOADTIMEOUT
    Dim theForm, theField, vFilename
    On Error Resume Next
    Err.Number = 0
    Set theForm = Server.CreateObject("ABCUpload4.XForm")
    If Err.Number <> 0 Then
        Response.Write("<b>Error</b>: Missing component ABCUpload4. You can download this component from <a href='http://www.websupergoo.com/downloadftp.htm'>websupergoo.com</a>")
        Response.End
    End If
    On Error Goto 0
    theForm.MaxUploadSize = OPENWIKI_MAXUPLOADSIZE
    theForm.Overwrite = True
    theForm.AbsolutePath = False
    ' TODO: maybe implement pop-up progress-bar
    'theForm.ID = Request.QueryString("ID")

    'On Error Resume Next
    Set theField = theForm("file")(1)
    If theField.FileExists Then
        ' If you want to store your files as BLOBs in the database, then you should
        ' comment the next line
        CreateFolders()

        vFilename = theField.SafeFileName
        vFilename = gNamespace.SaveAttachmentMetaData(vFilename, theField.Length, theForm("link"), theForm("hide"), theForm("comment"))

        ' Save to filesystem.
        theField.Save OPENWIKI_UPLOADDIR & gPage & "/" & vFilename
    End If
    Response.Redirect(gScriptName & "?p=" & Server.URLEncode(gPage) & "&a=attach")
    Response.End
End Sub


Sub ActionHidefile
    Call gNamespace.HideAttachmentMetaData(Request("file"), Request("rev"), 1)
    Response.Redirect(gScriptName & "?p=" & Server.URLEncode(gPage) & "&a=attach")
    Response.End
End Sub

Sub ActionUndohidefile
    Call gNamespace.HideAttachmentMetaData(Request("file"), Request("rev"), 0)
    Response.Redirect(gScriptName & "?p=" & Server.URLEncode(gPage) & "&a=attach")
    Response.End
End Sub

Sub ActionTrashfile
    Call gNamespace.TrashAttachmentMetaData(Request("file"), Request("rev"), 1)
    Response.Redirect(gScriptName & "?p=" & Server.URLEncode(gPage) & "&a=attach")
    Response.End
End Sub

Sub ActionUndotrashfile
    Call gNamespace.TrashAttachmentMetaData(Request("file"), Request("rev"), 0)
    Response.Redirect(gScriptName & "?p=" & Server.URLEncode(gPage) & "&a=attach")
    Response.End
End Sub

Sub ActionAttachchanges
    Call gTransformer.Transform(gNamespace.GetPageAndAttachments(gPage, 0, False, True).ToXML(0))
    gActionReturn = True
End Sub



' If you want to store your files as BLOBs in the database, then you'd need
' to change this function.
'
' IN:
'   pPagename : page that has the attachment
'   pFilename : filename of the attachment
' RETURN: full URL to view/download the attachment
Function GetAttachmentLink(pPagename, pFilename)
    GetAttachmentLink = gServerRoot & OPENWIKI_UPLOADDIR & pPagename & "/" & pFilename
End Function


' Create all the subfolders if they do not exist yet.
Sub CreateFolders()
    Dim vFSO, vPosBegin, vPosEnd, vPath
    Set vFSO = Server.CreateObject("Scripting.FileSystemObject")
    If Not vFSO.FolderExists(Server.MapPath(OPENWIKI_UPLOADDIR & gPage & "/")) Then
        vPosBegin = 1
        vPath = Server.MapPath(OPENWIKI_UPLOADDIR)
        Do While True
            vPosEnd = InStr(vPosBegin, gPage, "/")
            If vPosEnd > vPosBegin Then
                vPath = vPath & "\" & Mid(gPage, vPosBegin, vPosEnd - vPosBegin)
                If Not vFSO.FolderExists(vPath) Then
                    Call vFSO.CreateFolder(vPath)
                End If
                vPosBegin = vPosEnd + 1
            Else
                vPath = vPath & "\" & Mid(gPage, vPosBegin)
                If Not vFSO.FolderExists(vPath) Then
                    Call vFSO.CreateFolder(vPath)
                End If
                Exit Do
            End If
        Loop
    End If
End Sub


%>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jonathan Hodgson
Web Developer
United Kingdom United Kingdom
Jonathan Hodgson works as Software Developer in London, UK.
 
He started programming in the '80s on a trusty 48k Spectrum before moving to PC development in the early 90s. During the working week most of his time is spent involved in application development both Windows and Web-based; .NET, C#, ASP.NET, SQL Server.
 
He is a Microsoft Certified Software Developer (MCSD) and MCP for developing web applications using ASP.NET in C# and is always looking for new projects and challenges to work on.
 
http://www.jonathanhodgson.co.uk/

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 8 Feb 2004
Article Copyright 2004 by Jonathan Hodgson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid