Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     $type = $input->getOption('type');
     if (file_exists($filename)) {
         $data = \FreePBX::Bulkhandler()->fileToArray($filename);
     } else {
         $output->writeln('<error>The specified file does not exist or we cannot read it</error>');
         return false;
     }
     if (!$data) {
         $output->writeln('<error>The file provided did not process properly. Check the file formatting</error>');
         return false;
     }
     switch ($type) {
         case 'dids':
             $output->writeln('Importing bulk dids');
             $ret = \FreePBX::Bulkhandler()->import('dids', $data);
             break;
         case 'extensions':
             $output->writeln('Importing bulk extensions');
             $ret = \FreePBX::Bulkhandler()->import('extensions', $data);
             break;
         default:
             $output->writeln('<error>You must specify the file type of --type=dids or --type=extensions</error>');
             return false;
             break;
     }
     if (!$ret) {
         $output->writeln('<error>The import failed</error>');
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 2
0
/**
* do variable substitution 
*/
function backup__($var)
{
    global $amp_conf;
    /*
     * Substitues Config vars for __VARNAME__.
     *
     * If no __VAR__, return $var
     * If Config var doesn't exist, throws an exception.
     */
    if (!preg_match("/__(.+)__/", $var, $out)) {
        return $var;
    }
    $ampvar = $out[1];
    if (!\FreePBX::Config()->conf_setting_exists($ampvar)) {
        if (isset($amp_conf[$ampvar])) {
            // This is for things like AMPDBHOST which are defined in /etc/freepbx.conf
            $replace = $amp_conf[$ampvar];
        } else {
            throw new \Exception("Was asked for FreePBX Setting '{$var}', but it doesn't exist. Can't continue.");
        }
    } else {
        $replace = \FreePBX::Config()->get($ampvar);
    }
    return str_replace("__{$ampvar}__", $replace, $var);
}
Ejemplo n.º 3
0
 function __construct($mode = 'local')
 {
     if ($mode == 'local') {
         //Setup our objects for use
         //FreePBX is the FreePBX Object
         $this->FreePBX = \FreePBX::create();
         //UCP is the UCP Specific Object from BMO
         $this->Ucp = $this->FreePBX->Ucp;
         //System Notifications Class
         //TODO: pull this from BMO
         $this->notifications = \notifications::create();
         //database subsystem
         $this->db = $this->FreePBX->Database;
         //This causes crazy errors later on. Dont use it
         //$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     }
     $this->emoji = new Client(new Ruleset());
     $this->emoji->imagePathPNG = 'assets/images/emoji/png/';
     // defaults to jsdelivr's free CDN
     $this->emoji->imagePathSVG = 'assets/images/emoji/svg/';
     // defaults to jsdelivr's free CDN
     $this->detect = new \Mobile_Detect();
     // Ensure the local object is available
     self::$uobj = $this;
 }
Ejemplo n.º 4
0
/** If this is ours, we return it, otherwise we return false
 *  We use just use customappsreg and not the display because it
 *  is a per-module routine
 */
function customappsreg_getdestinfo($dest)
{
    global $active_modules;
    $allDests = \FreePBX::Customappsreg()->getAllCustomDests();
    // Look for $dest in allDests. If we know about it, then return
    // the details. If we don't, return false.
    // Is it a new one?
    if (substr($dest, 0, 12) == "customdests,") {
        if (!preg_match("/customdests,dest-(\\d+),1/", $dest, $matches)) {
            throw new \Exception("Unable to validate dest {$dest}");
        }
        if (!isset($allDests[$matches[1]])) {
            return false;
        } else {
            // Found it.
            $cd = $allDests[$matches[1]];
            $tmparr = array('description' => sprintf(_("Custom Destination: %s"), $cd['description']), 'edit_url' => "config.php?display=customdests&destid=" . $cd['destid']);
            return $tmparr;
        }
    }
    foreach ($allDests as $cd) {
        if ($cd['target'] == $dest) {
            // Found it.
            $tmparr = array('description' => sprintf(_("Custom Destination: %s"), $cd['description']), 'edit_url' => "config.php?display=customdests&destid=" . $cd['destid']);
            return $tmparr;
        }
    }
    // Didn't find it.
    return false;
}
 public function getSections()
 {
     $sections = array();
     $users = \FreePBX::Core()->listUsers(true);
     $ret = array();
     $ret['title'] = _("Users");
     $featurecodes = \featurecodes_getAllFeaturesDetailed();
     $ret['textdesc'] = _('User');
     $ret['numdesc'] = _('Extension');
     $ret['items'] = array();
     foreach ($users as $user) {
         $ret['items'][] = array($user[1], $user[0]);
     }
     $sections[] = $ret;
     $hookdata = \FreePBX::Hooks()->processHooks();
     foreach ($hookdata as $key => $value) {
         $sections[] = $value;
     }
     $html .= '<div class="row holder">';
     $html .= '<div class="col-sm-12">';
     foreach ($sections as $k => $v) {
         $html .= '<div class="row">';
         $html .= '<h3>' . $v['title'] . '</h3>';
         $html .= '<ul class="list-group">';
         foreach ($v['items'] as $item) {
             $html .= '	<li class="list-group-item col-sm-6"><b>' . $item[1] . '</b> - ' . $item[0] . '</li>';
         }
         $html .= '</ul>';
         $html .= '<br/>';
         $html .= '	</div>';
     }
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 6
0
 public function __construct($test = false)
 {
     // Asterisk Directories
     $this->agidir = \FreePBX::Config()->get('ASTAGIDIR');
     $this->varlibdir = \FreePBX::Config()->get('ASTVARLIBDIR');
     $moh = \FreePBX::Config()->get('MOHDIR');
     $this->mohdir = $this->varlibdir . "/" . (!empty($moh) ? $moh : "moh");
     $this->etcdir = \FreePBX::Config()->get('ASTETCDIR');
     $this->logdir = \FreePBX::Config()->get('ASTLOGDIR');
     $this->moddir = \FreePBX::Config()->get('ASTMODDIR');
     $this->rundir = \FreePBX::Config()->get('ASTRUNDIR');
     $this->spooldir = \FreePBX::Config()->get('ASTSPOOLDIR');
     $this->webroot = \FreePBX::Config()->get('AMPWEBROOT');
     $this->sbindir = \FreePBX::Config()->get('AMPSBIN');
     $this->bindir = \FreePBX::Config()->get('AMPBIN');
     $vars = array("agidir", "varlibdir", "mohdir", "etcdir", "logdir", "moddir", "rundir", "spooldir", "webroot", "sbindir", "bindir");
     foreach ($vars as $v) {
         if (empty($this->{$v})) {
             throw new \Exception("I couldn't find {$v}");
         }
         if (substr($this->{$v}, -1) != "/") {
             // If it doesn't end with a slash
             $this->{$v} = $this->{$v} . "/";
             // Add it.
         }
     }
     // Assumptions...
     $this->soundsdir = $this->varlibdir . "sounds/";
 }
Ejemplo n.º 7
0
 public function getProxySettings()
 {
     $conf = FreePBX::Config();
     if ($conf->get('PROXY_ENABLED')) {
         $url = trim($conf->get('PROXY_ADDRESS'));
         if (!$url) {
             // It's blank? Whut?
             return array("enabled" => false);
         }
         $retarr = array("enabled" => true, "type" => "http", "url" => $url);
         // We don't want any prefix before the proxy host for the 'host' tag.
         if (preg_match("/\\/\\/(.+)/", $url, $out)) {
             $retarr['host'] = $out[1];
         } else {
             $retarr['host'] = $url;
         }
         // Do we have a valid username and password?
         $user = $conf->get('PROXY_USERNAME');
         $pass = $conf->get('PROXY_PASSWORD');
         if ($user && $pass) {
             $retarr['username'] = $user;
             $retarr['password'] = $pass;
         }
         return $retarr;
     } else {
         return array("enabled" => false);
     }
 }
Ejemplo n.º 8
0
function sql($sql, $type = "query", $fetchmode = 'default')
{
    global $db;
    if (empty($db) || !is_object($db) || get_class($db) != "DB") {
        $dbh = FreePBX::Create()->Database();
        $db = new DB($dbh);
    }
    switch ($fetchmode) {
        case 'DB_FETCHMODE_ASSOC':
            //You guessed it, looking for string constants!
        //You guessed it, looking for string constants!
        case DB_FETCHMODE_ASSOC:
            //simulate craptacular function from previous versions
            //that didn't even work correctly! sweet :-/
            //(The integer shouldnt go there)
            if ($type == 'getAssoc') {
                $results = $db->{$type}($sql, true);
            } else {
                $results = $db->{$type}($sql, array(), DB_FETCHMODE_ASSOC);
            }
            break;
        case DB_FETCHMODE_ORDERED:
            $results = $db->{$type}($sql, array(), DB_FETCHMODE_ORDERED);
            break;
        case 'default':
            $results = $db->sql($sql, $type);
            break;
        default:
            throw new Exception("Unknown SQL fetchmode of {$fetchmode}");
            break;
    }
    return $results;
}
Ejemplo n.º 9
0
function certman_devices_configprocess()
{
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extension = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $tech = isset($_POST['tech']) ? $_POST['tech'] : null;
    switch ($action) {
        case 'add':
            $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
        case 'edit':
            if ($_POST['dtls_enable'] == 'yes') {
                $settings = array();
                foreach ($_POST as $key => $value) {
                    if (preg_match('/^dtls_(.*)/', $key, $matches)) {
                        $settings[$matches[1]] = $value;
                    }
                }
                FreePBX::Certman()->addDTLSOptions($extension, $settings);
            } else {
                FreePBX::Certman()->removeDTLSOptions($extension);
            }
            break;
        case 'del':
            FreePBX::Certman()->removeDTLSOptions($extension);
            break;
    }
}
Ejemplo n.º 10
0
 public static function setUpBeforeClass()
 {
     global $amp_conf, $db;
     include "/etc/freepbx.conf";
     include __DIR__ . '/../classes/DiskUsage.class.php';
     self::$f = FreePBX::create();
     self::$d = new DiskUsage();
 }
Ejemplo n.º 11
0
 protected function configure()
 {
     $this->setName('motd')->setDescription(_('Prints MOTD'))->setDefinition(array(new InputArgument('args', InputArgument::IS_ARRAY, null, null)));
     //banners should be base64 encoded, Why? Because php likes to randomly shift multiline variables. Also makes it all look super cryptic :-/
     $this->banner = "IF9fX19fICAgICAgICAgICAgICBfX19fICBfX19fX18gIF9fDQp8ICBfX198IF9fIF9fXyAgX19ffCAgXyBcfCBfXyApIFwvIC8NCnwgfF8gfCAnX18vIF8gXC8gXyBcIHxfKSB8ICBfIFxcICAvIA0KfCAgX3x8IHwgfCAgX18vICBfXy8gIF9fL3wgfF8pIC8gIFwgDQp8X3wgIHxffCAgXF9fX3xcX19ffF98ICAgfF9fX18vXy9cX1wgICAgIA==";
     $this->supporturl = 'http://www.freepbx.org/support-and-professional-services';
     $this->FreePBX = \FreePBX::Create();
 }
Ejemplo n.º 12
0
 public static function setUpBeforeClass()
 {
     include 'setuptests.php';
     self::$p = FreePBX::PKCS();
     `rm -rf /tmp/ssltest`;
     `mkdir /tmp/ssltest`;
     self::$p->setKeysLocation("/tmp/ssltest");
 }
Ejemplo n.º 13
0
 public function chownFreePBX()
 {
     $webroot = \FreePBX::Config()->get('AMPWEBROOT');
     $modulebindir = $webroot . '/admin/modules/callback/bin/';
     $files = array();
     $files[] = array('type' => 'file', 'path' => $modulebindir . 'callback', 'perms' => 0755);
     return $files;
 }
Ejemplo n.º 14
0
 public static function setUpBeforeClass()
 {
     global $amp_conf, $db;
     include "/etc/freepbx.conf";
     include __DIR__ . '/../classes/AsteriskInfo.class.php';
     self::$f = FreePBX::create();
     self::$a = new AsteriskInfo2();
 }
Ejemplo n.º 15
0
 public function ajaxHandler()
 {
     $request = $_REQUEST;
     if (!empty($_REQUEST['oldval']) && $_REQUEST['command'] == 'add') {
         $_REQUEST['command'] = 'edit';
     }
     switch ($_REQUEST['command']) {
         case 'add':
             $this->numberAdd($request);
             return array('status' => true);
             break;
         case 'edit':
             $this->numberDel($request['oldval']);
             $this->numberAdd($request);
             return array('status' => true);
             break;
         case 'bulkdelete':
             $numbers = isset($_REQUEST['numbers']) ? $_REQUEST['numbers'] : array();
             $numbers = json_decode($numbers, true);
             foreach ($numbers as $number) {
                 $this->numberDel($number);
             }
             return array('status' => 'true', 'message' => _("Numbers Deleted"));
             break;
         case 'del':
             $ret = $this->numberDel($request['number']);
             return array('status' => $ret);
             break;
         case 'calllog':
             $number = $request['number'];
             $sql = 'SELECT calldate FROM asteriskcdrdb.cdr WHERE src = ?';
             $stmt = \FreePBX::Database()->prepare($sql);
             $stmt->execute(array($number));
             $ret = $stmt->fetchAll(\PDO::FETCH_ASSOC);
             return $ret;
             break;
         case 'getJSON':
             switch ($request['jdata']) {
                 case 'grid':
                     $ret = array();
                     $blacklist = $this->getBlacklist();
                     foreach ($blacklist as $item) {
                         $number = $item['number'];
                         $description = $item['description'];
                         if ($number == 'dest' || $number == 'blocked') {
                             continue;
                         } else {
                             $ret[] = array('number' => $number, 'description' => $description);
                         }
                     }
                     return $ret;
                     break;
             }
             break;
     }
 }
Ejemplo n.º 16
0
 public static function setUpBeforeClass()
 {
     global $amp_conf, $db;
     include "/etc/freepbx.conf";
     if (!class_exists('MemInfo')) {
         include __DIR__ . '/../classes/MemInfo.class.php';
     }
     self::$f = FreePBX::create();
     self::$m = new MemInfo();
 }
Ejemplo n.º 17
0
 public static function setUpBeforeClass()
 {
     include 'setuptests.php';
     self::$f = FreePBX::create();
     $_REQUEST['test1'] = 1;
     $_REQUEST['test2'] = "two";
     $_REQUEST['test3'] = "3";
     $_REQUEST['test4'] = "'<>\"";
     $_REQUEST['radio'] = "radio=poot";
 }
Ejemplo n.º 18
0
 public function __construct()
 {
     // Is firewall enabled and active?
     try {
         $this->fwobj = \FreePBX::Firewall();
         $this->fw = $this->fwobj->isEnabled();
     } catch (\Exception $e) {
         // Firewall not active, or not enabled, don't do anything
         return;
     }
 }
 public static function runHook($hook)
 {
     if (strpos($hook, "builtin_") === 0) {
         // It's a builtin module.
         return FreePBX::create()->Dashboard->doBuiltInHook($hook);
     }
     if (strpos($hook, "freepbx_ha_") === 0) {
         return "This is not the hook you want";
     }
     throw new Exception("Extra hooks not done yet");
 }
Ejemplo n.º 20
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $output->write(_("Connecting to the Database..."));
     try {
         $db = \FreePBX::Database();
     } catch (\Exception $e) {
         $output->writeln("<error>" . _("Unable to connect to database!") . "</error>");
         return;
     }
     $output->writeln(_("Connected"));
     $driver = $db->getAttribute(\PDO::ATTR_DRIVER_NAME);
     $bundles = array();
     while (true) {
         $question = new Question($driver . '>', '');
         $question->setAutocompleterValues($bundles);
         $answer = $helper->ask($input, $output, $question);
         if (preg_match("/^exit/i", $answer)) {
             exit;
         }
         $bundles[] = $answer;
         try {
             $time_start = microtime(true);
             $ob = $db->query($answer);
             $time_end = microtime(true);
         } catch (\Exception $e) {
             $output->writeln("<error>" . $e->getMessage() . "</error>");
             continue;
         }
         if (!$ob) {
             $output->writeln("<error>" . $db->errorInfo() . "</error>");
             continue;
         }
         //if we get rows back from a query fetch them
         if ($ob->rowCount()) {
             $gotRows = $ob->fetchAll(\PDO::FETCH_ASSOC);
         } else {
             $gotRows = array();
         }
         if (!empty($gotRows)) {
             $rows = array();
             foreach ($gotRows as $row) {
                 $rows[] = array_values($row);
             }
             $table = new Table($output);
             $table->setHeaders(array_keys($gotRows[0]))->setRows($rows);
             $table->render();
             $output->writeln(sprintf(_("%s rows in set (%s sec)"), $ob->rowCount(), round($time_end - $time_start, 2)));
         } else {
             $output->writeln(_("Successfully executed"));
         }
     }
 }
Ejemplo n.º 21
0
 /** This is our pseudo-__construct, called whenever our public functions are called. */
 private static function checkDatabase()
 {
     // Have we already run?
     if (self::$checked != false) {
         return;
     }
     if (!isset(self::$db)) {
         self::$db = \FreePBX::create()->Database;
     }
     // Definitions
     $create = "CREATE TABLE IF NOT EXISTS " . self::$dbname . " ( `module` CHAR(64) NOT NULL, `key` CHAR(255) NOT NULL, `val` LONGBLOB, `type` CHAR(16) DEFAULT NULL, `id` CHAR(255) DEFAULT NULL)";
     // These are limited to 50 chars as prefixes are limited to 255 chars in total (or 1000 in later versions
     // of mysql), and UTF can cause that to overflow. 50 is plenty.
     $index['index1'] = "ALTER TABLE " . self::$dbname . " ADD INDEX index1 (`key`(50))";
     $index['index3'] = "ALTER TABLE " . self::$dbname . " ADD UNIQUE INDEX index3 (`module`, `key`(50), `id`(50))";
     $index['index5'] = "ALTER TABLE " . self::$dbname . " ADD INDEX index5 (`module`, `id`(50))";
     // Check to make sure our Key/Value table exists.
     try {
         $res = self::$db->query("SELECT * FROM `" . self::$dbname . "` LIMIT 1");
     } catch (\Exception $e) {
         if ($e->getCode() == "42S02") {
             // Table does not exist
             self::$db->query($create);
         } else {
             self::checkException($e);
         }
     }
     // Check for indexes.
     // TODO: This only works on MySQL
     $res = self::$db->query("SHOW INDEX FROM `" . self::$dbname . "`");
     $out = $res->fetchAll(\PDO::FETCH_COLUMN | \PDO::FETCH_GROUP, 2);
     foreach ($out as $i => $null) {
         // Do we not know about this index? (Are we upgrading?)
         if (!isset($index[$i])) {
             self::$db->query("ALTER TABLE " . self::$dbname . " DROP INDEX {$i}");
         }
     }
     // Now lets make sure all our indexes exist.
     foreach ($index as $i => $sql) {
         if (!isset($out[$i])) {
             self::$db->query($sql);
         }
     }
     // Add our stored procedures
     self::$dbGet = self::$db->prepare("SELECT `val`, `type` FROM `" . self::$dbname . "` WHERE `module` = :mod AND `key` = :key AND `id` = :id");
     self::$dbGetAll = self::$db->prepare("SELECT `key` FROM `" . self::$dbname . "` WHERE `module` = :mod AND `id` = :id ORDER BY `key`");
     self::$dbDel = self::$db->prepare("DELETE FROM `" . self::$dbname . "` WHERE `module` = :mod AND `key` = :key  AND `id` = :id");
     self::$dbAdd = self::$db->prepare("INSERT INTO `" . self::$dbname . "` ( `module`, `key`, `val`, `type`, `id` ) VALUES ( :mod, :key, :val, :type, :id )");
     self::$dbDelId = self::$db->prepare("DELETE FROM `" . self::$dbname . "` WHERE `module` = :mod AND `id` = :id");
     self::$dbDelMod = self::$db->prepare("DELETE FROM `" . self::$dbname . "` WHERE `module` = :mod");
     // Now this has run, everything IS JUST FINE.
     self::$checked = true;
 }
Ejemplo n.º 22
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $FreePBX = \FreePBX::Create();
     $args = $input->getArgument('args');
     session_id($args[0]);
     session_start();
     $output->writeln(sprintf(_('Unlocking: %s'), $args[0]));
     if (!isset($_SESSION["AMP_user"])) {
         $_SESSION["AMP_user"] = new \ampuser('fwconsole');
         $_SESSION["AMP_user"]->setAdmin();
         $output->writeln(_('Session Should be unlocked now'));
     }
 }
Ejemplo n.º 23
0
 public function __construct($freepbx = null)
 {
     $this->FreePBX = $freepbx;
     $this->db = $freepbx->Database;
     $this->brand = \FreePBX::Config()->get("DASHBOARD_FREEPBX_BRAND");
     if (!interface_exists('FreePBX\\modules\\Userman\\Auth\\Base')) {
         include __DIR__ . "/functions.inc/auth/Base.php";
     }
     if (!class_exists('FreePBX\\modules\\Userman\\Auth\\Auth')) {
         include __DIR__ . "/functions.inc/auth/Auth.php";
     }
     $this->switchAuth($this->getConfig('auth'));
 }
Ejemplo n.º 24
0
function contactmanager_getdestinfo($dest)
{
    if (substr(trim($dest), 0, 19) == 'ext-contactmanager,') {
        $exten = explode(',', $dest);
        $exten = $exten[1];
        $cm = \FreePBX::Contactmanager();
        $entries = $cm->getContactsByUserID(-1);
        $destinations = array();
        foreach ($entries as $entry) {
            $name = !empty($entry['displayname']) ? $entry['displayname'] : $entry['fname'] . " " . $entry['lname'];
            if (!empty($entry['numbers'])) {
                foreach ($entry['numbers'] as $type => $number) {
                    if ($number == $exten) {
                        switch ($entry['type']) {
                            case "internal":
                            case "external":
                                return array('description' => sprintf(_("Contact Manager: %s"), $name . "(" . $type . ")"), 'edit_url' => 'config.php?display=contactmanager&action=showentry&group=' . urlencode($entry['groupid']) . '&entry=' . urlencode($entry['uid']));
                                break;
                            case "userman":
                                return array('description' => sprintf(_("Contact Manager: %s"), $name . "(" . $type . ")"), 'edit_url' => 'display=userman&action=showuser&user='******'id']));
                                break;
                        }
                        break;
                    }
                }
            }
        }
        return array();
    } else {
        return false;
    }
    /*
    	global $active_modules;
    
    	if (substr(trim($dest),0,14) == 'ext-miscdests,') {
    		$exten = explode(',',$dest);
    		$exten = $exten[1];
    		$thisexten = miscdests_get($exten);
    		if (empty($thisexten)) {
    			return array();
    		} else {
    			//$type = isset($active_modules['announcement']['type'])?$active_modules['announcement']['type']:'setup';
    			return array('description' => sprintf(_("Misc Destination: %s"),$thisexten['description']),
    			'edit_url' => 'config.php?display=miscdests&id='.urlencode($exten),
    		);
    	}
    } else {
    	return false;
    }
    */
}
Ejemplo n.º 25
0
    public static function setUpBeforeClass()
    {
        include "setuptests.php";
        self::$f = FreePBX::create();
        self::$config_file = basename(tempnam(sys_get_temp_dir(), "utest"));
        self::$config_file2 = basename(tempnam(sys_get_temp_dir(), "utest"));
        self::$config_dir = sys_get_temp_dir() . "/";
        $config = <<<'EOF'
; Config file parser test
;-- Multi-line comment
in the header --;firstvalue=is not in a section!

[template-section](!)
foobar=barfoo

[first-section]
foo=bar
bar=[bracketed value]
one => two
hey =this is a big long\r\n
hey+=	multi-line value\r\n
hey +=that goes on and on

;-- block comment on one line! --;
[second_section](template-section)
setting=>value ;comment at the end
setting2=>value with a \; semicolon
setting3	= value;-- multiline comment starts here
and continues
and ends here--;setting4 =>value
;--a comment

[bad_section]
--;;another =>comment? i hope so
	setting5     => value
setting=value 2
#include foo.conf

[first-section](+)
baz=bix

[voicemail]
9876 => 1234,Typical voicemail,,,attach=no|saycid=no|envelope=no|delete=no
5432=>1234,Typical voicemail,,,attach=no|saycid=no|envelope=no|delete=no

EOF;
        file_put_contents(self::$config_dir . self::$config_file, $config);
        $config = str_replace("setting=value 2", "[invalid section]", $config);
        file_put_contents(self::$config_dir . self::$config_file2, $config);
    }
Ejemplo n.º 26
0
 public function getSections($order)
 {
     if (!defined('DASHBOARD_FREEPBX_BRAND')) {
         if (!empty($_SESSION['DASHBOARD_FREEPBX_BRAND'])) {
             define('DASHBOARD_FREEPBX_BRAND', $_SESSION['DASHBOARD_FREEPBX_BRAND']);
         } else {
             define('DASHBOARD_FREEPBX_BRAND', \FreePBX::Config()->get("DASHBOARD_FREEPBX_BRAND"));
         }
     } else {
         $_SESSION['DASHBOARD_FREEPBX_BRAND'] = DASHBOARD_FREEPBX_BRAND;
     }
     $brand = DASHBOARD_FREEPBX_BRAND;
     return array(array("title" => "{$brand} " . _("Statistics"), "group" => _("Statistics"), "width" => "550px", "order" => isset($order['statistics']) ? $order['statistics'] : '300', "section" => "statistics"));
 }
Ejemplo n.º 27
0
 public static function endpointsAutoload($class)
 {
     // If for some reason we get here and the class is already loaded, return
     if (class_exists($class, FALSE)) {
         return TRUE;
     }
     // Try to include the class
     $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
     $file = FreePBX::Endpointman()->PHONE_MODULES_PATH . $file;
     if (is_file($file)) {
         require $file;
         return TRUE;
     }
     return FALSE;
 }
Ejemplo n.º 28
0
function soundlang_hookGet_config($engine)
{
    global $core_conf;
    switch ($engine) {
        case "asterisk":
            if (isset($core_conf) && is_a($core_conf, "core_conf")) {
                $language = FreePBX::Soundlang()->getLanguage();
                if ($language != "") {
                    $core_conf->addSipGeneral('language', $language);
                    $core_conf->addIaxGeneral('language', $language);
                }
            }
            break;
    }
}
Ejemplo n.º 29
0
 public function __construct($freepbx = null)
 {
     if ($freepbx == null) {
         throw new Exception("Not given a FreePBX Object");
     }
     $this->FreePBX = $freepbx;
     $this->db = $freepbx->Database;
     $this->mohdir = $freepbx->Config->get('MOHDIR');
     $this->varlibdir = $freepbx->Config->get('ASTVARLIBDIR');
     $this->mohpath = $this->varlibdir . '/' . $this->mohdir;
     $this->config = $this->loadMoHConfig();
     $this->tmp = \FreePBX::Config()->get("ASTSPOOLDIR") . "/tmp";
     if (!file_exists($this->tmp)) {
         mkdir($this->tmp, 0777, true);
     }
 }
Ejemplo n.º 30
0
 public function __construct()
 {
     $this->conf = \FreePBX::create()->ConfigFile("modules.conf");
     $this->ProcessedConfig =& $this->conf->config->ProcessedConfig;
     // Now, is it empty? We want some defaults..
     if (sizeof($this->ProcessedConfig) == 0) {
         $this->conf->addEntry("modules", "autoload=yes");
         $this->conf->addEntry("modules", "preload=pbx_config.so");
         $this->conf->addEntry("modules", "preload=chan_local.so");
         $this->conf->addEntry("modules", "preload=res_mwi_blf.so");
         $this->conf->addEntry("modules", "noload=chan_also.so");
         $this->conf->addEntry("modules", "noload=chan_oss.so");
         $this->conf->addEntry("modules", "noload=app_directory_odbcstorage.so");
         $this->conf->addEntry("modules", "noload=app_voicemail_odbcstorage.so");
     }
 }