diff --git a/app/Models/Exam.php b/app/Models/Exam.php index e49843ef..54d1d341 100644 --- a/app/Models/Exam.php +++ b/app/Models/Exam.php @@ -40,7 +40,7 @@ class Exam extends NexusModel self::INDEX_UPLOADED => ['name' => 'Uploaded', 'unit' => 'GB', 'source_user_field' => 'uploaded'], self::INDEX_SEED_TIME_AVERAGE => ['name' => 'Seed time average', 'unit' => 'Hour', 'source_user_field' => 'seedtime'], self::INDEX_DOWNLOADED => ['name' => 'Downloaded', 'unit' => 'GB', 'source_user_field' => 'downloaded'], - self::INDEX_SEED_BONUS => ['name' => 'Seed bonus', 'unit' => '', 'source_user_field' => 'seed_points'], + self::INDEX_SEED_BONUS => ['name' => 'Seed points', 'unit' => '', 'source_user_field' => 'seed_points'], ]; const FILTER_USER_CLASS = 'classes'; diff --git a/app/Repositories/ExamRepository.php b/app/Repositories/ExamRepository.php index e5b7b02b..6e2a9998 100644 --- a/app/Repositories/ExamRepository.php +++ b/app/Repositories/ExamRepository.php @@ -482,7 +482,7 @@ class ExamRepository extends BaseRepository $attributes['index'] = $index['index']; $attributes['created_at'] = $now; $attributes['updated_at'] = $now; - $attributes['value'] = $user->{Exam::$indexes[$index['index']]['source_user_field']}; + $attributes['value'] = $user->{Exam::$indexes[$index['index']]['source_user_field']} ?? 0; do_log("[GET_TOTAL_VALUE]: " . $attributes['value']); $newVersionProgress = ExamProgress::query() ->where('exam_user_id', $examUser->id) diff --git a/include/functions.php b/include/functions.php index 8fc0deb7..308a655a 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5242,7 +5242,6 @@ function get_ip_location_from_geoip($ip) if (is_null($reader)) { $reader = new \GeoIp2\Database\Reader($database); } - $record = $reader->city($ip); $lang = get_langfolder_cookie(); $langMap = [ 'chs' => 'zh-CN', @@ -5250,8 +5249,15 @@ function get_ip_location_from_geoip($ip) 'en' => 'en', ]; $locale = $langMap[$lang] ?? $lang; - $countryName = $record->country->names[$locale] ?? $record->country->names['en']; - $cityName = $record->city->names[$locale] ?? $record->city->names['en'] ?? ''; + try { + $record = $reader->city($ip); + $countryName = $record->country->names[$locale] ?? $record->country->names['en']; + $cityName = $record->city->names[$locale] ?? $record->city->names['en'] ?? ''; + } catch (\Exception $exception) { + do_log($exception->getMessage() . "\n" . $exception->getTraceAsString(), 'error'); + $countryName = ''; + $cityName = ''; + } do_log("ip: $ip, locale: $locale, city: $cityName, country: $countryName"); return [ 'name' => sprintf('%s·%s', $cityName, $countryName), diff --git a/public/subtitles.php b/public/subtitles.php index 21bba28f..3ff7838e 100644 --- a/public/subtitles.php +++ b/public/subtitles.php @@ -89,7 +89,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["action"]) && $_POST["a exit; } */ - + //end process upload file //start process torrent ID @@ -166,13 +166,13 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["action"]) && $_POST["a $anonymous = "no"; $anon = $CURUSER["username"]; } - + //$file["name"] = str_replace("", "_", htmlspecialchars("$file[name]")); //$file["name"] = preg_replace('/[^a-z0-9_\-\.]/i', '_', $file[name]); - + //make_folder($SUBSPATH."/",$detail_torrent_id); //stderr("",$file["name"]); - + $r = sql_query("SELECT lang_name from language WHERE sub_lang=1 AND id = " . sqlesc($lang_id)) or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($r); @@ -182,15 +182,15 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["action"]) && $_POST["a $size = $file["size"]; sql_query("INSERT INTO subs (torrent_id, lang_id, title, filename, added, uppedby, anonymous, size, ext) VALUES (" . implode(",", array_map("sqlesc", array($torrent_id, $lang_id, $title, $filename, $added, $uppedby, $anonymous, $size, $ext))). ")") or sqlerr(); - + $id = mysql_insert_id(); - + //stderr("",make_folder($SUBSPATH."/",$torrent_id). "/" . $id . "." .$ext); if (!move_uploaded_file($file["tmp_name"], make_folder($SUBSPATH."/",$torrent_id). "/" . $id . "." .$ext)) echo($lang_subtitles['std_failed_moving_file']); - + KPS("+",$uploadsubtitle_bonus,$uppedby); //subtitle uploader gets bonus - + write_log("$arr[lang_name] Subtitle $id ($title) was uploaded by $anon"); $msg_bt = "$arr[lang_name] Subtitle $id ($title) was uploaded by $anon, Download: " . get_protocol_prefix() . "$BASEURL/downloadsubs.php/".$file["name"].""; } @@ -270,7 +270,7 @@ if (get_user_class() >= UC_PEASANT) print("
       ".$lang_subtitles['text_rule_four']."
\n"); print("       ".$lang_subtitles['text_rule_five']."
\n"); print("       ".$lang_subtitles['text_rule_six']."
\n"); - + print($lang_subtitles['text_red_star_required']); if($in_detail != "") { @@ -311,7 +311,7 @@ if (get_user_class() >= UC_PEASANT) { tr($lang_subtitles['row_show_uploader'], "".$lang_subtitles['hide_uploader_note'], 1); } - + print("