本文整理汇总了PHP中fpbx_which函数的典型用法代码示例。如果您正苦于以下问题:PHP fpbx_which函数的具体用法?PHP fpbx_which怎么用?PHP fpbx_which使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fpbx_which函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: supportedCodecs
/**
* Query Asterisk for the supported formats
* @param array $formats Previously supported formats
* @return array Array of formats
*/
public static function supportedCodecs(&$formats)
{
if (!empty(self::$supported)) {
return self::$supported;
}
$loc = fpbx_which("asterisk");
exec($loc . " -rx 'core show file formats'", $lines, $ret);
foreach ($lines as $line) {
if (preg_match('/([a-z0-9\\|]*)$/i', $line, $matches)) {
$l = trim($matches[1]);
$codecs = explode("|", $matches[1]);
foreach ($codecs as $codec) {
if (!in_array($codec, array('gsm', 'g722', 'alaw', 'ulaw', 'sln', 'wav16', 'WAV', 'sln12', 'sln16', 'sln24', 'sln32', 'sln44', 'sln48', 'sln96', 'sln192'))) {
continue;
}
$formats["in"][$codec] = $codec;
$formats["out"][$codec] = $codec;
}
}
}
$lines = null;
exec($loc . " -rx 'g729 show licenses'", $lines, $ret);
foreach ($lines as $line) {
if (preg_match('/licensed channels are currently in use/', $line)) {
$formats["in"]['g729'] = 'g729';
$formats["out"]['g729'] = 'g729';
}
}
$formats["out"]["wav"] = "wav";
$formats["out"]["WAV"] = "WAV";
$formats["in"]["wav"] = "wav";
$formats["in"]["WAV"] = "WAV";
self::$supported = $formats;
return self::$supported;
}
示例2: getRoutes
/**
* Get Local routes
* @return array Array of routes
*/
public function getRoutes()
{
// Return a list of routes the machine knows about.
$route = fpbx_which('route');
if (empty($route)) {
return array();
}
exec("{$route} -nv", $output, $retcode);
if ($retcode != 0 || empty($output)) {
return array();
}
// Drop the first two lines, which are just headers..
array_shift($output);
array_shift($output);
// Now loop through whatever's left
$routes = array();
foreach ($output as $line) {
$arr = preg_split('/\\s+/', $line);
if (count($arr) < 3) {
//some strange value we dont understand
continue;
}
if ($arr[2] == "0.0.0.0" || $arr[2] == "255.255.255.255") {
// Don't care about default or host routes
continue;
}
if (substr($arr[0], 0, 7) == "169.254") {
// Ignore ipv4 link-local addresses. See RFC3927
continue;
}
$cidr = 32 - log((ip2long($arr[2]) ^ 4294967295.0) + 1, 2);
$routes[] = array($arr[0], $cidr);
}
return $routes;
}
示例3: installed
public static function installed()
{
$loc = fpbx_which("lame");
$process = new Process($loc . ' --version');
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
return false;
}
return true;
}
示例4: __construct
public function __construct($debug = 0)
{
$this->defaults['server_cn'] = $this->getHostname();
if (is_int($debug)) {
$this->debug = $debug;
} else {
$this->debug = 0;
}
if (function_exists('fpbx_which')) {
$command = fpbx_which('openssl');
$this->openssl = !empty($command) ? $command : $this->openssl;
}
}
示例5: installed
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;
}
示例6: fax_tiffinfo
/**
* Get info on a tiff file. Require tiffinfo
* @param string - absolute path to file
* @param string - specifc option to receive
*
* @return mixed - if $opt & exists returns a string, else bool false,
* otherwise an array of details
*/
function fax_tiffinfo($file, $opt = '')
{
//ensure file exists
if (!is_file($file)) {
return false;
}
$tiffinfo = fpbx_which('tiffinfo');
$info = array();
if (!$tiffinfo) {
return false;
}
exec($tiffinfo . ' ' . $file, $output);
if ($output && strpos($output[0], 'Not a TIFF or MDI file') === 0) {
return false;
}
foreach ($output as $out) {
$o = explode(':', $out, 2);
$info[trim($o[0])] = isset($o[1]) ? trim($o[1]) : '';
}
if (!$info) {
return false;
}
//special case prossesing
//Page Number: defualt format = 0-0. Use only first set of digits, increment by 1
$info['Page Number'] = explode('-', $info['Page Number']);
$info['Page Number'] = $info['Page Number'][0] + 1;
if ($opt) {
return isset($info[$opt]) ? $info[$opt] : false;
}
return $info;
}
示例7: switch
//action actions
switch ($var['action']) {
case 'download':
$var['restore_path'] = backup_restore_locate_file($var['id'], $var['restore_path']);
$_SESSION['backup_restore_path'] = $var['restore_path'];
download_file($var['restore_path']);
break;
case 'upload':
//make sure our file was uploaded
if (!is_uploaded_file($_FILES['upload']['tmp_name'])) {
$message = _('Error uploading file!');
$var['action'] = '';
break;
}
//ensure uploaded file is a valid tar file
exec(fpbx_which('tar') . ' -tf ' . $_FILES['upload']['tmp_name'], $array, $ret_code);
if ($ret_code !== 0) {
$message = _('Error verifying uploaded file!');
$var['action'] = '';
break;
}
$dest = $amp_conf['ASTSPOOLDIR'] . '/tmp/' . 'backuptmp-suser-' . time() . '-' . basename($_FILES['upload']['name']);
move_uploaded_file($_FILES['upload']['tmp_name'], $dest);
//$var['restore_path'] = $dest;
$_SESSION['backup_restore_path'] = $dest;
break;
case 'list_dir':
echo json_encode(backup_jstree_list_dir($var['id'], $var['path']));
exit;
break;
case 'backup_list':
示例8: unlink
unlink($path);
// Now, if we're selected skipnat, restore everything we backed up
// before the import.
if ($skipnat) {
backup_log(_('Restoring NAT settings'));
$ss = FreePBX::create()->Sipsettings;
$ss->setConfig('localnets', $backup['localnets']);
$ss->setConfig('externip', $backup['externip']);
}
}
}
// How about ASTDB?
if (isset($items['astdb']) || isset($items['settings']) && $items['settings'] == 'true') {
if ($manifest['astdb'] != '') {
backup_log(_('Restoring astDB...'));
$cmd[] = fpbx_which('tar');
$cmd[] = 'zxOf';
$cmd[] = $vars['restore'];
$cmd[] = './' . $manifest['astdb'];
exec(implode(' ', $cmd), $file);
astdb_put(unserialize($file[0]), array('RINGGROUP', 'BLKVM', 'FM', 'dundi'));
unset($cmd);
}
backup_log(_('Restoring Settings complete'));
}
//dbug($file);
//run hooks
if (isset($manifest['hooks']['post_restore']) && $manifest['hooks']['post_restore']) {
backup_log(_('Running post restore script...'));
exec($manifest['hooks']['post_restore']);
}
示例9: fpbx_ami_update
/**
* 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;
}
示例10: logfiles_get_logfile
/**
* Get last X lines of log file, with html tags to provide highlighting
*/
function logfiles_get_logfile($lines = 500, $file, $filter = false)
{
global $amp_conf;
$files = logfiles_list();
$logfile = $amp_conf['ASTLOGDIR'] . '/' . $files[$file];
if (!file_exists($logfile) || !is_file($logfile)) {
echo _('Error parsing log file or file not found!');
return;
}
$channels = array();
exec(fpbx_which('tail') . ' -n' . $lines . ' ' . $logfile, $log);
if ($filter) {
$regex_check = @preg_match('/' . $filter . '/', null);
if ($regex_check !== 0) {
echo _("Invalid pattern");
return;
} else {
$log = preg_grep('/' . $filter . '/', $log);
}
}
//If we filter out all the things....
if (empty($log)) {
echo _("No lines returned");
return;
}
foreach ($log as $l) {
switch (true) {
case strpos($l, 'INFO'):
$l = '<span class="beige">' . htmlentities($l, ENT_COMPAT | ENT_HTML401, "UTF-8") . '</span>';
break;
case strpos($l, 'WARNING'):
$l = '<span class="orange">' . htmlentities($l, ENT_COMPAT | ENT_HTML401, "UTF-8") . '</span>';
break;
case strpos($l, 'DEBUG'):
$l = '<span class="green">' . htmlentities($l, ENT_COMPAT | ENT_HTML401, "UTF-8") . '</span>';
break;
case strpos($l, 'UPDATE'):
case strpos($l, 'NOTICE'):
$l = '<span class="cyan">' . htmlentities($l, ENT_COMPAT | ENT_HTML401, "UTF-8") . '</span>';
break;
case strpos($l, 'FATAL'):
case strpos($l, 'CRITICAL'):
case strpos($l, 'ERROR'):
$l = '<span class="red">' . htmlentities($l, ENT_COMPAT | ENT_HTML401, "UTF-8") . '</span>';
break;
default:
$l = logfiles_highlight_asterisk(htmlentities($l, ENT_NOQUOTES, "UTF-8"), $channels);
break;
}
echo $l . '<br />';
}
}
示例11: _process_archive
function _process_archive($filename, $progress_callback = '')
{
global $amp_conf;
if (is_readable($filename) !== TRUE) {
return array(sprintf(_('Unable to save %s'), $filename));
}
// invoke progress callback
if (isset($progress_callback)) {
if (!is_array($progress_callback) && function_exists($progress_callback)) {
$progress_callback('untar', array('module' => $modulename, 'size' => filesize($filename)));
} else {
if (is_array($progress_callback) && method_exists($progress_callback[0], $progress_callback[1])) {
$progress_callback[0]->{$progress_callback}[1]('untar', array('module' => $modulename, 'size' => filesize($filename)));
}
}
}
$temppath = $amp_conf['AMPWEBROOT'] . '/admin/modules/_cache/' . uniqid("upload");
if (!@mkdir($temppath)) {
return array(sprintf(_("Error creating temporary directory: %s"), $temppath));
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (preg_match('/^(gpg)$/', $extension)) {
try {
if (!FreePBX::GPG()->verifyFile($filename)) {
return array(sprintf(_('File Integrity failed for %s - aborting (GPG Verify File check failed)'), $filename));
}
} catch (\Exception $e) {
return array(sprintf(_('File Integrity failed for %s - aborting (Cause: %s)'), $filename, $e->getMessage()));
}
try {
$filename = FreePBX::GPG()->getFile($filename);
if (!file_exists($filename)) {
return array(sprintf(_('Could not find extracted module: %s'), $filename));
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
} catch (\Exception $e) {
return array(sprintf(_('Unable to work with GPG file, message was: %s'), $e->getMessage()));
}
}
switch (true) {
case preg_match('/^(tgz|tar)$/', $extension) || preg_match('/(tar\\.gz)$/', $filename):
$err = exec("/usr/bin/env tar zxf " . escapeshellarg($filename) . " -C " . escapeshellarg($temppath), $output, $exitcode);
if ($exitcode != 0) {
return array(sprintf(_('Error from %s: %s'), 'tar', $err));
}
break;
case preg_match('/^(zip)$/', $extension):
exec("/usr/bin/env unzip", $output, $exitcode);
if ($exitcode != 0) {
return array(_("The binary unzip is not installed. Unable to work with zip file"));
}
$err = exec("/usr/bin/env unzip " . escapeshellarg($filename) . " -d " . escapeshellarg($temppath), $output, $exitcode);
if ($exitcode != 0) {
return array(sprintf(_('Error from %s: %s'), 'unzip', $err));
}
break;
case preg_match('/^(bz2|bz|tbz2|tbz)$/', $extension):
$err = exec("/usr/bin/env tar xjf " . escapeshellarg($filename) . " -C " . escapeshellarg($temppath), $output, $exitcode);
if ($exitcode != 0) {
return array(sprintf(_('Error from %s: %s'), 'tar', $err));
}
break;
default:
return array(sprintf(_('Unknown file format of %s for %s, supported formats: tar,tgz,tar.gz,zip,bzip'), $extension, basename($filename)));
break;
}
// since untarring was successful, remvove the tarball so they do not accumulate
if (unlink($filename) === false) {
freepbx_log(FPBX_LOG_WARNING, sprintf(_("failed to delete %s from cache directory after opening module archive."), $filename));
}
if (!file_exists($temppath . '/module.xml')) {
$dirs = glob($temppath . '/*', GLOB_ONLYDIR);
if (count($dirs) > 1 || !count($dirs)) {
return array(sprintf(_('Incorrect Number of Directories for %s'), $filename));
}
$archivepath = $dirs[0];
} else {
$archivepath = $temppath;
}
if (!file_exists($archivepath . '/module.xml')) {
return array(sprintf(_('Missing module.xml in %s'), $filename));
}
$xml = simplexml_load_file($archivepath . '/module.xml');
$modulename = (string) $xml->rawname;
$this->downloadedRawname = !empty($modulename) ? $modulename : "";
if (empty($modulename)) {
return array(sprintf(_('Module Name is blank in %s'), $filename));
}
if (file_exists($amp_conf['AMPWEBROOT'] . "/admin/modules/" . $modulename)) {
exec("rm -rf " . $amp_conf['AMPWEBROOT'] . "/admin/modules/" . $modulename, $output, $exitcode);
if ($exitcode != 0) {
return array(sprintf(_('Could not remove old module %s to install new version'), $amp_conf['AMPWEBROOT'] . '/admin/modules/' . $modulename));
}
}
//we just deleted it, if we cant recreate it then we have some serious issues going on
if (!@mkdir($amp_conf['AMPWEBROOT'] . "/admin/modules/" . $modulename)) {
return array(sprintf(_("Error creating module directory: %s"), $amp_conf['AMPWEBROOT'] . "/admin/modules/" . $modulename));
}
$installBinary = fpbx_which("install");
exec(sprintf("%s -d -o %s -g %s %s %s", $installBinary, $amp_conf['AMPASTERISKWEBUSER'], $amp_conf['AMPASTERISKWEBGROUP'], $archivepath . "/*", $amp_conf['AMPWEBROOT'] . "/admin/modules/" . $modulename . "/"), $output, $exitcode);
//.........这里部分代码省略.........
示例12: checkUpdateCertificates
/**
* 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;
}
示例13: fpbx_ami_update
/**
* 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;
}
示例14: unset
//
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);
}
$outdated = array($amp_conf['AMPWEBROOT'] . '/admin/reports.php', $amp_conf['AMPWEBROOT'] . '/admin/assets/js/pbxlib.js.php', $amp_conf['AMPWEBROOT'] . '/admin/assets/css/jquery-ui-1.8.16.css', $amp_conf['AMPWEBROOT'] . '/admin/common/db_connect.php', $amp_conf['AMPWEBROOT'] . '/admin/common/json.inc.php', $amp_conf['AMPWEBROOT'] . '/admin/common/libfreepbx.javascripts.js', $amp_conf['AMPWEBROOT'] . '/admin/common/mainstyle-alternative.css', $amp_conf['AMPWEBROOT'] . '/admin/common/mainstyle.css', $amp_conf['AMPWEBROOT'] . '/admin/common/script.js.php', $amp_conf['AMPWEBROOT'] . '/admin/images/category1.png', $amp_conf['AMPWEBROOT'] . '/admin/images/freepbx_large.png', $amp_conf['AMPWEBROOT'] . '/admin/images/header-back.png', $amp_conf['AMPWEBROOT'] . '/admin/images/loading.gif', $amp_conf['AMPWEBROOT'] . '/admin/images/logo.png', $amp_conf['AMPWEBROOT'] . '/admin/images/modules1.png', $amp_conf['AMPWEBROOT'] . '/admin/images/shadow-side-background.png', $amp_conf['AMPWEBROOT'] . '/admin/images/tab-first-current.png', $amp_conf['AMPWEBROOT'] . '/admin/images/tab.png', $amp_conf['AMPWEBROOT'] . '/admin/images/watermark.png', $amp_conf['AMPWEBROOT'] . '/admin/views/freepbx_admin.php', $amp_conf['AMPWEBROOT'] . '/admin/views/loggedout.php');
out("Cleaning up deprecated or moved files:");
foreach ($outdated as $file) {
outn("Checking {$file}..");
if (file_exists($file) || is_link($file)) {
unlink($file) ? out("removed") : out("failed to remove");
} else {
out("Not Required");
}
}
$rm_command = function_exists('fpbx_which') ? fpbx_which('rm') : 'rm';
$common_dir = $amp_conf['AMPWEBROOT'] . '/admin/common';
exec($rm_command . ' -rf ' . $common_dir . '/mstyle_autogen_*.css');
outn("Trying to remove dir {$common_dir}..");
if (is_dir($common_dir) && !is_link($common_dir)) {
rmdir($common_dir) ? out("removed") : out("failed to remove, there may be left over files that need to be deleted");
} else {
out("Not Required");
}
示例15: backup_migrate_legacy
function backup_migrate_legacy($bu)
{
global $amp_conf;
$legacy_name = '';
$name = pathinfo($bu, PATHINFO_BASENAME);
if (substr($name, -7) != '.tar.gz') {
return false;
}
//get legacy name based on the directory the legacy backup was origionally created in
//were expcecting to see something like: /tmp/ampbackups.20110310.16.00.00/
//in the tarball
$cmd[] = fpbx_which('tar');
$cmd[] = 'tf';
$cmd[] = $bu;
exec(implode(' ', $cmd), $res);
unset($cmd);
foreach ($res as $r) {
if (preg_match('/\\/tmp\\/ampbackups\\.([\\d]{8}(\\.[\\d]{2}){3})\\//', $r, $legacy_name)) {
if (isset($legacy_name[1])) {
$legacy_name = $legacy_name[1];
break;
}
}
}
if (!$legacy_name) {
return false;
}
//create directory where tarball will be exctracted to
$dir = $amp_conf['ASTSPOOLDIR'] . '/tmp/' . $legacy_name;
mkdir($dir, 0755, true);
$cmd[] = fpbx_which('tar');
$cmd[] = '-zxf';
$cmd[] = $bu;
$cmd[] = ' -C ' . $dir;
exec(implode(' ', $cmd));
unset($cmd);
$dir2 = $dir . '/tmp/ampbackups.' . $legacy_name;
//exctract sub tarballs
foreach (scandir($dir2) as $file) {
if (substr($file, -7) == '.tar.gz') {
$cmd[] = fpbx_which('tar');
$cmd[] = '-zxf';
$cmd[] = $dir2 . '/' . $file;
$cmd[] = ' -C ' . $dir2;
exec(implode(' ', $cmd));
unset($cmd);
unlink($dir2 . '/' . $file);
}
}
//add files to manifest
$ret['file_list'] = scandirr($dir2);
$ret['file_count'] = count($ret['file_list'], COUNT_RECURSIVE);
$ret['fpbx_db'] = '';
$ret['fpbx_cdrdb'] = '';
//format db's + add to manifest
if (is_file($dir2 . '/astdb.dump')) {
//rename file
rename($dir2 . '/astdb.dump', $dir2 . '/astdb');
//remove it from the file_list
unset($ret['file_list'][array_search('astdb.dump', $ret['file_list'])]);
//set the manifest
$ret['astdb'] = 'astdb';
} elseif (is_file($dir2 . '/tmp/ampbackups.' . $legacy_name . '/astdb.dump')) {
rename($dir2 . '/tmp/ampbackups.' . $legacy_name . '/astdb.dump', $dir2 . '/astdb');
$ret['astdb'] = 'astdb';
}
//serialize the astdb
if (!empty($ret['astdb'])) {
$astdb = array();
foreach (file($dir2 . '/astdb') as $line) {
$line = explode('] [', trim($line, '[]/'));
//chuck the bad values
if ($line[1] == '<bad value>') {
continue;
}
//expldoe the key
list($family, $key) = explode('/', $line[0], 2);
//add to astdb array
$astdb[$family][$key] = trim(trim($line[1]), ']');
}
file_put_contents($dir2 . '/astdb', serialize($astdb));
}
//migrate mysql files to a format that we can restore from
$src = $dir2 . '/asterisk.sql';
if (is_file($src)) {
$dst = $dir2 . '/mysql-db.sql';
unset($ret['file_list'][array_search('asterisk.sql', $ret['file_list'])]);
//remove from manifest
$ret['fpbx_db'] = 'mysql-db';
$ret['mysql']['db'] = array('file' => 'mysql-db.sql');
// remove SET and comments that later break restores when using pear
$cmd[] = fpbx_which('grep');
$cmd[] = "-v '^\\/\\*\\|^SET\\|^--'";
$cmd[] = $src;
$cmd[] = ' > ' . $dst;
exec(implode(' ', $cmd), $file, $status);
if ($status) {
// The grep failed, if there is a $dst file remove it and either way rename the $src
freepbx_log(FPBX_LOG_ERROR, _("Failed converting asterisk.sql to proper format, renaming to mysql-db.sql in current state"));
if (is_file($dst)) {
//.........这里部分代码省略.........