Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Bootstrap

This only applies to FreePBX 2.9+. Trying to use this on FreePBX 2.8 or lower will end up causing you headaches. This is because the entire backend system was re-written in 2.9.

...

  1. $amp_conf (array)- This is an array with all the (formerly) amportal.conf settings. (Note, these settings have been moved to the databases, and amportal.conf has been depreciated.). These settings also include some defaults that in the past were set by another function. This array is ready to use and requires no further modifications

    $amp_conf example

    Code Block
    <?php
    include '/etc/freepbx.conf';
     
    global $amp_conf;
    echo $amp_conf['AMPWEBROOT']; //Echoes the webroot
    //OR//
    echo FreePBX::Config()->get('AMPWEBROOT');
  2. $astman (object) - An instantiation of the PHP Asterisk Manager class. Use this to access anything directly in access, like to get information, run a command, or originate a call. If bootstrap cannot connect to asterisk, these variables will not be set. Please see the documentation here: Asterisk Manager Class

    $astman example

    Code Block
    <?php
    include '/etc/freepbx.conf';
    if($astman->connected()) {
        $out = $astman->Command('sip show registry');
        echo $out['data'];
    } else {
        echo "no asterisk manager connection";
    }
  3. $db (object) - The humble database connect, used via the PearDB class. Please see the documentation here: PearDB

    $db example

    Code Block
    <?php
    include '/etc/freepbx.conf';
    global $db;
    $sql = "SELECT * FROM sip WHERE keyword = 'account'";
    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
    /* $results is either an array or a PearDB Error Object
    +------+---------+------+-------+
    | id   | keyword | data | flags |
    +------+---------+------+-------+
    | 1000 | account | 1000 |    25 |
    | 1002 | account | 1002 |    25 |
    +------+---------+------+-------+
    2 rows in set (0.00 sec)
    */
  4. The Constant FREEPBX_IS_AUTH - This constant can be used to verify if a file has been accessed directly or via proper authentication. It saves the developer the need to have a .htaccess file to secure individual files. Use it as follows:

    FREEPBX_IS_AUTH Example

    Code Block
    <?php
    defined('FREEPBX_IS_AUTH') OR die('No direct script access allowed');}
    /*your code here */
  5. All functions from framework functions.inc.php.

  6. All module functions (from their respective function.inc.php).

  7. $asterisk_conf the asterisk settings from asterisk.conf 

...