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; }
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(); }
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(); }
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"; }
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(); }
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"); }
/** 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; }
public static function setUpBeforeClass() { include 'setuptests.php'; self::$f = FreePBX::create(); // Ensure that our /etc/freepbx.secure directory exists if (!is_dir("/etc/freepbx.secure")) { if (posix_geteuid() !== 0) { throw new \Exception("Can't create /etc/freepbx.secure, not runnign tests as root"); } else { mkdir("/etc/freepbx.secure"); } } chmod("/etc/freepbx.secure", 0644); }
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); }
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"); } }
protected function execute(InputInterface $input, OutputInterface $output) { $args = $input->getArgument('args'); $command = isset($args[0]) ? $args[0] : ''; $soundlang = \FreePBX::create()->Userman; switch ($command) { case "auth": break; case "migrate": break; default: $output->writeln("<error>The command provided is not valid.</error>"); $output->writeln("Avalible commands are:"); $output->writeln("<info>auth <user> <password></info> - Authenticate user and get information about user back"); $output->writeln("<info>migrate<id></info> - Migrate/Update voicemail users into User Manager"); exit(4); break; } }
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->detect = new \Mobile_Detect(); // Ensure the local object is available self::$obj = $this; }
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", "preload=func_db.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"); } //https://issues.asterisk.org/jira/browse/ASTERISK-25966 if (empty($this->ProcessedConfig['modules']['preload']) || is_array($this->ProcessedConfig['modules']['preload']) && !in_array("func_db.so", $this->ProcessedConfig['modules']['preload']) || is_string($this->ProcessedConfig['modules']['preload']) && $this->ProcessedConfig['modules']['preload'] != "func_db.so") { $this->conf->addEntry("modules", "preload=func_db.so"); } }
protected function execute(InputInterface $input, OutputInterface $output) { $args = $input->getArgument('args'); $command = isset($args[0]) ? $args[0] : ''; $userman = \FreePBX::create()->Userman; switch ($command) { case "sync": $auth = $userman->getAuthObject(); if (method_exists($auth, "sync")) { $output->write("Starting Sync..."); $auth->sync($output); $output->writeln("Finished"); } else { $output->writeln("<comment>The active authentication driver does not support syncing.</comment>"); } break; default: $output->writeln("<error>The command provided is not valid.</error>"); $output->writeln("Avalible commands are:"); $output->writeln("<info>sync</info> - Syncronize User/Group information for an authentication engine"); exit(4); break; } }
public static function setUpBeforeClass() { include 'setuptests.php'; self::$f = FreePBX::create(); }
public static function setUpBeforeClass() { global $amp_conf, $db; include '/etc/freepbx.conf'; self::$d = FreePBX::create()->Dashboard; }
/** * Construct Module Configuration Pages * This is used to setup and display module configuration pages * in User Manager * @param {array} $user The user array */ function constructModuleConfigPages($user) { //module with no module folder $html = ''; $modulef =& module_functions::create(); $modules = $modulef->getinfo(false); $path = $this->FreePBX->Config->get_conf_setting('AMPWEBROOT'); $location = $path . "/admin/modules"; foreach ($modules as $module) { if (isset($module['rawname']) && $module['status'] == MODULE_STATUS_ENABLED) { $rawname = trim($module['rawname']); $mod = ucfirst(strtolower($module['rawname'])); if (file_exists($location . "/" . $rawname . "/" . $mod . ".class.php")) { if (method_exists(FreePBX::create()->{$mod}, 'getUCPAdminDisplay')) { \modgettext::push_textdomain(strtolower($mod)); $data = FreePBX::create()->{$mod}->getUCPAdminDisplay($user); \modgettext::pop_textdomain(); if (isset($data['content'])) { $html[] = array('description' => $data['description'], 'content' => $data['content']); } elseif (isset($data[0]['content'])) { foreach ($data as $item) { $html[] = array('description' => $item['description'], 'content' => $item['content']); } } } } } } return $html; }
case 'sip': case 'iax': case 'custom': default: $label = substr($tresult['name'], 0, 15); if (trim($label) == '') { $label = substr($tresult['channelid'], 0, 15); } $label .= " (" . $tresult['tech'] . ")"; break; } $trunks[] = array('label' => $label, 'background' => $background, 'tresult' => $tresult); } $displayvars = array('extdisplay' => $extdisplay, 'display' => $display, 'trunks' => $trunks, 'trunknum' => $trunknum); show_view(dirname(__FILE__) . '/views/trunks/header.php', $displayvars); $sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER'); if (!$tech && !$extdisplay) { $trunk_types = \FreePBX::Core()->listTrunkTypes(); $displayvars['trunk_types'] = $trunk_types; show_view(dirname(__FILE__) . '/views/trunks/main.php', $displayvars); } else { if ($extdisplay) { $trunk_details = core_trunks_getDetails($trunknum); $tech = htmlentities($trunk_details['tech'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $outcid = htmlentities($trunk_details['outcid'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $maxchans = htmlentities($trunk_details['maxchans'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $dialoutprefix = htmlentities($trunk_details['dialoutprefix'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $keepcid = htmlentities($trunk_details['keepcid'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $failtrunk = htmlentities($trunk_details['failscript'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $failtrunk_enable = $failtrunk == "" ? '' : 'CHECKED'; $disabletrunk = htmlentities($trunk_details['disabled'], ENT_COMPAT | ENT_HTML401, "UTF-8");
public function ajaxHandler() { if (!class_exists('DashboardHooks')) { include 'classes/DashboardHooks.class.php'; } switch ($_REQUEST['command']) { case "deletemessage": \FreePBX::create()->Notifications->safe_delete($_REQUEST['raw'], $_REQUEST['id']); return array("status" => true); break; case "resetmessage": \FreePBX::create()->Notifications->reset($_REQUEST['raw'], $_REQUEST['id']); return array("status" => true); break; case "saveorder": $this->setConfig('visualorder', $_REQUEST['order']); return array("status" => true); break; case "getcontent": if (file_exists(__DIR__ . '/sections/' . $_REQUEST['rawname'] . '.class.php')) { include __DIR__ . '/sections/' . $_REQUEST['rawname'] . '.class.php'; $class = '\\FreePBX\\modules\\Dashboard\\Sections\\' . $_REQUEST['rawname']; $class = new $class(); return array("status" => true, "content" => $class->getContent($_REQUEST['section'])); } else { return array("status" => false, "message" => "Missing Class Object!"); } break; case "gethooks": if (!$this->getConfig('allhooks')) { $this->doDialplanHook($foo = null, null, null); // Avoid warnings. } // Remove next line to enable caching. // $this->doDialplanHook($foo = null, null, null); // Avoid warnings. $config = $this->getConfig('allhooks'); $order = $this->getConfig('visualorder'); if (!empty($order)) { foreach ($config as &$page) { $entries = array(); foreach ($page['entries'] as $k => $e) { $o = isset($order[$e['section']]) ? $order[$e['section']] : $k; $entries[$o] = $e; } ksort($entries); $page['entries'] = $entries; } } return $config; break; case "sysstat": if (!class_exists('Statistics')) { include 'classes/Statistics.class.php'; } $s = new Statistics(); return $s->getStats(); break; default: return DashboardHooks::runHook($_REQUEST['command']); break; } }
<?php $mods = FreePBX::create()->ModulesConf(); $pc = $mods->ProcessedConfig['modules']; $loadrows = $noloadrows = ''; $preloadrows = ''; if (isset($pc['noload'])) { $noloads = is_array($pc['noload']) ? $pc['noload'] : array($pc['noload']); foreach ($noloads as $mod) { $noloadrows .= <<<HERE <tr id = "row{$mod}"> <td>{$mod}</td> <td> \t<a href="#" id="del{$mod}" data-mod="{$mod}"> \t<i class="fa fa-trash-o"></i></a></td> </tr> HERE; } } if (isset($pc['load'])) { $loads = is_array($pc['load']) ? $pc['load'] : array($pc['load']); foreach ($loads as $mod) { $loadrows .= <<<HERE <tr id = "row{$mod}"> <td>{$mod}</td> <td> \t<a href="#" id="del{$mod}" data-mod="{$mod}"> \t<i class="fa fa-trash-o"></i></a></td> </tr> HERE; }
$old = sql($sql, 'getAll', DB_FETCHMODE_ASSOC); foreach ($old as $user) { $assigned = json_decode($user['settings'], true); $ret = $userman->addUser($user['username'], $user['password'], 'none', 'User Migrated from UCP', array(), false); if ($ret['status']) { $userman->setAssignedDevices($ret['id'], $assigned['modules']['Voicemail']['assigned']); $userman->setModuleSettingByID($ret['id'], 'ucp|Voicemail', 'assigned', $assigned['modules']['Voicemail']['assigned']); } } $sql = 'DROP TABLE IF EXISTS ucp_users'; $result = $db->query($sql); } switch (true) { case FreePBX::Modules()->checkStatus('ucp', MODULE_STATUS_NOTINSTALLED): //ok so auto enable UCP for all users $ucp = FreePBX::create()->Ucp; $ucp->enableAllUsers(); break; } // VIEW_UCP_FOOTER_CONTENT $set['value'] = 'views/dashfootercontent.php'; $set['defaultval'] =& $set['value']; $set['readonly'] = 1; $set['hidden'] = 1; $set['level'] = 1; $set['sortorder'] = 355; $set['module'] = 'ucp'; //This will help delete the settings when module is uninstalled $set['category'] = 'Styling and Logos'; $set['emptyok'] = 0; $set['name'] = 'View: UCP dashfootercontent.php';
private function delNotification() { // Triggered from above. $id = $_REQUEST['id']; $mod = $_REQUEST['mod']; return FreePBX::create()->Notifications->safe_delete($mod, $id); }
if (!$amp_conf["ASTMANAGERPROXYPORT"] || !($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) { // attempt to connect directly to asterisk, if no proxy or if proxy failed if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) { // couldn't connect at all unset($astman); freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed"); } else { $bootstrap_settings['astman_connected'] = true; } } } else { $bootstrap_settings['astman_connected'] = true; } //Because BMO was moved upward we have to inject this lower if (isset($astman)) { FreePBX::create()->astman = $astman; } //include gui functions + auth if nesesarry // If set to freepbx_auth but we are in a cli mode, then don't bother authenticating either way. // TODO: is it ever possible through an apache or httplite configuration to run a web launched php script // as 'cli' ? Also, from a security perspective, should we just require this always be set to false // if we want to bypass authentication and not try to be automatic about it? // if (!$bootstrap_settings['freepbx_auth'] || php_sapi_name() == 'cli') { if (!defined('FREEPBX_IS_AUTH')) { define('FREEPBX_IS_AUTH', 'TRUE'); } } else { require $dirname . '/libraries/gui_auth.php'; frameworkPasswordCheck(); }
/** Run the module install/uninstall scripts * @param string The name of the module * @param string The action to perform, either 'install' or 'uninstall' * @param array The modulexml array * @return boolean If the action was succesful */ function _runscripts($modulename, $type, $modulexml = false) { global $amp_conf; $db_engine = $amp_conf["AMPDBENGINE"]; $moduledir = $amp_conf["AMPWEBROOT"] . "/admin/modules/" . $modulename; if (!is_dir($moduledir)) { return false; } switch ($type) { case 'install': // install sql files $sqlfilename = "install.sql"; $rc = true; if (is_file($moduledir . '/' . $sqlfilename)) { $rc = execSQL($moduledir . '/' . $sqlfilename); } //include additional files developer requested if ($modulexml !== false) { $this->_runscripts_include($modulexml, $type); } // If it's a BMO module, manually include the file. $mn = ucfirst($modulename); $bmofile = "{$moduledir}/{$mn}.class.php"; if (file_exists($bmofile)) { try { FreePBX::create()->injectClass($mn, $bmofile); $o = FreePBX::create()->{$mn}->install(); if ($o === false) { return false; } } catch (Exception $e) { dbug("Error Returned was: " . $e->getMessage()); return false; } } // then run .php scripts return $this->_doinclude($moduledir . '/install.php', $modulename) && $rc; break; case 'uninstall': //include additional files developer requested if ($modulexml !== false) { $this->_runscripts_include($modulexml, $type); } // run uninstall .php scripts first $rc = $this->_doinclude($moduledir . '/uninstall.php', $modulename); $sqlfilename = "uninstall.sql"; // If it's a BMO module, run uninstall. $mn = ucfirst($modulename); $bmofile = "{$moduledir}/{$mn}.class.php"; if (file_exists($bmofile)) { try { $o = FreePBX::create()->{$mn}->uninstall(); if ($o === false) { return false; } } catch (Exception $e) { dbug("Error Returned was: " . $e->getMessage()); return false; } } // then uninstall sql files if (is_file($moduledir . '/' . $sqlfilename)) { return $rc && execSQL($moduledir . '/' . $sqlfilename); } else { return $rc; } break; default: return false; } return true; }
/** * Check Credentials against username with a passworded sha * @param {string} $username The username * @param {string} $password_sha1 The sha */ public function checkCredentials($username, $password) { $config = $this->userman->getConfig("authVoicemailSettings"); try { $d = $this->FreePBX->Voicemail->getVoicemail(); } catch (\Exception $e) { $path = $this->FreePBX->Config->get("AMPWEBROOT"); $moduledir = $path . "/admin/modules/voicemail"; $modulename = "voicemail"; $mn = ucfirst($modulename); $bmofile = "{$moduledir}/{$mn}.class.php"; if (file_exists($bmofile)) { \FreePBX::create()->injectClass($mn, $bmofile); } $d = $this->FreePBX->Voicemail->getVoicemail(); } if (!empty($d[$config['context']][$username])) { if ($password == $d[$config['context']][$username]['pwd']) { //Injecting breaks how FreePBX protects itself //To fix this just force a refresh of modules $this->FreePBX->Modules->active_modules = array(); $user = $this->getUserByUsername($username); return !empty($user['id']) ? $user['id'] : false; } } return false; }
" id="MENU_BRAND_IMAGE_TANGO_LEFT" data-BRAND_IMAGE_FREEPBX_LINK_LEFT="<?php echo $amp_conf['BRAND_IMAGE_FREEPBX_LINK_LEFT']; ?> " /> </a> </div> <div class="collapse navbar-collapse" id="fpbx-menu-collapse"> <ul class="nav navbar-nav navbar-left"> <?php include_once __DIR__ . '/menu_items.php'; ?> </ul> </div> <ul class="stuck-right"> <?php if (FreePBX::create()->astman->connected()) { ?> <li><a id="button_reload" class="btn btn-danger nav-button reload-btn"><?php echo _('Apply Config'); ?> </a></li> <?php } else { ?> <li><a class="btn btn-danger nav-button reload-btn"><?php echo _('Can Not Connect to Asterisk'); ?> </a></li> <?php } ?>
case "misdn": if (function_exists('misdn_groups_ports')) { show_view(dirname(__FILE__) . '/views/trunks/misdn.php', $displayvars); } break; //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- case "custom": show_view(dirname(__FILE__) . '/views/trunks/custom.php', $displayvars); break; case "dundi": show_view(dirname(__FILE__) . '/views/trunks/dundi.php', $displayvars); break; case "pjsip": // displayvars is passed by reference, and may or may not be updated. FreePBX::create()->PJSip->getDisplayVars($extdisplay, $displayvars); show_view(dirname(__FILE__) . '/views/trunks/pjsip.php', $displayvars); break; case "iax": case "iax2": case "sip": $displayvars['peerdetails'] = $peerdetails; $displayvars['usercontext'] = $usercontext; $displayvars['userconfig'] = $userconfig; $displayvars['register'] = $register; $displayvars['peerdetails'] = $peerdetails; show_view(dirname(__FILE__) . '/views/trunks/sip.php', $displayvars); break; default: break; }
public function listTrunkTypes() { $sipdriver = \FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER'); $default_trunk_types = array("DAHDI" => 'DAHDi', "IAX2" => 'IAX2', "ENUM" => 'ENUM', "DUNDI" => 'DUNDi', "CUSTOM" => 'Custom'); $sip = $sipdriver == 'both' || $sipdriver == 'chan_sip' ? array("SIP" => sprintf(_('SIP (%s)'), 'chan_sip')) : array(); $pjsip = $sipdriver == 'both' || $sipdriver == 'chan_pjsip' ? array("PJSIP" => sprintf(_('SIP (%s)'), 'chan_pjsip')) : array(); $trunk_types = $pjsip + $sip + $default_trunk_types; // Added to enable the unsupported misdn module if (function_exists('misdn_ports_list_trunks') && count(misdn_ports_list_trunks())) { $trunk_types['MISDN'] = 'mISDN'; } return $trunk_types; }
public function getGraphDataAst($period) { // Grab our memory info... $si = FreePBX::create()->Dashboard->getSysInfoPeriod($period); $retarr['template'] = 'astchart'; $count = 0; $trunkoffline = false; foreach ($si as $key => $val) { if (!isset($val['ast.connections.users_online'])) { $retarr['values']['uonline'][$count] = null; $retarr['values']['uoffline'][$count] = null; $retarr['values']['tonline'][$count] = null; $retarr['values']['toffline'][$count] = null; $retarr['values']['channels'][$count] = null; } else { $retarr['values']['uonline'][$count] = (int) $val['ast.connections.users_online']; $retarr['tooltips']['uonline'][$count] = $val['ast.connections.users_online'] . " users online"; $retarr['values']['uoffline'][$count] = (int) $val['ast.connections.users_offline']; $retarr['tooltips']['uoffline'][$count] = $val['ast.connections.users_offline'] . " users offline"; $retarr['values']['tonline'][$count] = (int) $val['ast.connections.trunks_online']; $retarr['tooltips']['tonline'][$count] = $val['ast.connections.trunks_online'] . " trunks online"; if ($val['ast.connections.trunks_offline'] != 0) { if (!$trunkoffline) { $trunkoffline = true; if ($count > 1) { $retarr['values']['toffline'][$count - 1] = 0; } } $retarr['values']['toffline'][$count] = (int) $val['ast.connections.trunks_offline']; $retarr['tooltips']['toffline'][$count] = $val['ast.connections.trunks_offline'] . " trunks offline"; } else { // We only want to render a line to zero immediately after it was not zero, so the line // goes back down the bottom of the graph before vanishing. if ($trunkoffline) { $retarr['values']['toffline'][$count] = 0; $trunkoffline = false; } else { // $retarr['values']['toffline'][$count] = null; } } $retarr['values']['channels'][$count] = (int) $val['ast.chan_totals.total_calls']; $retarr['tooltips']['channels'][$count] = $val['ast.chan_totals.total_calls'] . " active calls"; } $count++; } return $retarr; }
/** * Find the file for the object * @param string $objname The Object Name (same as class name, filename) * @param string $hint The location of the Class file * @return bool True if found or throws exception */ private function loadObject($objname, $hint = null) { $objname = str_replace('FreePBX\\modules\\', '', $objname); $class = class_exists($this->moduleNamespace . $objname) ? $this->moduleNamespace . $objname : $objname; // If it already exists, we're fine. if (class_exists($class)) { //do reflection tests for ARI junk, we **dont** want to load ARI $class = new ReflectionClass($class); //this is a stop gap, remove in 13 or 14 when ARI is no longer used if (!$class->hasMethod('navMenu') && !$class->hasMethod('rank')) { return true; } } // This is the file we loaded the class from, for debugging later. $loaded = false; if ($hint) { if (!file_exists($hint)) { throw new Exception(sprintf(_("Attempted to load %s with a hint of %s and it didn't exist"), $objname, $hint)); } else { $try = $hint; } } else { // Does this exist as a default Library inside BMO? $try = __DIR__ . "/{$objname}.class.php"; } if (file_exists($try)) { include $try; $loaded = $try; } else { // It's a module, hopefully. // This is our root to search from $path = $this->Config->get_conf_setting('AMPWEBROOT') . "/admin/modules/"; $active_modules = array_keys(FreePBX::create()->Modules->getActiveModules()); foreach ($active_modules as $module) { // Lets try this one.. //TODO: this needs to look with dirname not from webroot $try = $path . $module . "/{$objname}.class.php"; if (file_exists($try)) { //Now we need to make sure this is not a revoked module! try { $signature = FreePBX::Modules()->getSignature($module); if (empty($signature['status'])) { $revoked = false; } else { $revoked = $signature['status'] & GPG::STATE_REVOKED; } } catch (\Exception $e) { $revoked = false; } //if revoked then dont load! if (!$revoked) { include $try; $loaded = $try; } break; } } } // Right, after all of this we should now have our object ready to create. if (!class_exists($class) && !class_exists($this->moduleNamespace . $objname)) { // Bad things have happened. if (!$loaded) { $sobjname = strtolower($objname); throw new Exception(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"), $objname) . sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) amportal a ma install %s 2) amportal a ma enable %s"), $sobjname, $sobjname)); //die_freepbx(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"),$objname), sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) amportal a ma install %s 2) amportal a ma enable %s"),$sobjname,$sobjname)); } // We loaded a file that claimed to represent that class, but didn't. throw new Exception(sprintf(_("Attempted to load %s but it didn't define the class %s"), $try, $objname)); } return true; }