mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
More Eloquent conversions
This commit is contained in:
parent
c1ed98a5bd
commit
ab632347b6
20 changed files with 145 additions and 257 deletions
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
define('IN_PONEPASTE', 1);
|
||||
|
||||
require_once(__DIR__ . '/../includes/common.php');
|
||||
|
||||
use PonePaste\Models\Tag;
|
||||
|
||||
/* get rid of unintended wildcards in a parameter to LIKE queries; not a security issue, just unexpected behaviour. */
|
||||
function escapeLikeQuery(string $query) : string {
|
||||
return str_replace(['\\', '_', '%'], ['\\\\', '\\_', '\\%'], $query);
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
define('IN_PONEPASTE', 1);
|
||||
require_once('includes/common.php');
|
||||
|
||||
use PonePaste\Models\Paste;
|
||||
|
||||
|
||||
$date = date('jS F Y');
|
||||
|
||||
// Temp count for untagged pastes
|
||||
$total_untagged = intval($conn->query("SELECT COUNT(*) from pastes WHERE tagsys IS NULL")->fetch(PDO::FETCH_NUM)[0]);
|
||||
$total_untagged = Paste::doesntHave('tags')->count();
|
||||
|
||||
updatePageViews($conn);
|
||||
|
||||
|
|
8
includes/Models/IPBan.php
Normal file
8
includes/Models/IPBan.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
namespace PonePaste\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class IPBan extends Model {
|
||||
protected $table = 'ban_user';
|
||||
}
|
8
includes/Models/PageView.php
Normal file
8
includes/Models/PageView.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
namespace PonePaste\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PageView extends Model {
|
||||
protected $table = 'page_view';
|
||||
}
|
|
@ -3,7 +3,6 @@ namespace PonePaste\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Paste extends Model {
|
||||
public const VISIBILITY_PUBLIC = 0;
|
||||
|
|
|
@ -5,6 +5,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class User extends Model {
|
||||
protected $table = 'users';
|
||||
protected $fillable = [
|
||||
'username', 'password', 'recovery_code_hash', 'date'
|
||||
];
|
||||
|
||||
public function session() {
|
||||
return $this->hasOne(UserSession::class);
|
||||
|
|
|
@ -8,9 +8,9 @@ require_once(__DIR__ . '/functions.php');
|
|||
require_once(__DIR__ . '/DatabaseHandle.class.php');
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use PonePaste\Helpers\SessionHelper;
|
||||
use PonePaste\Models\IPBan;
|
||||
use PonePaste\Models\PageView;
|
||||
use PonePaste\Models\Paste;
|
||||
use PonePaste\Models\User;
|
||||
|
||||
|
@ -102,22 +102,6 @@ function getSiteInfo() : array {
|
|||
return require(__DIR__ . '/../config/site.php');
|
||||
}
|
||||
|
||||
function getSiteAds(DatabaseHandle $conn) : array|bool {
|
||||
return $conn->query('SELECT text_ads, ads_1, ads_2 FROM ads LIMIT 1')->fetch();
|
||||
}
|
||||
|
||||
function getSiteTotalPastes(DatabaseHandle $conn) : int {
|
||||
return intval($conn->query('SELECT COUNT(*) FROM pastes')->fetch(PDO::FETCH_NUM)[0]);
|
||||
}
|
||||
|
||||
function getSiteTotalviews(DatabaseHandle $conn) : int {
|
||||
return intval($conn->query('SELECT tpage FROM page_view ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_NUM)[0]);
|
||||
}
|
||||
|
||||
function getSiteTotal_unique_views(DatabaseHandle $conn) : int {
|
||||
return intval($conn->query('SELECT tvisit FROM page_view ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_NUM)[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialization of `htmlentities()` that avoids double escaping and uses UTF-8.
|
||||
*
|
||||
|
@ -186,11 +170,11 @@ $capsule->bootEloquent();
|
|||
$site_info = getSiteInfo();
|
||||
$global_site_info = $site_info['site_info'];
|
||||
$row = $site_info['site_info'];
|
||||
$title = Trim($row['title']);
|
||||
$baseurl = Trim($row['baseurl']);
|
||||
$site_name = Trim($row['site_name']);
|
||||
$email = Trim($row['email']);
|
||||
$additional_scripts = Trim($row['additional_scripts']);
|
||||
$title = trim($row['title']);
|
||||
$baseurl = trim($row['baseurl']);
|
||||
$site_name = trim($row['site_name']);
|
||||
$email = trim($row['email']);
|
||||
$additional_scripts = trim($row['additional_scripts']);
|
||||
|
||||
// Setup theme
|
||||
$default_theme = 'bulma';
|
||||
|
@ -212,14 +196,13 @@ $captcha_enabled = (bool) $captcha_config['enabled'];
|
|||
|
||||
// Check if IP is banned
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if ($conn->query('SELECT 1 FROM ban_user WHERE ip = ?', [$ip])->fetch()) {
|
||||
if (IPBan::where('ip', $ip)->first()) {
|
||||
die('You have been banned.');
|
||||
}
|
||||
|
||||
$site_ads = getSiteAds($conn);
|
||||
$total_pastes = getSiteTotalPastes($conn);
|
||||
$total_page_views = getSiteTotalviews($conn);
|
||||
$total_unique_views = getSiteTotal_unique_views($conn);
|
||||
$total_pastes = Paste::count();
|
||||
$total_page_views = PageView::select('tpage')->orderBy('id', 'desc')->first()->tpage;
|
||||
$total_unique_views = PageView::select('tvisit')->orderBy('id', 'desc')->first()->tvisit;
|
||||
|
||||
$current_user = SessionHelper::currentUser();
|
||||
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
function getPasteTags(DatabaseHandle $conn, int $paste_id) : array {
|
||||
return $conn->query(
|
||||
'SELECT name, slug FROM tags
|
||||
INNER JOIN paste_taggings ON paste_taggings.tag_id = tags.id
|
||||
WHERE paste_taggings.paste_id = ?',
|
||||
[$paste_id])->fetchAll();
|
||||
}
|
||||
|
||||
function getUserFavs(DatabaseHandle $conn, int $user_id) : array {
|
||||
$query = $conn->prepare(
|
||||
"SELECT pins.f_time, pastes.id, pins.paste_id, pastes.title, pastes.created_at, pastes.updated_at
|
||||
FROM pins
|
||||
INNER JOIN pastes ON pastes.id = pins.paste_id
|
||||
WHERE pins.user_id = ?");
|
||||
$query->execute([$user_id]);
|
||||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
function checkFavorite($user, $paste_id) : string {
|
||||
if ($user->favourites->where('paste_id', $paste_id)->first()) {
|
||||
return "<a href='#' id='favorite' class='icon tool-icon' data-fid='" . $paste_id . "'><i class='fas fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
||||
} else {
|
||||
return "<a href='#' id='favorite' class='icon tool-icon' data-fid='" . $paste_id . "'><i class='far fa-star fa-lg has-text-grey' title='Favourite'></i></a>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getreports($conn, $count = 10) {
|
||||
$query = $conn->prepare('SELECT * FROM user_reports LIMIT ?');
|
||||
$query->execute([$count]);
|
||||
|
@ -162,21 +134,6 @@ function getRecentadmin($conn, $count = 5) {
|
|||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
function getUserPastes(DatabaseHandle $conn, int $user_id) : array {
|
||||
return $conn->query(
|
||||
"SELECT id, title, visible, code, created_at, views FROM pastes
|
||||
WHERE user_id = ?
|
||||
ORDER by pastes.id DESC", [$user_id])->fetchAll();
|
||||
}
|
||||
|
||||
function getTotalPastes(DatabaseHandle $conn, int $user_id) : int {
|
||||
$query = $conn->prepare("SELECT COUNT(*) AS total_pastes
|
||||
FROM pastes INNER JOIN users ON users.id = pastes.user_id
|
||||
WHERE users.id = ?");
|
||||
$query->execute([$user_id]);
|
||||
|
||||
return intval($query->fetch(PDO::FETCH_NUM)[0]);
|
||||
}
|
||||
|
||||
function friendlyDateDifference(DateTime $lesser, DateTime $greater) : string {
|
||||
$delta = $greater->diff($lesser, true);
|
||||
|
|
69
login.php
69
login.php
|
@ -4,6 +4,10 @@ require_once('includes/common.php');
|
|||
require_once('includes/functions.php');
|
||||
require_once('includes/passwords.php');
|
||||
|
||||
use PonePaste\Helpers\SessionHelper;
|
||||
use PonePaste\Models\User;
|
||||
use PonePaste\Models\UserSession;
|
||||
|
||||
// Current Date & User IP
|
||||
$date = date('jS F Y');
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
@ -22,22 +26,24 @@ if (isset($_POST['forgot'])) {
|
|||
$username = trim($_POST['username']);
|
||||
$recovery_code = trim($_POST['recovery_code']);
|
||||
|
||||
$query = $conn->query("SELECT id, recovery_code_hash FROM users WHERE username = ?", [$username]);
|
||||
$row = $query->fetch();
|
||||
|
||||
if ($row && pp_password_verify($_POST['recovery_code'], $row['recovery_code_hash'])) {
|
||||
$user = User::select('id', 'recovery_code_hash')
|
||||
->where('username', $username);
|
||||
/* see justification below for error-suppression operator */
|
||||
if (pp_password_verify($_POST['recovery_code'], @$user->recovery_code_hash)) {
|
||||
$new_password = pp_random_password();
|
||||
$new_password_hash = pp_password_hash($new_password);
|
||||
|
||||
$recovery_code = pp_random_token();
|
||||
$new_recovery_code_hash = pp_password_hash($recovery_code);
|
||||
|
||||
$conn->prepare('UPDATE users SET password = ?, recovery_code_hash = ? WHERE id = ?')
|
||||
->execute([$new_password_hash, $new_recovery_code_hash, $row['id']]);
|
||||
$user->password = $new_password_hash;
|
||||
$user->recovery_code_hash = $new_recovery_code_hash;
|
||||
|
||||
$user->save();
|
||||
|
||||
$success = 'Your password has been changed. A new recovery code has also been generated. Please note the recovery code and then sign in with the new password.';
|
||||
} else {
|
||||
$error = 'Incorrect username or password.';
|
||||
$error = 'Incorrect username or recovery code.';
|
||||
}
|
||||
} else {
|
||||
$error = 'All fields must be filled out.';
|
||||
|
@ -46,38 +52,40 @@ if (isset($_POST['forgot'])) {
|
|||
if (!empty($_POST['username']) && !empty($_POST['password'])) {
|
||||
$remember_me = (bool) $_POST['remember_me'];
|
||||
$username = trim($_POST['username']);
|
||||
$row = $conn->query("SELECT id, password, banned FROM users WHERE username = ?", [$username])
|
||||
->fetch();
|
||||
$user = User::select('id', 'password', 'banned')
|
||||
->where('username', $username)
|
||||
->first();
|
||||
|
||||
$needs_rehash = false;
|
||||
|
||||
/* This is designed to be a constant time lookup, hence the warning suppression operator so that
|
||||
* we always call pp_password_verify, even if row is null.
|
||||
* we always call pp_password_verify, even if the user is null.
|
||||
*/
|
||||
if (pp_password_verify($_POST['password'], @$row['password'], $needs_rehash)) {
|
||||
$user_id = $row['id'];
|
||||
|
||||
if (pp_password_verify($_POST['password'], @$user->password, $needs_rehash)) {
|
||||
if ($needs_rehash) {
|
||||
$new_password_hash = pp_password_hash($_POST['password']);
|
||||
|
||||
$conn->query('UPDATE users SET password = ? WHERE id = ?',
|
||||
[$new_password_hash, $user_id]);
|
||||
$user->password = pp_password_hash($_POST['password']);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
if ($row['banned']) {
|
||||
if ($user->banned) {
|
||||
// User is banned
|
||||
$error = 'You are banned.';
|
||||
} else {
|
||||
// Login successful
|
||||
$_SESSION['user_id'] = (string) $user_id;
|
||||
$_SESSION['user_id'] = (string) $user->id;
|
||||
|
||||
if ($remember_me) {
|
||||
$remember_token = pp_random_token();
|
||||
$expire_at = (new DateTime())->add(new DateInterval('P1Y'));
|
||||
|
||||
$conn->query('INSERT INTO user_sessions (user_id, token, expire_at) VALUES (?, ?, FROM_UNIXTIME(?))', [$user_id, $remember_token, $expire_at->format('U')]);
|
||||
$session = new UserSession([
|
||||
'user_id' => $user->id,
|
||||
'token' => $remember_token,
|
||||
'expire_at' => $expire_at
|
||||
]);
|
||||
$session->save();
|
||||
|
||||
setcookie(User::REMEMBER_TOKEN_COOKIE, $remember_token, [
|
||||
setcookie(SessionHelper::REMEMBER_TOKEN_COOKIE, $remember_token, [
|
||||
'expires' => (int) $expire_at->format('U'),
|
||||
'secure' => !empty($_SERVER['HTTPS']), /* Local dev environment is non-HTTPS */
|
||||
'httponly' => true,
|
||||
|
@ -96,7 +104,7 @@ if (isset($_POST['forgot'])) {
|
|||
$error = 'All fields must be filled out.';
|
||||
}
|
||||
} elseif (isset($_POST['signup'])) { // Registration process
|
||||
$username = htmlentities(trim($_POST['username'], ENT_QUOTES));
|
||||
$username = trim($_POST['username']);
|
||||
$password = pp_password_hash($_POST['password']);
|
||||
|
||||
if (empty($_POST['password']) || empty($_POST['username'])) {
|
||||
|
@ -106,15 +114,20 @@ if (isset($_POST['forgot'])) {
|
|||
} elseif (preg_match('/[^A-Za-z0-9._\\-$]/', $username)) {
|
||||
$error = 'Username is invalid - please use A-Za-z0-9, periods, hyphens, and underscores only.';
|
||||
} else {
|
||||
if ($conn->querySelectOne('SELECT 1 FROM users WHERE username = ?', [$username])) {
|
||||
if (User::where('username', $username)->first()) {
|
||||
$error = 'That username has already been taken.';
|
||||
} else {
|
||||
/* this is displayed to the user in the template, hence the variable rather than inlining */
|
||||
$recovery_code = pp_random_token();
|
||||
$recovery_code_hash = pp_password_hash($recovery_code);
|
||||
$conn->query(
|
||||
"INSERT INTO users (username, password, recovery_code_hash, picture, date, ip, badge) VALUES (?, ?, ?, 'NONE', ?, ?, '0')",
|
||||
[$username, $password, $recovery_code_hash, $date, $ip]
|
||||
);
|
||||
|
||||
$user = new User([
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'recovery_code_hash' => pp_password_hash($recovery_code),
|
||||
'date' => $date,
|
||||
'ip' => $ip
|
||||
]);
|
||||
$user->save();
|
||||
|
||||
$success = 'Your account was successfully registered.';
|
||||
}
|
||||
|
|
19
paste.php
19
paste.php
|
@ -21,7 +21,7 @@ $paste_id = intval(trim($_REQUEST['id']));
|
|||
updatePageViews($conn);
|
||||
|
||||
// This is used in the theme files.
|
||||
$totalpastes = getSiteTotalPastes($conn);
|
||||
$totalpastes = Paste::count();
|
||||
|
||||
// Get paste favorite count
|
||||
$fav_count = $conn->querySelectOne('SELECT COUNT(*) FROM user_favourites WHERE paste_id = ?', [$paste_id], PDO::FETCH_NUM)[0];
|
||||
|
@ -46,8 +46,6 @@ if (!$paste) {
|
|||
goto Not_Valid_Paste;
|
||||
}
|
||||
|
||||
//var_dump($paste);
|
||||
|
||||
$paste_owner_id = $paste->user->id;
|
||||
$paste_title = $paste->title;
|
||||
$paste_code = $paste->code;
|
||||
|
@ -69,6 +67,7 @@ $p_visible = $paste->visible;
|
|||
$p_expiry = $paste->expiry;
|
||||
$p_password = $paste->password;
|
||||
$p_encrypt = (bool) $paste->encrypt;
|
||||
$paste_is_favourited = $current_user !== null && $current_user->favourites->where('paste_id', $paste->id)->count() === 1;
|
||||
|
||||
|
||||
$is_private = $p_visible === '2';
|
||||
|
@ -110,6 +109,15 @@ if (!empty($p_expiry) && $p_expiry !== 'SELF') {
|
|||
}
|
||||
}
|
||||
|
||||
/* handle favouriting */
|
||||
if (isset($_POST['fave'])) {
|
||||
if ($paste_is_favourited) {
|
||||
$current_user->favourites()->detach($paste->id);
|
||||
} else {
|
||||
$current_user->favourites()->attach($paste->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($p_encrypt == 1) {
|
||||
$p_content = openssl_decrypt($p_content, PP_ENCRYPTION_ALGO, PP_ENCRYPTION_KEY);
|
||||
}
|
||||
|
@ -133,7 +141,7 @@ if (isset($_POST['delete'])) {
|
|||
if (!$current_user || ($paste_owner_id !== $current_user->user_id)) {
|
||||
flashError('You must be logged in and own this paste to delete it.');
|
||||
} else {
|
||||
$conn->query('DELETE FROM pastes WHERE id = ?', [$paste_id]);
|
||||
$paste->delete();
|
||||
flashSuccess('Paste deleted.');
|
||||
header('Location: ' . urlForMember($current_user->username));
|
||||
die();
|
||||
|
@ -195,7 +203,8 @@ if ($password_required && $password_valid) {
|
|||
// View counter
|
||||
if (@$_SESSION['not_unique'] !== $paste_id) {
|
||||
$_SESSION['not_unique'] = $paste_id;
|
||||
$conn->query("UPDATE pastes SET views = (views + 1) where id = ?", [$paste_id]);
|
||||
$paste->views += 1;
|
||||
$paste->save();
|
||||
}
|
||||
|
||||
$page_template = 'view';
|
||||
|
|
15
profile.php
15
profile.php
|
@ -4,6 +4,8 @@ require_once('includes/common.php');
|
|||
require_once('includes/functions.php');
|
||||
require_once('includes/passwords.php');
|
||||
|
||||
use PonePaste\Models\Paste;
|
||||
|
||||
// Check if already logged in
|
||||
if ($current_user === null) {
|
||||
header("Location: ./login.php");
|
||||
|
@ -11,14 +13,11 @@ if ($current_user === null) {
|
|||
}
|
||||
|
||||
$user_username = $current_user->username;
|
||||
|
||||
$query = $conn->query('SELECT * FROM users WHERE id = ?', [$current_user->user_id]);
|
||||
$row = $query->fetch();
|
||||
$user_id = $row['id'];
|
||||
$user_platform = Trim($row['platform']);
|
||||
$user_date = $row['date'];
|
||||
$user_ip = $row['ip'];
|
||||
$user_password = $row['password'];
|
||||
$user_id = $current_user->id;
|
||||
$user_date = $current_user->date;
|
||||
$user_ip = $current_user->ip;
|
||||
$user_password = $current_user->password;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if (isset($_POST['cpassword'])) {
|
||||
|
@ -41,7 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
|
||||
updatePageViews($conn);
|
||||
|
||||
$total_user_pastes = getTotalPastes($conn, $current_user->user_id);
|
||||
$total_user_pastes = Paste::where('user_id', $current_user->user_id)->count();
|
||||
|
||||
// Theme
|
||||
$page_template = 'profile';
|
||||
|
|
|
@ -69,13 +69,6 @@
|
|||
</table>
|
||||
|
||||
<div class="paginator"></div>
|
||||
|
||||
|
||||
<?php
|
||||
if (isset($site_ads)) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -161,14 +161,25 @@ input:checked + .slider:before {
|
|||
}
|
||||
}
|
||||
|
||||
img [alt="www.000webhost.com"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.td-center {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.green .hljs-comment {
|
||||
color: #789922;
|
||||
}
|
||||
|
||||
button.button--no-style {
|
||||
background: none;
|
||||
color: inherit;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
outline: inherit;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.form--inline {
|
||||
display: inline;
|
||||
}
|
|
@ -68,11 +68,11 @@
|
|||
<div class="media">
|
||||
<div class="media-content" style="overflow: hidden">
|
||||
<p class="title is-5">
|
||||
<a href="<?= urlForPaste($paste['id']) ?>"
|
||||
title="<?= $paste['title'] ?>"> <?= $paste['title'] ?> </a>
|
||||
<a href="<?= urlForPaste($paste) ?>"
|
||||
title="<?= pp_html_escape($paste->title) ?>"> <?= pp_html_escape($paste->title) ?> </a>
|
||||
</p>
|
||||
<p class="subtitle is-6">
|
||||
<a href="<?= urlForMember($paste['member']) ?>"><?= $paste['member'] ?></a>
|
||||
<a href="<?= urlForMember($paste->user) ?>"><?= pp_html_escape($paste->user->username) ?></a>
|
||||
<br>
|
||||
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_time'] ?></time>
|
||||
</p>
|
||||
|
@ -107,11 +107,11 @@
|
|||
<div class="media">
|
||||
<div class="media-content" style="overflow: hidden">
|
||||
<p class="title is-5">
|
||||
<a href="<?= urlForPaste($paste['id']) ?>"
|
||||
title="<?= $paste['title'] ?>"> <?= $paste['title'] ?> </a>
|
||||
<a href="<?= urlForPaste($paste) ?>"
|
||||
title="<?= pp_html_escape($paste->title) ?>"> <?= pp_html_escape($paste->title) ?> </a>
|
||||
</p>
|
||||
<p class="subtitle is-6">
|
||||
<a href="<?= urlForMember($paste['member']) ?>"><?= $paste['member'] ?></a>
|
||||
<a href="<?= urlForMember($paste->user) ?>"><?= pp_html_escape($paste->user->username) ?></a>
|
||||
<br>
|
||||
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_time'] ?></time>
|
||||
</p>
|
||||
|
@ -146,11 +146,11 @@
|
|||
<div class="media">
|
||||
<div class="media-content" style="overflow: hidden">
|
||||
<p class="title is-5">
|
||||
<a href="<?= urlForPaste($paste['id']) ?>"
|
||||
title="<?= $paste['title'] ?>"> <?= $paste['title'] ?> </a>
|
||||
<a href="<?= urlForPaste($paste) ?>"
|
||||
title="<?= pp_html_escape($paste->title) ?>"> <?= pp_html_escape($paste->title) ?> </a>
|
||||
</p>
|
||||
<p class="subtitle is-6">
|
||||
<a href="<?= urlForMember($paste['member']) ?>"><?= $paste['member'] ?></a>
|
||||
<a href="<?= urlForMember($paste->user) ?>"><?= pp_html_escape($paste->user->username) ?></a>
|
||||
<br>
|
||||
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_update_time'] ?></time>
|
||||
</p>
|
||||
|
@ -185,11 +185,11 @@
|
|||
<div class="media">
|
||||
<div class="media-content" style="overflow: hidden">
|
||||
<p class="title is-5">
|
||||
<a href="<?= urlForPaste($paste['id']) ?>"
|
||||
title="<?= $paste['title'] ?>"> <?= $paste['title'] ?> </a>
|
||||
<a href="<?= urlForPaste($paste) ?>"
|
||||
title="<?= pp_html_escape($paste->title) ?>"> <?= pp_html_escape($paste->title) ?> </a>
|
||||
</p>
|
||||
<p class="subtitle is-6">
|
||||
<a href="<?= urlForMember($paste['member']) ?>"><?= $paste['member'] ?></a>
|
||||
<a href="<?= urlForMember($paste->user) ?>"><?= pp_html_escape($paste->user->username) ?></a>
|
||||
<br>
|
||||
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_time'] ?></time>
|
||||
</p>
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
<!-- Submitted Pastes -->
|
||||
<div class="col-md-9 col-lg-10">
|
||||
<div class="panel panel-default">
|
||||
<h1 class="title is-4">Submited Entries
|
||||
<h1 class="title is-4">Submitted Entries
|
||||
<h1>
|
||||
<div class="panel-body">
|
||||
<div class="list-widget pagination-content">
|
||||
|
@ -164,18 +164,7 @@
|
|||
'</header>';
|
||||
?>
|
||||
|
||||
<?php }
|
||||
// Display a message if the pastebin is empty
|
||||
$query = "SELECT count(*) as count FROM pastes";
|
||||
$result = mysqli_query($con, $query);
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
$totalpastes = $row['count'];
|
||||
}
|
||||
|
||||
if ($totalpastes == '0') {
|
||||
echo "None submitted";
|
||||
} ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="notification is-warning">
|
||||
|
@ -201,10 +190,4 @@
|
|||
|
||||
|
||||
<!-- End Panel -->
|
||||
<?php }
|
||||
if (!$site_is_private) {
|
||||
return;
|
||||
} elseif (isset($site_ads)) {
|
||||
echo $site_ads['ads_2'];
|
||||
}// Remove sidebar if site is private
|
||||
?>
|
||||
<?php } ?>
|
||||
|
|
|
@ -64,11 +64,6 @@
|
|||
<div class="column">
|
||||
</div>
|
||||
<div class="column">
|
||||
<?php
|
||||
if (isset($site_ads) && $current_user === null) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -121,11 +116,6 @@
|
|||
<div class="column">
|
||||
</div>
|
||||
<div class="column">
|
||||
<?php
|
||||
if (isset($site_ads) && $current_user === null) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
|
@ -169,11 +159,6 @@
|
|||
<div class="column">
|
||||
</div>
|
||||
<div class="column">
|
||||
<?php
|
||||
if (isset($site_ads) && $current_user === null) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -188,11 +173,6 @@
|
|||
<div class="column">
|
||||
</div>
|
||||
<div class="column">
|
||||
<?php
|
||||
if (isset($site_ads) && $current_user === null) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
|
@ -302,13 +302,6 @@
|
|||
</nav>
|
||||
</div>
|
||||
<div class="column is-3">
|
||||
<!-- $text_ads -->
|
||||
<?php
|
||||
// don't display ads for logged in users.
|
||||
if (!empty($site_ads) && $current_user === null) {
|
||||
echo $site_ads['text_ads'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="column is-4">
|
||||
<!-- CAPTCHA -->
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
} else {
|
||||
echo '<p class="help is-danger subtitle is-6">Not Found</p>';
|
||||
}
|
||||
|
||||
if (isset($site_ads)) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -209,16 +209,22 @@
|
|||
<?php foreach ($profile_favs as $paste): ?>
|
||||
<?php
|
||||
$escaped_title = pp_html_escape(truncate($paste->title, 20, 50));
|
||||
$p_date = new DateTime($paste->created_at);
|
||||
$f_date = new DateTime($paste->pivot->f_time);
|
||||
$update_date = new DateTime($paste->updated_at);
|
||||
$delta = $update_date->diff(new DateTime(), true);
|
||||
?>
|
||||
<?php if ($is_current_user || $row['visible'] == Paste::VISIBILITY_PUBLIC): ?>
|
||||
<tr>
|
||||
<td><a href="<?= urlForPaste($paste) ?>" title="<?= $escaped_title ?>"><?= $escaped_title ?></a></td>
|
||||
<td data-sort="<?= $p_date->format('U') ?>" class="td-center"><?= $p_date->format('d F Y') ?></td>
|
||||
<td class="td-center"><?= $p_visible; ?></td>
|
||||
<td class="td-center"><?= $paste->views ?></td>
|
||||
<td class="td-center">
|
||||
<?php if ($delta->days <= 2): ?>
|
||||
<i class='far fa-check-square fa-lg' aria-hidden='true'></i>
|
||||
<?php else: ?>
|
||||
<i class='far fa-minus-square fa-lg' aria-hidden='true'></i>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="td-left"><?= tagsToHtmlUser($paste->tags, $profile_username); ?></td>
|
||||
<!-- Delete button here? -->
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
@ -231,62 +237,9 @@
|
|||
<td class="td-center">Tags</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($profile_favs as $row) {
|
||||
$ftitle = Trim($row['title']);
|
||||
$f_id = Trim($row['paste_id']);
|
||||
$f_date = new DateTime($row['f_time']);
|
||||
$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));
|
||||
$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";
|
||||
$title = truncate($title, 20, 50);
|
||||
$current_time = time();
|
||||
$past = strtotime('-2 day', $current_time);
|
||||
if ($past <= $Recent_update_u && $Recent_update_u <= $current_time) {
|
||||
$updatenote = "<i class='far fa-check-square fa-lg' aria-hidden='true'></i>";
|
||||
} else {
|
||||
$updatenote = "<i class='far fa-minus-square fa-lg' aria-hidden='true'></i>";
|
||||
}
|
||||
|
||||
echo '<tr>
|
||||
<td>
|
||||
<a href="' . $protocol . $baseurl . '/' . $f_id . '" title="' . $ftitle . '">' . ($ftitle) . '</a>
|
||||
</td>
|
||||
<td data-sort="' . date_format($f_date, 'U') . '" class="td-center">
|
||||
<span>' . $f_dateui . '</span>
|
||||
</td>
|
||||
<td data-sort="' . $Recent_update_u . '" class="td-center">
|
||||
<span>' . $updatenote . '</span>
|
||||
|
||||
</td>
|
||||
<td class="td-left">';
|
||||
if (strlen($f_tags) > 0) {
|
||||
echo tagsToHtmlUser($f_tags,$profile_username);
|
||||
} else {
|
||||
echo ' <span class="tag is-warning">No tags</span>';
|
||||
}
|
||||
|
||||
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($site_ads)) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -175,11 +175,12 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
|
|||
<div class="column is-4 has-text-right">
|
||||
<div class="">
|
||||
<div class="panel-tools">
|
||||
<?php
|
||||
if ($current_user !== null) {
|
||||
echo checkFavorite($current_user, $paste->id);
|
||||
}
|
||||
?>
|
||||
<?php if ($current_user !== null): ?>
|
||||
<form action="" method="POST" class="form--inline">
|
||||
<input type="hidden" name="fave" value="1" />
|
||||
<button type="submit" class="icon tool-icon button--no-style"><i class="fas fa-star fa-lg <?= $paste_is_favourited ? '' : 'has-text-grey' ?>" title="Favourite"></i></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<a class="icon tool-icon flip" onclick="openreport()"><i
|
||||
class="far fa-flag fa-lg has-text-grey" title="Report Paste"></i></a>
|
||||
<?php if ($paste['code'] != "pastedown") { ?>
|
||||
|
@ -442,11 +443,6 @@ $selectedloader = "$bg[$i]"; // set variable equal to which random filename was
|
|||
</div>
|
||||
<br/>
|
||||
</nav>
|
||||
<?php
|
||||
if (isset($site_ads)) {
|
||||
echo $site_ads['ads_2'];
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue