Available Variables

This page documents the variables available within cPanel's HTML logic and DynamicUI files.

Basics

When placed inside of an HTML file:

  • To display the contents of a variable:
<cpanel print="$var">
  • To use the variable to determine what HTML to render:
<cpanelif $var>
$var is true!
</cpanelif>

For information about using these variables inside of a DynamicUI file, please refer to the Adding Icons and Groups to cPanel document.

Variables

Variable $LANG{'KEY'}
Description Language key lookup. These keys correspond to the entry inside of the language file at /usr/local/cpanel/lang or by selecting "Download a Language File" inside of WHM and viewing the key/pairs there.
Example $LANG{'hd'}
Explanation Will print Backups to the cPanel interface, if the language is set to english.
 
Variable $FORM{‘KEY’}
Description Conains GET or POST data passed to a page.
Example $FORM{'test'}
Explanation Will equal GETDATA if ?test=GETDATA is added as a parameter to the page.
 
Variable $URI_ENCODED_FORM{'KEY'}
Description Contains specified GET or POST key in a URI-decoded format.
Example $URI_ENCODED_FORM{'test'}
Explanation Will equal GET+DATA if ?test=GET DATA is passed to the page.
 
Variable $CPDATA{‘KEY’}
Description Contains specified KEY from user's CPUSERS file.
Example $CPDATA{'DNS'}
Explanation Will contain the primary domain specified by DNS= in /var/cpanel/users/$username
 
Variable $CONF{‘KEY’}
Description Contains a key from the cpanel.config file.
Example $CONF{'mysql-version'}
Explanation Will contain 5.0 if mysql-version=5.0 exists in /var/cpanel/cpanel.conf
 
Variable $CPERROR{'modulename'}
Description Contains the last error returned by a module. The modulename should be in all lowercase.
Example $CPERROR{'email'}
Explanation Will contain "Sorry, the given email address is invalid." if the last email address created was invalid.
 
Variable $CPVAR{‘KEY’}
Description Value of a cpanel variable that is set elsewhere within the same page load. Can be set by a cpanel function or <cpanel setvar> function
Example $CPVAR{'bob'}
Explanation If <cpanel setvar=”bob=1”> has been run, this will equal 1.
 
Variable $BRANDINGIMG[‘KEY’}
Description Branding image lookup (returns URL of a brandable image).
Example $BRANDINGIMG{'email-pass.gif'}
Explanation Will return /frontend/x3/branding/email-pass.gif, preceded by cpanel_magic_revision_$randomint
 
Variable $NVDATA{‘KEY’}
Description Look up an non-volatile data key.
Example $NVDATA{'test'}
Explanation Will contain the contents of $homedir/.cpanel/nvdata/test
 
Variable $lang
Description Current language name.
Example <cpanel print="$lang">
Explanation Prints the currently enabled language.
 
Variable $version
Description The version of cPanel currently installed.
Example <cpanel print="$version">
Explanation Prints the current version of cPanel installed on a system.

Variable $homedir
Description User's home directory.
Example <cpanel print="$homedir">
Explanation Prints the user's home directory.
 
Variable $ip
Description Current primary IP for an account.
Example <cpanel print="$ip">
Explanation Prints the user's primary IP.
 
Variable $user
Description An account's username.
Example <cpanel print="$user">
Explanation Prints an account's username.
 
Variable $basefile
Description Relative URL path to the file that's currently being read.
Example <cpanel print="$basefile">
Explanation Will print the relative URL path to the file that's currently being read.
 
Variable $basedir
Description Relative path to the URL currently being used.
Example <cpanel print="basedir">
Explanation Prints the relative path to the directory currently being used.
 
Variable $appname
Description Print the application currently being used by the cPanel engine (for example, cpanel, webmail).
Example <cpanel print="$appname">
Explanation Prints the application currently being used by the cPanel engine (always either webmail or cpanel).
 
Variable $hostname
Description Contains the server's hosname.
Example <cpanel print="$hostname">
Explanation Prints the hostname of the server.
 
Variable $formdump
Description Prints all contents of the $FORM{} hash, used for debugging purposes.
Example <cpanel print="$formdump">
Explanation Prints all values passed via GET or POST to a page.
 
Variable $password
Description Contains user’s password (may not be available).
Example <cpanel print="$password">
Explanation Will print a user's password to the cPanel interface (probably a bad idea).
 
Variable $random
Description Returns a random number between 1 and 1000000.
Example <cpanel print="$random">
Explanation Prints a random number.
 
Variable $httphost
Description Current HTTP host used for connecting the cPanel daemon.
Example <cpanel print="$httphost">
Explanation Prints the HTTP host.
 
Variable $abshomedir
Description The absolute path to the users homedir (if the homedir is a symlink, the actual path will be shown).
Example <cpanel print="$abshomedir">
Explanation Prints the path to a cPanel user's home directory.
 
Variable $mainhttpdport
Description Contains that port on which Apache is listening (normally 80).
Example <cpanel print="mainhttpdport">
Explanation Prints the port on which Apache is running.
 
Variable $sslhttpdport
Description The port on which Apache is listening for SSL connection (usually 443).
Example <cpanel print="$sslhttpdport">
Explanation Prints 443 in most cases.
 
Variable $brandingpkg
Description Contains the current branding package.
Example <cpanel print="$brandingpkg">
Explanation Prints the currently used branding package (e.g. blackice, blueroy, etc).
 
Variable $isresellerlogin
Description Contains a numerical boolean value indicating whether the currently logged in session is authenticated using a reseller's (or the root user's) password.
Example <cpanelif $isresellerlogin>
Explanation Executes the block of code below it if the session is reseller/root-authenticated.
 
Variable $isreseller
Description Contains a numerical boolean value indicating whether the user has reseller privileges.
Example <cpanelif $isreseller>
Explanation Executes the block of code below it if the user has reseller privileges.

Variable $isallowedssl
Description Contains a numerical boolean value indicating whether the user is allowed to use the SSL feature of cPanel.
Example <cpanelif $isallowedssl>
Explanation Executes the block of code below it if the user has SSL privileges.
 
Variable $isresold
Description Contains a numerical boolean value indicating whether the account belongs to a reseller, and not the root user.
Example <cpanelif $isallowedssl>
Explanation Executes the block of code below if the user is owned by a reseller, rather than the root user.
 
Variable $mailactionhost
Description The mail host as configured in the WHM Tweak Settings interface.
Example <cpanel print="$mailactionhost">
Explanation Will print the mail host as configured in the WHM Tweak Settings interface.
 
Variable $hasdedicatedip
Description Contains a numerical boolean value indicating whether an account has a dedicated IP address.
Example <cpanelif $hasdedicatedip>
Explanation Will execute the block of code below it if the user has a dedicated IP address.
 
Variable $hasvalidshell
Description Contains a numerical boolean value indicating whether an account has shell access.
Example <cpanelif $hasvalidshell>
Explanation Will execute the block of code before it if the user has shell access.
 
Variable $haspureftp
Description Contains a numeric boolean value indicating whether the server is running Pure-FTPd or ProFTPd.
Example <cpanelif $haspureftp>
Explanation Will execute the block of code below it if the server is running Pure-FTPd.
 
Variable $hasanonftp
Description Contains a numeric boolean value indicating whether the server has anonymous FTP enabled.
Example <cpanelif $hasanonftp>
Explanation Executes the block of code below it if the server has anonymous FTP enabled.
 
Variable $hasurchin
Description Contains a numeric boolean value indicating whether the server has Urchin installed.
Example <cpanelif $hasurchin>
Explanation Executes the block of code below it if Urchin is installed.
 
Variable $hasmoddeflate
Description Contains a numerc boolean value indicating whether the server has mod_deflate.
Example <cpanelif $hasmoddefault>
Explanation Executes the block of code before it if mod_deflate is installed.
 
Variable $hasmodproxy
Description Contains a numeric boolean value indicating whether mod_proxy is installed.
Example <cpanelif $modproxy>
Explanation Executes the block of code below it if mod_proxy is installed.
 
Variable $hasgem
Description Contains a numeric boolean value indicating whether RubyGems support is available to the account.
Example <cpanelif $hasgem>
Explanation Executes the block of code below it if RubyGems support is available.
 
Variable $hasrails
Description Contains a numeric boolean value indicating whether Ruby on Rails is installed.
Example <cpanelif $hasrails>
Explanation Executes the block of code below it if Rails support is available to an account.
 
Variable $haspear
Description Contains a numeric boolean value indicating whether PHP PEAR is installed.
Example <cpanelif $haspear>
Explanation Executes the block of code below it if PHP PEAR is installed.
 
Variable $haspostgres
Description Contains a numeric boolean value indicating whether PostgreSQL support is enabled within an account.
Example <cpanelif $haspostgres>
Explanation Execute the block of code below it if PostgreSQL support is installed.
 
Variable $mysqlversion
Description Contains the version of MySQL installed on the server, in the format x.x.x.
Example <cpanel print="$mysqlversion">
Explanation Prints the MySQL version to the cPanel interface.

Logic Operators

Operator =ltet=
Description Less than or equal to
Example
<cpanelif 2 =ltet= 3>
 
Operator =gtet=
Description Greater than or equal to
Example
<cpanelif 4 =gtet= 3>
 
Operator ==
Description Equals
Example
<cpanelif 1 == 1>
 
Operator =et=
Description Equal to
Example
<cpanelif 1 =et= 1>
 
Operator =gt=
Description Greater than
Example
<cpanelif 4 =gt= 3>
 
Operator =lt=
Description Less than
Example
<cpanelif 2 =ltet= 3>
 
Operator !
Description Reverse
Example
<cpanelif !2 == 3>
Topic revision: r11 - 06 Nov 2009 - 16:55:21 - Main.MattDees
DeveloperResources.ExpVarRef moved from Sandbox.ExpVarRef on 05 Nov 2009 - 19:42 by Main.JustinSchaefer - put it back
 

Copyright © cPanel 2000-2009.