Improved index.php a bit and added a clean version of database file.
This commit is contained in:
BIN
geo-empty.db
Normal file
BIN
geo-empty.db
Normal file
Binary file not shown.
12
index.php
12
index.php
@@ -9,11 +9,11 @@ $path = strtolower(trim(stripslashes(isset($_GET['path']) ? $_GET['path'] : ''),
|
|||||||
|
|
||||||
|
|
||||||
list($action, $parameter) = array_pad(explode('/', $path), 2, null);
|
list($action, $parameter) = array_pad(explode('/', $path), 2, null);
|
||||||
|
$db = new SQLite3('geo.db');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
|
||||||
case 'list':
|
case 'list':
|
||||||
$db = new SQLite3('geo.db');
|
|
||||||
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
|
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
|
||||||
$rows = [];
|
$rows = [];
|
||||||
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
|
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
|
||||||
@@ -25,8 +25,6 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$db = new SQLite3('geo.db');
|
|
||||||
|
|
||||||
$stmt = $db->prepare('DELETE FROM location WHERE id = :id');
|
$stmt = $db->prepare('DELETE FROM location WHERE id = :id');
|
||||||
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
|
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
|
||||||
$entry = $stmt->execute();
|
$entry = $stmt->execute();
|
||||||
@@ -34,8 +32,6 @@ switch ($action) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
|
||||||
$db = new SQLite3('geo.db');
|
|
||||||
$stmt = $db->prepare('SELECT * FROM location WHERE id = :id');
|
$stmt = $db->prepare('SELECT * FROM location WHERE id = :id');
|
||||||
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
|
$stmt->bindValue(':id', $parameter, SQLITE3_INTEGER);
|
||||||
$entry = $stmt->execute();
|
$entry = $stmt->execute();
|
||||||
@@ -43,9 +39,6 @@ switch ($action) {
|
|||||||
include 'templates/edit.php';
|
include 'templates/edit.php';
|
||||||
break;
|
break;
|
||||||
case 'save':
|
case 'save':
|
||||||
|
|
||||||
$db = new SQLite3('geo.db');
|
|
||||||
|
|
||||||
//edycja
|
//edycja
|
||||||
if (isset($parameter) && !is_null($parameter) && (int)$parameter > 0) {
|
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 = $db->prepare('UPDATE location SET title=:title, description=:description, dl=:dl, szer=:szer, up_dt=:up_dt WHERE id=:id');
|
||||||
@@ -70,15 +63,12 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'mapa':
|
case 'mapa':
|
||||||
$db = new SQLite3('geo.db');
|
|
||||||
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
|
$results = $db->query('SELECT * FROM location ORDER BY cre_dt DESC');
|
||||||
$rows = [];
|
$rows = [];
|
||||||
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
|
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
include 'templates/mapa.php';
|
include 'templates/mapa.php';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
include 'templates/main.php';
|
include 'templates/main.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user