AndyDvorak.net  -  Suggest a Feature  -  Report a Bug  -  Check for Updates  -  Help

SiteProtect Documentation

Thank you for download SiteProtect!  This documentation is designed to help give you a better feel for the app, and show you how to completely customize this app to suit your needs.

:: Installation / Setup
:: Settings
:: Protecting Your Site
:: Giving Users Privileges
:: Skinning SiteProtect
:: Custom Start Pages
:: Connection Types
:: Write Permissions
:: More Help
:: More Free Stuff!
:: Copyright

:: Installation / Setup

  1. To install SiteProtect, first unzip siteprotect.zip to a folder within your website that you wish to use as a login point, like "/login/" or "/protect/".
  2. Open up the file "inc_protect.asp", and change dbPath to point to your database.  Select your connection type, and change the variables accordingly:

    DSN-less Connection
    dbPath = "NAME_OF_DSN"
    useDSN = 1

    DSN Connection
    dbPath = "/databases/siteprotect.mdb"
    useDSN = 0


    More information on connection types

:: Settings

  1. Open up your web browser, and type in the address of your website, followed by the folder you installed SiteProtect to (e.g. "www.yoursite.com/login/")
  2. Click "Log In", and enter the username and password of "admin".  Once you've logged in, you will want to change your username and password.  To do this, click "Preferences", and change your username, password, name, and email.  You can change any other information you wish to as well.
  3. Click on "Settings", and change the settings to match your site:

.: Homepage
Click on the link to the right of "Homepage".  You will need to select the file that acts as the homepage for your site.  For most sites, the file is /index.html, /index.asp, or default.asp.

.: Admin Email
The admin email setting is for users to email you from the Contact page, or to email you about a Lost Password.

.: Menu
This changes how the menu works.  "Images" will make the menu display links with images, whereas "Text" will display the menu in text format.

.: Mail Program
If selected, SiteProtect will send email using CDOSYS, and will connect to the mail server you specify.

.: Mail Server
This is the SMTP server of your website, used for sending email.  Usually, this is something like "smtp.yoursite.com" or "mail.yoursite.com".  If you do not have an SMTP server, just make one up, and then set Mail Program to "Do  not send email from SiteProtect".

.: Allow New Users
Allows new users to register.  If you select No, new users will not be able to register.

.: Logo
This allows you to upload your own logo to SiteProtect.  You can always change the rest of the site's design by Skinning SiteProtect.

:: Protecting Your Site

Protecting your website is easy.  There are four levels of user access:

1 = Administrator
2 = Moderator
3 = Registered user
4 = Unregistered user

So, if you would like to restrict access to only moderators and above, simply add these two lines to the top of your page:

<% privRequired = 2 %>
<!--#Include Virtual="/login/inc_protect.asp"-->

If a user attempts to access that page, and they are either not logged in or not authorized to view the page, they will be take to a login screen with a message telling them they first need to log in, or that they aren't authorized to view the page.  Once logged in, they will be taken back to the page they were initially trying to view.

Please keep in mind that the page you are protecting MUST be an ASP page with an extension of ".asp".  If you add this code to the top of an HTML page (".htm" or ".html"), it will NOT work.

:: Giving Users Privileges

Assigning privilege levels is most useful when you want to restrict pages of your website to only certain groups of users.  SiteProtect enables you to select 3 levels of privileges for registered users:

.: Administrator
Has access to all parts of SiteProtect.  May edit and delete users, and edit settings.  May view all pages protected by SiteProtect.

.: Moderator
Has intermediate access to SiteProtect.  May view users, but may not edit or delete them.  May not edit settings.  May view pages requiring Moderator privileges.

.: User
Limited access to SiteProtect.  May not edit or delete users, and may not edit settings.  May only edit their own profile and view pages requiring registration.

To assign a privilege level to a user, click on User List.  Select the user you want to give privileges to, and click Edit.  You will then be able to assign their privilege level.

PLEASE NOTE: The administrator with a user ID of 1 has super-admin rights, which means that it cannot be deleted.  It does, however, have access to delete other admins, but other admins do not have access to delete the super-admin.  DO NOT DELETE the user with the ID of 1, or change its privilege level.  Doing so will upset the SiteProtect system.

:: Skinning SiteProtect

SiteProtect allows you to easily apply your own skin, or Graphical User Interface (GUI).  To do this, you must first have the HTML for your interface ready.  The file MUST be named gui.html.  ASP code will NOT work within this file, and you cannot simply rename it to ".asp" because of the way SiteProtect works.  The format is as follows:

<html>
<head>
[TAG_TITLE]
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!--BEGIN STYLE-->
<style type="text/css">
// style information goes here
</style>
<!--END STYLE-->
<!--BEGIN SCRIPT-->
<script language="JavaScript" type="text/javascript">
// this function MUST remain in your HTML
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
</script>
<!--END SCRIPT-->

</head>

[TAG_BODY]
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">[LOGO]</td>
  </tr>
  <tr>
    <td width="100%" height="20" background="images/header_menu-bg.jpg">[MENU]</td>
  </tr>
  <tr>
    <td width="100%" height="100%" valign="top" style="padding: 14px">[CONTENT]</td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#F8F8F8" style="padding: 4px; border-top: 1px solid #E1E1E1">Copyright &copy; [YEAR] <a href="[HOMEPAGE]">[TITLE]</a></td>
  </tr>
</table>
</body>
</html>

Here's how it works: wherever you want the content of the page to be, type [CONTENT] (in all upper case).  You must also replace the <title></title> with [TAG_TITLE] (also in all caps), and the <body> with [TAG_BODY].  Wherever you want your logo to go, place a [LOGO].  For the menu, put [MENU].  When you insert styling into the page (with <style></style> tags), make sure it is surrounded by the Begin Style and End Style markers, like so:

<!--BEGIN STYLE-->
<style type="text/css">
// style information goes here
</style>
<!--END STYLE-->

This will make sure that SiteProtect can find the style information and place it onto each page.  Tags marked in red are required, and tags in blue are strongly suggested, but not required.  SiteProtect will replace these tags with environment variables that you specify in Settings.  This makes it much easier to quickly update your website through SiteProtect, instead of having to change the GUI.

Variable list:

[TAG_TITLE] = Current page's title (e.g. "<title>YourSite.com - Page Title</title>")
[TAG_BODY] = Body tag (e.g. "<body>")
[CONTENT] = Page content
[LOGO] = Website logo
[MENU] = Menu
[TITLE] = Your website's title (e.g. YourSite.com)
[HOMEPAGE] = Your homepage
[YEAR] = The current year
[DATE] = The current date
[TIME] = The current time

A copy of the PSD (Photoshop) file used in creating the skin that comes with SiteProtect is included in the ZIP file, under /images/PSD/.  If you would like to keep the clean, simplistic look of the original skin, simply modify the file "gui.psd" in Photoshop to show your logo, and you're all set.  I even included the fonts I used along with :)

:: Custom Start Pages

There are four pages within the SiteProtect folder:

.: startPage1.asp
Start page that administrators see when they log in

.: startPage2.asp
Start page that moderators see when the log in

.: startPage3.asp
Start page that registered users see when the log in

.: startPage4.asp
Start page that unregistered users see when the log in

You can go ahead and edit each one of these to display whatever content you want the users to see when they log in or click Home.  You may use ASP code.  You do NOT need to add code to the top of the page to protect it ("<% privRequired = 1 %>" or whatever), it is already taken care of by SiteProtect.

:: Connection Types

There are two basic connection types for connecting to an Access database: a DSN-less connection and a DSN connection.  In either case, the database must have Write permissions to run.  More information on giving files Write permissions.  To make the decision as to which connection type you choose, you must first know the differences between the two:

.: DSN-less connection
A DSN-less connection uses the Microsoft Jet Database Engine to connect to your database.  It's quick and easy to set up.  However, if you move your database, you will also have to change the connection string to reflect that change.

.: DSN connection
A DSN connection is different from a DSN-less connection in that you set it up on the server and then forget about it.  If you move the database, all you have to do is change the path to it in the IIS manager, and all references so that DSN will automatically be directed to the new database path.  To set up a DSN connection, you must have physical access to the server.  Here's how to set one up:

  1. Click on the Start menu, and navigate to Control Panel > Administrative Tools > Data Sources (ODBC).
  2. Click on the System DSN tab, and click Add.
  3. Select Microsoft Access Driver (*.mdb), and click Finish.
  4. Type in a name for your DSN, without spaces or special characters.  You may type in a description if you wish.
  5. Under Database, click Select, and navigate to the database you want to use.  Select it, and click OK.  Now click OK.  And once more, click OK.

Now all you have to do is reference the name of the DSN you just created, and you're all set.

:: Write Permissions

You may receive an error telling you that the database is Read Only, and that SiteProtect cannot write information to the database.  This is because the database does not have Write permissions.  If you are not the administrator of your web server, or do not have physical access to the server, please ask your admin to give the file Write permissions.  If you are the admin, here's how you can give your database Write permissions:

  1. On the desktop, right-click on My Computer and select Manage.
  2. In the left window pane, navigate to Services and Applications > Internet Information Services > Web Sites > Default Web Site, and find your database.  Right click on it, and select Properties.
  3. In the Properties window, under the File tab, there is a checkbox labeled Write.  Check that box, and click OK.  You may then close the Computer Management console.

:: More Help

If you have trouble with anything, and this document does not provide the answers you need, please don't hesitate to email me.  I will be happy to answer any questions or concerns you have.

:: More Free Stuff!

For more free apps, backgrounds, and tutorials, check out www.andydvorak.net.

:: Copyright

SiteProtect is copyright © 2012 AndyDvorak.net.  You may use this program on as many servers and websites as you wish, and distribute it freely, so long as you do not charge any money or services for its use, and so long as all copyright notices are intact.  Please do not modify this page, as it is used as a reference.

Copyright © 2012 AndyDvorak.net