diff --git a/www/_templates/Template.php b/www/_templates/Template.php
index 2739e6f..a633a3f 100644
--- a/www/_templates/Template.php
+++ b/www/_templates/Template.php
@@ -3,22 +3,26 @@
// All credit goes to Chad Minick:
// http://chadminick.com/articles/simple-php-template-engine.html
-class Template {
- private $vars = array();
+class Template
+{
+ private $vars = array();
- public function __get($name) {
+ public function __get($name)
+ {
return $this->vars[$name];
}
- public function __set($name, $value) {
- if($name == 'view_template_file') {
+ public function __set($name, $value)
+ {
+ if ($name == 'view_template_file') {
throw new Exception("Cannot bind variable named 'view_template_file'");
}
$this->vars[$name] = $value;
}
- public function render($view_template_file) {
- if(array_key_exists('view_template_file', $this->vars)) {
+ public function render($view_template_file)
+ {
+ if (array_key_exists('view_template_file', $this->vars)) {
throw new Exception("Cannot bind variable called 'view_template_file'");
}
extract($this->vars);
diff --git a/www/_templates/admin_doc_edit.php b/www/_templates/admin_doc_edit.php
index 359c013..e2f742c 100644
--- a/www/_templates/admin_doc_edit.php
+++ b/www/_templates/admin_doc_edit.php
@@ -1,25 +1,27 @@
= $doc["Title"] ?>
-
+
-
= $doc["Author"] ?>
+
= $doc["Author"] ?>
-
+
-
Published: = $doc["Published"] ?>
+
Published: = $doc["Published"] ?>
-
+
-
Tags:
-
- foreach($doc["tags"] as $tag){
- echo '
" . $tag["Name"] . "";
- }
- ?>
-
+
Tags:
+
+ foreach ($doc["tags"] as $tag) {
+ echo '
" . $tag["Name"] . "";
+ }
+ ?>
+
-
+
-
= empty($doc["URL"]) ? "Content" : "Description" ?>: = $doc["Description"] ?>
+
= empty($doc["URL"]) ? "Content" : "Description" ?>
+ : = $doc["Description"] ?>
-
+
diff --git a/www/_templates/front_intro.php b/www/_templates/front_intro.php
index 74853a5..b1f92e9 100644
--- a/www/_templates/front_intro.php
+++ b/www/_templates/front_intro.php
@@ -1,5 +1,8 @@
-
This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...
-
Tohle je hromádka zajÃmavýho materiálu co nÄ›co znamená v kontextu sdbs - budeme sem postupnÄ› dávat ty nejdůležitÄ›jÅ¡Ã nebo nejzajÃmavÄ›jÅ¡Ã vÄ›ci, zatim se o tom ale nikde moc neÅ¡iÅ™te.
+
This site is the sdbs pile, where we upload the stuff we consider important to the larger
+ conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to
+ self-determination, counter-culture and such...
+
Tohle je hromádka zajÃmavýho materiálu co nÄ›co znamená v kontextu sdbs - budeme sem postupnÄ›
+ dávat ty nejdůležitÄ›jÅ¡Ã nebo nejzajÃmavÄ›jÅ¡Ã vÄ›ci, zatim se o tom ale nikde moc neÅ¡iÅ™te.
/-\
\ No newline at end of file
diff --git a/www/_templates/front_wrap.php b/www/_templates/front_wrap.php
index acc1e40..269bd72 100644
--- a/www/_templates/front_wrap.php
+++ b/www/_templates/front_wrap.php
@@ -1,67 +1,71 @@
-
-
-
This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...
-
Tohle je hromádka zajÃmavýho materiálu co nÄ›co znamená v kontextu sdbs - budeme sem postupnÄ› dávat ty nejdůležitÄ›jÅ¡Ã nebo nejzajÃmavÄ›jÅ¡Ã vÄ›ci, zatim se o tom ale nikde moc neÅ¡iÅ™te.
+
This site is the sdbs pile, where we upload the stuff we consider important to the larger
+ conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to
+ self-determination, counter-culture and such...
+
Tohle je hromádka zajÃmavýho materiálu co nÄ›co znamená v kontextu sdbs - budeme sem postupnÄ›
+ dávat ty nejdůležitÄ›jÅ¡Ã nebo nejzajÃmavÄ›jÅ¡Ã vÄ›ci, zatim se o tom ale nikde moc neÅ¡iÅ™te.
/-\
\ No newline at end of file
diff --git a/www/_util/PileDB.php b/www/_util/PileDB.php
index e60e1a8..baae02b 100644
--- a/www/_util/PileDB.php
+++ b/www/_util/PileDB.php
@@ -1,25 +1,32 @@
db = new SQLite3("pile.db");
}
- function prepare($statement){
+ function prepare($statement)
+ {
return $this->db->prepare($statement);
}
- function query($statement){
+ function query($statement)
+ {
return $this->db->query($statement);
}
- public function getDocCount(){
+ public function getDocCount()
+ {
$ret_count = $this->db->query("SELECT count(ID) FROM Documents")->fetchArray(SQLITE3_NUM);
return $ret_count[0];
}
-
- public function getUntaggedDocCount(){
+
+ public function getUntaggedDocCount()
+ {
$ret_count = $this->db->query("SELECT
count(ID)
FROM
@@ -30,7 +37,8 @@ class PileDB {
return $ret_count[0];
}
- public function getTags(){
+ public function getTags()
+ {
$tag_query = "SELECT
ID, Name, count(Document)
FROM
@@ -51,7 +59,8 @@ class PileDB {
return $tags;
}
- public function fetchDoc($id){
+ public function fetchDoc($id)
+ {
$stmt_doc = $this->db->prepare("SELECT * FROM Documents WHERE ID = :id");
$stmt_doc->bindValue(":id", $id, SQLITE3_INTEGER);
$doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC);
@@ -69,10 +78,11 @@ class PileDB {
return $doc;
}
- public function listDocs(){
- if (func_num_args() > 0){
+ public function listDocs()
+ {
+ if (func_num_args() > 0) {
$tag = func_get_arg(0);
- if ($tag > 0 ) {
+ if ($tag > 0) {
$stmt = $this->db->prepare("SELECT
ID, Title, Author, Published, URL
FROM
@@ -103,8 +113,9 @@ class PileDB {
return $docs;
}
- public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids){
- if ( empty($id) ){
+ public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids)
+ {
+ if (empty($id)) {
$stmt = $this->db->prepare("INSERT INTO Documents
(ID, Title, Author, Description, Published, URL)
VALUES
@@ -125,18 +136,18 @@ class PileDB {
$stmt->bindValue(":published", $published, SQLITE3_TEXT);
$stmt->bindValue(":url", $url, SQLITE3_TEXT);
$stmt->execute();
- if ( empty($id) ){
+ if (empty($id)) {
$id = $this->db->lastInsertRowid();
}
- if ( ! empty($id) ){
+ if (!empty($id)) {
$delete_stmt = $this->db->prepare("DELETE FROM DocumentsToTags
WHERE Document = :id");
$delete_stmt->bindValue(":id", $id, SQLITE3_INTEGER);
$delete_stmt->execute();
}
- foreach ($tag_ids as $tag){
+ foreach ($tag_ids as $tag) {
$tag_stmt = $this->db->prepare("INSERT INTO DocumentsToTags ('Document', 'Tag')
VALUES (:doc, :tag)");
$tag_stmt->bindValue("doc", $id, SQLITE3_INTEGER);
@@ -145,32 +156,36 @@ class PileDB {
}
}
- public function removeDoc($id){
+ public function removeDoc($id)
+ {
$doc_stmt = $this->db->prepare("DELETE FROM Documents
WHERE ID = :id");
$doc_stmt->bindValue("id", $id, SQLITE3_INTEGER);
$doc_stmt->execute();
-
+
$tag_stmt = $this->db->prepare("DELETE FROM DocumentsToTags
WHERE Document = :id");
$tag_stmt->bindValue("id", $id, SQLITE3_INTEGER);
$tag_stmt->execute();
}
- public function findTag($name){
+ public function findTag($name)
+ {
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE Name == :name COLLATE NOCASE");
$stmt->bindValue(":name", $name, SQLITE3_TEXT);
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
}
- public function fetchTag($tag){
+ public function fetchTag($tag)
+ {
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE ID == :tag");
$stmt->bindValue(":tag", $tag, SQLITE3_INTEGER);
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
}
- public function updateTag($id, $name, $description){
- if (empty($id)){
+ public function updateTag($id, $name, $description)
+ {
+ if (empty($id)) {
$stmt = $this->db->prepare("INSERT INTO Tags
(ID, Name, Description)
VALUES
@@ -188,7 +203,8 @@ class PileDB {
return $stmt->execute();
}
- public function authenticate($username, $password){
+ public function authenticate($username, $password)
+ {
$stmt = $this->db->prepare("SELECT
*
FROM
@@ -199,11 +215,12 @@ class PileDB {
$auth_ret = $stmt->execute();
$auth = $auth_ret->fetchArray(SQLITE3_ASSOC);
- if (password_verify($password, $auth["Password"])){
+ if (password_verify($password, $auth["Password"])) {
return $auth["ID"];
} else {
return -1;
}
}
}
+
?>
diff --git a/www/_util/Uploader.php b/www/_util/Uploader.php
index 5c9a874..1007beb 100644
--- a/www/_util/Uploader.php
+++ b/www/_util/Uploader.php
@@ -1,7 +1,10 @@
-class Uploader {
- public function handle($files, $dir){
- if ( is_array($files['upfile']['error']) ) {
+
+class Uploader
+{
+ public function handle($files, $dir)
+ {
+ if (is_array($files['upfile']['error'])) {
throw new RuntimeException('Invalid parameters.');
}
@@ -20,20 +23,20 @@ class Uploader {
$finfo = new finfo(FILEINFO_MIME_TYPE);
if (false === $ext = array_search(
- $finfo->file($files['upfile']['tmp_name']),
- array(
- 'pdf' => 'application/pdf',
- 'zip' => 'application/zip',
- 'rar' => 'application/rar'
- ),
- true
- )) {
+ $finfo->file($files['upfile']['tmp_name']),
+ array(
+ 'pdf' => 'application/pdf',
+ 'zip' => 'application/zip',
+ 'rar' => 'application/rar'
+ ),
+ true
+ )) {
throw new RuntimeException('Invalid file format.');
}
$name = basename($files['upfile']['name']);
- $name = preg_replace('/[^\x20-\x7E]/','', $name);
- if ($name != ".htaccess"){
+ $name = preg_replace('/[^\x20-\x7E]/', '', $name);
+ if ($name != ".htaccess") {
if (!move_uploaded_file(
$files['upfile']['tmp_name'],
$dir . $name)) {
@@ -46,4 +49,5 @@ class Uploader {
return $name;
}
}
+
?>
diff --git a/www/admin.php b/www/admin.php
index 9efda29..694a2a5 100644
--- a/www/admin.php
+++ b/www/admin.php
@@ -8,23 +8,23 @@ $db = new PileDB();
$uploader = new Uploader();
session_start();
-if (isset($_SESSION['ID'])){
+if (isset($_SESSION['ID'])) {
$page = new Template();
- if (isset($_GET["action"])){
- switch ($_GET["action"]){
+ if (isset($_GET["action"])) {
+ switch ($_GET["action"]) {
case "new_tag":
$content = $page->render("admin_tag_edit.php");
break;
case "edit_tag":
- if (isset($_POST["Name"])){
+ if (isset($_POST["Name"])) {
$db->updateTag(
$_GET["tag"],
$_POST["Name"],
$_POST["Description"]
);
}
- if ( !empty($_GET["tag"]) ) {
+ if (!empty($_GET["tag"])) {
$page->tag = $db->fetchTag($_GET["tag"]);
}
$content = $page->render("admin_tag_edit.php");
@@ -33,18 +33,18 @@ if (isset($_SESSION['ID'])){
$content = $page->render("admin_doc_edit.php");
break;
case "edit_item":
- if (isset($_POST["Title"]) || !empty($_FILES['upfile']['name']) ){
+ if (isset($_POST["Title"]) || !empty($_FILES['upfile']['name'])) {
$title = $_POST["Title"];
-
- if ( !empty($_FILES['upfile']['name']) ){
+
+ if (!empty($_FILES['upfile']['name'])) {
try {
- if ( empty($title) ){
+ if (empty($title)) {
$title = pathinfo($_FILES['upfile']['name'], PATHINFO_FILENAME);
$title = str_replace("_", " ", $title);
$title = trim($title);
}
$url = "http://pile.sdbs.cz/docs/" . rawurlencode($uploader->handle($_FILES, "docs/"));
- } catch (RuntimeException $ex){
+ } catch (RuntimeException $ex) {
$page->text = $ex->getMessage();
echo $page->render('full_text.php');
return;
@@ -54,10 +54,10 @@ if (isset($_SESSION['ID'])){
}
$doc_tags = [];
- foreach (explode(",", $_POST["Tags"]) as $tagName){
+ foreach (explode(",", $_POST["Tags"]) as $tagName) {
$tagName = trim($tagName);
$tag = $db->findTag($tagName);
- if (!in_array($tag["ID"], $doc_tags)){
+ if (!in_array($tag["ID"], $doc_tags)) {
array_push($doc_tags, $tag["ID"]);
}
}
@@ -73,14 +73,14 @@ if (isset($_SESSION['ID'])){
);
}
- if ( !empty($_GET["item"]) ) {
+ if (!empty($_GET["item"])) {
$page->doc = $db->fetchDoc($_GET["item"]);
}
$content = $page->render("admin_doc_edit.php");
break;
case "remove":
- if ( ! empty($_GET["confirm"]) && $_GET["confirm"] == "yes"){
+ if (!empty($_GET["confirm"]) && $_GET["confirm"] == "yes") {
$db->removeDoc($_GET["item"]);
$page->text = "Document deleted.";
$page->redirect = $_GET["ret"];
@@ -100,7 +100,7 @@ if (isset($_SESSION['ID'])){
}
} elseif (isset($_GET["tag"])) {
$doc_list_template = new Template();
- if ($_GET["tag"] == "*"){
+ if ($_GET["tag"] == "*") {
$docs = $db->listDocs();
} elseif ($_GET["tag"] == "_") {
$docs = $db->listDocs(-1);
@@ -129,19 +129,19 @@ if (isset($_SESSION['ID'])){
} else {
$page = new Template();
- if (isset($_POST['username']) && isset($_POST['password'])){
+ if (isset($_POST['username']) && isset($_POST['password'])) {
$ret_id = $db->authenticate($_POST["username"], $_POST["password"]);
- if ($ret_id > 0){
+ if ($ret_id > 0) {
$_SESSION['ID'] = $ret_id;
$page->text = "You have logged in successfully.";
- $page->redirect = "admin.php";
+ $page->redirect = "admin.php";
} else {
$page->text = "Username and/or password incorrect.";
- $page->redirect = "/";
+ $page->redirect = "/";
}
} else {
$page->text = "Please log in before accessing this page.";
- $page->redirect = "/";
+ $page->redirect = "/";
}
echo $page->render('full_text.php');
diff --git a/www/assets/admin.css b/www/assets/admin.css
index 380b532..0ea6a3c 100644
--- a/www/assets/admin.css
+++ b/www/assets/admin.css
@@ -4,11 +4,13 @@
}
*, *:before, *:after {
- -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
}
body {
- font-family: Prociono;
+ font-family: Prociono, serif;
margin: 0;
padding: 0;
position: relative;
@@ -27,7 +29,7 @@ a {
#sidebar-head {
background-color: #f2f2f2;
- color: 202020;
+ color: #202020;
text-align: center;
}
@@ -82,7 +84,7 @@ a {
margin-right: 3em;
}
-.doc-item h2 {
+.doc-item h2 {
font-size: 14pt;
font-weight: normal;
margin: 0;
@@ -164,7 +166,7 @@ a {
}
input[type="text"] {
- width: 80%;
+ width: 80%;
}
@media screen and (min-width: 64em ) {
@@ -174,26 +176,26 @@ input[type="text"] {
left: 2rem;
width: 14rem;
}
-
+
#content {
margin: 2rem 2rem 0 18rem;
padding: 0 0 2rem 0;
- }
+ }
}
-@media screen and (max-width: 64em ) {
+@media screen and (max-width: 64em ) {
#sidebar-head {
background-position: 14%;
background-size: 4rem;
height: 7rem;
margin-bottom: 1rem;
}
-
+
#sidebar-head > h1 {
padding-top: 1.5rem;
font-size: 3rem;
}
-
+
#sidebar-taglist {
margin-bottom: 1rem;
}
@@ -214,7 +216,7 @@ input[type="text"] {
height: 14pt;
font-size: 8pt;
border: 1px solid lightgray;
- background: 202020;
+ background: #202020;
}
.czech {
@@ -227,7 +229,7 @@ input[type="text"] {
margin: 0;
}
-input[type="submit"], input[type="file"]{
+input[type="submit"], input[type="file"] {
font-family: Prociono, serif;
}
diff --git a/www/assets/main.css b/www/assets/main.css
index dbfafc4..5a8bad8 100644
--- a/www/assets/main.css
+++ b/www/assets/main.css
@@ -4,7 +4,9 @@
}
*, *:before, *:after {
- -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
}
body {
@@ -28,15 +30,15 @@ a {
#sidebar-head {
background-color: #202020;
color: white;
-
+
background-image: url(/assets/pile_white.svg);
background-repeat: no-repeat;
background-position: center 1.5em;
background-size: 50%;
-
+
text-align: center;
}
-
+
#sidebar-head > h1 {
padding: 0.5em;
padding-top: 6em;
@@ -109,7 +111,6 @@ a {
}
.tag-text
-
.document h1 {
margin: 0;
font-size: 24pt;
@@ -164,26 +165,26 @@ a {
left: 2rem;
width: 14rem;
}
-
+
#content {
margin: 2rem 2rem 0 18rem;
padding: 0 0 2rem 0;
- }
+ }
}
-@media screen and (max-width: 64em ) {
+@media screen and (max-width: 64em ) {
#sidebar-head {
background-position: 14%;
background-size: 4rem;
height: 7rem;
margin-bottom: 1rem;
}
-
+
#sidebar-head > h1 {
padding-top: 1.5rem;
font-size: 3rem;
}
-
+
#sidebar-taglist {
margin-bottom: 1rem;
}
diff --git a/www/composer.json b/www/composer.json
index 6c10150..9c1ef1c 100644
--- a/www/composer.json
+++ b/www/composer.json
@@ -1,8 +1,8 @@
{
- "config": {
- "vendor-dir": "_vendor"
- },
- "require": {
- "erusev/parsedown": "^1.7"
- }
+ "config": {
+ "vendor-dir": "_vendor"
+ },
+ "require": {
+ "erusev/parsedown": "^1.7"
+ }
}
diff --git a/www/index.php b/www/index.php
index 51229bf..5438248 100644
--- a/www/index.php
+++ b/www/index.php
@@ -16,7 +16,7 @@ if (isset($_GET["item"])) {
$content = $doc_template->render('front_doc_overview.php');
} elseif (isset($_GET["tag"])) {
$doc_list_template = new Template();
- if ($_GET["tag"] == "*"){
+ if ($_GET["tag"] == "*") {
$docs = $db->listDocs();
} elseif ($_GET["tag"] == "_") {
$docs = $db->listDocs(-1);