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:56] – digitalman | server:web [2014/07/25 02:26] – Fix Authorization default value. 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 ===== |
==== Startup INI [Web] Section Keys ==== | ==== Startup INI [Web] Section Keys ==== | ||
- | The '' | + | The '' |
=== RootDirectory === | === RootDirectory === | ||
Line 24: | Line 26: | ||
'' | '' | ||
- | ::!:: 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 47: | Line 49: | ||
=== 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 111: | Line 113: | ||
Default value: '' | Default value: '' | ||
- | The | separated list of options to enable. | + | The '' |
- | options, the web server also supports the following: | + | |
'' | '' | ||
+ | |||
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. | ||
'' | '' | ||
+ | |||
Log all transmitted data except the reply body itself, as well | Log all transmitted data except the reply body itself, as well | ||
as various extra bits of information related to transmitted | as various extra bits of information related to transmitted | ||
Line 124: | Line 127: | ||
'' | '' | ||
+ | |||
Supports name-based virtual hosts. | Supports name-based virtual hosts. | ||
host names, you can have each host name return unique content | host names, you can have each host name return unique content | ||
depending on which hostname is used. ie: if | 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 | system, you could have FreeBSD-specific pages on one, and | ||
general *nix stuff on the other. | general *nix stuff on the other. | ||
A virtual host is added by simply putting the desired content | A virtual host is added by simply putting the desired content | ||
- | into a sub-directory of RootDirectory with the desired hostname | + | into a sub-directory of [[#RootDirectory]] with the desired hostname |
- | ie: web/ | + | ie: '' |
the request host name (very old browsers, or some automated | the request host name (very old browsers, or some automated | ||
tools) they will be served out of document root. | tools) they will be served out of document root. | ||
It is therefore a good idea to put links to your various | It is therefore a good idea to put links to your various | ||
- | virtual hosts in an index.html page in RootDirectory something | + | virtual hosts in an '' |
like this: | like this: | ||
- | | + | <code html> |
- | < | + | < |
- | < | + | |
- | </ | + | < |
- | < | + | </ |
- | Your browser is either too old to support | + | < |
- | name-based virtual hosts, or you have visited a | + | Your browser is either too old to support |
- | virtual hosts that is not yet configured. | + | name-based virtual hosts, or you have visited a |
- | following are hosted here:< | + | virtual hosts that is not yet configured. |
- | <a href=" | + | following are hosted here:< |
- | | + | <a href=" |
- | <a href=" | + | <a href=" |
- | </ | + | </ |
- | </ | + | </html> |
+ | </code> | ||
'' | '' | ||
+ | |||
Disable CGI script execution. | Disable CGI script execution. | ||
'' | '' | ||
+ | |||
Enable logging to a Common Logfile Format log as described in | Enable logging to a Common Logfile Format log as described in | ||
the HttpLogFile section. | the HttpLogFile section. | ||
Line 163: | Line 170: | ||
'' | '' | ||
+ | |||
Disable SSJS execution. | Disable SSJS execution. | ||
Line 168: | Line 176: | ||
==== Other configuration files ==== | ==== Other configuration files ==== | ||
- | In addition to the [Web] keys in the [[Startup INI]] file, the web server | + | In addition to the '' |
also uses some other configuration files: | also uses some other configuration files: | ||
Line 189: | Line 197: | ||
specified: | specified: | ||
- | == CGI == | + | == [CGI] == |
The [CGI] section is for natively-executed CGI handlers | The [CGI] section is for natively-executed CGI handlers | ||
- | (e.g. "pl = perl" indicates " | + | (e.g. "pl = perl" indicates " |
- | files). | + | |
- | == JavaScript == | + | == [JavaScript] == |
The [JavaScript] section is used for JS-executed content | The [JavaScript] section is used for JS-executed content | ||
Line 209: | Line 216: | ||
Each directory under the [[# | Each directory under the [[# | ||
the directory it's in and all child directories. | the directory it's in and all child directories. | ||
- | either globally, | + | either globally, in a per-filename group, or, in version 3.17 or greater, a per-directory-name group. |
- | the group name such as '' | + | Using the * and ? wildcards as the group name such as '' |
=== AccessRequirements === | === AccessRequirements === | ||
Line 243: | Line 250: | ||
For example, to require a login, but allow **any** user to access files in a | For example, to require a login, but allow **any** user to access files in a | ||
- | directory, but only a sysop to access '' | + | directory, but only a sysop to access '' |
- | AccessRequirements=level 0 | + | <file webctrl.ini> |
- | [*.log] | + | AccessRequirements=level 0 |
- | AccessRequirements=level90 | + | [*.log] |
+ | AccessRequirements=level 90 | ||
+ | [*.git] | ||
+ | AccessRequirements=level 90 | ||
+ | </ | ||
- | ==== JavaScript | + | ===== 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 === | + | ==== 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. | during this request. | ||
- | == path_info == | + | === path_info |
Contains extra path information that was included with the | Contains extra path information that was included with the | ||
request AFTER the URI which identified this script. | request AFTER the URI which identified this script. | ||
Line 265: | Line 276: | ||
would contain the string "/ | would contain the string "/ | ||
- | == method == | + | === method |
Contains the HTTP method used to run the script. | Contains the HTTP method used to run the script. | ||
writing, the available methods are " | writing, the available methods are " | ||
" | " | ||
- | == virtual_path == | + | === virtual_path |
The virtual path that this URI was reached by. This is the | 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 | portion of the URI from the end of the host to the end of the | ||
filename. | filename. | ||
- | == query == | + | === query === |
This object contains the values of any form data which was | This object contains the values of any form data which was | ||
submitted with the request. | submitted with the request. | ||
Line 282: | Line 293: | ||
form fields with the same name. | form fields with the same name. | ||
- | == query_string == | + | === query_string |
If a query string was included, this is the raw, unparsed query | If a query string was included, this is the raw, unparsed query | ||
string. | string. | ||
- | == post_data == | + | === post_data |
As with query_string but for data which was POSTed. | As with query_string but for data which was POSTed. | ||
- | == header == | + | === header |
An associative array of header name/value pairs. | An associative array of header name/value pairs. | ||
- | == cookie == | + | === cookie |
Much like the query object, this object contains key/value pairs | Much like the query object, this object contains key/value pairs | ||
of set cookies. | of set cookies. | ||
multiple values for the same key can be set for cookies. | multiple values for the same key can be set for cookies. | ||
- | == real_path == | + | === real_path |
- | The real OSs complete path to this script. | + | The real OS' |
- | == ars == | + | === ars === |
The ARS string which applies to this request. | The ARS string which applies to this request. | ||
- | == request_string == | + | === request_string |
The raw request string sent by the client. | The raw request string sent by the client. | ||
- | == host == | + | === host === |
The value of the host header for this request. | The value of the host header for this request. | ||
- | == vhost == | + | === vhost === |
The virtual host serving this request. | The virtual host serving this request. | ||
- | == http_ver == | + | === http_ver |
The HTTP version used for this request as a string. | The HTTP version used for this request as a string. | ||
- | == remote_ip == | + | === remote_ip |
The IP address of the client. | The IP address of the client. | ||
- | == remote_host == | + | === remote_host |
If the web server does host lookups (disabled by default), this | If the web server does host lookups (disabled by default), this | ||
Line 325: | Line 334: | ||
- | === http_reply object === | + | ==== http_reply object |
Line 331: | Line 340: | ||
Synchronet web server. | Synchronet web server. | ||
- | == status == | + | === status |
HTTP status string. | HTTP status string. | ||
- | == header == | + | === header |
An associative array of headers to include with the reply. | An associative array of headers to include with the reply. | ||
only pre-defined one is " | only pre-defined one is " | ||
- | == fast == | + | === fast === |
This optional property can be set to " | This optional property can be set to " | ||
directly to the client for HTTP/1.0 connections. | directly to the client for HTTP/1.0 connections. | ||
Line 347: | Line 356: | ||
- | === Extra global methods === | + | ==== Extra global methods |
- | The web server also adds new global JavaScript | + | The web server also adds a new global JavaScript |
set_cookie(string key, | set_cookie(string key, | ||
Line 357: | Line 366: | ||
[, string path | [, string path | ||
[, bool secure ]]]]) | [, bool secure ]]]]) | ||
- | | ||
- | + | ===== The SSJS Template System | |
- | ==== 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: | + | [Note: |
- | nested.] | + | |
- | === The SSJS Template Scheme === | + | ==== The SSJS Template Scheme |
Each page consists of four parts: | Each page consists of four parts: | ||
- | == The Header | + | === The Header |
../ | ../ | ||
- | + | ||
- | + | ||
This file contains the basic requirements for the HTML page. | This file contains the basic requirements for the HTML page. | ||
The opening HTML, doctype, title, CSS file link, etc. The | The opening HTML, doctype, title, CSS file link, etc. The | ||
Line 382: | Line 387: | ||
of the layout is continued in the next files. | of the layout is continued in the next files. | ||
- | == Top Navigation == | + | === Top Navigation |
- | ../ | + | ../ |
+ | | ||
- | The topnav.inc file contains the basic design of the " | + | The '' |
- | The links are dynamically generated by topnav_html.ssjs so both | + | The links are dynamically generated by '' |
files need to be addressed when modifying or creating themes. | files need to be addressed when modifying or creating themes. | ||
- | In the case of the default layout, topnav.inc has a left and right | + | In the case of the default layout, |
graphic and a middle section that the dynamic content goes. The | graphic and a middle section that the dynamic content goes. The | ||
background image is handled by CSS. You can change this to anything | background image is handled by CSS. You can change this to anything | ||
you like. | you like. | ||
- | The topnav_html.ssjs file may seem daunting at first, but it is | + | The '' |
pretty straight forward. | pretty straight forward. | ||
check the current page location and sets up the breadcrumbs based | check the current page location and sets up the breadcrumbs based | ||
Line 402: | Line 408: | ||
You want to add a Links page called links.html in the main | You want to add a Links page called links.html in the main | ||
directory. | directory. | ||
- | as: | + | as: |
- | if(http_request.virtual_path=="/ | + | |
- | template.topnav.push({html: | + | |
- | Some Links</ | + | |
- | == Left Side Navigation == | + | <code javascript> |
+ | if(http_request.virtual_path=="/ | ||
+ | template.topnav.push({html: | ||
+ | </ | ||
+ | |||
+ | === Left Side Navigation | ||
- | ../ | + | |
+ | | ||
+ | | ||
This starts the main table layout in the default layout and also | This starts the main table layout in the default layout and also | ||
Line 417: | Line 427: | ||
above with the exception of the two static links. | above with the exception of the two static links. | ||
- | == Main Content (various files) == | + | === Main Content (various files) |
This is where the layout of the main content is created. | This is where the layout of the main content is created. | ||
Line 425: | Line 435: | ||
each of the special codes contained in those files do will follow. | each of the special codes contained in those files do will follow. | ||
- | == Footer == | + | === Footer |
| | ||
../ | ../ | ||
Line 436: | Line 446: | ||
- | === SSJS Theme Support === | + | ==== 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 | ||
Line 444: | Line 453: | ||
Themes are activated by editing the ../ | Themes are activated by editing the ../ | ||
This file contains: | This file contains: | ||
+ | <code javascript> | ||
+ | /* Set default theme name */ | ||
+ | var DefaultTheme=" | ||
- | /* Set default theme name */ | + | /* Edit this bit to add/ |
- | var DefaultTheme=" | + | Themes[" |
- | + | Themes[" | |
- | | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | </ |
- | Themes[" | + | |
- | Themes[" | + | |
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[" | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | Themes[" |
+ | </ | ||
To change the Default Theme, change: | To change the Default Theme, change: | ||
- | | + | <code javascript> |
+ | var DefaultTheme=" | ||
+ | </ | ||
to: | to: | ||
+ | <code javascript> | ||
+ | var DefaultTheme=" | ||
+ | </ | ||
- | var DefaultTheme=" | + | ==== 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/ | By looking at at the message related files located in templates/ | ||
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 480: | Line 491: | ||
For example the groups.inc: | For example the groups.inc: | ||
+ | <code html> | ||
<!-- Main Content --> | <!-- Main Content --> | ||
| | ||
- | | + | <td class=" |
<table class=" | <table class=" | ||
Line 491: | Line 502: | ||
<< | << | ||
<tr> | <tr> | ||
- | | + | |
- | <a class=" | + | <a class=" |
- | %%groups: | + | %%groups: |
- | <td class=" | + | <td class=" |
- | @@JS: | + | @@JS: |
</tr> | </tr> | ||
<<END REPEAT groups>> | <<END REPEAT groups>> | ||
Line 502: | Line 513: | ||
<!-- end Main Content --> | <!-- end Main Content --> | ||
+ | </ | ||
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 507: | Line 519: | ||
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=" | <td class=" | ||
- | << | + | |
<a class=" | <a class=" | ||
%%groups: | %%groups: | ||
@@JS: | @@JS: | ||
- | <<END REPEAT groups>> | + | |
- | <br /> | + | |
- | <!-- 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 | + | i.e.; Spaces are replaced with: '' |
- | i.e.; Spaces are replaced with: this& | + | '' |
- | ^^name^^ is replaced with the URI encoded value of template.name | + | i.e.; Spaces are replaced with: |
- | + | ||
- | i.e.; Spaces are replaced with: this%20is%20URI | + | |
| | ||
- | @@name@@ is replaced with the value if template.name | + | '' |
No changes or encoding is performed. | No changes or encoding is performed. | ||
- | @@name: | + | '' |
(^^ and %% are also supported) | (^^ and %% are also supported) | ||
- | @@JS: | + | '' |
(^^ and %% are also supported) | (^^ and %% are also supported) | ||
+ | <code javascript> | ||
<< | << | ||
- | | + | |
<<END REPEAT name>> | <<END REPEAT name>> | ||
+ | </ | ||
- | Iterates over the array/ | + | Iterates over the array/ |
- | the value of template.name.sname. | + | the value of '' |
(^^ 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 | + | |
- | ../ | + | |
+ | Configuration settings for the SSJS Messaging system is located in the | ||
+ | '' | ||
+ | <code javascript> | ||
max_messages=20; | max_messages=20; | ||
max_pages=30; | max_pages=30; | ||
Line 573: | Line 586: | ||
show_messages_spacer_html="& | show_messages_spacer_html="& | ||
anon_only_message=" | anon_only_message=" | ||
- | anon_allowed_message='< | + | anon_allowed_message='< |
- | Post message anonymously'; | + | anon_reply_message='< |
- | anon_reply_message='< | + | |
- | Post message anonymously'; | + | |
private_only_message=" | private_only_message=" | ||
- | private_allowed_message='< | + | private_allowed_message='< |
- | Mark message as private'; | + | private_reply_message='< |
- | private_reply_message='< | + | </ |
- | Mark message as private'; | + | |
- | Each of these are configurable. NOTE: Lines ending in " | + | Each of these are configurable. |
- | below is part of the line above. | + | |
- | 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 '' |
which is parsed by the JavaScript engine. | which is parsed by the JavaScript engine. | ||
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 |
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: | + | <code javascript> |
- | '< | + | @@JS: |
+ | else '< | ||
+ | </ | ||
| | ||
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. | + | and not Guest. |
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 612: | Line 621: | ||
the Left side node listing. | the Left side node listing. | ||
- | IMPORTANT! | + | IMPORTANT! |
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. | + | '' |
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; | ||
+ | </ | ||
- | Now @@user_alias@@ can be in any *.inc template files and it will display the | + | Now '' |
user's alias. | user's alias. | ||
- | Care should be excersied | + | Care should be exercised |
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 637: | Line 646: | ||
- | 5.0 XJS files | + | ===== XJS files ===== |
- | ------------- | + | |
- | XJS files, handled by exec/ | + | XJS files, handled by '' |
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 654: | Line 663: | ||
either "<? | either "<? | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 660: | Line 670: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
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 668: | Line 680: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
Looping constructs are permitted, however, not using brackets can result in | Looping constructs are permitted, however, not using brackets can result in | ||
Line 674: | Line 687: | ||
The following example displays the numbers from one to 10. | The following example displays the numbers from one to 10. | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 684: | Line 698: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 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> | ||