Reformat code.

This commit is contained in:
Floorb 2021-08-22 22:05:26 -04:00
parent 7cd0aec39e
commit 9349d245a0
19 changed files with 1558 additions and 834 deletions

View file

@ -39,6 +39,6 @@ class DatabaseHandle {
public function queryInsert(string $query, array $params = null) : int {
$this->query($query, $params);
return (int)$this->conn->lastInsertId();
return (int) $this->conn->lastInsertId();
}
}

View file

@ -1,4 +1,5 @@
<?php
class NonRetardedSSP {
public static function run(DatabaseHandle $conn, array $request, string $countQuery, string $query) {
/* Some of these parameters might not be passed; zero is an OK default */

View file

@ -6,7 +6,7 @@ class Tag {
public string $slug;
public function __construct(array $row) {
$this->id = (int)$row['id'];
$this->id = (int) $row['id'];
$this->name = $row['name'];
$this->slug = $row['slug'];
}

View file

@ -101,7 +101,7 @@ function captcha($color, $mode, $mul, $allowed) : array {
}
if (!function_exists('hex2rgb')) {
function hex2rgb($hex_str) : array | null {
function hex2rgb($hex_str) : array|null {
$hex_str = preg_replace("/[^0-9A-Fa-f]/", '', $hex_str); // Gets a proper hex string
if (strlen($hex_str) == 6) {

View file

@ -37,10 +37,12 @@ function getreports($conn, $count = 10) {
}
function tagsToHtml(string | array $tags) : string {
function tagsToHtml(string|array $tags) : string {
$output = "";
if (is_array($tags)) {
$tagsSplit = array_map(function($tag) { return $tag['name']; }, $tags);
$tagsSplit = array_map(function ($tag) {
return $tag['name'];
}, $tags);
} else {
$tagsSplit = explode(",", $tags);
}
@ -85,7 +87,7 @@ function linkify($value, $protocols = array('http', 'mail'), array $attributes =
}, $value);
// Extract text links for each protocol
foreach ((array)$protocols as $protocol) {
foreach ((array) $protocols as $protocol) {
$value = match ($protocol) {
'http', 'https' => preg_replace_callback('~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i', function ($match) use ($protocol, &$links, $attr) {
if ($match[1]) $protocol = $match[1];

View file

@ -133,7 +133,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Edit existing paste or create new?
if ($editing) {
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']);
$conn->query(

View file

@ -47,7 +47,7 @@ if (isset($_POST['forgot'])) {
}
} elseif (isset($_POST['signin'])) { // Login process
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$remember_me = (bool)$_POST['remember_me'];
$remember_me = (bool) $_POST['remember_me'];
$username = trim($_POST['username']);
$row = $conn->query("SELECT id, password, banned FROM users WHERE username = ?", [$username])
->fetch();
@ -72,7 +72,7 @@ if (isset($_POST['forgot'])) {
$error = $lang['banned'];
} else {
// Login successful
$_SESSION['user_id'] = (string)$user_id;
$_SESSION['user_id'] = (string) $user_id;
if ($remember_me) {
$remember_token = pp_random_token();
@ -81,7 +81,7 @@ if (isset($_POST['forgot'])) {
$conn->query('INSERT INTO user_sessions (user_id, token, expire_at) VALUES (?, ?, FROM_UNIXTIME(?))', [$user_id, $remember_token, $expire_at->format('U')]);
setcookie(User::REMEMBER_TOKEN_COOKIE, $remember_token, [
'expires' => (int)$expire_at->format('U'),
'expires' => (int) $expire_at->format('U'),
'secure' => !empty($_SERVER['HTTPS']), /* Local dev environment is non-HTTPS */
'httponly' => true,
'samesite' => 'Lax'

View file

@ -62,12 +62,12 @@ $paste = [
'tags' => getPasteTags($conn, $paste_id)
];
$p_member = $row['member'];
$p_content = $row['content'];
$p_visible = $row['visible'];
$p_expiry = $row['expiry'];
$p_password = $row['password'];
$p_encrypt = (bool) $row['encrypt'];
$p_member = $row['member'];
$p_content = $row['content'];
$p_visible = $row['visible'];
$p_expiry = $row['expiry'];
$p_password = $row['password'];
$p_encrypt = (bool) $row['encrypt'];
$is_private = $row['visible'] === '2';
@ -85,7 +85,7 @@ $password_candidate = '';
if ($password_required) {
if (!empty($_POST['mypass'])) {
$password_candidate = $_POST['mypass'];
} else if (!empty($_GET['password'])) {
} elseif (!empty($_GET['password'])) {
$password_candidate = @base64_decode($_GET['password']);
}

View file

@ -1,7 +1,7 @@
<script>
$(document).ready(function () {
$("#archive").dataTable({
rowReorder: { selector: 'td:nth-child(2)'},
rowReorder: {selector: 'td:nth-child(2)'},
responsive: true,
processing: true,
language: {processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> '},

View file

@ -16,7 +16,7 @@ $start = $time;
<!DOCTYPE html>
<html lang="<?php echo basename($default_lang, ".php"); ?>">
<head>
<meta charset="UTF-8" />
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
@ -33,9 +33,9 @@ $start = $time;
<meta name="description" content="<?= pp_html_escape($global_site_info['description']) ?>"/>
<meta name="keywords" content="<?= pp_html_escape($global_site_info['keywords']) ?>"/>
<link rel="shortcut icon" href="<?php echo '//' . $baseurl . '/theme/' . $default_theme; ?>/img/favicon.ico">
<link href="//<?= $baseurl ?>/theme/bulma/css/paste.css" rel="stylesheet" />
<link href="//<?= $baseurl ?>/theme/bulma/css/table-responsive.css" rel="stylesheet" />
<link href="//<?= $baseurl ?>/theme/bulma/css/table-row-orders.css" rel="stylesheet" />
<link href="//<?= $baseurl ?>/theme/bulma/css/paste.css" rel="stylesheet"/>
<link href="//<?= $baseurl ?>/theme/bulma/css/table-responsive.css" rel="stylesheet"/>
<link href="//<?= $baseurl ?>/theme/bulma/css/table-row-orders.css" rel="stylesheet"/>
<script src="//<?= $baseurl ?>/theme/bulma/js/jquery.min.js"></script>
<script src="//<?= $baseurl ?>/theme/bulma/js/jquery-ui.min.js"></script>
<script src="//<?= $baseurl ?>/theme/bulma/js/paste.js"></script>
@ -54,7 +54,7 @@ $start = $time;
class="navbar-item mx-1"><?php echo $site_name; ?></a>
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<input type="checkbox" id="checkbox"/>
<div class="slider round"></div>
</label>
</div>
@ -355,7 +355,6 @@ CONTENT HERE!
</footer>
<script>
const whenReady = (callback) => {
if (document.readyState !== 'loading') {

File diff suppressed because it is too large Load diff

View file

@ -4,11 +4,13 @@ table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty {
cursor: default !important;
background-color: #e8e8e8;
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty:before {
display: none !important;
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
position: relative;
@ -16,6 +18,7 @@ table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
padding-top: 25px;
cursor: pointer;
}
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
top: 50%;
@ -33,17 +36,20 @@ table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
font-family: 'Font Awesome\ 5 Free';
font-weight: 900;
line-height: 1em;
content:"\f054";
content: "\f054";
color: #3298dc;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
content:"\f078";
content: "\f078";
}
table.dataTable.dtr-inline.collapsed.compact > tbody > tr > td.dtr-control,
table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th.dtr-control {
padding-left: 27px;
}
table.dataTable.dtr-inline.collapsed.compact > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th.dtr-control:before {
left: 4px;
@ -53,6 +59,7 @@ table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th.dtr-control:befor
line-height: 14px;
text-indent: 3px;
}
table.dataTable.dtr-column > tbody > tr > td.dtr-control,
table.dataTable.dtr-column > tbody > tr > th.dtr-control,
table.dataTable.dtr-column > tbody > tr > td.control,
@ -60,6 +67,7 @@ table.dataTable.dtr-column > tbody > tr > th.control {
position: relative;
cursor: pointer;
}
table.dataTable.dtr-column > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-column > tbody > tr > th.dtr-control:before,
table.dataTable.dtr-column > tbody > tr > td.control:before,
@ -79,42 +87,51 @@ table.dataTable.dtr-column > tbody > tr > th.control:before {
font-family: 'Font Awesome\ 5 Free';
font-weight: 900;
line-height: 1em;
content:"\f054";
content: "\f054";
color: #3298dc;
}
table.dataTable.dtr-column > tbody > tr.parent td.dtr-control:before,
table.dataTable.dtr-column > tbody > tr.parent th.dtr-control:before,
table.dataTable.dtr-column > tbody > tr.parent td.control:before,
table.dataTable.dtr-column > tbody > tr.parent th.control:before {
content:"\f078";
content: "\f078";
}
table.dataTable > tbody > tr.child {
padding: 0.5em 1em;
}
table.dataTable > tbody > tr.child:hover {
background: transparent !important;
}
table.dataTable > tbody > tr.child ul.dtr-details {
display: inline-block;
list-style-type: none;
margin: 0;
padding: 0;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
border-bottom: 1px solid #efefef;
padding: 0.5em 0;
}
table.dataTable > tbody > tr.child ul.dtr-details > li:first-child {
padding-top: 0;
}
table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
border-bottom: none;
}
table.dataTable > tbody > tr.child span.dtr-title {
display: inline-block;
min-width: 75px;
font-weight: bold;
}
div.dtr-modal {
position: fixed;
box-sizing: border-box;
@ -125,6 +142,7 @@ div.dtr-modal {
z-index: 100;
padding: 10em 1em;
}
div.dtr-modal div.dtr-modal-display {
position: absolute;
top: 0;
@ -142,10 +160,12 @@ div.dtr-modal div.dtr-modal-display {
border-radius: 0.5em;
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
div.dtr-modal div.dtr-modal-content {
position: relative;
padding: 1em;
}
div.dtr-modal div.dtr-modal-close {
position: absolute;
top: 6px;
@ -159,9 +179,11 @@ div.dtr-modal div.dtr-modal-close {
cursor: pointer;
z-index: 12;
}
div.dtr-modal div.dtr-modal-close:hover {
background-color: #eaeaea;
}
div.dtr-modal div.dtr-modal-background {
position: fixed;
top: 0;
@ -171,6 +193,7 @@ div.dtr-modal div.dtr-modal-background {
z-index: 101;
background: rgba(0, 0, 0, 0.6);
}
@media screen and (max-width: 767px) {
div.dtr-modal div.dtr-modal-display {
width: 95%;

View file

@ -6,13 +6,16 @@ table.dt-rowReorder-float {
outline-offset: -2px;
z-index: 2001;
}
tr.dt-rowReorder-moving {
outline: 2px solid #555;
outline-offset: -2px;
}
body.dt-rowReorder-noOverflow {
overflow-x: hidden;
}
table.dataTable td.reorder {
text-align: center;
cursor: move;

View file

@ -15,9 +15,9 @@
<form action="" method="post">
<div class="field has-addons">
<div class="control">
<input type="hidden" name="id" value="<?php echo $paste_id; ?>" />
<input type="hidden" name="id" value="<?php echo $paste_id; ?>"/>
<input type="password" class="input" name="mypass"
placeholder="<?php echo $lang['enterpwd']; ?>" />
placeholder="<?php echo $lang['enterpwd']; ?>"/>
</div>
</div>
<button type="submit" name="submit" class="button is-info">Submit</button>

View file

@ -2,7 +2,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="theme/bulma/js/bulma-tagsinput.min.js"></script>
<script>
function setupTagsInput() {
function setupTagsInput() {
const tagsInput = document.getElementById('tags-with-source');
new BulmaTagsInput(tagsInput, {
allowDuplicates: false,
@ -329,7 +329,7 @@ function setupTagsInput() {
<div class="column">
<input type="text" class="input" name="pass" id="pass"
placeholder="<?php echo $lang['pwopt']; ?>"
value="<?php echo (isset($_POST['pass'])) ? pp_html_escape($_POST['pass']) : ''; ?>" />
value="<?php echo (isset($_POST['pass'])) ? pp_html_escape($_POST['pass']) : ''; ?>"/>
</div>
</div>
</div>

View file

@ -34,7 +34,8 @@
</div>
</div>
<div class="field">
<button disabled type="submit" name="Gen_key" class="button is-info">Generate New Key</button>
<button disabled type="submit" name="Gen_key" class="button is-info">Generate New Key
</button>
<br>
<small>Coming soon</small>
</div>

View file

@ -1,7 +1,7 @@
<script>
$(document).ready(function () {
$("#archive").dataTable({
rowReorder: { selector: 'td:nth-child(2)'},
rowReorder: {selector: 'td:nth-child(2)'},
responsive: true,
pageLength: 50,
autoWidth: false,
@ -21,7 +21,7 @@
<script>
$(document).ready(function () {
$("#favs").dataTable({
rowReorder: { selector: 'td:nth-child(2)'},
rowReorder: {selector: 'td:nth-child(2)'},
responsive: true,
pageLength: 50,
autoWidth: false,
@ -232,7 +232,7 @@
' . strtoupper($p_code) . '
</td>
<td class="td-center">
<a href="' . $protocol . $baseurl . '/' . $p_delete_link . '" title="' . $title . '" onClick="return confirm(' . $p_delete_message. ')"><i class="far fa-trash-alt fa-lg" aria-hidden="true"></i></a>
<a href="' . $protocol . $baseurl . '/' . $p_delete_link . '" title="' . $title . '" onClick="return confirm(' . $p_delete_message . ')"><i class="far fa-trash-alt fa-lg" aria-hidden="true"></i></a>
</td>
</tr>';
}
@ -264,7 +264,9 @@
$f_dateui = $f_date->format("d F Y");
$Recent_update = new DateTime($row['updated_at']);
$Recent_update_u = date_format($Recent_update, 'U');
$tagArray2 = array_map(function ($tag) { return $tag['name'];}, getPasteTags($conn, $f_id));
$tagArray2 = array_map(function ($tag) {
return $tag['name'];
}, getPasteTags($conn, $f_id));
$f_tags = implode(',', $tagArray2);
//$p_link = ($mod_rewrite == '1') ? "$f_id" : "paste.php?favdel=$fu_id";
//$f_delete_link = ($mod_rewrite == '1') ? "user.php?favdel&user=$profile_username&fid=$f_id" : "user.php?favdel&user=$profile_username&fid=$f_id";

View file

@ -1,7 +1,7 @@
<link rel="stylesheet" href="theme/bulma/css/bulma-tagsinput.min.css"/>
<script src="theme/bulma/js/bulma-tagsinput.min.js"></script>
<script>
function setupTagsInput() {
function setupTagsInput() {
const tagsInput = document.getElementById('tags-with-source');
if (tagsInput) {
@ -68,7 +68,7 @@ function setupTagsInput() {
});
</script>
<?php if ($using_highlighter): ?>
<link rel="stylesheet" href="/vendor/scrivo/highlight.php/styles/default.css" />
<link rel="stylesheet" href="/vendor/scrivo/highlight.php/styles/default.css"/>
<?php endif; ?>
<?php
$protocol = paste_protocol();
@ -212,7 +212,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
} else {
echo 'paste.php?embed&id=';
}
echo $paste_id . '"></script>'; ?>' readonly />
echo $paste_id . '"></script>'; ?>' readonly/>
</div>
</div>
</div>
@ -295,7 +295,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
<p class="control has-icons-left">
<input type="text" class="input" name="title"
placeholder="<?= $paste['title'] ?>"
value="<?= $paste['title'] ?>" />
value="<?= $paste['title'] ?>"/>
<span class="icon is-small is-left">
<i class="fa fa-font"></i>
</span>
@ -346,8 +346,8 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
$inputtags = $paste['tags'];
foreach ($inputtags as $tag) {
$tagsName = ucfirst(pp_html_escape($tag['name']));
echo ','.$tagsName.'';
}?>">
echo ',' . $tagsName . '';
} ?>">
</div>
</div>
</div>
@ -412,7 +412,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
<div class="columns">
<div class="column">
<input type="text" class="input" name="pass" id="pass" value=""
placeholder="<?php echo $lang['pwopt']; ?>" />
placeholder="<?php echo $lang['pwopt']; ?>"/>
</div>
</div>
</div>