Home
Download
User Info
New User FAQ
Tutorials
Demos
Commands
Variables
Troubleshooting
Code Examples
Sysop Info
Sysop FAQ
Theory
Installation
Management
Tests
Troubleshooting
FAQ
Feedback
Useful Links
Release Notes
Credits
Disclaimer

SourceForge Logo

This page contains a number of examples commonly requested for use in users' pages.

Blocks of code that can easily be inserted into NeoWebScript documents or .htaccess files and <Directory></Directory> blocks are highlighted in red.

If you're looking for more general answers to questions, you can read the NeoWebScript Frequently Asked Questions page.


Examples

1. How can I add just a plain counter to my webpage?
2. How can I add a graphical counter to my webpage?
3. How can I make it so that a directory can only be accessed by users with an account on my system?
4. How can I password protect a directory using usernames and passwords stored in DB files?
5. How can I read in all the lines in a file one-by-one and do something to them?
6. How can I read in all the lines in a file all at once?
7. How can I make a single header file appear at the top of all my documents?
8. How can I make a single footer file appear at the bottom of all my documents?

1. How can I add just a plain counter to my webpage?

Where Used:
  • NeoWebScript document

    <nws>html [incr_page_counter]</nws>
    This will spit a number out to the page. You can surround it with any kind of HTML text you want for the counter to read like you like.

    2. How can I add a graphical counter to my webpage?

    Where Used:
  • NeoWebScript document

    <nws>
    html [display_graphic_num -font set0 [incr_page_counter]]
    </nws>
    -font can be any of set0 - set38. An example of the fonts can be seen in the documentation for the command.

    3. How can I make it so that a directory can only be accessed by users with an account on my system?

    Where Used:
  • <Directory></Directory> block in httpd.conf
  • .htacess file

    AuthName "Protected Area"
    AuthType Basic
    TclAuthBasic tcl_passwd_auth
    TclAuthAccess tcl_passwd_access
    require valid-user
    With this code installed, only users with an account on the system will be able to see access the directory. They must type their login and password for the system to see the directory.

    NOTE:
    mod_auth_tcl must have been compiled and installed on your NeoWebScript server.


    4. How can I password protect a directory using usernames and passwords stored in DB files?

    Where Used:
  • NeoWebScript document

    AuthName "Protected Area"
    AuthType Basic
    TclAuthBasic tcl_db_auth username dbfilename
    TclAuthAccess tcl_db_access
    require valid-user
    Replace username with the person who owns the DB file and dbfilename with the name of the db file you have the users stored in. The passwords must be stored in the database using the -singleVar option to dbstore.

    5. How can I read in all the lines in a file one-by-one and do something to them?

    Where Used:
  • NeoWebScript document

    set fp [open filename]
    while {[gets $fp line] != -1} {
      DO SOMETHING TO $line
    }
    Replace filename with the name of the file in the local directory. If you are in a safe interpreter, you cannot open a file outside of the current directory.

    6. How can I read in all the lines in a file all at once?

    Where Used:
  • NeoWebScript document

    set lines [read_file filename]
    foreach line [split [string trim $lines] \n] {
      DO SOMETHING TO $line
    }
    Replace filename with the name of the file in the local directory. This method is much faster and less expensive than reading the lines one-by-one. You must remember that the last in the file will cause a null element to be appended as the last element of the list. We string trim the lines to get around this.

    7. How can I make a single header file appear at the top of all my documents?

    Where Used:
  • <Directory></Directory> block in httpd.conf
  • .htacess file

    NeoWebUserConf HeaderFile header.nhtml
    Replace header.nhtml with the filename you want displayed as the header. This file will be displayed before every file in the current directory and every subdirectory beneath it.

    8. How can I make a single footer file appear at the bottom of all my documents?

    Where Used:
  • <Directory></Directory> block in httpd.conf
  • .htacess file

    NeoWebUserConf FooterFile footer.nhtml
    Replace footer.nhtml with the filename you want displayed as the footer. This file will be displayed after every file in the current directory and every subdirectory beneath it.