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


PHP FreePBX::Firewall方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     // Is firewall enabled and active?
     try {
         $this->fwobj = \FreePBX::Firewall();
         $this->fw = $this->fwobj->isEnabled();
     } catch (\Exception $e) {
         // Firewall not active, or not enabled, don't do anything
         return;
     }
 }
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:11,代码来源:FirewallAPI.class.php

示例2: getSettings

 public function getSettings()
 {
     $retarr = array("ssf" => true, "period" => 60, "responsive" => false);
     $retarr['rprotocols'] = array("pjsip" => array("state" => true, "descr" => _("SIP Protocol (pjsip)")), "chansip" => array("state" => true, "descr" => _("Legacy SIP (chan_sip)")), "iax" => array("state" => false, "descr" => _("IAX Protocol")));
     if (\FreePBX::Firewall()->getConfig("responsivefw")) {
         $retarr['responsive'] = true;
         foreach ($retarr['rprotocols'] as $id => $null) {
             $retarr['rprotocols'][$id]['state'] = \FreePBX::Firewall()->getConfig($id, "rfw");
         }
     }
     return $retarr;
 }
开发者ID:ntadmin,项目名称:firewall,代码行数:12,代码来源:Smart.class.php

示例3: exec

 private function &getCurrentIptables()
 {
     if (!$this->currentconf) {
         // Am I root?
         if (posix_getuid() === 0) {
             // Parse iptables-save output
             exec('/sbin/iptables-save 2>&1', $ipv4, $ret);
             exec('/sbin/ip6tables-save 2>&1', $ipv6, $ret);
             $this->currentconf = array("ipv4" => $this->parseIptablesOutput($ipv4), "ipv6" => $this->parseIptablesOutput($ipv6));
         } else {
             // Not root, need to run a hook.
             @unlink("/tmp/iptables.out");
             \FreePBX::Firewall()->runHook("getiptables");
             // Wait for up to 5 seconds for the output.
             $crashafter = time() + 5;
             while (!file_exists("/tmp/iptables.out")) {
                 if ($crashafter > time()) {
                     throw new \Exception("/tmp/iptables.out wasn't created");
                 }
                 usleep(200000);
             }
             // OK, it exists. We should be able to parse it as json
             while (true) {
                 $json = file_get_contents("/tmp/iptables.out");
                 $res = json_decode($json, true);
                 if (!is_array($res)) {
                     if ($crashafter > time()) {
                         throw new \Exception("/tmp/iptables.out wasn't valid json");
                     }
                     usleep(200000);
                 } else {
                     $this->currentconf = $res;
                     break;
                 }
             }
         }
     }
     // Return as a ref, people may want to mangle it.
     return $this->currentconf;
 }
开发者ID:ntadmin,项目名称:firewall,代码行数:40,代码来源:Iptables.class.php


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