$weblog = weblog_from_para($weblog);
    $_GET['w'] = $weblog;
    $Current_weblog = $weblog;
} else {
    reset($Weblogs);
    $Current_weblog = key($Weblogs);
}
// check to see if we want to filter on category.
if (in_array($ye, explode("|", $Cfg['cats']))) {
    // if the second 'directory' is a category, we use that to filter whatever comes after..
    $filtercat = $ye;
    // we need to shift the year, month and day;
    $ye = $mo;
    $mo = $da;
    $da = $name;
}
// show the appropriate pages:
if (isset($ye) && isset($mo) && isset($da) && is_numeric($ye) && is_numeric($mo) && is_numeric($da)) {
    make_archive_list($ye, $mo, $da, $name);
} else {
    if (isset($ye) && isset($mo) && is_numeric($ye) && is_numeric($mo)) {
        make_archive_list($ye, $mo, "", $da);
    } else {
        if (isset($ye) && is_numeric($ye)) {
            make_archive_list($ye, "", "", $mo);
        } else {
            // just show the default page:
            make_default();
        }
    }
}
function treat_rec($rec, $deflist)
{
    global $debug;
    $has_fired = false;
    foreach ($deflist as $def) {
        $fieldname = $def["FIELD"];
        $env_field = $def["ENV_FIELD"];
        $cell = $rec[$fieldname];
        $startvalue = $def["rule_startvalue"];
        // initialize the environment with some reasonable knowledge about our world
        $env = array_merge($def, $rec);
        // THINK: what's the correct precedence? Should full $rec override the stored environment $rec[$env_field] or not? I'm unsure
        if ($env_field) {
            $stored_env = eval("return " . $rec[$env_field] . ";");
            $env = array_merge($stored_env, $env);
        }
        $env["HAS_FORKED"] = false;
        $env["IS_SON"] = false;
        $env["IS_GLOBAL"] = false;
        $env["LEVEL"] = 0;
        if (test_location($env, $def["rule_location"]) && value_matches($env, $startvalue, $cell) && test_condition($env, $def["rule_condition"])) {
            if (!$has_fired) {
                // before starting the action, remember that we have fired...
                $firevalue = make_default($def["rule_firevalue"], $cell, "start");
                do_writeback($env, $firevalue);
                $has_fired = true;
            }
            // now do the action...
            $env["VALUE"] = $cell;
            $ok = do_action($env, $env["rule_action"]);
            if (!$ok) {
                // failure: try the next alternative
                //echo "FAIL......CONTINUE\n";
                if (@$env["IS_SON"]) {
                    // mission completed...
                    if ($debug) {
                        echo "forked mission failed.\n";
                    }
                    exit(-1);
                }
                continue;
            }
            if (@$env["HAS_FORKED"] || @$env["DO_BREAK"]) {
                //echo "BREAK......\n";
                break;
            }
            // record final result of execution,
            $endvalue = "-1 ENGINE_ERROR";
            // sorry, but this should never happen: the HIT_FLAG must always be set because of the $APPEND fallbacks
            if (@$env["HIT_FLAG"] && @$env["cont_endvalue"]) {
                $endvalue = make_default($env["cont_endvalue"], $env["VALUE"], "end", 2);
            }
            do_writeback($env, $endvalue);
            // end this record
            break;
        }
    }
    // only the father process should consider the next record...
    if (@$env["IS_SON"]) {
        // mission completed...
        if ($debug) {
            echo "forked mission completed.\n";
        }
        exit(0);
    }
}
Beispiel #3
0
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             save_source($pdo);
         }
     }
     break;
 case 'edit_source':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             echo edit_source($pdo);
         }
     }
     break;
 case 'make_default':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             make_default($pdo);
         }
     }
     break;
 case 'delete':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             delete($pdo);
         }
     }
     break;
 case 'delete_source':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             delete_source($pdo);
         }