public function groupEdit() { if (IS_POST) { $id = I("id"); $rules = I("list"); $title = I("title"); if (!id || !is_array($rules) || empty($rules) || !$title) { $this->error("请填写相关数据"); } $arr = arrayToString($rules); $data = array("title" => $title, "rules" => $arr); $save = M("auth_group")->where(array("id" => $id))->save($data); if (!$save) { $this->error("保存失败"); } $this->success("操作成功"); } else { $id = I("id"); $info = M("auth_group")->where(array("id" => $id))->find(); $rules = explode(",", $info['rules']); $this->rules = $rules; $this->info = $info; $arr = getRules($column, $rules); //dump($column); $this->arr = $arr; $this->display(); } }
function __construct($parameters) { $this->rules_ = getRules(); $this->inputPath_ = $parameters['input_path']; $this->outputDir_ = rtrim($parameters['output_dir'], '/\\') . DS; $this->outputFilename_ = $parameters['output_filename']; $this->outputSourcePath_ = $this->outputDir_ . $this->outputFilename_ . '.cpp'; $this->outputHeaderPath_ = $this->outputDir_ . $this->outputFilename_ . '.h'; $this->macros_ = $parameters['macros']; $this->luaopenFunctionName_ = str_replace('-', '_', sprintf('luaopen_%s', $parameters['output_filename'])); $this->prefixName_ = $parameters['prefix_name']; }
* * MMC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MMC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC. If not, see <http://www.gnu.org/licenses/>. */ $filter = $_GET["filter"]; $list = getRules("", $src, $dst, $filter); $src_zones = getZonesInterfaces($src); $dst_zones = getZonesInterfaces($dst); $deleteAction = new ActionPopupItem(_T("Delete rule"), "delete_" . $page . "_rule", "delete", ""); $ids = array(); $decision = array(); $service = array(); $source = array(); $destination = array(); $proto = array(); $port = array(); $actionsDelete = array(); foreach ($list as $index => $rule) { include 'rule_list.inc.php'; } $n = new ListInfos($decision, _T("Decision"));
<?php include "common/include/db_login.php"; $connection = mysql_connect($host, $user, $pass); mysql_select_db($database); if (isset($_REQUEST["method"])) { if ($_REQUEST["method"] == "getRulesList") { getRules($_REQUEST["rulesId"], $_REQUEST["userId"]); } } function getRules($rulesId, $userId) { $qry = "SELECT * FROM RulesManagementSet WHERE Active = 1 AND memberID = " . $userId . " AND Title = '" . $rulesId . "';"; $result = mysql_query($qry); $i = 0; $return = ''; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $return .= $row[rulesID] . ","; $i++; } // echo json_encode($return); echo $return; } ?> <?php class ServiceResult { /** * * @var Boolean
} $unique[$k] = $appName . $v['role_id'] . $v['model_id'] . $v['feature_id']; } $unique = array_unique($unique); foreach ($unique as $k => $vu) { $rule[] = $acl[$k]; } return $rule; } $m = new Mycached(); $m->addServers([['127.0.0.1', '11211']]); print_r($m->getError()); $rules = $m->mem('rule'); if (!$rules) { echo ' it`s new rules!' . "\n"; $m->mem('rule', getRules(), 10); $rules = $m->mem('rule'); } else { echo ' it`s the cache rules!' . "\n"; } $str = ''; foreach ($rules as $v) { $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_app\t\thdr(X-App)\t\t" . $v['app'] . "\n"; $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_role\t\thdr(X-Role)\t\t" . $v['user'] . "\n"; $scope_str = ''; foreach ($v['scope'] as $vs) { $scope_str .= $vs . " "; } $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_scopes\t\thdr(X-Scope)\t" . $scope_str . "\n"; $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_feature\tpath_reg\t\t-i\t\t/" . $v['model_name'] . "/" . $v['feature_name'] . "\n"; $str .= "use_backend dynamic\tif app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_app app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_role app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_scopes app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_feature\n\n";
/** * "Rewrite" handling for zenphoto * * The basic rules are found in the zenphoto-rewrite.txt file. Additional rules can be provided by plugins. But * for the plugin to load in time for the rules to be seen it must be either a CLASS_PLUGIN or a FEATURE_PLUGIN. * Plugins add rules by inserting them into the $_zp_conf_vars['special_pages'] array. Each "rule" is an array * of three elements: <var>define</var>, <var>rewrite</var>, and (optionally) <var>rule</rule>. * * Elemments which have a <var>define</var> and no <var>rule</rule> are processed by rewrite rules in the * zenphoto-rewrite.txt file and the <var>define</var> is used internally to zenphoto to reference * the rewrite text when building links. * * Elements with a <var>rule</rule> defined are processed after Search, Pages, and News rewrite rules and before * Image and album rewrite rules. The tag %REWRITE% in the rule is replaced with the <var>rewrite</var> text * before processing the rule. Thus <var>rewrite</var> is the token that should appear in the acutal URL. * * It makes no sense to have an element without either a <var>define</var> or a <var>rule</rule> as nothing will happen. * * At present all rules are presumed to to stop processing the rule set. Historically that is what all our rules have done, but I suppose * we could change that. The "R" flag may be used to cause a <var>header</var> status to be sent. However, we do not redirect * back to index.php, so the "R" flag is only useful if the target is a different script. * * @author Stephen Billard (sbillard) * * @package admin */ function rewriteHandler() { global $_zp_conf_vars, $_zp_rewritten; $_zp_rewritten = false; $definitions = array(); // query parameters should already be loaded into the $_GET and $_REQUEST arrays, so we discard them here $request = explode('?', getRequestURI()); //rewrite base $requesturi = ltrim(substr($request[0], strlen(WEBPATH)), '/'); list($definitions, $rules) = getRules(); //process the rules foreach ($rules as $rule) { if ($rule = trim($rule)) { if ($rule[0] != '#') { if (preg_match('~^rewriterule~i', $rule)) { // it is a rewrite rule, see if it is applicable $rule = strtr($rule, $definitions); preg_match('~^rewriterule\\s+(.*?)\\s+(.*?)\\s*\\[(.*)\\]$~i', $rule, $matches); if (array_key_exists(1, $matches)) { if (preg_match('~' . $matches[1] . '~', $requesturi, $subs)) { $params = array(); // setup the rule replacement values foreach ($subs as $key => $sub) { $params['$' . $key] = urlencode($sub); // parse_str is going to decode the string! } // parse rewrite rule flags $flags = array(); $banner = explode(',', strtoupper($matches[3])); foreach ($banner as $flag) { $flag = strtoupper(trim($flag)); $f = explode('=', $flag); $flags[trim($f[0])] = isset($f[1]) ? trim($f[1]) : NULL; } if (!array_key_exists('QSA', $flags)) { // QSA means merge the query parameters. Otherwise we clear them $_REQUEST = array_diff($_REQUEST, $_GET); $_GET = array(); } preg_match('~(.*?)\\?(.*)~', $matches[2], $action); if (empty($action)) { $action[1] = $matches[2]; } if (array_key_exists(2, $action)) { // process the rules replacements $query = strtr($action[2], $params); parse_str($query, $gets); $_GET = array_merge($_GET, $gets); $_REQUEST = array_merge($_REQUEST, $gets); } // we will execute the index.php script in due course. But if the rule // action takes us elsewhere we will have to re-direct to that script. if (isset($action[1]) && $action[1] != 'index.php') { $qs = http_build_query($_GET); if ($qs) { $qs = '?' . $qs; } if (array_key_exists('R', $flags)) { header('Status: ' . $flags['R']); } header('Location: ' . WEBPATH . '/' . $action[1] . $qs); exit; } $_zp_rewritten = true; break; } } else { zp_error(sprintf(gettext('Error processing rewrite rule: “%s”'), trim(preg_replace('~^rewriterule~i', '', $rule))), E_USER_WARNING); } } else { if (preg_match('~define\\s+(.*?)\\s*\\=\\>\\s*(.*)$~i', $rule, $matches)) { // store definitions eval('$definitions[$matches[1]] = ' . $matches[2] . ';'); } } } } } }
$rules[$file->getBasename('.json')] = json_decode(file_get_contents($file->getRealPath()), true); } } return $rules; } /** * @param string $fileName * @param array $rules * * @return bool */ function insertRules($fileName, array $rules = []) { $startTag = '/*INSERT_START*/'; $endTag = '/*INSERT_END*/'; $content = file_get_contents($fileName); $content = preg_replace($regexp = sprintf('#%s(.*)%s#s', quotemeta($startTag), quotemeta($endTag)), $startTag . var_export($rules, true) . $endTag, $content); return false !== file_put_contents($fileName, $content); } $directory = __DIR__ . '/../Resources/rules'; $fileName = __DIR__ . '/../src/RuleProvider/DefaultRuleProvider.php'; $rules = getRules($directory); $result = insertRules($fileName, $rules); $ruleCount = array_reduce($rules, function ($count, $rules) { return $count + count($rules); }, 0); if ($result) { printf("Written %d rules into '%s'.\n", $ruleCount, $fileName); } else { printf("Error writing rules into '%s'.\n", $fileName); }