Upload
This commit is contained in:
42 files changed
+4036
No files matched your search
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
orblog - Simple blog for hidden networks.
|
||||
|
||||
Version: 0.1
|
||||
Git: https://git.runx.zip/chicory/orblog-legacy
|
||||
Copyright: chicory@runx.zip 2020
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
$_TPL['title'] = $_LANG['error_404'].' | '.TITLE;
|
||||
|
||||
include_template('header');
|
||||
include_template('404');
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
orblog - Simple blog for hidden networks.
|
||||
|
||||
Version: 0.1
|
||||
Git: https://git.runx.zip/chicory/orblog-legacy
|
||||
Copyright: chicory@runx.zip 2020
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/*-- Admin panel auth -----------------------------------------------------*/
|
||||
if($_GET['auth'] == 'sign_in')
|
||||
{
|
||||
if($_POST['pass'] == PASS and $_POST['captcha'] == $_SESSION['captcha'])
|
||||
$_SESSION['admin'] = 1;
|
||||
else
|
||||
$_TPL['error'] = $_LANG['error_sign_in'];
|
||||
}
|
||||
if($_GET['auth'] == 'sign_out')
|
||||
$_SESSION['admin'] = 0;
|
||||
|
||||
/*-- Admin panel actions --------------------------------------------------*/
|
||||
if($_GET['action'] == 'add_post' and $_SESSION['admin']) // Add post
|
||||
{
|
||||
$query = 'INSERT INTO `posts`
|
||||
(time, category, title, desc, text, tags)
|
||||
VALUES
|
||||
(:time, :cat, :title, :desc, :text, :tags)';
|
||||
|
||||
$stmt = $sqlite -> prepare($query);
|
||||
|
||||
$stmt -> bindValue(':time', time(), SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':cat', $_POST['category'], SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':title', $_POST['title'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':desc', $_POST['desc'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':text', $_POST['text'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':tags', $_POST['tags'], SQLITE3_TEXT);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
header('Location:'.URL); exit;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'edit_post' and $_SESSION['admin']) // Edit post
|
||||
{
|
||||
$query = 'SELECT COUNT(*) FROM `comments` WHERE id = '.$_GET['post'];
|
||||
$count = $sqlite -> querySingle($query);
|
||||
|
||||
$query = 'UPDATE `posts` SET
|
||||
category = :cat,
|
||||
title = :title,
|
||||
desc = :desc,
|
||||
text = :text,
|
||||
tags = :tags,
|
||||
comments = :count
|
||||
WHERE id = :id';
|
||||
|
||||
$stmt = $sqlite -> prepare($query);
|
||||
|
||||
$stmt -> bindValue(':cat', $_POST['category'], SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':title', $_POST['title'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':desc', $_POST['desc'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':text', $_POST['text'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':tags', $_POST['tags'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':count', $count, SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':id', $_GET['post'], SQLITE3_INTEGER);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
header('Location:'.URL.'/index.php?view=post&id='.$_GET['post']); exit;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'delete_post' and $_SESSION['admin']) // Del post
|
||||
{
|
||||
$query = 'DELETE FROM `posts` WHERE id = '.$_GET['id'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
$query = 'DELETE FROM `comments` WHERE id = '.$_GET['id'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
header('Location:'.URL); exit;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'add_category' and $_SESSION['admin']) // Add category
|
||||
{
|
||||
if (!$_POST['sort']) $_POST['sort'] = 0;
|
||||
$query = 'INSERT INTO `categories`
|
||||
(sort, name)
|
||||
VALUES
|
||||
('.$_POST['sort'].',
|
||||
"'.$_POST['name'].'")';
|
||||
|
||||
$sqlite -> exec($query);
|
||||
header('Location:'.URL.'index.php?view=admin&page=categories'); exit;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'edit_category' and $_SESSION['admin']) // Edit category
|
||||
{
|
||||
if($_POST['delete'])
|
||||
{
|
||||
$query = 'DELETE FROM `categories` WHERE id = '.$_GET['id'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
header('Location:'.URL.'index.php?view=admin&page=categories'); exit;
|
||||
}
|
||||
$query = 'UPDATE `categories` SET
|
||||
sort = '.$_POST['sort'].',
|
||||
name = "'.$_POST['name'].'"
|
||||
WHERE id = '.$_GET['id'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
header('Location:'.URL.'index.php?view=admin&page=categories'); exit;
|
||||
}
|
||||
|
||||
if($_GET['action'] == 'delete_comment' and $_SESSION['admin']) // Del comment
|
||||
{
|
||||
$query = 'DELETE FROM `comments` WHERE cid = '.$_GET['id'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
$query = 'SELECT COUNT(*) FROM `comments` WHERE id = '.$_GET['post'];
|
||||
$count = $sqlite -> querySingle($query);
|
||||
|
||||
$query = 'UPDATE `posts` SET comments = '.$count.'
|
||||
WHERE id = '.$_GET['post'];
|
||||
$sqlite -> exec($query);
|
||||
|
||||
header('Location:'.$_SERVER['HTTP_REFERER']); exit;
|
||||
}
|
||||
|
||||
/*-- Pages ----------------------------------------------------------------*/
|
||||
$_TPL['title'] = $_LANG['admin'].' | '.TITLE;
|
||||
include_template('header');
|
||||
|
||||
if(!$_SESSION['admin']) // Login
|
||||
{
|
||||
$_SESSION['captcha'] = gen_captcha();
|
||||
include_template('sign_in');
|
||||
}
|
||||
else if($_GET['page'] == 'add_post') // Add post
|
||||
{
|
||||
$_TPL['category_select'] = select_categories($category_dump);
|
||||
|
||||
include_template('admin_header');
|
||||
include_template('add_post');
|
||||
}
|
||||
else if($_GET['page'] == 'categories') // Categories
|
||||
{
|
||||
include_template('admin_header');
|
||||
include_template('categories_header');
|
||||
|
||||
view_edit_categories($category_dump);
|
||||
|
||||
include_template('categories');
|
||||
}
|
||||
else if($_GET['page'] == 'comments') // Comments
|
||||
{
|
||||
$parser = new Parsedown();
|
||||
$parser -> setSafeMode(true);
|
||||
|
||||
$query = 'SELECT * FROM `comments` LIMIT 50';
|
||||
$result = $sqlite -> query($query);
|
||||
|
||||
include_template('admin_header');
|
||||
include_template('comments');
|
||||
view_comments($result);
|
||||
}
|
||||
else if($_GET['page'] == 'edit_post') // Edit post
|
||||
{
|
||||
$result = $sqlite -> query('SELECT * FROM `posts` WHERE id='.$_GET['id']);
|
||||
$post_data = $result -> fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
$_TPL['id'] = $post_data['id'];
|
||||
$_TPL['category'] = $post_data['category'];
|
||||
$_TPL['title'] = $post_data['title'];
|
||||
$_TPL['title'] = $post_data['title'];
|
||||
$_TPL['desc'] = $post_data['desc'];
|
||||
$_TPL['text'] = $post_data['text'];
|
||||
$_TPL['tags'] = $post_data['tags'];
|
||||
|
||||
if($post_data['category'])
|
||||
$_TPL['category_name'] = category_name($post_data['category']);
|
||||
else $_TPL['category_name'] = $_LANG['without_cat'];
|
||||
|
||||
$_TPL['category_select'] = select_categories($category_dump);
|
||||
|
||||
include_template('admin_header');
|
||||
include_template('edit_post');
|
||||
}
|
||||
else // Admin inddex
|
||||
{
|
||||
$query = 'SELECT COUNT(*) FROM `posts`';
|
||||
$_TPL['posts'] = $sqlite -> querySingle($query);
|
||||
|
||||
$query = 'SELECT COUNT(*) FROM `comments`';
|
||||
$_TPL['comments'] = $sqlite -> querySingle($query);
|
||||
|
||||
include_template('admin_header');
|
||||
include_template('admin_index');
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
orblog - Simple blog for hidden networks.
|
||||
|
||||
Version: 0.1
|
||||
Git: https://git.runx.zip/chicory/orblog-legacy
|
||||
Copyright: chicory@runx.zip 2020
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
/*-- Posts count ----------------------------------------------------------*/
|
||||
if(!isset($_GET['category']) and !isset($_GET['tag']))
|
||||
{
|
||||
$query = 'SELECT COUNT(*) FROM `posts`';
|
||||
}
|
||||
else if(isset($_GET['category']))
|
||||
{
|
||||
$cat = filter_input(INPUT_GET, 'category', FILTER_SANITIZE_NUMBER_INT);
|
||||
if ($cat < 0) $cat = 0;
|
||||
$query = 'SELECT COUNT(*) FROM `posts` WHERE category = '.$cat;
|
||||
|
||||
$name = category_name($cat);
|
||||
}
|
||||
else if($_GET['tag'])
|
||||
{
|
||||
$tag = preg_replace ("/[^a-zA-Zа-яА-ЯёЁ_\-\d]/ui","",$_GET['tag']);
|
||||
$query = 'SELECT COUNT(*) FROM `posts` WHERE tags LIKE "%'.$tag.'%"';
|
||||
}
|
||||
$count = $sqlite -> querySingle($query);
|
||||
|
||||
/*-- Pagination -----------------------------------------------------------*/
|
||||
if($count)
|
||||
{
|
||||
if(!$_GET['page']) $page = 0;
|
||||
else $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
$start = $page * MAXPOSTS;
|
||||
|
||||
if($page < 0 or ($page * MAXPOSTS) >= $count )
|
||||
{
|
||||
header('Location:'.URL.'index.php?view=404'); exit;
|
||||
}
|
||||
}
|
||||
/*-- Get posts and set pagination links -----------------------------------*/
|
||||
if(!isset($_GET['category']) and !isset($_GET['tag']))
|
||||
{
|
||||
$query = 'SELECT * FROM `posts`
|
||||
ORDER BY `time` DESC
|
||||
LIMIT '.$start.', '.MAXPOSTS;
|
||||
|
||||
$_TPL['title'] = TITLE;
|
||||
|
||||
if(($page - 1) >= 0)
|
||||
$_TPL['prev_page'] = 'index.php?page='.($page - 1);
|
||||
if((($page + 1) * MAXPOSTS) < $count)
|
||||
$_TPL['next_page'] = 'index.php?page='.($page + 1);
|
||||
}
|
||||
else if(isset($cat)) // Categories
|
||||
{
|
||||
$query = 'SELECT * FROM `posts` WHERE category = '.$cat.'
|
||||
ORDER BY `time` DESC LIMIT '.$start.', '.MAXPOSTS;
|
||||
|
||||
$_TPL['title'] = $name.' | '.TITLE;
|
||||
if($cat == 0) $_TPL['title'] = $_LANG['without_cat'].' | '.TITLE;
|
||||
|
||||
if(($page - 1) >= 0)
|
||||
$_TPL['prev_page'] = 'index.php?category='.$cat.'&page='.($page - 1);
|
||||
if((($page + 1) * MAXPOSTS) < $count)
|
||||
$_TPL['next_page'] = 'index.php?category='.$cat.'&page='.($page + 1);
|
||||
}
|
||||
else if(isset($tag)) // Tags
|
||||
{
|
||||
$query = 'SELECT * FROM `posts` WHERE tags LIKE "%'.$tag.'%"
|
||||
ORDER BY `time` DESC LIMIT '.$start.', '.MAXPOSTS;
|
||||
|
||||
$_TPL['title'] = '@'.$tag.' | '.TITLE;
|
||||
|
||||
if(($page - 1) >= 0)
|
||||
$_TPL['prev_page'] = 'index.php?tag='.$tag.'&page='.($page - 1);
|
||||
if((($page + 1) * MAXPOSTS) < $count)
|
||||
$_TPL['next_page'] = 'index.php?tag='.$tag.'&page='.($page + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location:'.URL.'index.php'); exit;
|
||||
}
|
||||
|
||||
$result = $sqlite -> query($query);
|
||||
|
||||
/*-- View posts -----------------------------------------------------------*/
|
||||
$parser = new Parsedown();
|
||||
|
||||
include_template('header');
|
||||
|
||||
if($count) view_posts($result);
|
||||
else include_template('index_empty');
|
||||
|
||||
include_template('index_footer');
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
orblog - Simple blog for hidden networks.
|
||||
|
||||
Version: 0.1
|
||||
Git: https://git.runx.zip/chicory/orblog-legacy
|
||||
Copyright: chicory@runx.zip 2020
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
/*-- Get post contents -----------------------------------------------------*/
|
||||
if($id <= 0)
|
||||
{
|
||||
header('Location:'.URL.'index.php?view=404'); exit;
|
||||
}
|
||||
|
||||
$result = $sqlite -> query('SELECT * FROM `posts` WHERE id='.$id);
|
||||
$post_data = $result -> fetchArray(SQLITE3_ASSOC);
|
||||
|
||||
if(!$post_data['time'])
|
||||
{
|
||||
header('Location:'.URL.'index.php?view=404'); exit;
|
||||
}
|
||||
|
||||
$_TPL['title'] = $post_data['title'].' | '.TITLE;
|
||||
|
||||
include_template('header');
|
||||
|
||||
/*-- View post contents ----------------------------------------------------*/
|
||||
$parser = new Parsedown();
|
||||
|
||||
$_TPL['id'] = $id;
|
||||
$_TPL['time'] = date("d.m.y", $post_data['time']);
|
||||
$_TPL['title'] = $post_data['title'];
|
||||
$_TPL['desc'] = parser($post_data['desc']);
|
||||
$_TPL['text'] = parser($post_data['text']);
|
||||
$_TPL['tags'] = separate_tags($post_data['tags']);
|
||||
$_TPL['comments'] = $post_data['comments'];
|
||||
|
||||
include_template('post');
|
||||
|
||||
/*-- Add a comment --------------------------------------------------------*/
|
||||
if($_GET['action'] == 'add_comment' && COMMENTS)
|
||||
{
|
||||
$post_url = URL.'index.php?view=post&id='.$_TPL['id'];
|
||||
|
||||
if(empty($_POST['text']) or $_POST['captcha'] != $_SESSION['captcha'])
|
||||
{
|
||||
header('Location:'.$post_url.'&error=comment_err#add'); exit;
|
||||
}
|
||||
|
||||
if($_SESSION['flood'] and (time() - $_SESSION['flood']) < ANTIFLOOD)
|
||||
{
|
||||
header('Location:'.$post_url.'&error=antiflood#add'); exit;
|
||||
}
|
||||
|
||||
$_SESSION['flood'] = time();
|
||||
|
||||
$query = 'INSERT INTO `comments` (id, time, text, admin)
|
||||
VALUES (:id, :time, :text, :admin)';
|
||||
|
||||
$stmt = $sqlite -> prepare($query);
|
||||
|
||||
$stmt -> bindValue(':id', $id, SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':time', time(), SQLITE3_INTEGER);
|
||||
$stmt -> bindValue(':text', $_POST['text'], SQLITE3_TEXT);
|
||||
$stmt -> bindValue(':admin', $_SESSION['admin'], SQLITE3_INTEGER);
|
||||
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$query = 'UPDATE `posts` SET comments = '.($post_data['comments']+1).'
|
||||
WHERE id = '.$id;
|
||||
$sqlite -> exec($query);
|
||||
}
|
||||
/*-- View comments --------------------------------------------------------*/
|
||||
|
||||
$parser -> setSafeMode(true);
|
||||
|
||||
$query = 'SELECT * FROM `comments` WHERE id='.$id;
|
||||
$result = $sqlite -> query($query);
|
||||
|
||||
view_comments($result);
|
||||
|
||||
/*-- Comment form ---------------------------------------------------------*/
|
||||
if(COMMENTS)
|
||||
{
|
||||
$_SESSION['captcha'] = gen_captcha();
|
||||
|
||||
if ($_GET['error'] == "comment_err") $_TPL['error'] = $_LANG['comment_err'];
|
||||
if ($_GET['error'] == "antiflood") $_TPL['error'] = $_LANG['flood_err'];
|
||||
|
||||
include_template('comment_form');
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
orblog - Simple blog for hidden networks.
|
||||
|
||||
Version: 0.1
|
||||
Git: https://git.runx.zip/chicory/orblog-legacy
|
||||
Copyright: chicory@runx.zip 2020
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
header("Content-Type: application/xml; charset=UTF-8");
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title><?=TITLE?></title>
|
||||
<link><?=URL?></link>
|
||||
|
||||
<?php
|
||||
|
||||
$query = 'SELECT COUNT(*) FROM `posts`';
|
||||
$count = $sqlite -> querySingle($query);
|
||||
$query = 'SELECT * FROM `posts` ORDER BY `time` DESC LIMIT 0, '.MAXPOSTS;
|
||||
$result = $sqlite -> query($query);
|
||||
|
||||
if($count)
|
||||
{
|
||||
$parser = new Parsedown();
|
||||
$parser -> setSafeMode(true);
|
||||
|
||||
while ($row = $result -> fetchArray())
|
||||
{
|
||||
if(!$row['time']) exit;
|
||||
|
||||
$_TPL['id'] = $row['id'];
|
||||
$_TPL['title'] = $row['title'];
|
||||
$_TPL['desc'] = parser($row['desc']);
|
||||
|
||||
include_template('rss');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</channel>
|
||||
</rss>
|
||||
<?php exit;
|
||||
Reference in new issue
Block a user