当前位置: 首页>>代码示例>>PHP>>正文


PHP FreePBX::Freepbx_conf方法代码示例

本文整理汇总了PHP中FreePBX::Freepbx_conf方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::Freepbx_conf方法的具体用法?PHP FreePBX::Freepbx_conf怎么用?PHP FreePBX::Freepbx_conf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FreePBX的用法示例。


在下文中一共展示了FreePBX::Freepbx_conf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dirname

}
// bootstrap.php should always be called from freepbx.conf so
// database conifguration already included, connect to database:
//
require_once $dirname . '/libraries/db_connect.php';
//PEAR must be installed
// BMO: Initialize BMO as early as possible.
$bmo = dirname(__FILE__) . "/libraries/BMO/FreePBX.class.php";
if (file_exists($bmo)) {
    include_once $bmo;
    $bmo = new FreePBX($amp_conf);
} else {
    throw new Exception("Unable to load BMO");
}
// get settings
$freepbx_conf = $bmo->Freepbx_conf();
// passing by reference, this means that the $amp_conf available to everyone is the same one as present
// within the class, which is probably a direction we want to go to use the class.
//
$bootstrap_settings['amportal_conf_initialized'] = false;
$amp_conf =& $freepbx_conf->parse_amportal_conf("/etc/amportal.conf", $amp_conf);
// set the language so local module languages take
set_language();
$asterisk_conf =& $freepbx_conf->get_asterisk_conf();
$bootstrap_settings['amportal_conf_initialized'] = true;
//connect to cdrdb if requestes
if ($bootstrap_settings['cdrdb']) {
    $dsn = array('phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'], 'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'], 'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'], 'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'], 'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306', 'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : 'asteriskcdrdb');
    $cdrdb = DB::connect($dsn);
}
$bootstrap_settings['astman_connected'] = false;
开发者ID:ntadmin,项目名称:framework,代码行数:31,代码来源:bootstrap.php

示例2: checkPermissions

 /**
  * Check Permissions on said directory and fix if need be
  * @param {string} $dir = false The Directory to check and fix
  */
 private function checkPermissions($dir = false)
 {
     if (!$dir) {
         // No directory specified. Let's use the default.
         $dir = $this->getKeysLocation();
     }
     // If it ends in a slash, remove it, for sanity
     $dir = rtrim($dir, "/");
     if (!is_dir($dir)) {
         // That's worrying. Can I make it?
         $ret = @mkdir($dir);
         if (!$ret) {
             throw new \Exception(sprintf(_("Directory %s doesn't exist, and I can't make it."), $dir));
         }
     }
     // Now, who should be running OpenSSL normally?
     $freepbxuser = \FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
     $pwent = posix_getpwnam($freepbxuser);
     $uid = $pwent['uid'];
     $gid = $pwent['gid'];
     // What are the permissions of the keys directory?
     $stat = stat($dir);
     if ($uid != $stat['uid']) {
         // Permissions are wrong on the keys directory. Hopefully, I'm root, so I can fix them.
         if (posix_geteuid() !== 0) {
             throw new \Exception(sprintf(_("Permissions error on directory %s (is %s:%s, should be %s:%s)- please run 'fwconsole chown' as root to repair"), $dir, $stat['uid'], $stat['gid'], $uid, $gid));
         }
         // We're root. Yay.
         chown($dir, $uid);
         chgrp($dir, $gid);
     }
     // Check the permissions of the files inside the key location
     $allfiles = glob($dir . "/*");
     // Add the entropy file
     $allfiles[] = "{$dir}/.rnd";
     foreach ($allfiles as $file) {
         if (!file_exists($file)) {
             // .rnd file may not exist
             continue;
         }
         $stat = stat($file);
         if ($uid != $stat['uid']) {
             // Permissions are wrong on the keys directory. Hopefully, I'm root, so I can fix them.
             if (posix_geteuid() !== 0) {
                 throw new \Exception(sprintf(_("Permissions error on file %s - please re-run as root to automatically repair"), $file));
             }
             // We're root. Yay.
             chown($file, $uid);
             chgrp($file, $gid);
         }
     }
 }
开发者ID:lidl,项目名称:framework,代码行数:56,代码来源:PKCS.class.php

示例3: createFreePBXAdmin

 private function createFreePBXAdmin($settings)
 {
     // This will never, ever, overwrite an existing admin.
     $db = FreePBX::Database();
     if (!$this->isFrameworkOOBENeeded()) {
         throw new \Exception("Tried to add an admin user, but some users ({$count}) already exist.");
     }
     $sth = $db->prepare("INSERT INTO `ampusers` (`username`, `password_sha1`, `sections`) VALUES ( ?, ?, '*')");
     $username = htmlentities(strip_tags($settings['username']));
     $sth->execute(array($username, sha1($settings['password'])));
     // TODO: REMOVE IN FREEPBX 14 - ARI is deprecated as of FreePBX 12
     // set ari password
     $freepbx_conf = FreePBX::Freepbx_conf();
     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' => $settings['password']), true);
     }
     //set email address
     $cm =& cronmanager::create($db);
     $cm->save_email($settings['email']);
 }
开发者ID:lidl,项目名称:framework,代码行数:20,代码来源:OOBE.class.php

示例4: checkPermissions

 private function checkPermissions($dir = false)
 {
     if (!$dir) {
         // No directory specified. Let's use the default.
         $dir = $this->getGpgLocation();
     }
     // If it ends in a slash, remove it, for sanity
     $dir = rtrim($dir, "/");
     if (!is_dir($dir)) {
         // That's worrying. Can I make it?
         $ret = @mkdir($dir);
         if (!$ret) {
             throw new Exception(sprintf(_("Directory %s doesn't exist, and I can't make it. (checkPermissions)"), $dir));
         }
     }
     // Now, who should be running gpg normally?
     $freepbxuser = FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
     $pwent = posix_getpwnam($freepbxuser);
     $uid = $pwent['uid'];
     $gid = $pwent['gid'];
     // What are the permissions of the GPG home directory?
     $stat = stat($dir);
     if ($uid != $stat['uid'] || $gid != $stat['gid']) {
         // Permissions are wrong on the GPG directory. Hopefully, I'm root, so I can fix them.
         if (!posix_geteuid() === 0) {
             throw new Exception(sprintf(_("Permissions error on %s - please re-run as root to automatically repair"), $home));
         }
         // We're root. Yay.
         chown($dir, $uid);
         chgrp($dir, $gid);
     }
     // Check the permissions of the files inside the .gpg directory
     $allfiles = glob($dir . "/*");
     foreach ($allfiles as $file) {
         $stat = stat($file);
         if ($uid != $stat['uid'] || $gid != $stat['gid']) {
             // Permissions are wrong on the file inside the .gnupg directory.
             if (!posix_geteuid() === 0) {
                 throw new Exception(sprintf(_("Permissions error on %s - please re-run as root to automatically repair"), $home));
             }
             // We're root. Yay.
             chown($file, $uid);
             chgrp($file, $gid);
         }
     }
 }
开发者ID:ntadmin,项目名称:framework,代码行数:46,代码来源:GPG.class.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output, $quiet = false)
 {
     if (posix_geteuid() != 0) {
         $output->writeln("<error>" . _("You need to be root to run this command") . "</error>");
         exit(1);
     }
     $this->quiet = $quiet;
     if (!$this->quiet) {
         $output->writeln(_("Setting Permissions") . "...");
     }
     $freepbx_conf = \freepbx_conf::create();
     $conf = $freepbx_conf->get_conf_settings();
     foreach ($conf as $key => $val) {
         ${$key} = $val['value'];
     }
     /*
      * These are files Framework is responsible for This list can be
      * reduced by moving responsibility to other modules as a hook
      * where appropriate.
      *
      * Types:
      * 		file:		Set permissions/ownership on a single item
      * 		dir: 		Set permissions/ownership on a single directory
      * 		rdir: 		Set permissions/ownership on a single directory then recursively on
      * 					files within less the execute bit. If the dir is 755, child files will be 644,
      * 					child directories will be set the same as the parent.
      * 		execdir:	Same as rdir but the execute bit is not stripped.
      */
     $sessdir = session_save_path();
     $sessdir = !empty($session) ? $session : '/var/lib/php/session';
     $args = array();
     if ($input) {
         $args = $input->getArgument('args');
         $this->moduleName = !empty($this->moduleName) ? $this->moduleName : strtolower($args[0]);
     }
     // Always update hooks before running a Chown
     \FreePBX::Hooks()->updateBMOHooks();
     if (!empty($this->moduleName) && $this->moduleName != 'framework') {
         $mod = $this->moduleName;
         $this->modfiles[$mod][] = array('type' => 'rdir', 'path' => $AMPWEBROOT . '/admin/modules/' . $mod, 'perms' => 0755);
         $hooks = $this->fwcChownFiles();
         $current = isset($hooks[ucfirst($mod)]) ? $hooks[ucfirst($mod)] : false;
         if (is_array($current)) {
             $this->modfiles[$mod] = array_merge_recursive($this->modfiles[$mod], $current);
         }
     } else {
         $webuser = \FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
         $web = posix_getpwnam($webuser);
         if (!$web) {
             throw new \Exception(sprintf(_("I tried to find out about %s, but the system doesn't think that user exists"), $webuser));
         }
         $home = trim($web['dir']);
         if (is_dir($home)) {
             $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $home, 'perms' => 0755);
             // SSH folder needs non-world-readable permissions (otherwise ssh complains, and refuses to work)
             $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => "{$home}/.ssh", 'perms' => 0700);
         }
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $sessdir, 'perms' => 0744);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/amportal.conf', 'perms' => 0640);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/freepbx.conf', 'perms' => 0640);
         $this->modfiles['framework'][] = array('type' => 'dir', 'path' => $ASTRUNDIR, 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => \FreePBX::GPG()->getGpgLocation(), 'perms' => 0755);
         //we may wish to declare these manually or through some automated fashion
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTETCDIR, 'perms' => 0750);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $ASTVARLIBDIR . '/.ssh/id_rsa', 'perms' => 0600);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTLOGDIR, 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTSPOOLDIR, 'perms' => 0755);
         //I have added these below individually,
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBXDBUGFILE, 'perms' => 0644);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBX_LOG_FILE, 'perms' => 0644);
         //We may wish to declare files individually rather than touching everything
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/' . $MOHDIR, 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/sounds', 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/obdc.ini', 'perms' => 0644);
         //we were doing a recursive on this which I think is not needed.
         //Changed to just be the directory
         //^ Needs to be the whole shebang, doesnt work otherwise
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $AMPWEBROOT, 'perms' => 0755);
         //Anything in bin and agi-bin should be exec'd
         //Should be after everything except but before hooks
         //So that we dont get overwritten by ampwebroot
         $this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $AMPBIN, 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTAGIDIR, 'perms' => 0755);
         //Merge static files and hook files, then act on them as a single unit
         $fwcCF = $this->fwcChownFiles();
         if (!empty($this->modfiles) && !empty($fwcCF)) {
             $this->modfiles = array_merge_recursive($this->modfiles, $fwcCF);
         }
     }
     $ampowner = $AMPASTERISKWEBUSER;
     /* Address concerns carried over from amportal in FREEPBX-8268. If the apache user is different
      * than the Asterisk user we provide permissions that allow both.
      */
     $ampgroup = $AMPASTERISKWEBUSER != $AMPASTERISKUSER ? $AMPASTERISKGROUP : $AMPASTERISKWEBGROUP;
     foreach ($this->modfiles as $moduleName => $modfilelist) {
         foreach ($modfilelist as $file) {
             if (!isset($file['path']) || !isset($file['perms']) || !file_exists($file['path'])) {
                 continue;
             }
             //Handle custom ownership (optional)
//.........这里部分代码省略.........
开发者ID:sokrat,项目名称:freepbx-framework,代码行数:101,代码来源:Chown.class.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output, $quiet = false)
 {
     $this->output = $output;
     if (posix_geteuid() != 0) {
         $output->writeln("<error>" . _("You need to be root to run this command") . "</error>");
         exit(1);
     }
     $this->quiet = $quiet;
     $etcdir = \FreePBX::Config()->get('ASTETCDIR');
     if (!$this->quiet) {
         if (!file_exists($etcdir . '/freepbx_chown.conf')) {
             $output->writeln("<info>" . sprintf(_("Taking too long? Customize the chown command, See %s"), "http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf") . "</info>");
         }
         $output->writeln(_("Setting Permissions") . "...");
     }
     $freepbx_conf = \freepbx_conf::create();
     $conf = $freepbx_conf->get_conf_settings();
     foreach ($conf as $key => $val) {
         ${$key} = $val['value'];
     }
     /*
      * These are files Framework is responsible for This list can be
      * reduced by moving responsibility to other modules as a hook
      * where appropriate.
      *
      * Types:
      * 		file:		Set permissions/ownership on a single item
      * 		dir: 		Set permissions/ownership on a single directory
      * 		rdir: 		Set permissions/ownership on a single directory then recursively on
      * 					files within less the execute bit. If the dir is 755, child files will be 644,
      * 					child directories will be set the same as the parent.
      * 		execdir:	Same as rdir but the execute bit is not stripped.
      */
     $sessdir = session_save_path();
     $sessdir = !empty($sessdir) ? $sessdir : '/var/lib/php/session';
     $args = array();
     if ($input) {
         $args = $input->getArgument('args');
         $mname = isset($args[0]) ? $args[0] : '';
         $this->moduleName = !empty($this->moduleName) ? $this->moduleName : strtolower($mname);
     }
     // Always update hooks before running a Chown
     \FreePBX::Hooks()->updateBMOHooks();
     if (!empty($this->moduleName) && $this->moduleName != 'framework') {
         $mod = $this->moduleName;
         $this->modfiles[$mod][] = array('type' => 'rdir', 'path' => $AMPWEBROOT . '/admin/modules/' . $mod, 'perms' => 0755);
         $hooks = $this->fwcChownFiles();
         $current = isset($hooks[ucfirst($mod)]) ? $hooks[ucfirst($mod)] : false;
         if (is_array($current)) {
             $this->modfiles[$mod] = array_merge_recursive($this->modfiles[$mod], $current);
         }
     } else {
         $webuser = \FreePBX::Freepbx_conf()->get('AMPASTERISKWEBUSER');
         $web = posix_getpwnam($webuser);
         if (!$web) {
             throw new \Exception(sprintf(_("I tried to find out about %s, but the system doesn't think that user exists"), $webuser));
         }
         $home = trim($web['dir']);
         if (is_dir($home)) {
             $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $home, 'perms' => 0755);
             // SSH folder needs non-world-readable permissions (otherwise ssh complains, and refuses to work)
             $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => "{$home}/.ssh", 'perms' => 0700);
         }
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $sessdir, 'perms' => 0744, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/amportal.conf', 'perms' => 0640, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/freepbx.conf', 'perms' => 0640, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'dir', 'path' => $ASTRUNDIR, 'perms' => 0755, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => \FreePBX::GPG()->getGpgLocation(), 'perms' => 0755, 'always' => true);
         //we may wish to declare these manually or through some automated fashion
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTETCDIR, 'perms' => 0750, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $ASTVARLIBDIR . '/.ssh/id_rsa', 'perms' => 0600);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTLOGDIR, 'perms' => 0755, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTSPOOLDIR, 'perms' => 0755);
         //I have added these below individually,
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBXDBUGFILE, 'perms' => 0644);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => $FPBX_LOG_FILE, 'perms' => 0644);
         //We may wish to declare files individually rather than touching everything
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/' . $MOHDIR, 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $ASTVARLIBDIR . '/sounds', 'perms' => 0755);
         $this->modfiles['framework'][] = array('type' => 'file', 'path' => '/etc/obdc.ini', 'perms' => 0644);
         //we were doing a recursive on this which I think is not needed.
         //Changed to just be the directory
         //^ Needs to be the whole shebang, doesnt work otherwise
         $this->modfiles['framework'][] = array('type' => 'rdir', 'path' => $AMPWEBROOT, 'perms' => 0755);
         //Anything in bin and agi-bin should be exec'd
         //Should be after everything except but before hooks
         //So that we dont get overwritten by ampwebroot
         $this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $AMPBIN, 'perms' => 0755, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTAGIDIR, 'perms' => 0755, 'always' => true);
         $this->modfiles['framework'][] = array('type' => 'execdir', 'path' => $ASTVARLIBDIR . "/bin", 'perms' => 0755, 'always' => true);
         //Merge static files and hook files, then act on them as a single unit
         $fwcCF = $this->fwcChownFiles();
         if (!empty($this->modfiles) && !empty($fwcCF)) {
             foreach ($fwcCF as $key => $value) {
                 $this->modfiles[$key] = $value;
             }
             //$this->modfiles = array_merge_recursive($this->modfiles,$fwcCF);
         }
     }
     //Let's move the custom array to the end so it happens last
//.........这里部分代码省略.........
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:101,代码来源:Chown.class.php


注:本文中的FreePBX::Freepbx_conf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。