Exemple #1
0
             $s_name = $line;
             if ($level <= $c_level) {
                 end($sections);
                 for ($i = $level; $i <= key($sections); $i++) {
                     unset($sections[$i]);
                 }
                 end($counters);
                 for ($i = $level; $i <= key($counters); $i++) {
                     unset($counters[$i]);
                 }
             }
             $section = end($sections);
             $counter = end($counters) + 1;
             if ($s_query->execute() !== false) {
                 $counters[key($counters)]++;
                 $sections[$level] = $sqlite->querySingle("select s_id from sections where rowid=" . $sqlite->lastInsertRowId(), false);
                 $counters[$level] = 0;
                 $section = $sections[$level];
                 $c_level = $level;
             }
         } else {
             $params = preg_split("/\\s+/", trim($line), 2);
             $l_url = $params[0];
             $l_comment = isset($params[1]) ? $params[1] : "";
             $l_query->execute();
         }
     }
 }
 fclose($defaults);
 $s_query->close();
 $l_query->close();
Exemple #2
0
<?php

require "../includes/include.php";
if (!empty($_POST["url"]) && is_numeric($_POST["section"]) && intval($_POST["section"]) > 0) {
    $sqlite = new SQLite3($db_str, SQLITE3_OPEN_READWRITE);
    $url = $_POST["url"];
    $comment = $_POST["comment"];
    $section = is_numeric($_POST["section"]) && intval($_POST["section"]) > 0 ? intval($_POST["section"]) : null;
    if (sectionExists($section)) {
        $insert = $sqlite->prepare("insert into links (l_url,l_comment,l_section) values (:url,:comment,:section)");
        $insert->bindValue("url", $url, SQLITE3_TEXT);
        $insert->bindValue("comment", $comment, SQLITE3_TEXT);
        $insert->bindValue("section", $section, SQLITE3_INTEGER);
        if ($insert->execute() !== false) {
            $id = $sqlite->querySingle("select l_id from links where rowid=" . $sqlite->lastInsertRowId());
            $result = ["insert" => findLinkById($id), "success" => true, "message" => date("Y-m-d H:i:s"), "anchor" => "s{$section}"];
        } else {
            $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Unable to execute query", "anchor" => "s{$section}"];
        }
        $insert->close();
    } else {
        $result = ["insert" => ["url" => $url, "comment" => $comment, "section" => $section], "success" => false, "message" => "Section {$section} not found"];
    }
    $sqlite->close();
} else {
    $result = ["insert" => $_POST, "success" => false, "message" => "Bad request"];
}
print json_encode($result);
Exemple #3
0
<?php

require "../includes/include.php";
if (!empty($_POST["name"])) {
    $sqlite = new SQLite3($db_str, SQLITE3_OPEN_READWRITE);
    $name = $_POST["name"];
    $container = is_numeric($_POST["container"]) && intval($_POST["container"]) > 0 ? intval($_POST["container"]) : null;
    $position = is_numeric($_POST["position"]) && intval($_POST["position"]) > 0 ? intval($_POST["position"]) : 1;
    if (sectionExists($container) && hack($container, $position)) {
        $insert = $sqlite->prepare("insert into sections(s_name,s_container,s_position) values(:name,:container,:position)");
        $insert->bindValue("name", $name, SQLITE3_TEXT);
        $insert->bindValue("container", $container, SQLITE3_INTEGER);
        $insert->bindValue("position", $position, SQLITE3_INTEGER);
        if ($insert->execute() !== false) {
            $id = $sqlite->querySingle("select s_id from sections where rowid=" . $sqlite->lastInsertRowId());
            $result = ["insert" => findSectionById($id), "success" => true, "message" => date("Y-m-d H:i:s"), "anchor" => "s{$id}"];
        } else {
            $result = ["insert" => ["name" => $name, "container" => $container, "position" => $position], "success" => false, "message" => "Unable to execute query", "anchor" => "s" . ($container != null ? $container : "null")];
        }
        $insert->close();
    } else {
        $result = ["insert" => ["name" => $name, "container" => $container, "position" => $position], "success" => false, "message" => "Container {$container} not found or not accesible"];
    }
    $sqlite->close();
} else {
    $result = ["insert" => $_POST, "success" => false, "message" => "Bad request"];
}
print json_encode($result);