Automatic push 4.1.3

This commit is contained in:
chevereto
2024-05-13 19:53:04 +00:00
parent 1202d38387
commit 3059e4843d
46 changed files with 4873 additions and 1675 deletions

View File

@@ -1,20 +0,0 @@
Chevereto 4.1.2 (2024-05-06)
- 🎥 Added support for custom FFmpeg and FFprobe binaries
- 🎥 Improved video display on listings and viewer
- ✅ Improved embed codes display
- ✅ Improved upgrading in systems without passthru
- 🖼️ Improved compatibility with jpg extension
- 🐘 Added Dashboard section for PHP configuration (ini files)
- 💅 Added feedback on CLI update command
- 💅 Added remark on Homepage settings when conflicts with single profile routing
- 💅 Fixed file references on /album
- 💅 Improved style for user settings button
- 💅 Improved style for user top menu
- 🐞 Fixed bug affecting album password when using encryption
- 🐞 Fixed bug affecting full screen video behavior
- 🐞 Fixed bug affecting not working URL upload editing
- 🐞 Fixed bug affecting wrong video image frame permissions
- 🐞 Fixed bug in album embed codes
- 🐞 Fixed bug in password protected album editing on listings
- 🐞 Fixed bug in Search class

19
.package/4.1.3.txt Normal file
View File

@@ -0,0 +1,19 @@
Chevereto 4.1.3 (2024-05-13)
- ✅ Added configurable view for user profiles
- ✅ Added failover for missing image sizes
- ✅ Force 0644 permission for medium and thumb sizes
- ✅ One-click upgrading process now clears previous locks
- 🐋 Added upgrade instructions when using Docker
- 🐋 Disabled app upgrading when using Docker
- 🐋 Disabled license key handling when using Docker
- 🌏 Updated Chinese Simplified and Vietnamese translations
- 🐞 Fixed bug affecting available upgrade modal link
- 🐞 Fixed bug affecting Homepage custom paragraph
- 🐞 Fixed bug affecting max image size setting
- 🐞 Fixed bug affecting share modal
- 🐞 Fixed bug affecting user background picture
- 🐞 Fixed bug affecting website mode personal showing menu links
- 🐞 Fixed bug causing open_basedir issues
- 🐞 Fixed bug with Image class breaking update
- 🐘 Updated dependencies

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

36
app/composer.lock generated
View File

@@ -2137,16 +2137,16 @@
},
{
"name": "paragonie/constant_time_encoding",
"version": "v2.6.3",
"version": "v2.7.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "58c3f47f650c94ec05a151692652a868995d2938"
"reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938",
"reference": "58c3f47f650c94ec05a151692652a868995d2938",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/52a0d99e69f56b9ec27ace92ba56897fe6993105",
"reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105",
"shasum": ""
},
"require": {
@@ -2200,7 +2200,7 @@
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding"
},
"time": "2022-06-14T06:56:20+00:00"
"time": "2024-05-08T12:18:48+00:00"
},
{
"name": "paragonie/random_compat",
@@ -2872,20 +2872,20 @@
},
{
"name": "psr/http-factory",
"version": "1.0.2",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "e616d01114759c4c489f93b099585439f795fe35"
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35",
"reference": "e616d01114759c4c489f93b099585439f795fe35",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
@@ -2909,7 +2909,7 @@
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interfaces for PSR-7 HTTP message factories",
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
@@ -2921,9 +2921,9 @@
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory/tree/1.0.2"
"source": "https://github.com/php-fig/http-factory"
},
"time": "2023-04-10T20:10:41+00:00"
"time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
@@ -5317,16 +5317,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.10.67",
"version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493"
"reference": "666cb1703742cea9cc80fee631f0940e1592fa6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493",
"reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/666cb1703742cea9cc80fee631f0940e1592fa6e",
"reference": "666cb1703742cea9cc80fee631f0940e1592fa6e",
"shasum": ""
},
"require": {
@@ -5371,7 +5371,7 @@
"type": "github"
}
],
"time": "2024-04-16T07:22:02+00:00"
"time": "2024-05-13T06:02:22+00:00"
},
{
"name": "phpunit/php-code-coverage",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -605,6 +605,9 @@ $settings_updates = [
'upload_enabled_image_formats' => 'jpg,png,bmp,gif,webp,mov,mp4,webm',
],
'4.1.2' => null,
'4.1.3' => [
'user_profile_view' => 'files',
],
];
$cheveretoFreeMap = [
'1.0.0' => '3.8.3',
@@ -2154,7 +2157,7 @@ EOT;
$envDotPhp->file()->create();
$envDotPhp->file()->put($envDotPhpContents);
$doing = 'ready';
} catch (Throwable $e) {
} catch (Throwable) {
$doing = 'env';
}
}

View File

@@ -9,5 +9,5 @@
* file that was distributed with this source code.
*/
const APP_VERSION = '4.1.2';
const APP_VERSION = '4.1.3';
const APP_VERSION_AKA = 'pulento';

View File

@@ -54,8 +54,10 @@ function filesystemPermissionsCheck(): void
if (!file_exists($v)) {
try {
mkdir($v);
} catch (Throwable $e) {
$errors[] = "<code>" . absolute_to_relative($v) . "</code> doesn't exists. Make sure to upload it.";
} catch (Throwable) {
$errors[] = "<code>"
. absolute_to_relative($v)
. "</code> doesn't exists and can't be created.";
}
} else {
if (!is_writable($v)) {

View File

@@ -216,6 +216,10 @@ $hook_before = function (Handler $handler) {
}
}
if (getSetting('website_mode') == 'personal') {
$userMapPaths = ['search'];
$userMapPaths[] = getSetting('user_profile_view') == 'files'
? 'albums'
: 'files';
if ($handler->request_array()[0] == '/'
&& getSetting('website_mode_personal_routing') == '/'
&& in_array(key($querystr), ['random'])
@@ -227,7 +231,7 @@ $hook_before = function (Handler $handler) {
$handler->mapRoute('search');
} elseif ($handler->request_array()[0] == getSetting('website_mode_personal_routing')
|| (getSetting('website_mode_personal_routing') == '/'
&& in_array($handler->request_array()[0], ['albums', 'search']))
&& in_array($handler->request_array()[0], $userMapPaths))
) {
$handler->mapRoute('user', [
'id' => getSetting('website_mode_personal_uid'),
@@ -342,7 +346,7 @@ $hook_before = function (Handler $handler) {
$categories[$key] = DB::formatRow($categories[$key]);
}
}
} catch (Throwable $e) {
} catch (Throwable) {
}
}
if ($handler::cond('explore_enabled')

View File

@@ -50,7 +50,7 @@ return function (Handler $handler) {
$action = $handler->request()[1] ?? null;
$key = $SERVER['HTTP_X_API_KEY'] ?? $REQUEST['key'] ?? null;
foreach (['version', 'action', 'key'] as $var) {
if ($$var === null) {
if (${$var} === null) {
throw new Exception("No $var provided", 100);
}
}

View File

@@ -49,7 +49,7 @@ return function (Handler $handler) {
sessionVar()->put('isHuman', $isSuccess);
sessionVar()->put('isBot', !$isSuccess);
die($fetch);
} catch (Exception $e) {
} catch (Exception) {
}
die();
};

View File

@@ -93,11 +93,15 @@ return function (Handler $handler) {
if (!is_dir($upgradingDir)) {
mkdir($upgradingDir);
}
$upgradingLock = $upgradingDir . 'upgrading.lock';
unlinkIfExists($upgradingLock);
$lockUpgrading = $upgradingDir . 'upgrading.lock';
$lockDownloading = $upgradingDir . 'downloading.lock';
$lockExtracting = $upgradingDir . 'extracting.lock';
unlinkIfExists($lockUpgrading);
unlinkIfExists($lockDownloading);
unlinkIfExists($lockExtracting);
$token = randomString(128);
touch($upgradingLock);
file_put_contents($upgradingLock, $token);
touch($lockUpgrading);
file_put_contents($lockUpgrading, $token);
$params = [
'action' => 'download',
'token' => $token,
@@ -352,9 +356,11 @@ return function (Handler $handler) {
];
$links = [];
$linksButtons = '';
$licenseKey = getLicenseKey();
$handler::setVar('licenseKey', $licenseKey);
if (env()['CHEVERETO_CONTEXT'] !== 'saas') {
$licenseKey = '';
if (env()['CHEVERETO_CONTEXT'] !== 'saas'
&& (env()['CHEVERETO_SERVICING'] ?? null) !== 'docker'
) {
$licenseKey = getLicenseKey();
$upgradeClass = 'hidden';
$upgradeLink = get_base_url('dashboard/upgrade/?auth_token=' . $handler::getAuthToken());
if ($licenseKey !== '' && env()['CHEVERETO_EDITION'] === 'free') {
@@ -378,6 +384,7 @@ return function (Handler $handler) {
],
]);
}
$handler::setVar('licenseKey', $licenseKey);
if (env()['CHEVERETO_CONTEXT'] === 'saas') {
$links = array_merge($links, [
[
@@ -1453,9 +1460,8 @@ return function (Handler $handler) {
}
if (isset($POST['website_mode']) && $POST['website_mode'] == 'personal' && isset($POST['website_mode_personal_routing'])) {
if ($logged_user['id'] == $POST['website_mode_personal_uid']) {
$new_user_url = get_base_url($POST['website_mode_personal_routing'] !== '/' ? $POST['website_mode_personal_routing'] : '');
Login::setUser('url', get_base_url($POST['website_mode_personal_routing'] !== '/' ? $POST['website_mode_personal_routing'] : ''));
Login::setUser('url_albums', User::getUrlAlbums(Login::getUser()['url']));
Login::setUser('url_albums', User::getUrlPath(Login::getUser()['url'], 'albums'));
} elseif (User::getSingle($POST['website_mode_personal_uid']) === []) { // Is a valid user id anyway?
$validations['website_mode_personal_uid'] = [
'validate' => false,
@@ -1564,7 +1570,7 @@ return function (Handler $handler) {
try {
$verifyAkismet = $akismet->verifyKey();
} catch (Throwable $e) {
} catch (Throwable) {
$verifyAkismet = false;
}
$validations['akismet_api_key'] = [
@@ -1799,15 +1805,11 @@ return function (Handler $handler) {
break;
}
if ($doing != 'stats') {
if ($doing !== 'stats') {
$pre_doctitle[] = $routesLinkLabels[$doing];
if ($doing == 'settings' && isset($settings_sections)) {
reset($settings_sections);
$firstKey = key($settings_sections);
$dashSettingsProp = $handler::var('settings');
if ($dashSettingsProp['key'] != $firstKey) {
$pre_doctitle[] = $dashSettingsProp['title'];
}
$pre_doctitle[] = $dashSettingsProp['title'];
}
}
$pre_doctitle[] = _s('Dashboard');

View File

@@ -30,9 +30,13 @@ return function (Handler $handler) {
return;
}
$doing = $handler->request()[0] ?? null;
if (!isset($doing) && getSetting('homepage_style') == 'route_explore' && strpos(get_current_url(), get_base_url(get_route_name())) !== false) {
$redir = str_replace_first(get_base_url(get_route_name()), get_base_url(), get_current_url());
redirect($redir);
$baseUrlRouteName = get_base_url(get_route_name());
if (!isset($doing)
&& getSetting('homepage_style') == 'route_explore'
&& str_contains(get_current_url(), $baseUrlRouteName)
) {
$redirect = str_replace_first($baseUrlRouteName, get_base_url(), get_current_url());
redirect($redirect);
}
$explore_semantics = $handler::var('explore_semantics');
if (isset($doing) && !array_key_exists($doing, $explore_semantics)) {

View File

@@ -281,17 +281,19 @@ return function (Handler $handler) {
$sharing['%' . strtoupper($imageKey) . '%'] = $imageValue;
}
$embed = [];
$hasFrame = $image['url_frame'] !== '';
$hasMedium = $image['medium']['url'] !== null;
$hasSizes = [
'frame' => $image['url_frame'] !== '',
'medium' => $image['medium']['url'] !== null,
'thumb' => $image['thumb']['url'] !== null,
];
foreach ($embed_share_tpl as $code => $group) {
$entries = [];
$groupLabel = $group['label'];
foreach ($group['options'] as $option => $optionValue) {
if (!$hasFrame && str_starts_with($option, 'frame-')) {
continue;
}
if (!$hasMedium && str_starts_with($option, 'medium-')) {
continue;
foreach ($hasSizes as $sizeKey => $sizeValue) {
if (!$sizeValue && str_starts_with($option, $sizeKey . '-')) {
continue 2;
}
}
$value = $optionValue['template'];
if (is_array($value)) {

View File

@@ -113,18 +113,9 @@ return function (Handler $handler) {
'thumbnail_height' => $display_height,
]);
}
switch (get()['format'] ?? '') {
case 'xml':
xml_output(['oembed' => $data]);
break;
case 'json':
default:
json_output($data);
break;
}
match (get()['format'] ?? '') {
'xml' => xml_output(['oembed' => $data]),
default => json_output($data),
};
die();
};

View File

@@ -91,7 +91,7 @@ return function (Handler $handler) {
$listing->setOutputTpl($search->type);
$listing->exec();
$handler::setVar('listing', $listing);
} catch (Exception $e) {
} catch (Exception) {
$getParams = [];
}
$tabs = Listing::getTabs([

View File

@@ -208,7 +208,7 @@ return function (Handler $handler) {
$mail['subject'] = _s('Welcome to %s', getSetting('website_name'));
$mail['message'] = get_email_body_str('mails/account-welcome');
send_mail($logged_user['email'], $mail['subject'], $mail['message']);
} catch (Exception $e) {
} catch (Exception) {
} // Silence
redirect($user['url']);
}
@@ -225,7 +225,7 @@ return function (Handler $handler) {
'type' => 'signup',
'result' => 'fail'
]);
$error_message = $error_message ?? _s('Check the errors in the form to continue.');
$error_message ??= _s('Check the errors in the form to continue.');
if ((getSetting('captcha') ?? false) && must_use_captcha($failed_access_requests['day'] + 1)) {
$captcha_needed = true;
}

View File

@@ -40,16 +40,25 @@ return function (Handler $handler) {
$request_handle = $userIndex === 0
? $handler->requestArray()
: $handler->request();
$userMapPaths = ['search', 'following', 'followers'];
$userMapPaths[] = getSetting('user_profile_view') == 'files'
? 'albums'
: 'files';
if (getSetting('website_mode') == 'personal'
&& getSetting('website_mode_personal_routing') == '/'
&& in_array($request_handle[0], ['albums', 'search', 'following', 'followers'])
&& $request_handle[0] !== '/'
) {
if (!in_array($request_handle[0], $userMapPaths)) {
$handler->issueError(404);
return;
}
$personal_mode_user = User::getSingle(getSetting('website_mode_personal_uid'));
if ($personal_mode_user !== []) {
$request_handle = [
0 => $personal_mode_user['username'],
1 => $request_handle[0]
];
0 => $personal_mode_user['username'],
1 => $request_handle[0]
];
}
}
if ($request_handle[0] === getSetting('route_user') && getSetting('root_route') !== 'user') {
@@ -70,7 +79,8 @@ return function (Handler $handler) {
$logged_user = Login::getUser();
User::statusRedirect($logged_user['status'] ?? null);
$userHandle = isset($id) ? 'id' : 'username';
$user = $personal_mode_user ?? User::getSingle($$userHandle, $userHandle);
$user = $personal_mode_user
?? User::getSingle(${$userHandle}, $userHandle);
$is_owner = false;
if (isset($user['id'], $logged_user['id'])) {
$is_owner = $user['id'] == $logged_user['id'];
@@ -102,8 +112,11 @@ return function (Handler $handler) {
}
$pre_doctitle = '';
$user_routes = [];
$userHome = $user['home'] === 'files'
? 'files'
: $user['home'];
$user_views = [
'images' => [
'files' => [
'title' => _s(
"%t by %s",
[
@@ -121,9 +134,13 @@ return function (Handler $handler) {
'title_short' => _s('Search'),
],
];
foreach (array_keys($user_views) as $k) { // Need to use $k => $v to fetch array key easily
$user_routes[] = $k == 'images' ? $username : $k;
foreach (array_keys($user_views) as $k) {
$user_routes[] = $k == $userHome
? $username
: $k;
}
// albums: images, admin, search
// images: admin, albums, search
if (getSetting('enable_likes')) {
$user_views['liked'] = [
'title' => _s("Liked by %s"),
@@ -183,7 +200,7 @@ return function (Handler $handler) {
$user_views[$request_handle[1]]['current'] = true;
}
} else {
$user_views['images']['current'] = true;
$user_views[$userHome]['current'] = true;
}
$user['followed'] = false;
$show_follow_button = false;
@@ -203,14 +220,14 @@ return function (Handler $handler) {
}
$handler::setCond('show_follow_button', $show_follow_button);
$base_user_url = $user['url'];
$type = 'images';
$type = $userHome;
$current_view = $type;
$tools = false;
foreach ($user_views as $k => $v) {
$handler::setCond('user_' . $k, (bool) $v['current']);
if ($v['current']) {
$current_view = $k;
if ($current_view !== 'images') {
if ($current_view !== $userHome) {
$base_user_url .= "/$k";
}
}
@@ -218,7 +235,7 @@ return function (Handler $handler) {
$currentKey = 0;
$safe_html_user = safe_html($user);
switch ($current_view) {
case 'images':
case 'files':
case 'liked':
$type = "images";
$tools = $is_owner || $handler::cond('content_manager');
@@ -276,7 +293,7 @@ return function (Handler $handler) {
break;
}
$icon = [
'images' => 'fas fa-photo-film',
'files' => 'fas fa-photo-film',
'albums' => 'fas fa-images',
'liked' => 'fas fa-heart',
'following' => 'fas fa-rss',
@@ -304,7 +321,7 @@ return function (Handler $handler) {
if (!array_key_exists('params_hidden', $tabs)) {
$tabs[$k]['params_hidden'] = http_build_query($params_hidden);
}
$v['disabled'] = $user[($user_views['images']['current'] ? 'image' : 'album') . '_count'] == 0 ? !$v['current'] : false;
$v['disabled'] = $user[($user_views['files']['current'] ? 'image' : 'album') . '_count'] == 0 ? !$v['current'] : false;
}
$listing = new Listing();
if ($user["image_count"] > 0
@@ -386,7 +403,7 @@ return function (Handler $handler) {
}
$listing->setOutputTpl($output_tpl);
$listing->exec();
} catch (Exception $e) {
} catch (Exception) {
} // Silence to avoid wrong input queries
}
$title = sprintf($user_views[$current_view]['title'], $user['name_short_html']);

View File

@@ -24,13 +24,10 @@ abstract class EntityIo implements EntityIoInterface
{
use GetWhereEqualsTrait;
protected Database $database;
protected string $whereIdClause;
public function __construct(Database $database)
public function __construct(protected Database $database)
{
$this->database = $database;
$this->whereIdClause = $this->getWhereEquals($this->id());
}

View File

@@ -32,7 +32,7 @@ final class Key implements KeyInterface
}
}
public function __toString()
public function __toString(): string
{
return $this->key;
}

View File

@@ -50,7 +50,7 @@ final class HashId
$this->table[] = substr($this->hash, $n, 1);
}
array_multisort($this->table, SORT_DESC, $index);
$this->index = implode($index);
$this->index = implode('', $index);
$this->base = strlen($this->index);
$this->baseString = (string) $this->base;
}

View File

@@ -596,7 +596,7 @@ class Album
COUNT(IF(album_date_gmt >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH), 1, NULL)) AS month
FROM " . DB::getTable('albums') . " WHERE album_creation_ip='" . get_client_ip() . "' AND album_date_gmt >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH)"
);
} catch (Exception $e) {
} catch (Exception) {
$flood_db = false;
} // Silence
if ($flood_db === false) {
@@ -630,7 +630,7 @@ class Album
$addValue = session()['flood_albums_notify'];
$addValue[$flood_by] = true;
sessionVar()->put('flood_albums_notify', $addValue);
} catch (Exception $e) {
} catch (Exception) {
} // Silence
}

View File

@@ -685,7 +685,7 @@ class Image
if (is_array($source) && $params['use_file_date'] && $source['type'] === 'image/jpeg') {
try {
$exifSource = \exif_read_data($source['tmp_name']);
} catch (Throwable $e) {
} catch (Throwable) {
}
if (isset($exifSource['DateTime'])) {
$stockDateGmt = date_create_from_format("Y:m:d H:i:s", $exifSource['DateTime'], new DateTimeZone('UTC'));
@@ -735,7 +735,7 @@ class Image
$dummy_insert = DB::insert('images', $dummy);
DB::delete('images', ['id' => $dummy_insert]);
$target_id = $dummy_insert;
} catch (Throwable $e) {
} catch (Throwable) {
$fileNaming = 'original';
}
}
@@ -821,6 +821,7 @@ class Image
$image_resize_options = ['width' => $params['width']];
}
$image_resize_options['extension'] = $image_upload['uploaded']['extension'];
$image_resize_options['chmod'] = 0644;
$image_upload['uploaded'] = self::resize(
source: $resizeSourceImage,
destination: dirname($resizeSourceImage),
@@ -835,7 +836,8 @@ class Image
'fitted' => true,
'width' => getSetting('upload_thumb_width'),
'height' => getSetting('upload_thumb_height'),
'extension' => $chainExtension
'extension' => $chainExtension,
'chmod' => 0644,
];
$medium_size = getSetting('upload_medium_size');
$medium_fixed_dimension = getSetting('upload_medium_fixed_dimension');
@@ -876,7 +878,9 @@ class Image
$image_upload['uploaded']['fileinfo']['md5'] = $original_md5; // Preserve original MD5 for watermarked images
}
if ($image_upload['uploaded']['fileinfo'][$medium_fixed_dimension] > $medium_size || $is_animated_image) {
$image_medium_options = [];
$image_medium_options = [
'chmod' => 0644,
];
$image_medium_options[$medium_fixed_dimension] = $medium_size;
if ($is_animated_image) {
$image_medium_options['forced'] = true;
@@ -933,7 +937,7 @@ class Image
try {
$renamed_uploaded = rename($downstream, $uploaded_file);
} catch (Throwable $e) {
} catch (Throwable) {
$renamed_uploaded = file_exists($uploaded_file);
}
if (!$renamed_uploaded) {
@@ -958,7 +962,7 @@ class Image
try {
$renamed_chain = rename(${"image_$k"}['file'], $chain_file);
} catch (Throwable $e) {
} catch (Throwable) {
$renamed_chain = file_exists($chain_file);
}
if (!$renamed_chain) {
@@ -1012,7 +1016,7 @@ class Image
$expirable_diff = datetime_diff(datetimegmt(), $params['expiration_date_gmt'], 'm');
$image_insert_values['expiration_date_gmt'] = $expirable_diff < 5 ? datetime_modify(datetimegmt(), '+5 minutes') : $params['expiration_date_gmt'];
}
} catch (Exception $e) {
} catch (Exception) {
} // Silence
}
if (isset($storage_id, $storage)) {
@@ -1503,7 +1507,9 @@ class Image
$image['url_short'] = self::getUrlViewer($image['id_encoded']);
foreach ($targets['chain'] as $k => $v) {
if ($targets['type'] == 'path') {
$image[$k] = file_exists($v) ? get_fileinfo($v) : null;
$image[$k] = file_exists($v)
? get_fileinfo($v)
: null;
} else {
$image[$k] = get_fileinfo($v);
}
@@ -1516,7 +1522,7 @@ class Image
?? '';
$display_width = $image['width'];
$display_height = $image['height'];
if (!empty($image['medium'])) {
if (isset($image['medium']['url'])) {
$display_url = $image['medium']['url'];
$image_ratio = $image['width'] / $image['height'];
switch ($medium_fixed_dimension) {
@@ -1533,10 +1539,11 @@ class Image
}
$displaySize = $image['medium']['size'];
} elseif (
$image['size'] > get_bytes('200 KB')
&& $image['type'] === 1
isset($image['thumb']['url'], $image['thumb']['size'])
&& $image['size'] > get_bytes('200 KB')
&& ($image['type'] ?? 1) === 1
) {
$display_url = $image['thumb']['url'] ?? '';
$display_url = $image['thumb']['url'];
$display_width = getSetting('upload_thumb_width');
$display_height = getSetting('upload_thumb_height');
$displaySize = $image['thumb']['size'];
@@ -1563,8 +1570,15 @@ class Image
'extension' => null,
'url' => null,
];
$image['thumb'] = $image['thumb'] ?? [
'filename' => null,
'name' => null,
'mime' => null,
'extension' => null,
'url' => null,
];
$image['duration_time'] = $duration_time;
$image['type'] = self::$types[$image['type']];
$image['type'] = self::$types[$image['type'] ?? 1];
$image['display_url'] = $display_url;
$image['display_width'] = $display_width;
$image['display_height'] = $display_height;

View File

@@ -113,11 +113,15 @@ class ImageResize
$this->destination = add_ending_slash($this->destination);
$this->resized_file = $this->destination . $this->filename . '.' . $this->file_extension;
$this->resize();
if ($this->options['chmod'] ?? false) {
chmod($this->resized_file, $this->options['chmod']);
}
$this->resized = [
'file' => $this->resized_file,
'filename' => get_filename($this->resized_file),
'name' => get_basename_without_extension($this->resized_file),
'fileinfo' => get_image_fileinfo($this->resized_file),
'extension' => $this->file_extension,
];
}

View File

@@ -213,7 +213,7 @@ class L10n
if (!file_exists($cache_path)) {
try {
mkdir($cache_path);
} catch (Throwable $e) {
} catch (Throwable) {
$cache_path = dirname($cache_path);
}
}

View File

@@ -104,7 +104,7 @@ class Settings
$settings[$v['name']] = $value;
$defaults[$v['name']] = $default;
}
} catch (Exception $e) {
} catch (Exception) {
$settings = [];
$defaults = [];
}
@@ -202,6 +202,7 @@ class Settings
'website_random_guest' => true,
'website_search_guest' => true,
'debug_errors' => false,
'user_profile_view' => 'files',
];
if (env()['CHEVERETO_SERVICING'] === 'docker') {
$stock['xr_host'] = 'host.docker.internal';

View File

@@ -231,7 +231,7 @@ class Upload
if (array_key_exists('exif', $this->options)) {
try {
$this->source_image_exif = $reader->read($this->downstream);
} catch (Throwable $e) {
} catch (Throwable) {
}
if ($this->source_image_exif instanceof Exif) {
$this->source_image_exif->setFileName($this->source_filename);
@@ -291,7 +291,7 @@ class Upload
try {
$uploaded = rename($this->downstream, $this->uploaded_file);
} catch (Throwable $e) {
} catch (Throwable) {
$uploaded = file_exists($this->uploaded_file);
}
unlinkIfExists($this->downstream);
@@ -303,7 +303,7 @@ class Upload
if (!isset($this->storage_id)) {
try {
chmod($this->uploaded_file, 0644);
} catch (Throwable $e) {
} catch (Throwable) {
}
}
$fileInfo = $this->mediaType === 'video'
@@ -481,7 +481,7 @@ class Upload
try {
$renamed = rename($this->source['tmp_name'], $this->downstream);
} catch (Throwable $e) {
} catch (Throwable) {
$renamed = file_exists($this->downstream);
}
if (!$renamed) {
@@ -589,7 +589,7 @@ class Upload
COUNT(IF(image_date_gmt >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH), 1, NULL)) AS month
FROM ' . DB::getTable('images') . " WHERE image_uploader_ip='" . get_client_ip() . "' AND image_date_gmt >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 MONTH)"
);
} catch (Exception $e) {
} catch (Exception) {
$flood_db = [];
} // Silence
if ($flood_db === false) {
@@ -623,7 +623,7 @@ class Upload
$addValues = session()['flood_uploads_notify'] ?? [];
$addValues[$flood_by] = true;
sessionVar()->put('flood_uploads_notify', $addValues);
} catch (Exception $e) {
} catch (Exception) {
} // Silence
}

View File

@@ -213,9 +213,9 @@ class User
return get_base_url($url);
}
public static function getUrlAlbums(string $user_url): string
public static function getUrlPath(string $user_url, string $path): string
{
return rtrim($user_url, '/') . '/albums';
return rtrim($user_url, '/') . '/' . $path;
}
public static function insert(array $values): int
@@ -318,20 +318,23 @@ class User
);
/** @var array $uploaded */
$uploaded = $image_upload['uploaded'];
$extension = $uploaded['extension'];
if ($type == 'avatar') {
$max_res = ['width' => 500, 'height' => 500, 'fitted' => true];
$must_resize = $uploaded['fileinfo']['width'] > $max_res['width']
|| $uploaded['fileinfo']['height'] > $max_res['height'];
$options = ['width' => 500, 'height' => 500, 'fitted' => true];
$must_resize = $uploaded['fileinfo']['width'] > $options['width']
|| $uploaded['fileinfo']['height'] > $options['height'];
} else {
$max_res = ['width' => 1920];
$must_resize = $uploaded['fileinfo']['width'] > $max_res['width'];
$options = ['width' => 1920];
$must_resize = $uploaded['fileinfo']['width'] > $options['width'];
$medium = Image::resize(
$uploaded['file'],
null,
$uploaded['name'] . '.md',
[
source: $uploaded['file'],
destination: null,
filename: $uploaded['name'] . '.md',
options: [
'width' => 500,
'over_resize' => true,
'extension' => $extension,
'chmod' => 0644
]
);
$toStorage[] = [
@@ -341,7 +344,14 @@ class User
];
}
if ($must_resize) {
$uploaded = Image::resize($uploaded['file'], null, null, $max_res);
$options['extension'] = $extension;
$options['chmod'] = 0644;
$uploaded = Image::resize(
source: $uploaded['file'],
destination: null,
filename: null,
options: $options
);
}
$toStorage[] = [
'file' => $uploaded['file'],
@@ -535,16 +545,22 @@ class User
public static function fill(array &$user): void
{
$user['home'] = getSetting('user_profile_view');
$user['palette_id'] = (int) ($user['palette_id'] ?? 0);
$user['id_encoded'] = encodeID((int) ($user['id'] ?? 0));
$user['image_count_display'] = isset($user['image_count']) ? abbreviate_number($user['image_count']) : 0;
$user['album_count_display'] = isset($user['album_count']) ? abbreviate_number($user['album_count']) : 0;
$user['url'] = self::getUrl($user);
$user['public_url'] = get_public_url($user['url']);
$user['url_albums'] = self::getUrlAlbums($user['url']);
$user['url_liked'] = $user['url'] . '/liked';
$user['url_following'] = $user['url'] . '/following';
$user['url_followers'] = $user['url'] . '/followers';
$user['url_images'] = $user['home'] !== 'files'
? self::getUrlPath($user['url'], 'files')
: $user['url'];
$user['url_albums'] = $user['home'] !== 'albums'
? self::getUrlPath($user['url'], 'albums')
: $user['url'];
$user['url_liked'] = get_base_url($user['url'] . '/liked');
$user['url_following'] = get_base_url($user['url'] . '/following');
$user['url_followers'] = get_base_url($user['url'] . '/followers');
if (isset($user['website']) && !is_url_web($user['website'])) {
unset($user['website']);
}

View File

@@ -9,7 +9,6 @@
* file that was distributed with this source code.
*/
namespace Chevereto\Legacy\Classes;
use DOMDocument;
@@ -32,7 +31,7 @@ class XmpMetadataExtractor extends Base
$output['@root'] = $root->tagName;
return $output;
} catch (Throwable $e) {
} catch (Throwable) {
return [];
}
}
@@ -45,7 +44,7 @@ class XmpMetadataExtractor extends Base
}
$xmpDataEnd = (int) strpos($content, '</x:xmpmeta>');
$xmpLength = $xmpDataEnd - $xmpDataStart;
return substr($content, $xmpDataStart, $xmpLength + 12);
}
}

View File

@@ -531,7 +531,7 @@ class Gettext
try {
include_once $this->cache_file;
} catch (Throwable $e) {
} catch (Throwable) {
return false;
}
if (isset($translation_table)) {
@@ -547,7 +547,7 @@ class Gettext
return true;
}
} catch (Throwable $e) {
} catch (Throwable) {
}
$this->is_cached = false;
@@ -594,8 +594,7 @@ class Gettext
try {
touch($this->source_file);
} catch (Throwable $e) {
// Shhh
} catch (Throwable) {
}
fclose($fh);
}

View File

@@ -12,7 +12,6 @@
namespace Chevereto\Legacy\G;
use function Chevere\Message\message;
use Chevere\Throwable\Exceptions\LogicException;
use Chevereto\Config\Config;
use function Chevereto\Legacy\get_captcha_component;
use function Chevereto\Legacy\getSetting;
@@ -24,6 +23,7 @@ use function Chevereto\Vars\session;
use function Chevereto\Vars\sessionVar;
use Closure;
use Exception;
use LogicException;
/** @deprecate V4 */
class Handler
@@ -84,18 +84,18 @@ class Handler
$this->request_uri = str_replace($query_string, '/', $this->request_uri);
}
$this->valid_request = '/' . ltrim(rtrim(sanitize_path_slashes($this->request_uri), '/'), '/');
$theRequest = rtrim(PATH_PUBLIC, '/') . $this->valid_request;
if ($this->valid_request !== '/' && file_exists($theRequest)) {
throw new LogicException('Invalid PHP front controller setup. Review your web server configuration.');
}
if (!empty(server()['QUERY_STRING'])) {
$this->request_uri = server()['REQUEST_URI'];
$this->valid_request .= $query_string;
}
$this->canonical_request = $this->valid_request;
if ((is_dir(PATH_PUBLIC . $this->valid_request)
|| is_dir(dirname(PATH_PUBLIC) . $this->valid_request))
&& $this->valid_request !== '/'
) {
$this->canonical_request .= '/';
}
$this->handled_request = strtok($this->relative_root == '/' ? $this->valid_request : preg_replace('#' . $this->relative_root . '#', '/', $this->request_uri, 1), '?');
$this->handled_request = strtok($this->relative_root == '/'
? $this->valid_request
: preg_replace('#' . $this->relative_root . '#', '/', $this->request_uri, 1), '?');
$this->request_array = explode('/', rtrim(str_replace('//', '/', ltrim($this->handled_request, '/')), '/'));
if ($this->request_array[0] == '') {
$this->request_array[0] = '/';
@@ -226,9 +226,9 @@ class Handler
}
if (is_array($routes) && array_key_exists(self::$base_request, $routes)) {
$magic = [
'post' => post() ? post() : null,
'get' => get() ? get() : null,
'request' => request() ? request() : null,
'post' => post() ?: null,
'get' => get() ?: null,
'request' => request() ?: null,
'safe_post' => post() ? safe_html(post()) : null,
'safe_get' => get() ? safe_html(get()) : null,
'safe_request' => request() ? safe_html(request()) : null,
@@ -306,6 +306,7 @@ class Handler
throw new LogicException(
message('Missing route file %file%')
->withCode('%file%', $route_file)
->__toString()
);
}

View File

@@ -128,7 +128,7 @@ function random_values(int $min, int $max, int $limit): array
}
$array = [];
for ($i = 0; $i < $limit; ++$i) {
$rand = rand($min, $max);
$rand = random_int($min, $max);
while (in_array($rand, $array)) {
$rand = mt_rand($min, $max);
}
@@ -209,7 +209,7 @@ function str_replace_last(string $search, string $replace, string $subject): str
/** @deprecated V4 */
function starts_with(string $needle, string $haystack): bool
{
return substr($haystack, 0, strlen($needle)) === $needle;
return str_starts_with($haystack, $needle);
}
/** @deprecated V4 */
@@ -316,8 +316,9 @@ function abbreviate_number(string|int $number): string
0 => null,
];
foreach ($abbreviations as $exponent => $abbreviation) {
if ($number >= pow(10, $exponent)) {
return round(floatval($number / pow(10, $exponent))) . $abbreviation;
if ($number >= 10 ** $exponent) {
return round(floatval($number / 10 ** $exponent))
. $abbreviation;
}
}
@@ -458,7 +459,7 @@ function linkify(string $text, array $options = []): string
}
}
return implode($chunks);
return implode('', $chunks);
}
function linkify_emails(string $text, array $options = ['attr' => '']): string
@@ -634,7 +635,7 @@ function exception_to_error(Throwable $e, bool $print = true): string
"#%s %s(%s): %s(%s)\n",
$count,
isset($frame['file']) ? absolute_to_relative($frame['file']) : 'unknown file',
isset($frame['line']) ? $frame['line'] : 'unknown line',
$frame['line'] ?? 'unknown line',
(isset($frame['class'])) ? $frame['class'] . $frame['type'] . $frame['function'] : $frame['function'],
$args
);
@@ -758,7 +759,7 @@ function datetime_alter(string $datetime, string $var, $action = 'add'): string
} else {
try {
$interval = new DateInterval($var);
} catch (Throwable $e) {
} catch (Throwable) {
return $datetime;
}
$DateTime->$action($interval);
@@ -771,7 +772,7 @@ function dateinterval(string $duration): DateInterval|bool
{
try {
return new DateInterval($duration);
} catch (Exception $e) {
} catch (Exception) {
}
return false;
@@ -931,7 +932,7 @@ function parse_user_agent(?string $u_agent = null): array
$find('Version', $key);
$version = $result['version'][$key];
} elseif ($browser == 'MSIE' || strpos($browser, 'Trident') !== false) {
} elseif ($browser == 'MSIE' || str_contains($browser, 'Trident')) {
if ($find('IEMobile', $key)) {
$browser = 'IEMobile';
} else {
@@ -1285,7 +1286,7 @@ function format_bytes(mixed $bytes, int $round = 1): string
}
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
foreach ($units as $k => $v) {
$multiplier = pow(1000, $k + 1);
$multiplier = 1000 ** ($k + 1);
$threshold = $multiplier * 1000;
if ($bytes < $threshold) {
$size = round($bytes / $multiplier, $round);
@@ -1323,12 +1324,12 @@ function get_bytes(string $size, ?int $cut = null): int
$pow_factor = array_search($suffix, $units) + 1;
$num = strlen($suffix) == 2 ? 1000 : 1024;
return (int) ($number * pow($num, $pow_factor));
return (int) ($number * $num ** $pow_factor);
}
function bytes_to_mb(int|float $bytes): float
{
return round($bytes / pow(10, 6));
return round($bytes / 10 ** 6);
}
function get_ini_bytes(string $size): int
@@ -1773,7 +1774,7 @@ function is_url(mixed $string, array $protocols = []): bool
function is_https(string $string): bool
{
return strpos($string, 'https://') !== false;
return str_starts_with($string, 'https://');
}
function is_valid_url(string $string): bool
@@ -1826,18 +1827,12 @@ function is_windows_os(): bool
function is_animated_image($filename): bool
{
switch (get_file_extension($filename)) {
case 'gif':
return is_animated_gif($filename);
case 'png':
return is_animated_png($filename);
case 'webp':
return is_animated_webp($filename);
}
return false;
return match (get_file_extension($filename)) {
'gif' => is_animated_gif($filename),
'png' => is_animated_png($filename),
'webp' => is_animated_webp($filename),
default => false,
};
}
function is_animated_gif($filename): bool
@@ -1898,7 +1893,7 @@ function is_writable(string $path): bool
try {
$handle = fopen($testFile, 'w');
fclose($handle);
} catch (Throwable $e) {
} catch (Throwable) {
return false;
}
@@ -2293,7 +2288,9 @@ function imagecreatefrombmp(string $file): GdImage|bool
}
}
}
$meta['colors'] = !$meta['colors'] ? pow(2, $meta['bits']) : $meta['colors'];
$meta['colors'] = !$meta['colors']
? 2 ** $meta['bits']
: $meta['colors'];
$palette = [];
if ($meta['bits'] < 16) {
$palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
@@ -2650,7 +2647,7 @@ function getQsParams(): array
$a = [];
foreach (explode("&", server()["QUERY_STRING"]) as $q) {
$p = explode('=', $q, 2);
$a[$p[0]] = isset($p[1]) ? $p[1] : '';
$a[$p[0]] = $p[1] ?? '';
}
return $a;

View File

@@ -236,16 +236,16 @@ function get_share_links(array $share_element = [])
'label' => '分享到微信',
],
'weibo' => [
'url' => 'https://service.weibo.com/share/share.php?url=%URL%&title=%TITLE%&pic=%PHOTO_URL%&searchPic=true',
'url' => 'https://service.weibo.com/share/share.php?url=%URL%&title=%TITLE%&pic=%IMAGE%&searchPic=true',
'label' => '分享到微博',
],
'qzone' => [
'url' => 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%URL%&pics=%PHOTO_URL%&title=%TITLE%',
'url' => 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=%URL%&pics=%IMAGE%&title=%TITLE%',
'label' => '分享到QQ空间',
'icon' => 'star'
],
'qq' => [
'url' => 'https://connect.qq.com/widget/shareqq/index.html?url=%URL%&summary=%DESCRIPTION%&title=%TITLE%&pics=%PHOTO_URL%',
'url' => 'https://connect.qq.com/widget/shareqq/index.html?url=%URL%&summary=%DESCRIPTION%&title=%TITLE%&pics=%IMAGE%',
'label' => '分享到QQ',
],
'reddit' => [
@@ -261,17 +261,17 @@ function get_share_links(array $share_element = [])
'label' => 'Blogger',
],
'tumblr' => [
'url' => 'http://www.tumblr.com/share/photo?source=%PHOTO_URL%&caption=%TITLE%&clickthru=%URL%&title=%TITLE%',
'url' => 'https://www.tumblr.com/widgets/share/tool/?canonicalUrl=%URL%&posttype=photo&content=%IMAGE%&caption=%TITLE%',
'label' => 'Tumblr.',
],
'pinterest' => [
'url' => 'http://www.pinterest.com/pin/create/bookmarklet/?media=%PHOTO_URL%&url=%URL%&is_video=false&description=%DESCRIPTION%&title=%TITLE%',
'url' => 'http://www.pinterest.com/pin/create/bookmarklet/?media=%IMAGE%&url=%URL%&is_video=false&description=%DESCRIPTION%&title=%TITLE%',
'label' => 'Pinterest',
],
];
}
$return = [];
$search = ['%URL%', '%TITLE%', '%DESCRIPTION%', '%HTML%', '%PHOTO_URL%', '%TWITTER%'];
$search = ['%URL%', '%TITLE%', '%DESCRIPTION%', '%HTML%', '%IMAGE%', '%TWITTER%'];
$replace = ['url', 'title', 'description', 'HTML', 'image', 'twitter'];
foreach ($share_links_networks as $key => $value) {
for ($i = 0; $i < count($replace); ++$i) {
@@ -279,6 +279,7 @@ function get_share_links(array $share_element = [])
$replace[$i] = $elements[$replace[$i]];
}
}
$value['url'] = str_replace($search, $replace, $value['url']);
$icon = "fab";
switch ($key) {
@@ -554,7 +555,9 @@ function get_peafowl_item_list($item, $template, $tools, $tpl = 'image', array $
$replacements['IMAGE_ALBUM_PRIVACY'] = 'public';
}
if (in_array($stock_tpl, ['IMAGE', 'ALBUM'])) {
$nsfw = $stock_tpl == 'IMAGE' ? $item['nsfw'] : (isset($item['images_slice'][0]['nsfw']) ? $item['images_slice'][0]['nsfw'] : '');
$nsfw = $stock_tpl == 'IMAGE'
? $item['nsfw']
: ($item['images_slice'][0]['nsfw'] ?? '');
$placeholder = $stock_tpl == 'IMAGE' ? 'IMAGE_FLAG' : 'ALBUM_COVER_FLAG';
$replacements[$placeholder] = $nsfw ? 'unsafe' : 'safe';
}
@@ -1020,7 +1023,7 @@ var disqus_config = function () {
'%page_id' => str_replace_first(get_route_path(), get_route_name(), get_route_path(true)), // image.ID
'%shortname' => getSetting('disqus_shortname'),
'%language_code' => get_language_used()['base'],
'%auth' => isset($auth) ? $auth : null,
'%auth' => $auth ?? null,
'%api_key' => $disqus_public,
]);

View File

@@ -276,7 +276,7 @@ function getStorages(): array|bool
function get_banner_code(string $banner, bool $safe_html = true): string
{
if (strpos($banner, 'banner_') !== 0) {
if (!str_starts_with($banner, 'banner_')) {
$banner = 'banner_' . $banner;
}
$banner_code = Settings::get($banner);
@@ -367,7 +367,7 @@ function hashed_token_info(string $public_token_format): array
function generate_hashed_token(int $id, string $token = ''): array
{
$token = random_string(rand(128, 256));
$token = random_string(random_int(128, 256));
$hash = password_hash($token, PASSWORD_BCRYPT);
return [
@@ -509,7 +509,7 @@ function cheveretoID(string|int $in, string $action = 'encode'): string|int
];
}
array_multisort($p, SORT_DESC, $i);
$index = implode($i);
$index = implode('', $i);
$base = strlen($index);
if ($action == 'decode') {
$out = 0;
@@ -770,7 +770,8 @@ function upload_to_content_images(array $source, string $what): void
if (!$file_contents) {
throw new Exception("Can't read uploaded file content", 600);
}
if (strpos($file_contents, '<!DOCTYPE svg PUBLIC') === false and strpos($file_contents, '<svg') === false) {
if (!str_contains($file_contents, '<!DOCTYPE svg PUBLIC')
&& !str_contains($file_contents, '<svg')) {
throw new Exception("Uploaded file isn't SVG.", 300);
}
$filename = $name . random_string(8) . '.svg';
@@ -808,9 +809,14 @@ function upload_to_content_images(array $source, string $what): void
$what = 'homepage_cover_image';
$homepage_cover_image = getSetting($what);
if ($cover_handle == 'add') {
$filename = (isset($homepage_cover_image) ? $homepage_cover_image : getSetting('homepage_cover_images')[0]['basename']) . ',' . $filename;
$filename = (
$homepage_cover_image
?? getSetting('homepage_cover_images')[0]['basename']
) . ',' . $filename;
} else {
$filename = isset($homepage_cover_image) ? str_replace($db_filename, $filename, getSetting('homepage_cover_image')) : $filename;
$filename = isset($homepage_cover_image)
? str_replace($db_filename, $filename, getSetting('homepage_cover_image'))
: $filename;
}
$filename = trim($filename, ',');
@@ -898,7 +904,7 @@ function updateCheveretoNews()
'chevereto_news' => serialize($chevereto_news),
'news_check_datetimegmt' => datetimegmt(),
]);
} catch (Throwable $e) {
} catch (Throwable) {
$chevereto_news = [];
}
@@ -918,20 +924,11 @@ function obfuscate(string $string): string
function isShowEmbedContent(): bool
{
switch (getSetting('theme_show_embed_content_for')) {
case 'none':
$showEmbed = false;
break;
case 'users':
$showEmbed = Login::isLoggedUser();
break;
default:
$showEmbed = true;
break;
}
$showEmbed = match (getSetting('theme_show_embed_content_for')) {
'none' => false,
'users' => Login::isLoggedUser(),
default => true,
};
return $showEmbed;
}
@@ -1123,7 +1120,7 @@ function loaderHandler(
'key' => Settings::get('xr_key'),
]);
new XrInstance(new Xr(...$xrArguments));
} catch (Throwable $e) {
} catch (Throwable) {
// Silent failover
}
$uploadImageFolder = Settings::get('chevereto_version_installed') !== null
@@ -1319,7 +1316,7 @@ function adjustBrightness(string $hexCode, float $adjustPercent)
$color = str_pad(dechex(intval($color + $adjustAmount)), 2, '0', STR_PAD_LEFT);
}
return '#' . implode($hexCode);
return '#' . implode('', $hexCode);
}
function getLicenseKey(): string

View File

@@ -18,7 +18,7 @@ function env(): array
{
try {
return EnvVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -27,7 +27,7 @@ function request(): array
{
try {
return RequestVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -36,7 +36,7 @@ function get(): array
{
try {
return GetVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -45,7 +45,7 @@ function post(): array
{
try {
return PostVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -54,7 +54,7 @@ function server(): array
{
try {
return ServerVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -63,7 +63,7 @@ function files(): array
{
try {
return FilesVar::toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -72,7 +72,7 @@ function cookie(): array
{
try {
return cookieVar()->toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}
@@ -86,7 +86,7 @@ function session(): array
{
try {
return sessionVar()->toArray();
} catch (LogicException $e) {
} catch (LogicException) {
return [];
}
}

View File

@@ -87,6 +87,9 @@ if (file_exists($envFile)) {
$env = require $envFile;
}
$env = array_merge($_ENV, $_SERVER, $env);
if (($env['CHEVERETO_SERVICING'] ?? null) === 'docker') {
abort('[!] This feature is not available when using Docker', 403);
}
if (!class_exists('ZipArchive')) {
abort('[!] ZipArchive is not available');
}

View File

@@ -28,11 +28,11 @@ $share_links_networks = [
'label' => 'Blogger'
],
'tumblr' => [
'url' => 'http://www.tumblr.com/share/photo?source=%PHOTO_URL%&caption=%TITLE%&clickthru=%URL%&title=%TITLE%',
'url' => 'https://www.tumblr.com/widgets/share/tool/?canonicalUrl=%URL%&posttype=photo&content=%IMAGE%&caption=%TITLE%',
'label' => 'Tumblr.'
],
'pinterest' => [
'url' => 'http://www.pinterest.com/pin/create/bookmarklet/?media=%PHOTO_URL%&url=%URL%&is_video=false&description=%DESCRIPTION%&title=%TITLE%',
'url' => 'http://www.pinterest.com/pin/create/bookmarklet/?media=%IMAGE%&url=%URL%&is_video=false&description=%DESCRIPTION%&title=%TITLE%',
'label' => 'Pinterest'
],
'reddit' => [

View File

@@ -244,14 +244,21 @@ if (is_route('page') || is_route('plugin')) {
<div class="pop-box-inner pop-box-menu">
<ul>
<li class="with-icon"><a href="<?php echo Login::getUser()['url']; ?>"><span class="btn-icon fas fa-id-card"></span><?php _se('My Profile'); ?></a></li>
<li class="with-icon"><a href="<?php echo Login::getUser()['url_albums']; ?>"><span class="btn-icon fas fa-images"></span><?php _se('Albums'); ?></a></li>
<?php if (getSetting('enable_likes') || env()['CHEVERETO_ENABLE_EXPOSE_PAID_FEATURES']) {
?>
<?php
if (Login::getUser()['home'] === 'files') {
?>
<li class="with-icon"><a href="<?php echo Login::getUser()['url_albums']; ?>"><span class="btn-icon fas fa-images"></span><?php _ne('Album', 'Albums', 20); ?></a></li>
<?php
} else { ?>
<li class="with-icon"><a href="<?php echo Login::getUser()['url_images']; ?>"><span class="btn-icon fas fa-photo-film"></span><?php _ne('File', 'Files', 20); ?></a></li>
<?php } ?>
<?php if (getSetting('enable_likes') || (env()['CHEVERETO_ENABLE_EXPOSE_PAID_FEATURES'] && in_array(env()['CHEVERETO_EDITION'], ['free', 'lite']))) {
?>
<li class="with-icon"><a href="<?php echo linkPaid('pro') ?? Login::getUser()['url_liked']; ?>"><span class="btn-icon fas fa-heart"></span><?php echo _s('Liked') . badgePaid('pro'); ?></a></li>
<?php
} ?>
} ?>
<?php
if (getSetting('enable_followers') || env()['CHEVERETO_ENABLE_EXPOSE_PAID_FEATURES']) {
if (getSetting('enable_followers') || (env()['CHEVERETO_ENABLE_EXPOSE_PAID_FEATURES'] && in_array(env()['CHEVERETO_EDITION'], ['free', 'lite']))) {
?>
<li class="with-icon"><a href="<?php echo linkPaid('pro') ?? Login::getUser()['url_following']; ?>"><span class="btn-icon fas fa-rss"></span><?php echo _s('Following') . badgePaid('pro'); ?></a></li>
<li class="with-icon"><a href="<?php echo linkPaid('pro') ?? Login::getUser()['url_followers']; ?>"><span class="btn-icon fas fa-users"></span><?php echo _s('Followers') . badgePaid('pro'); ?></a></li>

View File

@@ -879,7 +879,7 @@ $(function () {
modal_tpl = $(modal_sel).html();
dealing_with = CHV.obj.resource.type;
url = window.location.href;
image = $('#image-viewer-container').find('img').first().attr('src');
image = CHV.obj.image_viewer.image.display_url;
link = $(".header > h1 > a");
}
title = PF.fn.htmlEncode(link.text());
@@ -2127,12 +2127,25 @@ $(function () {
data.current_version
) == -1
) {
let splitVersion = CHV.obj.system_info.version.split(".");
let majorVersion = splitVersion[0];
let minorVersion = majorVersion + '.' + splitVersion[1];
let upgradeButtonTarget = "_self";
let upgradeButtonSrc = PF.obj.config.base_url + 'dashboard/upgrade/?auth_token=' + PF.obj.config.auth_token;
let upgradeButtonText = PF.fn._s("Upgrade");
let upgradeButtonIcon = "fas fa-download";
if(CHV.obj.system_info.servicing === 'docker') {
upgradeButtonTarget = "_blank";
upgradeButtonSrc = 'https://v4-docs.chevereto.com/guides/docker/#upgrading';
upgradeButtonText = PF.fn._s("Instructions");
upgradeButtonIcon = "fa-brands fa-docker";
}
PF.fn.modal.simple({
title: '<i class="fas fa-arrow-alt-circle-up"></i> ' + PF.fn._s("Chevereto v%s available", data.current_version),
message: "<p>" +
PF.fn._s("There is a new Chevereto version available with the following release notes.") +
' ' +
PF.fn._s("Check %s for a complete changelog since you last upgrade.", '<a href="https://releases.chevereto.com/4.X/4.0/' + CHV.obj.system_info.version + '" target="_blank">' + CHV.obj.system_info.version + '<span class="btn-icon fas fas fa-code-branch"></span></a>') +
PF.fn._s("Check %s for a complete changelog since you last upgrade.", '<a href="https://releases.chevereto.com/' + majorVersion + '.X/' + minorVersion + '/' + CHV.obj.system_info.version + '" target="_blank">' + CHV.obj.system_info.version + '<span class="btn-icon fas fas fa-code-branch"></span></a>') +
'</p>' +
'<textarea class="r4 resize-vertical">' +
data.release_notes.trim() +
@@ -2141,11 +2154,16 @@ $(function () {
PF.fn._s("Check the %s for alternative update methods.", '<a href="https://chv.to/v4update" target="_blank">' + PF.fn._s('documentation') + '</a>') +
'</p>' +
'<div class="btn-container margin-bottom-0">' +
'<a href="' + PF.obj.config.base_url + 'dashboard/upgrade/?auth_token=' + PF.obj.config.auth_token
+ '" class="btn btn-input accent">' +
'<span class="btn-icon fas fa-download user-select-none"></span>' +
'<a href="' +
upgradeButtonSrc +
'" class="btn btn-input accent" target="' +
upgradeButtonTarget +
'">' +
'<span class="btn-icon ' +
upgradeButtonIcon +
' user-select-none"></span>' +
'<span class="btn-text user-select-none">' +
PF.fn._s("Upgrade now") +
upgradeButtonText +
'</span>' +
'</a> ' +
'</div>',
@@ -4776,18 +4794,23 @@ CHV.fn.fillEmbedCodes = function (elements, parent, fn) {
var embed_tpl = CHV.fn.uploader.selectors.root == parent ? "embed_upload_tpl" : "embed_share_tpl";
var hasFrame = false;
var hasMedium = false;
var hasThumb = false;
$.each(elements, function (key, value) {
if (typeof value == typeof undefined) return;
var image = "id_encoded" in value ? value : value.image;
var flatten_image = Object.flatten(image);
let itemHasFrame = image.url_frame !== "";
let itemHasMedium = image.medium.url !== null;
let itemHasThumb = image.thumb.url !== null;
if(itemHasFrame) {
hasFrame = true;
}
if(itemHasMedium) {
hasMedium = true;
}
if(itemHasThumb) {
hasThumb = true;
}
$.each(CHV.obj[embed_tpl], function (key, value) {
$.each(value.options, function (k, v) {
if(!itemHasFrame && k.startsWith('frame-')) {
@@ -4796,6 +4819,9 @@ CHV.fn.fillEmbedCodes = function (elements, parent, fn) {
if(!itemHasMedium && k.startsWith('medium-')) {
return;
}
if(!itemHasThumb && k.startsWith('thumb-')) {
return;
}
var $embed = $("textarea[name=" + k + "]", parent);
var template = v.template;
if(typeof template === 'object' && template.hasOwnProperty(flatten_image["type"])
@@ -4825,6 +4851,7 @@ CHV.fn.fillEmbedCodes = function (elements, parent, fn) {
});
$("option[value^=frame]", parent).prop("disabled", !hasFrame);
$("option[value^=medium-]", parent).prop("disabled", !hasMedium);
$("option[value^=thumb-]", parent).prop("disabled", !hasThumb);
$.each(CHV.obj[embed_tpl], function (key, value) {
$.each(value.options, function (k, v) {
var $embed = $("textarea[name=" + k + "]", parent);

File diff suppressed because one or more lines are too long

View File

@@ -74,7 +74,7 @@ $embed_upload_tpl = [
'template' => '<a href="%URL_VIEWER%"><img src="%MEDIUM_URL%" alt="%DISPLAY_TITLE%" border="0"></a>',
'size' => 'medium',
],
'thumbnail-html-embed' => [
'thumb-html-embed' => [
'label' => _s('%s thumbnail linked', 'HTML'),
'template' => '<a href="%URL_VIEWER%"><img src="%THUMB_URL%" alt="%DISPLAY_TITLE%" border="0"></a>',
'size' => 'thumb',
@@ -105,7 +105,7 @@ $embed_upload_tpl = [
'template' => '[![%DISPLAY_TITLE%](%MEDIUM_URL%)](%URL_VIEWER%)',
'size' => 'medium',
],
'thumbnail-markdown-embed' => [
'thumb-markdown-embed' => [
'label' => _s('%s thumbnail linked', 'Markdown'),
'template' => '[![%DISPLAY_TITLE%](%THUMB_URL%)](%URL_VIEWER%)',
'size' => 'thumb',
@@ -136,7 +136,7 @@ $embed_upload_tpl = [
'template' => '[url=%URL_VIEWER%][img]%MEDIUM_URL%[/img][/url]',
'size' => 'medium',
],
'thumbnail-bbcode-embed' => [
'thumb-bbcode-embed' => [
'label' => _s('%s thumbnail linked', 'BBCode'),
'template' => '[url=%URL_VIEWER%][img]%THUMB_URL%[/img][/url]',
'size' => 'thumb',

View File

@@ -119,6 +119,7 @@ if (Handler::cond('captcha_needed') && getSetting('captcha_api') == '3') {
CHV.obj.system_info = <?php echo json_encode([
'version' => get_app_version(),
'edition' => env()['CHEVERETO_EDITION'],
'servicing' => env()['CHEVERETO_SERVICING'] ?? 'server'
]); ?>;
<?php
}

View File

@@ -30,7 +30,13 @@ if ($hasPrev == false) { ?>
<div id="home-cover-content" class="c20 phone-c1 phablet-c1 fluid-column center-box padding-left-10 padding-right-10">
<?php show_banner('home_before_title', (Handler::var('listing') !== null ? Handler::var('listing')->sfw() : true)); ?>
<h1><?php echo getSetting('homepage_title_html') ?: _s('Upload and share your media'); ?></h1>
<p class="c20 center-box text-align-center"><?php echo getSetting('homepage_paragraph_html') ?? _s('Drag and drop anywhere to start uploading.'); ?> <?php _se('Get direct links, Markdown, BBCode and HTML thumbnails.'); ?></p>
<p class="c20 center-box text-align-center"><?php echo
getSetting('homepage_paragraph_html') ?? (
_s('Drag and drop anywhere to start uploading.')
. ' '
. _s('Get direct links, Markdown, BBCode and HTML thumbnails.')
); ?>
</p>
<div class="home-buttons">
<?php echo Handler::var('homepage_cta'); ?>
</div>
@@ -40,7 +46,7 @@ if ($hasPrev == false) { ?>
<?php } ?>
<?php show_banner('home_after_cover', (Handler::var('listing') !== null ? Handler::var('listing')->sfw() : true)); ?>
<?php if (Settings::get('homepage_style') == 'split') {
?>
?>
<div class="top-sub-bar follow-scroll margin-bottom-5 margin-top-5">
<div class="content-width">
@@ -86,5 +92,5 @@ if ($hasPrev == false) { ?>
} ?>
</div>
<?php
} ?>
} ?>
<?php include_theme_footer(); ?>

View File

@@ -130,7 +130,7 @@ if (!defined('ACCESS') || !ACCESS) {
</div>
<div class="header-content-right phone-float-none">
<div class="text-align-right">
<a class="number-figures" href="<?php echo Handler::var('user')["url"]; ?>"><i class="icon fas fa-photo-film"></i> <b data-text="image-count"><?php echo Handler::var('user')["image_count"]; ?></b> <span data-text="image-label" data-label-single="<?php _ne('file', 'files', 1); ?>" data-label-plural="<?php _ne('file', 'files', 2); ?>"><?php _ne('file', 'files', Handler::var('user')['image_count']); ?></span></a>
<a class="number-figures" href="<?php echo Handler::var('user')["url_images"]; ?>"><i class="icon fas fa-photo-film"></i> <b data-text="image-count"><?php echo Handler::var('user')["image_count"]; ?></b> <span data-text="image-label" data-label-single="<?php _ne('file', 'files', 1); ?>" data-label-plural="<?php _ne('file', 'files', 2); ?>"><?php _ne('file', 'files', Handler::var('user')['image_count']); ?></span></a>
<a class="number-figures" href="<?php echo Handler::var('user')["url_albums"]; ?>"><i class="icon far fa-images"></i> <b data-text="album-count"><?php echo Handler::var('user')["album_count"]; ?></b> <span data-text="album-label" data-label-single="<?php _ne('album', 'albums', 1); ?>" data-label-plural="<?php _ne('album', 'albums', 2); ?>"><?php _ne('album', 'albums', Handler::var('user')['album_count']); ?></span></a>
<?php if (getSetting('enable_likes') && Handler::var('user')['is_private'] == 0) {
?>