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(" \n"); print("\n"); print("\n"); @@ -377,7 +377,7 @@ if(get_user_class() >= UC_PEASANT) { // the number $start_subid is just for legacy support of prevoiusly uploaded subs, if the site is completely new, it should be 0 or just remove it $lang = "" . "\""" . "\n"; - $title = "" . htmlspecialchars($arr["title"]) . "" . + $title = "" . htmlspecialchars($arr["title"]) . "" . ($mod || ($pu && $arr["uppedby"] == $CURUSER["id"]) ? " ".$lang_subtitles['text_delete']."" : "") ."\n"; $addtime = gettime($arr["added"],false,false); $added = "" . $addtime . "\n"; diff --git a/resources/lang/en/exam.php b/resources/lang/en/exam.php index 2367e4fb..5854ea7d 100644 --- a/resources/lang/en/exam.php +++ b/resources/lang/en/exam.php @@ -7,7 +7,7 @@ return [ 'index_text_' . \App\Models\Exam::INDEX_UPLOADED => 'Uploaded', 'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => 'Seed time average', 'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => 'Downloaded', - 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => 'Seed bonus', + 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => 'Seed points', 'require_value' => 'Require', 'current_value' => 'Current', 'result' => 'Result', diff --git a/resources/lang/zh_CN/exam.php b/resources/lang/zh_CN/exam.php index 2b50a728..d3acffe1 100644 --- a/resources/lang/zh_CN/exam.php +++ b/resources/lang/zh_CN/exam.php @@ -7,7 +7,7 @@ return [ 'index_text_' . \App\Models\Exam::INDEX_UPLOADED => '上传量', 'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => '平均做种时间', 'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => '下载量', - 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做种魔力', + 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做种积分', 'require_value' => '要求', 'current_value' => '当前', 'result' => '结果', diff --git a/resources/lang/zh_TW/exam.php b/resources/lang/zh_TW/exam.php index ddfaa4d9..a77b9328 100644 --- a/resources/lang/zh_TW/exam.php +++ b/resources/lang/zh_TW/exam.php @@ -7,7 +7,7 @@ return [ 'index_text_' . \App\Models\Exam::INDEX_UPLOADED => '上傳量', 'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => '平均做種時間', 'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => '下載量', - 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做種魔力', + 'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做種積分', 'require_value' => '要求', 'current_value' => '當前', 'result' => '結果',