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:
|
// All credit goes to Chad Minick:
|
||||||
// http://chadminick.com/articles/simple-php-template-engine.html
|
// http://chadminick.com/articles/simple-php-template-engine.html
|
||||||
|
|
||||||
class Template {
|
class Template
|
||||||
|
{
|
||||||
private $vars = array();
|
private $vars = array();
|
||||||
|
|
||||||
public function __get($name) {
|
public function __get($name)
|
||||||
|
{
|
||||||
return $this->vars[$name];
|
return $this->vars[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value)
|
||||||
if($name == 'view_template_file') {
|
{
|
||||||
|
if ($name == 'view_template_file') {
|
||||||
throw new Exception("Cannot bind variable named 'view_template_file'");
|
throw new Exception("Cannot bind variable named 'view_template_file'");
|
||||||
}
|
}
|
||||||
$this->vars[$name] = $value;
|
$this->vars[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render($view_template_file) {
|
public function render($view_template_file)
|
||||||
if(array_key_exists('view_template_file', $this->vars)) {
|
{
|
||||||
|
if (array_key_exists('view_template_file', $this->vars)) {
|
||||||
throw new Exception("Cannot bind variable called 'view_template_file'");
|
throw new Exception("Cannot bind variable called 'view_template_file'");
|
||||||
}
|
}
|
||||||
extract($this->vars);
|
extract($this->vars);
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
<div class="text document edit-form">
|
<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>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>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>
|
<strong>Description:</strong><br>
|
||||||
<textarea name="Description" cols="120" rows="20">
|
<textarea name="Description" cols="120" rows="20">
|
||||||
<?= empty($doc) ? "" : $doc["Description"] ?>
|
<?= empty($doc) ? "" : $doc["Description"] ?>
|
||||||
</textarea><br>
|
</textarea><br>
|
||||||
<strong>File:</strong> <input type="file" name="upfile"><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>URL:</strong> <input type="text" name="URL" value="<?= empty($doc) ? "" : $doc["URL"] ?>"><br>
|
||||||
<strong>Tags:</strong> <input type="text" name="Tags" value="<?
|
<strong>Tags:</strong> <input type="text" name="Tags" value="<?
|
||||||
if ( !empty($doc) ){
|
if (!empty($doc)) {
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach ($doc["tags"] as $tag){
|
foreach ($doc["tags"] as $tag) {
|
||||||
array_push($tags, $tag["Name"]);
|
array_push($tags, $tag["Name"]);
|
||||||
}
|
}
|
||||||
echo implode(", ", $tags);
|
echo implode(", ", $tags);
|
||||||
} else if ( !empty($_GET["tag"]) ) {
|
} else if (!empty($_GET["tag"])) {
|
||||||
echo $_GET["tag"];
|
echo $_GET["tag"];
|
||||||
}
|
}
|
||||||
?>"><br>
|
?>"><br>
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
<?php if (isset($tag)): ?>
|
<?php if (isset($tag)): ?>
|
||||||
<div class="text tag-text">
|
<div class="text tag-text">
|
||||||
<h1><?= $tag["Name"] ?></h1>
|
<h1><?= $tag["Name"] ?></h1>
|
||||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||||
<a class="tag-edit-link" href="?action=edit_tag&tag=<?= $tag["ID"] ?>">[edit tag]</a>
|
<a class="tag-edit-link" href="?action=edit_tag&tag=<?= $tag["ID"] ?>">[edit tag]</a>
|
||||||
</div>
|
</div>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
|
|
||||||
<?php if ($_GET["tag"] != "*" &&
|
<?php if ($_GET["tag"] != "*" &&
|
||||||
$_GET["tag"] != "_"): ?>
|
$_GET["tag"] != "_"): ?>
|
||||||
<div class="text doc-item doc-new-item">
|
<div class="text doc-item doc-new-item">
|
||||||
<a href="?action=new_item&tag=<?= $tag["Name"] ?>">
|
<a href="?action=new_item&tag=<?= $tag["Name"] ?>">
|
||||||
<div class="doc-item-text">
|
<div class="doc-item-text">
|
||||||
<h2>Upload a new document</h2>
|
<h2>Upload a new document</h2>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
|
|
||||||
<?php foreach($docs as $doc): ?>
|
<?php foreach ($docs as $doc): ?>
|
||||||
<div class="text doc-item">
|
<div class="text doc-item">
|
||||||
<a class="doc-item-link" href="?action=remove&item=<?= $doc["ID"] ?>">[X]</a>
|
<a class="doc-item-link" href="?action=remove&item=<?= $doc["ID"] ?>">[X]</a>
|
||||||
<a href="?action=edit_item&item=<?= $doc["ID"]?>">
|
<a href="?action=edit_item&item=<?= $doc["ID"] ?>">
|
||||||
<div class="doc-item-text">
|
<div class="doc-item-text">
|
||||||
<h2><?= $doc["Title"]?></h2>
|
<h2><?= $doc["Title"] ?></h2>
|
||||||
<h3><?= $doc["Author"] . " " . $doc['date']?></h3>
|
<h3><?= $doc["Author"] . " " . $doc['date'] ?></h3>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<p>Confirm deletion of <strong>"<?= $doc["Title"] ?>"</strong>:</p>
|
<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>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<form method="post" id="form" action="admin.php?action=edit_tag<?= empty($tag) ? "" : "&tag=" . $tag["ID"] ?>">
|
<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>Name:</strong> <input type="text" name="Name" value="<?= empty($tag) ? "" : $tag["Name"] ?>"><br>
|
||||||
<strong>Description:</strong><br>
|
<strong>Description:</strong><br>
|
||||||
<textarea name="Description" cols="120" rows="20">
|
<textarea name="Description" cols="120" rows="20">
|
||||||
<?= empty($tag) ? "" : $tag["Description"] ?>
|
<?= empty($tag) ? "" : $tag["Description"] ?>
|
||||||
</textarea><br>
|
</textarea><br>
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
@ -8,10 +8,10 @@
|
||||||
<title>pile ADMIN INTERFACE</title>
|
<title>pile ADMIN INTERFACE</title>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="assets/admin.css">
|
<link rel="stylesheet" type="text/css" href="assets/admin.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div id="sidebar-head">
|
<div id="sidebar-head">
|
||||||
<h1><a href="admin.php">pile admin</a></h1>
|
<h1><a href="admin.php">pile admin</a></h1>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,23 +23,23 @@
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<?
|
<?
|
||||||
foreach($tags as $tag){
|
foreach ($tags as $tag) {
|
||||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<?php echo $content ?>
|
<?php echo $content ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<input type="hidden" name="action" value="logout">
|
<input type="hidden" name="action" value="logout">
|
||||||
<button type="submit" id="login-button">log out</button>
|
<button type="submit" id="login-button">log out</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
<?php if (isset($tag)): ?>
|
<?php if (isset($tag)): ?>
|
||||||
<div class="text tag-text">
|
<div class="text tag-text">
|
||||||
<h1><?= $tag["Name"] ?></h1>
|
<h1><?= $tag["Name"] ?></h1>
|
||||||
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
<p class="tag-desc"><?= $tag["Description"] ?></p>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php foreach($docs as $doc): ?>
|
<?php foreach ($docs as $doc): ?>
|
||||||
<div class="text doc-item">
|
<div class="text doc-item">
|
||||||
<?php if (!empty($doc["URL"])): ?>
|
<?php if (!empty($doc["URL"])): ?>
|
||||||
<a class="doc-item-link" href="<?= $doc["URL"] ?>">🔗</a>
|
<a class="doc-item-link" href="<?= $doc["URL"] ?>">🔗</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="?item=<?= $doc["ID"]?>">
|
<a href="?item=<?= $doc["ID"] ?>">
|
||||||
<div class="doc-item-text">
|
<div class="doc-item-text">
|
||||||
<h2><?= $doc["Title"]?></h2>
|
<h2><?= $doc["Title"] ?></h2>
|
||||||
<h3><?= $doc["Author"] . " " . $doc['date']?></h3>
|
<h3><?= $doc["Author"] . " " . $doc['date'] ?></h3>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<?php if (!empty($doc["tags"])): ?>
|
<?php if (!empty($doc["tags"])): ?>
|
||||||
<h3 class="doc-taglist">Tags:
|
<h3 class="doc-taglist">Tags:
|
||||||
<?
|
<?
|
||||||
foreach($doc["tags"] as $tag){
|
foreach ($doc["tags"] as $tag) {
|
||||||
echo '<li><a href="?tag=' . $tag["Name"] . "\">" . $tag["Name"] . "</a></li>";
|
echo '<li><a href="?tag=' . $tag["Name"] . "\">" . $tag["Name"] . "</a></li>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -20,10 +20,13 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (!empty($doc["Description"])): ?>
|
<?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 endif; ?>
|
||||||
|
|
||||||
<?php if (!empty($doc["URL"])): ?>
|
<?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; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<div class="text">
|
<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"> This site is the sdbs pile, where we upload the stuff we consider important to the larger
|
||||||
<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>
|
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>
|
<p class="intro sign">/-\</p>
|
||||||
</div>
|
</div>
|
|
@ -1,6 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
@ -14,20 +14,24 @@
|
||||||
var _paq = _paq || [];
|
var _paq = _paq || [];
|
||||||
_paq.push(['trackPageView']);
|
_paq.push(['trackPageView']);
|
||||||
_paq.push(['enableLinkTracking']);
|
_paq.push(['enableLinkTracking']);
|
||||||
(function() {
|
(function () {
|
||||||
var u="//www.sdbs.cz/piwik/";
|
var u = "//www.sdbs.cz/piwik/";
|
||||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
||||||
_paq.push(['setSiteId', '2']);
|
_paq.push(['setSiteId', '2']);
|
||||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
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);
|
g.type = 'text/javascript';
|
||||||
|
g.async = true;
|
||||||
|
g.defer = true;
|
||||||
|
g.src = u + 'piwik.js';
|
||||||
|
s.parentNode.insertBefore(g, s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
|
<noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt=""/></p></noscript>
|
||||||
<!-- End Piwik Code -->
|
<!-- End Piwik Code -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div id="sidebar-head">
|
<div id="sidebar-head">
|
||||||
<h1><a href="..">The /-\ pile</a></h1>
|
<h1><a href="..">The /-\ pile</a></h1>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,19 +42,19 @@
|
||||||
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
<li id="sidebar-taglist-top"><a href="?tag=_">UNTAGGED (<?= $none_count ?>)</a></li>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
<?
|
<?
|
||||||
foreach($tags as $tag){
|
foreach ($tags as $tag) {
|
||||||
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
echo '<li><a href="?tag=' . $tag['name'] . "\">" . $tag['name'] . " (" . $tag['count'] . ")</a></li>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<?php echo $content ?>
|
<?php echo $content ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<?php if ($logged): ?>
|
<?php if ($logged): ?>
|
||||||
<form method="get" action="admin.php">
|
<form method="get" action="admin.php">
|
||||||
<button type="submit" id="login-button">enter admin interface</button>
|
<button type="submit" id="login-button">enter admin interface</button>
|
||||||
|
@ -62,6 +66,6 @@
|
||||||
<button type="submit" id="login-button">></button>
|
<button type="submit" id="login-button">></button>
|
||||||
</form>
|
</form>
|
||||||
<? endif; ?>
|
<? endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<?php if (isset($redirect)): ?>
|
<?php if (isset($redirect)): ?>
|
||||||
<meta http-equiv="refresh" content="1;URL=<?= $redirect ?>" />
|
<meta http-equiv="refresh" content="1;URL=<?= $redirect ?>"/>
|
||||||
<?php endif;?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<title>The /-\ pile</title>
|
<title>The /-\ pile</title>
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
<?= $text ?>
|
<?= $text ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,5 +1,8 @@
|
||||||
<div class="text">
|
<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"> This site is the sdbs pile, where we upload the stuff we consider important to the larger
|
||||||
<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>
|
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>
|
<p class="intro sign">/-\</p>
|
||||||
</div>
|
</div>
|
|
@ -1,25 +1,32 @@
|
||||||
<?php
|
<?php
|
||||||
class PileDB {
|
|
||||||
|
class PileDB
|
||||||
|
{
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
function __construct() {
|
function __construct()
|
||||||
|
{
|
||||||
$this->db = new SQLite3("pile.db");
|
$this->db = new SQLite3("pile.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepare($statement){
|
function prepare($statement)
|
||||||
|
{
|
||||||
return $this->db->prepare($statement);
|
return $this->db->prepare($statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($statement){
|
function query($statement)
|
||||||
|
{
|
||||||
return $this->db->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);
|
$ret_count = $this->db->query("SELECT count(ID) FROM Documents")->fetchArray(SQLITE3_NUM);
|
||||||
return $ret_count[0];
|
return $ret_count[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUntaggedDocCount(){
|
public function getUntaggedDocCount()
|
||||||
|
{
|
||||||
$ret_count = $this->db->query("SELECT
|
$ret_count = $this->db->query("SELECT
|
||||||
count(ID)
|
count(ID)
|
||||||
FROM
|
FROM
|
||||||
|
@ -30,7 +37,8 @@ class PileDB {
|
||||||
return $ret_count[0];
|
return $ret_count[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTags(){
|
public function getTags()
|
||||||
|
{
|
||||||
$tag_query = "SELECT
|
$tag_query = "SELECT
|
||||||
ID, Name, count(Document)
|
ID, Name, count(Document)
|
||||||
FROM
|
FROM
|
||||||
|
@ -51,7 +59,8 @@ class PileDB {
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchDoc($id){
|
public function fetchDoc($id)
|
||||||
|
{
|
||||||
$stmt_doc = $this->db->prepare("SELECT * FROM Documents WHERE ID = :id");
|
$stmt_doc = $this->db->prepare("SELECT * FROM Documents WHERE ID = :id");
|
||||||
$stmt_doc->bindValue(":id", $id, SQLITE3_INTEGER);
|
$stmt_doc->bindValue(":id", $id, SQLITE3_INTEGER);
|
||||||
$doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC);
|
$doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC);
|
||||||
|
@ -69,10 +78,11 @@ class PileDB {
|
||||||
return $doc;
|
return $doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listDocs(){
|
public function listDocs()
|
||||||
if (func_num_args() > 0){
|
{
|
||||||
|
if (func_num_args() > 0) {
|
||||||
$tag = func_get_arg(0);
|
$tag = func_get_arg(0);
|
||||||
if ($tag > 0 ) {
|
if ($tag > 0) {
|
||||||
$stmt = $this->db->prepare("SELECT
|
$stmt = $this->db->prepare("SELECT
|
||||||
ID, Title, Author, Published, URL
|
ID, Title, Author, Published, URL
|
||||||
FROM
|
FROM
|
||||||
|
@ -103,8 +113,9 @@ class PileDB {
|
||||||
return $docs;
|
return $docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids){
|
public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids)
|
||||||
if ( empty($id) ){
|
{
|
||||||
|
if (empty($id)) {
|
||||||
$stmt = $this->db->prepare("INSERT INTO Documents
|
$stmt = $this->db->prepare("INSERT INTO Documents
|
||||||
(ID, Title, Author, Description, Published, URL)
|
(ID, Title, Author, Description, Published, URL)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -125,18 +136,18 @@ class PileDB {
|
||||||
$stmt->bindValue(":published", $published, SQLITE3_TEXT);
|
$stmt->bindValue(":published", $published, SQLITE3_TEXT);
|
||||||
$stmt->bindValue(":url", $url, SQLITE3_TEXT);
|
$stmt->bindValue(":url", $url, SQLITE3_TEXT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
if ( empty($id) ){
|
if (empty($id)) {
|
||||||
$id = $this->db->lastInsertRowid();
|
$id = $this->db->lastInsertRowid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($id) ){
|
if (!empty($id)) {
|
||||||
$delete_stmt = $this->db->prepare("DELETE FROM DocumentsToTags
|
$delete_stmt = $this->db->prepare("DELETE FROM DocumentsToTags
|
||||||
WHERE Document = :id");
|
WHERE Document = :id");
|
||||||
$delete_stmt->bindValue(":id", $id, SQLITE3_INTEGER);
|
$delete_stmt->bindValue(":id", $id, SQLITE3_INTEGER);
|
||||||
$delete_stmt->execute();
|
$delete_stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tag_ids as $tag){
|
foreach ($tag_ids as $tag) {
|
||||||
$tag_stmt = $this->db->prepare("INSERT INTO DocumentsToTags ('Document', 'Tag')
|
$tag_stmt = $this->db->prepare("INSERT INTO DocumentsToTags ('Document', 'Tag')
|
||||||
VALUES (:doc, :tag)");
|
VALUES (:doc, :tag)");
|
||||||
$tag_stmt->bindValue("doc", $id, SQLITE3_INTEGER);
|
$tag_stmt->bindValue("doc", $id, SQLITE3_INTEGER);
|
||||||
|
@ -145,7 +156,8 @@ class PileDB {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeDoc($id){
|
public function removeDoc($id)
|
||||||
|
{
|
||||||
$doc_stmt = $this->db->prepare("DELETE FROM Documents
|
$doc_stmt = $this->db->prepare("DELETE FROM Documents
|
||||||
WHERE ID = :id");
|
WHERE ID = :id");
|
||||||
$doc_stmt->bindValue("id", $id, SQLITE3_INTEGER);
|
$doc_stmt->bindValue("id", $id, SQLITE3_INTEGER);
|
||||||
|
@ -157,20 +169,23 @@ class PileDB {
|
||||||
$tag_stmt->execute();
|
$tag_stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findTag($name){
|
public function findTag($name)
|
||||||
|
{
|
||||||
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE Name == :name COLLATE NOCASE");
|
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE Name == :name COLLATE NOCASE");
|
||||||
$stmt->bindValue(":name", $name, SQLITE3_TEXT);
|
$stmt->bindValue(":name", $name, SQLITE3_TEXT);
|
||||||
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
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 = $this->db->prepare("SELECT * FROM Tags WHERE ID == :tag");
|
||||||
$stmt->bindValue(":tag", $tag, SQLITE3_INTEGER);
|
$stmt->bindValue(":tag", $tag, SQLITE3_INTEGER);
|
||||||
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateTag($id, $name, $description){
|
public function updateTag($id, $name, $description)
|
||||||
if (empty($id)){
|
{
|
||||||
|
if (empty($id)) {
|
||||||
$stmt = $this->db->prepare("INSERT INTO Tags
|
$stmt = $this->db->prepare("INSERT INTO Tags
|
||||||
(ID, Name, Description)
|
(ID, Name, Description)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -188,7 +203,8 @@ class PileDB {
|
||||||
return $stmt->execute();
|
return $stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authenticate($username, $password){
|
public function authenticate($username, $password)
|
||||||
|
{
|
||||||
$stmt = $this->db->prepare("SELECT
|
$stmt = $this->db->prepare("SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
|
@ -199,11 +215,12 @@ class PileDB {
|
||||||
$auth_ret = $stmt->execute();
|
$auth_ret = $stmt->execute();
|
||||||
$auth = $auth_ret->fetchArray(SQLITE3_ASSOC);
|
$auth = $auth_ret->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
if (password_verify($password, $auth["Password"])){
|
if (password_verify($password, $auth["Password"])) {
|
||||||
return $auth["ID"];
|
return $auth["ID"];
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?
|
<?
|
||||||
class Uploader {
|
|
||||||
public function handle($files, $dir){
|
class Uploader
|
||||||
if ( is_array($files['upfile']['error']) ) {
|
{
|
||||||
|
public function handle($files, $dir)
|
||||||
|
{
|
||||||
|
if (is_array($files['upfile']['error'])) {
|
||||||
throw new RuntimeException('Invalid parameters.');
|
throw new RuntimeException('Invalid parameters.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +35,8 @@ class Uploader {
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = basename($files['upfile']['name']);
|
$name = basename($files['upfile']['name']);
|
||||||
$name = preg_replace('/[^\x20-\x7E]/','', $name);
|
$name = preg_replace('/[^\x20-\x7E]/', '', $name);
|
||||||
if ($name != ".htaccess"){
|
if ($name != ".htaccess") {
|
||||||
if (!move_uploaded_file(
|
if (!move_uploaded_file(
|
||||||
$files['upfile']['tmp_name'],
|
$files['upfile']['tmp_name'],
|
||||||
$dir . $name)) {
|
$dir . $name)) {
|
||||||
|
@ -46,4 +49,5 @@ class Uploader {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -8,23 +8,23 @@ $db = new PileDB();
|
||||||
$uploader = new Uploader();
|
$uploader = new Uploader();
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (isset($_SESSION['ID'])){
|
if (isset($_SESSION['ID'])) {
|
||||||
$page = new Template();
|
$page = new Template();
|
||||||
|
|
||||||
if (isset($_GET["action"])){
|
if (isset($_GET["action"])) {
|
||||||
switch ($_GET["action"]){
|
switch ($_GET["action"]) {
|
||||||
case "new_tag":
|
case "new_tag":
|
||||||
$content = $page->render("admin_tag_edit.php");
|
$content = $page->render("admin_tag_edit.php");
|
||||||
break;
|
break;
|
||||||
case "edit_tag":
|
case "edit_tag":
|
||||||
if (isset($_POST["Name"])){
|
if (isset($_POST["Name"])) {
|
||||||
$db->updateTag(
|
$db->updateTag(
|
||||||
$_GET["tag"],
|
$_GET["tag"],
|
||||||
$_POST["Name"],
|
$_POST["Name"],
|
||||||
$_POST["Description"]
|
$_POST["Description"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( !empty($_GET["tag"]) ) {
|
if (!empty($_GET["tag"])) {
|
||||||
$page->tag = $db->fetchTag($_GET["tag"]);
|
$page->tag = $db->fetchTag($_GET["tag"]);
|
||||||
}
|
}
|
||||||
$content = $page->render("admin_tag_edit.php");
|
$content = $page->render("admin_tag_edit.php");
|
||||||
|
@ -33,18 +33,18 @@ if (isset($_SESSION['ID'])){
|
||||||
$content = $page->render("admin_doc_edit.php");
|
$content = $page->render("admin_doc_edit.php");
|
||||||
break;
|
break;
|
||||||
case "edit_item":
|
case "edit_item":
|
||||||
if (isset($_POST["Title"]) || !empty($_FILES['upfile']['name']) ){
|
if (isset($_POST["Title"]) || !empty($_FILES['upfile']['name'])) {
|
||||||
$title = $_POST["Title"];
|
$title = $_POST["Title"];
|
||||||
|
|
||||||
if ( !empty($_FILES['upfile']['name']) ){
|
if (!empty($_FILES['upfile']['name'])) {
|
||||||
try {
|
try {
|
||||||
if ( empty($title) ){
|
if (empty($title)) {
|
||||||
$title = pathinfo($_FILES['upfile']['name'], PATHINFO_FILENAME);
|
$title = pathinfo($_FILES['upfile']['name'], PATHINFO_FILENAME);
|
||||||
$title = str_replace("_", " ", $title);
|
$title = str_replace("_", " ", $title);
|
||||||
$title = trim($title);
|
$title = trim($title);
|
||||||
}
|
}
|
||||||
$url = "http://pile.sdbs.cz/docs/" . rawurlencode($uploader->handle($_FILES, "docs/"));
|
$url = "http://pile.sdbs.cz/docs/" . rawurlencode($uploader->handle($_FILES, "docs/"));
|
||||||
} catch (RuntimeException $ex){
|
} catch (RuntimeException $ex) {
|
||||||
$page->text = $ex->getMessage();
|
$page->text = $ex->getMessage();
|
||||||
echo $page->render('full_text.php');
|
echo $page->render('full_text.php');
|
||||||
return;
|
return;
|
||||||
|
@ -54,10 +54,10 @@ if (isset($_SESSION['ID'])){
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc_tags = [];
|
$doc_tags = [];
|
||||||
foreach (explode(",", $_POST["Tags"]) as $tagName){
|
foreach (explode(",", $_POST["Tags"]) as $tagName) {
|
||||||
$tagName = trim($tagName);
|
$tagName = trim($tagName);
|
||||||
$tag = $db->findTag($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"]);
|
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"]);
|
$page->doc = $db->fetchDoc($_GET["item"]);
|
||||||
}
|
}
|
||||||
$content = $page->render("admin_doc_edit.php");
|
$content = $page->render("admin_doc_edit.php");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
if ( ! empty($_GET["confirm"]) && $_GET["confirm"] == "yes"){
|
if (!empty($_GET["confirm"]) && $_GET["confirm"] == "yes") {
|
||||||
$db->removeDoc($_GET["item"]);
|
$db->removeDoc($_GET["item"]);
|
||||||
$page->text = "Document deleted.";
|
$page->text = "Document deleted.";
|
||||||
$page->redirect = $_GET["ret"];
|
$page->redirect = $_GET["ret"];
|
||||||
|
@ -100,7 +100,7 @@ if (isset($_SESSION['ID'])){
|
||||||
}
|
}
|
||||||
} elseif (isset($_GET["tag"])) {
|
} elseif (isset($_GET["tag"])) {
|
||||||
$doc_list_template = new Template();
|
$doc_list_template = new Template();
|
||||||
if ($_GET["tag"] == "*"){
|
if ($_GET["tag"] == "*") {
|
||||||
$docs = $db->listDocs();
|
$docs = $db->listDocs();
|
||||||
} elseif ($_GET["tag"] == "_") {
|
} elseif ($_GET["tag"] == "_") {
|
||||||
$docs = $db->listDocs(-1);
|
$docs = $db->listDocs(-1);
|
||||||
|
@ -129,9 +129,9 @@ if (isset($_SESSION['ID'])){
|
||||||
} else {
|
} else {
|
||||||
$page = new Template();
|
$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"]);
|
$ret_id = $db->authenticate($_POST["username"], $_POST["password"]);
|
||||||
if ($ret_id > 0){
|
if ($ret_id > 0) {
|
||||||
$_SESSION['ID'] = $ret_id;
|
$_SESSION['ID'] = $ret_id;
|
||||||
$page->text = "You have logged in successfully.";
|
$page->text = "You have logged in successfully.";
|
||||||
$page->redirect = "admin.php";
|
$page->redirect = "admin.php";
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
*, *:before, *:after {
|
*, *: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 {
|
body {
|
||||||
font-family: Prociono;
|
font-family: Prociono, serif;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -27,7 +29,7 @@ a {
|
||||||
|
|
||||||
#sidebar-head {
|
#sidebar-head {
|
||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
color: 202020;
|
color: #202020;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ input[type="text"] {
|
||||||
height: 14pt;
|
height: 14pt;
|
||||||
font-size: 8pt;
|
font-size: 8pt;
|
||||||
border: 1px solid lightgray;
|
border: 1px solid lightgray;
|
||||||
background: 202020;
|
background: #202020;
|
||||||
}
|
}
|
||||||
|
|
||||||
.czech {
|
.czech {
|
||||||
|
@ -227,7 +229,7 @@ input[type="text"] {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"], input[type="file"]{
|
input[type="submit"], input[type="file"] {
|
||||||
font-family: Prociono, serif;
|
font-family: Prociono, serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
*, *:before, *:after {
|
*, *: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 {
|
body {
|
||||||
|
@ -109,7 +111,6 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-text
|
.tag-text
|
||||||
|
|
||||||
.document h1 {
|
.document h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 24pt;
|
font-size: 24pt;
|
||||||
|
|
|
@ -16,7 +16,7 @@ if (isset($_GET["item"])) {
|
||||||
$content = $doc_template->render('front_doc_overview.php');
|
$content = $doc_template->render('front_doc_overview.php');
|
||||||
} elseif (isset($_GET["tag"])) {
|
} elseif (isset($_GET["tag"])) {
|
||||||
$doc_list_template = new Template();
|
$doc_list_template = new Template();
|
||||||
if ($_GET["tag"] == "*"){
|
if ($_GET["tag"] == "*") {
|
||||||
$docs = $db->listDocs();
|
$docs = $db->listDocs();
|
||||||
} elseif ($_GET["tag"] == "_") {
|
} elseif ($_GET["tag"] == "_") {
|
||||||
$docs = $db->listDocs(-1);
|
$docs = $db->listDocs(-1);
|
||||||
|
|
Loading…
Reference in a new issue