Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
server:web [2010/02/21 20:37] – digitalman | server:web [2023/12/20 23:08] – [sbbs.ini] Re-org and beautify digital man | ||
---|---|---|---|
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 5: | Line 7: | ||
The Synchronet Web Server is a mostly HTTP 1.1 compliant web server capable of | The Synchronet Web Server is a mostly HTTP 1.1 compliant web server capable of | ||
handing basic web servicing tasks. | handing basic web servicing tasks. | ||
- | general-purpose web server one would come to expect | + | general-purpose web server one would come to expect, including |
It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | ||
Line 11: | Line 13: | ||
- | ===== Web Server | + | ===== Configure ===== |
- | Most of the web server | + | |
- | ctrl/sbbs.ini). The '' | + | The Synchronet |
+ | |||
+ | < | ||
+ | ╔══════════════════════════════════════════════════════════════════════╗ | ||
+ | ║ Web Server | ||
+ | ╠══════════════════════════════════════════════════════════════════════╣ | ||
+ | ║ │Enabled | ||
+ | ║ │Log Level | ||
+ | ║ │HTTP Interfaces | ||
+ | ║ │HTTP Port | ||
+ | ║ │HTTPS Support | ||
+ | ║ │HTTPS Interfaces | ||
+ | ║ │HTTPS Port 443 ║ | ||
+ | ║ │SSJS File Extension | ||
+ | ║ │Index Filenames | ||
+ | ║ │Content Root Directory | ||
+ | ║ │Error Sub-directory | ||
+ | ║ │Strict Transport Security | ||
+ | ║ │Virtual Host Support | ||
+ | ║ │Access Logging | ||
+ | ║ │Max Clients | ||
+ | ║ │Max Inactivity | ||
+ | ║ │Filebase Index Script | ||
+ | ║ │Filebase VPath Prefix | ||
+ | ║ │Filebase VPath for VHosts | ||
+ | ║ │Authentication Methods | ||
+ | ║ │Output Buffer Drain Timeout | ||
+ | ║ │Lookup Client Hostname | ||
+ | ║ │CGI Support | ||
+ | ╚══════════════════════════════════════════════════════════════════════╝ | ||
+ | </ | ||
+ | |||
+ | ... or via [[monitor: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ... or via manual edit of the '' | ||
+ | |||
+ | ==== sbbs.ini | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ^ Key ^ Default | ||
+ | | AutoStart | ||
+ | | HostName | ||
+ | | LogLevel | ||
+ | | TLSErrorLevel | ||
+ | | Interface | ||
+ | | TLSInterface | ||
+ | | Port | '' | ||
+ | | TLSPort | ||
+ | | BindRetryCount | ||
+ | | BindRetryDelay | ||
+ | | MaxClients | ||
+ | | MaxInactivity | ||
+ | | MaxCgiInactivity | ||
+ | | SemFileCheckFrequency | ||
+ | | IndexFileNames | ||
+ | | RootDirectory | ||
+ | | ErrorDirectory | ||
+ | | CGIDirectory | ||
+ | | DefaultCGIContent | ||
+ | | CGIExtensions | ||
+ | | JavaScriptExtension | ||
+ | | Authentication | ||
+ | | HttpLogFile | ||
+ | | FileIndexScript | ||
+ | | FileVPathPrefix | ||
+ | | FileVPathForVHosts | ||
+ | | OutbufDrainTimeout | ||
+ | | TempDirectory | ||
+ | | Options | ||
+ | |||
+ | === Options === | ||
+ | |||
+ | The '' | ||
+ | |||
+ | Default value: **'' | ||
+ | |||
+ | In addition to the [[config:sbbs.ini|standard options]], the web server also supports the following: | ||
+ | |||
+ | == DEBUG_RX == | ||
+ | |||
+ | Log all received data to the console log, as well as various | ||
+ | extra bits related to receiving data. | ||
+ | |||
+ | == DEBUG_TX == | ||
+ | |||
+ | Log all transmitted data except the reply body itself, as well | ||
+ | as various extra bits of information related to transmitted | ||
+ | data. | ||
+ | |||
+ | == DEBUG_SSJS == | ||
+ | |||
+ | Log server-side JavaScript execution details. | ||
+ | |||
+ | == VIRTUAL_HOSTS == | ||
+ | |||
+ | Supports name-based virtual hosts. | ||
+ | host names, you can have each host name return unique content | ||
+ | depending on which hostname is used. ie: if | ||
+ | '' | ||
+ | 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 [[# | ||
+ | ie: '' | ||
+ | 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 '' | ||
+ | like this: | ||
+ | <code html> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | Your browser is either too old to support | ||
+ | name-based virtual hosts, or you have visited a | ||
+ | virtual hosts that is not yet configured. | ||
+ | | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | == NO_CGI == | ||
+ | |||
+ | Disable CGI/FastCGI script execution. | ||
+ | |||
+ | == HTTP_LOGGING == | ||
+ | |||
+ | Enable logging to a Common Logfile Format log as described in | ||
+ | the HttpLogFile section. | ||
+ | programs (like Webalizer: http:// | ||
+ | |||
+ | == NO_JAVASCRIPT == | ||
+ | |||
+ | Disable SSJS execution. | ||
+ | |||
+ | == ALLOW_TLS == | ||
+ | |||
+ | Enable TLS/SSL support. | ||
+ | |||
+ | == HSTS_SAFE == | ||
+ | Indicates that all URLs available via http are also available via https and redirects clients who want a TLS session to the https location. | ||
- | ==== [Web] Section Keys ==== | + | ==== Reference |
+ | Web Server configuration settings reference: | ||
+ | |||
=== RootDirectory === | === RootDirectory === | ||
Line 25: | Line 177: | ||
'' | '' | ||
- | ::!:: Older versions of Synchronet had this value default to '' | + | **NOTE**: Older versions of Synchronet had this value default to '' |
=== ErrorDirectory === | === ErrorDirectory === | ||
Default value: '' | Default value: '' | ||
- | The directory relative to [# | + | The directory relative to [[# |
message files are located. | message files are located. | ||
numeric HTTP error code they will represent and may be either '' | numeric HTTP error code they will represent and may be either '' | ||
Line 48: | Line 200: | ||
=== Authorization === | === Authorization === | ||
- | Default value: '' | + | Default value: '' |
A comma-separated list of authentication mechanisms in order of preference. | A comma-separated list of authentication mechanisms in order of preference. | ||
Line 108: | Line 260: | ||
(if enabled, see next item), date, and '' | (if enabled, see next item), date, and '' | ||
- | === Options | + | === FileVPathPrefix |
+ | Default value: "" | ||
- | Default | + | Suggested |
- | The | separated list of options | + | A virtual sub-directory |
- | options, the web server also supports the following: | + | |
- | * '' | + | === FileVPathForVHosts === |
- | Log all received data to the console log, as well as various | + | Default value: |
- | extra bits related to receiving data. | + | |
- | * DEBUG_TX | + | By default, virtual hosts will not have the virtual |
- | 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 | + | |
- | 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 | + | |
- | into a sub-directory of RootDirectory with the desired hostname | + | |
- | ie: web/ | + | |
- | 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 | + | |
- | | + | |
- | like this: | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | < | + | |
- | Your browser is either too old to support | + | |
- | name-based | + | |
- | virtual hosts that is not yet configured. | + | |
- | following are hosted here:< | + | |
- | <a href=" | + | |
- | </ | + | |
- | <a href=" | + | |
- | </ | + | |
- | </ | + | |
- | NO_CGI | + | |
- | Disable CGI script execution. | + | |
- | HTTP_LOGGING | + | |
- | Enable logging to a Common Logfile Format log as described in | + | |
- | the HttpLogFile section. | + | |
- | programs (like Webalizer: http:// | + | |
- | NO_JAVASCRIPT | + | |
- | Disable SSJS execution. | + | |
+ | === FileIndexScript === | ||
+ | Default value: "" | ||
- | 2.2. Other web-related configuration files | + | Suggested value: '' |
- | ------------------------------------------ | + | |
- | In addition to the [Web] keys in the initialization file, the web server | + | |
- | also uses some other configuration files: | + | |
- | ctrl/ | + | A Server-side JavaScript (SSJS) |
- | Contains the file extension | + | |
- | is in the format " | + | |
- | The extensions are case-insensitive | + | |
- | ctrl/webicons.ini | + | |
- | Contains the URLs to the icons used by the default 404.ssjs | + | |
- | script for each file type/ | + | |
- | Example: " | + | |
- | DIRECTORY which is used for directories | + | |
- | is used for extensions which don't exist in the list. | + | |
- | ctrl/ | + | |
- | Contains 2 sections, [CGI] and [JavaScript], | + | |
- | extensions and their associated content-creation handlers are | + | |
- | specified. The [CGI] section is for natively-executed CGI handlers | + | |
- | (e.g. "pl = perl" indicates " | + | |
- | files). The [JavaScript] section is used for JS-executed content | + | |
- | handlers (e.g. "xjs = xjs_handler.js" | + | |
- | ctrl/ | + | |
- | Contains a list of system environment variables to pass to CGI | + | |
- | processes. | + | |
- | value, over-ridden value, and prepended or appended text. | + | |
+ | ==== Other configuration files ==== | ||
- | 2.3. webctrl.ini per-directory configuration file | + | In addition to the '' |
- | ------------------------------------------------ | + | also uses some other configuration |
- | Each directory may have a webctrl.ini file which overrides certain settings for | + | |
- | the directory it's in and all child directorys. | + | |
- | either globally, or in a per-filename group. | + | |
- | the group name such as [*.html]. The following keys may be used in these files: | + | |
- | AccessRequirements: | + | === ctrl/ |
- | Specifices an ARS string which all users must match to be able to access | + | Contains |
- | files in this directory. Will force an HTTP login. | + | is in the format " |
- | Realm: | + | The extensions |
- | Sets the realm that is displayed | + | |
- | Default | + | |
- | 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. | + | |
- | browser currently appears to use Digest if Basic is listed first. | + | |
- | Supported values | + | |
- | users password is never sent over the wire. | + | |
- | ErrorDirectory: | + | |
- | Specifies a different directory to check for error pages. | + | |
- | 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. | + | |
- | For example, to require a login, but allow *any* user to access files in a | + | === ctrl/ |
- | directory, but only a sysop to access *.log files, | + | Contains the URLs to the icons used by the default 404.ssjs |
- | AccessRequirements=level 0 | + | script for each file type/ |
- | [*.log] | + | Example: "html=/ |
- | AccessRequirements=level90 | + | DIRECTORY which is used for directories and DefaultIcon which |
+ | is used for extensions which don't exist in the list. | ||
+ | === ctrl/ | ||
- | 3.0 JavaScript Web Server Objects | + | This file contains 2 sections where a list of file |
- | --------------------------------- | + | extensions and their associated content-creation handlers are |
- | In addition to the standard JavaScript objects, the web server provides the | + | specified: |
- | following: | + | |
+ | == [CGI] == | ||
- | 3.1 http_request object | + | The [CGI] section is for natively-executed CGI handlers |
- | ----------------------- | + | (e.g. "pl = perl" indicates " |
- | The http_request object contains information from the client that was included | + | |
- | during this request. | + | |
- | path_info | + | == [JavaScript] == |
- | | + | |
- | | + | |
- | | + | |
- | would contain the string "/ | + | |
- | method | + | |
- | | + | |
- | " | + | |
- | virtual_path - The virtual path that this URI was reached by. This is the | + | |
- | | + | |
- | | + | |
- | query - This object contains the values of any form data which was | + | |
- | | + | |
- | | + | |
- | for this is that it is legal and often usefull to have multiple | + | |
- | form fields with the same name. | + | |
- | query_string - If a query string was included, this is the raw, unparsed query | + | |
- | | + | |
- | post_data | + | |
- | header | + | |
- | cookie | + | |
- | of set cookies. | + | |
- | | + | |
- | real_path | + | |
- | 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 | + | |
- | remote_ip | + | |
- | remote_host | + | |
- | is the remote hostname. | + | |
+ | The [JavaScript] section is used for JS-executed content | ||
+ | handlers (e.g. "xjs = xjs_handler.js" | ||
- | 3.2 http_reply object | + | === ctrl/ |
- | --------------------- | + | Contains a list of system environment variables |
- | The http_reply object is used to pass information about the reply back to the | + | processes. |
- | Synchronet web server. | + | value, over-ridden value, and prepended or appended text. |
- | status | ||
- | header | ||
- | only pre-defined one is " | ||
- | " | ||
- | fast - This optional property can be set to " | ||
- | | ||
- | | ||
- | | ||
- | | ||
+ | ==== webctrl.ini ==== | ||
- | 3.3 Extra global methods | + | Each directory under the [[# |
- | ------------------------ | + | the directory it's in and all child directories. |
- | The web server also adds new global methods. | + | 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 '' | ||
- | set_cookie(string key, | + | === AccessRequirements === |
- | | + | Specifies an ARS string |
- | [, time_t expires | + | files in this directory. |
- | [, string domain | + | |
- | [, string path | + | |
- | [, bool secure ]]]]) | + | |
- | | + | |
+ | For example, to require a login, but allow **any** user to access files in a | ||
+ | directory, but only a sysop to access '' | ||
+ | <file webctrl.ini> | ||
+ | AccessRequirements=level 0 | ||
+ | [*.log] | ||
+ | AccessRequirements=level 90 | ||
+ | [*.git] | ||
+ | AccessRequirements=level 90 | ||
+ | </ | ||
- | 4.0 The SSJS Template System | + | === Realm === |
- | ---------------------------- | + | Sets the realm that is displayed to the user for the HTTP login. |
- | The default web pages use a SSJS Template engine which also allows | + | Default is the BBS name. |
- | support. | + | |
- | [Note: | + | === DigestRealm === |
- | nested.] | + | Sets the realm that is displayed to the user for the HTTP login when |
+ | Digest authentication is being used. | ||
+ | === Authorization === | ||
+ | A comma-separated list of authentication mechanisms in order of | ||
+ | preference. | ||
+ | browser currently appears to use Digest if Basic is listed first. | ||
+ | Supported values are '' | ||
+ | users password is never sent over the wire. | ||
- | 4.1 The SSJS Template Scheme | + | === ErrorDirectory === |
- | ---------------------------- | + | Specifies a different directory to check for error pages. If the error |
- | Each page consists of four parts: | + | page is not found, will still check the global error directory. |
- | The Header (../ | + | === CGIDirectory === |
- | This file contains the basic requirements | + | Specify an alternate CGI directory to check for CGI files. |
- | 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. | + | |
- | of the layout is continued in the next files. | + | |
- | Top Navigation (../ | + | === PathInfoIndex === |
- | | + | Specifies that the index files can be ran for unlocated pages in the |
- | The topnav.inc file contains | + | current directory. |
- | The links are dynamically generated by topnav_html.ssjs so both | + | |
- | | + | |
- | In the case of the default layout, topnav.inc has a left and right | + | |
- | | + | |
- | 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. | + | |
- | check the current | + | |
- | on what you want it to say. | + | |
- | For example: | + | |
- | You want to add a Links page called links.html in the main | + | |
- | directory. | + | |
- | as: | + | |
- | if(http_request.virtual_path=="/ | + | |
- | template.topnav.push({html: | + | |
- | Some Links</ | + | |
- | Left Side Navigation | + | === FastCGISocket === |
- | | + | Specifies the socket address of a FastCGI listener in either < |
- | This starts the main table layout in the default layout and also | + | <file webctrl.ini> |
- | | + | [*.php] |
- | | + | FastCGISocket=127.0.0.1:9000 |
- | The links are dynamically created as in the Top Navigation example | + | </ |
- | above with the exception of the two static links. | + | |
- | Main Content (various files) | + | See [[howto: |
- | This is where the layout of the main content is created. | + | |
- | to look at the various files in ../ | + | |
- | ../ | + | |
- | various functions of the Web side of Synchronet. | + | |
- | each of the special codes contained in those files do will follow. | + | |
- | Footer (../ | + | === Rewrite* === |
- | | + | Specifies a Javascript snippet which can modify the http_request.request_string. This allows internal redirects |
- | you would like. In the case of the default layout, the | + | |
- | Web Server/ | + | |
- | privacy statements or anything else can be placed here and they will | + | |
- | be displayed at the bottom | + | |
+ | <file webctrl.ini> | ||
+ | RewriteDetail=var n=http_request.request_string.replace(/ | ||
+ | </ | ||
- | 4.2 SSJS Theme Support | + | If the expression returns " |
- | ---------------------- | + | an internal redirect. |
- | Theme Layouts can be added to Synchronet by creating them and placing the | + | |
- | *.inc files in their own directory under ../ | + | |
- | Themes are activated by editing the ../web/templates/ | + | Added on November 3rd, 2015 to CVS (in 3.17a). ([[https://gitlab.synchro.net/ |
- | This file contains: | + | |
- | /* Set default theme name */ | + | === JSPreExec === |
- | var DefaultTheme=" | + | A JavaScript snippet which is executed in the same context as Rewrite* lines, but before any Rewrites are executed. |
- | /* Edit this bit to add/ | + | Added on November 3rd, 2015 to CVS (in 3.17a). |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes are added by editing below the Default Theme such as: | + | ===== JavaScript Objects ===== |
+ | In addition to the standard JavaScript objects, the web server provides the | ||
+ | following: | ||
- | Themes[" | + | ==== http_request object ==== |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | To change | + | The http_request object contains information from the client that was included |
+ | during this request. | ||
- | var DefaultTheme="Default"; | + | === path_info === |
+ | Contains extra path information that was included with the | ||
+ | request AFTER the URI which identified this script. | ||
+ | example, if the request was for | ||
+ | '' | ||
+ | would contain the string | ||
- | to: | + | === method === |
+ | Contains the HTTP method used to run the script. | ||
+ | writing, the available methods are " | ||
+ | " | ||
- | var DefaultTheme=" | + | === virtual_path === |
+ | The virtual path that this URI was reached by. This is the | ||
+ | portion of the URI from the end of the host to the end of the | ||
+ | filename. | ||
+ | === query === | ||
+ | This object contains the values of any form data which was | ||
+ | submitted with the request. | ||
+ | name/value pairs. | ||
+ | for this is that it is legal and often useful to have multiple | ||
+ | form fields with the same name. | ||
- | 4.3 Special Codes Used in the SSJS Template System | + | === query_string === |
- | -------------------------------------------------- | + | If a query string was included, this is the raw, unparsed query |
- | By looking at at the message related files located in templates/ | + | string. |
- | it can be seen that some special codes are used to display dynamically created | + | |
- | content. It is very important to maintain | + | |
- | each file or else the messaging system will fail. While how it is displayed | + | |
- | can be changed, the correct information will only be dispayed by following the | + | |
- | format in the *.inc files. | + | |
- | For example the groups.inc: | + | === post_data === |
+ | As with query_string but for data which was POSTed. | ||
- | <!-- Main Content --> | + | === header === |
- | + | An associative array of header name/value pairs. | |
- | <td class=" | + | |
- | <table class=" | + | === cookie |
- | < | + | Much like the query object, this object contains key/value pairs |
- | <th class=" | + | of set cookies. Once again, this is an array of strings since |
- | </tr> | + | multiple values for the same key can be set for cookies. |
- | << | + | |
- | < | + | |
- | <td class=" | + | |
- | <a class=" | + | |
- | | + | |
- | <td class=" | + | |
- | @@JS: | + | |
- | </ | + | |
- | <<END REPEAT groups>> | + | |
- | </ | + | |
- | <br /> | + | |
- | <!-- end Main Content --> | + | === real_path === |
+ | The real OS's complete path to this script. | ||
- | While the table layout can be changed or even eliminated, the information | + | === ars === |
- | within the << | + | The ARS string which applies |
- | To remove the table yet keep the correct infomation, the resulting groups.inc | + | |
- | would be changed | + | |
- | <!-- Main Content --> | + | === request_string === |
- | + | ||
- | <td class=" | + | |
- | << | + | The raw request string sent by the client. |
- | <a class=" | + | |
- | %%groups: | + | |
- | @@JS: | + | |
- | <<END REPEAT groups>> | + | |
- | <br /> | + | === 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. | ||
- | <!-- end Main Content --> | + | === remote_ip === |
+ | The IP address of the client. | ||
- | This principle applies to all the .inc files in msgs respectively. | + | === remote_host === |
+ | If the web server does host lookups (disabled by default), this | ||
+ | is the remote hostname. | ||
- | 4.4 The SSJS Template Library | + | === scheme === |
- | ------------------------------- | + | |
- | %%name%% | + | " |
+ | ==== http_reply object ==== | ||
- | i.e.; Spaces are replaced with: this& | ||
- | ^^name^^ | + | The http_reply object |
+ | Synchronet web server. The properties are as follows: | ||
- | i.e.; Spaces are replaced with: this%20is%20URI | + | === status === |
- | + | ||
- | @@name@@ is replaced with the value if template.name | + | |
- | No changes or encoding is performed. | + | HTTP status string. The default is generally "200 Ok" |
- | @@name: | + | === header === |
- | (^^ and %% are also supported) | + | An associative array of headers to include |
+ | only pre-defined one is " | ||
- | @@JS: | + | === fast === |
- | (^^ and %% are also supported) | + | This optional property can be set to " |
+ | directly to the client for HTTP/1.0 connections. | ||
+ | keep-alives from working but generally appears faster to the | ||
+ | client. | ||
+ | required for HTTP/1.1. | ||
- | << | ||
- | @@name: | ||
- | <<END REPEAT name>> | ||
- | Iterates over the array/ | + | ==== Extra global methods ==== |
- | the value of template.name.sname. | + | |
- | (^^ and %% are also supported) | + | |
+ | The web server also adds a new global JavaScript method that requests that the specified cookie be set: | ||
- | 4.5 SSJS Message Configuration | + | set_cookie(string key, |
- | ------------------------------ | + | string value |
- | Configuration settings for the SSJS Messaging system is located in the | + | [, time_t expires |
- | ../ | + | [, string domain |
+ | [, string path | ||
+ | [, bool secure ]]]]) | ||
- | max_messages=20; | ||
- | max_pages=30; | ||
- | next_msg_html=" | ||
- | prev_msg_html=" | ||
- | next_page_html=" | ||
- | prev_page_html=" | ||
- | showall_subs_enable_html=" | ||
- | showall_subs_disable_html=" | ||
- | show_messages_all_html=" | ||
- | show_messages_yours_html=" | ||
- | show_messages_your_unread_html=" | ||
- | show_messages_spacer_html="& | ||
- | anon_only_message=" | ||
- | anon_allowed_message='< | ||
- | Post message anonymously'; | ||
- | anon_reply_message='< | ||
- | Post message anonymously'; | ||
- | private_only_message=" | ||
- | private_allowed_message='< | ||
- | Mark message as private'; | ||
- | private_reply_message='< | ||
- | Mark message as private'; | ||
- | Each of these are configurable. | + | ==== Extra global variables ==== |
- | below is part of the line above. | + | |
- | it too be removed. | + | |
- | See the actual file for the defaults currently in use. | + | === web_root_dir === |
+ | The path to the web server' | ||
- | 4.6 Embedded Javascript | + | See also: the RootDirectory key under [Web] in [[config: |
- | ----------------------- | + | |
- | The *.inc files can (and do in the default layout) have embedded JavaScript | + | ===== XJS files ===== |
- | which is parsed by the JavaScript engine. | + | |
- | number of embedded JavaScript in the *.inc files slow down overall processing | + | |
- | of pages. | + | |
- | Anything contained within @@JS: @@ is processed by the Server-side JavaScript | + | XJS files, handled by '' |
- | engine. | + | |
- | + | ||
- | For example, it can check if the user is Guest or an actual user with this line: | + | |
- | + | ||
- | @@JS: | + | |
- | '< | + | |
- | + | ||
- | What this does is display links specific for Registered Users only to them | + | |
- | and not Guest. | + | |
- | 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 | + | |
- | online, or if the user is anywhere but the Who's Online page before displaying | + | |
- | the Left side node listing. | + | |
- | + | ||
- | IMPORTANT! | + | |
- | will be errors in parsing. | + | |
- | + | ||
- | + | ||
- | 4.7 global_defs.ssjs | + | |
- | -------------------- | + | |
- | + | ||
- | This version of the Web Layout now includes a new file called | + | |
- | global_defs.ssjs. | + | |
- | be used for creating global definitions that span all pages of a site. | + | |
- | For example: | + | |
- | + | ||
- | template.user_alias=user.alias; | + | |
- | + | ||
- | Now @@user_alias@@ can be in any *.inc template files and it will display the | + | |
- | user's alias. | + | |
- | + | ||
- | Care should be excersied when using this file as loading it up with hundreds | + | |
- | 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 | + | |
- | definitions that are truly global rather many definitions. | + | |
- | inefficient to have thirty of forty message definitions being loaded when a | + | |
- | user is looking at the statistics page. | + | |
- | + | ||
- | + | ||
- | 5.0 XJS files | + | |
- | ------------- | + | |
- | XJS files, handled by exec/ | + | |
an easier method of generating SSJS files. | an easier method of generating SSJS files. | ||
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 '' |
- | 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 '' |
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 525: | ||
either "<? | either "<? | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 589: | Line 532: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
This would send the following web page to the remote system: | This would send the following web page to the remote system: | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 597: | Line 542: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
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 549: | ||
The following example displays the numbers from one to 10. | The following example displays the numbers from one to 10. | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 613: | Line 560: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 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. | ||
+ | are NOT visible to '' | ||
+ | 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(filename) | + | the value of '' |
- | Runs the specified xjs file at the current position. | + | check for files. |
- | are NOT visible to xjs_load()ed pages. | + | |
- | 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> | ||