本文整理汇总了PHP中FreePBX::Dashboard方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::Dashboard方法的具体用法?PHP FreePBX::Dashboard怎么用?PHP FreePBX::Dashboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreePBX
的用法示例。
在下文中一共展示了FreePBX::Dashboard方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$db = FreePBX::Database();
$dash = FreePBX::Dashboard();
if (!is_object($db)) {
throw new Exception("DB isn't a Database?");
}
if (!is_object($dash)) {
throw new Exception("Dash isn't an Object?");
}
$this->db = $db;
$this->dash = $dash;
// Generate a temporary 'what's next' array for lookups.
foreach ($this->periods as $p => $i) {
if ($this->last) {
$this->pnext[$this->last] = $p;
$this->last = $p;
} else {
$this->last = $p;
}
}
}
示例2: getFeed
/**
* Get the feed from cache or retrieve it
* @param string $feed The feed URL
* @return object Reader object
*/
private function getFeed($feed)
{
$reader = new Reader();
$d = \FreePBX::Dashboard();
$etag = $d->getConfig($feed, "etag");
$last_modified = $d->getConfig($feed, "last_modified");
try {
$resource = $reader->download($feed, $last_modified, $etag);
if ($resource->isModified()) {
$parser = $reader->getParser($resource->getUrl(), $resource->getContent(), $resource->getEncoding());
$content = $parser->execute();
$etag = $resource->getEtag();
$last_modified = $resource->getLastModified();
$d->setConfig($feed, $content, "content");
$d->setConfig($feed, $etag, "etag");
$d->setConfig($feed, $last_modified, "last_modified");
} else {
$content = $d->getConfig($feed, "content");
}
} catch (\PicoFeed\PicoFeedException $e) {
$content = $d->getConfig($feed, "content");
}
return $content;
}
示例3: getURL
private function getURL($url)
{
// Check to see if we've already grabbed this recently
$d = \FreePBX::Dashboard();
$res = $d->getConfig($url, "Blogs");
// 3 Hours.
$expired = time() - 10800;
// Has this expired, or is it new?
if (!$res || $res['timestamp'] < $expired) {
$contents = file_get_contents($url);
$res['timestamp'] = time();
$res['contents'] = $contents;
$d->setConfig($url, $res, "Blogs");
}
return $res['contents'];
}
示例4: genAlertGlyphicon
private function genAlertGlyphicon($res, $tt = null)
{
return \FreePBX::Dashboard()->genStatusIcon($res, $tt);
}
示例5: array
<?php
// vim: set ai ts=4 sw=4 ft=phtml:
// New Dashboard
// License for all code of this FreePBX module can be found in the license file inside the module directory
// Copyright 2013 Schmooze Com Inc.
//
if (!class_exists('DashboardHooks')) {
include 'classes/DashboardHooks.class.php';
}
$allhooks = DashboardHooks::genHooks(FreePBX::Dashboard()->getConfig('visualorder'));
FreePBX::Dashboard()->setConfig('allhooks', $allhooks);
show_view(__DIR__ . '/views/main.php', array("brand" => FREEPBX::Config()->get('DASHBOARD_FREEPBX_BRAND')));
示例6: get_connections
public function get_connections()
{
// Grab our list of extensions.
$sql = "SELECT `id` FROM `devices` WHERE `tech` <> 'custom'";
$alldevices = FreePBX::create()->Database->query($sql)->fetchAll(PDO::FETCH_COLUMN, 0);
$devices = array_flip($alldevices);
$protocols = array("sip", "iax2", "pjsip");
$vars = array("users_online", "users_offline", "users_total", "trunks_online", "trunks_offline", "trunks_total", "registrations_online", "registrations_offline", "registrations_total");
// Build array to return
foreach ($protocols as $p) {
foreach ($vars as $v) {
$retarr[$p . "_" . $v] = 0;
}
}
// Add Totals
foreach ($vars as $v) {
$retarr[$v] = 0;
}
if (!$this->astman) {
return $retarr;
}
$response = $this->astman->send_request('Command', array('Command' => "sip show peers"));
$astout = explode("\n", $response['data']);
$blacklist = \FreePBX::Dashboard()->extIgnoreList();
foreach ($astout as $line) {
// Previous bug IRT trunks starting or ending with /'s here. Investigate.
$exploded = preg_split('/\\s+/', $line);
if (strpos($exploded[0], '/') === false) {
$name = $exploded[0];
} else {
list($name, $null) = explode('/', $exploded[0]);
}
//prefix blacklist
foreach ($blacklist as $num) {
if (substr($name, 0, $num['length']) == $num['value'] && $name !== $num['value']) {
continue;
}
}
// How to we see if a trunk is down?
if ($exploded[1] == "(Unspecified)" || $exploded[5] == "UNREACHABLE" || $exploded[6] == "UNREACHABLE") {
// This is a device that's down
if (!isset($devices[$name])) {
// It is, actually a TRUNK that's down.
$retarr['sip_trunks_offline']++;
} else {
$retarr['sip_users_offline']++;
}
} elseif (filter_var($exploded[1], FILTER_VALIDATE_IP)) {
// This is a device that's up.
if (!isset($devices[$name])) {
$retarr['sip_trunks_online']++;
} else {
$retarr['sip_users_online']++;
}
}
// else it's not a device.
}
$response = $this->astman->send_request('Command', array('Command' => "sip show registry"));
$astout = explode("\n", $response['data']);
$pos = false;
foreach ($astout as $line) {
if (trim($line) != '') {
if ($pos === false) {
// find the position of "State" in the first line
$pos = strpos($line, "State");
} else {
// subsequent lines, check if it says "Registered" at that position
if (substr($line, $pos, 10) == "Registered") {
$retarr['sip_registrations_online']++;
} elseif (strlen($line) > $pos) {
$retarr['sip_registrations_offline']++;
}
}
}
}
$response = $this->astman->send_request('Command', array('Command' => "iax2 show peers"));
$astout = explode("\n", $response['data']);
foreach ($astout as $line) {
if (preg_match('/^(([a-z0-9\\-_]+)(\\/([a-z0-9\\-_]+))?)\\s+(\\([a-z]+\\)|\\d{1,3}(\\.\\d{1,3}){3})/i', $line, $matches)) {
//matches: [2] = name, [4] = username, [5] = host, [6] = part of ip (if IP)
// have an IP address listed, so its online
$online = !empty($matches[6]);
if (!isset($devices[$matches[2]])) {
// this is a trunk
//TODO match trunk tech as well?
$retarr['iax2_trunks_' . ($online ? 'online' : 'offline')]++;
} else {
$retarr['iax2_users_' . ($online ? 'online' : 'offline')]++;
}
}
}
$response = $this->astman->send_request('Command', array('Command' => "iax2 show registry"));
$astout = explode("\n", $response['data']);
$pos = false;
foreach ($astout as $line) {
if (trim($line) != '') {
if ($pos === false) {
// find the position of "State" in the first line
$pos = strpos($line, "State");
} else {
//.........这里部分代码省略.........
示例7: exit
// Copyright 2013 Schmooze Com Inc.
//
// Dashboard Scheduler.
// Runs every minute.
//
// Start quickly.
$bootstrap_settings['freepbx_auth'] = false;
// Just in case.
$restrict_mods = true;
// Takes startup from 0.2 seconds to 0.07 seconds.
include '/etc/freepbx.conf';
$astrundir = \FreePBX::Config()->get('ASTRUNDIR');
if (!is_dir($astrundir) || !is_writable($astrundir)) {
echo "Asterisk Run Dir [" . $astrundir . "] is missing or not writable! Is Asterisk running?\n";
exit(1);
}
$lockfile = $astrundir . "/scheduler.lock";
// Sleep to fix crazy issues with large VM hosting providers
sleep(mt_rand(1, 30));
// Create a lock to make sure no more than one instance of this
// program can be running on a machine at a time
$fh = fopen($lockfile, "a");
if (!$fh || !flock($fh, LOCK_EX | LOCK_NB)) {
// Unable to lock, we're already running.
exit;
}
// Run the trigger
\FreePBX::Dashboard()->runTrigger();
// remove lockfile, and then close handle to release kernel lock
unlink($lockfile);
fclose($fh);