clear icon cache after modify

This commit is contained in:
xiaomlove
2023-02-06 14:25:05 +08:00
parent 23ea393ffe
commit 59b7a2916e
12 changed files with 35 additions and 13 deletions

View File

@@ -18,4 +18,9 @@ class CreateIcon extends CreateRecord
'desc' => nexus_trans('label.icon.desc')
];
}
public function afterCreate()
{
clear_icon_cache();
}
}

View File

@@ -28,4 +28,9 @@ class EditIcon extends EditRecord
'desc' => nexus_trans('label.icon.desc')
];
}
public function afterSave()
{
clear_icon_cache();
}
}

View File

@@ -43,7 +43,7 @@ class Kernel extends HttpKernel
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\Platform::class,
// \App\Http\Middleware\Platform::class,
],
'filament' => [
\Illuminate\Session\Middleware\StartSession::class,

View File

@@ -17,7 +17,7 @@ class SecondIcon extends NexusModel
foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTableModel) {
$mode = $data['mode'];
if ($mode === null || empty($data[$torrentField][$mode])) {
unset($data[$torrentField]);
$data[$torrentField] = 0;
} else {
$data[$torrentField] = $data[$torrentField][$mode];
}

View File

@@ -17,9 +17,9 @@ class AuthenticateRepository extends BaseRepository
if (!$user || md5($user->secret . $password . $user->secret) != $user->passhash) {
throw new \InvalidArgumentException('Username or password invalid.');
}
if (nexus()->isPlatformAdmin() && !$user->canAccessAdmin()) {
throw new UnauthorizedException('Unauthorized!');
}
// if (nexus()->isPlatformAdmin() && !$user->canAccessAdmin()) {
// throw new UnauthorizedException('Unauthorized!');
// }
$user->checkIsNormal();
$tokenName = __METHOD__ . __LINE__;
$token = DB::transaction(function () use ($user, $tokenName) {

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-01');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-02-06');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -26,7 +26,7 @@ function emu_getallheaders() {
function block_browser()
{
$agent = $_SERVER["HTTP_USER_AGENT"];
$agent = $_SERVER["HTTP_USER_AGENT"] ?? '';
if (preg_match("/^Mozilla/", $agent) || preg_match("/^Opera/", $agent) || preg_match("/^Links/", $agent) || preg_match("/^Lynx/", $agent) )
err("Browser access blocked!");
// check headers

View File

@@ -1044,6 +1044,15 @@ function clear_search_box_cache()
\Nexus\Database\NexusDB::cache_del("search_box_content");
}
/**
* @see functions.php::get_category_icon_row()
*/
function clear_icon_cache()
{
do_log("clear_icon_cache");
\Nexus\Database\NexusDB::cache_del("category_icon_content");
}
function user_can($permission, $fail = false, $uid = 0): bool
{
$log = "permission: $permission, fail: $fail, user: $uid";

View File

@@ -75,7 +75,7 @@ class Torrent
$ptGen = new PTGen();
}
$ptGenInfo = $torrentInfo['pt_gen'];
if (!is_array($torrentInfo['pt_gen'])) {
if (!is_array($torrentInfo['pt_gen']) && is_string($torrentInfo['pt_gen'])) {
$ptGenInfo = json_decode($ptGenInfo, true);
}

View File

@@ -3,7 +3,7 @@ require '../include/bittorrent_announce.php';
require ROOT_PATH . 'include/core.php';
do_log(nexus_json_encode($_SERVER));
//1. BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
$agent = $_SERVER["HTTP_USER_AGENT"];
$agent = $_SERVER["HTTP_USER_AGENT"] ?? '';
block_browser();
dbconn_announce();
//check authkey
@@ -32,7 +32,7 @@ foreach (array("passkey","info_hash","peer_id","port","downloaded","uploaded","l
if (!isset($x)) err("Missing key: $x");
foreach (array("info_hash","peer_id") as $x)
if (strlen($GLOBALS[$x]) != 20) err("Invalid $x (" . strlen($GLOBALS[$x]) . " - " . rawurlencode($GLOBALS[$x]) . ")");
if (strlen($passkey) != 32) err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
if (isset($passkey) && strlen($passkey) != 32) err("Invalid passkey (" . strlen($passkey) . " - $passkey)");
//4. GET IP AND CHECK PORT
$ip = getip(); // avoid to get the spoof ip from some agent

View File

@@ -109,7 +109,10 @@ if (filesize($fn) == 0) {
}
$approvalNotAllowed = $row['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no';
$allowOwnerDownload = $row['owner'] == $CURUSER['id'] && \App\Models\Snatch::query()->where('torrentid', $id)->count() == 0;
if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) && !user_can('seebanned')) || !can_access_torrent($row)) {
$canSeedBanned = user_can('seebanned');
$canAccessTorrent = can_access_torrent($row);
if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload)) && !$canSeedBanned) || !$canAccessTorrent) {
do_log("[DENY_DOWNLOAD], user: {$CURUSER['id']}, approvalNotAllowed: $approvalNotAllowed, allowOwnerDownload: $allowOwnerDownload, canSeedBanned: $canSeedBanned, canAccessTorrent: $canAccessTorrent", 'error');
denyDownload();
}

View File

@@ -41,8 +41,8 @@ $locationInfo = get_ip_location_from_geoip($ip);
$thisLoginLog = \App\Models\LoginLog::query()->create([
'ip' => $ip,
'uid' => $row['id'],
'country' => $locationInfo['country_en'],
'city' => $locationInfo['city_en'],
'country' => $locationInfo['country_en'] ?? '',
'city' => $locationInfo['city_en'] ?? '',
'client' => 'Web',
]);
$lastLoginLog = \App\Models\LoginLog::query()->where('uid', $row['id'])->orderBy('id', 'desc')->first();