fix(tags): client-sided tag limit is better; tag highlighting rules slightly better

This commit is contained in:
Floorb 2023-02-27 05:22:21 -05:00
parent c238975adf
commit 758d1d5d1d
23 changed files with 1015 additions and 1196 deletions

View file

@ -1,65 +0,0 @@
<?php
session_start();
if (!isset($_SESSION['login'])) {
header("Location: .");
exit();
}
if (isset($_GET['logout'])) {
if (isset($_SESSION['login']))
unset($_SESSION['login']);
session_destroy();
header("Location: .");
exit();
}
require_once('../includes/config.php');
// DB table to use
$table = 'user_reports';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'm_report', 'dt' => 1),
array('db' => 'p_report', 'dt' => 2),
array('db' => 't_report', 'dt' => 3)
);
$columns2 = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'm_report', 'dt' => 1),
array('db' => 'p_report', 'dt' => 2),
array('db' => 't_report', 'dt' => 3),
array('db' => 'details', 'dt' => 4),
array('db' => 'view', 'dt' => 5),
array('db' => 'delete', 'dt' => 6)
);
// SQL server connection information
$sql_details = array(
'user' => $dbuser,
'pass' => $dbpassword,
'db' => $dbname,
'host' => $dbhost
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require('ssp.reports.php');
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2)
);

View file

@ -1,57 +0,0 @@
<?php
require_once('../includes/config.php');
// DB table to use
$table = 'users';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'username', 'dt' => 1),
array('db' => 'date', 'dt' => 3),
array('db' => 'platform', 'dt' => 4),
array('db' => 'id', 'dt' => 5),
array('db' => 'verified', 'dt' => 7)
);
$columns2 = array(
array('db' => 'id', 'dt' => 0),
array('db' => 'username', 'dt' => 1),
array('db' => 'date', 'dt' => 3),
array('db' => 'platform', 'dt' => 4),
array('db' => 'ban', 'dt' => 5),
array('db' => 'view', 'dt' => 6),
array('db' => 'delete', 'dt' => 7)
);
// SQL server connection information
$sql_details = array(
'user' => $db_user,
'pass' => $db_pass,
'db' => $db_schema,
'host' => $db_host
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require('ssp.users.php');
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $columns2)
);
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
header("Location: http://ponepaste.org/SVOtaKqJZh4nT9Z");
die();
}

View file

@ -162,15 +162,6 @@ if (isset($_GET['delete'])) {
<li class="col-xs-3 col-sm-2 col-md-1">
<a href="stats.php"><i class="fa fa-line-chart"></i>Statistics</a>
</li>
<li class="col-xs-3 col-sm-2 col-md-1">
<a href="ads.php"><i class="fa fa-gbp"></i>Ads</a>
</li>
<li class="col-xs-3 col-sm-2 col-md-1">
<a href="sitemap.php"><i class="fa fa-map-signs"></i>Sitemap</a>
</li>
<li class="col-xs-3 col-sm-2 col-md-1">
<a href="tasks.php"><i class="fa fa-tasks"></i>Tasks</a>
</li>
</ul>
</div>
</div>

View file

View file

@ -1,244 +0,0 @@
<?php
session_start();
if (!isset($_SESSION['login'])) {
header("Location: .");
exit();
}
if (isset($_GET['logout'])) {
if (isset($_SESSION['login']))
unset($_SESSION['login']);
session_destroy();
header("Location: .");
exit();
}
$date = date('jS F Y');
$ip = $_SERVER['REMOTE_ADDR'];
require_once('../includes/config.php');
$con = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname);
if (mysqli_connect_errno()) {
$sql_error = mysqli_connect_error();
die("Unable connect to database");
}
$query = "SELECT @last_id := MAX(id) FROM admin_history";
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {
$last_id = $row['@last_id := MAX(id)'];
}
$query = "SELECT * FROM admin_history WHERE id=" . Trim($last_id);
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {
$last_date = $row['last_date'];
$last_ip = $row['ip'];
}
if ($last_ip == $ip) {
if ($last_date == $date) {
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query);
}
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query);
}
$query = "Select * From sitemap_options WHERE id='1'";
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {
$priority = $row['priority'];
$changefreq = $row['changefreq'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Paste - Sitemap</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="css/paste.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top" class="clearfix">
<!-- Start App Logo -->
<div class="applogo">
<a href="../" class="logo">Paste</a>
</div>
<!-- End App Logo -->
<!-- Start Top Right -->
<ul class="top-right">
<li class="dropdown link">
<a href="#" data-toggle="dropdown" class="dropdown-toggle profilebox"><b>Admin</b><span
class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-list dropdown-menu-right">
<li><a href="admin.php">Settings</a></li>
<li><a href="?logout">Logout</a></li>
</ul>
</li>
</ul>
<!-- End Top Right -->
</div>
<!-- END TOP -->
<div class="content">
<!-- START CONTAINER -->
<div class="container-widget">
<!-- Start Menu -->
<?php include 'menu.php'; ?>
<!-- End Menu -->
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$priority = htmlentities(Trim($_POST['priority']));
$changefreq = htmlentities(Trim($_POST['changefreq']));
$query = "UPDATE sitemap_options SET priority='$priority', changefreq='$changefreq' WHERE id='1'";
mysqli_query($con, $query);
if (mysqli_errno($con)) {
echo '<div class="paste-alert alert6">
' . mysqli_error($con) . '
</div>';
} else {
echo '
<div class="paste-alert alert3">
Sitemap saved.
</div>';
}
}
?>
<!-- Start Sitemap -->
<div class="row">
<div class="col-md-12">
<div class="panel panel-widget">
<div class="panel-body">
<div class="panel-title">Sitemap</a></div>
<?php if (isset($msg)) echo $msg; ?>
<form method="POST" action="sitemap.php">
<div class="form-group">
<label for="changefreq">Change Frequency</label>
<input type="text" placeholder="Enter frequency range" name="changefreq" id="changefreq"
value="<?php echo $changefreq; ?>" class="form-control">
</div>
<div class="form-group">
<label for="priority">Priority Level</label>
<input type="text" placeholder="Enter priority..." id="priority" name="priority"
value="<?php echo $priority; ?>" class="form-control">
</div>
<button class="btn btn-default" type="submit">Submit</button>
</form>
<br/>
<?php
if (isset($_GET['re'])) {
unlink('../sitemap.xml');
// which protocol are we on
$protocol = paste_protocol();
// level up, dirty but meh
$x = 2;
$path = dirname($_SERVER['PHP_SELF']);
while (max(0, --$x)) {
$levelup = dirname($path);
}
$c_date = date('Y-m-d');
$data = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>' . $protocol . $_SERVER['SERVER_NAME'] . $levelup . '/</loc>
<priority>1.0</priority>
<changefreq>daily</changefreq>
<lastmod>' . $c_date . '</lastmod>
</url>
</urlset>';
file_put_contents("../sitemap.xml", $data);
$rec_limit = 10;
$query = "SELECT count(id) FROM pastes";
$retval = mysqli_query($con, $query);
$row = mysqli_fetch_array($retval);
$rec_count = Trim($row[0]);
$offset = 0;
// Set the specific query to display in the table
$sql = "SELECT * FROM `pastes` WHERE visible='0' LIMIT $offset, $rec_count ";
$result = mysqli_query($con, $sql);
// Loop through each record
while ($row = mysqli_fetch_array($result)) {
$paste_id = Trim($row['id']);
$site_data = file_get_contents("../sitemap.xml");
$site_data = str_replace("</urlset>", "", $site_data);
if (PP_MOD_REWRITE) {
$server_name = $protocol . $_SERVER['SERVER_NAME'] . $levelup . "/" . $paste_id;
} else {
$server_name = $protocol . $_SERVER['SERVER_NAME'] . $levelup . "/paste.php?id=" . $paste_id;
}
$c_date = date('Y-m-d');
$c_sitemap = '
<url>
<loc>' . $server_name . '</loc>
<priority>' . $priority . '</priority>
<changefreq>' . $changefreq . '</changefreq>
<lastmod>' . $c_date . '</lastmod>
</url>
</urlset>';
$full_map = $site_data . $c_sitemap;
file_put_contents("../sitemap.xml", $full_map);
}
}
?>
<?php
if (isset($_GET['re'])) {
echo '
<div class="paste-alert alert3">
sitemap.xml rebuilt
</div>';
}
?>
<form method="GET" action="sitemap.php">
<button class="btn btn-default" name="re" id="re" type="submit">Generate sitemap.xml
</button>
</form>
</div>
</div>
</div>
</div>
<!-- End Sitemap -->
</div>
<!-- END CONTAINER -->
<!-- Start Footer -->
<div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div>
<!-- End Footer -->
</div>
<!-- End content -->
</body>
</html>

View file

@ -96,10 +96,6 @@ if ($last_ip == $ip) {
<!-- Start Statistics -->
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Post Handler
}
$query = "SELECT * FROM page_view";
$result = mysqli_query($con, $query);

View file

@ -1 +0,0 @@
deny from all

View file

@ -6,13 +6,14 @@ function tagsToHtml(array | Collection $tags) : string {
$output = "";
foreach ($tags as $tagObj) {
$tag = $tagObj->name;
if (stripos($tag, 'nsfw') !== false) {
$tag_lower = strtolower($tag);
if ($tag_lower === 'nsfw' || $tag_lower === 'explicit') {
$tag = strtoupper($tag);
$tagcolor = "tag is-danger";
} elseif (stripos($tag, 'SAFE') !== false) {
} elseif ($tag_lower === 'safe') {
$tag = strtoupper($tag);
$tagcolor = "tag is-success";
} elseif (str_contains($tag, '/')) {
} elseif ($tag[0] === '/' && $tag[-1] === '/') {
$tagcolor = "tag is-primary";
} else {
$tagcolor = "tag is-info";
@ -40,13 +41,14 @@ function tagsToHtmlUser(string | array | Collection $tags, $profile_username) :
}
foreach ($tagsSplit as $tag) {
if (stripos($tag, 'nsfw') !== false) {
$tag_lower = strtolower($tag);
if ($tag_lower === 'nsfw' || $tag_lower === 'explicit') {
$tag = strtoupper($tag);
$tagcolor = "tag is-danger";
} elseif (stripos($tag, 'SAFE') !== false) {
} elseif ($tag_lower === 'safe') {
$tag = strtoupper($tag);
$tagcolor = "tag is-success";
} elseif (str_contains($tag, '/')) {
} elseif ($tag[0] === '/' && $tag[-1] === '/') {
$tagcolor = "tag is-primary";
} else {
$tagcolor = "tag is-info";

View file

@ -6,7 +6,7 @@ class TagsInput {
this.tags = [];
this.options = options
this.maxTags = options.maxTags || 10;
this.maxTags = options.maxTags || 32;
this.inputNode = null;
this.containerNode = null;
}
@ -15,7 +15,7 @@ class TagsInput {
this.element.style.display = 'none';
this.containerNode = makeEl('<div class="tags-input"></div>');
this.inputNode = makeEl('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
this.inputNode = makeEl('<input class="input" type="text" placeholder="32 tags maximum" value="" />');
this.containerNode.appendChild(this.inputNode);
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);

View file

@ -1,14 +1,14 @@
import { escape } from "./dom";
const tagsToHtml = (tags) => {
return tags.map(tagData => {
let tagColorClass;
if (tagData.name.indexOf('nsfw') !== -1) {
const tagLower = tagData.name.toLowerCase();
if (tagLower === 'nsfw' || tagLower === 'explicit') {
tagColorClass = 'is-danger';
} else if (tagData.name.indexOf('safe') !== -1) {
} else if (tagLower === 'safe') {
tagColorClass = 'is-success';
} else if (tagData.name.indexOf('/') !== -1) {
} else if (tagLower.charAt(0) === '/' && tagLower.charAt(tagLower.length - 1) === '/') {
tagColorClass = 'is-primary';
} else {
tagColorClass = 'is-info';

View file

@ -11,5 +11,10 @@
"main": "index.js",
"repository": "git@github.com:aftercase/punishedponepaste.git",
"author": "AppleDash <pet@feather.horse>",
"license": "MIT"
"license": "MIT",
"dependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"zxcvbn": "^4.4.2"
}
}

View file

@ -289,14 +289,14 @@ const dumbFilterCallback = (datum, query) => {
};
const tagsToHtml = (tags) => {
return tags.map(tagData => {
let tagColorClass;
if (tagData.name.indexOf('nsfw') !== -1) {
const tagLower = tagData.name.toLowerCase();
if (tagLower === 'nsfw' || tagLower === 'explicit') {
tagColorClass = 'is-danger';
} else if (tagData.name.indexOf('safe') !== -1) {
} else if (tagLower === 'safe') {
tagColorClass = 'is-success';
} else if (tagData.name.indexOf('/') !== -1) {
} else if (tagLower.charAt(0) === '/' && tagLower.charAt(tagLower.length - 1) === '/') {
tagColorClass = 'is-primary';
} else {
tagColorClass = 'is-info';
@ -314,7 +314,7 @@ class TagsInput {
this.tags = [];
this.options = options;
this.maxTags = options.maxTags || 10;
this.maxTags = options.maxTags || 32;
this.inputNode = null;
this.containerNode = null;
}
@ -323,7 +323,7 @@ class TagsInput {
this.element.style.display = 'none';
this.containerNode = makeEl('<div class="tags-input"></div>');
this.inputNode = makeEl('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
this.inputNode = makeEl('<input class="input" type="text" placeholder="32 tags maximum" value="" />');
this.containerNode.appendChild(this.inputNode);
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -45,7 +45,7 @@ class TagsInput {
this.tags = [];
this.options = options;
this.maxTags = options.maxTags || 10;
this.maxTags = options.maxTags || 32;
this.inputNode = null;
this.containerNode = null;
}
@ -54,7 +54,7 @@ class TagsInput {
this.element.style.display = 'none';
this.containerNode = makeEl('<div class="tags-input"></div>');
this.inputNode = makeEl('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
this.inputNode = makeEl('<input class="input" type="text" placeholder="32 tags maximum" value="" />');
this.containerNode.appendChild(this.inputNode);
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -289,14 +289,14 @@ const dumbFilterCallback = (datum, query) => {
};
const tagsToHtml = (tags) => {
return tags.map(tagData => {
let tagColorClass;
if (tagData.name.indexOf('nsfw') !== -1) {
const tagLower = tagData.name.toLowerCase();
if (tagLower === 'nsfw' || tagLower === 'explicit') {
tagColorClass = 'is-danger';
} else if (tagData.name.indexOf('safe') !== -1) {
} else if (tagLower === 'safe') {
tagColorClass = 'is-success';
} else if (tagData.name.indexOf('/') !== -1) {
} else if (tagLower.charAt(0) === '/' && tagLower.charAt(tagLower.length - 1) === '/') {
tagColorClass = 'is-primary';
} else {
tagColorClass = 'is-info';
@ -314,7 +314,7 @@ class TagsInput {
this.tags = [];
this.options = options;
this.maxTags = options.maxTags || 10;
this.maxTags = options.maxTags || 32;
this.inputNode = null;
this.containerNode = null;
}
@ -323,7 +323,7 @@ class TagsInput {
this.element.style.display = 'none';
this.containerNode = makeEl('<div class="tags-input"></div>');
this.inputNode = makeEl('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
this.inputNode = makeEl('<input class="input" type="text" placeholder="32 tags maximum" value="" />');
this.containerNode.appendChild(this.inputNode);
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,6 @@
// noinspection JSUnusedGlobalSymbols,JSCheckFunctionSignatures
import { nodeResolve } from '@rollup/plugin-node-resolve';
import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import {terser} from 'rollup-plugin-terser';
@ -17,7 +18,8 @@ const output = (name) => {
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] }), terser()],
sourcemap: true
}
]
],
plugins: [nodeResolve()]
}
};

View file

@ -269,6 +269,7 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
<label class="label">Tags</label>
<div class="control">
<label class="label" for="field_tags">Tags</label>
<small>Type a comma to separate each tag.</small>
<div class="control">
<input name="tag_input" class="input js-tag-input" id="field_tags"
value="<?= pp_html_escape($paste->tags->map(function($t) { return $t->name; })->join(',')) ?>" />

1753
yarn.lock

File diff suppressed because it is too large Load diff