Introduction
The LiveAPI system and dynamicui
files can access cPanel's global variables. These variables return data about the server's configuration and the authenticated user.
Note:
The examples below use the following LiveAPI system methods:
- The
cpanelif()
method evaluates a logic operator or cPanel variable as true or false. - The
cpanelprint()
method returns a cPanel variable's value.
Logic operators
!
Description:
This logic operator reverses the action of another logic operator.
Example:
The following code returns true
if a
does not equal b
:
<cpanelif !a==b> |
==
Description:
This logic operator checks whether the first argument is equal to the second argument.
Example:
The following code returns true
if a
equals b
:
<cpanelif a==b> |
=et=
Description:
This logic operator checks whether the first argument is equal to the second argument.
Example:
The following code returns true
if 1
equals 1
:
<cpanelif 1=et=1> |
=gt=
Description:
This logic operator checks whether the first argument is greater than the second argument.
Example:
The following code returns true
if 4
is greater than 3:
<cpanelif 4=gt=3> |
=gtet=
Description:
This logic operator checks whether the first argument is greater than or equal to the second argument.
Example:
The following code returns true
if 4
is greater than or equal to 3
:
<cpanelif 4=gtet=3> |
=lt=
Description:
This logic operator checks whether the first argument is less than the second argument.
Example:
The following code returns true
if 3
is less than 4
:
<cpanelif 3=lt=4> |
=ltet=
Description:
This logic operator checks whether the first argument is less than or equal to the second argument.
Example:
The following code returns true
if 3
is less than or equal to 4
:
<cpanelif 3=ltet=4> |
cPanel variables
$abshomedir
Description:
This variable returns the absolute path to the authenticated user's home directory.
Note:
If the user's home directory is a symlink, this variable returns the absolute path to the symlink's target.
Example:
The following code prints the absolute path to the authenticated user's home directory:
$cpliveapi ->cpanelprint( '$abshomedir' }); |
$appname
Description:
This variable returns the current cPanel & WHM application.
For example, this variable returns cpanel
if you call it from the cPanel interface, or webmail
if you call it within a cPanel account's webmail interface.
Example:
The following code prints the current cPanel & WHM application:
$cpliveapi ->cpanelprint( '$appname' }); |
$basedir
Description:
This variable returns the absolute path to the current directory.
Example:
The following code prints the current directory's path:
$cpliveapi ->cpanelprint( '$basedir' }); |
$basefile
Description:
This variable returns the absolute path to the current file.
Example:
The following code prints the current file's location:
$cpliveapi ->cpanelprint( '$basefile' }); |
$BRANDINGIMG{'KEY'}
Description:
This variable returns the string cpanel_magic_revision_random
, where random
is a random integer, and the relative path to the specified image file (key
).
This path is relative to the /usr/local/cpanel/base/
directory.
Example:
The following code prints the relative path to the email-pass.gif
file:
$cpliveapi ->cpanelprint( $BRANDINGIMG { 'email-pass.gif' }); |
$brandingpkg
Description:
This variable returns the user's current branding package.
Example:
The following code prints the current branding package's name:
$cpliveapi ->cpanelprint( '$brandingpkg' ); |
$CONF{'KEY'}
Description:
This variable returns the value for a specific setting (key
) in the /var/cpanel/cpanel.config
file.
Example:
The following code prints the server's mysql-version
setting:
$cpliveapi ->cpanelprint( $CONF { 'mysql-version' }); |
$CPDATA{'KEY'}
Description:
This variable returns the value for a specific setting (key
) in the authenticated user's data file.
The system retrieves this information from the hash of settings in the /var/cpanel/users/username
file, whereusername
is the cPanel or WHM account username.
Example:
The following code prints the user's CONTACTEMAIL
setting:
$cpliveapi ->cpanelprint( $CPDATA { 'CONTACTEMAIL' }); |
$CPERROR{'module'}
Description:
This variable returns most recent error that the specified module (module
) returned.
Note:
Module names must be in lowercase.
Example:
The following code prints the most recent error for the email
module:
$cpliveapi ->cpanelprint( $CPERROR { 'email' }); |
$CPVAR{'KEY'}
Description:
This variable returns the value of a cPanel variable that you set elsewhere in the same page.
This variable will check any cPanel variables that you set with a cpanel
function or a <cpanel setvar>
tag.
Example:
The following code prints the test
variable's most recent value:
$cpliveapi ->cpanelprint( $CPVAR { 'test' }); |
$FORM{'KEY'}
Description:
This variable returns the GET or POST data for a specific variable (key
) that a user passes to a page as part of a form.
Note:
To return the URI-encoded version of the value, use the $URI_ENCODED_FORM{'KEY'
} variable.
Example:
The following code prints the test
variable's value:
$cpliveapi ->cpanelprint( $FORM { 'test' }); |
$formdump
Description:
This variable returns the entire contents of the $FORM{}
hash, which contains all of the GET or POST data that a user passes to a page.
Use this variable to debug an interface form.
Example:
The following code prints the contents of the $FORM{}
hash:
$cpliveapi ->cpanelprint( '$formdump' }); |
$hasanonftp
Description:
This variable returns a boolean value that indicates whether anonymous FTP is enabled on the server.
- A value of
1
indicates that anonymous FTP is enabled. - A value of
0
indicates that anonymous FTP is disabled.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasanonftp' }); |
$hasdedicatedip
Description:
This variable returns a boolean value that indicates whether the authenticated account has a dedicated IP address.
- A value of
1
indicates that the account has a dedicated IP address. - A value of
0
indicates that the account does not have a dedicated IP address.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasdedicatedip' }); |
$hasgem
Description:
This variable returns a boolean value that indicates whether RubyGems are enabled for the authenticated account.
- A value of
1
indicates that RubyGems are enabled. - A value of
0
indicates that RubyGems are disabled.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasgem' }); |
$hasmoddeflate
Description:
This variable returns a boolean value that indicates whether the mod_deflate
Apache module is available on the server.
- A value of
1
indicates that the module is available. - A value of
0
indicates that the module is not available.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasmoddeflate' }); |
$hasmodproxy
Description:
This variable returns a boolean value that indicates whether the mod_proxy
Apache module is available on the server.
- A value of
1
indicates that the module is available. - A value of
0
indicates that the module is not available.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasmodproxy' }); |
$haspear
Description:
This variable returns a boolean value that indicates whether PHP PEAR is installed.
- A value of
1
indicates that PHP PEAR is installed. - A value of
0
indicates that PHP PEAR is not installed.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$haspear' }); |
$haspostgres
Description:
This variable returns a boolean value that indicates whether PostgreSQL® is installed.
- A value of
1
indicates that PostgreSQL is installed. - A value of
0
indicates that PostgreSQL is not installed.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$haspostgres' }); |
$haspureftp
Description:
This variable returns a boolean value that indicates whether the authenticated account uses the Pure-FTPd FTP server.
- A value of
1
indicates that the account uses Pure-FTPd. - A value of
0
indicates that the account does not use Pure-FTPd.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$haspureftp' }); |
$hasrails
Description:
This variable returns a boolean value that indicates whether Ruby on Rails® is enabled for the authenticated account.
- A value of
1
indicates that Ruby on Rails is enabled. - A value of
0
indicates that Ruby on Rails is disabled.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasrails' }); |
$hasvalidshell
Description:
This variable returns a boolean value that indicates whether the authenticated account has shell access.
- A value of
1
indicates that the account has shell access. - A value of
0
indicates that the account does not have shell access.
Example:
The following code prints a boolean value, as described above:
$cpliveapi ->cpanelprint( '$hasvalidshell' }); |
$homedir
Description:
This variable returns the absolute path to the authenticated user's home directory.
Example:
The following code prints the authenticated user's home directory path:
$cpliveapi ->cpanelprint( '$homedir' }); |
$hostname
- 0 Users Found This Useful