Server class

From PhiWiki
Jump to: navigation, search

This class contains all specific settings for the server. You can query the servername, port, etc.


The server class is global object in the Phi server environment.

var s=server;


  • String admin [read]
  • String documentroot [read]
  • Number keepalive [read]
  • String localaddress [read]
  • String nowutc [read]
  • String remoteaddress [read]
  • String serverdef [read]
  • String serverhost [read]
  • String servername [read]
  • String tempdir [read]
  • String today [read]
  • Number port [read]
  • StringArray properties [read]

String admin

Returns the administrator email of the current server.

var admin=server.admin;

String documentroot

Returns the documentroot of the current server.

var root=server.documentroot;

Number keepalive

Returns how long the server keeps the connection to a client without any transfer.

var alive=server.keepalive;

String localaddress

Returns the local IP address of the server.

var ip=server.localaddress;

String nowutc

Returns the current date and time in UTC (GMT) in the format yyyymmddhhmmsszzz.

var utc=server.nowutc;

Use the request.started function to get the current date and time in local time. If you want to obtain the current date in a Date format use server.utc.

See also: server.utc, request.started.

String remoteaddress

Returns the remote IP address of the client (browser).

var add=server.remoteaddress;

String serverdef

Returns the server definition (manager) name (usually default if you use the Phis server).

var name=server.serverdef;

String serverhost

Returns the hostname of the server (usually the domain name).

var name=server.serverhost;

String servername

Returns the server name (usally phis/version number/system string in Phis server or the Apache server string in the Apache module).

var name=server.servername;

String tempdir

Returns the temporay directory of the server where generated images, the session database and temporarly CSS and JavaScript files are stored.

var tmp=server.tempdir;

Note: If you want to get the systems temp directory use file.tempdir instead.

String today

Returns the current date (local server time) in the ISO8601 format yyyy-mm-dd.


Note: Use server.started to obtain the current date in a Date format.

Number port

Returns the current used port of the server (usally 80 or 8080).

var port=server.port;

StringArray properties

Returns the available properties for the server class in a string array.


Date utc

v1.1 Returns the current server time in UTC (GMT).

var utc=server.utc;

See also: server.nowutc, request.started.


Void log()

Logs string to the error log (Apache or Phis log).

server.log( string );

Note: for your convenience this is also provided through system.log().

Additional notes

In Text sources you can make use of the $PHISERVER[prop] variable. Simply replace prop with one of the provided properties to get the appropriate replacement.