예제 #1
0
 public function globalSearch()
 {
     $modules = \FreePBX::Modules()->getActiveModules();
     // If I'm in device and user mode, don't display Extensions, and vice-versa.
     $mode = \FreePBX::Config()->get('AMPEXTENSIONS');
     $retarr = array();
     foreach ($modules as $rawname => $m) {
         if (isset($m['items'])) {
             foreach ($m['items'] as $k => $v) {
                 if ($mode == "deviceanduser" && $v['name'] == "Extensions") {
                     continue;
                 } elseif ($mode == "extensions" && ($v['name'] == "Devices" || $v['name'] == "Users")) {
                     continue;
                 }
                 \modgettext::push_textdomain(strtolower($m['rawname']));
                 $retarr[] = array("rawname" => $rawname, "rawtext" => $v['name'], "text" => _($v['name']), "type" => "get", "dest" => !empty($v['href']) ? $v['href'] : "?display={$k}");
                 \modgettext::pop_textdomain();
             }
         }
     }
     $hooks = $this->FreePBX->Hooks->returnHooks();
     foreach ($hooks as $hook) {
         $mod = $hook['module'];
         $hook = $hook['method'];
         $out = \FreePBX::$mod()->{$hook}($retarr);
         if (!empty($out)) {
             $retarr = $out;
         }
     }
     return $retarr;
 }
예제 #2
0
 public function getContent($section)
 {
     if (!class_exists('TimeUtils')) {
         include dirname(__DIR__) . '/classes/TimeUtils.class.php';
     }
     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;
     if (\FreePBX::Config()->get("FREEPBX_SYSTEM_IDENT")) {
         $idline = sprintf(_("<strong>'%s'</strong><br><i>(You can change this name in Advanced Settings)</i>"), \FreePBX::Config()->get("FREEPBX_SYSTEM_IDENT"));
     } else {
         $idline = "";
     }
     try {
         $getsi = \FreePBX::create()->Dashboard->getSysInfo();
     } catch (\Exception $e) {
     }
     $since = time() - $getsi['timestamp'];
     $notifications = $this->getNotifications(isset($_COOKIE['dashboardShowAll']) && $_COOKIE['dashboardShowAll'] == "true");
     $nots = $notifications['nots'];
     $alerts = $this->getAlerts($nots);
     return load_view(dirname(__DIR__) . '/views/sections/overview.php', array("showAllMessage" => $notifications['showAllMessage'], "nots" => $nots, "alerts" => $alerts, "brand" => $brand, "idline" => $idline, "version" => get_framework_version(), "since" => $since, "services" => $this->getSummary()));
 }
예제 #3
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);
}
예제 #4
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/";
 }
예제 #5
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);
     }
 }
예제 #6
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;
 }
예제 #7
0
 public function __construct($freepbx = null)
 {
     if ($freepbx == null) {
         throw new Exception("Not given a FreePBX Object");
     }
     $this->FreePBX = $freepbx;
     $this->Userman = $this->FreePBX->Userman;
     $this->db = $freepbx->Database;
     $this->brand = \FreePBX::Config()->get("DASHBOARD_FREEPBX_BRAND");
 }
예제 #8
0
 public function doDialplanHook(&$ext, $engine, $priority)
 {
     // While we're here, we should check that our cronjob is
     // still there.
     $file = \FreePBX::Config()->get('AMPWEBROOT') . "/admin/modules/dashboard/" . $this->sched;
     $cmd = "[ -x {$file} ] && {$file}";
     // Ensure we instantiate cron with the correct user
     $c = \FreePBX::create()->Cron(\FreePBX::Config()->get('AMPASTERISKWEBUSER'));
     $c->addLine("* * * * * {$cmd}");
 }
예제 #9
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'));
 }
예제 #10
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"));
 }
예제 #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->updateVars();
     $edgemode = \FreePBX::Config()->get('MODULEADMINEDGE');
     $alerts = \FreePBX::Notifications()->get_num_active();
     $output->write(base64_decode($this->banner));
     $output->writeln("");
     $output->writeln("");
     if ($alerts != 0) {
         $output->writeln("<fg=red>" . sprintf(_("NOTICE! You have %s notifications! Please log into the UI to see them!"), $alerts) . "</fg=red>");
     }
     if ($edgemode == 1) {
         $output->writeln("<fg=red>" . sprintf(_("NOTICE! This system had EDGE mode enabled. For more information visit %s"), 'http://wiki.freepbx.org/x/boi3Aw') . "</fg=red>");
     }
     $output->writeln("");
     $output->writeln("<info>" . _("Current Network Configuration") . "</info>");
     $iflist = $this->listIFS();
     if ($iflist) {
         $rows = array();
         foreach ($iflist as $if => $info) {
             $rows[] = array($if, $info['mac'], $info['ip']);
         }
         $table = new Table($output);
         $table->setHeaders(array(_('Interface'), _('MAC Address'), _('IP Addresses')))->setRows($rows);
         $table->render();
     } else {
         $output->writeln("-------------------");
         $output->writeln(_("No interfaces found"));
         $output->writeln("-------------------");
     }
     $messages = $this->externalMessages();
     if (isset($messages['pre'])) {
         foreach ($messages['pre'] as $o) {
             $output->writeln($o);
         }
     }
     if (!$messages['cancel']) {
         $output->writeln("");
         $output->writeln(_("Please note most tasks should be handled through the GUI."));
         $output->writeln(_("You can access the GUI by typing one of the above IPs in to your web browser."));
         $output->writeln(_("For support please visit: "));
         $output->writeln("    " . $this->supporturl);
         $output->writeln("");
     }
     if (isset($messages['post'])) {
         foreach ($messages['post'] as $o) {
             $output->writeln($o);
         }
     }
 }
예제 #12
0
 public function __construct()
 {
     $feeds = \FreePBX::Config()->get('RSSFEEDS');
     $feeds = str_replace("\r", "", $feeds);
     if (!empty($feeds)) {
         $feeds = explode("\n", $feeds);
         $i = 0;
         $this->urls = array();
         foreach ($feeds as $feed) {
             $this->urls['rss-' . $i] = $feed;
             $i++;
         }
     }
 }
예제 #13
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);
     }
 }
예제 #14
0
 public function getContent($section)
 {
     $feeds = \FreePBX::Config()->get('RSSFEEDS');
     $feeds = str_replace("\r", "", $feeds);
     if (empty($feeds)) {
         return '';
     }
     $feeds = explode("\n", $feeds);
     if (empty($feeds[$section])) {
         return '';
     }
     $feed = $this->getFeed($feeds[$section]);
     if (empty($feed)) {
         return '';
     }
     return load_view(dirname(__DIR__) . '/views/sections/blog.php', array("items" => $feed->items, "limit" => 5));
 }
예제 #15
0
 public function __construct($freepbx = null)
 {
     if ($freepbx == null) {
         throw new \Exception("NO");
     }
     $this->FreePBX = $freepbx;
     $this->db = $freepbx->Database;
     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;
     }
     $this->brand = DASHBOARD_FREEPBX_BRAND;
 }
예제 #16
0
 public function doDialplanHook(&$ext, $engine, $priority)
 {
     // We're not actually doing any dialplan modifications. This
     // is just a handy place to discover modules that have requested hooks
     // into the status page.
     if (!class_exists('DashboardHooks')) {
         include 'classes/DashboardHooks.class.php';
     }
     $allhooks = DashboardHooks::genHooks($this->getConfig('visualorder'));
     $this->setConfig('allhooks', $allhooks);
     // Also, while we're here, we should check that our cronjob is
     // still there.
     $file = \FreePBX::Config()->get('AMPWEBROOT') . "/admin/modules/dashboard/" . $this->sched;
     $cmd = "[ -x {$file} ] && {$file}";
     // Ensure we instantiate cron with the correct user
     $c = \FreePBX::Cron(\FreePBX::Config()->get('AMPASTERISKWEBUSER'));
     $c->addLine("* * * * * {$cmd}");
 }
예제 #17
0
/**
 * Log a message to the freepbx security file
 * @param  {string} $message the message
 */
function freepbx_log_security($txt)
{
    $path = FreePBX::Config()->get('ASTLOGDIR');
    $log_file = $path . '/freepbx_security.log';
    $tz = date_default_timezone_get();
    if (!$tz) {
        $tz = 'America/Los_Angeles';
    }
    date_default_timezone_set($tz);
    $tstamp = date("Y-m-d H:i:s");
    // Don't append if the file is greater than ~2G since some systems fail
    //
    $size = file_exists($log_file) ? sprintf("%u", filesize($log_file)) + strlen($txt) : 0;
    if ($size > 2000000000) {
        unlink($log_file);
    }
    file_put_contents($log_file, "[{$tstamp}] {$txt}\n", FILE_APPEND);
}
예제 #18
0
function pinsets_get_config($engine)
{
    global $ext;
    // is this the best way to pass this?
    global $asterisk_conf;
    $pinsets_conf = pinsets_conf::create();
    $astetcdir = \FreePBX::Config()->get("ASTETCDIR");
    $allpinsets = pinsets_list();
    if (is_array($allpinsets)) {
        foreach ($allpinsets as $item) {
            // write our own pin list files
            $pinsets_conf->addPinsets($item['pinsets_id'], $item['passwords']);
        }
        // write out a macro that handles the authenticate
        $ext->add('macro-pinsets', 's', '', new ext_gotoif('${ARG2} = 1', 'cdr,1'));
        $ext->add('macro-pinsets', 's', '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]', 'Authenticate', $astetcdir . '/pinset_${ARG1}'));
        $ext->add('macro-pinsets', 's', '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]', 'ResetCDR'));
        // authenticate with the CDR option (a)
        $ext->add('macro-pinsets', 'cdr', '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]', 'Authenticate', $astetcdir . '/pinset_${ARG1},a'));
        $ext->add('macro-pinsets', 'cdr', '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]', 'ResetCDR'));
    }
    $usage_list = pinsets_list_usage('routing');
    if (is_array($usage_list) && count($usage_list)) {
        $pinsets = pinsets_list();
        $addtocdr = array();
        foreach ($pinsets as $pinset) {
            $addtocdr[$pinset['pinsets_id']] = $pinset['addtocdr'];
        }
        foreach ($usage_list as $thisroute) {
            $context = 'outrt-' . $thisroute['foreign_id'];
            $patterns = core_routing_getroutepatternsbyid($thisroute['foreign_id']);
            foreach ($patterns as $pattern) {
                $fpattern = core_routing_formatpattern($pattern);
                $exten = $fpattern['dial_pattern'];
                $ext->splice($context, $exten, 1, new ext_macro('pinsets', $thisroute['pinsets_id'] . ',' . $addtocdr[$thisroute['pinsets_id']]), 'pinsets');
            }
        }
    }
}
예제 #19
0
 public function doDialplanHook(&$ext, $engine, $priority)
 {
     // We're not actually doing any dialplan modifications. This
     // is just a handy place to discover modules that have requested hooks
     // into the status page.
     if (!class_exists('DashboardHooks')) {
         include 'classes/DashboardHooks.class.php';
     }
     $allhooks = DashboardHooks::genHooks($this->getConfig('visualorder'));
     $this->setConfig('allhooks', $allhooks);
     // Also, while we're here, we should check that our cronjob is
     // still there.
     $file = \FreePBX::Config()->get('AMPWEBROOT') . "/admin/modules/dashboard/" . $this->sched;
     $cmd = "[ -x {$file} ] && {$file}";
     // Some HA machines had TWO schedulers running. Whoops. Manually
     // remove ALL of them. (To be removed in 13)
     $all = \FreePBX::Cron()->getAll();
     foreach ($all as $line) {
         if (strpos($line, "dashboard/scheduler.php") !== false) {
             \FreePBX::Cron()->remove($line);
         }
     }
     $this->Cron->addLine("* * * * * {$cmd}");
 }
예제 #20
0
$ext->add($mcontext, $exten, '', new ext_gosubif('$[${REGEX("^[\\+]?[0-9]+$" ${CALLERID(number)})} = 1]', 'ctset,1', 'ctclear,1'));
//TODO: do we need to check for anything beyond auto-blkvm in this call path?
$ext->add($mcontext, $exten, 'skiptrace', new ext_set('D_OPTIONS', '${IF($["${NODEST}"!="" & ${REGEX("(M[(]auto-blkvm[)])" ${ARG2})} != 1]?${ARG2}M(auto-blkvm):${ARG2})}'));
//Advanced settings alert info internal calls
$ext->add($mcontext, $exten, '', new ext_noop('Blind Transfer: ${BLINDTRANSFER}, Attended Transfer: ${ATTENDEDTRANSFER}, User: ${AMPUSER}, Alert Info: ${ALERT_INFO}'));
$ai = FreePBX::Config()->get('INTERNALALERTINFO');
$ai = trim($ai);
$ai = $ai != "none" && $ai != "inherit" ? $ai : '';
$ext->add($mcontext, $exten, '', new ext_execif('$["${ALERT_INFO}"="" & ${LEN(${AMPUSER})}!=0 & ${LEN(${BLINDTRANSFER})}=0 & ${LEN(${ATTENDEDTRANSFER})}=0]', 'Set', 'ALERT_INFO=' . $ai));
//Advanced settings alert info Blind Transfer
$bt = FreePBX::Config()->get('BLINDTRANSALERTINFO');
$bt = trim($bt);
$bt = $bt != "none" && $bt != "inherit" ? $bt : '';
$ext->add($mcontext, $exten, '', new ext_execif('$[${LEN(${BLINDTRANSFER})}!=0]', 'Set', 'ALERT_INFO=' . $bt));
//Advanced settings alert info Attended Transfer
$at = FreePBX::Config()->get('ATTTRANSALERTINFO');
$at = trim($at);
$at = $at != "none" && $at != "inherit" ? $at : '';
$ext->add($mcontext, $exten, '', new ext_execif('$[${LEN(${ATTENDEDTRANSFER})}!=0]', 'Set', 'ALERT_INFO=' . $at));
//Now set Alert Info
$ext->add($mcontext, $exten, '', new ext_gosubif('$["${ALERT_INFO}"!="" & "${ALERT_INFO}"!=" "]', 'func-set-sipheader,s,1', false, 'Alert-Info,${ALERT_INFO}'));
// This is now broken. SIPADDHEADER needs to be a hash. TODO figure out how to fix this
// $ext->add($mcontext,$exten,'', new ext_execif('$["${SIPADDHEADER}"!=""]', 'SIPAddHeader', '${SIPADDHEADER}'));
$ext->add($mcontext, $exten, '', new ext_execif('$[("${MOHCLASS}"!="default") & ("${MOHCLASS}"!="")]', 'Set', 'CHANNEL(musicclass)=${MOHCLASS}'));
$ext->add($mcontext, $exten, '', new ext_gosubif('$["${QUEUEWAIT}"!=""]', 'qwait,1'));
$ext->add($mcontext, $exten, '', new ext_set('__CWIGNORE', '${CWIGNORE}'));
$ext->add($mcontext, $exten, '', new ext_set('__KEEPCID', 'TRUE'));
// Use goto if no timelimit set from CF
$ext->add($mcontext, $exten, '', new ext_gotoif('$["${USEGOTO}"="1"]', 'usegoto,1'));
// Once setting CONNECTEDLINE(), add the I option to Dial() so the device doesn't further update the value with the
// "device" <devicenum> data from device CID information, don't send an update if the calling party is not an extension it breaks some providers
예제 #21
0
 public function getSections($order)
 {
     $brand = \FreePBX::Config()->get("DASHBOARD_FREEPBX_BRAND");
     return array(array("title" => "{$brand} " . _("Statistics"), "group" => _("Statistics"), "width" => "550px", "order" => isset($order['statistics']) ? $order['statistics'] : '300', "section" => "statistics"));
 }
예제 #22
0
function callrecording_get_config($engine)
{
    global $ext;
    switch ($engine) {
        case 'asterisk':
            $context = 'ext-callrecording';
            foreach (callrecording_list() as $row) {
                $ext->add($context, $row['callrecording_id'], '', new ext_noop_trace('Call Recording: [' . $row['callrecording_mode'] . '] Event'));
                switch ($row['callrecording_mode']) {
                    case 'force':
                        $ext->add($context, $row['callrecording_id'], '', new ext_gosub('1', 's', 'sub-record-check', 'generic,${FROM_DID},always'));
                        break;
                    case 'delayed':
                        $ext->add($context, $row['callrecording_id'], '', new ext_set('__REC_POLICY_MODE', 'always'));
                        break;
                    case 'never':
                        $ext->add($context, $row['callrecording_id'], '', new ext_gosub('1', 's', 'sub-record-check', 'generic,${FROM_DID},never'));
                        $ext->add($context, $row['callrecording_id'], '', new ext_set('__REC_POLICY_MODE', 'never'));
                        break;
                    default:
                        // allowed
                        $ext->add($context, $row['callrecording_id'], '', new ext_execif('$["${REC_POLICY_MODE}"="never"]', 'Set', '__REC_POLICY_MODE='));
                        break;
                }
                $ext->add($context, $row['callrecording_id'], '', new ext_goto($row['dest']));
            }
            /*
             * This used to abort and remove a recording, but is no longer needed. It's
             * kept around as a null stub in case other modules call it.
             */
            $context = 'sub-record-cancel';
            $exten = 's';
            $ext->add($context, $exten, '', new ext_return(''));
            /*
            ; ARG1: type
            ;       exten, out, rg, q, conf
            ; ARG2: called_exten
            ; ARG3: action (if we know it)
            ;       force (== always), yes, dontcare, no, never
            ;
            */
            $context = 'sub-record-check';
            $exten = 's';
            $ext->add($context, $exten, '', new ext_gotoif('$[${LEN(${FROMEXTEN})}]', 'initialized'));
            $ext->add($context, $exten, '', new ext_set('__REC_STATUS', 'INITIALIZED'));
            $ext->add($context, $exten, '', new ext_set('NOW', '${EPOCH}'));
            $ext->add($context, $exten, '', new ext_set('__DAY', '${STRFTIME(${NOW},,%d)}'));
            $ext->add($context, $exten, '', new ext_set('__MONTH', '${STRFTIME(${NOW},,%m)}'));
            $ext->add($context, $exten, '', new ext_set('__YEAR', '${STRFTIME(${NOW},,%Y)}'));
            $ext->add($context, $exten, '', new ext_set('__TIMESTR', '${YEAR}${MONTH}${DAY}-${STRFTIME(${NOW},,%H%M%S)}'));
            $ext->add($context, $exten, '', new ext_set('__FROMEXTEN', '${IF($[${LEN(${AMPUSER})}]?${AMPUSER}:${IF($[${LEN(${REALCALLERIDNUM})}]?${REALCALLERIDNUM}:unknown)})}'));
            // MON_FMT is the format that MixMon knows about. If we're set to 'wav49', MixMonitor actually saves the
            // filename as 'WAV', not, as expected, 'wav49' - see https://issues.asterisk.org/jira/browse/ASTERISK-24798
            // So, if we've been given wav49, change it to WAV.  Note, this breaks on non-case-sensitive filesystems (such
            // as anything windows based), so don't use GSM encoded wavs in that case.
            $ext->add($context, $exten, '', new ext_set('__MON_FMT', '${IF($["${MIXMON_FORMAT}"="wav49"]?WAV:${MIXMON_FORMAT})}'));
            $ext->add($context, $exten, 'initialized', new ext_noop('Recordings initialized'));
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${ARG3})}]', 'Set', 'ARG3=dontcare'));
            // Make sure we have a recording request.
            // Backup our current setting, just in case we need to roll back to it.
            $ext->add($context, $exten, '', new ext_set('REC_POLICY_MODE_SAVE', '${REC_POLICY_MODE}'));
            // When we're internally transferred, we are NEVER recording.
            $ext->add($context, $exten, '', new ext_execif('$["${BLINDTRANSFER}${ATTENDEDTRANSFER}" != ""]', 'Set', 'REC_STATUS=NO'));
            // If we weren't given a type, error. This is a bug.
            $ext->add($context, $exten, 'next', new ext_gotoif('$[${LEN(${ARG1})}]', 'checkaction'));
            $ext->add($context, $exten, 'recorderror', new ext_playback('something-terribly-wrong,error'));
            $ext->add($context, $exten, '', new ext_hangup());
            // If we don't have a current mode, and we were explicitly given a command, we can set our current mode
            // to that. This is what we CURRENTLY think we should be doing. This may change if it's an exten.
            //  .. Disabled. Legacy code, should be unneeded now.
            // $ext->add($context, $exten, 'checkaction', new ext_execif('$["${REC_POLICY_MODE}"="" & "${ARG3}"!=""]','Set','__REC_POLICY_MODE=${TOUPPER(${ARG3})}'));
            // Now jump to the dialplan handler. If it doesn't exist, do the generic test (rg, force, q use these).
            $ext->add($context, $exten, 'checkaction', new ext_gotoif('$[${DIALPLAN_EXISTS(' . $context . ',${ARG1})}]', $context . ',${ARG1},1'));
            // Generic check
            $ext->add($context, $exten, '', new ext_noop('Generic ${ARG1} Recording Check - ${FROMEXTEN} ${ARG2}'));
            $ext->add($context, $exten, '', new ext_gosub('1', 'recordcheck', false, '${ARG3},${ARG1},${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // Check to see what should be done, based on the request type.
            // ARG1 = Policy.
            // ARG2 = Name ('q', 'exten', etc)
            // ARG3 = Destination
            $exten = 'recordcheck';
            $ext->add($context, $exten, '', new ext_noop('Starting recording check against ${ARG1}'));
            $ext->add($context, $exten, '', new ext_goto('${ARG1}'));
            // Don't care - just return, nothing's changed.
            $ext->add($context, $exten, 'dontcare', new ext_return(''));
            // ALWAYS: Extensions used 'Always' and 'Never'. Alias 'Always' to 'Force'
            $ext->add($context, $exten, 'always', new ext_noop('Detected legacy "always" entry. Mapping to "force"'));
            // FORCE: Always start recording, if you're not already.
            $ext->add($context, $exten, 'force', new ext_set('__REC_POLICY_MODE', 'FORCE'));
            $ext->add($context, $exten, '', new ext_gotoif('$["${REC_STATUS}"!="RECORDING"]', 'startrec'));
            $ext->add($context, $exten, '', new ext_return(''));
            $ext->add($context, $exten, 'delayed', new ext_noop('Detected legacy "delayed" entry. Mapping to "yes"'));
            // YES: Start recording if we haven't been told otherwise.
            $ext->add($context, $exten, 'yes', new ext_execif('$["${REC_POLICY_MODE}" = "NEVER" | "${REC_POLICY_MODE}" = "NO" | "${REC_STATUS}" = "RECORDING"]', 'Return'));
            $ext->add($context, $exten, '', new ext_set('__REC_POLICY_MODE', 'YES'));
            $ext->add($context, $exten, '', new ext_goto('startrec'));
            // NO: Don't record this. This won't STOP a recording that's already happening though.
            $ext->add($context, $exten, 'no', new ext_set('__REC_POLICY_MODE', 'NO'));
            $ext->add($context, $exten, '', new ext_return(''));
            // NEVER: Don't record this call, and stop recording if we are.
            $ext->add($context, $exten, 'never', new ext_set('__REC_POLICY_MODE', 'NEVER'));
            $ext->add($context, $exten, '', new ext_goto('stoprec'));
            // Start recording if requested
            $ext->add($context, $exten, 'startrec', new ext_noop('Starting recording: ${ARG2}, ${ARG3}'));
            $ext->add($context, $exten, '', new ext_set('AUDIOHOOK_INHERIT(MixMonitor)', 'yes'));
            $ext->add($context, $exten, '', new ext_set('__CALLFILENAME', '${ARG2}-${ARG3}-${FROMEXTEN}-${TIMESTR}-${UNIQUEID}'));
            $ext->add($context, $exten, '', new ext_mixmonitor('${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MON_FMT}', 'ai(LOCAL_MIXMON_ID)', '${MIXMON_POST}'));
            $ext->add($context, $exten, '', new ext_set('__MIXMON_ID', '${LOCAL_MIXMON_ID}'));
            $ext->add($context, $exten, '', new ext_set('__RECORD_ID', '${CHANNEL(name)}'));
            $ext->add($context, $exten, '', new ext_set('__REC_STATUS', 'RECORDING'));
            $ext->add($context, $exten, '', new ext_set('CDR(recordingfile)', '${CALLFILENAME}.${MON_FMT}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // Stop recording if requested.
            $ext->add($context, $exten, 'stoprec', new ext_noop('Stopping recording: ${ARG2}, ${ARG3}'));
            $ext->add($context, $exten, '', new ext_set('__REC_STATUS', 'STOPPED'));
            // See https://issues.asterisk.org/jira/browse/ASTERISK-24527
            $ext->add($context, $exten, '', new ext_system(FreePBX::Config()->get('ASTVARLIBDIR') . '/bin/stoprecording.php "${CHANNEL(name)}"'));
            $ext->add($context, $exten, '', new ext_return(''));
            // RECORDING POLICY LOGIC HERE
            //
            // OUTBOUND ROUTES
            $exten = 'out';
            $ext->add($context, $exten, '', new ext_noop('Outbound Recording Check from ${FROMEXTEN} to ${ARG2}'));
            // The Extension is first in the chain.
            $ext->add($context, $exten, '', new ext_set('RECMODE', '${DB(AMPUSER/${FROMEXTEN}/recording/out/external)}'));
            // If the exten is blank or DONTCARE, then we use the route.
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${RECMODE})} | "${RECMODE}" = "dontcare"]', 'Goto', 'routewins'));
            // If the route is FORCE or NEVER, then we use the route.
            $ext->add($context, $exten, '', new ext_execif('$["${ARG3}" = "never" | "${ARG3}" = "force"]', 'Goto', 'routewins'));
            // Neither of those, so we use exten's setting.
            $ext->add($context, $exten, 'extenwins', new ext_gosub('1', 'recordcheck', false, '${RECMODE},out,${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // Route wins
            $ext->add($context, $exten, 'routewins', new ext_gosub('1', 'recordcheck', false, '${ARG3},out,${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // INBOUND ROUTES
            $exten = 'in';
            $ext->add($context, $exten, '', new ext_noop('Inbound Recording Check to ${ARG2}'));
            $ext->add($context, $exten, '', new ext_set('FROMEXTEN', 'unknown'));
            $ext->add($context, $exten, '', new ext_execif('$[${LEN(${CALLERID(num)})}]', 'Set', 'FROMEXTEN=${CALLERID(num)}'));
            $ext->add($context, $exten, '', new ext_gosub('1', 'recordcheck', false, '${ARG3},in,${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // CALLS BETWEEN EXTENSIONS
            $exten = 'exten';
            $ext->add($context, $exten, '', new ext_noop('Exten Recording Check between ${FROMEXTEN} and ${ARG2}'));
            $ext->add($context, $exten, '', new ext_set('CALLTYPE', '${IF($[${LEN(${FROM_DID})}]?external:internal)}'));
            $ext->add($context, $exten, '', new ext_execif('${LEN(${CALLTYPE_OVERRIDE})}', 'Set', 'CALLTYPE=${CALLTYPE_OVERRIDE}'));
            // Queues use this to make sure a call is tagged as external
            $ext->add($context, $exten, '', new ext_set('CALLEE', '${DB(AMPUSER/${ARG2}/recording/in/${CALLTYPE})}'));
            // Make sure CALLEE isn't empty. Bad astdb entry?
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${CALLEE})}]', 'Set', 'CALLEE=dontcare'));
            // Is it an external call? It's not going to be caller.
            $ext->add($context, $exten, '', new ext_gotoif('$["${CALLTYPE}"="external"]', 'callee'));
            // Does the callee care about it? If not, we let the caller choose.
            $ext->add($context, $exten, '', new ext_gotoif('$["${CALLEE}"="dontcare"]', 'caller'));
            // It does. We may have a priority battle on our hands.
            $ext->add($context, $exten, '', new ext_execif('$[${LEN(${DB(AMPUSER/${FROMEXTEN}/recording/priority)})}]', 'Set', 'CALLER_PRI=${DB(AMPUSER/${FROMEXTEN}/recording/priority)}', 'Set', 'CALLER_PRI=0'));
            $ext->add($context, $exten, '', new ext_execif('$[${LEN(${DB(AMPUSER/${ARG2}/recording/priority)})}]', 'Set', 'CALLEE_PRI=${DB(AMPUSER/${ARG2}/recording/priority)}', 'Set', 'CALLEE_PRI=0'));
            // Who wins?
            $ext->add($context, $exten, '', new ext_gotoif('$["${CALLER_PRI}"="${CALLEE_PRI}"]', '${REC_POLICY}', '${IF($[${CALLER_PRI}>${CALLEE_PRI}]?caller:callee)}'));
            // Recpient of the call wins. We've already sanity checked them above, so we can use the CALLEE var.
            $ext->add($context, $exten, 'callee', new ext_gosub('1', 'recordcheck', false, '${CALLEE},${CALLTYPE},${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // Originator of the call wins. Always out/internal.
            $ext->add($context, $exten, 'caller', new ext_set('RECMODE', '${DB(AMPUSER/${FROMEXTEN}/recording/out/internal)}'));
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${RECMODE})}]', 'Set', 'RECMODE=dontcare'));
            // If we don't care, then the callee gets to pick.
            $ext->add($context, $exten, '', new ext_execif('$["${RECMODE}"="dontcare"]', 'Set', 'RECMODE=${CALLEE}'));
            $ext->add($context, $exten, '', new ext_gosub('1', 'recordcheck', false, '${RECMODE},${CALLTYPE},${ARG2}'));
            $ext->add($context, $exten, '', new ext_return(''));
            // For confernecing we will set the variables (since the actual meetme does the recording) in case an option were to exist to do on-demand recording
            // of the conference which doesn't currenly seem like it is supported but might.
            //
            $exten = 'conf';
            $ext->add($context, $exten, '', new ext_noop('Conference Recording Check ${FROMEXTEN} to ${ARG2}'));
            $ext->add($context, $exten, '', new ext_gosub('1', 'recconf', false, '${ARG2},${ARG2},${ARG3}'));
            $ext->add($context, $exten, '', new ext_return(''));
            $exten = 'page';
            $ext->add($context, $exten, '', new ext_noop('Paging Recording Check ${FROMEXTEN} to ${ARG2}'));
            $ext->add($context, $exten, '', new ext_gosubif('$["${REC_POLICY_MODE}"="always"]', 'recconf,1', false, '${ARG2},${FROMEXTEN},${ARG3}'));
            $ext->add($context, $exten, '', new ext_return(''));
            $exten = 'recconf';
            $ext->add($context, $exten, '', new ext_noop('Setting up recording: ${ARG1}, ${ARG2}, ${ARG3}'));
            if (FreePBX::Config()->get('ASTCONFAPP')) {
                $ext->add($context, $exten, '', new ext_set('__CALLFILENAME', '${IF($[${CONFBRIDGE_INFO(parties,${ARG2})}]?${DB(RECCONF/${ARG2})}:${ARG1}-${ARG2}-${ARG3}-${TIMESTR}-${UNIQUEID})}'));
                $ext->add($context, $exten, '', new ext_execif('$[!${CONFBRIDGE_INFO(parties,${ARG2})}]', 'Set', 'DB(RECCONF/${ARG2})=${CALLFILENAME}'));
                $ext->add($context, $exten, '', new ext_set('CONFBRIDGE(bridge,record_file)', '${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MON_FMT}'));
            } else {
                // Conferencing must set the path to MIXMON_DIR explicitly since unlike other parts of Asterisk
                // Meetme does not default to the defined monitor directory.
                //
                $ext->add($context, $exten, '', new ext_set('__CALLFILENAME', '${IF($[${MEETME_INFO(parties,${ARG2})}]?${DB(RECCONF/${ARG2})}:${ARG1}-${ARG2}-${ARG3}-${TIMESTR}-${UNIQUEID})}'));
                $ext->add($context, $exten, '', new ext_execif('$[!${MEETME_INFO(parties,${ARG2})}]', 'Set', 'DB(RECCONF/${ARG2})=${CALLFILENAME}'));
                $ext->add($context, $exten, '', new ext_set('MEETME_RECORDINGFILE', '${IF($[${LEN(${MIXMON_DIR})}]?${MIXMON_DIR}:${ASTSPOOLDIR}/monitor/)}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}'));
                $ext->add($context, $exten, '', new ext_set('MEETME_RECORDINGFORMAT', '${MON_FMT}'));
            }
            $ext->add($context, $exten, '', new ext_execif('$["${ARG3}"!="always"]', 'Return'));
            if (FreePBX::Config()->get('ASTCONFAPP') == 'app_confbridge') {
                $ext->add($context, $exten, '', new ext_set('CONFBRIDGE(bridge,record_conference)', 'yes'));
            }
            $ext->add($context, $exten, '', new ext_set('__REC_STATUS', 'RECORDING'));
            $ext->add($context, $exten, '', new ext_set('CDR(recordingfile)', '${CALLFILENAME}.${MON_FMT}'));
            $ext->add($context, $exten, '', new ext_return(''));
            /* Queue Recording Section */
            $exten = 'recq';
            $ext->add($context, $exten, '', new ext_noop('Setting up recording: ${ARG1}, ${ARG2}, ${ARG3}'));
            $ext->add($context, $exten, '', new ext_set('AUDIOHOOK_INHERIT(MixMonitor)', 'yes'));
            $ext->add($context, $exten, '', new ext_set('MONITOR_FILENAME', '${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}'));
            $ext->add($context, $exten, '', new ext_mixmonitor('${MONITOR_FILENAME}.${MON_FMT}', '${MONITOR_OPTIONS}', '${MIXMON_POST}'));
            $ext->add($context, $exten, '', new ext_set('__REC_STATUS', 'RECORDING'));
            $ext->add($context, $exten, '', new ext_set('CDR(recordingfile)', '${CALLFILENAME}.${MON_FMT}'));
            $ext->add($context, $exten, '', new ext_return(''));
            /* Picked up parked call */
            $exten = 'parking';
            $ext->add($context, $exten, '', new ext_noop('User ${ARG2} picked up a parked call'));
            $ext->add($context, $exten, '', new ext_set('USER', '${ARG2}'));
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${ARG2})}]', 'Set', 'USER=unknown'));
            $ext->add($context, $exten, '', new ext_set('RECMODE', '${DB(AMPUSER/${ARG2}/recording/out/internal)}'));
            $ext->add($context, $exten, '', new ext_execif('$[!${LEN(${RECMODE})}]', 'Set', 'RECMODE=dontcare'));
            // Make sure we have a recording request.
            $ext->add($context, $exten, '', new ext_gosub('1', 'recordcheck', false, '${RECMODE},parked,${USER}'));
            $ext->add($context, $exten, '', new ext_return(''));
            /* macro-one-touch-record */
            $context = 'macro-one-touch-record';
            $exten = 's';
            $ext->add($context, $exten, '', new ext_set('ONETOUCH_REC_SCRIPT_STATUS', ''));
            $ext->add($context, $exten, '', new ext_system(FreePBX::Config()->get('ASTVARLIBDIR') . '/bin/one_touch_record.php "${CHANNEL(name)}"'));
            $ext->add($context, $exten, '', new ext_noop('ONETOUCH_REC_SCRIPT_STATUS: [${ONETOUCH_REC_SCRIPT_STATUS}]'));
            $ext->add($context, $exten, '', new ext_noop_trace('REC_STATUS: [${REC_STATUS}]'));
            $ext->add($context, $exten, '', new ext_noop_trace('ONETOUCH_RECFILE: [${ONETOUCH_RECFILE}] CDR(recordingfile): [${CDR(recordingfile)}]'));
            $ext->add($context, $exten, '', new ext_execif('$["${REC_STATUS}"="RECORDING"]', 'Playback', 'beep'));
            $ext->add($context, $exten, '', new ext_execif('$["${REC_STATUS}"="STOPPED"]', 'Playback', 'beep&beep'));
            $ext->add($context, $exten, '', new ext_execif('$["${ONETOUCH_REC_SCRIPT_STATUS:0:6}"="DENIED"]', 'Playback', 'access-denied'));
            $ext->add($context, $exten, '', new ext_macroexit());
    }
}
예제 #23
0
    $sth = FreePBX::Database()->prepare($sql);
    $sth->execute();
}
$set = array();
$set['value'] = '';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'userman';
$set['category'] = 'User Management Module';
$set['emptyok'] = 1;
$set['name'] = 'Email "From:" Address';
$set['description'] = 'The From: field for emails when using the user management email feature.';
$set['type'] = CONF_TYPE_TEXT;
FreePBX::Config()->define_conf_setting('AMPUSERMANEMAILFROM', $set, true);
//Quick check to see if we are previously installed
//this lets us know if we need to create a default group
$sql = "SELECT * FROM userman_groups";
$sth = FreePBX::Database()->prepare($sql);
try {
    $sth->execute();
    $grps = $sth->fetchAll();
} catch (\Exception $e) {
    $grps = array();
}
if (empty($grps)) {
    $sql = "INSERT INTO userman_groups (`groupname`, `description`, `users`) VALUES (?, ?, ?)";
    $sth = FreePBX::Database()->prepare($sql);
    $sth->execute(array(_("All Users"), _("This group was created on install and is automatically assigned to new users. This can be disabled in User Manager Settings"), "[]"));
    $id = FreePBX::Database()->lastInsertId();
예제 #24
0
 /**
  * Get all Cached Signatures, update if it doesnt exist
  * @param {bool} $cached=true Whether to use cached data or not
  */
 function getAllSignatures($cached = true, $online = false)
 {
     FreePBX::GPG();
     //declare class to get constants
     $sql = "SELECT modulename, signature FROM modules";
     $sth = FreePBX::Database()->prepare($sql);
     $sth->execute();
     $res = $sth->fetchAll(PDO::FETCH_ASSOC);
     $modules = array();
     $globalValidation = true;
     // String below, if i18n'ed, must be identical to that in GPG class.
     // Read the comment there.
     $amportal = FreePBX::Config()->get('AMPSBIN') . "/amportal " . _("altered");
     if (!$cached && $online) {
         FreePBX::GPG()->refreshKeys();
     }
     foreach ($res as $mod) {
         // Ignore ARI for the moment.
         if ($mod['modulename'] == 'fw_ari') {
             continue;
         }
         //TODO: determine if this should be in here or not.
         if (!$cached || empty($mod['signature'])) {
             $mod['signature'] = $this->updateSignature($mod['modulename']);
         } else {
             $mod['signature'] = json_decode($mod['signature'], TRUE);
         }
         $modules['modules'][$mod['modulename']] = $mod;
         if (!is_int($mod['signature']['status'])) {
             $modules['statuses']['unsigned'][] = sprintf(_('Module "%s" is is missing its signature status.'), $modname);
             continue;
         }
         if (~$mod['signature']['status'] & GPG::STATE_GOOD) {
             $globalValidation = false;
         }
         $trusted = $mod['signature']['status'] & GPG::STATE_TRUSTED;
         $tampered = $mod['signature']['status'] & GPG::STATE_TAMPERED;
         $unsigned = $mod['signature']['status'] & GPG::STATE_UNSIGNED;
         $invalid = $mod['signature']['status'] & GPG::STATE_INVALID;
         $revoked = $mod['signature']['status'] & GPG::STATE_REVOKED;
         //if revoked then disable
         $md = $this->getInfo();
         $modname = !empty($md[$mod['modulename']]['name']) ? $md[$mod['modulename']]['name'] : sprintf(_('%s [not enabled]'), $mod['modulename']);
         if ($invalid) {
             $modules['statuses']['tampered'][] = sprintf(_('Module "%s" signed by an invalid key.'), $modname);
         }
         if ($unsigned) {
             if ($mod['modulename'] == "framework" || $mod['modulename'] == "core") {
                 // Unsigned framework or core is extremely terribly bad.
                 $modules['statuses']['tampered'][] = sprintf(_('Critical Module "%s" is unsigned, re-download immediately'), $modname);
             } else {
                 $modules['statuses']['unsigned'][] = sprintf(_('Module "%s" is unsigned and should be re-downloaded'), $modname);
             }
         } else {
             if ($tampered) {
                 foreach ($mod['signature']['details'] as $d) {
                     if ($d == $amportal) {
                         $modules['statuses']['tampered'][] = sprintf(_("Module: '%s', File: '%s' (If you just updated FreePBX, you'll need to run 'amportal chown' and then 'amportal a r' to clear this message. If you did not just update FreePBX, your system may have been compromised)"), $modname, $d);
                     } else {
                         $modules['statuses']['tampered'][] = sprintf(_('Module: "%s", File: "%s"'), $modname, $d);
                     }
                 }
             }
             if (!$trusted) {
                 if ($revoked) {
                     $modules['statuses']['revoked'][] = sprintf(_('Module: "%s"\'s signature has been revoked. Module has been automatically disabled'), $modname);
                 }
             }
         }
     }
     $statuses = array('untrusted' => _('untrusted'), 'unsigned' => _('unsigned'), 'tampered' => _('tampered'), 'unknown' => _('unknown'), 'revoked' => _('revoked'));
     $nt = notifications::create();
     foreach ($statuses as $type => $name) {
         if (!empty($modules['statuses'][$type]) && FreePBX::Config()->get('SIGNATURECHECK')) {
             switch ($type) {
                 case 'unsigned':
                     //TODO: check the hash
                     $hash = md5(json_encode($modules['statuses'][$type]));
                     $sth = FreePBX::Database()->prepare("SELECT value FROM admin WHERE variable = 'unsigned' LIMIT 1");
                     $sth->execute();
                     $o = $sth->fetch();
                     if (empty($o)) {
                         $nt->add_signature_unsigned('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s unsigned modules'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]), '', true, true);
                         sql("INSERT INTO admin (variable, value) VALUE ('unsigned', '{$hash}')");
                     } elseif ($o['value'] != $hash) {
                         $nt->add_signature_unsigned('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s unsigned modules'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]), '', true, true);
                         $sth = FreePBX::Database()->prepare("UPDATE admin SET value = ? WHERE variable = 'unsigned'");
                         $sth->execute(array($hash));
                     }
                     break;
                 case 'tampered':
                     $nt->add_security('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s tampered files'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]));
                     break;
                 default:
                     $nt->add_security('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s %s modules'), count($modules['statuses'][$type]), $name), implode("<br>", $modules['statuses'][$type]));
                     break;
             }
         } else {
             $nt->delete('freepbx', 'FW_' . strtoupper($type));
         }
     }
     $modules['validation'] = $globalValidation;
     return $modules;
 }
예제 #25
0
$set['name'] = 'View: UCP icons';
$set['description'] = 'UCP icons folder. This should never be changed except for very advanced layout changes';
$set['type'] = CONF_TYPE_TEXT;
FreePBX::Config()->define_conf_setting('VIEW_UCP_ICONS_FOLDER', $set, true);
$set['value'] = true;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 1;
$set['module'] = 'ucp';
//This will help delete the settings when module is uninstalled
$set['category'] = 'User Control Panel';
$set['emptyok'] = 0;
$set['name'] = 'Allow Username Changes';
$set['description'] = 'Allow users to change thier username in UCP';
$set['type'] = CONF_TYPE_BOOL;
FreePBX::Config()->define_conf_setting('UCPCHANGEUSERNAME', $set, true);
$set['value'] = true;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 1;
$set['module'] = 'ucp';
//This will help delete the settings when module is uninstalled
$set['category'] = 'User Control Panel';
$set['emptyok'] = 0;
$set['name'] = 'Allow Password Changes';
$set['description'] = 'Allow users to change thier password in UCP';
$set['type'] = CONF_TYPE_BOOL;
FreePBX::Config()->define_conf_setting('UCPCHANGEPASSWORD', $set, true);
예제 #26
0
function displayRepoSelect($buttons, $online = false, $repo_list = array())
{
    global $display, $online, $tabindex;
    $modulef = module_functions::create();
    $displayvars = array("display" => $display, "online" => $online, "tabindex" => $tabindex, "repo_list" => $repo_list, "active_repos" => $modulef->get_active_repos());
    $button_display = '';
    $href = "config.php?display={$display}";
    $button_template = '<input type="button" value="%s" onclick="location.href=\'%s\';" />' . "\n";
    $displayvars['button_display'] = '';
    foreach ($buttons as $button) {
        switch ($button) {
            case 'local':
                $displayvars['button_display'] .= sprintf($button_template, _("Manage local modules"), $href);
                break;
            case 'upload':
                $displayvars['button_display'] .= sprintf($button_template, _("Upload modules"), $href . '&action=upload');
                break;
        }
    }
    $brand = \FreePBX::Config()->get("DASHBOARD_FREEPBX_BRAND");
    $displayvars['tooltip'] = _("Choose the repositories that you want to check for new modules. Any updates available for modules you have on your system will be detected even if the repository is not checked. If you are installing a new system, you may want to start with the Basic repository and update all modules, then go back and review the others.") . ' ';
    $displayvars['tooltip'] .= sprintf(_(" The modules in the Extended repository are less common and may receive lower levels of support. The Unsupported repository has modules that are not supported by the %s team but may receive some level of support by the authors."), $brand) . ' ';
    $displayvars['tooltip'] .= _("The Commercial repository is reserved for modules that are available for purchase and commercially supported.") . ' ';
    $displayvars['tooltip'] .= '<br /><br /><small><i>(' . sprintf(_("Checking for updates will transmit your %s, Distro, Asterisk and PHP version numbers along with a unique but random identifier. This is used to provide proper update information and track version usage to focus development and maintenance efforts. No private information is transmitted."), $brand) . ')</i></small>';
    return load_view('views/module_admin/reposelect.php', $displayvars);
}
예제 #27
0
    if ($bmo->Unlock($unlock)) {
        unset($no_auth);
        $display = 'index';
    }
}
//redirect back to the modules page for upgrade
if (isset($_SESSION['modulesRedirect'])) {
    $display = 'modules';
    unset($_SESSION['modulesRedirect']);
}
// determine if the user has a session time out set in advanced settings. If the timeout is 0 or not set, we don't force logout
$sessionTimeOut = \FreePBX::Config()->get('SESSION_TIMEOUT');
if ($sessionTimeOut) {
    // Make sure it's not set to something crazy short.
    if ($sessionTimeOut < 60) {
        \FreePBX::Config()->update('SESSION_TIMEOUT', 60);
        $sessionTimeOut = 60;
    }
    if (!empty($_SESSION['AMP_user']) && is_object($_SESSION['AMP_user'])) {
        //if we don't have last activity set it now
        if (empty($_SESSION['AMP_user']->_lastactivity)) {
            $_SESSION['AMP_user']->_lastactivity = time();
        } else {
            //check to see if we should be logged out or reset the last activity time
            if ($_SESSION['AMP_user']->_lastactivity + $sessionTimeOut < time()) {
                unset($_SESSION['AMP_user']);
            } else {
                $_SESSION['AMP_user']->_lastactivity = time();
            }
        }
    }
예제 #28
0
    // add new field
    $sql = "ALTER TABLE recordings ADD `fcode_pass` VARCHAR( 20 ) NULL ;";
    $result = $db->query($sql);
    if (DB::IsError($result)) {
        die_freepbx($result->getDebugInfo());
    }
    out(_("OK"));
} else {
    out(_("already exists"));
}
sql('DELETE FROM recordings WHERE displayname = "__invalid"');
$freepbx_conf =& freepbx_conf::create();
if ($freepbx_conf->conf_setting_exists('AMPPLAYKEY')) {
    $freepbx_conf->remove_conf_setting('AMPPLAYKEY');
}
$dir = FreePBX::Config()->get("ASTVARLIBDIR") . "/sounds";
$sql = "SELECT * FROM recordings";
$sth = FreePBX::Database()->prepare($sql);
$sth->execute();
$recordings = $sth->fetchAll(\PDO::FETCH_ASSOC);
$default = FreePBX::Soundlang()->getLanguage();
if (!file_exists($dir . "/" . $default . "/custom")) {
    mkdir($dir . "/" . $default . "/custom", 0777, true);
}
foreach ($recordings as $recording) {
    $files = explode("&", $recording['filename']);
    $filenames = array();
    foreach ($files as $file) {
        //move all custom files to the default language first
        if (preg_match("/^custom\\/(.*)/", $file, $matches)) {
            foreach (glob($dir . "/custom/" . $matches[1] . ".*") as $f) {
예제 #29
0
    return $em->send();
}
$brand = $amp_conf['DASHBOARD_FREEPBX_BRAND'] ? $amp_conf['DASHBOARD_FREEPBX_BRAND'] : 'FreePBX';
$email = $cm->get_email();
if ($email) {
    $mid = $cm->get_machineid();
    $htext = sprintf(_("This notification was generated by the %s Server identified as '%s'."), $brand, $mid) . "\n";
    $htext .= _("You may change this designation in the module admin page, by clicking on the alert icon in the top right hand corner of the page.") . "\n";
    // clear email flag
    $nt->delete('freepbx', 'NOEMAIL');
    //list_signature_unsigned
    // set to false, if no updates are needed then it will not be
    // set to true and no email will go out even though the hash
    // may have changed.
    //
    if (FreePBX::Config()->get('SEND_UNSIGNED_EMAILS_NOTIFICATIONS')) {
        $send_email = false;
        $unsigned = $nt->list_signature_unsigned();
        if (count($unsigned)) {
            $send_email = true;
            $text = $htext;
            $text .= _("UNSIGNED MODULES NOTICE:") . "\n\n";
            foreach ($unsigned as $item) {
                $text .= $item['display_text'] . "\n";
                $text .= $item['extended_text'] . "\n\n";
            }
        }
        $text .= "\n\n";
        if ($send_email && !$cm->check_hash('update_sigemail', $text)) {
            $cm->save_hash('update_sigemail', $text);
            if (chron_scheduler_send_message($email, $from_email, sprintf(_("%s: New Unsigned Modules Notifications (%s)"), $brand, $mid), $text)) {
예제 #30
0
파일: groups.php 프로젝트: casvcasv/userman
													</div>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-md-12">
												<span id="group_users-help" class="help-block fpbx-help-block"><?php 
echo _("Which users are in this group");
?>
</span>
											</div>
										</div>
									</div>
								</div>
								<?php 
if (\FreePBX::Config()->get('AUTHTYPE') == "usermanager") {
    ?>
									<div role="tabpanel" class="tab-pane display" id="pbx">
										<div class="element-container">
											<div class="row">
												<div class="col-md-12">
													<div class="row">
														<div class="form-group">
															<div class="col-md-3">
																<label class="control-label" for="pbx_login"><?php 
    echo sprintf(_('Allow %s Administration Login'), $brand);
    ?>
</label>
																<i class="fa fa-question-circle fpbx-help-icon" data-for="pbx_login"></i>
															</div>
															<div class="col-md-9 radioset">