First init as an backup of all the data. for the future use.

This commit is contained in:
2017-07-18 11:33:10 +02:00
commit f0f07b7ae7
9 changed files with 538 additions and 0 deletions

88
index.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$path = strtolower(trim(stripslashes(isset($_GET['path']) ? $_GET['path'] : ''), '/'));
list($action, $parameter) = array_pad(explode('/', $path), 2, null);
switch ($action) {
case 'list':
$db = new SQLite3('geo.db');
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
$rows = [];
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
$rows[] = $row;
}
include 'templates/list.php';
break;
case 'delete':
$db = new SQLite3('geo.db');
$stmt = $db->prepare('DELETE FROM location WHERE id = :id');
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
$entry = $stmt->execute();
header('Location: /list');
break;
case 'edit':
$db = new SQLite3('geo.db');
$stmt = $db->prepare('SELECT * FROM location WHERE id = :id');
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
$entry = $stmt->execute();
$entry = $entry->fetchArray(SQLITE3_ASSOC);
include 'templates/edit.php';
break;
case 'save':
$db = new SQLite3('geo.db');
//edycja
if (isset($parameter) && !is_null($parameter) && (int)$parameter > 0) {
$stmt = $db->prepare('UPDATE location SET title=:title, description=:description, dl=:dl, szer=:szer, up_dt=:up_dt WHERE id=:id');
$stmt->bindValue(':id', $parameter, SQLITE3_TEXT);
} else { //nowy wpis
$stmt = $db->prepare('INSERT INTO location (title, description, dl, szer, cre_dt, up_dt) VALUES (:title, :description, :dl, :szer, :cre_dt, :up_dt)');
$stmt->bindValue(':cre_dt', date('Y-m-d H:i:s'), SQLITE3_TEXT);
}
$stmt->bindValue(':title', $_POST['title'], SQLITE3_TEXT);
$stmt->bindValue(':description', $_POST['desc'], SQLITE3_TEXT);
$stmt->bindValue(':szer', $_POST['szer'], SQLITE3_TEXT);
$stmt->bindValue(':dl', $_POST['dl'], SQLITE3_TEXT);
$stmt->bindValue(':up_dt', date('Y-m-d H:i:s'), SQLITE3_TEXT);
$entry = $stmt->execute();
var_dump($entry->numColumns());
header('Location: /list');
break;
case 'mapa':
$db = new SQLite3('geo.db');
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
$rows = [];
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
$rows[] = $row;
}
include 'templates/mapa.php';
break;
default:
include 'templates/main.php';
break;
}