mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-02 10:04:52 +00:00
add profile identicons
This commit is contained in:
parent
8847a86085
commit
c723ce85b1
@ -85,7 +85,6 @@ git checkout -b my-pr-branch-name
|
||||
+ [ ] Comments
|
||||
+ [ ] Settings
|
||||
+ [ ] Public name
|
||||
+ [ ] Avatar
|
||||
+ [ ] Downloads customization
|
||||
+ [ ] Address Tracker
|
||||
+ [ ] Web Seed
|
||||
@ -108,8 +107,9 @@ git checkout -b my-pr-branch-name
|
||||
|
||||
#### Components
|
||||
|
||||
* [Icons](https://icons.getbootstrap.com)
|
||||
* [SVG icons](https://icons.getbootstrap.com)
|
||||
* [PHP Scrapper](https://github.com/medariox/scrapeer)
|
||||
* [Identicon](https://github.com/dmester/jdenticon-php)
|
||||
|
||||
#### Feedback
|
||||
|
||||
|
@ -4,7 +4,8 @@
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"yggverse/parser": ">=0.2.0"
|
||||
"yggverse/parser": ">=0.2.0",
|
||||
"jdenticon/jdenticon": "^1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
|
@ -27,6 +27,56 @@ $response = (object)
|
||||
// Begin action request
|
||||
switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
|
||||
{
|
||||
case 'profile':
|
||||
|
||||
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
|
||||
{
|
||||
case 'identicon':
|
||||
|
||||
// Yggdrasil connections only
|
||||
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
|
||||
{
|
||||
$response->success = false;
|
||||
$response->message = _('Yggdrasil connection required for this action');
|
||||
}
|
||||
|
||||
// Init session
|
||||
else if (!$userId = $db->initUserId($_SERVER['REMOTE_ADDR'], USER_DEFAULT_APPROVED, time()))
|
||||
{
|
||||
$response->success = false;
|
||||
$response->message = _('Could not init user session');
|
||||
}
|
||||
|
||||
// Get user
|
||||
else if (!$user = $db->getUser($userId))
|
||||
{
|
||||
$response->success = false;
|
||||
$response->message = _('Could not init user info');
|
||||
}
|
||||
|
||||
// Render icon
|
||||
else
|
||||
{
|
||||
header('Cache-Control: max-age=604800');
|
||||
|
||||
|
||||
$icon = new Jdenticon\Identicon();
|
||||
|
||||
$icon->setValue($user->address);
|
||||
$icon->setSize(empty($_GET['size']) ? 100 : (int) $_GET['size']);
|
||||
$icon->setStyle(
|
||||
[
|
||||
'backgroundColor' => 'rgba(255, 255, 255, 0)',
|
||||
]
|
||||
);
|
||||
$icon->displayImage('webp');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
|
||||
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
|
||||
|
@ -172,6 +172,10 @@
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.margin-r-4 {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.margin-r-8 {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
@ -413,10 +413,16 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
|
||||
<?php foreach ($db->getMagnetComments($response->magnet->magnetId) as $magnetComment) { ?>
|
||||
<div class="padding-x-16 padding-t-16 padding-b-8 margin-t-8 border-radius-3 background-color-night <?php echo !$magnetComment->approved || !$magnetComment->public ? 'opacity-06 opacity-hover-1' : false ?>">
|
||||
<a name="comment-<?php echo $magnetComment->magnetCommentId ?>"></a>
|
||||
<?php if ($response->user->address == $db->getUser($magnetComment->userId)->address || in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
|
||||
<?php if ($response->user->address == $db->getUser($magnetComment->userId)->address ||
|
||||
in_array($response->user->address, MODERATOR_IP_LIST)) { ?>
|
||||
<div class="margin-b-16">
|
||||
<?php echo nl2br(htmlentities($magnetComment->value)) ?>
|
||||
</div>
|
||||
<img class="float-left margin-r-8"
|
||||
alt=""
|
||||
src="<?php echo sprintf('%s/action.php?target=profile&toggle=identicon&userId=%s&size=16',
|
||||
WEBSITE_URL,
|
||||
$magnetComment->userId) ?>" />
|
||||
<sup>
|
||||
<?php echo Time::ago((int) $magnetComment->timeAdded) ?>
|
||||
</sup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user