autoformat, minor corrections
This commit is contained in:
parent
8b3023aca7
commit
0974466e37
19 changed files with 334 additions and 290 deletions
|
@ -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);
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
<div class="text document edit-form">
|
||||
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>" enctype="multipart/form-data">
|
||||
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>"
|
||||
enctype="multipart/form-data">
|
||||
<strong>Title:</strong> <input type="text" name="Title" value="<?= empty($doc) ? "" : $doc["Title"] ?>"><br>
|
||||
<strong>Author:</strong> <input type="text" name="Author" value="<?= empty($doc) ? "" : $doc["Author"] ?>"><br>
|
||||
<strong>Date published:</strong> <input type="text" name="Published" value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
||||
<strong>Date published:</strong> <input type="text" name="Published"
|
||||
value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
||||
<strong>Description:</strong><br>
|
||||
<textarea name="Description" cols="120" rows="20">
|
||||
<textarea name="Description" cols="120" rows="20">
|
||||
<?= empty($doc) ? "" : $doc["Description"] ?>
|
||||
</textarea><br>
|
||||
<strong>File:</strong> <input type="file" name="upfile"><br>
|
||||
<strong>URL:</strong> <input type="text" name="URL" value="<?= empty($doc) ? "" : $doc["URL"] ?>"><br>
|
||||
<strong>Tags:</strong> <input type="text" name="Tags" value="<?
|
||||
if ( !empty($doc) ){
|
||||
$tags = [];
|
||||
foreach ($doc["tags"] as $tag){
|
||||
array_push($tags, $tag["Name"]);
|
||||
}
|
||||
echo implode(", ", $tags);
|
||||
} else if ( !empty($_GET["tag"]) ) {
|
||||
echo $_GET["tag"];
|
||||
}
|
||||
if (!empty($doc)) {
|
||||
$tags = [];
|
||||
foreach ($doc["tags"] as $tag) {
|
||||
array_push($tags, $tag["Name"]);
|
||||
}
|
||||
echo implode(", ", $tags);
|
||||
} else if (!empty($_GET["tag"])) {
|
||||
echo $_GET["tag"];
|
||||
}
|
||||
?>"><br>
|
||||
<input type="submit">
|
||||
<input type="submit">
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<?php if (isset($tag)): ?>
|
||||
<div class="text tag-text">
|
||||
<h1><?= $tag["Name"] ?></h1>
|
||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||
<a class="tag-edit-link" href="?action=edit_tag&tag=<?= $tag["ID"] ?>">[edit tag]</a>
|
||||
</div>
|
||||
<div class="text tag-text">
|
||||
<h1><?= $tag["Name"] ?></h1>
|
||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||
<a class="tag-edit-link" href="?action=edit_tag&tag=<?= $tag["ID"] ?>">[edit tag]</a>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
|
||||
<?php if ($_GET["tag"] != "*" &&
|
||||
$_GET["tag"] != "_"): ?>
|
||||
<div class="text doc-item doc-new-item">
|
||||
<a href="?action=new_item&tag=<?= $tag["Name"] ?>">
|
||||
<div class="doc-item-text">
|
||||
<h2>Upload a new document</h2>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
$_GET["tag"] != "_"): ?>
|
||||
<div class="text doc-item doc-new-item">
|
||||
<a href="?action=new_item&tag=<?= $tag["Name"] ?>">
|
||||
<div class="doc-item-text">
|
||||
<h2>Upload a new document</h2>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
|
||||
<?php foreach($docs as $doc): ?>
|
||||
<div class="text doc-item">
|
||||
<a class="doc-item-link" href="?action=remove&item=<?= $doc["ID"] ?>">[X]</a>
|
||||
<a href="?action=edit_item&item=<?= $doc["ID"]?>">
|
||||
<div class="doc-item-text">
|
||||
<h2><?= $doc["Title"]?></h2>
|
||||
<h3><?= $doc["Author"] . " " . $doc['date']?></h3>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php foreach ($docs as $doc): ?>
|
||||
<div class="text doc-item">
|
||||
<a class="doc-item-link" href="?action=remove&item=<?= $doc["ID"] ?>">[X]</a>
|
||||
<a href="?action=edit_item&item=<?= $doc["ID"] ?>">
|
||||
<div class="doc-item-text">
|
||||
<h2><?= $doc["Title"] ?></h2>
|
||||
<h3><?= $doc["Author"] . " " . $doc['date'] ?></h3>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div class="text">
|
||||
<p>Confirm deletion of <strong>"<?= $doc["Title"] ?>"</strong>:</p>
|
||||
<a href="admin.php?action=remove&confirm=yes&item=<?= $doc["ID"] ?>&ret=<?= $_SERVER['HTTP_REFERER']; ?>" class="button">Remove from database</a>
|
||||
<a href="admin.php?action=remove&confirm=yes&item=<?= $doc["ID"] ?>&ret=<?= $_SERVER['HTTP_REFERER']; ?>"
|
||||
class="button">Remove from database</a>
|
||||
</div>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<form method="post" id="form" action="admin.php?action=edit_tag<?= empty($tag) ? "" : "&tag=" . $tag["ID"] ?>">
|
||||
<strong>Name:</strong> <input type="text" name="Name" value="<?= empty($tag) ? "" : $tag["Name"] ?>"><br>
|
||||
<strong>Description:</strong><br>
|
||||
<textarea name="Description" cols="120" rows="20">
|
||||
<textarea name="Description" cols="120" rows="20">
|
||||
<?= empty($tag) ? "" : $tag["Description"] ?>
|
||||
</textarea><br>
|
||||
<input type="submit">
|
||||
<input type="submit">
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>pile ADMIN INTERFACE</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="assets/admin.css">
|
||||
</head>
|
||||
<body>
|
||||
<title>pile ADMIN INTERFACE</title>
|
||||
|
||||
<div id="sidebar">
|
||||
<div id="sidebar-head">
|
||||
<h1><a href="admin.php">pile admin</a></h1>
|
||||
</div>
|
||||
<div id="sidebar-taglist">
|
||||
<ul id="sidebar-taglist-overview">
|
||||
<li id="sidebar-taglist-top"><a href="?tag=*">ALL (<?= $all_count ?>)</a></li>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
||||
<li id="sidebar-taglist-top"><a href="?action=new_tag">ADD TAG</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<?
|
||||
foreach($tags as $tag){
|
||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<link rel="stylesheet" type="text/css" href="assets/admin.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="content">
|
||||
<?php echo $content ?>
|
||||
</div>
|
||||
|
||||
<div id="login">
|
||||
<form method="get">
|
||||
<input type="hidden" name="action" value="logout">
|
||||
<button type="submit" id="login-button">log out</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="sidebar">
|
||||
<div id="sidebar-head">
|
||||
<h1><a href="admin.php">pile admin</a></h1>
|
||||
</div>
|
||||
<div id="sidebar-taglist">
|
||||
<ul id="sidebar-taglist-overview">
|
||||
<li id="sidebar-taglist-top"><a href="?tag=*">ALL (<?= $all_count ?>)</a></li>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
||||
<li id="sidebar-taglist-top"><a href="?action=new_tag">ADD TAG</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<?
|
||||
foreach ($tags as $tag) {
|
||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<?php echo $content ?>
|
||||
</div>
|
||||
|
||||
<div id="login">
|
||||
<form method="get">
|
||||
<input type="hidden" name="action" value="logout">
|
||||
<button type="submit" id="login-button">log out</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?php if (isset($tag)): ?>
|
||||
<div class="text tag-text">
|
||||
<h1><?= $tag["Name"] ?></h1>
|
||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||
</div>
|
||||
<div class="text tag-text">
|
||||
<h1><?= $tag["Name"] ?></h1>
|
||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach($docs as $doc): ?>
|
||||
<?php foreach ($docs as $doc): ?>
|
||||
<div class="text doc-item">
|
||||
<?php if (!empty($doc["URL"])): ?>
|
||||
<a class="doc-item-link" href="<?= $doc["URL"] ?>">🔗</a>
|
||||
<?php endif; ?>
|
||||
<a href="?item=<?= $doc["ID"]?>">
|
||||
<a href="?item=<?= $doc["ID"] ?>">
|
||||
<div class="doc-item-text">
|
||||
<h2><?= $doc["Title"]?></h2>
|
||||
<h3><?= $doc["Author"] . " " . $doc['date']?></h3>
|
||||
<h2><?= $doc["Title"] ?></h2>
|
||||
<h3><?= $doc["Author"] . " " . $doc['date'] ?></h3>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,29 +1,32 @@
|
|||
<div class="text document">
|
||||
<h1><?= $doc["Title"] ?></h1>
|
||||
|
||||
|
||||
<?php if (!empty($doc["Author"])): ?>
|
||||
<h2><?= $doc["Author"] ?></h2>
|
||||
<h2><?= $doc["Author"] ?></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if (!empty($doc["Published"])): ?>
|
||||
<h3>Published: <?= $doc["Published"] ?></h3>
|
||||
<h3>Published: <?= $doc["Published"] ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if (!empty($doc["tags"])): ?>
|
||||
<h3 class="doc-taglist">Tags:
|
||||
<?
|
||||
foreach($doc["tags"] as $tag){
|
||||
echo '<li><a href="?tag=' . $tag["Name"] . "\">" . $tag["Name"] . "</a></li>";
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<h3 class="doc-taglist">Tags:
|
||||
<?
|
||||
foreach ($doc["tags"] as $tag) {
|
||||
echo '<li><a href="?tag=' . $tag["Name"] . "\">" . $tag["Name"] . "</a></li>";
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if (!empty($doc["Description"])): ?>
|
||||
<p class="doc-description"><span class="doc-description-intro"><?= empty($doc["URL"]) ? "Content" : "Description" ?>: </span><?= $doc["Description"] ?></p>
|
||||
<p class="doc-description"><span
|
||||
class="doc-description-intro"><?= empty($doc["URL"]) ? "Content" : "Description" ?>
|
||||
: </span><?= $doc["Description"] ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($doc["URL"])): ?>
|
||||
<div class="doc-link"><span class="doc-link-intro">Access file at: </span><a href="<?= $doc["URL"] ?>"><?= urldecode($doc["URL"]) ?></a></div>
|
||||
<div class="doc-link"><span class="doc-link-intro">Access file at: </span><a
|
||||
href="<?= $doc["URL"] ?>"><?= urldecode($doc["URL"]) ?></a></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<div class="text">
|
||||
<p class="intro"> 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...</p>
|
||||
<p class="intro czech">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.</p>
|
||||
<p class="intro"> 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...</p>
|
||||
<p class="intro czech">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.</p>
|
||||
<p class="intro sign">/-\</p>
|
||||
</div>
|
|
@ -1,67 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>The /-\ pile</title>
|
||||
<title>The /-\ pile</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="assets/main.css">
|
||||
<link rel="stylesheet" type="text/css" href="assets/main.css">
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//www.sdbs.cz/piwik/";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', '2']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
|
||||
<!-- End Piwik Code -->
|
||||
</head>
|
||||
<body>
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function () {
|
||||
var u = "//www.sdbs.cz/piwik/";
|
||||
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
||||
_paq.push(['setSiteId', '2']);
|
||||
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||
g.type = 'text/javascript';
|
||||
g.async = true;
|
||||
g.defer = true;
|
||||
g.src = u + 'piwik.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
</script>
|
||||
<noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt=""/></p></noscript>
|
||||
<!-- End Piwik Code -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="sidebar">
|
||||
<div id="sidebar-head">
|
||||
<h1><a href="..">The /-\ pile</a></h1>
|
||||
</div>
|
||||
<div id="sidebar-taglist">
|
||||
<ul>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=*">ALL (<?= $doc_count ?>)</a></li>
|
||||
<? if ($none_count > 0): ?>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
||||
<? endif; ?>
|
||||
<?
|
||||
foreach($tags as $tag){
|
||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<?php echo $content ?>
|
||||
</div>
|
||||
|
||||
<div id="login">
|
||||
<?php if ($logged): ?>
|
||||
<form method="get" action="admin.php">
|
||||
<button type="submit" id="login-button">enter admin interface</button>
|
||||
</form>
|
||||
<? else: ?>
|
||||
<form method="post" action="admin.php">
|
||||
<input type="text" name="username" id="login-user"></input>
|
||||
<input type="password" name="password" id="login-pass"></input>
|
||||
<button type="submit" id="login-button">></button>
|
||||
</form>
|
||||
<div id="sidebar">
|
||||
<div id="sidebar-head">
|
||||
<h1><a href="..">The /-\ pile</a></h1>
|
||||
</div>
|
||||
<div id="sidebar-taglist">
|
||||
<ul>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=*">ALL (<?= $doc_count ?>)</a></li>
|
||||
<? if ($none_count > 0): ?>
|
||||
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
||||
<? endif; ?>
|
||||
</div>
|
||||
<?
|
||||
foreach ($tags as $tag) {
|
||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<?php echo $content ?>
|
||||
</div>
|
||||
|
||||
<div id="login">
|
||||
<?php if ($logged): ?>
|
||||
<form method="get" action="admin.php">
|
||||
<button type="submit" id="login-button">enter admin interface</button>
|
||||
</form>
|
||||
<? else: ?>
|
||||
<form method="post" action="admin.php">
|
||||
<input type="text" name="username" id="login-user"></input>
|
||||
<input type="password" name="password" id="login-pass"></input>
|
||||
<button type="submit" id="login-button">></button>
|
||||
</form>
|
||||
<? endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<?php if (isset($redirect)): ?>
|
||||
<meta http-equiv="refresh" content="1;URL=<?= $redirect ?>" />
|
||||
<?php endif;?>
|
||||
|
||||
<title>The /-\ pile</title>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<?php if (isset($redirect)): ?>
|
||||
<meta http-equiv="refresh" content="1;URL=<?= $redirect ?>"/>
|
||||
<?php endif; ?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="assets/main.css">
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: table
|
||||
}
|
||||
<title>The /-\ pile</title>
|
||||
|
||||
body p {
|
||||
font-size: 3rem;
|
||||
text-align: center;
|
||||
}
|
||||
<link rel="stylesheet" type="text/css" href="assets/main.css">
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: table
|
||||
}
|
||||
|
||||
div {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p>
|
||||
<?= $text ?>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
body p {
|
||||
font-size: 3rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p>
|
||||
<?= $text ?>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,8 @@
|
|||
<div class="text">
|
||||
<p class="intro"> 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...</p>
|
||||
<p class="intro czech">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.</p>
|
||||
<p class="intro"> 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...</p>
|
||||
<p class="intro czech">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.</p>
|
||||
<p class="intro sign">/-\</p>
|
||||
</div>
|
|
@ -1,25 +1,32 @@
|
|||
<?php
|
||||
class PileDB {
|
||||
|
||||
class PileDB
|
||||
{
|
||||
private $db;
|
||||
|
||||
function __construct() {
|
||||
function __construct()
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"config": {
|
||||
"vendor-dir": "_vendor"
|
||||
},
|
||||
"require": {
|
||||
"erusev/parsedown": "^1.7"
|
||||
}
|
||||
"config": {
|
||||
"vendor-dir": "_vendor"
|
||||
},
|
||||
"require": {
|
||||
"erusev/parsedown": "^1.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue