本文整理汇总了PHP中FreePBX类的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX类的具体用法?PHP FreePBX怎么用?PHP FreePBX使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FreePBX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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;
}
}
示例2: backup__
/**
* 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);
}
示例3: __construct
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;
}
示例4: customappsreg_getdestinfo
/** 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;
}
示例5: getSections
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;
}
示例6: __construct
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/";
}
示例7: getProxySettings
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);
}
}
示例8: sql
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;
}
示例9: certman_devices_configprocess
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;
}
}
示例10: setUpBeforeClass
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();
}
示例11: configure
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();
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
include 'setuptests.php';
self::$p = FreePBX::PKCS();
`rm -rf /tmp/ssltest`;
`mkdir /tmp/ssltest`;
self::$p->setKeysLocation("/tmp/ssltest");
}
示例13: chownFreePBX
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;
}
示例14: setUpBeforeClass
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();
}
示例15: ajaxHandler
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;
}
}