mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
fix exam assign undefined unit + improve announce ReAnnounce check
This commit is contained in:
+4
-32
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Repositories\ExamRepository;
|
||||||
|
|
||||||
class ExamUser extends NexusModel
|
class ExamUser extends NexusModel
|
||||||
{
|
{
|
||||||
protected $fillable = ['exam_id', 'uid', 'status', 'progress', 'begin', 'end', 'is_done'];
|
protected $fillable = ['exam_id', 'uid', 'status', 'progress', 'begin', 'end', 'is_done'];
|
||||||
@@ -43,38 +45,8 @@ class ExamUser extends NexusModel
|
|||||||
|
|
||||||
public function getProgressFormattedAttribute(): array
|
public function getProgressFormattedAttribute(): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$examRep = new ExamRepository();
|
||||||
$progress = $this->progress;
|
return $examRep->getProgressFormatted($this->exam, $this->progress);
|
||||||
foreach ($this->exam->indexes as $key => $index) {
|
|
||||||
if (!isset($index['checked']) || !$index['checked']) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$currentValue = $progress[$index['index']] ?? 0;
|
|
||||||
$requireValue = $index['require_value'];
|
|
||||||
$unit = Exam::$indexes[$index['index']]['unit'] ?? '';
|
|
||||||
switch ($index['index']) {
|
|
||||||
case Exam::INDEX_UPLOADED:
|
|
||||||
case Exam::INDEX_DOWNLOADED:
|
|
||||||
$currentValueFormatted = mksize($currentValue);
|
|
||||||
$requireValueAtomic = $requireValue * 1024 * 1024 * 1024;
|
|
||||||
break;
|
|
||||||
case Exam::INDEX_SEED_TIME_AVERAGE:
|
|
||||||
$currentValueFormatted = number_format($currentValue / 3600, 2) . " $unit";
|
|
||||||
$requireValueAtomic = $requireValue * 3600;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$currentValueFormatted = $currentValue;
|
|
||||||
$requireValueAtomic = $requireValue;
|
|
||||||
}
|
|
||||||
$index['name'] = Exam::$indexes[$index['index']]['name'] ?? '';
|
|
||||||
$index['index_formatted'] = nexus_trans('exam.index_text_' . $index['index']);
|
|
||||||
$index['require_value_formatted'] = "$requireValue " . ($index['unit'] ?? '');
|
|
||||||
$index['current_value'] = $currentValue;
|
|
||||||
$index['current_value_formatted'] = $currentValueFormatted;
|
|
||||||
$index['passed'] = $currentValue >= $requireValueAtomic;
|
|
||||||
$result[] = $index;
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function listStatus($onlyKeyValue = false): array
|
public static function listStatus($onlyKeyValue = false): array
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ class ExamRepository extends BaseRepository
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getProgressFormatted(Exam $exam, array $progress, $locale = null)
|
public function getProgressFormatted(Exam $exam, array $progress, $locale = null)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($exam->indexes as $key => $index) {
|
foreach ($exam->indexes as $key => $index) {
|
||||||
@@ -700,6 +700,7 @@ class ExamRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
$currentValue = $progress[$index['index']] ?? 0;
|
$currentValue = $progress[$index['index']] ?? 0;
|
||||||
$requireValue = $index['require_value'];
|
$requireValue = $index['require_value'];
|
||||||
|
$unit = Exam::$indexes[$index['index']]['unit'] ?? '';
|
||||||
switch ($index['index']) {
|
switch ($index['index']) {
|
||||||
case Exam::INDEX_UPLOADED:
|
case Exam::INDEX_UPLOADED:
|
||||||
case Exam::INDEX_DOWNLOADED:
|
case Exam::INDEX_DOWNLOADED:
|
||||||
@@ -707,7 +708,7 @@ class ExamRepository extends BaseRepository
|
|||||||
$requireValueAtomic = $requireValue * 1024 * 1024 * 1024;
|
$requireValueAtomic = $requireValue * 1024 * 1024 * 1024;
|
||||||
break;
|
break;
|
||||||
case Exam::INDEX_SEED_TIME_AVERAGE:
|
case Exam::INDEX_SEED_TIME_AVERAGE:
|
||||||
$currentValueFormatted = number_format($currentValue / 3600, 2) . " {$index['unit']}";
|
$currentValueFormatted = number_format($currentValue / 3600, 2) . " $unit";
|
||||||
$requireValueAtomic = $requireValue * 3600;
|
$requireValueAtomic = $requireValue * 3600;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -716,7 +717,7 @@ class ExamRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
$index['name'] = Exam::$indexes[$index['index']]['name'] ?? '';
|
$index['name'] = Exam::$indexes[$index['index']]['name'] ?? '';
|
||||||
$index['index_formatted'] = nexus_trans('exam.index_text_' . $index['index']);
|
$index['index_formatted'] = nexus_trans('exam.index_text_' . $index['index']);
|
||||||
$index['require_value_formatted'] = "$requireValue " . ($index['unit'] ?? '');
|
$index['require_value_formatted'] = "$requireValue $unit";
|
||||||
$index['current_value'] = $currentValue;
|
$index['current_value'] = $currentValue;
|
||||||
$index['current_value_formatted'] = $currentValueFormatted;
|
$index['current_value_formatted'] = $currentValueFormatted;
|
||||||
$index['passed'] = $currentValue >= $requireValueAtomic;
|
$index['passed'] = $currentValue >= $requireValueAtomic;
|
||||||
|
|||||||
@@ -617,8 +617,11 @@ class TrackerRepository extends BaseRepository
|
|||||||
protected function isReAnnounce(Request $request): int
|
protected function isReAnnounce(Request $request): int
|
||||||
{
|
{
|
||||||
$key = $request->query->get('key');
|
$key = $request->query->get('key');
|
||||||
|
$ip = $request->query->get('ip');
|
||||||
|
$ipv4 = $request->query->get('ipv4');
|
||||||
|
$ipv6 = $request->query->get('ipv6');
|
||||||
$queryString = $request->getQueryString();
|
$queryString = $request->getQueryString();
|
||||||
$lockKeyOriginal = str_replace($key, '', $queryString);
|
$lockKeyOriginal = str_replace([$key, $ip, $ipv4, $ipv6], '', $queryString);
|
||||||
$lockKey = md5($lockKeyOriginal);
|
$lockKey = md5($lockKeyOriginal);
|
||||||
$startTimestamp = nexus()->getStartTimestamp();
|
$startTimestamp = nexus()->getStartTimestamp();
|
||||||
$redis = Redis::connection()->client();
|
$redis = Redis::connection()->client();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.19');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.20');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-30');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-31');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
+1
-1
@@ -228,7 +228,7 @@ if ($compact == 1) {
|
|||||||
|
|
||||||
//check ReAnnounce
|
//check ReAnnounce
|
||||||
$params = $_GET;
|
$params = $_GET;
|
||||||
unset($params['key']);
|
unset($params['key'], $params['ip'], $params['ipv4'], $params['ipv6']);
|
||||||
$reAnnounceQuery = http_build_query($params);
|
$reAnnounceQuery = http_build_query($params);
|
||||||
$lockKey = md5($reAnnounceQuery);
|
$lockKey = md5($reAnnounceQuery);
|
||||||
$log .= ", [CHECK_RE_ANNOUNCE], reAnnounceQuery: $reAnnounceQuery, lockKey: $lockKey";
|
$log .= ", [CHECK_RE_ANNOUNCE], reAnnounceQuery: $reAnnounceQuery, lockKey: $lockKey";
|
||||||
|
|||||||
Reference in New Issue
Block a user