2021-07-10 19:18:17 +01:00
|
|
|
<?php
|
2022-07-30 17:55:17 -04:00
|
|
|
/** @noinspection PhpDefineCanBeReplacedWithConstInspection */
|
|
|
|
define('IN_PONEPASTE', 1);
|
|
|
|
require_once(__DIR__ . '/../includes/common.php');
|
2021-07-10 19:18:17 +01:00
|
|
|
|
2021-11-01 16:56:17 -04:00
|
|
|
use PonePaste\Models\Paste;
|
|
|
|
|
2022-08-25 01:51:54 -04:00
|
|
|
$per_page = 20;
|
|
|
|
$current_page = 0;
|
|
|
|
$filter_value = '';
|
|
|
|
|
|
|
|
if (!empty($_GET['page'])) {
|
|
|
|
$current_page = max(0, intval($_GET['page']));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_GET['per_page'])) {
|
|
|
|
$per_page = max(1, min(100, intval($_GET['per_page'])));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_GET['q'])) {
|
|
|
|
$filter_value = $_GET['q'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$pastes = Paste::with([
|
|
|
|
'user' => function($q) {
|
|
|
|
$q->select('users.id', 'username');
|
|
|
|
},
|
|
|
|
'tags' => function($q) {
|
|
|
|
$q->select('tags.id', 'name', 'slug');
|
|
|
|
}])
|
|
|
|
->select('id', 'user_id', 'title', 'created_at')
|
|
|
|
->where('visible', Paste::VISIBILITY_PUBLIC)
|
|
|
|
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($filter_value)) {
|
|
|
|
$pastes = $pastes->where('title', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%');
|
|
|
|
}
|
|
|
|
|
|
|
|
$total_results = $pastes->count();
|
|
|
|
|
|
|
|
$pastes = $pastes->limit($per_page)->offset($per_page * $current_page);
|
|
|
|
|
|
|
|
$pastes = $pastes->get();
|
2021-11-01 16:56:17 -04:00
|
|
|
|
2021-07-10 17:36:15 -04:00
|
|
|
// Temp count for untagged pastes
|
2021-11-01 16:56:17 -04:00
|
|
|
$total_untagged = Paste::doesntHave('tags')->count();
|
2021-07-10 19:18:17 +01:00
|
|
|
|
2022-03-12 13:56:32 -05:00
|
|
|
updatePageViews();
|
2021-07-10 17:36:15 -04:00
|
|
|
|
2021-08-22 21:45:26 -04:00
|
|
|
$page_template = 'archive';
|
2021-08-26 05:35:21 -04:00
|
|
|
$page_title = 'Pastes Archive';
|
2022-03-26 23:57:28 -04:00
|
|
|
$script_bundles[] = 'archive';
|
2022-07-30 17:55:17 -04:00
|
|
|
|
|
|
|
require_once(__DIR__ . '/../theme/' . $default_theme . '/common.php');
|