m1k1oblog/index.php

360 lines
13 KiB
PHP
Raw Normal View History

2016-12-27 20:25:32 +00:00
<?php
include 'common.php';
// Create token
if(empty($_SESSION['token'])){
2019-12-22 21:58:11 +00:00
if(function_exists('random_bytes')){
$_SESSION['token'] = bin2hex(random_bytes(5));
2016-12-27 20:25:32 +00:00
} else {
$_SESSION['token'] = bin2hex(openssl_random_pseudo_bytes(5));
}
}
2022-01-06 15:36:47 +00:00
function escape($str) {
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
2016-12-27 21:27:56 +00:00
//$.ajaxSetup({headers:{'Csrf-Token':'token'}});
2016-12-27 20:25:32 +00:00
2016-12-28 09:48:30 +00:00
Log::put("visitors");
2016-12-29 19:25:57 +00:00
$hours = '';
2020-01-24 21:08:09 +00:00
for($h=0;$h<24;$h++){
$hours .= sprintf('<option value="%d">%02d</option>', $h, $h);
2016-12-29 19:25:57 +00:00
}
$minutes = '';
2018-05-01 19:43:58 +00:00
for($m=0;$m<60;$m+=10){
2016-12-29 19:25:57 +00:00
$minutes .= sprintf('<option value="%d">%02d</option>', $m, $m);
}
2019-09-02 15:52:10 +00:00
$header_path = PROJECT_PATH.Config::get_safe("header", 'data/header.html');
2017-06-19 17:51:59 +00:00
if(file_exists($header_path)){
$header = file_get_contents($header_path);
} else {
$header = '';
}
2017-09-23 18:03:34 +00:00
// Translate styles into html
$styles = Config::get_safe("styles", []);
$styles_html = '';
if(!empty($styles)){
if(!is_array($styles)){
$styles = [$styles];
}
$styles = array_unique($styles);
2022-01-15 19:07:35 +00:00
$styles = array_map('escape', $styles);
2017-09-23 18:03:34 +00:00
$styles_html = '<link href="'.implode('" rel="stylesheet" type="text/css"/>'.PHP_EOL.'<link href="', $styles).'" rel="stylesheet" type="text/css"/>'.PHP_EOL;
}
// Translate script urls into html
$scripts = Config::get_safe("scripts", []);
$scripts_html = '';
if(!empty($scripts)){
2022-01-06 14:10:50 +00:00
if(!is_array($scripts)){
$scripts = [$scripts];
2017-09-23 18:03:34 +00:00
}
2019-12-20 17:38:48 +00:00
2017-09-23 18:03:34 +00:00
$scripts = array_unique($scripts);
2022-01-15 19:07:35 +00:00
$scripts = array_map('escape', $scripts);
2017-09-23 18:03:34 +00:00
$scripts_html = '<script src="'.implode('" type="text/javascript"></script>'.PHP_EOL.'<script src="', $scripts).'" type="text/javascript"></script>'.PHP_EOL;
}
2022-01-06 15:36:47 +00:00
// Use version suffix in URLs to prevent cache
$versionSuffix = '';
if (Config::get_safe("version", false)) {
2022-01-15 19:07:35 +00:00
$versionSuffix = '?v='.rawurlencode(Config::get("version"));
2022-01-06 15:36:47 +00:00
}
2016-12-27 20:25:32 +00:00
?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
2022-01-06 15:36:47 +00:00
<title><?php echo escape(Config::get("title")); ?></title>
2016-12-27 20:25:32 +00:00
<meta name="robots" content="noindex, nofollow">
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
2019-12-20 17:38:48 +00:00
2022-01-06 15:36:47 +00:00
<link href="static/styles/main.css<?php echo $versionSuffix?>" rel="stylesheet" type="text/css" />
2022-01-15 19:07:35 +00:00
<link href="static/styles/<?php echo rawurlencode(Config::get_safe("theme", "theme01")); ?>.css<?php echo $versionSuffix?>" rel="stylesheet" type="text/css" />
2019-12-20 17:38:48 +00:00
2016-12-28 09:55:38 +00:00
<link href="https://fonts.googleapis.com/css?family=Open+Sans&amp;subset=all" rel="stylesheet">
2017-09-23 10:19:00 +00:00
2017-09-23 18:03:34 +00:00
<link href="static/styles/lightbox.css" rel="stylesheet" type="text/css" />
2022-01-06 15:36:47 +00:00
<?php echo Config::get_safe("highlight", false) ? '<link href="static/styles/highlight-monokai-sublime.css" rel="stylesheet" type="text/css" />'.PHP_EOL : ''; ?>
2017-09-23 18:03:34 +00:00
<?php echo $styles_html; ?>
2016-12-27 20:25:32 +00:00
</head>
<body>
<div id="dd_mask" class="mask"></div>
<div id="prepared" style="display:none;">
<!-- Login Button -->
2017-06-19 17:51:59 +00:00
<a class="show_more"><?php echo __("Show More"); ?></a>
<!-- Login Button -->
<button type="button" class="button blue login_btn"><?php echo __("Login"); ?></button>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Logout Button -->
2017-06-19 17:51:59 +00:00
<button type="button" class="button gray logout_btn"><?php echo __("Logout"); ?></button>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Login Modal -->
<div class="modal login_modal">
2017-09-23 18:03:34 +00:00
<div class="modal-dialog" style="max-width: 350px;">
2016-12-27 20:25:32 +00:00
<div class="modal-content">
<div class="modal-header">
<a class="close"></a>
2017-09-23 18:03:34 +00:00
<h4 class="modal-title"><?php echo __("Login"); ?></h4>
2016-12-27 20:25:32 +00:00
</div>
2019-09-06 15:25:32 +00:00
<form>
<div class="modal-body login-form">
<input name="username" type="text" autocomplete="username" class="nick" placeholder="<?php echo __("Nick"); ?>">
<input name="password" type="password" autocomplete="current-password" class="pass" placeholder="<?php echo __("Password"); ?>">
2016-12-27 20:25:32 +00:00
</div>
2019-09-06 15:25:32 +00:00
<div class="modal-footer">
<div class="buttons">
<a class="button gray close"><?php echo __("Cancel"); ?></a>
<button type="button" class="button blue do_login"><?php echo __("Login"); ?></button>
</div>
</div>
</form>
2016-12-27 20:25:32 +00:00
</div>
</div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Post Link -->
<a class="b_link" target="_blank">
<div class="thumb">
<img class="thumb_imglink">
<div class="play"></div>
</div>
2020-01-24 01:31:29 +00:00
<div class="info has_thumb">
2016-12-27 20:25:32 +00:00
<div class="title"></div>
<div class="desc"></div>
<div class="host"></div>
</div>
</a>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Post Image Link -->
<a class="b_imglink">
<img>
<div class="ftr">
<div class="host"></div>
<i class="exit"></i>
<div class="desc"></div>
</div>
</a>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Post Image -->
<a class="b_img"><img></a>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- New Post -->
<div class="b_post new_post">
<div class="modal-header">
2017-06-19 17:51:59 +00:00
<h4 class="modal-title"><?php echo __("Post"); ?></h4>
2016-12-27 20:25:32 +00:00
</div>
<div class="edit-form"></div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Post Tools -->
<ul class="b_dropdown post_tools">
2017-06-19 17:51:59 +00:00
<li><a class="edit_post"><?php echo __("Edit Post"); ?></a></li>
<li><a class="edit_date"><?php echo __("Change Date"); ?></a></li>
2020-02-07 22:54:25 +00:00
<li>
<a class="hide"><?php echo __("Hide from Timeline"); ?></a>
<a class="show"><?php echo __("Show on Timeline"); ?></a>
</li>
2017-06-19 17:51:59 +00:00
<li><a class="delete_post"><?php echo __("Delete Post"); ?></a></li>
2016-12-27 20:25:32 +00:00
</ul>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Edit Modal -->
<div class="modal edit_modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a class="close"></a>
2017-06-19 17:51:59 +00:00
<h4 class="modal-title"><?php echo __("Edit Post"); ?></h4>
2016-12-27 20:25:32 +00:00
</div>
<div class="edit_form">
<div class="modal-body drop_space">
2017-06-19 17:51:59 +00:00
<div class="e_drag"><span><?php echo __("Drag photos here"); ?></span></div>
2018-05-01 20:31:41 +00:00
<div class="e_drop"><span><?php echo __("Drop photos here"); ?></span></div>
2022-01-15 19:07:35 +00:00
<img src="<?php echo escape(Config::get("pic_small")); ?>" width="40" height="40" class="e_profile">
2017-09-23 14:09:42 +00:00
<!--<div class="e_text" contenteditable="true"></div>-->
<div class="t_area">
<textarea class="e_text" placeholder="<?php echo __("What's on your mind?"); ?>"></textarea>
</div>
2016-12-27 20:25:32 +00:00
</div>
2020-01-09 18:21:30 +00:00
<div class="e_loading">
2020-01-24 01:35:41 +00:00
<span class="e_dots"></span>
<span class="e_dots"></span>
<span class="e_dots"></span>
2020-01-09 18:21:30 +00:00
<div class="e_meter"><span></span></div>
</div>
2016-12-27 20:25:32 +00:00
<input type="hidden" class="i_content_type">
<input type="hidden" class="i_content">
<div class="modal-body content"></div>
<table class="options_content">
2018-05-01 16:33:06 +00:00
<tr class="feeling"><th><?php echo __("Feeling"); ?></th><td><input type="text" class="i_feeling" placeholder="<?php echo __("How are you feeling?"); ?>" autocomplete="off"><button class="clear"></button></td></tr>
<tr class="persons"><th><?php echo __("With"); ?></th><td><input type="text" class="i_persons" placeholder="<?php echo __("Who are you with?"); ?>" autocomplete="off"><button class="clear"></button></td></tr>
<tr class="location"><th><?php echo __("At"); ?></th><td><input type="text" class="i_location" placeholder="<?php echo __("Where are you?"); ?>" autocomplete="off"><button class="clear"></button></td></tr>
2016-12-27 20:25:32 +00:00
</table>
<div class="modal-footer">
<ul class="options">
<li class="kepet"><a><span><input type="file" accept="image/*" multiple class="photo_upload" name="file"></span></a></li>
<li class="feeling"><a></a></li>
<li class="persons"><a></a></li>
<li class="location"><a></a></li>
</ul>
<div class="buttons">
2017-06-19 17:51:59 +00:00
<span class="button gray privacy"><span class="cnt"></span><i class="arrow"></i></span>
<button type="button" class="button blue save"><?php echo __("Save"); ?></button>
2016-12-27 20:25:32 +00:00
</div>
</div>
</div>
</div>
</div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Edit Date Modal -->
<div class="modal edit_date_modal">
2018-05-01 19:43:58 +00:00
<div class="modal-dialog small">
2016-12-27 20:25:32 +00:00
<div class="modal-content">
<div class="modal-header">
<a class="close"></a>
2017-06-19 17:51:59 +00:00
<h4 class="modal-title"><?php echo __("Change Date"); ?></h4>
2016-12-27 20:25:32 +00:00
</div>
<div class="modal-body">
2018-05-01 19:43:58 +00:00
<div class="datepicker">
<input type="hidden" class="year" value="">
<input type="hidden" class="month" value="">
<input type="hidden" class="day" value="">
<input type="hidden" class="month_names" value="<?php echo
__("January").",".
__("February").",".
__("March").",".
__("April").",".
__("May").",".
__("June").",".
__("July").",".
__("August").",".
__("September").",".
__("October").",".
__("November").",".
__("December");
?>">
</div>
<div style="text-align: center;">
<?php echo __("Time:"); ?>&nbsp;
<select class="hour">
<option value="" disabled="1"><?php echo __("Hour:"); ?></option>
<?php echo $hours; ?>
</select>&nbsp;:&nbsp;
<select class="minute">
<option value="" disabled="1"><?php echo __("Minute:"); ?></option>
<?php echo $minutes; ?>
</select>
</div>
2016-12-27 20:25:32 +00:00
</div>
<div class="modal-footer">
<div class="buttons">
2017-06-19 17:51:59 +00:00
<a class="button gray close"><?php echo __("Cancel"); ?></a>
<button type="button" class="button blue save"><?php echo __("Save"); ?></button>
2016-12-27 20:25:32 +00:00
</div>
</div>
</div>
</div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Delete Modal -->
<div class="modal delete_modal">
<div class="modal-dialog small">
<div class="modal-content">
<div class="modal-header">
<a class="close"></a>
2017-06-19 17:51:59 +00:00
<h4 class="modal-title"><?php echo __("Delete Post"); ?></h4>
2016-12-27 20:25:32 +00:00
</div>
2017-06-19 17:51:59 +00:00
<div class="modal-body"><?php echo __("This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something."); ?></div>
2016-12-27 20:25:32 +00:00
<div class="modal-footer">
<div class="buttons">
2017-06-19 17:51:59 +00:00
<a class="button gray close"><?php echo __("Cancel"); ?></a>
<button type="button" class="button blue delete"><?php echo __("Delete Post"); ?></button>
2016-12-27 20:25:32 +00:00
</div>
</div>
</div>
</div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Post Row -->
<div class="b_post post_row">
2020-02-02 00:46:05 +00:00
<div class="b_overlay">
2020-02-02 00:53:19 +00:00
<a class="button"><?php echo __("Show hidden content"); ?></a>
2020-02-02 00:46:05 +00:00
</div>
2016-12-27 20:25:32 +00:00
<div class="b_header">
2022-01-15 19:07:35 +00:00
<img src="<?php echo escape(Config::get("pic_small")); ?>" width="40" height="40" class="b_profile">
2016-12-27 20:25:32 +00:00
<div class="b_desc">
<div class="b_sharer">
2022-01-06 15:36:47 +00:00
<span class="b_name"><?php echo escape(Config::get("name")); ?></span><span class="b_options"> - </span><span class="b_feeling"></span><span class="b_with"> <?php echo __("with"); ?> </span><span class="b_persons"></span><span class="b_here"> <?php echo __("here:"); ?> </span><span class="b_location"></span>
2016-12-27 20:25:32 +00:00
</div>
2017-06-19 17:51:59 +00:00
<i class="privacy_icon"></i>
2016-12-27 20:25:32 +00:00
<a class="b_date"></a>
<a class="b_tools"></a>
</div>
</div>
<div class="b_text"></div>
<div class="b_content"></div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<!-- Pirvacy Settings -->
2017-06-19 17:51:59 +00:00
<ul class="b_dropdown privacy_settings">
<li><a class="set" data-val="public"><i class="public"></i><?php echo __("Public"); ?></a></li>
2017-09-25 18:43:27 +00:00
<li><a class="set" data-val="friends"><i class="friends"></i><?php echo __("Friends"); ?></a></li>
2017-06-19 17:51:59 +00:00
<li><a class="set" data-val="private"><i class="private"></i><?php echo __("Only me"); ?></a></li>
2016-12-27 20:25:32 +00:00
</ul>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<div class="bluebar">
2022-01-06 15:36:47 +00:00
<h1><?php echo escape(Config::get("title")); ?></h1>
2016-12-27 20:25:32 +00:00
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<div class="headbar">
<div class="cover">
2017-06-19 17:51:59 +00:00
<?php echo $header; ?>
2016-12-27 20:25:32 +00:00
<div class="overlay"></div>
2022-01-15 19:07:35 +00:00
<?php echo (Config::get_safe("cover", false) ? '<img src="'.escape(Config::get("cover")).'">' : (empty($header) ? '<div style="padding-bottom: 37%;"></div>' : '')); ?>
2016-12-27 20:25:32 +00:00
<div class="profile">
2022-01-15 19:07:35 +00:00
<img src="<?php echo escape(Config::get("pic_big")); ?>">
2016-12-27 20:25:32 +00:00
</div>
2022-01-06 15:36:47 +00:00
<div class="name"><?php echo escape(Config::get("name")); ?></div>
2016-12-27 20:25:32 +00:00
</div>
<div id="headline"></div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<div id="b_feed">
<div class="more_posts">
2017-06-19 17:51:59 +00:00
<a href="#" class="button"><?php echo __("Show all posts"); ?></a>
2016-12-27 20:25:32 +00:00
</div>
<div id="posts"></div>
</div>
2019-12-20 17:38:48 +00:00
2016-12-27 20:25:32 +00:00
<div id="eof_feed">
<img src="static/images/zpEYXu5Wdu6.png">
2022-01-06 15:36:47 +00:00
<p><?php echo escape(Config::get("version")); ?> &copy; 2016-2022<br>
<?php echo Config::get_safe("footer", false) ? escape(Config::get_safe("footer")) : '<a href="https://github.com/m1k1o/blog" class="link" title="m1k1o/blog github repository" target="_blank">m1k1o/blog</a>'; ?>
2021-11-20 18:36:00 +00:00
</p>
2016-12-27 20:25:32 +00:00
</div>
2019-12-22 21:53:56 +00:00
<script src="static/scripts/jquery.min.js"></script>
2016-12-27 21:27:56 +00:00
<script>$["\x61\x6A\x61\x78\x53\x65\x74\x75\x70"]({"\x68\x65\x61\x64\x65\x72\x73":{"\x43\x73\x72\x66-\x54\x6F\x6B\x65\x6E":"<?php echo $_SESSION['token'];?>"}});</script>
2017-09-23 18:03:34 +00:00
<script src="static/scripts/lightbox.js"></script>
2022-01-06 15:36:47 +00:00
<script src="static/scripts/datepick.js<?php echo $versionSuffix?>"></script>
2017-09-23 14:09:42 +00:00
<script src="static/scripts/autosize.js"></script>
2022-01-06 15:36:47 +00:00
<?php echo Config::get_safe("highlight", false) ? '<script src="static/scripts/highlight-10.1.2.min.js"></script><script>hljs.initHighlightingOnLoad();</script>'.PHP_EOL : ''; ?>
<script src="static/scripts/app.js<?php echo $versionSuffix?>"></script>
2017-09-23 18:03:34 +00:00
<?php echo $scripts_html; ?>
2016-12-27 20:25:32 +00:00
</body>
2020-01-24 18:21:52 +00:00
</html>