}
    return $a["group"] . $a["name"] < $b["group"] . $b["name"] ? -1 : 1;
}
$extentions = array("rules");
$values = array();
$automator_current_vars = array();
$automator_other_vars = array();
$rows = array();
if (is_dir($path)) {
    $dirContents = scandir($path);
    if (count($dirContents) > 2) {
        natsort($dirContents);
        foreach ($dirContents as $dirEntry) {
            $dirEntryFullPath = $path . "/" . $dirEntry;
            preg_replace('#/+#', '/', $dirEntryFullPath);
            if ($dirEntry != "." && $dirEntry != ".." && validExts($dirEntry, $extentions)) {
                $rulesJSON = file_get_contents($dirEntryFullPath);
                $rules = json_decode($rulesJSON, true);
                foreach ($rules["inputs"] as $rule) {
                    if ($rule["value"] != "<NOP>" && $rule["value"] != "<LABEL>") {
                        if ($dirEntryFullPath == $automator_file) {
                            $automator_vars[$rule["name"]] = "current";
                        } else {
                            if (!array_key_exists($rule["name"], $automator_vars)) {
                                $automator_vars[$rule["name"]] = "other";
                            }
                        }
                    }
                }
            }
        }
Example #2
0
if ($param != false) {
    $res = getParamVal($PARAMS_DB_PATH, $param);
    if ($res != false) {
        $res = $res[0];
        $path = $res['value'];
        if ($subpath != false) {
            $path = $path . "/" . $subpath;
        }
    }
} else {
    echo json_encode(array('iserror' => true, "result" => "KO", "errno" => 4, "errMsg" => "can't get parameter"));
    exit(1);
}
$values = array();
if (is_dir($path)) {
    $dirContents = scandir($path);
    if (count($dirContents) > 2) {
        natsort($dirContents);
        foreach ($dirContents as $dirEntry) {
            $dirEntryFullPath = $path . "/" . $dirEntry;
            preg_replace('#/+#', '/', $dirEntryFullPath);
            if ($excludes != false && in_array($dirEntryFullPath, $excludes)) {
                continue;
            }
            if (substr($dirEntry, 0, 1) != "." && !is_dir($dirEntryFullPath) && validExts($dirEntry, $extentions) && validPrefixes($dirEntry, $prefixes)) {
                array_push($values, $dirEntry);
            }
        }
    }
}
echo json_encode(array('iserror' => false, "result" => "OK", "values" => $values, "errno" => 0));