Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
369087d
chore(deps): update dependencies/requirements
itinerare Feb 3, 2023
b1bc11d
chore(deps): update doctrine/dbal
itinerare Feb 3, 2023
dad0aaf
Merge pull request #535 from itinerare/feature/8.1-upgrade
itinerare Mar 26, 2023
130ccb2
fix: fix lowercase "auth" references (#523)
preimpression May 28, 2023
678b9a0
chore(update): 2.1.2
itinerare May 28, 2023
9ad83b8
Fix(MYOs): Allows character images to work locally
SpeedyD Oct 15, 2023
5142ee3
fix(comments): more robust handling for non user-user comments
itinerare Oct 16, 2023
46e38f8
fix(comments): adjust staff-user default handling
itinerare Oct 16, 2023
8582dc9
fix(comments): remove empty staff-staff default
itinerare Oct 16, 2023
cc7103a
fix(characters): use only public_path() in CharacterManager (#703)
itinerare Oct 22, 2023
761f1b9
fix(items): disable box button on submit (#710)
ScuffedNewt Oct 22, 2023
ea2ff9e
fix(sales): allow setting minimum for ota and xta (#702)
SpeedyD Oct 22, 2023
f58cebf
Merge pull request #708 from itinerare/hotfix/adjust-comment-types
itinerare Oct 22, 2023
b9aac64
chore(update): 2.1.3
itinerare Oct 22, 2023
75bc208
hotfix(shops): round up shop purchase quantity (#829)
AW0005 Feb 11, 2024
8bd438f
fix(shops): validate quantity against purchase limit
itinerare Feb 14, 2024
a4ab8b7
Merge pull request #833 from itinerare/hotfix/purchase-limit-check
itinerare Feb 18, 2024
f28beb4
hotfix(security|requests): add middleware that parses post fields (#974)
ScuffedNewt Jun 16, 2024
426bbd1
chore(update): update version
itinerare Jun 16, 2024
f0aa1f8
fix: add numeric check to parse to prevent dropdowns from being parse…
ScuffedNewt Jun 16, 2024
1274c9f
fix(galleries): fix gallery submission visibility scope handling (#1082)
preimpression Oct 27, 2024
36cb052
Merge branch 'extension/online-status' of https://github.com/preimpre…
AnimatedCritter May 25, 2025
0af7834
Feat: create last-online visibility toggle
AnimatedCritter Sep 12, 2022
01bbb92
Feat: add "only site staff" to online visibility in user settings
AnimatedCritter Feb 21, 2023
dc39bf6
Feat: add "only logged-in users" to online visibility in user settings
AnimatedCritter May 25, 2025
93a35a3
Refactor: remove extra whitespace
AnimatedCritter May 25, 2025
3987c86
Refactor: improve online status if else readibility
AnimatedCritter May 25, 2025
d035559
Refactor: update is_online extension tracker
AnimatedCritter May 25, 2025
33db1ee
Refactor: remove numbers from last_online_settting dropdown
AnimatedCritter May 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions app/Console/Commands/UpdateCommentTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Console\Commands;

use App\Models\Comment;
use Illuminate\Console\Command;

class UpdateCommentTypes extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update-comment-types';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Updates comment types.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$comments = Comment::where('commentable_type', 'App\Models\Report\Report')->where('type', 'User-User');

if($comments->count()) {
$this->line('Updating comment types...');
$comments->update(['type' => 'Staff-User']);
} else {
$this->info('No comments to update!');
}

return 0;
}
}
1 change: 0 additions & 1 deletion app/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ function parse($text, &$pings = null) {
$config->set('Attr.EnableID', true);
$config->set('HTML.DefinitionID', 'include');
$config->set('HTML.DefinitionRev', 2);
$config->set('Cache.DefinitionImpl', null); // TODO: remove this later!
if ($def = $config->maybeGetRawHTMLDefinition()) {
$def->addElement('include', 'Block', 'Empty', 'Common', array('file*' => 'URI', 'height' => 'Text', 'width' => 'Text'));
$def->addAttribute('a', 'data-toggle', 'Enum#collapse,tab');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Characters/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getCharacterGallery($slug)
{
return view('character.gallery', [
'character' => $this->character,
'submissions' => GallerySubmission::whereIn('id', $this->character->gallerySubmissions->pluck('gallery_submission_id')->toArray())->visible()->accepted()->orderBy('created_at', 'DESC')->paginate(20),
'submissions' => GallerySubmission::whereIn('id', $this->character->gallerySubmissions->pluck('gallery_submission_id')->toArray())->visible(Auth::user() ?? null)->orderBy('created_at', 'DESC')->paginate(20),
]);
}

Expand Down
41 changes: 29 additions & 12 deletions app/Http/Controllers/PermalinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Models\Model;

use App\Models\Comment;
use App\Models\Report\Report;

class PermalinkController extends Controller
{
Expand All @@ -25,33 +26,49 @@ public function getComment($id) {
$comments = Comment::withTrashed()->get();
//$comments = $comments->sortByDesc('created_at');
$comment = $comments->find($id);

if(!$comment) abort(404);
if(!$comment->commentable) abort(404);

// Check if the comment can be viewed
switch($comment->type) {
case "Staff-User":
if(!Auth::check()) abort(404);
$submission = GallerySubmission::find($comment->commentable_id);
$isMod = Auth::user()->hasPower('manage_submissions');
$isOwner = ($submission->user_id == Auth::user()->id);
$isCollaborator = $submission->collaborators->where('user_id', Auth::user()->id)->first() != null ? true : false;
if(!$isMod && !$isOwner && !$isCollaborator) abort(404);
break;
switch($comment->commentable_type) {
case 'App\Models\Gallery\GallerySubmission':
$submission = GallerySubmission::where('id', $comment->commentable_id)->first();
$isMod = Auth::user()->hasPower('manage_submissions');
$isOwner = ($submission->user_id == Auth::user()->id);
$isCollaborator = $submission->collaborators->where('user_id', Auth::user()->id)->first() != null ? true : false;
if(!$isMod && !$isOwner && !$isCollaborator) abort(404);
break;
case 'App\Models\Report\Report':
$report = Report::where('id', $comment->commentable_id)->first();
$isMod = Auth::user()->hasPower('manage_reports');
$isOwner = ($report->user_id == Auth::user()->id);
if(!$isMod && !$isOwner) abort(404);
break;
default:
if(!Auth::user()->isStaff) abort(404);
break;
}
case "Staff-Staff":
if(!Auth::check()) abort(404);
if(!Auth::user()->hasPower('manage_submissions')) abort(404);
break;
default:
if(!Auth::user()->isStaff) abort(404);
// More specific filtering depending on circumstance
switch($comment->commentable_type) {
case 'App\Models\Gallery\GallerySubmission':
if(!Auth::user()->hasPower('manage_submissions')) abort(404);
break;
}
break;
}

if($comment->commentable_type == 'App\Models\User\UserProfile') $comment->location = $comment->commentable->user->url;
else $comment->location = $comment->commentable->url;

return view('comments._perma_layout',[
'comment' => $comment,
'comment' => $comment,
]);
}
}
18 changes: 18 additions & 0 deletions app/Http/Controllers/Users/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ public function postBirthday(Request $request, UserService $service)
return redirect()->back();
}

/**
* Changes user last-online setting
*
* @param \Illuminate\Http\Request $request
* @param App\Services\UserService $service
* @return \Illuminate\Http\RedirectResponse
*/
public function postLastOnline(Request $request, UserService $service)
{
if($service->updateLastOnline($request->input('last_online_setting'), Auth::user())) {
flash('Setting updated successfully.')->success();
}
else {
foreach($service->errors()->getMessages()['error'] as $error) flash($error)->error();
}
return redirect()->back();
}

/**
* Shows the notifications page.
*
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/Users/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getUser($name)
{
$characters = $this->user->characters();
if(!Auth::check() || !(Auth::check() && Auth::user()->hasPower('manage_characters'))) $characters->visible();

return view('user.profile', [
'user' => $this->user,
'items' => $this->user->items()->where('count', '>', 0)->orderBy('user_items.updated_at', 'DESC')->take(4)->get(),
Expand All @@ -84,7 +84,7 @@ public function getUserAliases($name)
{
$aliases = $this->user->aliases();
if(!Auth::check() || !(Auth::check() && Auth::user()->hasPower('edit_user_info'))) $aliases->visible();

return view('user.aliases', [
'user' => $this->user,
'aliases' => $aliases->orderBy('is_primary_alias', 'DESC')->orderBy('site')->get(),
Expand Down Expand Up @@ -299,7 +299,7 @@ public function getUserGallery($name)
{
return view('user.gallery', [
'user' => $this->user,
'submissions' => $this->user->gallerySubmissions()->paginate(20),
'submissions' => $this->user->gallerySubmissions()->visible(Auth::user() ?? null)->paginate(20),
'sublists' => Sublist::orderBy('sort', 'DESC')->get()
]);
}
Expand All @@ -315,7 +315,7 @@ public function getUserFavorites($name)
return view('user.favorites', [
'user' => $this->user,
'characters' => false,
'favorites' => GallerySubmission::whereIn('id', $this->user->galleryFavorites()->pluck('gallery_submission_id')->toArray())->visible(Auth::check() ? Auth::user() : null)->accepted()->orderBy('created_at', 'DESC')->paginate(20),
'favorites' => GallerySubmission::whereIn('id', $this->user->galleryFavorites()->pluck('gallery_submission_id')->toArray())->visible(Auth::user() ?? null)->orderBy('created_at', 'DESC')->paginate(20),
'sublists' => Sublist::orderBy('sort', 'DESC')->get()
]);
}
Expand All @@ -335,7 +335,7 @@ public function getUserOwnCharacterFavorites($name)
return view('user.favorites', [
'user' => $this->user,
'characters' => true,
'favorites' => $this->user->characters->count() ? GallerySubmission::whereIn('id', $userFavorites)->whereIn('id', GalleryCharacter::whereIn('character_id', $userCharacters)->pluck('gallery_submission_id')->toArray())->visible(Auth::check() ? Auth::user() : null)->accepted()->orderBy('created_at', 'DESC')->paginate(20) : null,
'favorites' => $this->user->characters->count() ? GallerySubmission::whereIn('id', $userFavorites)->whereIn('id', GalleryCharacter::whereIn('character_id', $userCharacters)->pluck('gallery_submission_id')->toArray())->visible(Auth::user() ?? null)->orderBy('created_at', 'DESC')->paginate(20) : null,
'sublists' => Sublist::orderBy('sort', 'DESC')->get()
]);
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\ParsePostRequestFields::class,
];

/**
Expand Down
71 changes: 71 additions & 0 deletions app/Http/Middleware/ParsePostRequestFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class ParsePostRequestFields
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next) {
if ($request->isMethod('post')) {
$excludedFields = ['_token', 'password', 'email', 'description', 'text'];
$strippedFields = ['name', 'title'];

$parsedFields = [];
foreach ($request->except($excludedFields) as $key => $value) {
if (is_array($value)) {
$parsedFields[$key] = $this->parseArray($value, $strippedFields);
} else {
if (is_numeric($value)) {
continue;
}

if (in_array($key, $strippedFields)) { // we strip these since parse() doesn't remove HTML tags
$parsedFields[$key] = parse(strip_tags($value));
} else {
$parsedFields[$key] = parse($value);
}
}
}

$request->merge($parsedFields);
}

return $next($request);
}

/**
* Recursively parse array values.
*
* @param array $array
* @param array $strippedFields
* @return array
*/
private function parseArray(array $array, array $strippedFields) : array {
foreach ($array as $key => $value) {
if (is_numeric($value)) {
continue;
}

if (is_array($value)) {
$array[$key] = $this->parseArray($value, $strippedFields);
} else {
if (in_array($key, $strippedFields)) {
$array[$key] = parse(strip_tags($value));
} else {
$array[$key] = parse($value);
}
}
}

return $array;
}
}
8 changes: 5 additions & 3 deletions app/Models/Sales/SalesCharacter.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,18 @@ public function getPriceAttribute()
;
break;
case 'ota':
return (isset($this->data['autobuy']) ? '<br/>Autobuy: '.$symbol.$this->data['autobuy'] : '');
return (isset($this->data['autobuy']) ? 'Autobuy: '.$symbol.$this->data['autobuy'].'<br/>' : '').
(isset($this->data['minimum']) ? 'Minimum: '.$symbol.$this->data['minimum'].'<br/>' : '');
break;
case 'xta':
return (isset($this->data['autobuy']) ? '<br/>Autobuy: '.$symbol.$this->data['autobuy'] : '');
return (isset($this->data['autobuy']) ? 'Autobuy: '.$symbol.$this->data['autobuy'].'<br/>' : '').
(isset($this->data['minimum']) ? 'Minimum: '.$symbol.$this->data['minimum'].'<br/>' : '');
break;
case 'flaffle':
return 'Price: '.$symbol.$this->data['price'];
break;
case 'pwyw':
return 'Minimum: '.$symbol.$this->data['minimum'];
return (isset($this->data['minimum']) ? 'Minimum: '.$symbol.$this->data['minimum'].'<br/>' : '');
break;
}
}
Expand Down
40 changes: 32 additions & 8 deletions app/Models/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function items()
*/
public function gallerySubmissions()
{
return $this->hasMany('App\Models\Gallery\GallerySubmission')->where('user_id', $this->id)->orWhereIn('id', GalleryCollaborator::where('user_id', $this->id)->where('type', 'Collab')->pluck('gallery_submission_id')->toArray())->visible($this)->accepted()->orderBy('created_at', 'DESC');
return $this->hasMany('App\Models\Gallery\GallerySubmission')->where('user_id', $this->id)->orWhereIn('id', GalleryCollaborator::where('user_id', $this->id)->where('type', 'Collab')->pluck('gallery_submission_id')->toArray())->orderBy('created_at', 'DESC');
}

/**
Expand Down Expand Up @@ -348,15 +348,39 @@ public function getLogTypeAttribute()
// Check if user is online and display When they were online
public function isOnline()
{
$onlineStatus = Cache::has('user-is-online-' . $this->id);
$online = Carbon::createFromTimeStamp(strtotime(Cache::get('user-is-online-time-' . $this->id)));
$onlineTime = isset($this->last_seen) ? Carbon::parse($this->last_seen)->diffForHumans() : 'a long time ago';

$onlineStatus = Cache::has('user-is-online-' . $this->id);
$online = Carbon::createFromTimeStamp(strtotime(Cache::get('user-is-online-time-' . $this->id)));
$onlineTime = isset($this->last_seen) ? Carbon::parse($this->last_seen)->diffForHumans() : 'A long time ago.';

if($onlineStatus) $result = '<i class="fas fa-circle text-success mr-2" data-toggle="tooltip" title="This user is online."></i>';
else $result = '<i class="far fa-circle text-secondary mr-2" data-toggle="tooltip" title="This user was last online ' . $onlineTime .'."></i>';
$statusHidden = '<i class="fas fa-circle text-faded mr-2" data-toggle="tooltip" title="This user\'s online status is hidden"></i>';
if ($onlineStatus) {
$statusShow = '<i class="fas fa-circle text-success mr-2" data-toggle="tooltip" title="This user is online."></i>';
} else {
$statusShow = '<i class="far fa-circle text-secondary mr-2" data-toggle="tooltip" title="This user was last online ' . $onlineTime .'."></i>';
}

return $result;
switch($this->settings->last_online_setting) {
case 0:
return $statusHidden;
break;
case 1:
return $statusShow;
break;
case 2:
if(Auth::check() && Auth::user()->isStaff){
return $statusShow;
} else {
return $statusHidden;
}
break;
case 3:
if(Auth::check()){
return $statusShow;
} else {
return $statusHidden;
}
break;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserSettings extends Model
* @var array
*/
protected $fillable = [
'is_fto', 'submission_count', 'banned_at', 'ban_reason', 'birthday_setting'
'is_fto', 'submission_count', 'banned_at', 'ban_reason', 'birthday_setting', 'last_online_setting'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/CommentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function create($user) : bool
*/
public function delete($user, Comment $comment) : bool
{
if(auth::user()->isStaff) {
if(Auth::user()->isStaff) {
return true;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions app/Services/CharacterManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ private function handleCharacterImage($data, $character, $isMyo = false)
// Use default images for MYO slots without an image provided
if(!isset($data['image']))
{
$data['image'] = asset('images/myo.png');
$data['thumbnail'] = asset('images/myo-th.png');
$data['image'] = public_path('images/myo.png');
$data['thumbnail'] = public_path('images/myo-th.png');
$data['extension'] = 'png';
$data['default_image'] = true;
unset($data['use_cropper']);
Expand Down
Loading