Click here to Skip to main content
15,895,709 members
Articles / Programming Languages / SQL

A Free Website Management System - Nukedit

Rate me:
Please Sign up or sign in to vote.
3.38/5 (25 votes)
9 Sep 2010CPOL3 min read 173.9K   728   93  
Realtime page editing, simple, "on-the-fly" menu construction, modifiable permissions for users and groups, built-in search engine optimisation
<!--#include file="../includes/inc_main.asp"-->
<!--#include file="../includes/setup.asp"-->
<!--#include file="../includes/inc_misc.asp"-->
<!--#include file="../includes/inc_dbfunctions.asp" -->
<!--#include file="../themes/standard.asp"-->
<% 
'#################################################################################
'## Copyright (C) 2003 Rick Eastes
'##
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or any later version.
'##
'## All copyright notices regarding EzyEdit
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to
'## http://www.ezyedit.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 the 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 the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
'##
'## Support can be obtained from support forums at:
'## http://www.ezyedit.com/forum
'##
'## Correspondence and Marketing Questions can be sent to:
'## rick@ezyedit.com
'## 191 Dorville Rd Carseldine.
'## Brisbane, Australia. 4034
'##
'#################################################################################

response.buffer = true 
WriteHeader "",""
%>

<style>
DIV.divobject
{
    LEFT: <%=setup_MenuWidth+30%>;
    VISIBILITY: hidden;
    WIDTH: 600px;
    POSITION: absolute;
    TOP: <%=setup_HeaderHeight+10%>;
}
DIV.divobjectv
{
    LEFT: <%=setup_MenuWidth+30%>;
    VISIBILITY: visible;
    WIDTH: 600px;
    POSITION: absolute;
    TOP: <%=setup_HeaderHeight+10%>;
}
</style>

<script language="JavaScript">
<!--
// This script is used to get the value from a popup window and insert it into
// the parent window.

var PowerWindow;
var SelectedValue;
var myObjectID; // So we know which text box the pop up window is supposed to write to
//myObjectID = "document.frmTimes.client1"

function openPowerWindow(textBoxObject,url)
{
  // This is complex. Email reastes@mail.com cause I don't have time to comment now
  myObjectID = textBoxObject;
  PowerWindow = window.open(url,'new_page','toolbar=no,width=400,height=600,directories=no,status=yes,scrollbars=yes,menubar=no');
  PowerWindow.location.href = url;
  if (PowerWindow.opener == null) PowerWindow.opener = self; 
}

function restart() {
    myObjectID.value = SelectedValue;
	PowerWindow.close();	
}

function selectLayer(strDivName){
	hideLayer('divAddDocument');
	hideLayer('divDeleteDocument');
	hideLayer('divFileListing');	
	hideLayer('divEditDocument');
	showLayer(strDivName);
}

function leapto(form,url) {
var myindex=form.employeeid.selectedIndex
location.href=(url+'?user='+form.employeeid.options[myindex].value);
}
-->
</script>

<%
'Nov 2001
'
'Check logged in

'	Session("Authenticated") = 1
'	Session("GroupID") = 1
'		Remember when last loged in and set session with last loggin
'		strToday = year(date) & "-" & month(date) & "-" & day(date)
'		strToday = year(date) & "-" & month(date) & "-" & day(date)-2 'DEBUG

		
'		if(isnull(Session("dtLastLogin"))  OR  (Session("dtLastLogin") = "")  OR  (len(Session("dtLastLogin")) = 0)) then
'			Session("dtLastLogin") = Request.Cookies("strLastLogin")
'		end if
''		Response.Cookies("strLastLogin") = strToday
'		Response.Cookies("strLastLogin").Expires = "01/01/2038" 'I wonder if the year 9999 bug will be a problem.


action = request("action")
username = Session("username")

intCategory = request("categoryid")
if len(intCategory) < 1 then
	intCategory = -1 ' just show new documents
end if

thispage = "documents.asp"

'###################################### PROCESS ACTIONS ###################################### 

'############## ADD DOCUMENT
if (action="Add") then
	documentsize = encode(request("documentsize"))
	documentname = encode(request("documentname"))
	documentpath = encode(request("documentpath"))
	documenttype = encode(request("documenttype"))	
	documentdescription = encode(request("documentdescription"))
	documentcategory = request("documentcategory")
	documentpermissions = request("permissions")
	permissiontype = request("defaultpermissiontype")
	defaultpermissions = request("defaultpermission")
	documentowner = Session("MemberName")
	documentnotify = request("documentnotify")
	if(not documentnotify = true) then
		documentnotify = false
	end if
		
		
	InsertIntoTable "tblDocuments", _
		"strName,strPath,strDescription,permissions,strType,strUserName,strSize,intCategory,bNotify,dtEntered", _
		"'" & documentname & "','" & documentpath & "','" & documentdescription & "','" & defaultpermissions & "$" & permissiontype & "$" & documentpermissions & "','" & documenttype & "','" & documentowner & "','" & documentsize & "','" & documentcategory & "'," & documentnotify & ",#" & year(date()) & "-" & month(date()) & "-" & day(date()) & "#"
end if

'############## EDIT DOCUMENT
if (action="DoEdit") then
	documentsize = encode(request("documentsize"))
	documentname = encode(request("documentname"))
	documentpath = encode(request("documentpath"))
	documenttype = request("documenttype")	
	documentdescription = encode(request("documentdescription"))
	documentcategory = request("documentcategory")
	documentpermissions = request("permissions")
	permissiontype = request("defaultpermissiontype")
	defaultpermissions = request("defaultpermission")
	documentowner = Session("MemberName")
	documentnotify = request("documentnotify")
	if(not documentnotify = true) then
		documentnotify = false
	end if		
		
	UpdateTable "tblDocuments", _
		"strName,strPath,strDescription,permissions,strType,strUserName,strSize,intCategory,bNotify,dtEntered", _
		"'" & documentname & "','" & documentpath & "','" & documentdescription & "','" & defaultpermissions & "$" & permissiontype & "$" & documentpermissions & "','" & documenttype & "','" & documentowner & "','" & documentsize & "','" & documentcategory & "'," & documentnotify & ",#" & year(date()) & "-" & month(date()) & "-" & day(date()) & "#" , _
		"intID = " & request("documentid")
end if

'############## DELETE DOCUMENT
if (action="Delete") then
	DeleteFromTable "tblDocuments" , "intID=" & request("documentid")
end if


'###################################### END PROCESS ACTIONS ###################################### 
%>

<tr><td>

<%
SetDatabase(dbSite)
response.write "<table><tr><td valign=top>"
'response.write "<table border=0 cellpadding=1 cellspacing=0 bgcolor=white>"
'WriteCategoryList("intID > 0")
'response.write "</table>"
response.write "</td><td valign=top>"
'################################################################ MAIN PART OF PAGE STARTS HERE

if(action = "edit") then
	response.write"<div id=divFileListing class=divobject>"
else response.write"<div id=divFileListing class=divobjectv>" end if

if (IsAllowed(rsPage("permissions")) >= 2) then
	response.write "<a href=""#"" onClick=""javascript:selectLayer('divAddDocument');"" class=link><img src=""" & site & "gfx/button-adddocument.gif"" border=0 height=19 class=""opacity50""></a><br>"
end if

	if intCategory = 0 then
		response.write "<font size=1>Documents that have been updated or added since you last logged in</font>"
	elseif intCategory = "-1" then
		response.write "<font size=1>All Documents that you have permission to see.</font>"
	else
		strCatDesc = GetData("tblDocCategories","strDescription","intID=" & intCategory)
		response.write "<font size=1>" & strCatDesc & "</font>"
	end if
	response.write "<table border=0 cellpadding=1 cellspacing=0 height=10><tr><td bgcolor=black>"
	response.write "<table border=0 cellpadding=1 cellspacing=0 bgcolor=white width=600>"
	WriteFileList "intCategory=" & intCategory
	response.write "</td></tr></table>"
	response.write "</td></tr></table>"
response.write "</div>"


if ((IsAllowed(rsPage("permissions")) >= 2)) then

	response.write"<div id=divAddDocument class=divobject>"
	response.write "<table border=0 cellpadding=5 cellspacing=1 bgcolor=white width=600>"
	response.write "<tr><td colspan=1 class=tabledata>"
	response.write "<form name=frmAddDocument method=post action=documents.asp>"
	response.write "<input type=hidden name=action value=""Add"">"
	response.write "<input type=hidden name=categoryid value=""" & request("categoryid") & """>"
	response.write("<b>Document Title</b> eg(mycode.doc)<br>")
	response.write("<input type=text name=documentname class=textfield></td>")
	
	response.write("<td colspan=2 class=tabledata><b>Category</b><br>")
	Response.Write "<select name=documentcategory class=""selectfield"">"
	WriteDropDown "tblDocCategories","strName","intID","",""
	Response.Write "</select>"
	
	response.write("</td></tr><tr><td colspan=2 class=tabledata><b>Document Path</b> eg(DOCUMENTS\mycode.doc)<br>")
	response.write("<input type=text name=documentpath class=textfield size=35></td>")
	
	response.write("<td class=tabledata valign=bottom><input type=button value=""Upload File"" class=button onClick=""openWindowShort('uploader/uploadform.htm');""></td></tr>")
	
			
	response.write("<tr><td class=tabledata><b>Document Type</b><br>") 
	response.write "<select name=documenttype class=""selectfield"">"
	WriteDropDown "tblDocumentType","strDescription","strName","",""
	Response.Write "</select>"

	response.write("</td><td colspan=2 width=400 class=tabledata><b>File Size</b> eg(542Kb)<br>")
	response.write("<input type=text name=documentsize class=textfield width=10></td></tr>")
	
	if(setup_IndividualDocPermissions = true)then
		Response.Write "<tr><td class=tabledata colspan=4>"
		WritePermissionsForm "ALLOW$R$","frmAddDocument"
		Response.Write "</td></tr>"
	end if
	
	response.write("</td></tr><tr><td colspan=4 valign=top class=tabledata><b>Description</b><br>")
	response.write("<textarea cols=30 rows=6 name=documentdescription class=textfield></textarea></td></tr>")

	response.write("<tr><td colspan=3 class=tabledata><input type=checkbox name=documentnotify class=checkbox size=35 checked><b>Notify?</b> (Other users will be notified that this document is new.)")
	response.write("<br></td></tr>")
	
	response.write "<tr><td colspan=3 class=tabledata><br><b>Please check your input and then click 'Add Document'</b><br><br><img src=""" & site & "gfx/button-cancel.gif"" onClick=""javascript:selectLayer('divFileListing');"">&nbsp;&nbsp;&nbsp;<input type=image src=""" & site & "gfx\button-adddocument.gif"">"%>
	
	</form>
	
<% 
response.write "</td></tr></table>"
response.write "</div>"
end if


response.write"<div id=divEditDocument class=divobjectv>"
if action = "edit" then
	set rsResults = db.execute("SELECT * from tblDocuments WHERE intID = " & request("documentid") & ";")
	response.write "<table border=0 cellpadding=5 cellspacing=1 bgcolor=white width=600>"
	response.write "<tr><td colspan=1 class=tabledata>"
	response.write "<form name=frmEditDocument method=post action=documents.asp>"
	response.write "<input type=hidden name=action value=""DoEdit"">"
	response.write "<input type=hidden name=documentid value=""" & request("documentid") & """>"
	response.write "<input type=hidden name=categoryid value=""" & request("categoryid") & """>"
	response.write("<b>Document Title</b> eg(mycode.doc)<br>")
	response.write("<input type=text name=documentname class=textfield value=""" & rsResults("strName") & """></td>")
	
	response.write("<td colspan=2 class=tabledata><b>Category</b><br>")
	Response.Write "<select name=documentcategory class=""selectfield"">"
	WriteDropDown "tblDocCategories","strName","intID", rsResults("intCategory") ,""
	Response.Write "</select>"
	
	response.write("</td></tr><tr><td colspan=3 class=tabledata><b>Document Path</b> eg(\documents\mycode.doc)<br>")
	response.write("<input type=text name=documentpath class=textfield size=35 value=""" & rsResults("strPath") & """><br></td></tr>")
			
	response.write("<tr><td class=tabledata><b>Document Type</b><br>") 
	response.write "<select name=documenttype class=""selectfield"">"
	WriteDropDown "tblDocumentType","strDescription","strName", rsResults("strType") ,""
	Response.Write "</select>"
	
	response.write("</td><td colspan=2 width=400 class=tabledata><b>File Size</b> eg(542Kb)<br>")
	response.write("<input type=text name=documentsize class=textfield width=10  value=""" & rsResults("strSize") & """></td></tr>")

	if(setup_IndividualDocPermissions = true)then
		Response.Write "<tr><td class=tabledata colspan=3>"
		WritePermissionsForm "ALLOW$R$","frmAddDocument"
		Response.Write "</td></tr>"
	end if
	
	response.write("<tr><td colspan=3 valign=top class=tabledata><b>Description</b><br>")
	response.write("<textarea cols=30 rows=6 name=documentdescription class=textfield>""" & rsResults("strDescription") & """</textarea></td></tr>")

	response.write("<tr><td colspan=3 class=tabledata><input type=checkbox name=documentnotify class=checkbox size=35")

	if rsResults("bNotify") = true then
		response.write(" checked ")
	end if
	response.write ("><b>Notify?</b> (Other users will be notified that this document is new.)")
	response.write("<br></td></tr>")
	response.write "<tr><td colspan=3 class=tabledata><br><b>Please check your input and then click 'Update Document'</b><br><input type=submit value="" Update Document"" class=button>"
	%>
	
	
	&nbsp;&nbsp;&nbsp;<input type=button value=" Cancel " class=button onClick="javascript:selectLayer('divFileListing');">
	</form>
	</td></tr></table>
	<% 
	rsResults.close
	end if %>
</div>


<div id=divDeleteDocument class=divobject>
	<table border=0 cellpadding=5 cellspacing=1>
	<tr><td colspan=1 class=normal>
	<form name="frmDeleteDocument" method="post" action="<%=thispage%>">
	<input type=hidden name=action value="Delete">
	<input type=hidden name=documentid value="">
	<b>Are you sure you wish to <font color=red>delete </font>this document?</b>
	<br><br><input type=image src="<%=site%>gfx/button-yes.gif">&nbsp;&nbsp;&nbsp;<img src="<%=site%>gfx/button-no.gif" onClick="javascript:selectLayer('divFileListing');"  class="link">
	</form>
	</td></tr></table>	
</div>

<%
'################################################################ END OF MAIN PART OF PAGE	
SetDatabase(dbJobBook)
response.write "</td></tr></table>"

response.write "</td></tr></table>" 'Close of main table cell
WriteFooter "N/A",rsPage("count")


Function WriteFileList(sqlWhere)
'sqlWhere simple sql statement to tell which entry to update. eg (WHERE userid > '12')

	sql = "SELECT * FROM tblDocuments"

	if not isnull(sqlWhere) then
		if sqlWhere = "intCategory=0" then
			sql = sql + " WHERE bNotify=true AND dtEntered >=#" & Session("dtLastLogin") & "#"
		elseif not sqlWhere = "intCategory=-1" then
			sql = sql + " WHERE " & sqlWhere
		end if
	end if
	
	sql = sql + " ORDER BY dtEntered;"
	'alert sql 'DEBUG

	set rsResults = db.execute(sql)
		response.write "<tr>"
		response.write "<td width=15 class=tableheader></td>"		
		response.write "<td width=150 class=tableheader>Document Name</td>"
		response.write "<td class=tableheader>Description</td>"		
		response.write "<td width=60 class=tableheader>File Size</td>"
		response.write "<td class=tableheader>Modified</td>"
		response.write "<td class=tableheader width=1>&nbsp;</td>"		
		response.write "</tr>"


	while ((not rsResults.EOF) AND (not rsResults.BOF))
		
			'if (setup_IndividualDocPermissions = true AND IsAllowed(rsResults("permissions")) > 0) OR 

			if (IsAllowed(rsPage("permissions")) > 0) then
			if toggle = true then 
				tableclass = "tabledata2"	
				toggle = false 
			else	
				tableclass = "tabledata" 
				toggle = true	
			end if

			response.write "<tr>"
			response.write "<td width=15 align=center valign=top><a href=""" & rsResults("strPath") &  """ target=_blank class=""link""><img src=""gfx/icon-" & rsResults("strType") & ".gif"" border=0></a></td>"		
			response.write "<td width=150 class=" & tableclass & " align=left valign=top><a href=""" & rsResults("strPath") &  """ target=_blank>" & rsResults("strName") & "</a></td>"
			response.write "<td class=" & tableclass & " align=left valign=top><font size=1>" & rsResults("strDescription") & "</font></td>"		
			response.write "<td width=40 class=" & tableclass & " align=left valign=top><font size=1>" & rsResults("strSize") & "</font></td>"
			response.write "<td width=60 class=" & tableclass & " align=left valign=top><font size=1>" & rsResults("dtEntered") & "</font></td>"
			response.write "<td width=31 class=" & tableclass & " align=left valign=top nobr>"
			if(IsAllowed(rsResults("permissions")) >= 2 ) then
				response.write "<a href=""documents.asp?action=edit&documentid=" & rsResults("intID") & "&categoryid=" & request("categoryid") & """ class=""link""> <img src=""gfx/icon-edit.gif"" border=0 alt=edit></a><a href=""javascript:document.frmDeleteDocument.documentid.value=" & rsResults("intID") & ";selectLayer('divDeleteDocument');"" class=""link""><img src=""gfx/icon-delete.gif"" border=0 alt=delete></a>"
			end if
			response.write "</td></tr>"
		end if
		rsResults.movenext
	wend



	rsResults.close
	set rsResults = nothing

end Function


Function WriteCategoryList(sqlWhere)
'sqlWhere simple sql statement to tell which entry to update. eg (WHERE userid > '12')

	sql = "SELECT * FROM tblDocCategories"

	if not isnull(sqlWhere) then
		sql = sql + " WHERE " & sqlWhere
	end if
	
	sql = sql + " ORDER BY strName;"
'	alert sql 'DEBUG

	set rsResults = db.execute(sql)


	'Link for new documents
	response.write "<tr>"
	response.write "<td align=left valign=top><a href=""documents.asp?categoryid=0"" class=linkdark><img src=""gfx/icon-folder-hot.gif"" border=0> <i>New</i> Documents</a> </td>"
'	response.write "<td class=tabledata align=left valign=top><font size=1>Show new documents since you last logged in.</font></td>"		

	'Link for ALL documents
	response.write "<td align=left valign=top><a href=""documents.asp?categoryid=-1"" class=linkdark><img src=""gfx/icon-folder.gif"" border=0> All Documents</a> </td>"
'	response.write "<td class=tabledata2 align=left valign=top><font size=1>Show all documents.</font></td>"		

	
	
	while ((not rsResults.EOF) AND (not rsResults.BOF))
		if IsAllowed(rsResults("permissions"))then
			tableclass = "" 
			response.write "<td class=" & tableclass & " align=left valign=top><a href=""documents.asp?categoryid=" & rsResults("intID") & """ class=linkdark> <img src=""gfx/icon-folder.gif"" border=0> " & rsResults("strName") &"</a> </td>"
		end if
		rsResults.movenext
	wend
	response.write "</tr>"
	
	rsResults.close
	set rsResults = nothing

end Function
%>


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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
From Brisbane, Australia.

Likes building stuff.

Comments and Discussions