public function getCurrentConfigurations($obj = null)
 {
     $type = 'action';
     if ($obj == null) {
         $action = get_controller_meta();
     } else {
         if (is_string($obj)) {
             $type = $obj;
             $action = get_controller_meta();
         } else {
             $action = $obj;
         }
     }
     $ret = array();
     $ret[] = $this->getAllMatch($type);
     $c = $this->getMatchController($action->controller, $type);
     $method_same = array();
     $method_match = array();
     $match = null;
     foreach ($c as $conf) {
         $conf->tag = isset($conf->tag) ? json_decode($conf->tag) : array();
         if ($conf->method == $action->method) {
             if ($action->args == $conf->tag) {
                 $match = $conf;
             } else {
                 $method_same[] = $conf;
             }
         } else {
             if (is_regex($conf->method) && preg_match($conf->method, $action->method)) {
                 $method_match[] = $conf;
             }
         }
     }
     if ($method_match) {
         foreach ($method_match as $m) {
             $ret[] = $m;
         }
     }
     $c = $this->getMatchMethod($action->method, $type);
     if (isset($c->id)) {
         $ret[] = $c;
     }
     if ($method_same) {
         foreach ($method_same as $m) {
             $ret[] = $m;
         }
     }
     if ($match) {
         $ret[] = $match;
     }
     return $ret;
 }
 public function getTemplateTarget($subject, $config, $type = 'actions')
 {
     if (!isset($this->sec_template)) {
         $this->loadTemplate();
     }
     $target = null;
     $target_exact = null;
     foreach ($this->sec_template as $k => $v) {
         if ($k == 'default' || $this->security_subject_model->translate($k) == $subject) {
             if (isset($v->{$type})) {
                 foreach ($v->{$type} as $target_template) {
                     if (is_regex($target_template->controller)) {
                         if (preg_match($target_template->controller, $config->controller)) {
                             if (is_regex($target_template->method)) {
                                 if (preg_match($target_template->method, $config->method)) {
                                     $target = $target_template;
                                 }
                             } else {
                                 if ($target_template->method == $config->method) {
                                     $target = $target_template;
                                 }
                             }
                         }
                     } else {
                         if ($target_template->controller == $config->controller) {
                             if (is_regex($target_template->method)) {
                                 if (preg_match($target_template->method, $config->method)) {
                                     $target = $target_template;
                                 }
                             } else {
                                 if ($target_template->method == $config->method) {
                                     $target = $target_template;
                                     if (isset($config->args) && isset($target_template->args) && $target_template->args == $config->args) {
                                         $target_exact = $target_template;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($target_exact) {
         return $target_exact;
     }
     return $target;
 }
Пример #3
0
function LOADRULES($id)
{
    $f = explode("\n", @file_get_contents("/etc/squid3/acls/container_{$id}.txt"));
    while (list($num, $val) = each($f)) {
        $val = trim(strtolower($val));
        if ($val == null) {
            continue;
        }
        if (is_regex($val)) {
            $GLOBALS["RULES"][$val] = true;
            continue;
        }
        $val = str_replace(".", "\\.", $val);
        $val = str_replace("*", ".*?", $val);
        $GLOBALS["RULES"][$val] = true;
    }
    WLOG("Starting Group Number:{$id} " . count($GLOBALS["RULES"]) . " rules");
}
 public function testIsRegex()
 {
     $this->assertTrue(!!is_regex('/asdf/'));
     $this->assertTrue(!is_regex('asdf'));
 }