Exemplo n.º 1
0
 /**
  * Get supported HTML5 formats
  * @return array Return array of formats
  */
 public function getSupportedHTML5Formats()
 {
     $browser = $this->detectSupportedFormats();
     $formats = $this->getSupportedFormats();
     $html5 = array("oga", "mp3", "m4a", "wav");
     $final = array();
     $missing = array();
     $unsupported = array();
     foreach ($html5 as $i) {
         if (in_array($i, $browser) && in_array($i, $formats['out'])) {
             $final[] = $i;
         } elseif (in_array($i, $browser) && !in_array($i, $formats['out'])) {
             $missing[] = $i;
         } else {
             $unsupported[] = $i;
         }
     }
     $nt = notifications::create();
     $mmm = $this->getConfig('mediamissingmessage');
     if (!empty($missing) && empty($mmm)) {
         $brand = $this->FreePBX->Config->get("DASHBOARD_FREEPBX_BRAND");
         $nt->add_notice("framework", "missing_html5", _("Missing HTML5 format converters"), sprintf(_("You are missing support for the following HTML5 codecs: %s. To fully support HTML5 browser playback you will need to install programs that can not be distributed with %s. If you'd like to install the binaries needed for these conversions click 'Resolve' in the lower left corner of this message. You can also safely ignore this message but browser playback might not work in your browser."), implode(",", $missing), $brand), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries", true, true);
         $this->setConfig('mediamissingmessage', true);
     } elseif (empty($missing) && !empty($mmm)) {
         $nt->delete("framework", "missing_html5");
         $this->setConfig('mediamissingmessage', false);
     }
     return !empty($final[0]) ? array($final[0]) : array();
 }
Exemplo n.º 2
0
 function __construct($mode = 'local')
 {
     if ($mode == 'local') {
         //Setup our objects for use
         //FreePBX is the FreePBX Object
         $this->FreePBX = \FreePBX::create();
         //UCP is the UCP Specific Object from BMO
         $this->Ucp = $this->FreePBX->Ucp;
         //System Notifications Class
         //TODO: pull this from BMO
         $this->notifications = \notifications::create();
         //database subsystem
         $this->db = $this->FreePBX->Database;
         //This causes crazy errors later on. Dont use it
         //$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     }
     $this->emoji = new Client(new Ruleset());
     $this->emoji->imagePathPNG = 'assets/images/emoji/png/';
     // defaults to jsdelivr's free CDN
     $this->emoji->imagePathSVG = 'assets/images/emoji/svg/';
     // defaults to jsdelivr's free CDN
     $this->detect = new \Mobile_Detect();
     // Ensure the local object is available
     self::$uobj = $this;
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $args = $input->getArgument('args');
     $nt = \notifications::create();
     if ($input->getOption('list')) {
         $notifications = array();
         foreach ($nt->list_all() as $notif) {
             $notifications[] = array($notif['module'], $notif['id'], $notif['display_text']);
         }
         if ($input->getOption('json')) {
             $output->writeln(json_encode($notifications));
         } else {
             $table = new Table($output);
             $table->setHeaders(array('Module', 'ID', 'Text'))->setRows($notifications);
             $table->render();
         }
     }
     if ($input->getOption('delete')) {
         if (!isset($args[1])) {
             $output->writeln("Usage: fwconsole notifications --delete module id");
         }
         if ($nt->exists($args[0], $args[1])) {
             $output->writeln("Deleting notification");
             $nt->delete($args[0], $args[1]);
             if (!$nt->exists($args[0], $args[1])) {
                 $output->writeln("Notification Deleted");
             } else {
                 $output->writeln("Notification did not delete");
             }
         } else {
             $output->writeln("Specified notification does not exist");
         }
     }
 }
Exemplo n.º 4
0
function weakpasswords_get_config($engine)
{
    switch ($engine) {
        case "asterisk":
            // Clear all weak password notifications
            $nt = notifications::create($db);
            $security_notifications = $nt->list_security();
            foreach ($security_notifications as $notification) {
                if ($notification['module'] == "weakpasswords") {
                    $nt->delete($notification['module'], $notification['id']);
                }
            }
            // Generate new notifications
            $weak = weakpasswords_get_users();
            if (sizeof($weak) > 0) {
                $extended_text = _("Warning: The use of weak SIP/IAX passwords can compromise this system resulting in toll theft of your telephony service.  You should change the reported devices and trunks to use strong secrets.") . "<br /><br />";
                $count = 0;
                foreach ($weak as $details) {
                    $extended_text .= sprintf(_("%s: %s / %s<br>"), $details['deviceortrunk'], $details['name'], $details['message']);
                    $count++;
                }
                if ($count == 1) {
                    $nt->add_security("weakpasswords", "all", $count . " " . _("extension/trunk has weak secret"), $extended_text);
                } else {
                    $nt->add_security("weakpasswords", "all", $count . " " . _("extensions/trunks have weak secrets"), $extended_text);
                }
            }
            break;
    }
}
Exemplo n.º 5
0
function fatal($text, $extended_text = "", $type = "FATAL")
{
    global $db;
    echo "[{$type}] " . $text . " " . $extended_text . "\n";
    if (!DB::isError($db)) {
        $nt = notifications::create($db);
        $nt->add_critical('cron_manager', $type, $text, $extended_text);
    }
    exit(1);
}
Exemplo n.º 6
0
 public static function installed()
 {
     $loc = fpbx_which("sox");
     $process = new Process($loc . ' --version');
     $process->run();
     // executes after the command finishes
     $nt = \notifications::create();
     if (!$process->isSuccessful()) {
         $nt->add_warning("FRAMEWORK", "MISSING_SOX", _("System is missing SOX"), _("To perform the minimal amount of file conversions for HTML5 support and conversion support you need to at least install SOX"), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries");
         return false;
     } else {
         $nt->delete("FRAMEWORK", "MISSING_SOX");
     }
     return true;
 }
Exemplo n.º 7
0
function frameworkPasswordCheck()
{
    global $amp_conf, $db;
    $nt = notifications::create($db);
    // Moved most of the other checks to retrieve_conf to avoid running every page load. These have been left
    // here becuase both of these settings could be affected differently in the php apache related settings vs.
    // what retrieve_conf would see running the CLI version of php
    //
    // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not
    //
    if (get_magic_quotes_gpc()) {
        $nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption"));
    } else {
        $nt->delete('core', 'MQGPC');
    }
}
Exemplo n.º 8
0
 function __construct($mode = 'local')
 {
     if ($mode == 'local') {
         //Setup our objects for use
         //FreePBX is the FreePBX Object
         $this->FreePBX = \FreePBX::create();
         //UCP is the UCP Specific Object from BMO
         $this->Ucp = $this->FreePBX->Ucp;
         //System Notifications Class
         //TODO: pull this from BMO
         $this->notifications = \notifications::create();
         //database subsystem
         $this->db = $this->FreePBX->Database;
         //This causes crazy errors later on. Dont use it
         //$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     }
     $this->detect = new \Mobile_Detect();
     // Ensure the local object is available
     self::$obj = $this;
 }
Exemplo n.º 9
0
 /**
  * Check and/or update all certificates
  *
  * If a certificate can't be automatically updated add a notice in the interface
  *
  * @return [type] [description]
  */
 public function checkUpdateCertificates()
 {
     $certs = $this->getAllManagedCertificates();
     $messages = array();
     foreach ($certs as $cert) {
         $cert = $this->getAdditionalCertDetails($cert);
         if (empty($cert['files'])) {
             //there are no files so delete this one
             $this->removeCertificate($cert['cid']);
             $messages[] = array('type' => 'danger', 'message' => sprintf(_('There were no files left for certificate "%s" so it was removed'), $cert['basename']));
             continue;
         }
         $validTo = $cert['info']['crt']['validTo_time_t'];
         $renewafter = $validTo - 86400 * 30;
         $update = false;
         if (time() > $validTo) {
             if ($cert['type'] == 'le') {
                 try {
                     $this->updateLE($cert['info']['crt']['subject']['CN']);
                     $messages[] = array('type' => 'success', 'message' => sprintf(_('Successfully updated certificate named "%s"'), $cert['basename']));
                     $this->FreePBX->astman->Reload();
                     //Until https://issues.asterisk.org/jira/browse/ASTERISK-25966 is fixed
                     $a = fpbx_which("asterisk");
                     if (!empty($a)) {
                         exec($a . " -rx 'dialplan reload'");
                     }
                     $update = true;
                 } catch (\Exception $e) {
                     $messages[] = array('type' => 'danger', 'message' => sprintf(_('There was an error updating certificate "%s": %s'), $cert['basename'], $e->getMessage()));
                     continue;
                 }
             } else {
                 $messages[] = array('type' => 'warning', 'message' => sprintf(_('Certificate named "%s" has expired. Please update this certificate in Certificate Manager'), $cert['basename']));
                 continue;
             }
         } elseif (time() > $renewafter) {
             if ($cert['type'] == 'le') {
                 try {
                     $this->updateLE($cert['info']['crt']['subject']['CN']);
                     $messages[] = array('type' => 'success', 'message' => sprintf(_('Successfully updated certificate named "%s"'), $cert['basename']));
                     $this->FreePBX->astman->Reload();
                     //Until https://issues.asterisk.org/jira/browse/ASTERISK-25966 is fixed
                     $a = fpbx_which("asterisk");
                     if (!empty($a)) {
                         exec($a . " -rx 'dialplan reload'");
                     }
                     $update = true;
                 } catch (\Exception $e) {
                     $messages[] = array('type' => 'danger', 'message' => sprintf(_('There was an error updating certificate "%s": %s'), $cert['basename'], $e->getMessage()));
                     continue;
                 }
             } else {
                 $messages[] = array('type' => 'warning', 'message' => sprintf(_('Certificate named "%s" is going to expire in less than a month. Please update this certificate in Certificate Manager'), $cert['basename']));
                 continue;
             }
         } else {
             $messages[] = array('type' => 'success', 'message' => sprintf(_('Certificate named "%s" is valid'), $cert['basename']));
         }
         //trigger hook
         $this->updateCertificate($cert, $cert['description']);
     }
     $nt = \notifications::create();
     $notification = '';
     foreach ($messages as $m) {
         switch ($m['type']) {
             case "warning":
             case "danger":
                 $notification .= $m['message'] . "</br>";
                 break;
         }
     }
     if (!empty($notification)) {
         $nt->add_security("certman", "EXPIRINGCERTS", _("Some Certificates are expiring or have expired"), $notification, "config.php?display=certman", true, true);
     }
     if ($update) {
         $nt->add_security("certman", "UPDATEDCERTS", _("Updated Certificates"), _("Some SSL/TLS Certificates have been automatically updated. You may need to ensure all services have the correctly update certificate by restarting PBX services"), "", true, true);
     }
     return $messages;
 }
Exemplo n.º 10
0
/**
 * Update AMI credentials in manager.conf
 *
 * @author Philippe Lindheimer
 * @pram mixed $user false means don't change
 * @pram mixed $pass password false means don't change
 * @pram mixed $writetimeout false means don't change
 * @returns boolean
 *
 * allows FreePBX to update the manager credentials primarily used by Advanced Settings and Backup and Restore.
 */
function fpbx_ami_update($user = false, $pass = false, $writetimeout = false)
{
    global $amp_conf, $astman, $db, $bootstrap_settings;
    $conf_file = $amp_conf['ASTETCDIR'] . '/manager.conf';
    $ret = $ret2 = $ret3 = 0;
    $output = array();
    if (strpos($amp_conf['ASTETCDIR'], "..") === false && !file_exists($conf_file)) {
        return;
    }
    if ($user !== false && $user != '') {
        $sed_arg = escapeshellarg('s/\\s*\\[general\\].*$/TEMPCONTEXT/;s/\\[.*\\]/\\[' . $amp_conf['AMPMGRUSER'] . '\\]/;s/^TEMPCONTEXT$/\\[general\\]/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output, $ret);
        if ($ret) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI user to [%s], internal failure details follow:"), $amp_conf['AMPMGRUSER']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($pass !== false && $pass != '') {
        unset($output);
        $sed_arg = escapeshellarg('s/secret\\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output2, $ret2);
        if ($ret2) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI password to [%s], internal failure details follow:"), $amp_conf['AMPMGRPASS']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
        // We've changed the password, let's update the notification
        //
        $nt = notifications::create($db);
        $freepbx_conf =& freepbx_conf::create();
        if ($amp_conf['AMPMGRPASS'] == $freepbx_conf->get_conf_default_setting('AMPMGRPASS')) {
            if (!$nt->exists('core', 'AMPMGRPASS')) {
                $nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password"));
            }
        } else {
            $nt->delete('core', 'AMPMGRPASS');
        }
    }
    //attempt to set writetimeout
    unset($output);
    if ($writetimeout) {
        $sed_arg = escapeshellarg('s/writetimeout\\s*=.*$/writetimeout = ' . $amp_conf['ASTMGRWRITETIMEOUT'] . '/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output3, $ret3);
        if ($ret3) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI writetimout to [%s], internal failure details follow:"), $amp_conf['ASTMGRWRITETIMEOUT']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($ret || $ret2 || $ret3) {
        dbug("aborting early because previous errors");
        return false;
    }
    if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
        $ast_ret = $astman->Command('module reload manager');
    } else {
        unset($output);
        dbug("no astman connection so trying to force through linux command line");
        exec(fpbx_which('asterisk') . " -rx 'module reload manager'", $output, $ret2);
        if ($ret2) {
            freepbx_log(FPBX_LOG_ERROR, _("Failed to reload AMI, manual reload will be necessary, try: [asterisk -rx 'module reload manager']"));
        }
    }
    if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
        $astman->disconnect();
    }
    if (!is_object($astman) || !method_exists($astman, "connected")) {
        //astman isn't initiated so escape
        return true;
    }
    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
        freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed");
    } else {
        $bmo = FreePBX::create();
        $bmo->astman = $astman;
    }
    return true;
}
Exemplo n.º 11
0
function voicemail_mailbox_remove($mbox)
{
    global $amp_conf;
    $uservm = voicemail_getVoicemail();
    $vmcontexts = array_keys($uservm);
    $return = true;
    foreach ($vmcontexts as $vmcontext) {
        if (isset($uservm[$vmcontext][$mbox])) {
            $vm_dir = $amp_conf['ASTSPOOLDIR'] . "/voicemail/{$vmcontext}/{$mbox}";
            exec("rm -rf {$vm_dir}", $output, $ret);
            if ($ret) {
                $return = false;
                $text = sprintf(_("Failed to delete vmbox: %s@%s"), $mbox, $vmcontext);
                $etext = sprintf(_("failed with retcode %s while removing %s:"), $ret, $vm_dir) . "<br>";
                $etext .= implode("<br>", $output);
                $nt =& notifications::create($db);
                $nt->add_error('voicemail', 'MBOXREMOVE', $text, $etext, '', true, true);
                //
                // TODO: this does not work but we should give some sort of feedback that id did not work
                //
                // echo "<script>javascript:alert('$text\n"._("See notification panel for details")."')</script>";
            }
        }
    }
    return $return;
}
Exemplo n.º 12
0
    }
}
if (isset($no_auth) && empty($display)) {
    $display = 'noauth';
}
// handle special requests
if (!in_array($display, array('noauth', 'badrefer')) && isset($_REQUEST['handler'])) {
    $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
    $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
    fileRequestHandler($_REQUEST['handler'], $module, $file);
    exit;
}
if (!$quietmode) {
    $modulef = module_functions::create();
    $modulef->run_notification_checks();
    $nt = notifications::create();
    if (!isset($_SERVER['HTACCESS']) && preg_match("/apache/i", $_SERVER['SERVER_SOFTWARE'])) {
        // No .htaccess support
        if (!$nt->exists('framework', 'htaccess')) {
            $nt->add_security('framework', 'htaccess', _('.htaccess files are disable on this webserver. Please enable them'), sprintf(_("To protect the integrity of your server, you must allow overrides in your webserver's configuration file for the User Control Panel. For more information see: %s"), '<a href="http://wiki.freepbx.org/display/F2/Webserver+Overrides">http://wiki.freepbx.org/display/F2/Webserver+Overrides</a>'), "http://wiki.freepbx.org/display/F2/Webserver+Overrides");
        }
    } elseif (!preg_match("/apache/i", $_SERVER['SERVER_SOFTWARE'])) {
        $sql = "SELECT value FROM admin WHERE variable = 'htaccess'";
        $sth = FreePBX::Database()->prepare($sql);
        $sth->execute();
        $o = $sth->fetch();
        if (empty($o)) {
            if ($nt->exists('framework', 'htaccess')) {
                $nt->delete('framework', 'htaccess');
            }
            $nt->add_warning('framework', 'htaccess', _('.htaccess files are not supported on this webserver.'), sprintf(_("htaccess files help protect the integrity of your server. Please make sure file paths and directories are locked down properly. For more information see: %s"), '<a href="http://wiki.freepbx.org/display/F2/Webserver+Overrides">http://wiki.freepbx.org/display/F2/Webserver+Overrides</a>'), "http://wiki.freepbx.org/display/F2/Webserver+Overrides", true, true);
Exemplo n.º 13
0
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     // legacy but in case someone was using this we will leave it
     //
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if (DB::IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         foreach ($results2 as $keyword => $data) {
             if ($ver12) {
                 switch ($keyword) {
                     case 'ringinuse':
                     case 'autofill':
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             } else {
                 switch ($keyword) {
                     case trim($data) == '':
                     case 'monitor-join':
                         break;
                     case 'monitor-format':
                         if (strtolower($data) != 'no') {
                             $output .= "monitor-type=mixmonitor\n";
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'announce-position':
                         if ($ver16) {
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             }
         }
         // Now pull out all the memebers, one line for each
         //
         if ($amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = $users[$matches[1]];
                     str_replace(',', '\\,', $name);
                     $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = $users[$matches[1]];
                         str_replace(',', '\\,', $name);
                         $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _("Warning, there are compound recordings configured in one or more Queue configurations. Queues can not play these so they have been truncated to the first sound file. You should correct this problem.<br />Details:<br /><br />");
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
Exemplo n.º 14
0
function general_generate_indications()
{
    global $db;
    global $amp_conf;
    $notify =& notifications::create($db);
    $country = $amp_conf['TONEZONE'];
    $filename = $amp_conf['ASTETCDIR'] . "/indications.conf";
    $zonelist = core_indications_get($country);
    $fd = fopen($filename, "w");
    if (empty($zonelist) || $fd === false) {
        $desc = sprintf(_("Failed to open %s for writing, aborting attempt to write the country indications. The file may be readonly or the permissions may be incorrect."), $filename);
        $notify->add_error('core', 'INDICATIONS', _("Failed to write indications.conf"), $desc);
        return;
    }
    $notify->delete('core', 'INDICATIONS');
    $indication_warning = ";--------------------------------------------------------------------------------;\n; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;\n; this file must be done via the web gui.                                        ;\n;--------------------------------------------------------------------------------;\n\n";
    fwrite($fd, $indication_warning);
    fwrite($fd, "[general]\ncountry=" . $country . "\n\n[" . $country . "]\n");
    fwrite($fd, "description = {$zonelist['name']}\n");
    fwrite($fd, "{$zonelist['conf']}\n\n");
    fclose($fd);
}
Exemplo n.º 15
0
 /** run_jobs()
  *  select all entries that need to be run now and run them, then update the times.
  *  
  *  1. select all entries
  *  2. foreach entry, if its paramters indicate it should be run, then run it and
  *     update it was run in the time stamp.
  */
 function run_jobs()
 {
     $errors = 0;
     $error_arr = array();
     $now = time();
     $jobs = sql("SELECT * FROM cronmanager", "getAll", DB_FETCHMODE_ASSOC);
     foreach ($jobs as $job) {
         $nexttime = $job['lasttime'] + $job['freq'] * 3600;
         if ($nexttime <= $now) {
             if ($job['time'] >= 0 && $job['time'] < 24) {
                 $date_arr = getdate($now);
                 // Now if lasttime is 0, then we want this kicked off at the proper hour
                 // after wich the frequencey will set the pace for same time each night
                 //
                 if ($date_arr['hours'] != $job['time'] && !$job['lasttime']) {
                     continue;
                 }
             }
         } else {
             // no need to run job, time is not up yet
             continue;
         }
         // run the job
         exec($job['command'], $job_out, $ret);
         if ($ret) {
             $errors++;
             $error_arr[] = array($job['command'], $ret);
             // If there where errors, let's print them out in case the script is being debugged or running
             // from cron which will then put the errors out through the cron system.
             //
             foreach ($job_out as $line) {
                 echo $line . "\n";
             }
         } else {
             $module = $job['module'];
             $id = $job['id'];
             $sql = "UPDATE cronmanager SET lasttime = {$now} WHERE module = '{$module}' AND id = '{$id}'";
             sql($sql);
         }
     }
     if ($errors) {
         $nt =& notifications::create($db);
         $text = sprintf(_("Cronmanager encountered %s Errors"), $errors);
         $extext = _("The following commands failed with the listed error");
         foreach ($error_arr as $item) {
             $extext .= "<br />" . $item[0] . " (" . $item[1] . ")";
         }
         $nt->add_error('cron_manager', 'EXECFAIL', $text, $extext, '', true, true);
     }
 }
Exemplo n.º 16
0
function general_generate_indications()
{
    global $db;
    global $asterisk_conf;
    $notify =& notifications::create($db);
    $sql = "SELECT value FROM globals WHERE variable='TONEZONE'";
    $result = $db->getRow($sql, DB_FETCHMODE_ASSOC);
    $filename = isset($asterisk_conf["astetcdir"]) && $asterisk_conf["astetcdir"] != '' ? rtrim($asterisk_conf["astetcdir"], DIRECTORY_SEPARATOR) : "/etc/asterisk";
    $filename .= "/indications.conf";
    if (($fd = fopen($filename, "w")) === false) {
        $desc = sprintf(_("Failed to open %s for writing, aborting attempt to write the country indications. The file may be readonly or the permissions may be incorrect."), $filename);
        $notify->add_error('core', 'INDICATIONS', _("Failed to write indications.conf"), $desc);
        return;
    }
    $notify->delete('core', 'INDICATIONS');
    $country = $result['value'];
    $indication_warning = ";--------------------------------------------------------------------------------;\n; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;\n; this file must be done via the web gui.                                        ;\n;--------------------------------------------------------------------------------;\n\n";
    fwrite($fd, $indication_warning);
    fwrite($fd, "[general]\ncountry=" . $country . "\n\n[" . $country . "]\n");
    $zonelist = general_get_zonelist();
    foreach ($zonelist as $key => $value) {
        if ($value['iso'] == $country) {
            fwrite($fd, "description = {$value['name']}\n");
            fwrite($fd, "{$value['conf']}\n\n");
        }
    }
    fclose($fd);
}
Exemplo n.º 17
0
/**
 * Update AMI credentials in manager.conf
 *
 * @author Philippe Lindheimer
 * @pram mixed $user false means don't change
 * @pram mixed $pass password false means don't change
 * @pram mixed $writetimeout false means don't change
 * @returns boolean
 *
 * allows FreePBX to update the manager credentials primarily used by Advanced Settings and Backup and Restore.
 */
function fpbx_ami_update($user = false, $pass = false, $writetimeout = false)
{
    global $amp_conf, $astman;
    $conf_file = $amp_conf['ASTETCDIR'] . '/manager.conf';
    $ret = $ret2 = 0;
    $output = array();
    if ($user !== false && $user != '') {
        exec('sed -i.bak "s/\\s*\\[general\\].*$/TEMPCONTEXT/;s/\\[.*\\]/\\[' . $amp_conf['AMPMGRUSER'] . '\\]/;s/^TEMPCONTEXT$/\\[general\\]/" ' . $conf_file, $output, $ret);
        if ($ret) {
            dbug($output);
            dbug($ret);
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI user to [%s], internal failure details follow:"), $amp_conf['AMPMGRUSER']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($pass !== false && $pass != '') {
        unset($output);
        exec('sed -i.bak "s/secret\\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/" ' . $conf_file, $output, $ret2);
        if ($ret2) {
            dbug($output);
            dbug($ret2);
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI password to [%s], internal failure details follow:"), $amp_conf['AMPMGRPASS']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
        // We've changed the password, let's update the notification
        //
        $nt = notifications::create($db);
        $freepbx_conf =& freepbx_conf::create();
        if ($amp_conf['AMPMGRPASS'] == $freepbx_conf->get_conf_default_setting('AMPMGRPASS')) {
            if (!$nt->exists('core', 'AMPMGRPASS')) {
                $nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password"));
            }
        } else {
            $nt->delete('core', 'AMPMGRPASS');
        }
    }
    //attempt to set writetimeout
    unset($output);
    if ($writetimeout) {
        exec('sed -i.bak "s/writetimeout\\s*=.*$/writetimeout = ' . $amp_conf['ASTMGRWRITETIMEOUT'] . '/" ' . $conf_file, $output, $ret3);
        if ($ret3) {
            dbug($output);
            dbug($ret3);
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI writetimout to [%s], internal failure details follow:"), $amp_conf['ASTMGRWRITETIMEOUT']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($ret || $ret2 || $ret3) {
        dbug("aborting early because previous errors");
        return false;
    }
    if (!empty($astman)) {
        $ast_ret = $astman->Command('module reload manager');
    } else {
        unset($output);
        dbug("no astman connection so trying to force through linux command line");
        exec(fpbx_which('asterisk') . " -rx 'module reload manager'", $output, $ret2);
        if ($ret2) {
            dbug($output);
            dbug($ret2);
            freepbx_log(FPBX_LOG_ERROR, _("Failed to reload AMI, manual reload will be necessary, try: [asterisk -rx 'module reload manager']"));
        }
    }
    return true;
}
Exemplo n.º 18
0
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     $ast_ge_18 = version_compare($ast_version, '1.8', 'ge');
     $ast_ge_120 = version_compare($ast_version, '12', 'ge');
     // legacy but in case someone was using this we will leave it
     //TODO: abstract getters/setters from business logic
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if ($db->IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         if (empty($results2['context'])) {
             $results2['context'] = "";
         }
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         // Queues cannot control their own recordings, it must now be
         // done through sub-record-check
         unset($results2['monitor-format']);
         unset($results2['recording']);
         //Unset Old commands Resolves FREEPBX-8610.
         unset($results2['monitor-join']);
         unset($results2['answered_elsewhere']);
         unset($results2['skip_joinannounce']);
         //These items still exist for backwards compatibility but are useless in 12+
         if ($ast_ge_120) {
             unset($results2['eventwhencalled']);
             unset($results2['eventmemberstatus']);
         }
         foreach ($results2 as $keyword => $data) {
             if (trim($data) == '' && $keyword != "context" || substr($keyword, 0, 4) == "cron") {
                 // Skip anything that's empty or not required
                 continue;
             }
             // Some old commands have been removed. Make sure we
             // don't add them.
             switch ($keyword) {
                 case 'monitor-join':
                 case 'answered_elsewhere':
                 case 'skip_joinannounce':
                     continue;
                     break;
                 case 'music':
                     $keyword = 'musicclass';
                     break;
             }
             if ($keyword == "retry" && $data == "none") {
                 $data = 0;
             }
             $output .= $keyword . "=" . $data . "\n";
         }
         // Now pull out all the memebers, one line for each
         //
         if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = sprintf('"%s"', $users[$matches[1]]);
                     //str_replace(',','\,',$name);
                     $qnostate = queues_get_qnostate($matches[1]);
                     if ($qnostate == 'ignorestate') {
                         freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                         $output .= "member={$member},{$name}\n";
                     } else {
                         $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                     }
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = sprintf('"%s"', $users[$matches[1]]);
                         //str_replace(',','\,',$name);
                         $qnostate = queues_get_qnostate($matches[1]);
                         if ($qnostate == 'ignorestate') {
                             freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                             $output .= "member={$member},{$name}\n";
                         } else {
                             $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                         }
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         if (isset($this->_queues_additional[$result[0]])) {
             foreach ($this->_queues_additional[$result[0]] as $qsetting) {
                 $output .= $qsetting['key'] . "=" . $qsetting['value'] . "\n";
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _('Warning, there are compound recordings configured in ' . 'one or more Queue configurations. Queues can not play these ' . 'so they have been truncated to the first sound file. You ' . 'should correct this problem.<br />Details:<br /><br />');
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
Exemplo n.º 19
0
<?php

global $amp_conf;
include_once $amp_conf['AMPWEBROOT'] . '/admin/libraries/freepbx_conf.class.php';
include_once $amp_conf['AMPWEBROOT'] . '/admin/libraries/notifications.class.php';
include_once $amp_conf['AMPWEBROOT'] . '/admin/libraries/moduleHook.class.php';
include_once $amp_conf['AMPWEBROOT'] . '/admin/libraries/modulelist.class.php';
include_once $amp_conf['AMPWEBROOT'] . '/admin/libraries/module.functions.php';
$freepbx_conf =& freepbx_conf::create();
$notify = notifications::create($db);
// Remove fop noitications if present since no longer supported
//
$notify->delete('freepbx', 'reload_fop');
// Remove FOP settings no longer used, and buffering_callback
//
$remove_settings = array('FOPDISABLE', 'FOPRUN', 'buffering_callback');
$freepbx_conf->remove_conf_settings($remove_settings);
unset($remove_settings);
// FOPPASSWORD was set hidden at some point which breaks things, so fix it here
// if it is present
//
if ($freepbx_conf->conf_setting_exists('FOPPASSWORD')) {
    unset($set);
    $set['hidden'] = 0;
    $set['value'] = $freepbx_conf->get_conf_setting('FOPPASSWORD');
    $freepbx_conf->define_conf_setting('FOPPASSWORD', $set);
    // comitted below
}
//move freepbx debug log
if ($freepbx_conf->conf_setting_exists('FPBXDBUGFILE')) {
    $freepbx_conf->set_conf_values(array('FPBXDBUGFILE' => $amp_conf['ASTLOGDIR'] . '/freepbx_dbug'), true);
Exemplo n.º 20
0
function module_run_notification_checks()
{
    global $db;
    $modules_needup = module_getinfo(false, MODULE_STATUS_NEEDUPGRADE);
    $modules_broken = module_getinfo(false, MODULE_STATUS_BROKEN);
    $notifications =& notifications::create($db);
    if ($cnt = count($modules_needup)) {
        $text = $cnt > 1 ? sprintf(_('You have %s disabled modules'), $cnt) : _('You have a disabled module');
        $desc = _('The following modules are disabled because they need to be upgraded:') . "\n" . implode(", ", array_keys($modules_needup));
        $desc .= "\n\n" . _('You should go to the module admin page to fix these.');
        $notifications->add_error('freepbx', 'modules_disabled', $text, $desc, '?type=tool&display=modules');
    } else {
        $notifications->delete('freepbx', 'modules_disabled');
    }
    if ($cnt = count($modules_broken)) {
        $text = $cnt > 1 ? sprintf(_('You have %s broken modules'), $cnt) : _('You have a broken module');
        $desc = _('The following modules are disabled because they are broken:') . "\n" . implode(", ", array_keys($modules_broken));
        $desc .= "\n\n" . _('You should go to the module admin page to fix these.');
        $notifications->add_critical('freepbx', 'modules_broken', $text, $desc, '?type=tool&display=modules', false);
    } else {
        $notifications->delete('freepbx', 'modules_broken');
    }
}
Exemplo n.º 21
0
/**
 * Create admin user & email address
 *
 */
function framework_obe_intialize_admin($username, $password, $confirm_password, $email, $confirm_email)
{
    $freepbx_conf =& freepbx_conf::create();
    //create admin user
    framework_add_amp_admin($username, $password);
    //set ari password
    if ($freepbx_conf->conf_setting_exists('ARI_ADMIN_USERNAME') && $freepbx_conf->conf_setting_exists('ARI_ADMIN_PASSWORD')) {
        $freepbx_conf->set_conf_values(array('ARI_ADMIN_USERNAME' => $username, 'ARI_ADMIN_PASSWORD' => $password), true);
        if ($freepbx_conf->get_last_update_status != $freepbx_conf->get_conf_default_setting('ARI_ADMIN_PASSWORD')) {
            $nt = notifications::create($db);
            $nt->delete('ari', 'ARI_ADMIN_PASSWORD');
        }
        $nt->delete('freepbx', 'NEWMODS');
    }
    //set email address
    $cm =& cronmanager::create($db);
    $cm->save_email($email);
}
Exemplo n.º 22
0
function fax_get_destinations()
{
    global $db;
    $sql = "SELECT fax_users.user,fax_users.faxemail,fax_users.faxattachformat FROM fax_users where fax_users.faxenabled = 'true' ORDER BY fax_users.user";
    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
    if (DB::IsError($results)) {
        die_freepbx($results->getMessage() . "<br><br>Error selecting from fax");
    }
    $final = array();
    $warning = array();
    foreach ($results as $res) {
        $o = \FreePBX::Userman()->getUserByID($res['user']);
        if (!empty($o)) {
            if (empty($o['email'])) {
                $warning[] = $o['username'];
                continue;
            }
            $res['uname'] = $o['username'];
            $res['name'] = !empty($o['displayname']) ? $o['displayname'] : $o['fname'] . " " . $o['lname'];
            $res['name'] = trim($res['name']);
            $res['name'] = !empty($res['name']) ? $res['name'] : $o['username'];
            $final[] = $res;
        }
    }
    $nt = \notifications::create();
    if (!empty($warning)) {
        $nt->add_warning("fax", "invalid_email", _("Invalid Email for Inbound Fax"), sprintf(_("User Manager users '%s' have the ability to receive faxes but have no email address defined so they will not be able to receive faxes."), implode(",", $warning)), "", true, true);
    } else {
        $nt->delete("fax", "invalid_email");
    }
    return $final;
}
Exemplo n.º 23
0
#!/usr/bin/php -q
<?php 
//include bootstrap
//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2013-2015 Schmooze Com Inc.
//
$bootstrap_settings['freepbx_auth'] = false;
if (!@(include_once getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
    include_once '/etc/asterisk/freepbx.conf';
}
// Define the notification class for logging to the dashboard
//
$nt = notifications::create($db);
// Check to see if email should be sent
//
$cm =& cronmanager::create($db);
$cm->run_jobs();
//If we have sysadmin installed
$from_email = get_current_user() . '@' . gethostname();
if (function_exists('sysadmin_get_storage_email')) {
    $emails = sysadmin_get_storage_email();
    //Check that what we got back above is a email address
    if (!empty($emails['fromemail']) && filter_var($emails['fromemail'], FILTER_VALIDATE_EMAIL)) {
        //Fallback address
        $from_email = $emails['fromemail'];
    }
}
//Send email with our mail class
function chron_scheduler_send_message($to, $from, $subject, $message)
{
    $em = new \CI_Email();
Exemplo n.º 24
0
 /**
  * Hook Definitions
  * @param {string} $conf The Configuration being passed through
  */
 public function writeConfig($conf)
 {
     //we also need to do port checking and if in chan sip mode port on 5060, if in both mode then put if on 5061
     $nt = \notifications::create();
     $ast_sip_driver = $this->freepbx->Config->get_conf_setting('ASTSIPDRIVER');
     if (version_compare($this->version, '12', 'ge')) {
         if ($ast_sip_driver == 'both') {
             $this->freepbx->ModulesConf->removenoload("chan_sip.so");
             foreach ($this->PJSipModules as $mod) {
                 $this->freepbx->ModulesConf->removenoload($mod);
             }
         } elseif ($ast_sip_driver == 'chan_pjsip') {
             $this->enablePJSipModules();
         } elseif ($ast_sip_driver == 'chan_sip') {
             $this->disablePJSipModules();
         }
     } else {
         // We don't support pjsip. If we're trying to use it, don't. Note
         // that if there are devices or trunks trying to use chan_pjsip, we
         // complain loudly about it core_devices_configpageload
         if ($ast_sip_driver == 'chan_pjsip' || $ast_sip_driver == 'both') {
             $this->freepbx->Config->set_conf_values(array('ASTSIPDRIVER' => 'chan_sip'), true, true);
         }
     }
     $this->freepbx->WriteConfig($conf);
 }
Exemplo n.º 25
0
function do_syslog_delete()
{
    global $db;
    $notify =& notifications::create($db);
    if (isset($_REQUEST['module']) && $_REQUEST['id']) {
        var_dump($_REQUEST);
        $notify->safe_delete($_REQUEST['module'], $_REQUEST['id']);
    }
}
Exemplo n.º 26
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;
 }
Exemplo n.º 27
0
function recordings_get_or_create_id($fn, $module)
{
    $id = recordings_get_id($fn);
    if ($id != null) {
        return $id;
    } else {
        // Create the id, name it the file name or if multi-part ...
        //
        $dname = explode('&', $displayname);
        $displayname = 'auto-created: ';
        $displayname .= count($dname) == 1 ? $fn : $dname[0] . "&...";
        $description = sprintf(_("Missing Sound file auto-created from migration of %s module"), $module);
        recordings_add($displayname, $fn, $description = '');
        // get the id we just created
        //
        $id = recordings_get_id($fn);
        // Notify of issue
        //
        $nt =& notifications::create($db);
        $text = sprintf(_("Non-Existent Recording in module %s"), $module);
        $extext = sprintf(_("The %s referenced a recording file listed below that does not exists. An entry has been generated, named %s, with the referenced file(s) but you should confirm that it really works and the real files exist. The file(s) referenced: %s "), $module, $displayname, $fn);
        $nt->add_error('recordings', 'NEWREC-' . $id, $text, $extext, '', true, true);
        unset($nt);
        // return the id just created
        return $id;
    }
}
Exemplo n.º 28
0
    out(_("not needed"));
}
outn(_("Checking for retvm.."));
$sql = "SELECT retvm FROM ivr";
$check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
if (DB::IsError($check)) {
    //  Add retvm field
    //
    $sql = "ALTER TABLE ivr ADD retvm VARCHAR(8);";
    $result = $db->query($sql);
    if (DB::IsError($result)) {
        out(_("fatal error"));
        die_freepbx($result->getDebugInfo());
    } else {
        out(_("added"));
    }
} else {
    out(_("not needed"));
}
$count = sql('SELECT COUNT(*) FROM `ivr` WHERE `enable_directory` = "CHECKED"', 'getOne');
if ($count) {
    global $db;
    $notifications =& notifications::create($db);
    $extext = sprintf(_("There are %s IVRs that have the legacy Directory dialing enabled. This has been deprecated and will be removed from future releases. You should convert your IVRs to use the Directory module for this functionality and assign an IVR destination to a desired Directory. You can install the Directory module from the Online Module Repository"), $count);
    $notifications->add_notice('ivr', 'DIRECTORY_DEPRECATED', sprintf(_('Deprecated Directory used by %s IVRs'), $count), $extext, '', true, true);
    out(_("posting notice about deprecated functionality"));
}
// This used to be called from page.ivr.php every time, it should not be needed, it should
// be called once and be done with.
//
ivr_init();
Exemplo n.º 29
0
 private function createIntermediaries()
 {
     //generate intermediary file
     $ts = time() . rand(0, 1000);
     $soxClass = "Media\\Driver\\Drivers\\SoxShell";
     if (!$soxClass::installed()) {
         throw new \Exception("Sox needs to be installed");
     }
     //Convert everything to 48k, so we upscale and downscale
     //This is on purpose.
     //Transform into a wav file
     foreach ($this->getDrivers() as $driver) {
         if ($this->extension == "wav" && $driver == "AsteriskShell") {
             continue;
             //just dont allow it
         }
         $class = "Media\\Driver\\Drivers\\" . $driver;
         if ($class::installed() && $class::isCodecSupported($this->extension, "in")) {
             $d = new $class($this->track, $this->extension, $this->mime, 48000, 1, 16);
             $d->convert($this->tempDir . "/temp." . $ts . ".wav", "wav", "audio/x-wav");
             $intermediary['wav']['path'] = $this->tempDir . "/temp." . $ts . ".wav";
             $intermediary['wav']['extension'] = "wav";
             $intermediary['wav']['mime'] = "audio/x-wav";
             break;
         }
     }
     if (!isset($intermediary['wav']['path']) || !file_exists($intermediary['wav']['path'])) {
         throw new \Exception(sprintf(_("Unable to find an intermediary converter for %s"), $this->track));
     }
     //Asterisk 11 should support sln48 but it doesnt, it says it does but then complains
     //It might be a bug, regardless this is fixed in 13 people should just use it
     $ver = \FreePBX::Config()->get("ASTVERSION");
     if (version_compare_freepbx($ver, "13.0", "ge") && \Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         $type = "sln48";
         $samplerate = 48000;
     } elseif (\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln16", "in")) {
         $type = "sln16";
         $samplerate = 16000;
     } else {
         $type = "wav16";
         $samplerate = 16000;
     }
     $nt = \notifications::create();
     if (version_compare_freepbx($ver, "13.0", "ge") && !\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         //something is wacky here
         $nt->add_warning("FRAMEWORK", "UNSUPPORTED_SLN48", _("The file format sln48 is not supported on your system"), _("The file format sln48 is not supported by Asterisk when it should be. Audio conversion quality will be limited to 16k instead of 48k"));
     } else {
         $nt->delete("FRAMEWORK", "UNSUPPORTED_SLN48");
     }
     //Now transform into a raw audio file
     $d = new $soxClass($intermediary['wav']['path'], $intermediary['wav']['extension'], $intermediary['wav']['mime'], $samplerate, 1, 16);
     $d->convert($this->tempDir . "/temp." . $ts . "." . $type, $type, "audio/x-raw");
     $intermediary['sln']['path'] = $this->tempDir . "/temp." . $ts . "." . $type;
     $intermediary['sln']['extension'] = $type;
     $intermediary['sln']['mime'] = "audio/x-raw";
     if (empty($intermediary)) {
         throw new \Exception("No Driver found for " . $this->extension);
     }
     if (!file_exists($intermediary['wav']['path']) || !file_exists($intermediary['sln']['path'])) {
         throw new \Exception("Intermediary files could not be created");
     }
     return $intermediary;
 }
Exemplo n.º 30
-1
function set_language()
{
    global $amp_conf, $db;
    $nt = notifications::create($db);
    if (extension_loaded('gettext')) {
        $nt->delete('core', 'GETTEXT');
        if (php_sapi_name() !== 'cli') {
            if (empty($_COOKIE['lang']) || !preg_match('/^[\\w\\._@-]+$/', $_COOKIE['lang'], $matches)) {
                $lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
                if (empty($_COOKIE['lang'])) {
                    setcookie("lang", $lang);
                }
            } else {
                preg_match('/^([\\w\\._@-]+)$/', $_COOKIE['lang'], $matches);
                $lang = !empty($matches[1]) ? $matches[1] : 'en_US';
            }
            $_COOKIE['lang'] = $lang;
        } else {
            $lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
        }
        putenv('LC_ALL=' . $lang);
        putenv('LANG=' . $lang);
        putenv('LANGUAGE=' . $lang);
        setlocale(LC_ALL, $lang);
        bindtextdomain('amp', $amp_conf['AMPWEBROOT'] . '/admin/i18n');
        bind_textdomain_codeset('amp', 'utf8');
        textdomain('amp');
        return $lang;
    }
    $nt->add_warning('core', 'GETTEXT', _("Gettext is not installed"), _("Please install gettext so that the PBX can properly translate itself"), 'https://www.gnu.org/software/gettext/');
    return 'en_US';
}