Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
server:web [2010/02/21 20:37] digitalmanserver:web [2020/03/10 11:33] – Apparently http:// assplodes everything... fix. Deuce
Line 1: Line 1:
 ====== Web Server ====== ====== Web Server ======
 +
 +The Synchronet Web Server serves static (e.g. files) and dynamic content to HTTP clients (e.g. web browsers).
  
 ===== Introduction ===== ===== Introduction =====
Line 11: Line 13:
  
  
-===== Web Server Configuration ===== +===== Configuration =====
-Most of the web server configuration is in your [[Startup INI]] file (usually +
-ctrl/sbbs.ini). The ''[Web]'' section contains the following unique settings:+
  
 +==== Startup INI [Web] Section Keys ====
  
-==== [Web] Section Keys ====+The ''[Web]'' section of your [[config:sbbs.ini]] file contains the following settings (keys):
  
 === RootDirectory === === RootDirectory ===
Line 25: Line 26:
 ''http://yourbbs.synchro.net/index.html'' will be served out of this directory. ''http://yourbbs.synchro.net/index.html'' will be served out of this directory.
  
-::!:: Older versions of Synchronet had this value default to ''../web/html''.+**NOTE**: Older versions of Synchronet had this value default to ''../web/html''
  
 === ErrorDirectory === === ErrorDirectory ===
 Default value: ''error'' Default value: ''error''
  
-The directory relative to [#RootDirectory]] where the various error+The directory relative to [[#RootDirectory]] where the various error
 message files are located.  The error message files are named by the message files are located.  The error message files are named by the
 numeric HTTP error code they will represent and may be either ''.html'' numeric HTTP error code they will represent and may be either ''.html''
Line 48: Line 49:
 === Authorization === === Authorization ===
  
-Default value: ''Basic,Default''+Default value: ''Basic,Digest''
  
 A comma-separated list of authentication mechanisms in order of preference. A comma-separated list of authentication mechanisms in order of preference.
Line 112: Line 113:
 Default value: ''NO_HOST_LOOKUP'' Default value: ''NO_HOST_LOOKUP''
  
-The | separated list of options to enable.  In addition to the standard +The ''Options'' key is set to a ''|'' separated list of options to enable.  In addition to the [[config:sbbs.ini|standard options]], the web server also supports the following: 
-options, the web server also supports the following:+ 
 +''DEBUG_RX''
  
-  * ''DEBUG_RX'' \\ 
 Log all received data to the console log, as well as various Log all received data to the console log, as well as various
 extra bits related to receiving data. extra bits related to receiving data.
  
-  *  DEBUG_TX +''DEBUG_TX''
-        Log all transmitted data except the reply body itself, as well +
-        as various extra bits of information related to transmitted +
-        data. +
-    VIRTUAL_HOSTS +
-        Supports name-based virtual hosts.  If your system has multiple +
-        host names, you can have each host name return unique content +
-        depending on which hostname is used.  ie: if +
-        freebsd.synchro.net and nix.synchro.net both resolved to your +
-        system, you could have FreeBSD-specific pages on one, and  +
-        general *nix stuff on the other. +
-        A virtual host is added by simply putting the desired content +
-        into a sub-directory of RootDirectory with the desired hostname +
-        ie: web/root/freebsd.synchro.net/ if the browser doesn't send +
-        the request host name (very old browsers, or some automated +
-        tools) they will be served out of document root. +
-        It is therefore a good idea to put links to your various +
-        virtual hosts in an index.html page in RootDirectory something +
-        like this: +
-            <html> +
-              <head> +
-                <title>Old Browser</title> +
-              </head> +
-              <body> +
-                Your browser is either too old to support +
-                name-based virtual hosts, or you have visited a +
-                virtual hosts that is not yet configured.  The +
-                following are hosted here:<br> +
-                <a href="freebsd.synchro.net">freebsd.synchro.net +
-                </a><br> +
-                <a href="nix.synchro.net">nix.synchro.net</a><br> +
-              </body> +
-            </html> +
-    NO_CGI +
-        Disable CGI script execution. +
-    HTTP_LOGGING +
-        Enable logging to a Common Logfile Format log as described in +
-        the HttpLogFile section.  Usefull for running log analysis +
-        programs (like Webalizer: http://www.mrunix.net/webalizer/+
-    NO_JAVASCRIPT +
-        Disable SSJS execution.+
  
 +Log all transmitted data except the reply body itself, as well
 +as various extra bits of information related to transmitted
 +data.
  
-2.2Other web-related configuration files +''VIRTUAL_HOSTS'' 
------------------------------------------- + 
-In addition to the [Web] keys in the initialization file, the web server+Supports name-based virtual hosts If your system has multiple 
 +host names, you can have each host name return unique content 
 +depending on which hostname is used ie: if 
 +''freebsd.synchro.net'' and ''nix.synchro.net'' both resolved to your 
 +system, you could have FreeBSD-specific pages on one, and  
 +general *nix stuff on the other. 
 + 
 +A virtual host is added by simply putting the desired content 
 +into a sub-directory of [[#RootDirectory]] with the desired hostname 
 +ie: ''web/root/freebsd.synchro.net/'' if the browser doesn't send 
 +the request host name (very old browsers, or some automated 
 +tools) they will be served out of document root. 
 +It is therefore a good idea to put links to your various 
 +virtual hosts in an ''index.html'' page in [[#RootDirectory]] something 
 +like this: 
 +<code html> 
 +<html> 
 +  <head> 
 +    <title>Old Browser</title> 
 +  </head> 
 +  <body> 
 +    Your browser is either too old to support 
 +    name-based virtual hosts, or you have visited a 
 +    virtual hosts that is not yet configured.  The 
 +    following are hosted here:<br> 
 +    <a href="freebsd.synchro.net">freebsd.synchro.net</a><br> 
 +    <a href="nix.synchro.net">nix.synchro.net</a><br> 
 +  </body> 
 +</html> 
 +</code> 
 + 
 +''NO_CGI'' 
 + 
 +Disable CGI script execution. 
 + 
 +''HTTP_LOGGING'' 
 + 
 +Enable logging to a Common Logfile Format log as described in 
 +the HttpLogFile section.  Usefull for running log analysis 
 +programs (like Webalizer: http://www.mrunix.net/webalizer/
 + 
 +''NO_JAVASCRIPT'' 
 + 
 +Disable SSJS execution. 
 + 
 +''ALLOW_TLS'' 
 + 
 +Enable TLS support. 
 + 
 +''HSTS_SAFE'' 
 + 
 +Indicates that all URLs availabe via http are also available via https and redirects clients who want a TLS session to the https location. 
 + 
 +==== Other configuration files ==== 
 + 
 +In addition to the ''[Web]'' keys in the [[config:sbbs.ini]] file, the web server
 also uses some other configuration files: also uses some other configuration files:
  
-    ctrl/mime_types.ini +=== ctrl/mime_types.ini === 
-        Contains the file extension to mime-type mapping.  Each line +Contains the file extension to mime-type mapping.  Each line 
-        is in the format "extension = mime-type" ie: "html = text/html" +is in the format "extension = mime-type" ie: "html = text/html" 
-        The extensions are case-insensitive and do not include the '.'+The extensions are case-insensitive and do not include the '.'.
-    ctrl/webicons.ini +
-        Contains the URLs to the icons used by the default 404.ssjs +
-        script for each file type/extension.  Format is "extension = URL"+
-        Example: "html=/icons/layout.gif" Two "magical" extensions exist: +
-        DIRECTORY which is used for directories and DefaultIcon which +
-        is used for extensions which don't exist in the list. +
-    ctrl/web_handler.ini +
-        Contains 2 sections, [CGI] and [JavaScript], where a list of file +
-        extensions and their associated content-creation handlers are +
-        specified. The [CGI] section is for natively-executed CGI handlers +
-        (e.g. "pl = perl" indicates "perl" will be used to handle ".pl" +
-        files). The [JavaScript] section is used for JS-executed content +
-        handlers (e.g. "xjs = xjs_handler.js"). +
-    ctrl/cgi_env.ini +
-        Contains a list of system environment variables to pass to CGI +
-        processes.  Each variable can have an optionally specified default +
-        value, over-ridden value, and prepended or appended text.+
  
 +=== ctrl/webicons.ini ===
 +Contains the URLs to the icons used by the default 404.ssjs
 +script for each file type/extension.  Format is "extension = URL".
 +Example: "html=/icons/layout.gif" Two "magical" extensions exist:
 +DIRECTORY which is used for directories and DefaultIcon which
 +is used for extensions which don't exist in the list.
  
-2.3. webctrl.ini per-directory configuration file +=== ctrl/web_handler.ini ===
------------------------------------------------- +
-Each directory may have a webctrl.ini file which overrides certain settings for +
-the directory it's in and all child directorys.  Configuration keys may be set +
-either globally, or in a per-filename group.  Using the * and ? wildcards as +
-the group name such as [*.html].  The following keys may be used in these files:+
  
-AccessRequirements: +This file contains 2 sections where a list of file 
- Specifices an ARS string which all users must match to be able to access +extensions and their associated content-creation handlers are 
- files in this directory.  Will force an HTTP login. +specified:
-Realm: +
- Sets the realm that is displayed to the user for the HTTP login. +
- Default is the BBS name. +
-DigestRealm: +
- Sets the realm that is displayed to the user for the HTTP login when +
- Digest authentication is being used.  Default is the Realm value. +
-Authorization: +
- A comma-separated list of authentication mechanisms in order of +
- preference.  The standards say that Basic must come first, but no +
- browser currently appears to use Digest if Basic is listed first. +
- Supported values are Basic and Digest.  Digest is more secure as the +
- users password is never sent over the wire. +
-ErrorDirectory: +
- Specifies a different directory to check for error pages.  If the error +
- page is not found, will still check the global error directory. +
-CGIDirectory: +
- Specify an alternate CGI directory to check for CGI files. +
-PathInfoIndex: +
- Specifies that the index files can be ran for unlocated pages in the +
- current directory.  This effecively works like a custom 404 page.+
  
-For example, to require a login, but allow *any* user to access files in a +== [CGI] == 
-directory, but only a sysop to access *.log files, the following could be used:+ 
 +The [CGI] section is for natively-executed CGI handlers 
 +(e.g. "pl = perl" indicates "perl" will be used to handle ".pl" files).   
 + 
 +== [JavaScript] == 
 + 
 +The [JavaScript] section is used for JS-executed content 
 +handlers (e.g. "xjs = xjs_handler.js"). 
 + 
 +=== ctrl/cgi_env.ini === 
 +Contains a list of system environment variables to pass to CGI 
 +processes.  Each variable can have an optionally specified default 
 +value, over-ridden value, and prepended or appended text. 
 + 
 + 
 +==== webctrl.ini per-directory configuration file ==== 
 +Each directory under the [[#RootDirectory]] may have a ''webctrl.ini'' file which overrides certain settings for 
 +the directory it's in and all child directories.  Configuration keys may be set 
 +either globally, in a per-filename group, or, in version 3.17 or greater, a per-directory-name group. 
 +Using the * and ? wildcards as the group name such as ''[*.html]'' or ''[dirname/]'' The following keys may be used in these files: 
 + 
 +=== AccessRequirements === 
 +Specifices an ARS string which all users must match to be able to access 
 +files in this directory.  Will force an HTTP login. 
 + 
 +For example, to require a login, but allow **any** user to access files in a 
 +directory, but only a sysop to access ''*.log'' files and .git directories, the following could be used: 
 +<file webctrl.ini>
 AccessRequirements=level 0 AccessRequirements=level 0
 [*.log] [*.log]
-AccessRequirements=level90+AccessRequirements=level 90 
 +[*.git] 
 +AccessRequirements=level 90 
 +</file> 
 + 
 +=== Realm === 
 +Sets the realm that is displayed to the user for the HTTP login. 
 +Default is the BBS name. 
 + 
 +=== DigestRealm === 
 +Sets the realm that is displayed to the user for the HTTP login when 
 +Digest authentication is being used.  Default is the [[#Realm]] value. 
 + 
 +=== Authorization === 
 +A comma-separated list of authentication mechanisms in order of 
 +preference.  The standards say that Basic must come first, but no 
 +browser currently appears to use Digest if Basic is listed first. 
 +Supported values are ''Basic'' and ''Digest'' Digest is more secure as the 
 +users password is never sent over the wire. 
 + 
 +=== ErrorDirectory === 
 +Specifies a different directory to check for error pages.  If the error 
 +page is not found, will still check the global error directory. 
 + 
 +=== CGIDirectory === 
 +Specify an alternate CGI directory to check for CGI files. 
 + 
 +=== PathInfoIndex === 
 +Specifies that the index files can be ran for unlocated pages in the 
 +current directory.  This effecively works like a custom 404 page. 
 + 
 +=== FastCGISocket === 
 +Specifies the socket and port of a FastCGI listener in the <Address>:<Port> format (ie: 127.0.0.1:9000).  Should be used with wildcard sections like this: 
 +<file webctrl.ini> 
 +[*.php] 
 +FastCGISocket=127.0.0.1:9000 
 +</file> 
 + 
 +Added on November 1st, 2015 to CVS (in 3.17a). 
 + 
 +See [[howto:php]] for details on using with PHP. 
 + 
 +=== Rewrite* === 
 +Specifies a Javascript snippet which can modify the http_request.request_string.  This allows internal redirects like the RewriteRule feature in Apache .htaccess files.  The key must *begin* with the string "Rewrite" which may be followed by any legal INI key characters.  The order of execution is not guaranteed. 
 + 
 +Added on November 3rd, 2015 to CVS (in 3.17a). 
 + 
 +=== JSPreExec === 
 +A JavaScript snippet which is executed in the same context as Rewrite* lines, but before any Rewrites are executed.  This allows load()ing some common code before execution... ie: ''JSPreExec=load(js.startup_dir+'/rewrite_lib.js');''.
  
 +Added on November 3rd, 2015 to CVS (in 3.17a).
  
-3.0 JavaScript Web Server Objects +===== JavaScript Objects =====
----------------------------------+
 In addition to the standard JavaScript objects, the web server provides the In addition to the standard JavaScript objects, the web server provides the
 following: following:
  
 +==== http_request object ====
  
-3.1 http_request object 
------------------------ 
 The http_request object contains information from the client that was included The http_request object contains information from the client that was included
 during this request.  This objects properties are as follows: during this request.  This objects properties are as follows:
  
-path_info    Contains extra path information that was included with the +=== path_info === 
-               request AFTER the URI which identified this script.  For  +Contains extra path information that was included with the 
-               example, if the request was for +request AFTER the URI which identified this script.  For  
-               http://www.synchro.net/script.ssjs/test/this then path_info +example, if the request was for 
-               would contain the string "/test/this" +''http://www.synchro.net/script.ssjs/test/this'' then path_info 
-method       - Contains the HTTP method used to run the script.  As of this +would contain the string "/test/this" 
-               writing, the available methods are "HEAD", "GET", "POST", and + 
-               "OPTIONS". +=== method === 
-virtual_path The virtual path that this URI was reached by.  This is the +Contains the HTTP method used to run the script.  As of this 
-               portion of the URI from the end of the host to the end of the +writing, the available methods are "HEAD", "GET", "POST", and 
-               filename. +"OPTIONS" 
-query        This object contains the values of any form data which was + 
-               submitted with the request.  This is an associative "array" of +=== virtual_path === 
-               name/value pairs.  THE VALUES ARE ARRAYS OF STRINGS.  The reason +The virtual path that this URI was reached by.  This is the 
-               for this is that it is legal and often usefull to have multiple +portion of the URI from the end of the host to the end of the 
-               form fields with the same name. +filename. 
-query_string If a query string was included, this is the raw, unparsed query + 
-               string. +=== query === 
-post_data    As with query_string but for data which was POSTed. +This object contains the values of any form data which was 
-header       - An associative array of header name/value pairs. +submitted with the request.  This is an associative "array" of 
-cookie       - Much like the query object, this object contains key/value pairs +name/value pairs.  THE VALUES ARE ARRAYS OF STRINGS.  The reason 
-               of set cookies.  Once again, this is an array of strings since +for this is that it is legal and often useful to have multiple 
-               multiple values for the same key can be set for cookies. +form fields with the same name. 
-real_path    The real OSs complete path to this script. + 
-ars          The ARS string which applies to this request. +=== query_string === 
-request_string The raw request string sent by the client. +If a query string was included, this is the raw, unparsed query 
-host         - The value of the host header for this request. +string. 
-vhost        The virtual host serving this request. + 
-http_ver     - The HTTP version used for this request as a string. +=== post_data === 
-remote_ip    The IP address of the client. +As with query_string but for data which was POSTed. 
-remote_host  If the web server does host lookups (disabled by default), this + 
-               is the remote hostname.+=== header === 
 +An associative array of header name/value pairs. 
 + 
 +=== cookie === 
 +Much like the query object, this object contains key/value pairs 
 +of set cookies.  Once again, this is an array of strings since 
 +multiple values for the same key can be set for cookies. 
 + 
 +=== real_path === 
 +The real OS'complete path to this script. 
 + 
 +=== ars === 
 +The ARS string which applies to this request. 
 + 
 +=== request_string === 
 + 
 +The raw request string sent by the client. 
 + 
 +=== host === 
 +The value of the host header for this request. 
 +=== vhost === 
 +The virtual host serving this request. 
 +=== http_ver === 
 +The HTTP version used for this request as a string. 
 + 
 +=== remote_ip === 
 +The IP address of the client. 
 + 
 +=== remote_host === 
 + 
 +If the web server does host lookups (disabled by default), this 
 +is the remote hostname. 
 + 
 + 
 +==== http_reply object ====
  
  
-3.2 http_reply object 
---------------------- 
 The http_reply object is used to pass information about the reply back to the The http_reply object is used to pass information about the reply back to the
 Synchronet web server.  The properties are as follows: Synchronet web server.  The properties are as follows:
  
-status       - HTTP status string.  The default is generally "200 Ok" +=== status ===
-header       - An associative array of headers to include with the reply.  The +
-               only pre-defined one is "Content-Type" which defaults to +
-               "text/html"+
-fast         - This optional property can be set to "true" to make write()s go +
-               directly to the client for HTTP/1.0 connections.  This prevents +
-               keep-alives from working but generally appears faster to the +
-               client.  Since HTTP/1.1 requests use chunked mode, this isn'+
-               required for HTTP/1.1.+
  
 +HTTP status string.  The default is generally "200 Ok"
  
-3.3 Extra global methods +=== header === 
------------------------- +An associative array of headers to include with the reply The 
-The web server also adds new global methods These are:+only pre-defined one is "Content-Type" which defaults to "text/html".
  
-set_cookie(string key, +=== fast === 
 +This optional property can be set to "true" to make write()s go 
 +directly to the client for HTTP/1.0 connections.  This prevents 
 +keep-alives from working but generally appears faster to the 
 +client.  Since HTTP/1.1 requests use chunked mode, this isn'
 +required for HTTP/1.1. 
 + 
 + 
 +==== Extra global methods ==== 
 + 
 +The web server also adds a new global JavaScript method that requests that the specified cookie be set: 
 + 
 +  set_cookie(string key, 
            string value             string value 
     [, time_t expires      [, time_t expires 
Line 299: Line 393:
     [, string path      [, string path 
     [, bool secure ]]]])     [, bool secure ]]]])
-               Requests that the specified cookie be set. 
  
- +===== The SSJS Template System =====
-4.0 The SSJS Template System +
-----------------------------+
 The default web pages use a SSJS Template engine which also allows for Theme  The default web pages use a SSJS Template engine which also allows for Theme 
 support. support.
  
-[Note:  With this latest implementation of SSJS, @@ codes no longer can be +[Note:  With this latest implementation of SSJS, @@ codes no longer can be nested.]
-nested.]+
  
  
-4.1 The SSJS Template Scheme +==== The SSJS Template Scheme ==== 
-----------------------------+
 Each page consists of four parts: Each page consists of four parts:
  
-    The Header (../web/templates/default/header.inc+=== The Header  === 
-        This file contains the basic requirements for the HTML page. +  ../web/templates/default/header.inc  
-        The opening HTML, doctype, title, CSS file link, etc.  The +
-        header file includes the open body, System Name, and User  +
-        greeting plus the initial page layout table start.  The rest +
-        of the layout is continued in the next files.+
  
-    Top Navigation (../web/templates/default/topnav.inc &  +This file contains the basic requirements for the HTML page. 
-        ../web/lib/topnav_html.ssjs) +The opening HTML, doctype, title, CSS file link, etc The 
-        The topnav.inc file contains the basic design of the "breadcrumbs" +header file includes the open body, System Name, and User  
-        The links are dynamically generated by topnav_html.ssjs so both +greeting plus the initial page layout table start.  The rest 
-        files need to be addressed when modifying or creating themes. +of the layout is continued in the next files.
-        In the case of the default layouttopnav.inc has a left and right  +
-        graphic and a middle section that the dynamic content goes.  The +
-        background image is handled by CSS.  You can change this to anything +
-        you like. +
-        The topnav_html.ssjs file may seem daunting at first, but it is  +
-        pretty straight forward.  It has a series of if statements that +
-        check the current page location and sets up the breadcrumbs based +
-        on what you want it to say. +
-        For example: +
-            You want to add a Links page called links.html in the main  +
-            directory You would add a check for the path to links.html +
-            as:   +
-                if(http_request.virtual_path=="/links.html"+
-                    template.topnav.push({html: '<span class="tlink"> +
-                        Some Links</span>'});+
  
-    Left Side Navigation (../web/templates/default/leftnav.inc & +=== Top Navigation ===
-        ../web/lib/leftnav_nodelist.ssjs & ../web/lib/leftnav_html.ssjs) +
-        This starts the main table layout in the default layout and also +
-        provides two other things -- the main navigation links and a brief +
-        nodelisting that displays when users are online via telnet. +
-        The links are dynamically created as in the Top Navigation example +
-        above with the exception of the two static links.+
  
-    Main Content (various files) +  ../web/templates/default/topnav.inc 
-        This is where the layout of the main content is created.  It is best +  ../web/lib/topnav_html.ssjs
-        to look at the various files in ../web/templates/default  +
-        ../web/templates/default/msgs to see how the code is dispayed for the +
-        various functions of the Web side of Synchronet.  Some details on what +
-        each of the special codes contained in those files do will follow.+
  
-    Footer (../web/templates/default/footer.inc+The ''topnav.inc'' file contains the basic design of the "breadcrumbs" 
-        This file contains the closing HTML and whatever bottom information +The links are dynamically generated by ''topnav_html.ssjs'' so both 
-        you would like. In the case of the default layout, the +files need to be addressed when modifying or creating themes. 
-        Web Server/Synchronet versions and the XHTML 1.0 logo.  Links to +In the case of the default layout, ''topnav.inc'' has a left and right  
-        privacy statements or anything else can be placed here and they will  +graphic and a middle section that the dynamic content goes The 
-        be displayed at the bottom of each page.+background image is handled by CSS.  You can change this to anything 
 +you like.
  
 +The ''topnav_html.ssjs'' file may seem daunting at first, but it is 
 +pretty straight forward.  It has a series of if statements that
 +check the current page location and sets up the breadcrumbs based
 +on what you want it to say.
 +
 +For example:
 +You want to add a Links page called links.html in the main 
 +directory.  You would add a check for the path to links.html
 +as:
 +
 +<code javascript>
 +if(http_request.virtual_path=="/links.html")
 +    template.topnav.push({html: '<span class="tlink">Some Links</span>'});
 +</code>   
 +  
 +=== Left Side Navigation ===
 +
 +  ../web/templates/default/leftnav.inc
 +  ../web/lib/leftnav_nodelist.ssjs
 +  ../web/lib/leftnav_html.ssjs
 +
 +This starts the main table layout in the default layout and also
 +provides two other things -- the main navigation links and a brief
 +nodelisting that displays when users are online via telnet.
 +The links are dynamically created as in the Top Navigation example
 +above with the exception of the two static links.
 +
 +=== Main Content (various files) ===
 +
 +This is where the layout of the main content is created.  It is best
 +to look at the various files in ''../web/templates/default''
 +''../web/templates/default/msgs'' to see how the code is displayed for the
 +various functions of the Web side of Synchronet.  Some details on what
 +each of the special codes contained in those files do will follow.
 +
 +=== Footer ===
 +  
 +  ../web/templates/default/footer.inc
 +  
 +This file contains the closing HTML and whatever bottom information
 +you would like. In the case of the default layout, the
 +Web Server/Synchronet versions and the XHTML 1.0 logo.  Links to
 +privacy statements or anything else can be placed here and they will 
 +be displayed at the bottom of each page.
 +
 +
 +==== SSJS Theme Support ====
  
-4.2 SSJS Theme Support 
----------------------- 
 Theme Layouts can be added to Synchronet by creating them and placing the Theme Layouts can be added to Synchronet by creating them and placing the
 *.inc files in their own directory under ../web/templates/ *.inc files in their own directory under ../web/templates/
Line 373: Line 480:
 Themes are activated by editing the ../web/templates/html_themes.ssjs file. Themes are activated by editing the ../web/templates/html_themes.ssjs file.
 This file contains: This file contains:
 +<code javascript>
 +/* Set default theme name */
 +var DefaultTheme="Default";
  
-    /* Set default theme name */ +/* Edit this bit to add/remove/modify theme descriptions and dirs */ 
-    var DefaultTheme="Default"; +Themes["Default"]=new Object; 
- +Themes["Default"].desc="Default Synchronet Theme"; 
-    /* Edit this bit to add/remove/modify theme descriptions and dirs */ +Themes["Default"].dir="default"; 
-    Themes["Default"]=new Object; +Themes["Default"].css="/synchronet.css";  
-    Themes["Default"].desc="Default Synchronet Theme"; +</code>
-    Themes["Default"].dir="default"; +
-    Themes["Default"].css="/synchronet.css"; +
  
 Themes are added by editing below the Default Theme such as: Themes are added by editing below the Default Theme such as:
- +<code javascript> 
-    Themes["CoolTheme"]=new Object; +Themes["CoolTheme"]=new Object; 
-    Themes["CoolTheme"].desc="My Cool Theme"; +Themes["CoolTheme"].desc="My Cool Theme"; 
-    Themes["CoolTheme"].dir="cooltheme"; +Themes["CoolTheme"].dir="cooltheme"; 
-    Themes["CoolTheme"].css="/cooltheme.css"; +Themes["CoolTheme"].css="/cooltheme.css"; 
 +</code>
 To change the Default Theme, change: To change the Default Theme, change:
  
-    var DefaultTheme="Default"; +<code javascript> 
 +var DefaultTheme="Default"; 
 +</code> 
 to: to:
 +<code javascript>
 +var DefaultTheme="CoolTheme";
 +</code>
  
-    var DefaultTheme="CoolTheme"; +==== Special Codes Used in the SSJS Template System ====
  
-4.3 Special Codes Used in the SSJS Template System 
--------------------------------------------------- 
 By looking at at the message related files located in templates/default/msgs, By looking at at the message related files located in templates/default/msgs,
 it can be seen that some special codes are used to display dynamically created it can be seen that some special codes are used to display dynamically created
Line 409: Line 518:
  
 For example the groups.inc: For example the groups.inc:
 +<code html>
 <!-- Main Content -->   <!-- Main Content -->  
          
-    <td class="main" valign="top"><br />+<td class="main" valign="top"><br />
  
 <table class="grouplist" border="0" cellpadding="2" cellspacing="2"> <table class="grouplist" border="0" cellpadding="2" cellspacing="2">
Line 420: Line 529:
 <<REPEAT groups>> <<REPEAT groups>>
 <tr> <tr>
-    <td class="grouplist"> +  <td class="grouplist"> 
-        <a class="grouplist" href="subs.ssjs?msg_grp=^^groups:name^^"> +      <a class="grouplist" href="subs.ssjs?msg_grp=^^groups:name^^"> 
-            %%groups:description%%</a></td> +          %%groups:description%%</a></td> 
-    <td class="grouplist" align="right"> +  <td class="grouplist" align="right"> 
-        @@JS:msg_area.grp_list[RepeatObj.index].sub_list.length@@</td>+      @@JS:msg_area.grp_list[RepeatObj.index].sub_list.length@@</td>
 </tr> </tr>
 <<END REPEAT groups>> <<END REPEAT groups>>
Line 431: Line 540:
  
 <!-- end Main Content --> <!-- end Main Content -->
 +</code>
  
 While the table layout can be changed or even eliminated, the information While the table layout can be changed or even eliminated, the information
Line 436: Line 546:
 To remove the table yet keep the correct infomation, the resulting groups.inc To remove the table yet keep the correct infomation, the resulting groups.inc
 would be changed to (while maintaining the main table layout in this case) to: would be changed to (while maintaining the main table layout in this case) to:
 +<code html>
 <!-- Main Content -->   <!-- Main Content -->  
          
     <td class="main" valign="top"><br />     <td class="main" valign="top"><br />
  
-<<REPEAT groups>>+  <<REPEAT groups>>
     <a class="grouplist" href="subs.ssjs?msg_grp=^^groups:name^^">     <a class="grouplist" href="subs.ssjs?msg_grp=^^groups:name^^">
         %%groups:description%%</a>         %%groups:description%%</a>
     @@JS:msg_area.grp_list[RepeatObj.index].sub_list.length@@<br />     @@JS:msg_area.grp_list[RepeatObj.index].sub_list.length@@<br />
-<<END REPEAT groups>>+  <<END REPEAT groups>>
  
-<br />+  <br />
  
-<!-- end Main Content -->+  <!-- end Main Content --
 +</code>
  
 This principle applies to all the .inc files in msgs respectively. This principle applies to all the .inc files in msgs respectively.
  
 +==== The SSJS Template Library ====
  
-4.4 The SSJS Template Library +''%%name%%'' is replaced with the HTML encoded value of template.name
--------------------------------+
  
-%%name%% is replaced with the HTML encoded value of template.name+i.e.; Spaces are replaced with: ''this&nbsp;is&nbsp;html''
  
-i.e.; Spaces are replaced with: this&nbsp;is&nbsp;html+''^^name^^'' is replaced with the URI encoded value of template.name
  
-^^name^^ is replaced with the URI encoded value of template.name +i.e.; Spaces are replaced with:  ''this%20is%20URI''
- +
-i.e.; Spaces are replaced with:  this%20is%20URI+
                      
-@@name@@ is replaced with the value if template.name+''@@name@@'' is replaced with the value if ''template.name''
  
 No changes or encoding is performed. No changes or encoding is performed.
  
-@@name:sname@@ is replaced with the value of template.name.sname+''@@name:sname@@'' is replaced with the value of ''template.name.sname''
 (^^ and %% are also supported) (^^ and %% are also supported)
  
-@@JS:js_expression@@ is replaced with the return value of js_expression   +''@@JS:js_expression@@'' is replaced with the return value of ''js_expression''
 (^^ and %% are also supported) (^^ and %% are also supported)
  
 +<code javascript>
 <<REPEAT name>> <<REPEAT name>>
-    @@name:sname@@+  @@name:sname@@
 <<END REPEAT name>> <<END REPEAT name>>
 +</code>
  
-Iterates over the array/object template.name and replaces name:sname with  +Iterates over the array/object ''template.name'' and replaces ''name:sname'' with  
-the value of template.name.sname.+the value of ''template.name.sname''.
 (^^ and %% are also supported) (^^ and %% are also supported)
  
  
-4.5 SSJS Message Configuration +==== SSJS Message Configuration ====
------------------------------- +
-Configuration settings for the SSJS Messaging system is located in the +
-../web/lib/msgsconfig.ssjs file:+
  
 +Configuration settings for the SSJS Messaging system is located in the
 +''../web/lib/msgsconfig.ssjs'' file:
 +<code javascript>
 max_messages=20; max_messages=20;
 max_pages=30; max_pages=30;
Line 502: Line 613:
 show_messages_spacer_html="&nbsp;<b>|</b>&nbsp;"; show_messages_spacer_html="&nbsp;<b>|</b>&nbsp;";
 anon_only_message="Message will be posted anonymously"; anon_only_message="Message will be posted anonymously";
-anon_allowed_message='<input type="checkbox" name="anonymous" value="Yes" /> +anon_allowed_message='<input type="checkbox" name="anonymous" value="Yes" /> Post message anonymously'; 
-Post message anonymously'; +anon_reply_message='<input type="checkbox" name="anonymous" value="Yes" checked /> Post message anonymously';
-anon_reply_message='<input type="checkbox" name="anonymous" value="Yes" checked /> +
-Post message anonymously';+
 private_only_message="Message will be marked private"; private_only_message="Message will be marked private";
-private_allowed_message='<input type="checkbox" name="private" value="Yes" /> +private_allowed_message='<input type="checkbox" name="private" value="Yes" /> Mark message as private'; 
-Mark message as private'; +private_reply_message='<input type="checkbox" name="private" value="Yes" checked /> Mark message as private'; 
-private_reply_message='<input type="checkbox" name="private" value="Yes" checked /> +</code>
-Mark message as private';+
  
-Each of these are configurable.  NOTE:  Lines ending in "\" indicate the line +Each of these are configurable.
-below is part of the line above.  The "\" is not part of the configuration as +
-it too be removed.+
  
 See the actual file for the defaults currently in use. See the actual file for the defaults currently in use.
  
-4.6 Embedded Javascript +==== Embedded Javascript ====
------------------------+
  
-The *.inc files can (and do in the default layout) have embedded JavaScript+The ''*.inc'' files can (and do in the default layout) have embedded JavaScript
 which is parsed by the JavaScript engine.  Care should be taken as a large which is parsed by the JavaScript engine.  Care should be taken as a large
 number of embedded JavaScript in the *.inc files slow down overall processing number of embedded JavaScript in the *.inc files slow down overall processing
 of pages. of pages.
  
-Anything contained within @@JS: @@ is processed by the Server-side JavaScript+Anything contained within ''@@JS: @@'' is processed by the Server-side JavaScript
 engine. engine.
  
 For example, it can check if the user is Guest or an actual user with this line: For example, it can check if the user is Guest or an actual user with this line:
  
-@@JS:if(user.number==0 || user.security.restrictions&UFLAG_G) +<code javascript> 
-'<html code for Guest>'; else '<html code for registered user>';@@+@@JS:if(user.number==0 || user.security.restrictions&UFLAG_G) '<html code for Guest>'; 
 +else '<html code for registered user>';@@ 
 +</code>
                  
 What this does is display links specific for Registered Users only to them What this does is display links specific for Registered Users only to them
-and not Guest.  There are many things that can be done with @@JS: @@ code.+and not Guest.  There are many things that can be done with ''@@JS: @@'' code.
 Note, it also can be used to display HTML based on location as in the Note, it also can be used to display HTML based on location as in the
 node listing stuff. In this case, it checks for whether or not a user is node listing stuff. In this case, it checks for whether or not a user is
Line 541: Line 648:
 the Left side node listing. the Left side node listing.
  
-IMPORTANT!  Anything contained within @@JS: @@ MUST be on one line or there+IMPORTANT!  Anything contained within ''@@JS: @@ MUST'' be on one line or there
 will be errors in parsing. will be errors in parsing.
  
- +==== global_defs.ssjs ====
-4.7 global_defs.ssjs +
---------------------+
  
 This version of the Web Layout now includes a new file called This version of the Web Layout now includes a new file called
-global_defs.ssjs.  It is located in the ../web/lib directory.  This file can+''global_defs.ssjs''.  It is located in the ''../web/lib'' directory.  This file can
 be used for creating global definitions that span all pages of a site. be used for creating global definitions that span all pages of a site.
 For example: For example:
  
 +<code javascript>
 template.user_alias=user.alias; template.user_alias=user.alias;
 +</code>
  
-Now @@user_alias@@ can be in any *.inc template files and it will display the+Now ''@@user_alias@@'' can be in any ''*.inc'' template files and it will display the
 user's alias. user's alias.
  
-Care should be excersied when using this file as loading it up with hundreds+Care should be exercised when using this file as loading it up with hundreds
 of predefined definitions may slow down overall page rendering as the file is of predefined definitions may slow down overall page rendering as the file is
 loaded on every page.  It would be better to just put a few popular  loaded on every page.  It would be better to just put a few popular 
Line 566: Line 673:
  
  
-5.0 XJS files +===== XJS files ===== 
-------------- + 
-XJS files, handled by exec/xjs_handler.js are what many people consider to be+XJS files, handled by ''exec/xjs_handler.js'' are what many people consider to be
 an easier method of generating SSJS files.  XJS files are HTML files with JS an easier method of generating SSJS files.  XJS files are HTML files with JS
 commands embedded in them using special tags much like PHP.  XJS files are commands embedded in them using special tags much like PHP.  XJS files are
-translated on-the-fly to .ssjs files using the same name with .ssjs appended. +translated on-the-fly to .ssjs files using the same name with ''.ssjs'' appended. 
-For example, a file named test.xjs will, when ran, generate a test.xjs.ssjs+For example, a file named test.xjs will, when ran, generate a ''test.xjs.ssjs''
 file. file.
  
  
-5.1 XJS syntax +==== XJS syntax ==== 
---------------+
 In an XJS file, everything not within a special xjs tag is send to the remote In an XJS file, everything not within a special xjs tag is send to the remote
 host unmodified, and everything inside the xjs tag is interpreted as JS host unmodified, and everything inside the xjs tag is interpreted as JS
Line 583: Line 690:
 either "<?xjs" or "<?" and ends with "?>" A simple example would be: either "<?xjs" or "<?" and ends with "?>" A simple example would be:
  
 +<code html>
 <html><head><title><?xjs write(system.name) ?></title></head> <html><head><title><?xjs write(system.name) ?></title></head>
 <body> <body>
Line 589: Line 697:
 </body> </body>
 </html> </html>
 +</code>
  
 This would send the following web page to the remote system: This would send the following web page to the remote system:
 +<code html>
 <html><head><title>My Brand New BBS</title></head> <html><head><title>My Brand New BBS</title></head>
 <body> <body>
Line 597: Line 707:
 </body> </body>
 </html> </html>
 +</code>
  
 Looping constructs are permitted, however, not using brackets can result in Looping constructs are permitted, however, not using brackets can result in
Line 603: Line 714:
  
 The following example displays the numbers from one to 10. The following example displays the numbers from one to 10.
 +<code html>
 <html><head><title>Counter</title></head> <html><head><title>Counter</title></head>
 <body> <body>
Line 613: Line 725:
 </body> </body>
 </html> </html>
 +</code>
 +
 +==== XJS-specific global methods and properties ====
 +
 +The following JavaScript methods and properties are available to XJS files only.
  
 +=== xjs_load(filename) ===
 +Runs the specified xjs file at the current position.  Local variables
 +are NOT visible to ''xjs_load()''ed pages.  The filename is assumed to be
 +relative to the including file (or absolute.)
  
-5.2 XJS-specific global methods and properties +=== cwd === 
----------------------------------------------- +Contains the path that the current xjs script was loaded from and which 
-The following JS commands are available to XJS files only. +parameters to ''xjs_load()'' are assumed to be relative to.  If you change 
-xjs_load(filename) +the value of ''cwd'', it will change the location where ''xjs_load()'' will 
- Runs the specified xjs file at the current position.  Local variables +check for files.
- are NOT visible to xjs_load()ed pages.  The filename is assumed to be +
- relative to the including file (or absolute.) +
-cwd +
- Contains the path that the current xjs script was loaded from and which +
- parameters to xjs_load() are assumed to be relative to.  If you change +
- the value of cwd, it will change the location where xjs_load() will +
- check for files.+
  
 +{{indexmenu_n>4}}