if (in_array($database, $_SESSION["dbzugriff"])) {
        $erlaubnis = -1;
    }
}
$url = tname2path($environment["parameter"][2]);
$tname2path = tname2path($environment["parameter"][2]);
if (is_array($cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]) && $cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]["category"] != "") {
    $kate = $cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]["category"];
    $laenge = strlen($kate) + 2;
    $sql = "SELECT SUBSTR(content,POSITION('[" . $kate . "]' IN content)+" . $laenge . ",POSITION('[/" . $kate . "]' IN content)-" . $laenge . "-POSITION('[" . $kate . "]' IN content) )as check_url from site_text where tname = '" . $environment["parameter"][2] . "'";
    $result = $db->query($sql);
    $data = $db->fetch_array($result, 1);
    $artikel_check = priv_check($data["check_url"], $cfg["wizard"]["right"]["edit"]);
    $artikel_check_publish = priv_check($data["check_url"], "publish");
}
if ($cfg["wizard"]["right"]["edit"] == "" || priv_check($url, $cfg["wizard"]["right"]["edit"]) || priv_check(tname2path($environment["parameter"][2]), $cfg["wizard"]["right"]["edit"]) || priv_check_old("", $cfg["wizard"]["right"]) || $artikel_check || $rechte["administration"] == -1 || $erlaubnis == -1) {
    // unzugaengliche #(marken) sichtbar machen
    // ***
    if (isset($_GET["edit"])) {
        $ausgaben["inaccessible"] = "inaccessible values:<br />";
        $ausgaben["inaccessible"] .= "# (error_result) #(error_result)<br />";
        $ausgaben["inaccessible"] .= "# (error_dupe) #(error_dupe)<br />";
    } else {
        $ausgaben["inaccessible"] = "";
    }
    // form options holen
    $form_options = form_options(eCRC("/admin/menued") . ".add");
    // fehlermeldungen
    $ausgaben["form_error"] = $_SESSION["form_error"]["desc"];
    if (strstr($_SERVER["HTTP_REFERER"], "auth/login")) {
        $ausgaben["form_referer"] = "/auth/login.html";
// + + +
// leere parameter abfangen
$ausgaben["empty_show_url"] = $cfg["wizard"]["basis"] . "/" . implode(",", array_slice($environment["parameter"], 0, 6)) . ",none.html";
// spezial-check fuer artikel mit kategorie
$artikel_check = "";
$artikel_check_publish = "";
if (is_array($cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]) && $cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]["category"] != "") {
    $kate = $cfg["bloged"]["blogs"][substr($tname2path, 0, strrpos($tname2path, "/"))]["category"];
    $laenge = strlen($kate) + 2;
    $sql = "SELECT SUBSTR(content,POSITION('[" . $kate . "]' IN content)+" . $laenge . ",POSITION('[/" . $kate . "]' IN content)-" . $laenge . "-POSITION('[" . $kate . "]' IN content) )as check_url from site_text where tname = '" . $environment["parameter"][2] . "'";
    $result = $db->query($sql);
    $data = $db->fetch_array($result, 1);
    $artikel_check = priv_check($data["check_url"], $cfg["wizard"]["right"]["edit"]);
    $artikel_check_publish = priv_check($data["check_url"], "publish");
}
if (priv_check($tname2path, $cfg["wizard"]["right"]["edit"]) || $artikel_check || priv_check($tname2path, $cfg["wizard"]["right"]["publish"]) || priv_check_old("", $cfg["wizard"]["right"])) {
    // page basics
    // ***
    if ($environment["parameter"][5] != "") {
        $version = " AND version=" . $environment["parameter"][5];
    } else {
        $version = "";
    }
    $sql = "SELECT *\n                  FROM " . SITETEXT . "\n                 WHERE lang = '" . $environment["language"] . "'\n                   AND label ='" . $environment["parameter"][3] . "'\n                   AND tname ='" . $environment["parameter"][2] . "'\n                       {$version}\n              ORDER BY version DESC\n                 LIMIT 0,1";
    if ($debugging["sql_enable"]) {
        $debugging["ausgabe"] .= "sql: " . $sql . $debugging["char"];
    }
    $result = $db->query($sql);
    $content_exists = $db->num_rows($result);
    $form_values = $db->fetch_array($result, 1);
    // falls content in session zwischengespeichert ist, diesen holen
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$position = $environment["parameter"][1] + 0;
// als tname werden die SESSIONS "ebene" u. "kategorie" verwendet
if ($environment["parameter"][2] == "") {
    if ($_SESSION["ebene"] != "") {
        $pfad = $_SESSION["ebene"] . "/" . $_SESSION["kategorie"];
        $tname = eCRC($_SESSION["ebene"]) . "." . $_SESSION["kategorie"];
    } else {
        $pfad = "/" . $_SESSION["kategorie"];
        $tname = $_SESSION["kategorie"];
    }
} else {
    $tname = $environment["parameter"][2];
    $pfad = tname2path($tname);
}
if (priv_check($pfad, $cfg["contented"]["right"]) || priv_check_old("", $cfg["contented"]["right"])) {
    // parameter-uebersicht
    //      1: selector-position                                2: tname
    //      3: label                                            4: old (versionsnr)
    //      5: new (versionsnr)                                 6: geparster Content? (->'html')
    //      7: diff-Typ (vgl $cfg[contented]["diff_engine"])
    // ueberschrift
    $ausgaben["url"] = $pfad;
    // label steuerung wenn kein para dann wird default-label aus cfg hergenommen
    if ($environment["parameter"][3] == "") {
        $label = $cfg["contented"]["default_label"];
    } else {
        $label = $environment["parameter"][3];
    }
    $old = $environment["parameter"][4];
    $new = $environment["parameter"][5];
    You may contact the author/development team at:

    Chaos Networks
    c/o Werner Ammon
    Lerchenstr. 11c

    86343 Königsbrunn

    URL: http://www.chaos.de
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($debugging["html_enable"]) {
    $debugging["ausgabe"] .= "[ ** " . $script["name"] . " ** ]" . $debugging["char"];
}
if ($cfg["bloged"]["blogs"][make_ebene($environment["parameter"][4])]["right"] == "" || (priv_check(make_ebene($environment["parameter"][3]), $cfg["bloged"]["blogs"][make_ebene($environment["parameter"][4])]["right"]) || function_exists(priv_check_old) && priv_check_old("", $cfg["bloged"]["blogs"][make_ebene($environment["parameter"][4])]["right"]))) {
    function renumber_blog($kategorie = "")
    {
        global $db, $environment, $blog, $cfg, $status;
        $where = "";
        if ($kategorie != "") {
            $where = " AND SUBSTR(content,POSITION('[" . $cfg["bloged"]["blogs"][$blog]["category"] . "]' IN content)+11,POSITION('[/" . $cfg["bloged"]["blogs"][$blog]["category"] . "]' IN content)-11-POSITION('[" . $cfg["bloged"]["blogs"][$blog]["category"] . "]' IN content)) ='" . $kategorie . "'";
        }
        $sql = "SELECT Cast(SUBSTR(content,POSITION('[" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "]' IN content)+6,POSITION('[/" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "]' IN content)-POSITION('[" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "]' IN content)-6) AS SIGNED) AS date,content,tname \n                    FROM site_text \n                    WHERE " . $status . " AND tname like '" . eCRC(make_ebene($environment["parameter"][4])) . ".%'" . $where . " order by date ASC";
        $result = $db->query($sql);
        $count = 0;
        $preg = "^\\[!\\][0-9]*";
        while ($data = $db->fetch_array($result, 1)) {
            $count = $count + 10;
            $content = preg_replace("|\\[" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "\\][-0-9]*\\[\\/" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "\\]|", "\\[" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "\\]" . $count . "[\\/" . $cfg["bloged"]["blogs"][$blog]["sort"][0] . "\\]", $data["content"]);
            $sql_update = "UPDATE site_text SET content='" . $content . "' WHERE " . $status . " and tname ='" . $data["tname"] . "'";
    You may contact the author/development team at:

    Chaos Networks
    c/o Werner Ammon
    Lerchenstr. 11c

    86343 Königsbrunn

    URL: http://www.chaos.de
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$check_url = $_POST["kategorie"];
if ($_POST["kategorie"] == "") {
    $check_url = $_POST["link"];
}
if ($cfg["bloged"]["blogs"][$_POST["link"]]["right"] == "" || (priv_check($check_url, $cfg["bloged"]["blogs"][$_POST["link"]]["right"]) || function_exists(priv_check_old) && priv_check_old("", $cfg["bloged"]["blogs"][$_POST["link"]]["right"]))) {
    function create($id)
    {
        global $cfg, $db, $header, $debugging, $_POST, $environment, $pathvars, $ebene;
        if ($cfg["bloged"]["blogs"][$ebene]["sort"][1] == -1) {
            $sort = "1000";
        } else {
            if ($_POST["SORT"] != "") {
                $sort = $_POST["SORT"];
            } else {
                $sort = date("Y-m-d H:i:s");
            }
        }
        $sqla = "lang";
        $sqlb = "'de'";
        $sqla .= ", label";
         $search .= strftime('%B', mktime(0, 0, 0, $monat, $tag, $jahr)) . " ";
     }
     if ($environment["parameter"][4] != "") {
         $search .= $jahr;
     }
     $hidedata["anfrage"]["suche"] = $search;
 }
 //keine treffer
 $ausgaben["hit"] = "#(hit)";
 if (count($dataloop["list"]) == 0) {
     $ausgaben["hit"] = "#(no_hit)";
     unset($hidedata["inhalt_selector"]);
 }
 // liste
 // new link
 if ($cfg["bloged"]["blogs"][$url]["right"] == "" || (priv_check($url, $cfg["bloged"]["blogs"][$url]["right"]) || function_exists(priv_check_old) && priv_check_old("", $cfg["bloged"]["blogs"][$url]["right"]))) {
     $hidedata["newlink"]["link"] = $pathvars["virtual"] . $url . ",,,,add.html";
 }
 switch ($environment["parameter"][7]) {
     case "group":
         if (is_array($work)) {
             foreach ($work as $key => $value) {
                 $array[$value["veranstalter_org"]][$key]["name"] = $value["name_org"];
                 $array[$value["veranstalter_org"]][$key]["termin"] = $value["termin_org"];
                 $array[$value["veranstalter_org"]][$key]["termin_en"] = $value["termin_en_org"];
                 $array[$value["veranstalter_org"]][$key]["veranstalter"] = $value["veranstalter_org"];
                 $array[$value["veranstalter_org"]][$key]["datum"] = $value["datum"];
                 $array[$value["veranstalter_org"]][$key]["ort"] = $value["ort_org"];
                 $array[$value["veranstalter_org"]][$key]["beschreibung"] = $value["beschreibung_org"];
                 $array[$value["veranstalter_org"]][$key]["deletelink"] = $value["deletelink"];
                 $array[$value["veranstalter_org"]][$key]["editlink"] = $value["editlink"];