commit f0f07b7ae79d590107721ba894543e6792eac00b Author: krzysiej Date: Tue Jul 18 11:33:10 2017 +0200 First init as an backup of all the data. for the future use. diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..b3b3e58 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine on +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/geo.db b/geo.db new file mode 100644 index 0000000..8b3517f Binary files /dev/null and b/geo.db differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..c683c67 --- /dev/null +++ b/index.php @@ -0,0 +1,88 @@ +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; + +} + diff --git a/templates/edit.php b/templates/edit.php new file mode 100644 index 0000000..d0241b0 --- /dev/null +++ b/templates/edit.php @@ -0,0 +1,71 @@ + + + + + Geo lokalizator + + + + + + + + +

Edycja wpisu

+
+ + + + + + + + + + + + + + + + + + + +
+List + + \ No newline at end of file diff --git a/templates/list.php b/templates/list.php new file mode 100644 index 0000000..6284e2d --- /dev/null +++ b/templates/list.php @@ -0,0 +1,34 @@ + + + + + Geo lokalizator + + + + +

Lista wpisów

+ +
+ + + + + + + + +
+
+
Utworzone: | Zaktualizowane:
+
Edycja | Usuń
+ + + + + +
+Główna + + \ No newline at end of file diff --git a/templates/main.php b/templates/main.php new file mode 100644 index 0000000..85b4891 --- /dev/null +++ b/templates/main.php @@ -0,0 +1,72 @@ + + + + + Geo lokalizator + + + + + + + + +

Dodaj wpis

+
+ + + + + + + + + + + + + + + + + + + + +
+List + + \ No newline at end of file diff --git a/templates/mapa.php b/templates/mapa.php new file mode 100644 index 0000000..ffd77db --- /dev/null +++ b/templates/mapa.php @@ -0,0 +1,110 @@ + + + + + Geo lokalizator + + + + + + + + + +

Mapa

+
+
+
+ +
+ +

+

+ Pokaż miejsce na mapie +
+ Dodane: | + Zaktualizowano: +
+
+ + + + +
+
+List + + \ No newline at end of file diff --git a/templates/style.php b/templates/style.php new file mode 100644 index 0000000..090fc75 --- /dev/null +++ b/templates/style.php @@ -0,0 +1,159 @@ + \ No newline at end of file