mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Format
This commit is contained in:
parent
f1742c65d9
commit
e7ad8bdde1
12 changed files with 97 additions and 72 deletions
|
@ -157,67 +157,81 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
action="<?= $_SERVER['PHP_SELF']; ?>">
|
action="<?= $_SERVER['PHP_SELF']; ?>">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_name">Site Name</label>
|
<label class="col-sm-2 control-label form-label" for="site_info_name">Site
|
||||||
|
Name</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" name="site_info[site_name]" id="site_info_name"
|
<input type="text" class="form-control" name="site_info[site_name]"
|
||||||
|
id="site_info_name"
|
||||||
placeholder="The name of your site"
|
placeholder="The name of your site"
|
||||||
value="<?= pp_html_escape($current_site_info['site_name']); ?>">
|
value="<?= pp_html_escape($current_site_info['site_name']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_title">Site Title</label>
|
<label class="col-sm-2 control-label form-label" for="site_info_title">Site
|
||||||
|
Title</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" name="site_info[title]" id="site_info_title"
|
<input type="text" class="form-control" name="site_info[title]"
|
||||||
|
id="site_info_title"
|
||||||
placeholder="Site title tag"
|
placeholder="Site title tag"
|
||||||
value="<?= pp_html_escape($current_site_info['title']); ?>">
|
value="<?= pp_html_escape($current_site_info['title']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_baseurl">Domain name</label>
|
<label class="col-sm-2 control-label form-label" for="site_info_baseurl">Domain
|
||||||
|
name</label>
|
||||||
<div class="col-sm-1" style="padding:5px;">
|
<div class="col-sm-1" style="padding:5px;">
|
||||||
<span class="badge">
|
<span class="badge">
|
||||||
<?= !empty($_SERVER['HTTPS']) ? 'https://' : 'http://' ?>;
|
<?= !empty($_SERVER['HTTPS']) ? 'https://' : 'http://' ?>;
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<input type="text" class="form-control" name="site_info[baseurl]" id="site_info_baseurl"
|
<input type="text" class="form-control" name="site_info[baseurl]"
|
||||||
|
id="site_info_baseurl"
|
||||||
placeholder="eg: ponepaste.org (no trailing slash)"
|
placeholder="eg: ponepaste.org (no trailing slash)"
|
||||||
value="<?= pp_html_escape($current_site_info['baseurl']); ?>">
|
value="<?= pp_html_escape($current_site_info['baseurl']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_description">Site Description</label>
|
<label class="col-sm-2 control-label form-label"
|
||||||
|
for="site_info_description">Site Description</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" name="site_info[description]" id="site_info_description"
|
<input type="text" class="form-control" name="site_info[description]"
|
||||||
|
id="site_info_description"
|
||||||
placeholder="Site description"
|
placeholder="Site description"
|
||||||
value="<?= pp_html_escape($current_site_info['description']); ?>">
|
value="<?= pp_html_escape($current_site_info['description']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_keywords">Site Keywords</label>
|
<label class="col-sm-2 control-label form-label" for="site_info_keywords">Site
|
||||||
|
Keywords</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" name="site_info[keywords]" id="site_info_keywords"
|
<input type="text" class="form-control" name="site_info[keywords]"
|
||||||
|
id="site_info_keywords"
|
||||||
placeholder="Keywords (separated by a comma)"
|
placeholder="Keywords (separated by a comma)"
|
||||||
value="<?= pp_html_escape($current_site_info['keywords']); ?>">
|
value="<?= pp_html_escape($current_site_info['keywords']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_email">Admin Email</label>
|
<label class="col-sm-2 control-label form-label" for="site_info_email">Admin
|
||||||
|
Email</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control" name="site_info[email]" placeholder="Email" id="site_info_email"
|
<input type="text" class="form-control" name="site_info[email]"
|
||||||
|
placeholder="Email" id="site_info_email"
|
||||||
value="<?= pp_html_escape($current_site_info['email']); ?>">
|
value="<?= pp_html_escape($current_site_info['email']); ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label form-label" for="site_info_additional_scripts">Additional Site
|
<label class="col-sm-2 control-label form-label"
|
||||||
|
for="site_info_additional_scripts">Additional Site
|
||||||
Scripts</label>
|
Scripts</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<textarea class="form-control" id="additional_scripts" id="site_info_additional_scripts"
|
<textarea class="form-control" id="additional_scripts"
|
||||||
|
id="site_info_additional_scripts"
|
||||||
name="site_info[additional_scripts]"
|
name="site_info[additional_scripts]"
|
||||||
rows="8"><?= pp_html_escape($current_site_info['title']); ?></textarea>
|
rows="8"><?= pp_html_escape($current_site_info['title']); ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
@ -274,7 +288,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
action="<?= $_SERVER['PHP_SELF']; ?>">
|
action="<?= $_SERVER['PHP_SELF']; ?>">
|
||||||
|
|
||||||
<div class="checkbox checkbox-primary">
|
<div class="checkbox checkbox-primary">
|
||||||
<input <?php if ($current_captcha['enabled']) echo 'checked="true"'; ?> type="checkbox"
|
<input <?php if ($current_captcha['enabled']) echo 'checked="true"'; ?>
|
||||||
|
type="checkbox"
|
||||||
name="captcha[enabked]"
|
name="captcha[enabked]"
|
||||||
id="captcha_enabled">
|
id="captcha_enabled">
|
||||||
<label for="captcha_enabled">Enable Captcha</label>
|
<label for="captcha_enabled">Enable Captcha</label>
|
||||||
|
@ -282,7 +297,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="captcha_mode" class="col-sm-1 col-form-label">Captcha Type</label>
|
<label for="captcha_mode" class="col-sm-1 col-form-label">Captcha
|
||||||
|
Type</label>
|
||||||
<select id="captcha_mode" class="selectpicker" name="captcha[mode]">
|
<select id="captcha_mode" class="selectpicker" name="captcha[mode]">
|
||||||
<?php
|
<?php
|
||||||
if ($current_captcha['mode'] == "Easy") {
|
if ($current_captcha['mode'] == "Easy") {
|
||||||
|
@ -311,7 +327,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
Internal Captcha Settings:
|
Internal Captcha Settings:
|
||||||
</div>
|
</div>
|
||||||
<div class="checkbox checkbox-primary">
|
<div class="checkbox checkbox-primary">
|
||||||
<input <?php if ($current_captcha['multiple']) echo 'checked="checked"'; ?> type="checkbox"
|
<input <?php if ($current_captcha['multiple']) echo 'checked="checked"'; ?>
|
||||||
|
type="checkbox"
|
||||||
name="captcha[multiple]"
|
name="captcha[multiple]"
|
||||||
id="captcha_multiple">
|
id="captcha_multiple">
|
||||||
<label for="captcha_multiple">Enable multiple backgrounds</label>
|
<label for="captcha_multiple">Enable multiple backgrounds</label>
|
||||||
|
@ -322,7 +339,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
Characters</label>
|
Characters</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" id="captcha_allowed" name="captcha[allowed]"
|
<input type="text" id="captcha_allowed" name="captcha[allowed]"
|
||||||
placeholder="Allowed Characters" value="<?php echo $current_captcha['allowed']; ?>">
|
placeholder="Allowed Characters"
|
||||||
|
value="<?php echo $current_captcha['allowed']; ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -331,7 +349,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
Colour</label>
|
Colour</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" id="captcha_colour" name="captcha[colour]"
|
<input type="text" id="captcha_colour" name="captcha[colour]"
|
||||||
placeholder="Captcha Text Colour" value="<?= $current_captcha['colour']; ?>">
|
placeholder="Captcha Text Colour"
|
||||||
|
value="<?= $current_captcha['colour']; ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class DatabaseHandle {
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function querySelectOne(string $query, array $params = null) : array | null {
|
public function querySelectOne(string $query, array $params = null) : array|null {
|
||||||
$stmt = $this->query($query, $params);
|
$stmt = $this->query($query, $params);
|
||||||
|
|
||||||
if ($row = $stmt->fetch()) {
|
if ($row = $stmt->fetch()) {
|
||||||
|
@ -39,6 +39,6 @@ class DatabaseHandle {
|
||||||
public function queryInsert(string $query, array $params = null) : int {
|
public function queryInsert(string $query, array $params = null) : int {
|
||||||
$this->query($query, $params);
|
$this->query($query, $params);
|
||||||
|
|
||||||
return (int) $this->conn->lastInsertId();
|
return (int)$this->conn->lastInsertId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Tag {
|
||||||
public string $slug;
|
public string $slug;
|
||||||
|
|
||||||
public function __construct(array $row) {
|
public function __construct(array $row) {
|
||||||
$this->id = (int) $row['id'];
|
$this->id = (int)$row['id'];
|
||||||
$this->name = $row['name'];
|
$this->name = $row['name'];
|
||||||
$this->slug = $row['slug'];
|
$this->slug = $row['slug'];
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class Tag {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function findBySlug(DatabaseHandle $conn, string $slug) : Tag | null {
|
public static function findBySlug(DatabaseHandle $conn, string $slug) : Tag|null {
|
||||||
if ($row = $conn->querySelectOne('SELECT id, name, slug FROM tags WHERE slug = ?', [$slug])) {
|
if ($row = $conn->querySelectOne('SELECT id, name, slug FROM tags WHERE slug = ?', [$slug])) {
|
||||||
return new Tag($row);
|
return new Tag($row);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ $noguests = $disableguest;
|
||||||
|
|
||||||
// CAPTCHA configuration
|
// CAPTCHA configuration
|
||||||
$captcha_config = $site_info['captcha'];
|
$captcha_config = $site_info['captcha'];
|
||||||
$captcha_enabled = (bool) $captcha_config['enabled'];
|
$captcha_enabled = (bool)$captcha_config['enabled'];
|
||||||
|
|
||||||
// Prevent a potential LFI (you never know :p)
|
// Prevent a potential LFI (you never know :p)
|
||||||
$lang_file = "${default_lang}.php";
|
$lang_file = "${default_lang}.php";
|
||||||
|
|
|
@ -73,7 +73,7 @@ function sandwitch($str) {
|
||||||
|
|
||||||
|
|
||||||
function getevent($conn, $event_name, $count) {
|
function getevent($conn, $event_name, $count) {
|
||||||
$query = $conn->prepare("SELECT id, visible, title, date, now_time, views, member, tagsys FROM pastes WHERE visible='1' AND tagsys LIKE '%?%'
|
$query = $conn->prepare("SELECT id, visible, title, date, now_time, views, member FROM pastes WHERE visible='1' AND tagsys LIKE '%?%'
|
||||||
ORDER BY RAND () LIMIT 0, ?");
|
ORDER BY RAND () LIMIT 0, ?");
|
||||||
$query->execute([$event_name, $count]);
|
$query->execute([$event_name, $count]);
|
||||||
return $query->fetchAll();
|
return $query->fetchAll();
|
||||||
|
|
|
@ -27,7 +27,7 @@ require_once('includes/captcha.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
require_once('includes/Tag.class.php');
|
require_once('includes/Tag.class.php');
|
||||||
|
|
||||||
function verifyCaptcha() : string | bool {
|
function verifyCaptcha() : string|bool {
|
||||||
global $captcha_config;
|
global $captcha_config;
|
||||||
global $lang;
|
global $lang;
|
||||||
global $current_user;
|
global $current_user;
|
||||||
|
@ -157,7 +157,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
// Edit existing paste or create new?
|
// Edit existing paste or create new?
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
if ($current_user &&
|
if ($current_user &&
|
||||||
$current_user->user_id === (int) $conn->querySelectOne('SELECT user_id FROM pastes WHERE id = ?', [$_POST['paste_id']])['user_id']) {
|
$current_user->user_id === (int)$conn->querySelectOne('SELECT user_id FROM pastes WHERE id = ?', [$_POST['paste_id']])['user_id']) {
|
||||||
$paste_id = intval($_POST['paste_id']);
|
$paste_id = intval($_POST['paste_id']);
|
||||||
|
|
||||||
$conn->query(
|
$conn->query(
|
||||||
|
|
|
@ -39,7 +39,7 @@ $fav_count = intval($query->fetch(PDO::FETCH_NUM)[0]);
|
||||||
|
|
||||||
// Get paste info
|
// Get paste info
|
||||||
$row = $conn->querySelectOne(
|
$row = $conn->querySelectOne(
|
||||||
'SELECT title, content, visible, code, expiry, pastes.password AS password, created_at, updated_at, encrypt, views, tagsys, users.username AS member, users.id AS user_id
|
'SELECT title, content, visible, code, expiry, pastes.password AS password, created_at, updated_at, encrypt, views, users.username AS member, users.id AS user_id
|
||||||
FROM pastes
|
FROM pastes
|
||||||
INNER JOIN users ON users.id = pastes.user_id
|
INNER JOIN users ON users.id = pastes.user_id
|
||||||
WHERE pastes.id = ?', [$paste_id]);
|
WHERE pastes.id = ?', [$paste_id]);
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
function setupTagsInput() {
|
function setupTagsInput() {
|
||||||
const tagsInput = document.getElementById('tags-with-source');
|
const tagsInput = document.getElementById('tags-with-source');
|
||||||
new BulmaTagsInput(tagsInput, {
|
new BulmaTagsInput(tagsInput, {
|
||||||
source: async function(value) {
|
source: async function (value) {
|
||||||
// Value equal input value
|
// Value equal input value
|
||||||
// We can then use it to request data from external API
|
// We can then use it to request data from external API
|
||||||
return await fetch("/api/tags_autocomplete.php?tag=" + encodeURIComponent(value))
|
return await fetch("/api/tags_autocomplete.php?tag=" + encodeURIComponent(value))
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.json();
|
return response.json();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,9 @@
|
||||||
<div class="list-widget pagination-content">
|
<div class="list-widget pagination-content">
|
||||||
<?php
|
<?php
|
||||||
$res = getrandom($conn, 10);
|
$res = getrandom($conn, 10);
|
||||||
foreach ($res as $index => $row) {
|
foreach ($res
|
||||||
|
|
||||||
|
as $index => $row) {
|
||||||
$title = Trim($row['title']);
|
$title = Trim($row['title']);
|
||||||
$titlehov = ($row['title']);
|
$titlehov = ($row['title']);
|
||||||
$p_member = Trim($row['member']);
|
$p_member = Trim($row['member']);
|
||||||
|
@ -242,8 +244,10 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Tags</label>
|
<label class="label">Tags</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input id="tags-with-source" name="tag_input" class="input" data-max-tags="10"
|
<input id="tags-with-source" name="tag_input" class="input"
|
||||||
data-max-chars="40" type="text" data-item-text="name" data-item-value="name"
|
data-max-tags="10"
|
||||||
|
data-max-chars="40" type="text" data-item-text="name"
|
||||||
|
data-item-value="name"
|
||||||
data-case-sensitive="false" placeholder="10 Tags Maximum"
|
data-case-sensitive="false" placeholder="10 Tags Maximum"
|
||||||
value="<?php echo (isset($_POST['tag_input'])) ? $_POST['tag_input'] : ''; // Pre-populate if we come here on an error" ?>">
|
value="<?php echo (isset($_POST['tag_input'])) ? $_POST['tag_input'] : ''; // Pre-populate if we come here on an error" ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -143,7 +143,7 @@ $protocol = paste_protocol();
|
||||||
<table id="archive" class="table is-fullwidth is-hoverable">
|
<table id="archive" class="table is-fullwidth is-hoverable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="td-right" ><?php echo $lang['pastetitle']; ?></td>
|
<td class="td-right"><?php echo $lang['pastetitle']; ?></td>
|
||||||
<td class="td-center"><?php echo $lang['pastetime']; ?></td>
|
<td class="td-center"><?php echo $lang['pastetime']; ?></td>
|
||||||
<?php if ($is_current_user) {
|
<?php if ($is_current_user) {
|
||||||
echo "<td class='td-center'>" . $lang['visibility'] . "</td>";
|
echo "<td class='td-center'>" . $lang['visibility'] . "</td>";
|
||||||
|
@ -179,7 +179,9 @@ $protocol = paste_protocol();
|
||||||
$p_dateui = $p_date->format("d F Y");
|
$p_dateui = $p_date->format("d F Y");
|
||||||
$p_views = Trim($row['views']);
|
$p_views = Trim($row['views']);
|
||||||
$p_visible = intval($row['visible']);
|
$p_visible = intval($row['visible']);
|
||||||
$tagArray = array_map(function($tag) { return $tag['name']; }, getPasteTags($conn, $p_id));
|
$tagArray = array_map(function ($tag) {
|
||||||
|
return $tag['name'];
|
||||||
|
}, getPasteTags($conn, $p_id));
|
||||||
$p_tags = implode(',', $tagArray);
|
$p_tags = implode(',', $tagArray);
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,7 +264,7 @@ $protocol = paste_protocol();
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ($profile_favs as $index => $row) {
|
foreach ($profile_favs as $row) {
|
||||||
$ftitle = Trim($row['title']);
|
$ftitle = Trim($row['title']);
|
||||||
$f_id = Trim($row['paste_id']);
|
$f_id = Trim($row['paste_id']);
|
||||||
$f_date = new DateTime($row['f_time']);
|
$f_date = new DateTime($row['f_time']);
|
||||||
|
|
Loading…
Add table
Reference in a new issue