Automatic push 4.0.10

This commit is contained in:
chevereto
2024-02-07 14:16:32 +00:00
parent 93edcbe481
commit 22cfa902a9
24 changed files with 380 additions and 658 deletions

17
.package/4.0.10.txt Normal file
View File

@@ -0,0 +1,17 @@
Chevereto 4.0.10 (2024-02-07)
✅ Added version CLI command
✅ Improved error display on CLI install
🐞 Fixed bug in AWS open_basedir restriction
🐞 Fixed bug in banners settings page
🐞 Fixed bug in comments implementation
🐞 Fixed bug in file size handling
🐞 Fixed bug in notifications missing links
🐞 Fixed bug in NSFW display
🐞 Fixed bug in Spanish translation
🐞 Fixed bug in update database query
🐞 Fixed bug in upload file title
🐞 Fixed bug in user interface for iOS
💅 Disabled listing viewer by default
💅 Improved arrow style navigation
💅 Improved notifications display (default avatar)

View File

@@ -1,9 +0,0 @@
Chevereto 4.0.9 (2023-08-27)
- 🌎 Updated translations: Chinese Simplified, Chinese Traditional, German, Portuguese (Brazil) and Vietnamese
- 🐞 Fixed bug in category listing missing name
- 🐞 Fixed bug in Dashboard stats
- 🐞 Fixed bug in ip ban editing
- 🐞 Fixed bug in json route
- 🐞 Fixed bug in Search class
- 🐞 Fixed bug in user profile NSFW banner display

View File

@@ -1381,7 +1381,7 @@ $translation_table = [
0 => "hacer click",
],
"Customize upload by %action% on any preview" => [
0 => "Personaliza la subida al %acción% en cualquier vista previa",
0 => "Personaliza la subida al %action% en cualquier vista previa",
],
"touching" => [
0 => "tocar",

488
app/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1466,7 +1466,7 @@ msgid "clicking"
msgstr "hacer click"
msgid "Customize upload by %action% on any preview"
msgstr "Personaliza la subida al %acción% en cualquier vista previa"
msgstr "Personaliza la subida al %action% en cualquier vista previa"
msgid "touching"
msgstr "tocar"

View File

@@ -0,0 +1,12 @@
<?php
/*
* This file is part of Chevereto.
*
* (c) Rodolfo Berrios <rodolfo@chevereto.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
echo APP_VERSION . PHP_EOL;

View File

@@ -34,6 +34,7 @@ if ($opts === []) {
'password-reset',
'setting-get',
'setting-update',
'version'
];
if (!in_array($access, $options)) {
echo "Invalid command\n";

View File

@@ -429,7 +429,7 @@ $settings_updates = [
'explore_albums_min_image_count' => '1',
'upload_max_filesize_mb_guest' => '0.5',
'notify_user_signups' => 0,
'listing_viewer' => 1,
// 'listing_viewer' => 1,
],
'3.10.7' => null,
'3.10.8' => null,
@@ -591,6 +591,9 @@ $settings_updates = [
'4.0.7' => null,
'4.0.8' => null,
'4.0.9' => null,
'4.0.10' => [
'listing_viewer' => 0,
],
];
$cheveretoFreeMap = [
'1.0.0' => '3.8.3',
@@ -1775,13 +1778,13 @@ ALTER TABLE `%table_prefix%users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8m
SELECT login_user_id, max(login_date_gmt), login_secret
FROM `%table_prefix%logins`
WHERE login_type = "password"
GROUP BY login_user_id;
GROUP BY login_user_id, login_secret;
INSERT IGNORE INTO `%table_prefix%login_cookies` (login_cookie_user_id, login_cookie_connection_id, login_cookie_date_gmt,
login_cookie_ip, login_cookie_user_agent, login_cookie_hash)
SELECT login_user_id, 0, login_date_gmt, login_ip, login_hostname, login_secret
FROM `%table_prefix%logins`
WHERE login_type = "cookie"
GROUP BY login_date_gmt
GROUP BY login_date_gmt, login_user_id, login_ip, login_hostname, login_secret
ORDER BY login_date_gmt DESC;
INSERT IGNORE INTO `%table_prefix%login_connections` (login_connection_user_id, login_connection_provider_id, login_connection_date_gmt,
login_connection_resource_id, login_connection_resource_name,
@@ -1790,7 +1793,7 @@ ALTER TABLE `%table_prefix%users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8m
FROM `%table_prefix%logins`
JOIN `%table_prefix%login_providers` ON login_provider_name = login_type COLLATE utf8mb4_unicode_ci
WHERE login_type IN ('facebook', 'twitter', 'google', 'vk')
GROUP BY login_user_id, login_provider_id;
GROUP BY login_user_id, login_provider_id, login_resource_id, login_resource_name;
SQL
.
"\n"
@@ -2260,6 +2263,13 @@ EOT;
}
}
if (PHP_SAPI === 'cli') {
if ($error === true) {
throw new LogicException(
message("$error_message: %errors%")
->withTranslate('%error%', implode("\n", $input_errors))
);
die(255);
}
switch ($doing) {
case 'already':
logger(

View File

@@ -9,5 +9,5 @@
* file that was distributed with this source code.
*/
const APP_VERSION = '4.0.9';
const APP_VERSION = '4.0.10';
const APP_VERSION_AKA = 'macanudo';

View File

@@ -75,7 +75,7 @@ abstract class EntityIo implements EntityIoInterface
foreach ($values as $column => $value) {
$column = (string) $column;
$queryBuilder
->set($column, ":${column}")
->set($column, ":{$column}")
->setParameter($column, $value);
}
@@ -92,7 +92,7 @@ abstract class EntityIo implements EntityIoInterface
foreach ($values as $column => $value) {
$column = (string) $column;
$queryBuilder
->setValue($column, ":${column}")
->setValue($column, ":{$column}")
->setParameter($column, $value);
}
$result = $queryBuilder->execute();

View File

@@ -547,15 +547,12 @@ class Image
$upload->detectFlood = false;
}
$upload->exec();
$return = [
return [
'uploaded' => $upload->uploaded(),
'source' => $upload->source(),
'moderation' => $upload->moderation(),
];
if (property_exists($upload, 'moderation') && $upload->moderation() !== null) {
$return['moderation'] = $upload->moderation();
}
return $return;
}
// Mostly for people uploading two times the same image to test or just bug you
@@ -985,22 +982,20 @@ class Image
: null
]);
}
$image_title = $params['title']
?? preg_replace('/[-_\s]+/', ' ', trim($image_upload['source']['name']));
/** @var ?Exif */
$exifRead = $image_upload['source']['image_exif'];
if ($exifRead instanceof Exif) {
if (!array_key_exists('title', $params)) {
$title_from_exif = null;
if ($exifRead->getTitle() !== false) {
$title_from_exif = trim($exifRead->getTitle());
}
if ($title_from_exif !== null) {
$exifTitle = $exifRead->getTitle();
if ($exifTitle !== false) {
$title_from_exif = trim($exifTitle);
$title_from_exif = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $title_from_exif);
$image_title = $title_from_exif;
} else {
$title_from_filename = preg_replace('/[-_\s]+/', ' ', trim($image_upload['source']['name']));
$image_title = $title_from_filename;
if ($title_from_exif !== '') {
$image_title = $title_from_exif;
}
}
$image_insert_values['title'] = $image_title;
}
if (!array_key_exists('description', $params)) {
$description_from_exif = null;
@@ -1013,6 +1008,7 @@ class Image
}
}
}
$image_insert_values['title'] = $image_title;
if ($filenaming == 'id' && isset($target_id)) { // Insert as a reserved ID
$image_insert_values['id'] = $target_id;
}

View File

@@ -40,7 +40,6 @@ use function Chevereto\Vars\sessionVar;
use Exception;
use Intervention\Image\ImageManagerStatic;
use PHPExif\Exif;
use stdClass;
use Throwable;
class Upload
@@ -59,7 +58,7 @@ class Upload
private ImageConvert $ImageConvert;
private object $moderation;
private ?object $moderation = null;
// filename => name.ext
// file => /full/path/to/name.ext
@@ -91,11 +90,6 @@ class Upload
'ftp'
];
public function __construct()
{
$this->moderation = new stdClass();
}
public function uploaded(): array
{
return $this->uploaded;
@@ -106,7 +100,7 @@ class Upload
return $this->source;
}
public function moderation(): object
public function moderation(): ?object
{
return $this->moderation;
}

View File

@@ -1304,27 +1304,25 @@ function get_bytes(string $size, ?int $cut = null): int
} else {
$suffix = substr($size, $cut);
}
$number = (int) str_replace($suffix, '', $size);
$number = (float) str_replace($suffix, '', $size);
$suffix = strtoupper($suffix);
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; // Default dec units
if (strlen($suffix) == 3) { // Convert units to bin
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
if (strlen($suffix) == 3) {
foreach ($units as &$unit) {
$split = str_split($unit);
$unit = $split[0] . 'I' . $split[1];
}
}
if (strlen($suffix) == 1) {
$suffix .= 'B'; // Adds missing "B" for shorthand ini notation (Turns 1G into 1GB)
$suffix .= 'B';
}
if (!in_array($suffix, $units)) {
return $number;
return (int) $number;
}
$pow_factor = array_search($suffix, $units) + 1;
$num = strlen($suffix) == 2 ? 1000 : 1024;
return $number * pow(strlen($suffix) == 2 ? 1000 : 1024, $pow_factor);
return (int) ($number * pow($num, $pow_factor));
}
function bytes_to_mb(int|float $bytes): float

View File

@@ -982,7 +982,7 @@ function getComments(): string
'id' => $logged_user['id_encoded'],
'username' => $logged_user['name'],
'email' => $logged_user['email'],
'avatar' => $logged_user['avatar']['url'],
'avatar' => $logged_user['avatar']['url'] ?? '',
'url' => $logged_user['url'],
];
}

View File

@@ -144,6 +144,7 @@ focus:-ms-input-placeholder {
body {
min-height: 100vh;
min-height: 100dvh;
min-height: -webkit-fill-available;
-webkit-font-smoothing: subpixel-antialiased;
}
@@ -159,6 +160,7 @@ html {
html, body {
min-height: 100vh;
min-height: 100dvh;
font-family: Helvetica, Arial, sans-serif;
color: var(--bodyText);
font-size: 16px;
@@ -2174,11 +2176,11 @@ body.landing .top-btn-text {
}
.top-bar-notifications-list li .user-image span.icon {
font-size: 30px;
width: 30px;
height: 30px;
margin-inline-start: -15px;
margin-top: -15px;
font-size: 48px;
width: 48px;
height: 48px;
margin-inline-start: -24px;
margin-top: -24px;
}
.top-bar-notifications-list li .how-long-ago {
@@ -3359,7 +3361,9 @@ html.menu-fullscreen-visible {
bottom: 0;
right: 0;
height: 100vh;
height: 100dvh;
width: 100vw;
width: 100dvw;
overflow: auto;
}
@@ -4439,6 +4443,7 @@ img.user-image.size-40, .default-user-image.size-40 {
transform: translateY(-5px);
transform-origin: top;
max-height: 100vh;
max-height: 100dvh;
}
[role="menu"].opened>.menu-box {
@@ -4621,7 +4626,7 @@ img.user-image.size-40, .default-user-image.size-40 {
}
.arrow-navigator a {
color: var(--bodyBackground);
color: var(--colorAccent);
display: block;
text-decoration: none;
text-align: center;

View File

@@ -2403,10 +2403,9 @@ jQuery.fn.highlight = function (color) {
$(this)
.css({
background: "",
backgroundColor: fadecolor,
borderColor: window.getComputedStyle(document.body).getPropertyValue('--colorAccent')
backgroundColor: fadecolor
})
.animate({ backgroundColor: base_background_color, borderColor: "" }, 1000, function () {
.animate({ backgroundColor: base_background_color}, 1000, function () {
$(this).css("background", "");
});
return this;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -15,7 +15,9 @@ html.powered-by-footer .upload-box-inner {
body.landing {
min-height: 500px;
height: calc(100%);
height: 100%;
height: 100vh;
height: 100dvh;
padding: 0;
margin: 0;
}
@@ -707,18 +709,22 @@ html.--idle .list-item-image-tools>div[data-action="viewer-close"], .list-item-i
display: none;
}
.unsafe-blur-on [data-flag="unsafe"] .image-container, .unsafe-blur-on .list-item .list-item-thumbs div[data-flag="unsafe"] a {
.unsafe-blur-on [data-flag="unsafe"]:not(.current) .image-container,
.unsafe-blur-on .list-item .list-item-thumbs div[data-flag="unsafe"] a {
filter: blur(8px);
-webkit-filter: blur(8px);
}
.unsafe-blur-on [data-flag="unsafe"]:not(.selected):not(.ui-selecting) .image-container, .unsafe-blur-on .list-item .list-item-thumbs div[data-flag="unsafe"]:not(.selected):not(.ui-selecting) a {
.unsafe-blur-on [data-flag="unsafe"]:not(.selected):not(.ui-selecting):not(.current) .image-container,
.unsafe-blur-on .list-item .list-item-thumbs div[data-flag="unsafe"]:not(.selected):not(.ui-selecting) a {
transform: scale(1.2);
}
.unsafe-blur-on [data-flag="unsafe"]:hover .image-container, .unsafe-blur-on .list-item:hover .list-item-thumbs div[data-flag="unsafe"] a {
.unsafe-blur-on [data-flag="unsafe"]:hover:not(.selected):not(.ui-selecting):not(.current) .image-container,
.unsafe-blur-on .list-item:hover .list-item-thumbs div[data-flag="unsafe"] a {
filter: none;
-webkit-filter: none;
transform: scale(1);
}
.list-item-buttons>div, .list-item-image-tools>div, .list-item-image-tools>div .btn-icon {
@@ -961,6 +967,7 @@ body.split #home-cover, body.landing #home-cover {
margin: 0;
padding: 0;
height: 100vh;
height: 100dvh;
}
body.split #home-cover {
@@ -1232,6 +1239,7 @@ body#maintenance, body#consent-screen {
background: rgba(0, 0, 0, 0.25);
width: 100%;
height: 100vh;
height: 100dvh;
}
#maintenance-cover-content, #consent-screen-cover-content {
@@ -1593,7 +1601,9 @@ body.--viewer-shown {
.viewer-content img {
position: absolute;
max-height: 100vh;
max-height: 100dvh;
max-width: 100vw;
max-width: 100dvw;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
@@ -1601,7 +1611,9 @@ body.--viewer-shown {
.viewer[data-cover="1"] .viewer-content img {
width: 100vw;
width: 100dvw;
height: 100vh;
height: 100dvh;
-o-object-fit: cover;
object-fit: contain;
}
@@ -2258,7 +2270,9 @@ a.login-provider-button--qq {
body.full--wh {
height: 100vh;
height: 100dvh;
width: 100vw;
width: 100dvw;
}
.display-flex #home-cover-slideshow {

File diff suppressed because one or more lines are too long

View File

@@ -1,142 +0,0 @@
<?php
use Chevereto\Legacy\Classes\Login;
use Chevereto\Legacy\Classes\Settings;
use function Chevereto\Legacy\G\get_base_url;
use Chevereto\Legacy\G\Handler;
use function Chevereto\Legacy\G\safe_html;
use function Chevereto\Legacy\get_select_options_html;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
}
echo read_the_docs_settings('homepage', _s('Homepage')); ?>
<div class="input-label">
<label for="homepage_style"><?php _se('Style'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="homepage_style" id="homepage_style" class="text-input" data-combo="home-style-combo">
<?php
echo get_select_options_html([
'landing' => _s('Landing page'),
'split' => _s('Split landing + images'),
'route_explore' => _s('Route %s', _s('explore')),
'route_upload' => _s('Route %s', _s('upload')),
], Settings::get('homepage_style')); ?>
</select></div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_style'] ?? ''; ?></div>
<div class="input-below"><?php _se('Select the homepage style. To customize it further edit app/themes/%s/views/index.php', Settings::get('theme')); ?></div>
</div>
<div id="home-style-combo">
<div data-combo-value="landing split" class="switch-combo<?php if (!in_array((Handler::var('safe_post') ? Handler::var('safe_post')['homepage_style'] : Settings::get('homepage_style')), ['split', 'landing'])) {
echo ' soft-hidden';
} ?>">
<?php
foreach (Settings::get('homepage_cover_images') ?? [] as $k => $v) {
$cover_index = $k + 1;
$cover_label = 'homepage_cover_image_' . $k;
$coverName = _s('Cover image') . ' (' . $cover_index . ')'; ?>
<div class="input-label">
<label for="<?php echo $cover_label; ?>"><?php echo $coverName; ?></label>
<div class="transparent-canvas dark margin-bottom-10" style="max-width: 200px;"><img class="display-block" width="100%" src="<?php echo $v['url']; ?>"></div>
<?php if (count(Settings::get('homepage_cover_images')) > 1) {
?>
<div class="margin-top-10 margin-bottom-10">
<a class="btn btn-small default" data-confirm="<?php _se("Do you really want to delete?"); ?> <?php _se("This can't be undone."); ?>" href="<?php echo get_base_url('dashboard/settings/homepage?action=delete-cover&cover=' . $cover_index); ?>"><i class="fas fa-trash-alt margin-right-5"></i><?php _se('Delete %s', $coverName); ?></a>
</div>
<?php
} ?>
<div class="c5 phablet-c1">
<input id="<?php echo $cover_label; ?>" name="<?php echo $cover_label; ?>" type="file" accept="image/*">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_cover_image_' . $k] ?? ''; ?></div>
</div>
<?php
} ?>
<div class="input-label">
<label for="homepage_cover_image_add"><?php _se('Add new cover image'); ?></label>
<div class="c5 phablet-c1">
<input id="homepage_cover_image_add" name="homepage_cover_image_add" type="file" accept="image/*">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_cover_image_add'] ?? ''; ?></div>
</div>
<hr class="line-separator">
<div class="input-label">
<label for="homepage_title_html"><?php _se('Title'); ?></label>
<div class="c12 phablet-c1"><textarea type="text" name="homepage_title_html" id="homepage_title_html" class="text-input r2 resize-vertical" placeholder="<?php echo safe_html(_s('This will be added inside the homepage %s tag. Leave it blank to use the default contents.', '<h1>')); ?>"><?php echo Settings::get('homepage_title_html'); ?></textarea></div>
</div>
<div class="input-label">
<label for="homepage_paragraph_html"><?php _se('Paragraph'); ?></label>
<div class="c12 phablet-c1"><textarea type="text" name="homepage_paragraph_html" id="homepage_paragraph_html" class="text-input r2 resize-vertical" placeholder="<?php echo safe_html(_s('This will be added inside the homepage %s tag. Leave it blank to use the default contents.', '<p>')); ?>"><?php echo Settings::get('homepage_paragraph_html'); ?></textarea></div>
</div>
<hr class="line-separator">
<div class="input-label">
<label for="homepage_cta_color"><?php _se('Call to action button color'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="homepage_cta_color" id="homepage_cta_color" class="text-input">
<?php
echo get_select_options_html(
[
'blue' => _s('Blue'),
'green' => _s('Green'),
'orange' => _s('Orange'),
'red' => _s('Red'),
'grey' => _s('Grey'),
'black' => _s('Black'),
'white' => _s('White'),
'default' => _s('Default'),
],
Handler::var('safe_post')
? Handler::var('safe_post')['homepage_cta_color']
: Settings::get('homepage_cta_color')
); ?>
</select></div>
<div class="input-below input-warning red-warning clear-both"><?php echo Handler::var('input_errors')['homepage_cta_color'] ?? ''; ?></div>
<div class="input-below"><?php _se('Color of the homepage call to action button.'); ?></div>
</div>
<div class="input-label">
<label for="homepage_cta_outline"><?php _se('Call to action outline style button'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="homepage_cta_outline" id="homepage_cta_outline" class="text-input">
<?php
echo get_select_options_html([1 => _s('Enabled'), 0 => _s('Disabled')], Settings::get('homepage_cta_outline')); ?>
</select></div>
<div class="input-below input-warning red-warning clear-both"><?php echo Handler::var('input_errors')['homepage_cta_outline'] ?? ''; ?></div>
<div class="input-below"><?php _se('Enable this to use outline style for the homepage call to action button.'); ?></div>
</div>
<div class="input-label">
<label for="homepage_cta_fn"><?php _se('Call to action functionality'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="homepage_cta_fn" id="homepage_cta_fn" class="text-input" data-combo="cta-fn-combo">
<?php
echo get_select_options_html([
'cta-upload' => _s('Trigger uploader'),
'cta-link' => _s('Open URL'),
], Settings::get('homepage_cta_fn')); ?>
</select></div>
<div class="input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_cta_fn'] ?? ''; ?></div>
</div>
<div id="cta-fn-combo">
<div data-combo-value="cta-link" class="switch-combo<?php if ((Handler::var('safe_post') ? Handler::var('safe_post')['homepage_cta_fn'] : Settings::get('homepage_cta_fn')) !== 'cta-link') {
echo ' soft-hidden';
} ?>">
<div class="input-label">
<label for="homepage_cta_fn_extra"><?php _se('Call to action URL'); ?></label>
<div class="c9 phablet-c1"><input type="text" name="homepage_cta_fn_extra" id="homepage_cta_fn_extra" class="text-input" value="<?php echo Settings::get('homepage_cta_fn_extra'); ?>" placeholder="<?php _se('Enter an absolute or relative URL'); ?>" <?php echo ((Handler::var('safe_post') ? Handler::var('safe_post')['homepage_cta_fn'] : Settings::get('homepage_cta_fn')) !== 'cta-link') ? 'data-required' : 'required'; ?>></div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_cta_fn_extra'] ?? ''; ?></div>
<div class="input-below"><?php _se('A relative URL like %r will be mapped to %l', ['%r' => 'page/welcome', '%l' => get_base_url('page/welcome')]); ?></div>
</div>
</div>
</div>
<div class="input-label">
<label for="homepage_cta_html"><?php _se('Call to action HTML'); ?></label>
<div class="c12 phablet-c1"><textarea type="text" name="homepage_cta_html" id="homepage_cta_html" class="text-input r2 resize-vertical" placeholder="<?php echo safe_html(_s('This will be added inside the call to action <a> tag. Leave it blank to use the default contents.')); ?>"><?php echo Settings::get('homepage_cta_html'); ?></textarea></div>
</div>
</div>
<div data-combo-value="split" class="switch-combo<?php if ((Handler::var('safe_post') ? Handler::var('safe_post')['homepage_style'] : Settings::get('homepage_style')) !== 'split') {
echo ' soft-hidden';
} ?>">
<div class="input-label">
<label for="homepage_uids"><?php _se('User IDs'); ?></label>
<div class="c4"><input type="text" name="homepage_uids" id="homepage_uids" class="text-input" value="<?php echo Settings::get('homepage_uids'); ?>" placeholder="<?php _se('Empty'); ?>" rel="tooltip" title="<?php _se('Your user id is: %s', Login::getUser()['id']); ?>" data-tipTip="right"></div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['homepage_uids'] ?? ''; ?></div>
<div class="input-below"><?php _se('Comma-separated list of target user IDs (integers) to show most recent images on homepage. Leave it empty to display trending images.'); ?></div>
</div>
</div>
</div>

View File

@@ -1,71 +0,0 @@
<?php
use Chevereto\Legacy\Classes\Settings;
use Chevereto\Legacy\G\Handler;
use function Chevereto\Legacy\G\random_string;
use function Chevereto\Legacy\get_select_options_html;
use function Chevereto\Legacy\get_system_image_url;
use function Chevereto\Vars\env;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
}
echo read_the_docs_settings('logo', _s('Logo')); ?>
<div class="input-label">
<label for="logo_type"><?php _se('Logo'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="logo_type" id="logo_type" class="text-input" data-combo="logo-combo">
<?php
echo get_select_options_html(
['vector' => _s('Vector'), 'image' => _n('Image', 'Images', 1), 'text' => _s('Text')],
Handler::var('safe_post') ? Handler::var('safe_post')['logo_type'] : Settings::get('logo_type')
); ?>
</select></div>
<div class="input-below input-warning red-warning clear-both"><?php echo Handler::var('input_errors')['logo_type'] ?? ''; ?></div>
<div class="input-below clear-both"><?php _se('Text option uses the website name as logo.'); ?></div>
</div>
<div id="logo-combo">
<?php
$logoType = Handler::var('safe_post') && (bool) env()['CHEVERETO_ENABLE_LOGO']
? Handler::var('safe_post')['logo_type']
: Settings::get('logo_type');
$logoComboVisibility = function (string ...$try) use ($logoType): string {
return !in_array($logoType, $try)
? ' soft-hidden'
: '';
}
?>
<div data-combo-value="vector" class="input-label switch-combo<?php echo $logoComboVisibility('vector'); ?>">
<label for="logo_vector"><?php _se('Logo vector'); ?></label>
<div class="transparent-canvas dark margin-bottom-10" style="max-width: 200px;"><img class="display-block" width="100%" src="<?php echo get_system_image_url(Settings::get('logo_vector')) . '?' . random_string(8); ?>"></div>
<div class="c5 phablet-c1">
<input id="logo_vector" name="logo_vector" type="file" accept="image/svg">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['logo_vector'] ?? ''; ?></div>
<div class="input-below"><?php _se('Vector version or your website logo in SVG format.'); ?></div>
</div>
<div data-combo-value="image" class="input-label switch-combo<?php echo $logoComboVisibility('image'); ?>">
<label for="logo_image"><?php _se('Logo image'); ?></label>
<div class="transparent-canvas dark margin-bottom-10" style="max-width: 200px;"><img class="display-block" width="100%" src="<?php echo get_system_image_url(Settings::get('logo_image')) . '?' . random_string(8); ?>"></div>
<div class="c5 phablet-c1">
<input id="logo_image" name="logo_image" type="file" accept="image/*">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['logo_image'] ?? ''; ?></div>
<div class="input-below"><?php _se('Bitmap version or your website logo. PNG format is recommended.'); ?></div>
</div>
<div data-combo-value="vector image" class="input-label switch-combo<?php echo $logoComboVisibility('vector', 'image'); ?>">
<label for="theme_logo_height"><?php _se('Logo height'); ?></label>
<div class="c4"><input type="number" min="0" pattern="\d+" name="theme_logo_height" id="theme_logo_height" class="text-input" value="<?php echo Settings::get('theme_logo_height'); ?>" placeholder="<?php _se('No value'); ?>"></div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['theme_logo_height'] ?? ''; ?></div>
<div class="input-below"><?php _se('Use this to set the logo height if needed.'); ?></div>
</div>
</div>
<hr class="line-separator">
<div class="input-label">
<label for="favicon_image"><?php _se('Favicon image'); ?></label>
<div class="transparent-canvas dark margin-bottom-10" style="max-width: 100px;"><img class="display-block" width="100%" src="<?php echo get_system_image_url(Settings::get('favicon_image')) . '?' . random_string(8); ?>"></div>
<div class="c5 phablet-c1">
<input id="favicon_image" name="favicon_image" type="file" accept="image/*">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['favicon_image'] ?? ''; ?></div>
<div class="input-below"><?php _se('Favicon image. Image must have same width and height.'); ?></div>
</div>

View File

@@ -1,127 +0,0 @@
<?php
use Chevereto\Legacy\Classes\Image;
use Chevereto\Legacy\Classes\Settings;
use Chevereto\Legacy\G\Handler;
use function Chevereto\Legacy\G\random_string;
use function Chevereto\Legacy\get_checkbox_html;
use function Chevereto\Legacy\get_select_options_html;
use function Chevereto\Legacy\get_system_image_url;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
}
echo read_the_docs_settings('watermarks', _s('Watermarks')); ?>
<div class="input-label">
<label for="watermark_enable"><?php _se('Watermarks'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="watermark_enable" id="watermark_enable" class="text-input" data-combo="watermark-combo">
<?php
echo get_select_options_html([1 => _s('Enabled'), 0 => _s('Disabled')], Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable'] : Settings::get('watermark_enable')); ?>
</select></div>
<div class="input-below input-warning red-warning clear-both"><?php echo Handler::var('input_errors')['watermark_enable'] ?? ''; ?></div>
<div class="input-below"><?php _se('Enable this to put a logo or anything you want in image uploads.'); ?></div>
</div>
<div id="watermark-combo">
<div data-combo-value="1" class="switch-combo phablet-c1<?php if ((Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable'] : Settings::get('watermark_enable')) != 1) {
echo ' soft-hidden';
} ?>">
<div class="input-label">
<label for="watermark_checkboxes"><?php _se('Watermark user toggles'); ?></label>
<?php echo get_checkbox_html([
'name' => 'watermark_enable_guest',
'label' => _s('Enable watermark on guest uploads'),
'checked' => ((bool) (Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable_guest'] : Settings::get('watermark_enable_guest'))),
]); ?>
<?php echo get_checkbox_html([
'name' => 'watermark_enable_user',
'label' => _s('Enable watermark on user uploads'),
'checked' => ((bool) (Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable_user'] : Settings::get('watermark_enable_user'))),
]); ?>
<?php echo get_checkbox_html([
'name' => 'watermark_enable_admin',
'label' => _s('Enable watermark on admin uploads'),
'checked' => ((bool) (Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable_admin'] : Settings::get('watermark_enable_admin'))),
]); ?>
</div>
<div class="input-label">
<label for="watermark_checkboxes"><?php _se('Watermark file toggles'); ?></label>
<?php echo get_checkbox_html([
'name' => 'watermark_enable_file_gif',
'label' => _s('Enable watermark on GIF image uploads'),
'checked' => ((bool) (Handler::var('safe_post') ? Handler::var('safe_post')['watermark_enable_file_gif'] : Settings::get('watermark_enable_file_gif'))),
]); ?>
<p class="highlight padding-5 display-inline-block"><i class="fas fa-exclamation-triangle"></i> <?php _se("Animated images won't be watermarked."); ?></p>
</div>
<div class="input-label">
<label for="watermark_target_min_width" class="display-block-forced"><?php _se('Minimum image size needed to apply watermark'); ?></label>
<div class="c5 overflow-auto clear-both">
<div class="c2 float-left">
<input type="number" min="0" pattern="\d+" name="watermark_target_min_width" id="watermark_target_min_width" class="text-input" value="<?php echo Handler::var('safe_post')['watermark_target_min_width'] ?? Settings::get('watermark_target_min_width'); ?>" placeholder="<?php echo Settings::getDefault('watermark_target_min_width'); ?>" rel="tooltip" data-tiptip="top" title="<?php _se('Width'); ?>" required>
</div>
<div class="c2 float-left margin-left-10">
<input type="number" min="0" pattern="\d+" name="watermark_target_min_height" id="watermark_target_min_height" class="text-input" value="<?php echo Handler::var('safe_post')['watermark_target_min_height'] ?? Settings::get('watermark_target_min_height'); ?>" placeholder="<?php echo Settings::getDefault('watermark_target_min_height'); ?>" rel="tooltip" data-tiptip="top" title="<?php _se('Height'); ?>" required>
</div>
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_target_min_width'] ?? ''; ?></div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_target_min_height'] ?? ''; ?></div>
<div class="input-below"><?php _se("Images smaller than this won't be watermarked. Use zero (0) to don't set a minimum image size limit."); ?></div>
</div>
<div class="input-label">
<?php Image::watermarkFromDb(); ?>
<label for="watermark_image"><?php _se('Watermark image'); ?></label>
<div class="transparent-canvas dark margin-bottom-10" style="max-width: 200px;"><img class="display-block" width="100%" src="<?php echo get_system_image_url(Settings::get('watermark_image')) . '?' . random_string(8); ?>"></div>
<div class="c5 phablet-c1">
<input id="watermark_image" name="watermark_image" type="file" accept="image/png">
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_image'] ?? ''; ?></div>
<div class="input-below">PNG - <?php _se('Max size %s.', '64KB'); ?></div>
</div>
<div class="input-label">
<label for="watermark_position"><?php _se('Watermark position'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="watermark_position" id="watermark_position" class="text-input">
<?php
echo get_select_options_html(
[
'left top' => _s('left top'),
'left center' => _s('left center'),
'left bottom' => _s('left bottom'),
'center top' => _s('center top'),
'center center' => _s('center center'),
'center bottom' => _s('center bottom'),
'right top' => _s('right top'),
'right center' => _s('right center'),
'right bottom' => _s('right bottom'),
],
Handler::var('safe_post')['watermark_position']
?? Settings::get('watermark_position')
); ?>
</select></div>
<div class="input-below input-warning red-warning clear-both"><?php echo Handler::var('input_errors')['watermark_position'] ?? ''; ?></div>
<div class="input-below"><?php _se('Relative position of the watermark image. First horizontal align then vertical align.'); ?></div>
</div>
<div class="input-label">
<label for="watermark_percentage"><?php _se('Watermark percentage'); ?></label>
<div class="c2">
<input type="number" min="1" max="100" pattern="\d+" name="watermark_percentage" id="watermark_percentage" class="text-input" value="<?php echo Handler::var('safe_post')['watermark_percentage'] ?? Settings::get('watermark_percentage'); ?>" placeholder="<?php echo Settings::getDefault('watermark_percentage'); ?>" required>
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_percentage'] ?? ''; ?></div>
<div class="input-below"><?php _se('Watermark percentual size relative to the target image area. Values 1 to 100.'); ?></div>
</div>
<div class="input-label">
<label for="watermark_margin"><?php _se('Watermark margin'); ?></label>
<div class="c2">
<input type="number" min="0" pattern="\d+" name="watermark_margin" id="watermark_margin" class="text-input" value="<?php echo Handler::var('safe_post')['watermark_margin'] ?? Settings::get('watermark_margin'); ?>" placeholder="<?php echo Settings::getDefault('watermark_margin'); ?>" required>
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_margin'] ?? ''; ?></div>
<div class="input-below"><?php _se('Margin from the border of the image to the watermark image.'); ?></div>
</div>
<div class="input-label">
<label for="watermark_opacity"><?php _se('Watermark opacity'); ?></label>
<div class="c2">
<input type="number" min="1" max="100" pattern="\d+" name="watermark_opacity" id="watermark_opacity" class="text-input" value="<?php echo Handler::var('safe_post')['watermark_opacity'] ?? Settings::get('watermark_opacity'); ?>" placeholder="<?php echo Settings::getDefault('watermark_opacity'); ?>" required>
</div>
<div class="input-below input-warning red-warning"><?php echo Handler::var('input_errors')['watermark_opacity'] ?? ''; ?></div>
<div class="input-below"><?php _se('Opacity of the watermark in the final watermarked image. Values 0 to 100.'); ?></div>
</div>
</div>
</div>

View File

@@ -326,7 +326,36 @@
return !(this.getEditorFn() instanceof jQuery);
}
},
smf: {
// smf2: { // 2.1
// settings: {
// html: ' <a %x class="%bClass sceditor-button" unselectable="on" title="%text"><div unselectable="on"><span class="%iClass">%iconSvg</span></div></a> ',
// css:
// ".%bClass>div{background:none;font-size:inherit;color:initial;}",
// sibling: ".sceditor-button-image",
// siblingPos: "after",
// fitEditor: 1
// },
// palettes: {
// default: ["#E7E7E7", "#333", "#B0C4D6", "#333"]
// },
// check: "reqOverlayDiv",
// getEditor: function () {
// var editor = this.getEditorFn();
// if (!editor) {
// return null;
// }
// return editor;
// },
// getEditorFn: function () {
// var editor = document.querySelector(".sceditor-container textarea");
// if (editor) {
// return editor;
// }
// return null;
// }
// },
smf: { // 2.0
settings: {
html:
' <button %x title="%text" class="%bClass"><span class="%iClass">%iconSvg</span><span class="%tClass">%text</span></button> ',
@@ -1153,4 +1182,4 @@
);
}
PUP.prepare();
})();
})();