mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 14:40:09 +01:00
Some code
This commit is contained in:
parent
82c956d9e1
commit
7ef5f25137
27 changed files with 314 additions and 163 deletions
4
admin/js/jquery.dataTables.js
vendored
4
admin/js/jquery.dataTables.js
vendored
|
@ -8389,8 +8389,8 @@
|
||||||
DataTable.settings = [];
|
DataTable.settings = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object models container, for the various models that DataTables has
|
* Object Models container, for the various Models that DataTables has
|
||||||
* available to it. These models define the objects that are used to hold
|
* available to it. These Models define the objects that are used to hold
|
||||||
* the active state and configuration of the table.
|
* the active state and configuration of the table.
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,5 +19,10 @@
|
||||||
"scrivo/highlight.php": "v9.18.1.7",
|
"scrivo/highlight.php": "v9.18.1.7",
|
||||||
"erusev/parsedown": "^1.7",
|
"erusev/parsedown": "^1.7",
|
||||||
"illuminate/database": "^8.56"
|
"illuminate/database": "^8.56"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PonePaste\\": "includes/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
composer.lock
generated
44
composer.lock
generated
|
@ -153,16 +153,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/collections",
|
"name": "illuminate/collections",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/collections.git",
|
"url": "https://github.com/illuminate/collections.git",
|
||||||
"reference": "dd68b267ada1893126d53792b6c57b19e95a9d04"
|
"reference": "673d71d9db2827b04c096c4fe9739edddea14ac4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/collections/zipball/dd68b267ada1893126d53792b6c57b19e95a9d04",
|
"url": "https://api.github.com/repos/illuminate/collections/zipball/673d71d9db2827b04c096c4fe9739edddea14ac4",
|
||||||
"reference": "dd68b267ada1893126d53792b6c57b19e95a9d04",
|
"reference": "673d71d9db2827b04c096c4fe9739edddea14ac4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -203,11 +203,11 @@
|
||||||
"issues": "https://github.com/laravel/framework/issues",
|
"issues": "https://github.com/laravel/framework/issues",
|
||||||
"source": "https://github.com/laravel/framework"
|
"source": "https://github.com/laravel/framework"
|
||||||
},
|
},
|
||||||
"time": "2021-08-23T08:57:48+00:00"
|
"time": "2021-08-25T13:02:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/container",
|
"name": "illuminate/container",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/container.git",
|
"url": "https://github.com/illuminate/container.git",
|
||||||
|
@ -258,16 +258,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/contracts",
|
"name": "illuminate/contracts",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/contracts.git",
|
"url": "https://github.com/illuminate/contracts.git",
|
||||||
"reference": "e4fa45682e8b558ccca02829e8e6e521ff9458d2"
|
"reference": "7354badf7b57eae805a56d1163fb023e0f58a639"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/e4fa45682e8b558ccca02829e8e6e521ff9458d2",
|
"url": "https://api.github.com/repos/illuminate/contracts/zipball/7354badf7b57eae805a56d1163fb023e0f58a639",
|
||||||
"reference": "e4fa45682e8b558ccca02829e8e6e521ff9458d2",
|
"reference": "7354badf7b57eae805a56d1163fb023e0f58a639",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -302,20 +302,20 @@
|
||||||
"issues": "https://github.com/laravel/framework/issues",
|
"issues": "https://github.com/laravel/framework/issues",
|
||||||
"source": "https://github.com/laravel/framework"
|
"source": "https://github.com/laravel/framework"
|
||||||
},
|
},
|
||||||
"time": "2021-08-19T13:06:39+00:00"
|
"time": "2021-08-24T21:29:28+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/database",
|
"name": "illuminate/database",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/database.git",
|
"url": "https://github.com/illuminate/database.git",
|
||||||
"reference": "18c2660dd2d5398263907d5717f0a611b901a05a"
|
"reference": "828d1cd4ee824c405f6edc52ab3d333b549be4ee"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/database/zipball/18c2660dd2d5398263907d5717f0a611b901a05a",
|
"url": "https://api.github.com/repos/illuminate/database/zipball/828d1cd4ee824c405f6edc52ab3d333b549be4ee",
|
||||||
"reference": "18c2660dd2d5398263907d5717f0a611b901a05a",
|
"reference": "828d1cd4ee824c405f6edc52ab3d333b549be4ee",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -370,11 +370,11 @@
|
||||||
"issues": "https://github.com/laravel/framework/issues",
|
"issues": "https://github.com/laravel/framework/issues",
|
||||||
"source": "https://github.com/laravel/framework"
|
"source": "https://github.com/laravel/framework"
|
||||||
},
|
},
|
||||||
"time": "2021-08-19T19:38:53+00:00"
|
"time": "2021-08-26T14:48:34+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/macroable",
|
"name": "illuminate/macroable",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/macroable.git",
|
"url": "https://github.com/illuminate/macroable.git",
|
||||||
|
@ -420,16 +420,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/support",
|
"name": "illuminate/support",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/support.git",
|
"url": "https://github.com/illuminate/support.git",
|
||||||
"reference": "586f77ee7f8568ecc60866f171074dccfbe69db5"
|
"reference": "5e8f059a5d1f298324e847822b997778a3472128"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/support/zipball/586f77ee7f8568ecc60866f171074dccfbe69db5",
|
"url": "https://api.github.com/repos/illuminate/support/zipball/5e8f059a5d1f298324e847822b997778a3472128",
|
||||||
"reference": "586f77ee7f8568ecc60866f171074dccfbe69db5",
|
"reference": "5e8f059a5d1f298324e847822b997778a3472128",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -484,7 +484,7 @@
|
||||||
"issues": "https://github.com/laravel/framework/issues",
|
"issues": "https://github.com/laravel/framework/issues",
|
||||||
"source": "https://github.com/laravel/framework"
|
"source": "https://github.com/laravel/framework"
|
||||||
},
|
},
|
||||||
"time": "2021-08-22T17:54:36+00:00"
|
"time": "2021-08-25T13:04:37+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nesbot/carbon",
|
"name": "nesbot/carbon",
|
||||||
|
|
12
discover.php
12
discover.php
|
@ -3,6 +3,8 @@ define('IN_PONEPASTE', 1);
|
||||||
require_once('includes/common.php');
|
require_once('includes/common.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
|
|
||||||
|
use PonePaste\Models\Paste;
|
||||||
|
|
||||||
function transformPasteRow(Paste $row) : array {
|
function transformPasteRow(Paste $row) : array {
|
||||||
return [
|
return [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
|
@ -16,11 +18,11 @@ function transformPasteRow(Paste $row) : array {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$popular_pastes = Paste::getMostViewed()->map('transformPasteRow');
|
$popular_pastes = Paste::getMostViewed();//->map('transformPasteRow');
|
||||||
$monthly_popular_pastes = Paste::getMonthPopular()->map('transformPasteRow');
|
$monthly_popular_pastes = Paste::getMonthPopular();//->map('transformPasteRow');
|
||||||
$recent_pastes = Paste::getRecent()->map('transformPasteRow');
|
$recent_pastes = Paste::getRecent();//->map('transformPasteRow');
|
||||||
$updated_pastes = Paste::getRecentlyUpdated()->map('transformPasteRow');
|
$updated_pastes = Paste::getRecentlyUpdated();//->map('transformPasteRow');
|
||||||
$random_pastes = Paste::getRandom()->map('transformPasteRow');
|
$random_pastes = Paste::getRandom();//->map('transformPasteRow');
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
$page_template = 'discover';
|
$page_template = 'discover';
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
namespace PonePaste\Helpers;
|
namespace PonePaste\Helpers;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use PonePaste\Models\User;
|
||||||
require_once(__DIR__ . '/models/UserSession.php');
|
use PonePaste\Models\UserSession;
|
||||||
|
|
||||||
class SessionHelper {
|
class SessionHelper {
|
||||||
public const REMEMBER_TOKEN_COOKIE = '_ponepaste_token';
|
public const REMEMBER_TOKEN_COOKIE = '_ponepaste_token';
|
||||||
|
@ -27,14 +27,14 @@ class SessionHelper {
|
||||||
public static function destroySession() {
|
public static function destroySession() {
|
||||||
$token = $_COOKIE[SessionHelper::REMEMBER_TOKEN_COOKIE];
|
$token = $_COOKIE[SessionHelper::REMEMBER_TOKEN_COOKIE];
|
||||||
|
|
||||||
\UserSession::where('token', $token)->delete();
|
UserSession::where('token', $token)->delete();
|
||||||
|
|
||||||
unset($_COOKIE[SessionHelper::REMEMBER_TOKEN_COOKIE]);
|
unset($_COOKIE[SessionHelper::REMEMBER_TOKEN_COOKIE]);
|
||||||
setcookie(SessionHelper::REMEMBER_TOKEN_COOKIE, null, time() - 3600);
|
setcookie(SessionHelper::REMEMBER_TOKEN_COOKIE, null, time() - 3600);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function currentUserFromRememberToken(string $remember_token) {
|
private static function currentUserFromRememberToken(string $remember_token) {
|
||||||
$session = \UserSession
|
$session = UserSession
|
||||||
::with('user')
|
::with('user')
|
||||||
->where('token', $remember_token)
|
->where('token', $remember_token)
|
||||||
->first();
|
->first();
|
||||||
|
@ -61,6 +61,6 @@ class SessionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return \User::find(intval($_SESSION['user_id']));
|
return User::find(intval($_SESSION['user_id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace PonePaste\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Watson\Validating\ValidatingTrait;
|
||||||
require_once(__DIR__ . '/Tag.php');
|
|
||||||
|
|
||||||
class Paste extends Model {
|
class Paste extends Model {
|
||||||
protected $table = 'pastes';
|
protected $table = 'pastes';
|
||||||
|
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
public function user() {
|
public function user() {
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +18,19 @@ class Paste extends Model {
|
||||||
return $this->belongsToMany(Tag::class, 'paste_taggings');
|
return $this->belongsToMany(Tag::class, 'paste_taggings');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function replaceTags(array $tags) {
|
||||||
|
$this->tags()->detach();
|
||||||
|
|
||||||
|
foreach ($tags as $tagName) {
|
||||||
|
$tag = Tag::getOrCreateByName($tagName);
|
||||||
|
$this->tags()->attach($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: We need to get rid of tagsys.
|
||||||
|
$this->tagsys = implode(',', $tags);
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
public static function getRecent(int $count = 10) : Collection {
|
public static function getRecent(int $count = 10) : Collection {
|
||||||
return Paste::with('user')
|
return Paste::with('user')
|
||||||
->orderBy('created_at', 'DESC')
|
->orderBy('created_at', 'DESC')
|
|
@ -1,34 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace PonePaste\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Tag extends Model {
|
class Tag extends Model {
|
||||||
protected $table = 'tags';
|
protected $table = 'tags';
|
||||||
|
|
||||||
public static function getOrCreateByName(DatabaseHandle $conn, string $name) : Tag {
|
public static function getOrCreateByName(string $name) : Tag {
|
||||||
$name = Tag::cleanTagName($name);
|
$name = Tag::cleanTagName($name);
|
||||||
|
|
||||||
if ($row = $conn->querySelectOne('SELECT id, name, slug FROM tags WHERE name = ?', [$name])) {
|
if ($tag = Tag::where('name', $name)->first()) {
|
||||||
return new Tag($row);
|
return $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_slug = Tag::encodeSlug($name);
|
return Tag::create([
|
||||||
$new_tag_id = $conn->queryInsert('INSERT INTO tags (name, slug) VALUES (?, ?)', [$name, $new_slug]);
|
|
||||||
|
|
||||||
return new Tag([
|
|
||||||
'id' => $new_tag_id,
|
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'slug' => $new_slug
|
'slug' => Tag::encodeSlug($name)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function findBySlug(DatabaseHandle $conn, string $slug) : Tag|null {
|
|
||||||
if ($row = $conn->querySelectOne('SELECT id, name, slug FROM tags WHERE slug = ?', [$slug])) {
|
|
||||||
return new Tag($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function replacePasteTags(DatabaseHandle $conn, int $pasteId, array $tags) {
|
public static function replacePasteTags(DatabaseHandle $conn, int $pasteId, array $tags) {
|
||||||
$conn->query('DELETE FROM paste_taggings WHERE paste_id = ?', [$pasteId]);
|
$conn->query('DELETE FROM paste_taggings WHERE paste_id = ?', [$pasteId]);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace PonePaste\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
require_once(__DIR__ . '/Paste.php');
|
|
||||||
|
|
||||||
class User extends Model {
|
class User extends Model {
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
|
@ -13,8 +14,8 @@ class User extends Model {
|
||||||
return $this->belongsToMany(Paste::class, 'user_favourites');
|
return $this->belongsToMany(Paste::class, 'user_favourites');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public function pastes() {
|
public function pastes() {
|
||||||
return $this->hasMany(Paste::class);
|
return $this->hasMany(Paste::class);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
namespace PonePaste\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class UserSession extends Model {
|
class UserSession extends Model {
|
|
@ -6,13 +6,11 @@ require_once(__DIR__ . '/../vendor/autoload.php');
|
||||||
require_once(__DIR__ . '/config.php');
|
require_once(__DIR__ . '/config.php');
|
||||||
require_once(__DIR__ . '/functions.php');
|
require_once(__DIR__ . '/functions.php');
|
||||||
require_once(__DIR__ . '/DatabaseHandle.class.php');
|
require_once(__DIR__ . '/DatabaseHandle.class.php');
|
||||||
//require_once(__DIR__ . '/User.class.php');
|
|
||||||
require_once(__DIR__ . '/ViewBag.class.php');
|
|
||||||
require_once(__DIR__ . '/models/User.php');
|
|
||||||
require_once(__DIR__ . '/SessionManager.class.php');
|
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use PonePaste\Helpers\SessionHelper;
|
use PonePaste\Helpers\SessionHelper;
|
||||||
|
use PonePaste\Models\Paste;
|
||||||
|
use PonePaste\Models\User;
|
||||||
|
|
||||||
/* View functions */
|
/* View functions */
|
||||||
function urlForPage($page = '') : string {
|
function urlForPage($page = '') : string {
|
||||||
|
@ -23,15 +21,15 @@ function urlForPage($page = '') : string {
|
||||||
return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/' . $page;
|
return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/' . $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
function urlForPaste($paste_id) : string {
|
function urlForPaste(Paste $paste) : string {
|
||||||
if (PP_MOD_REWRITE) {
|
if (PP_MOD_REWRITE) {
|
||||||
return "/${paste_id}";
|
return "/{$paste->id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "/paste.php?id=${paste_id}";
|
return "/paste.php?id={$paste->id}";
|
||||||
}
|
}
|
||||||
|
|
||||||
function urlForMember(string $member_name) : string {
|
function urlForMember(User $member_name) : string {
|
||||||
if (PP_MOD_REWRITE) {
|
if (PP_MOD_REWRITE) {
|
||||||
return '/user/' . urlencode($member_name);
|
return '/user/' . urlencode($member_name);
|
||||||
}
|
}
|
||||||
|
|
82
index.php
82
index.php
|
@ -1,4 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use PonePaste\Models\Paste;
|
||||||
|
use PonePaste\Models\Tag;
|
||||||
|
use PonePaste\Models\User;
|
||||||
|
|
||||||
define('IN_PONEPASTE', 1);
|
define('IN_PONEPASTE', 1);
|
||||||
require_once('includes/common.php');
|
require_once('includes/common.php');
|
||||||
require_once('includes/captcha.php');
|
require_once('includes/captcha.php');
|
||||||
|
@ -89,32 +94,29 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
|
||||||
$editing = isset($_POST['edit']);
|
$editing = isset($_POST['edit']);
|
||||||
|
|
||||||
$p_title = trim(htmlspecialchars($_POST['title']));
|
$paste_title = trim($_POST['title']);
|
||||||
|
|
||||||
if (empty($p_title)) {
|
if (empty($paste_title)) {
|
||||||
$p_title = 'Untitled';
|
$paste_title = 'Untitled';
|
||||||
}
|
}
|
||||||
|
|
||||||
$p_content = htmlspecialchars($_POST['paste_data']);
|
$paste_content = $_POST['paste_data'];
|
||||||
$p_visible = trim(htmlspecialchars($_POST['visibility']));
|
$paste_visibility = $_POST['visibility'];
|
||||||
$p_code = trim(htmlspecialchars($_POST['format']));
|
$paste_code = $_POST['format'];
|
||||||
|
$paste_password = $_POST['pass'];
|
||||||
|
$paste_encrypt = $_POST['encrypted'] === 'on'; // TODO: Make sure this works!
|
||||||
|
|
||||||
$p_expiry = trim(htmlspecialchars($_POST['paste_expire_date']));
|
$p_expiry = trim(htmlspecialchars($_POST['paste_expire_date']));
|
||||||
$p_password = $_POST['pass'];
|
|
||||||
$tag_input = $_POST['tag_input'];
|
$tag_input = $_POST['tag_input'];
|
||||||
|
|
||||||
if (empty($p_password)) {
|
if (empty($paste_password)) {
|
||||||
$p_password = null;
|
$paste_password = null;
|
||||||
} else {
|
} else {
|
||||||
$p_password = password_hash($p_password, PASSWORD_DEFAULT);
|
$paste_password = password_hash($paste_password, PASSWORD_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$p_encrypt = $_POST['encrypted'];
|
if ($paste_encrypt) {
|
||||||
if ($p_encrypt == "" || $p_encrypt == null) {
|
$paste_content = openssl_encrypt($paste_content, PP_ENCRYPTION_ALGO, PP_ENCRYPTION_KEY);
|
||||||
$p_encrypt = "0";
|
|
||||||
} else {
|
|
||||||
// Encrypt option
|
|
||||||
$p_encrypt = "1";
|
|
||||||
$p_content = openssl_encrypt($p_content, PP_ENCRYPTION_ALGO, PP_ENCRYPTION_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set expiry time
|
// Set expiry time
|
||||||
|
@ -126,26 +128,42 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$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(
|
$paste = Paste::find(intval($_POST['paste_id']));
|
||||||
"UPDATE pastes SET title = ?, content = ?, visible = ?, code = ?, expiry = ?, password = ?, encrypt = ?, ip = ?, updated_at = NOW()
|
$paste->update([
|
||||||
WHERE id = ?",
|
'title' => $paste_title,
|
||||||
[$p_title, $p_content, $p_visible, $p_code, $expires, $p_password, $p_encrypt, $ip, $paste_id]
|
'content' => $paste_content,
|
||||||
);
|
'visible' => $paste_visibility,
|
||||||
|
'code' => $paste_code,
|
||||||
|
'expiry' => $expires,
|
||||||
|
'password' => $paste_password,
|
||||||
|
'encrypt' => $paste_encrypt,
|
||||||
|
'ip' => $ip
|
||||||
|
]);
|
||||||
|
|
||||||
Tag::replacePasteTags($conn, $paste_id, Tag::parseTagInput($tag_input));
|
$paste->replaceTags(Tag::parseTagInput($tag_input));
|
||||||
} else {
|
} else {
|
||||||
$error = 'You must be logged in to do that.';
|
$error = 'You must be logged in to do that.';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$paste_owner = $current_user ? $current_user->user_id : 1; /* 1 is the guest user's user ID */
|
$paste_owner = $current_user ?: User::find(1); /* 1 is the guest user's user ID */
|
||||||
|
$paste = new Paste([
|
||||||
|
'title' => $paste_title,
|
||||||
|
'code' => $paste_code,
|
||||||
|
'content' => $paste_content,
|
||||||
|
'visible' => $paste_visibility,
|
||||||
|
'expiry' => $expires,
|
||||||
|
'password' => $paste_password,
|
||||||
|
'encrypt' => $paste_encrypt,
|
||||||
|
'created_at' => date_create(),
|
||||||
|
'ip' => $ip
|
||||||
|
]);
|
||||||
|
|
||||||
$paste_id = $conn->queryInsert(
|
$paste->user()->associate($paste_owner);
|
||||||
"INSERT INTO pastes (title, content, visible, code, expiry, password, encrypt, user_id, created_at, ip, views) VALUES
|
$paste->save();
|
||||||
(?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, 0)",
|
|
||||||
[$p_title, $p_content, $p_visible, $p_code, $expires, $p_password, $p_encrypt, $paste_owner, $ip]
|
|
||||||
);
|
|
||||||
|
|
||||||
Tag::replacePasteTags($conn, $paste_id, Tag::parseTagInput($tag_input));
|
$paste->replaceTags(Tag::parseTagInput($tag_input));
|
||||||
|
|
||||||
|
$paste_id = $new_paste->id;
|
||||||
|
|
||||||
if ($p_visible == '0') {
|
if ($p_visible == '0') {
|
||||||
addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite);
|
addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite);
|
||||||
|
@ -153,8 +171,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to paste on successful entry, or on successful edit redirect back to edited paste
|
// Redirect to paste on successful entry, or on successful edit redirect back to edited paste
|
||||||
if (isset($paste_id)) {
|
if (isset($paste)) {
|
||||||
header('Location: ' . urlForPaste($paste_id));
|
header('Location: ' . urlForPaste($paste));
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ define('IN_PONEPASTE', 1);
|
||||||
require_once('includes/common.php');
|
require_once('includes/common.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
require_once('includes/passwords.php');
|
require_once('includes/passwords.php');
|
||||||
require_once('includes/models/Paste.php');
|
|
||||||
|
|
||||||
use Highlight\Highlighter;
|
use Highlight\Highlighter;
|
||||||
|
use PonePaste\Models\Paste;
|
||||||
|
|
||||||
function rawView($content, $p_code) {
|
function rawView($content, $p_code) {
|
||||||
if ($p_code) {
|
if ($p_code) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ $flashes = getFlashes();
|
||||||
<div class="navbar-item has-dropdown is-hoverable">
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
<a class="navbar-link" role="presentation"><?= pp_html_escape($current_user->username) ?></a>
|
<a class="navbar-link" role="presentation"><?= pp_html_escape($current_user->username) ?></a>
|
||||||
<div class="navbar-dropdown">
|
<div class="navbar-dropdown">
|
||||||
<a class="navbar-item" href="<?= urlForMember($current_user->username) ?>">Pastes</a>
|
<a class="navbar-item" href="<?= urlForMember($current_user) ?>">Pastes</a>
|
||||||
<a class="navbar-item" href="<?= urlForPage('profile') ?>">Settings</a>
|
<a class="navbar-item" href="<?= urlForPage('profile') ?>">Settings</a>
|
||||||
<hr class="navbar-divider"/>
|
<hr class="navbar-divider"/>
|
||||||
<form action="<?= urlForPage('logout') ?>" method="POST">
|
<form action="<?= urlForPage('logout') ?>" method="POST">
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-content" style="overflow: hidden">
|
<div class="media-content" style="overflow: hidden">
|
||||||
<p class="title is-5">
|
<p class="title is-5">
|
||||||
<a href="<?= urlForPaste($paste['id']) ?>"
|
<a href="<?= urlForPaste($paste) ?>"
|
||||||
title="<?= $paste['title'] ?>"> <?= $paste['title'] ?> </a>
|
title="<?= pp_html_escape($paste->title) ?>"> <?= pp_html_escape($paste->title) ?> </a>
|
||||||
</p>
|
</p>
|
||||||
<p class="subtitle is-6">
|
<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>
|
<br>
|
||||||
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_time'] ?></time>
|
<time datetime="<?= $paste['time'] ?>"><?= $paste['friendly_time'] ?></time>
|
||||||
</p>
|
</p>
|
||||||
|
|
5
user.php
5
user.php
|
@ -1,8 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
define('IN_PONEPASTE', 1);
|
define('IN_PONEPASTE', 1);
|
||||||
require_once('includes/common.php');
|
require_once('includes/common.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
|
|
||||||
|
use PonePaste\Models\User;
|
||||||
|
|
||||||
|
|
||||||
if (empty($_GET['user'])) {
|
if (empty($_GET['user'])) {
|
||||||
// No username provided
|
// No username provided
|
||||||
header("Location: ../error.php");
|
header("Location: ../error.php");
|
||||||
|
|
8
vendor/composer/autoload_files.php
vendored
8
vendor/composer/autoload_files.php
vendored
|
@ -6,14 +6,14 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||||
|
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
|
||||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||||
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
|
||||||
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
||||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
|
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||||
|
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||||
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
|
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
|
||||||
|
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
|
||||||
'60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php',
|
'60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php',
|
||||||
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
|
'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php',
|
||||||
'72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php',
|
'72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php',
|
||||||
|
|
3
vendor/composer/autoload_psr4.php
vendored
3
vendor/composer/autoload_psr4.php
vendored
|
@ -20,7 +20,8 @@ return array(
|
||||||
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
|
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
|
||||||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
||||||
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
|
||||||
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/support'),
|
'PonePaste\\' => array($baseDir . '/includes'),
|
||||||
|
'Illuminate\\Support\\' => array($vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/support'),
|
||||||
'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'),
|
'Illuminate\\Database\\' => array($vendorDir . '/illuminate/database'),
|
||||||
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
|
'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'),
|
||||||
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
|
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
|
||||||
|
|
17
vendor/composer/autoload_static.php
vendored
17
vendor/composer/autoload_static.php
vendored
|
@ -7,14 +7,14 @@ namespace Composer\Autoload;
|
||||||
class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da
|
class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||||
|
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||||
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
|
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
|
||||||
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
|
||||||
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||||
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
|
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
|
||||||
|
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||||
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
|
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
|
||||||
|
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
|
||||||
'60799491728b879e74601d83e38b2cad' => __DIR__ . '/..' . '/illuminate/collections/helpers.php',
|
'60799491728b879e74601d83e38b2cad' => __DIR__ . '/..' . '/illuminate/collections/helpers.php',
|
||||||
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
|
'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php',
|
||||||
'72579e7bd17821bb1321b87411366eae' => __DIR__ . '/..' . '/illuminate/support/helpers.php',
|
'72579e7bd17821bb1321b87411366eae' => __DIR__ . '/..' . '/illuminate/support/helpers.php',
|
||||||
|
@ -44,6 +44,7 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da
|
||||||
array (
|
array (
|
||||||
'Psr\\SimpleCache\\' => 16,
|
'Psr\\SimpleCache\\' => 16,
|
||||||
'Psr\\Container\\' => 14,
|
'Psr\\Container\\' => 14,
|
||||||
|
'PonePaste\\' => 10,
|
||||||
),
|
),
|
||||||
'I' =>
|
'I' =>
|
||||||
array (
|
array (
|
||||||
|
@ -119,10 +120,14 @@ class ComposerStaticInit5bf95489f4eff2c10ec062bf7ba377da
|
||||||
array (
|
array (
|
||||||
0 => __DIR__ . '/..' . '/psr/container/src',
|
0 => __DIR__ . '/..' . '/psr/container/src',
|
||||||
),
|
),
|
||||||
|
'PonePaste\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/includes',
|
||||||
|
),
|
||||||
'Illuminate\\Support\\' =>
|
'Illuminate\\Support\\' =>
|
||||||
array (
|
array (
|
||||||
0 => __DIR__ . '/..' . '/illuminate/macroable',
|
0 => __DIR__ . '/..' . '/illuminate/collections',
|
||||||
1 => __DIR__ . '/..' . '/illuminate/collections',
|
1 => __DIR__ . '/..' . '/illuminate/macroable',
|
||||||
2 => __DIR__ . '/..' . '/illuminate/support',
|
2 => __DIR__ . '/..' . '/illuminate/support',
|
||||||
),
|
),
|
||||||
'Illuminate\\Database\\' =>
|
'Illuminate\\Database\\' =>
|
||||||
|
|
56
vendor/composer/installed.json
vendored
56
vendor/composer/installed.json
vendored
|
@ -153,17 +153,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/collections",
|
"name": "illuminate/collections",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/collections.git",
|
"url": "https://github.com/illuminate/collections.git",
|
||||||
"reference": "dd68b267ada1893126d53792b6c57b19e95a9d04"
|
"reference": "673d71d9db2827b04c096c4fe9739edddea14ac4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/collections/zipball/dd68b267ada1893126d53792b6c57b19e95a9d04",
|
"url": "https://api.github.com/repos/illuminate/collections/zipball/673d71d9db2827b04c096c4fe9739edddea14ac4",
|
||||||
"reference": "dd68b267ada1893126d53792b6c57b19e95a9d04",
|
"reference": "673d71d9db2827b04c096c4fe9739edddea14ac4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/var-dumper": "Required to use the dump method (^5.1.4)."
|
"symfony/var-dumper": "Required to use the dump method (^5.1.4)."
|
||||||
},
|
},
|
||||||
"time": "2021-08-23T08:57:48+00:00",
|
"time": "2021-08-25T13:02:21+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
@ -210,8 +210,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/container",
|
"name": "illuminate/container",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/container.git",
|
"url": "https://github.com/illuminate/container.git",
|
||||||
|
@ -264,17 +264,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/contracts",
|
"name": "illuminate/contracts",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/contracts.git",
|
"url": "https://github.com/illuminate/contracts.git",
|
||||||
"reference": "e4fa45682e8b558ccca02829e8e6e521ff9458d2"
|
"reference": "7354badf7b57eae805a56d1163fb023e0f58a639"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/e4fa45682e8b558ccca02829e8e6e521ff9458d2",
|
"url": "https://api.github.com/repos/illuminate/contracts/zipball/7354badf7b57eae805a56d1163fb023e0f58a639",
|
||||||
"reference": "e4fa45682e8b558ccca02829e8e6e521ff9458d2",
|
"reference": "7354badf7b57eae805a56d1163fb023e0f58a639",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -282,7 +282,7 @@
|
||||||
"psr/container": "^1.0",
|
"psr/container": "^1.0",
|
||||||
"psr/simple-cache": "^1.0"
|
"psr/simple-cache": "^1.0"
|
||||||
},
|
},
|
||||||
"time": "2021-08-19T13:06:39+00:00",
|
"time": "2021-08-24T21:29:28+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
@ -315,17 +315,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/database",
|
"name": "illuminate/database",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/database.git",
|
"url": "https://github.com/illuminate/database.git",
|
||||||
"reference": "18c2660dd2d5398263907d5717f0a611b901a05a"
|
"reference": "828d1cd4ee824c405f6edc52ab3d333b549be4ee"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/database/zipball/18c2660dd2d5398263907d5717f0a611b901a05a",
|
"url": "https://api.github.com/repos/illuminate/database/zipball/828d1cd4ee824c405f6edc52ab3d333b549be4ee",
|
||||||
"reference": "18c2660dd2d5398263907d5717f0a611b901a05a",
|
"reference": "828d1cd4ee824c405f6edc52ab3d333b549be4ee",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -347,7 +347,7 @@
|
||||||
"illuminate/pagination": "Required to paginate the result set (^8.0).",
|
"illuminate/pagination": "Required to paginate the result set (^8.0).",
|
||||||
"symfony/finder": "Required to use Eloquent model factories (^5.1.4)."
|
"symfony/finder": "Required to use Eloquent model factories (^5.1.4)."
|
||||||
},
|
},
|
||||||
"time": "2021-08-19T19:38:53+00:00",
|
"time": "2021-08-26T14:48:34+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
@ -386,8 +386,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/macroable",
|
"name": "illuminate/macroable",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/macroable.git",
|
"url": "https://github.com/illuminate/macroable.git",
|
||||||
|
@ -435,17 +435,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "illuminate/support",
|
"name": "illuminate/support",
|
||||||
"version": "v8.56.0",
|
"version": "v8.57.0",
|
||||||
"version_normalized": "8.56.0.0",
|
"version_normalized": "8.57.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/illuminate/support.git",
|
"url": "https://github.com/illuminate/support.git",
|
||||||
"reference": "586f77ee7f8568ecc60866f171074dccfbe69db5"
|
"reference": "5e8f059a5d1f298324e847822b997778a3472128"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/illuminate/support/zipball/586f77ee7f8568ecc60866f171074dccfbe69db5",
|
"url": "https://api.github.com/repos/illuminate/support/zipball/5e8f059a5d1f298324e847822b997778a3472128",
|
||||||
"reference": "586f77ee7f8568ecc60866f171074dccfbe69db5",
|
"reference": "5e8f059a5d1f298324e847822b997778a3472128",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -470,7 +470,7 @@
|
||||||
"symfony/var-dumper": "Required to use the dd function (^5.1.4).",
|
"symfony/var-dumper": "Required to use the dd function (^5.1.4).",
|
||||||
"vlucas/phpdotenv": "Required to use the Env class and env helper (^5.2)."
|
"vlucas/phpdotenv": "Required to use the Env class and env helper (^5.2)."
|
||||||
},
|
},
|
||||||
"time": "2021-08-22T17:54:36+00:00",
|
"time": "2021-08-25T13:04:37+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
|
36
vendor/composer/installed.php
vendored
36
vendor/composer/installed.php
vendored
|
@ -5,7 +5,7 @@
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '6eeb7f0a7e3ad263e25e78cc86e7f4027d0f1bbd',
|
'reference' => '070545e294d5191c315f4691080b63cd083955b1',
|
||||||
'name' => 'aftercase/ponepaste',
|
'name' => 'aftercase/ponepaste',
|
||||||
'dev' => true,
|
'dev' => true,
|
||||||
),
|
),
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '6eeb7f0a7e3ad263e25e78cc86e7f4027d0f1bbd',
|
'reference' => '070545e294d5191c315f4691080b63cd083955b1',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'doctrine/inflector' => array(
|
'doctrine/inflector' => array(
|
||||||
|
@ -38,17 +38,17 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/collections' => array(
|
'illuminate/collections' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/collections',
|
'install_path' => __DIR__ . '/../illuminate/collections',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => 'dd68b267ada1893126d53792b6c57b19e95a9d04',
|
'reference' => '673d71d9db2827b04c096c4fe9739edddea14ac4',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/container' => array(
|
'illuminate/container' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/container',
|
'install_path' => __DIR__ . '/../illuminate/container',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
@ -56,26 +56,26 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/contracts' => array(
|
'illuminate/contracts' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/contracts',
|
'install_path' => __DIR__ . '/../illuminate/contracts',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => 'e4fa45682e8b558ccca02829e8e6e521ff9458d2',
|
'reference' => '7354badf7b57eae805a56d1163fb023e0f58a639',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/database' => array(
|
'illuminate/database' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/database',
|
'install_path' => __DIR__ . '/../illuminate/database',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '18c2660dd2d5398263907d5717f0a611b901a05a',
|
'reference' => '828d1cd4ee824c405f6edc52ab3d333b549be4ee',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/macroable' => array(
|
'illuminate/macroable' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/macroable',
|
'install_path' => __DIR__ . '/../illuminate/macroable',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
@ -83,12 +83,12 @@
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'illuminate/support' => array(
|
'illuminate/support' => array(
|
||||||
'pretty_version' => 'v8.56.0',
|
'pretty_version' => 'v8.57.0',
|
||||||
'version' => '8.56.0.0',
|
'version' => '8.57.0.0',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../illuminate/support',
|
'install_path' => __DIR__ . '/../illuminate/support',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'reference' => '586f77ee7f8568ecc60866f171074dccfbe69db5',
|
'reference' => '5e8f059a5d1f298324e847822b997778a3472128',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'nesbot/carbon' => array(
|
'nesbot/carbon' => array(
|
||||||
|
|
8
vendor/illuminate/collections/Collection.php
vendored
8
vendor/illuminate/collections/Collection.php
vendored
|
@ -1146,13 +1146,15 @@ class Collection implements ArrayAccess, Enumerable
|
||||||
? $this->operatorForWhere(...func_get_args())
|
? $this->operatorForWhere(...func_get_args())
|
||||||
: $key;
|
: $key;
|
||||||
|
|
||||||
$items = $this->when($filter)->filter($filter);
|
$placeholder = new stdClass();
|
||||||
|
|
||||||
if ($items->isEmpty()) {
|
$item = $this->first($filter, $placeholder);
|
||||||
|
|
||||||
|
if ($item === $placeholder) {
|
||||||
throw new ItemNotFoundException;
|
throw new ItemNotFoundException;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items->first();
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface ContextualBindingBuilder
|
||||||
/**
|
/**
|
||||||
* Define the implementation for the contextual binding.
|
* Define the implementation for the contextual binding.
|
||||||
*
|
*
|
||||||
* @param \Closure|string $implementation
|
* @param \Closure|string|array $implementation
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function give($implementation);
|
public function give($implementation);
|
||||||
|
|
|
@ -114,6 +114,17 @@ class BroadcastableModelEventOccurred implements ShouldBroadcast
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the event should be broadcast synchronously.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function shouldBroadcastNow()
|
||||||
|
{
|
||||||
|
return $this->event === 'deleted' &&
|
||||||
|
! method_exists($this->model, 'bootSoftDeletes');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the event name.
|
* Get the event name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -111,6 +111,10 @@ trait BroadcastsEvents
|
||||||
*/
|
*/
|
||||||
protected function broadcastIfBroadcastChannelsExistForEvent($instance, $event, $channels = null)
|
protected function broadcastIfBroadcastChannelsExistForEvent($instance, $event, $channels = null)
|
||||||
{
|
{
|
||||||
|
if (! static::$isBroadcasting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($this->broadcastOn($event)) || ! empty($channels)) {
|
if (! empty($this->broadcastOn($event)) || ! empty($channels)) {
|
||||||
return broadcast($instance->onChannels(Arr::wrap($channels)));
|
return broadcast($instance->onChannels(Arr::wrap($channels)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,6 +348,72 @@ trait QueriesRelationships
|
||||||
return $this->doesntHaveMorph($relation, $types, 'or', $callback);
|
return $this->doesntHaveMorph($relation, $types, 'or', $callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a basic where clause to a relationship query.
|
||||||
|
*
|
||||||
|
* @param string $relation
|
||||||
|
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
|
||||||
|
* @param mixed $operator
|
||||||
|
* @param mixed $value
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||||
|
*/
|
||||||
|
public function whereRelation($relation, $column, $operator = null, $value = null)
|
||||||
|
{
|
||||||
|
return $this->whereHas($relation, function ($query) use ($column, $operator, $value) {
|
||||||
|
$query->where($column, $operator, $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an "or where" clause to a relationship query.
|
||||||
|
*
|
||||||
|
* @param string $relation
|
||||||
|
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
|
||||||
|
* @param mixed $operator
|
||||||
|
* @param mixed $value
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||||
|
*/
|
||||||
|
public function orWhereRelation($relation, $column, $operator = null, $value = null)
|
||||||
|
{
|
||||||
|
return $this->orWhereHas($relation, function ($query) use ($column, $operator, $value) {
|
||||||
|
$query->where($column, $operator, $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a polymorphic relationship condition to the query with a where clause.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation
|
||||||
|
* @param string|array $types
|
||||||
|
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
|
||||||
|
* @param mixed $operator
|
||||||
|
* @param mixed $value
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||||
|
*/
|
||||||
|
public function whereMorphRelation($relation, $types, $column, $operator = null, $value = null)
|
||||||
|
{
|
||||||
|
return $this->whereHasMorph($relation, $types, function ($query) use ($column, $operator, $value) {
|
||||||
|
$query->where($column, $operator, $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a polymorphic relationship condition to the query with an "or where" clause.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Relations\MorphTo|string $relation
|
||||||
|
* @param string|array $types
|
||||||
|
* @param \Closure|string|array|\Illuminate\Database\Query\Expression $column
|
||||||
|
* @param mixed $operator
|
||||||
|
* @param mixed $value
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||||
|
*/
|
||||||
|
public function orWhereMorphRelation($relation, $types, $column, $operator = null, $value = null)
|
||||||
|
{
|
||||||
|
return $this->orWhereHasMorph($relation, $types, function ($query) use ($column, $operator, $value) {
|
||||||
|
$query->where($column, $operator, $value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add subselect queries to include an aggregate value for a relationship.
|
* Add subselect queries to include an aggregate value for a relationship.
|
||||||
*
|
*
|
||||||
|
|
26
vendor/illuminate/database/Eloquent/Model.php
vendored
26
vendor/illuminate/database/Eloquent/Model.php
vendored
|
@ -166,6 +166,13 @@ abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jso
|
||||||
*/
|
*/
|
||||||
protected static $lazyLoadingViolationCallback;
|
protected static $lazyLoadingViolationCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if broadcasting is currently enabled.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected static $isBroadcasting = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the "created at" column.
|
* The name of the "created at" column.
|
||||||
*
|
*
|
||||||
|
@ -377,6 +384,25 @@ abstract class Model implements Arrayable, ArrayAccess, HasBroadcastChannel, Jso
|
||||||
static::$lazyLoadingViolationCallback = $callback;
|
static::$lazyLoadingViolationCallback = $callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a callback without broadcasting any model events for all model types.
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function withoutBroadcasting(callable $callback)
|
||||||
|
{
|
||||||
|
$isBroadcasting = static::$isBroadcasting;
|
||||||
|
|
||||||
|
static::$isBroadcasting = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return $callback();
|
||||||
|
} finally {
|
||||||
|
static::$isBroadcasting = $isBroadcasting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill the model with an array of attributes.
|
* Fill the model with an array of attributes.
|
||||||
*
|
*
|
||||||
|
|
2
vendor/illuminate/support/Facades/Http.php
vendored
2
vendor/illuminate/support/Facades/Http.php
vendored
|
@ -20,7 +20,7 @@ use Illuminate\Http\Client\Factory;
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest contentType(string $contentType)
|
* @method static \Illuminate\Http\Client\PendingRequest contentType(string $contentType)
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest dd()
|
* @method static \Illuminate\Http\Client\PendingRequest dd()
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest dump()
|
* @method static \Illuminate\Http\Client\PendingRequest dump()
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleep = 0)
|
* @method static \Illuminate\Http\Client\PendingRequest retry(int $times, int $sleep = 0, ?callable $when = null)
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest sink(string|resource $to)
|
* @method static \Illuminate\Http\Client\PendingRequest sink(string|resource $to)
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest stub(callable $callback)
|
* @method static \Illuminate\Http\Client\PendingRequest stub(callable $callback)
|
||||||
* @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds)
|
* @method static \Illuminate\Http\Client\PendingRequest timeout(int $seconds)
|
||||||
|
|
Loading…
Add table
Reference in a new issue