Variables

From PhiWiki
Jump to: navigation, search

In text data sources you can make usage of special Phi variables. The Phi variables are substituted by their value. Ensure you checked the field Parse data in the Text source dialog otherwise the variables will not be substituted.

See also: Text sources.

$PHIALL

Searches in all categories ie. cookies, GET variables, POST variables, etc. This can be time consuming.

$PHICOOKIE

Returns the cookie set for name or an empty string if the cookie is not set.

$PHICOOKIE[name]

$PHIFILE

Returns the appropriate component of an uploaded file for name. The component filename returns the original file name, tmpfile is the absolute path where the file is temporarely stored and size is the file size in bytes.

$PHIFILE[name][filename]
$PHIFILE[name][tmpfile]
$PHIFILE[name][size]

See also: File class, File upload.

$PHIGET

Returns the value for name for a GET request.

$PHIGET[name]

$PHIHEADER

Returns the HTTP header string for header.

$PHIHEADER[header]

Returns the browser agent string:

$PHIHEADER[User-Agent]

See also: HTTP header.

$PHIPOST

Returns the value for name for a POST request.

$PHIPOST[name]

Note: in Phi all form input elements are sent as POST data.

See also: Form action, request.post.

$PHIREQUEST

Searches in the categories GET, POST and COOKIE.

$PHIREQUEST[myfield]

The contents of myfield will be returned if it was set by a GET, POST or COOKIE request.

Note: A cookie has precedence before a POST and a POST before a GET if concurrent values are set.

$PHISERVER

accept

Contains the HTTP accept string the browser sent. This is the same as $PHIHEADER[accept].

admin

The server administrator's email address.

agent

Client user agent string. This is the same like $PHIHEADER[User-Agent].

contenttype

Content type of the request.

contentlength

Length in bytes of the requested POST data.

documentroot

Contains the document root as an absolute path.

filename

Requested filename including the absolut path on the local maschine.

hostname

The requested domain (part of the HTTP header Host: domain).

keepalive

Contains the keep alive time a connection remains valid without any data exchange. This can be set in the server configuration.

lang

Returns the current language used for this page requested by the browser and available by the server or the default language 'C' if no language does match. This may be overwritten by philang=<lang id> in the URL query string.

$PHISERVER[lang]

See also: phi.lang, document.lang.

localaddress

Contains the local IP address of the server.

See also: $PHISERVER[remoteaddress].

method

Request method (usually http or https).

modified

Date and time of the last modification of $PHISERVER[filename] in the format yyyymmddhhmmsszzz.

month

Returns the name of the current month (translated by the system locale) for $PHISERVER[lang].

$PHISERVER[month] or
$PHISERVER[month][0]

To optain a translated month name in the year (in this example february) use:

$PHISERVER[month][2]

monthlist

Returns a complete monthlist separeted by '\n' with the respective month number in squared brackets.

$PHISERVER[monthlist] (january[1]\nfebruary[2]\n...december[12]\n)

Note: the month names are automatically translated to the appropriate language if the requested locale is available on the server maschine.

nowutc

Date and time in GMT (universal time) in the format yyyymmddhhmmsszzz.

See also: $PHISERVER[started].

password

Contains the password part of the HTTP header (ie. if you protect pages with .htaccess).

See also: $PHISERVER[user].

port

The actual port the server is listening on (usually 80 or 8080).

postdata

Contains the POST data as a complete URL query string.

remoteaddress

Contains the remote IP address of the client for this request.

See also: $PHISERVER[localaddress].

self

Path of the current requested URL.

serverdef

Server definition string. In conjunction with Phis server this is usually default.

serverhost

Full qualified domain name of the server.

servername

If you use the Phis server this contains the version and system string. Using the Apache module this contains the Apache server version.

started

Date and time when the request started in the format yyyymmddhhmmsszzz in local server time.

See also: $PHISERVER[nowutc].

tempdir

Contains the server's temporary directory where database files and images are stored.

Note: this is not necessarely the system's temp directory! If you want to obtain the system's temp directory you may use file.tempdir in JavaScript.

today

Returns the current date in the ISO format YYYY-MM-DD or days after/before if you specify an index.

$PHISERVER[today]
$PHISERVER[today][3] (three days in the future)
$PHISERVER[today][-5] (five days in the back)

url

URL string of the request.

user

Contains the user part of the HTTP header (ie. if you restrict pages with .htaccess.

See also: $PHISERVER[password].

useragent

v1.4.1 Returns the user agent as a string. Currently supported are:

  • MSIE
  • Safari
  • Firefox
  • Chrome
  • Konqueror
  • SeaMonkey
  • Amphibia

userengine

v1.4.1 Returns the user engine as a string. Supported are:

  • Trident
  • WebKit
  • Gecko
  • Presto

useros

v1.4.1 Returns the user operating system as a string. Currently supported are:

  • Windows
  • MacOSX
  • iOS
  • Linux
  • Android
  • WindowsMobile
  • Symbian
  • Solaris
  • HPUX
  • AIX

version

v1.4.1 Returns the current Phi version in the form 'major.minor.patch'.

year

Returns the current year in the ISO format or a year in the future or in the back by the offset.

$PHISERVER[year] (2010, if this is the current year)
$PHISERVER[year][3] (2013, if 2010 is the current year)
$PHISERVER[year][-2] (2008, if 2010 is the current year)

yearlist

Returns a year list separated by a '\n' if you specify an index or the currenty year without any index.

$PHISERVER[yearlist][3] (2010\n2011\n2012, if 2010 is the current year)

The maximum index is 1000.

$PHISQL

Returns the SQL value at position x (starting from 0).

$PHISQL[x]

Asume the following SQL statement:

SELECT firstname, lastname FROM persons WHERE id=$PHIGET[uid]

Then lastname will be accessible through:

$PHISQL[1]