PHP Module loxberry_system.php


require_once "loxberry_system.php";

It's not required to add a path to the PHP library.

Constants and Globals

Difference between global variables and constants

Constants are valid in the full PHP script and are specified without $ mark (e.g. LBHOMEDIR).  Disadvantage of constants is, that they are not expanded inside double-quotes. All LoxBerry constants are written in CAPITAL letters.

Global variables are available in the main script, but they need to be declared as global inside functions. They are, equivalent to the variables in the Perl modules, written in lowercase.

Variable example Quelle erweitern

# Usage of constants
// Using the constant LBHOMEDIR
// Result: 1. LBHOMEDIR: /opt/loxberry
// Constants do not expand in strings - this cannot be used
// A function called testglobals using variables
function testglobals 
    global $lbpplugindir;
    // Using the declared $lbpplugindir
    print "3. lbpplugindir: $lbpplugindir";
    // Result: 3. lbpplugindir: myplugin
    // Without declaration - not working
    print "4. lbhomedir: $lbhomedir";
    // Result: 4. lbhomedir: 

The following table shows all global variables and all constants. Use variables or constants as you prefer. All plugin variables contain your plugin folder. Please remember that both constants and variables are case-sensitive (constants: CAPITAL without $; variables: lowercase with $).

In other languages like bash, you cannot access the PHP variables. For such cases you can use the system environment variables, that do not include the plugin folder. 

Variable Constant Usage
\\ $lbhomedir\\ 
Home directory of LoxBerry, usually /opt/loxberry
PLUGIN variables and constants
$lbpplugindir LBPPLUGINDIR Sub-directory of the current plugin without path, e.g. squeezelite
$lbphtmlauthdir LBPHTMLAUTHDIR Absolute path to the HTMLAUTH directory of the active plugin, e.g. /opt/loxberry/webfrontend/htmlauth/plugins/squeezelite
$lbphtmldir LBPHTMLDIR Absolute path to the HTML directory of the active plugin, e.g. /opt/loxberry/webfrontend/html/plugins/squeezelite
$lbptemplatedir LBPTEMPLATEDIR Absolute path to the template directory of the active plugin, e.g. /opt/loxberry/templates/plugins/squeezelite
$lbpdatadir LBPDATADIR Absolute path to the data directory of the active plugin, e.g. /opt/loxberry/data/plugins/squeezelite
$lbplogdir LBPLOGDIR Absolute path to the log directory of the active plugin, e.g. /opt/loxberry/log/plugins/squeezelite
$lbpconfigdir LBPCONFIGDIR Absolute path to the config directory of the active plugin, e.g. /opt/loxberry/config/plugins/squeezelite
$lbpbindir LBPBINDIR Absolute path to the bin directory of the active plugin, e.g. /opt/loxberry/bin/plugins/squeezelite
SYSTEM variables and constants for LoxBerry-Core developers (plugin devs usually won't need)
$lbshtmlauthdir LBSHTMLAUTHDIR Absolute path to the SYSTEM HTMLAUTH directory /opt/loxberry/webfrontend/htmlauth/system
$lbshtmldir LBSHTMLDIR Absolute path to the SYSTEM HTML directory /opt/loxberry/webfrontend/html/system
$lbstemplatedir LBSTEMPLATEDIR Absolute path to the SYSTEM templates directory /opt/loxberry/templates/system
$lbsdatadir LBSDATADIR Absolute path to the SYSTEM data directory /opt/loxberry/data/system
$lbslogdir LBSLOGDIR Absolute path to the SYSTEM log directory /opt/loxberry/log/system
$lbstmpfslogdir LBSTMPFSLOGDIR Absolute path to the SYSTEM tmpfs log directory /opt/loxberry/system_tmpfs
$lbsconfigdir LBSCONFIGDIR Absolute path to the SYSTEM config directory /opt/loxberry/config/system
$lbsbindir LBSBINDIR Absolute path to the SYSTEM bin directory /opt/loxberry/bin
$lbssbindir LBSSBINDIR Absolute path to the SYSTEM bin directory /opt/loxberry/sbin/system


Most functions are in the class LBSystem, therefore they need to be called with LBSystem::function(). Some functions are in the main namespace and therefore don't require the LBSystem prefix. The title of every function in this documentation shows how to call it. 

Most function names and features are identical to the Perl sibling LoxBerry::System with PHP adjusted syntax. 


Returns a pre-formatted date/time string, e.g. to use in logfiles. Without parameter the format is human-readable. With parameters you can request a string that is optimized for file names, or an ISO formatted string.


This function returns from a Unix Epoch timestamp the Loxone timestamp, or, without parameter, the current time as Loxone timestamp. 


LoxBerry's configuration saves execution paths to common binaries to stay system independend. As the required binary exists in the binary list, you should favor the variable instead of hard-coding the execution pathes in your plugin.


Miniserver's FTP port is not included in Loxberry's configuration because it is requested on-demand by a webservice call. This function additionally supports Loxone CloudDNS and therefore always returns the correct FTP port.


Returns the LoxBerry network ip address as string.


Searches for the given ip address in the Miniserver list and returns the list number. Use the list number in the array of get_miniservers.


Searches for the given Miniserver name and returns the list number. Use the list number in the array of get_miniservers.


This function returns an two dimension array of LoxBerry's configured Miniservers.


Returns an array with all installed plugins, including version information and icon uri.


Used for config parameters. Returns True if the $text contains a word that fuzzy could mean False.


Used for config parameters. Returns True if the $text contains a word that fuzzy could mean True.


Returns the current user country of LoxBerry (e.g. "at")


Returns the user defined friendly name of this LoxBerry. This is not the hostname.


Returns the network hostname of LoxBerry.


Returns the current user langauge of LoxBerry (e.g. "de")


Returns the current version of LoxBerry (e.g. "0.4.1")


Returns the Apache2 webserver port.


This function returns from a Loxone timestamp the Unix Epoch timestamp . 


This function returns a named array with all data of the current plugin from the plugin database. Optionally you can use the pluginname or foldername as parameter, to get the data from the named plugin.


This function returns the currently set plugin loglevel, that the user has set in the plugin management.


Returns the plugin version of your plugin from LoxBerry's plugin database.


Returns the appropriate user language as an array.


Sets the state of LoxBerry to require a reboot. This can be used for example in a plugin, where a change of a setting requires a reboot of LoxBerry.


TESTING We had done no tests with the Cloud DNS features, therefore please give feedback if you have any issues.