mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
add profile identicons
This commit is contained in:
parent
8847a86085
commit
c723ce85b1
5 changed files with 65 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue