migrations check if table exists

This commit is contained in:
xiaomlove
2021-06-09 15:11:02 +08:00
parent 5c4c2ccf8f
commit c771ff9ef1
96 changed files with 339 additions and 17 deletions

View File

@@ -62,3 +62,4 @@ GOOGLE_DRIVE_REFRESH_TOKEN=
GOOGLE_DRIVE_FOLDER_ID= GOOGLE_DRIVE_FOLDER_ID=
GEOIP2_DATABASE= GEOIP2_DATABASE=
EXAM_PROGRESS_UPDATE_PROBABILITY=60

View File

@@ -319,6 +319,16 @@ class ExamRepository extends BaseRepository
ExamProgress::query()->insert($insert); ExamProgress::query()->insert($insert);
do_log("[addProgress] " . nexus_json_encode($insert)); do_log("[addProgress] " . nexus_json_encode($insert));
/**
* Updating progress is more performance intensive and will only be done with a certain probability
*/
$probability = (int)nexus_env('EXAM_PROGRESS_UPDATE_PROBABILITY', 60);
$random = mt_rand(1, 100);
do_log("probability: $probability, random: $random");
if ($random > $probability) {
do_log("[SKIP_UPDATE_PROGRESS], random: $random > probability: $probability", 'warning');
return true;
}
$examProgress = $this->calculateProgress($examUser); $examProgress = $this->calculateProgress($examUser);
$examProgressFormatted = $this->getProgressFormatted($exam, $examProgress); $examProgressFormatted = $this->getProgressFormatted($exam, $examProgress);
$examNotPassed = array_filter($examProgressFormatted, function ($item) { $examNotPassed = array_filter($examProgressFormatted, function ($item) {
@@ -452,31 +462,48 @@ class ExamRepository extends BaseRepository
return false; return false;
} }
if ($exams->count() > 1) { if ($exams->count() > 1) {
do_log("Valid and discovered exam more than 1.", "warning"); do_log("Valid and discovered exam more than 1.", "error");
return false; return false;
} }
/** @var Exam $exam */ /** @var Exam $exam */
$exam = $exams->first(); $exam = $exams->first();
$filters = $exam->filters;
do_log("exam: {$exam->id}, filters: " . nexus_json_encode($filters));
$userTable = (new User())->getTable(); $userTable = (new User())->getTable();
$examUserTable = (new ExamUser())->getTable(); $examUserTable = (new ExamUser())->getTable();
$baseQuery = User::query() $baseQuery = User::query()
->leftJoin($examUserTable, function (JoinClause $join) use ($examUserTable, $userTable) { ->leftJoin($examUserTable, function (JoinClause $join) use ($examUserTable, $userTable) {
$join->on("$userTable.id", "=", "$examUserTable.uid") $join->on("$userTable.id", "=", "$examUserTable.uid");
->on("$examUserTable.status", "=", DB::raw(ExamUser::STATUS_NORMAL));
}) })
->where('enabled', User::ENABLED_YES) ->where("$userTable.enabled", User::ENABLED_YES)
->where('visible', User::STATUS_CONFIRMED) ->where("$userTable.status", User::STATUS_CONFIRMED)
->whereRaw("$examUserTable.id is null") ->whereRaw("$examUserTable.id is null")
->selectRaw("$userTable.*") ->selectRaw("$userTable.*")
->orderBy("$userTable.id", "asc"); ->orderBy("$userTable.id", "asc");
if (empty($filters->classes)) {
do_log("{$exam->id} no classes.");
return false;
} else {
$baseQuery->whereIn("$userTable.class", $filters->classes);
}
if (empty($filters->register_time_range) || empty($filters->register_time_range[0]) || empty($filters->register_time_range[1])) {
do_log("{$exam->id} no register_time_range.");
return false;
} else {
$baseQuery->where("$userTable.added", ">=", Carbon::parse($filters->register_time_range[0])->toDateTimeString())
->where("$userTable.added", '<=', Carbon::parse($filters->register_time_range[1])->toDateTimeString());
}
$size = 1000; $size = 1000;
$minId = 0; $minId = 0;
$result = 0; $result = 0;
while (true) { while (true) {
$logPrefix = sprintf('[%s], exam: %s, size: %s', __FUNCTION__, $exam->id , $size); $logPrefix = sprintf('[%s], exam: %s, size: %s', __FUNCTION__, $exam->id , $size);
$users = (clone $baseQuery)->where("$userTable.id", ">", $minId)->limit($size)->get(); $users = (clone $baseQuery)->where("$userTable.id", ">", $minId)->limit($size)->get();
do_log("$logPrefix, query: " . last_query() . ", counts: " . $users->count());
if ($users->isEmpty()) { if ($users->isEmpty()) {
do_log("$logPrefix, no more data..." . last_query()); do_log("no more data...");
break; break;
} }
$insert = []; $insert = [];
@@ -484,10 +511,10 @@ class ExamRepository extends BaseRepository
foreach ($users as $user) { foreach ($users as $user) {
$minId = $user->id; $minId = $user->id;
$currentLogPrefix = sprintf("$logPrefix, user: %s", $user->id); $currentLogPrefix = sprintf("$logPrefix, user: %s", $user->id);
if (!$this->isExamMatchUser($exam, $user)) { // if (!$this->isExamMatchUser($exam, $user)) {
do_log("$currentLogPrefix, exam not match this user."); // do_log("$currentLogPrefix, exam not match this user.");
continue; // continue;
} // }
$insert[] = [ $insert[] = [
'uid' => $user->id, 'uid' => $user->id,
'exam_id' => $exam->id, 'exam_id' => $exam->id,

View File

@@ -13,6 +13,9 @@ class CreatePersonalAccessTokensTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('personal_access_tokens')) {
return;
}
Schema::create('personal_access_tokens', function (Blueprint $table) { Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->morphs('tokenable'); $table->morphs('tokenable');

View File

@@ -13,6 +13,9 @@ class CreateAdclicksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('adclicks')) {
return;
}
Schema::create('adclicks', function (Blueprint $table) { Schema::create('adclicks', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedInteger('adid')->nullable(); $table->unsignedInteger('adid')->nullable();

View File

@@ -13,6 +13,9 @@ class CreateAdminpanelTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('adminpanel')) {
return;
}
Schema::create('adminpanel', function (Blueprint $table) { Schema::create('adminpanel', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 128)->default(''); $table->string('name', 128)->default('');

View File

@@ -13,6 +13,9 @@ class CreateAdvertisementsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('advertisements')) {
return;
}
Schema::create('advertisements', function (Blueprint $table) { Schema::create('advertisements', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->boolean('enabled')->default(0); $table->boolean('enabled')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateAgentAllowedExceptionTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('agent_allowed_exception')) {
return;
}
Schema::create('agent_allowed_exception', function (Blueprint $table) { Schema::create('agent_allowed_exception', function (Blueprint $table) {
$table->unsignedTinyInteger('family_id')->default(0)->index('family_id'); $table->unsignedTinyInteger('family_id')->default(0)->index('family_id');
$table->string('name', 100)->default(''); $table->string('name', 100)->default('');

View File

@@ -13,6 +13,9 @@ class CreateAgentAllowedFamilyTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('agent_allowed_family')) {
return;
}
Schema::create('agent_allowed_family', function (Blueprint $table) { Schema::create('agent_allowed_family', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('family', 50)->default(''); $table->string('family', 50)->default('');

View File

@@ -13,6 +13,9 @@ class CreateAllowedemailsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('allowedemails')) {
return;
}
Schema::create('allowedemails', function (Blueprint $table) { Schema::create('allowedemails', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->mediumText('value'); $table->mediumText('value');

View File

@@ -13,6 +13,9 @@ class CreateAttachmentsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('attachments')) {
return;
}
Schema::create('attachments', function (Blueprint $table) { Schema::create('attachments', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateAttendanceTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('attendance')) {
return;
}
Schema::create('attendance', function (Blueprint $table) { Schema::create('attendance', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->unsignedInteger('uid')->default(0)->index('idx_uid'); $table->unsignedInteger('uid')->default(0)->index('idx_uid');

View File

@@ -13,6 +13,9 @@ class CreateAudiocodecsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('audiocodecs')) {
return;
}
Schema::create('audiocodecs', function (Blueprint $table) { Schema::create('audiocodecs', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateAvpsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('avps')) {
return;
}
Schema::create('avps', function (Blueprint $table) { Schema::create('avps', function (Blueprint $table) {
$table->string('arg', 20)->default('')->primary(); $table->string('arg', 20)->default('')->primary();
$table->text('value_s'); $table->text('value_s');

View File

@@ -13,6 +13,9 @@ class CreateBannedemailsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('bannedemails')) {
return;
}
Schema::create('bannedemails', function (Blueprint $table) { Schema::create('bannedemails', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->mediumText('value'); $table->mediumText('value');

View File

@@ -13,6 +13,9 @@ class CreateBansTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('bans')) {
return;
}
Schema::create('bans', function (Blueprint $table) { Schema::create('bans', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->dateTime('added')->nullable(); $table->dateTime('added')->nullable();

View File

@@ -13,6 +13,9 @@ class CreateBitbucketTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('bitbucket')) {
return;
}
Schema::create('bitbucket', function (Blueprint $table) { Schema::create('bitbucket', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('owner')->default(0); $table->unsignedMediumInteger('owner')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateBlocksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('blocks')) {
return;
}
Schema::create('blocks', function (Blueprint $table) { Schema::create('blocks', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateBookmarksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('bookmarks')) {
return;
}
Schema::create('bookmarks', function (Blueprint $table) { Schema::create('bookmarks', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('torrentid')->default(0); $table->unsignedMediumInteger('torrentid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateCategoriesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('categories')) {
return;
}
Schema::create('categories', function (Blueprint $table) { Schema::create('categories', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedTinyInteger('mode')->default(1); $table->unsignedTinyInteger('mode')->default(1);

View File

@@ -13,6 +13,9 @@ class CreateCaticonsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('caticons')) {
return;
}
Schema::create('caticons', function (Blueprint $table) { Schema::create('caticons', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 64)->default(''); $table->string('name', 64)->default('');

View File

@@ -13,6 +13,9 @@ class CreateCheatersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('cheaters')) {
return;
}
Schema::create('cheaters', function (Blueprint $table) { Schema::create('cheaters', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->dateTime('added')->nullable(); $table->dateTime('added')->nullable();

View File

@@ -13,6 +13,9 @@ class CreateChronicleTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('chronicle')) {
return;
}
Schema::create('chronicle', function (Blueprint $table) { Schema::create('chronicle', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateCodecsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('codecs')) {
return;
}
Schema::create('codecs', function (Blueprint $table) { Schema::create('codecs', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateCommentsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('comments')) {
return;
}
Schema::create('comments', function (Blueprint $table) { Schema::create('comments', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('user')->default(0)->index('user'); $table->unsignedMediumInteger('user')->default(0)->index('user');

View File

@@ -13,6 +13,9 @@ class CreateCountriesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('countries')) {
return;
}
Schema::create('countries', function (Blueprint $table) { Schema::create('countries', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->string('name', 50)->default(''); $table->string('name', 50)->default('');

View File

@@ -13,6 +13,9 @@ class CreateDownloadspeedTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('downloadspeed')) {
return;
}
Schema::create('downloadspeed', function (Blueprint $table) { Schema::create('downloadspeed', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 50)->default(''); $table->string('name', 50)->default('');

View File

@@ -13,6 +13,9 @@ class CreateExamProgressTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('exam_progress')) {
return;
}
Schema::create('exam_progress', function (Blueprint $table) { Schema::create('exam_progress', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->integer('exam_user_id')->index(); $table->integer('exam_user_id')->index();

View File

@@ -13,6 +13,9 @@ class CreateExamUsersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('exam_users')) {
return;
}
Schema::create('exam_users', function (Blueprint $table) { Schema::create('exam_users', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->integer('uid')->index(); $table->integer('uid')->index();

View File

@@ -13,6 +13,9 @@ class CreateExamsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('exams')) {
return;
}
Schema::create('exams', function (Blueprint $table) { Schema::create('exams', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('name'); $table->string('name');

View File

@@ -13,6 +13,9 @@ class CreateFailedJobsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('failed_jobs')) {
return;
}
Schema::create('failed_jobs', function (Blueprint $table) { Schema::create('failed_jobs', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('uuid')->unique(); $table->string('uuid')->unique();

View File

@@ -13,6 +13,9 @@ class CreateFaqTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('faq')) {
return;
}
Schema::create('faq', function (Blueprint $table) { Schema::create('faq', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedSmallInteger('link_id')->default(0); $table->unsignedSmallInteger('link_id')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateFilesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('files')) {
return;
}
Schema::create('files', function (Blueprint $table) { Schema::create('files', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('torrent')->default(0)->index('torrent'); $table->unsignedMediumInteger('torrent')->default(0)->index('torrent');

View File

@@ -13,6 +13,9 @@ class CreateForummodsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('forummods')) {
return;
}
Schema::create('forummods', function (Blueprint $table) { Schema::create('forummods', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedSmallInteger('forumid')->default(0)->index('forumid'); $table->unsignedSmallInteger('forumid')->default(0)->index('forumid');

View File

@@ -13,6 +13,9 @@ class CreateForumsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('forums')) {
return;
}
Schema::create('forums', function (Blueprint $table) { Schema::create('forums', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedSmallInteger('sort')->default(0); $table->unsignedSmallInteger('sort')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateFriendsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('friends')) {
return;
}
Schema::create('friends', function (Blueprint $table) { Schema::create('friends', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateFunTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('fun')) {
return;
}
Schema::create('fun', function (Blueprint $table) { Schema::create('fun', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateFundsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('funds')) {
return;
}
Schema::create('funds', function (Blueprint $table) { Schema::create('funds', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->decimal('usd')->default(0.00); $table->decimal('usd')->default(0.00);

View File

@@ -13,6 +13,9 @@ class CreateFunvotesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('funvotes')) {
return;
}
Schema::create('funvotes', function (Blueprint $table) { Schema::create('funvotes', function (Blueprint $table) {
$table->unsignedMediumInteger('funid'); $table->unsignedMediumInteger('funid');
$table->unsignedMediumInteger('userid'); $table->unsignedMediumInteger('userid');

View File

@@ -13,6 +13,9 @@ class CreateInvitesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('invites')) {
return;
}
Schema::create('invites', function (Blueprint $table) { Schema::create('invites', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('inviter')->default(0); $table->unsignedMediumInteger('inviter')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateIplogTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('iplog')) {
return;
}
Schema::create('iplog', function (Blueprint $table) { Schema::create('iplog', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('ip', 64)->default(''); $table->string('ip', 64)->default('');

View File

@@ -13,6 +13,9 @@ class CreateIspTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('isp')) {
return;
}
Schema::create('isp', function (Blueprint $table) { Schema::create('isp', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 50)->nullable(); $table->string('name', 50)->nullable();

View File

@@ -13,6 +13,9 @@ class CreateLanguageTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('language')) {
return;
}
Schema::create('language', function (Blueprint $table) { Schema::create('language', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->string('lang_name', 50)->default(''); $table->string('lang_name', 50)->default('');

View File

@@ -13,6 +13,9 @@ class CreateLinksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('links')) {
return;
}
Schema::create('links', function (Blueprint $table) { Schema::create('links', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateLocationsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('locations')) {
return;
}
Schema::create('locations', function (Blueprint $table) { Schema::create('locations', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('name', 50)->nullable(); $table->string('name', 50)->nullable();

View File

@@ -13,6 +13,9 @@ class CreateLoginattemptsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('loginattempts')) {
return;
}
Schema::create('loginattempts', function (Blueprint $table) { Schema::create('loginattempts', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('ip', 64)->default(''); $table->string('ip', 64)->default('');

View File

@@ -13,6 +13,9 @@ class CreateMagicTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('magic')) {
return;
}
Schema::create('magic', function (Blueprint $table) { Schema::create('magic', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->integer('torrentid')->default(0)->index('idx_torrentid'); $table->integer('torrentid')->default(0)->index('idx_torrentid');

View File

@@ -13,6 +13,9 @@ class CreateMediaTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('media')) {
return;
}
Schema::create('media', function (Blueprint $table) { Schema::create('media', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateMessagesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('messages')) {
return;
}
Schema::create('messages', function (Blueprint $table) { Schema::create('messages', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('sender')->default(0)->index('sender'); $table->unsignedMediumInteger('sender')->default(0)->index('sender');

View File

@@ -13,6 +13,9 @@ class CreateModpanelTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('modpanel')) {
return;
}
Schema::create('modpanel', function (Blueprint $table) { Schema::create('modpanel', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 128)->default(''); $table->string('name', 128)->default('');

View File

@@ -13,6 +13,9 @@ class CreateNewsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('news')) {
return;
}
Schema::create('news', function (Blueprint $table) { Schema::create('news', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateOffersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('offers')) {
return;
}
Schema::create('offers', function (Blueprint $table) { Schema::create('offers', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0)->index('userid'); $table->unsignedMediumInteger('userid')->default(0)->index('userid');

View File

@@ -13,6 +13,9 @@ class CreateOffervotesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('offervotes')) {
return;
}
Schema::create('offervotes', function (Blueprint $table) { Schema::create('offervotes', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('offerid')->default(0); $table->unsignedMediumInteger('offerid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateOverforumsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('overforums')) {
return;
}
Schema::create('overforums', function (Blueprint $table) { Schema::create('overforums', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->string('name', 60)->default(''); $table->string('name', 60)->default('');

View File

@@ -13,6 +13,9 @@ class CreatePeersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('peers')) {
return;
}
Schema::create('peers', function (Blueprint $table) { Schema::create('peers', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('torrent')->default(0)->index('torrent'); $table->unsignedMediumInteger('torrent')->default(0)->index('torrent');

View File

@@ -13,6 +13,9 @@ class CreatePmboxesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('pmboxes')) {
return;
}
Schema::create('pmboxes', function (Blueprint $table) { Schema::create('pmboxes', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreatePollanswersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('pollanswers')) {
return;
}
Schema::create('pollanswers', function (Blueprint $table) { Schema::create('pollanswers', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('pollid')->default(0)->index('pollid'); $table->unsignedMediumInteger('pollid')->default(0)->index('pollid');

View File

@@ -13,6 +13,9 @@ class CreatePollsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('polls')) {
return;
}
Schema::create('polls', function (Blueprint $table) { Schema::create('polls', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->dateTime('added')->nullable(); $table->dateTime('added')->nullable();

View File

@@ -13,6 +13,9 @@ class CreatePostsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('posts')) {
return;
}
Schema::create('posts', function (Blueprint $table) { Schema::create('posts', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('topicid')->default(0); $table->unsignedMediumInteger('topicid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateProcessingsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('processings')) {
return;
}
Schema::create('processings', function (Blueprint $table) { Schema::create('processings', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateProlinkclicksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('prolinkclicks')) {
return;
}
Schema::create('prolinkclicks', function (Blueprint $table) { Schema::create('prolinkclicks', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateReadpostsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('readposts')) {
return;
}
Schema::create('readposts', function (Blueprint $table) { Schema::create('readposts', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('userid')->default(0)->index('userid'); $table->unsignedMediumInteger('userid')->default(0)->index('userid');

View File

@@ -13,6 +13,9 @@ class CreateRegimagesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('regimages')) {
return;
}
Schema::create('regimages', function (Blueprint $table) { Schema::create('regimages', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->string('imagehash', 32)->default(''); $table->string('imagehash', 32)->default('');

View File

@@ -13,6 +13,9 @@ class CreateReportsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('reports')) {
return;
}
Schema::create('reports', function (Blueprint $table) { Schema::create('reports', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('addedby')->default(0); $table->unsignedMediumInteger('addedby')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateRequestsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('requests')) {
return;
}
Schema::create('requests', function (Blueprint $table) { Schema::create('requests', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedInteger('userid')->default(0)->index('userid'); $table->unsignedInteger('userid')->default(0)->index('userid');

View File

@@ -13,6 +13,9 @@ class CreateResreqTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('resreq')) {
return;
}
Schema::create('resreq', function (Blueprint $table) { Schema::create('resreq', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->integer('reqid')->default(0)->index('reqid'); $table->integer('reqid')->default(0)->index('reqid');

View File

@@ -13,6 +13,9 @@ class CreateRulesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('rules')) {
return;
}
Schema::create('rules', function (Blueprint $table) { Schema::create('rules', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedSmallInteger('lang_id')->default(6); $table->unsignedSmallInteger('lang_id')->default(6);

View File

@@ -13,6 +13,9 @@ class CreateSchoolsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('schools')) {
return;
}
Schema::create('schools', function (Blueprint $table) { Schema::create('schools', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->string('name', 50)->nullable(); $table->string('name', 50)->nullable();

View File

@@ -13,6 +13,9 @@ class CreateSearchboxFieldsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('searchbox_fields')) {
return;
}
Schema::create('searchbox_fields', function (Blueprint $table) { Schema::create('searchbox_fields', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->integer('searchbox_id'); $table->integer('searchbox_id');

View File

@@ -13,6 +13,9 @@ class CreateSearchboxTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('searchbox')) {
return;
}
Schema::create('searchbox', function (Blueprint $table) { Schema::create('searchbox', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->string('name', 30)->nullable(); $table->string('name', 30)->nullable();

View File

@@ -13,6 +13,9 @@ class CreateSecondiconsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('secondicons')) {
return;
}
Schema::create('secondicons', function (Blueprint $table) { Schema::create('secondicons', function (Blueprint $table) {
$table->smallIncrements('id'); $table->smallIncrements('id');
$table->unsignedTinyInteger('source')->default(0); $table->unsignedTinyInteger('source')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateSettingsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('settings')) {
return;
}
Schema::create('settings', function (Blueprint $table) { Schema::create('settings', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->string('name')->default('')->unique('uniqe_name'); $table->string('name')->default('')->unique('uniqe_name');

View File

@@ -13,6 +13,9 @@ class CreateShoutboxTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('shoutbox')) {
return;
}
Schema::create('shoutbox', function (Blueprint $table) { Schema::create('shoutbox', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->unsignedMediumInteger('userid')->default(0); $table->unsignedMediumInteger('userid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateSitelogTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('sitelog')) {
return;
}
Schema::create('sitelog', function (Blueprint $table) { Schema::create('sitelog', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->dateTime('added')->nullable()->index('added'); $table->dateTime('added')->nullable()->index('added');

View File

@@ -13,6 +13,9 @@ class CreateSnatchedTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('snatched')) {
return;
}
Schema::create('snatched', function (Blueprint $table) { Schema::create('snatched', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->unsignedMediumInteger('torrentid')->default(0); $table->unsignedMediumInteger('torrentid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateSourcesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('sources')) {
return;
}
Schema::create('sources', function (Blueprint $table) { Schema::create('sources', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateStaffmessagesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('staffmessages')) {
return;
}
Schema::create('staffmessages', function (Blueprint $table) { Schema::create('staffmessages', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('sender')->default(0); $table->unsignedMediumInteger('sender')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateStandardsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('standards')) {
return;
}
Schema::create('standards', function (Blueprint $table) { Schema::create('standards', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateStylesheetsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('stylesheets')) {
return;
}
Schema::create('stylesheets', function (Blueprint $table) { Schema::create('stylesheets', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('uri')->default(''); $table->string('uri')->default('');

View File

@@ -13,6 +13,9 @@ class CreateSubsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('subs')) {
return;
}
Schema::create('subs', function (Blueprint $table) { Schema::create('subs', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('torrent_id')->default(0); $table->unsignedMediumInteger('torrent_id')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateSuggestTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('suggest')) {
return;
}
Schema::create('suggest', function (Blueprint $table) { Schema::create('suggest', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('keywords')->default('')->index('keywords'); $table->string('keywords')->default('')->index('keywords');

View File

@@ -13,6 +13,9 @@ class CreateSysoppanelTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('sysoppanel')) {
return;
}
Schema::create('sysoppanel', function (Blueprint $table) { Schema::create('sysoppanel', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 128)->default(''); $table->string('name', 128)->default('');

View File

@@ -13,6 +13,9 @@ class CreateTeamsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('teams')) {
return;
}
Schema::create('teams', function (Blueprint $table) { Schema::create('teams', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 30)->default(''); $table->string('name', 30)->default('');

View File

@@ -13,6 +13,9 @@ class CreateThanksTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('thanks')) {
return;
}
Schema::create('thanks', function (Blueprint $table) { Schema::create('thanks', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedMediumInteger('torrentid')->default(0); $table->unsignedMediumInteger('torrentid')->default(0);

View File

@@ -13,6 +13,9 @@ class CreateTopicsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('topics')) {
return;
}
Schema::create('topics', function (Blueprint $table) { Schema::create('topics', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0)->index('userid'); $table->unsignedMediumInteger('userid')->default(0)->index('userid');

View File

@@ -13,6 +13,9 @@ class CreateTorrentSecretsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('torrent_secrets')) {
return;
}
Schema::create('torrent_secrets', function (Blueprint $table) { Schema::create('torrent_secrets', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->integer('uid')->index('idx_uid'); $table->integer('uid')->index('idx_uid');

View File

@@ -13,6 +13,9 @@ class CreateTorrentsCustomFieldValuesTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('torrents_custom_field_values')) {
return;
}
Schema::create('torrents_custom_field_values', function (Blueprint $table) { Schema::create('torrents_custom_field_values', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->integer('torrent_id')->default(0)->index('idx_torrent_id'); $table->integer('torrent_id')->default(0)->index('idx_torrent_id');

View File

@@ -13,6 +13,9 @@ class CreateTorrentsCustomFieldsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('torrents_custom_fields')) {
return;
}
Schema::create('torrents_custom_fields', function (Blueprint $table) { Schema::create('torrents_custom_fields', function (Blueprint $table) {
$table->integer('id', true); $table->integer('id', true);
$table->string('name')->default(''); $table->string('name')->default('');

View File

@@ -13,6 +13,9 @@ class CreateTorrentsStateTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('torrents_state')) {
return;
}
Schema::create('torrents_state', function (Blueprint $table) { Schema::create('torrents_state', function (Blueprint $table) {
$table->unsignedTinyInteger('global_sp_state')->default(1); $table->unsignedTinyInteger('global_sp_state')->default(1);
}); });

View File

@@ -13,6 +13,9 @@ class CreateTorrentsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('torrents')) {
return;
}
Schema::create('torrents', function (Blueprint $table) { Schema::create('torrents', function (Blueprint $table) {
$table->mediumIncrements('id'); $table->mediumIncrements('id');
$table->binary('info_hash')->unique('info_hash'); $table->binary('info_hash')->unique('info_hash');

View File

@@ -13,6 +13,9 @@ class CreateUploadspeedTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('uploadspeed')) {
return;
}
Schema::create('uploadspeed', function (Blueprint $table) { Schema::create('uploadspeed', function (Blueprint $table) {
$table->tinyIncrements('id'); $table->tinyIncrements('id');
$table->string('name', 50)->nullable(); $table->string('name', 50)->nullable();

View File

@@ -13,6 +13,9 @@ class CreateUserBanLogsTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('user_ban_logs')) {
return;
}
Schema::create('user_ban_logs', function (Blueprint $table) { Schema::create('user_ban_logs', function (Blueprint $table) {
$table->bigInteger('id', true); $table->bigInteger('id', true);
$table->integer('uid')->default(0)->index('idx_uid'); $table->integer('uid')->default(0)->index('idx_uid');

View File

@@ -13,6 +13,9 @@ class CreateUsersTable extends Migration
*/ */
public function up() public function up()
{ {
if (Schema::hasTable('users')) {
return;
}
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('username', 40)->default('')->unique('username'); $table->string('username', 40)->default('')->unique('username');

View File

@@ -155,11 +155,35 @@ function nexus_dd($vars)
*/ */
function do_log($log, $level = 'info') function do_log($log, $level = 'info')
{ {
static $uid, $passkey, $env, $sequence, $setLogLevel;
if (is_null($setLogLevel)) {
$setLogLevel = nexus_env('LOG_LEVEL', 'debug');
}
$logLevels = [
\Psr\Log\LogLevel::DEBUG,
\Psr\Log\LogLevel::INFO,
\Psr\Log\LogLevel::NOTICE,
\Psr\Log\LogLevel::WARNING,
\Psr\Log\LogLevel::ERROR,
\Psr\Log\LogLevel::CRITICAL,
\Psr\Log\LogLevel::ALERT,
\Psr\Log\LogLevel::EMERGENCY,
];
$setLogLevelKey = array_search($setLogLevel, $logLevels);
$currentLogLevelKey = array_search($level, $logLevels);
if ($currentLogLevelKey === false) {
$level = \Psr\log\LogLevel::ERROR;
$log = "[ERROR_LOG_LEVEL] $log";
$currentLogLevelKey = array_search($level, $logLevels);
}
if ($currentLogLevelKey < $setLogLevelKey) {
return;
}
$logFile = getLogFile(); $logFile = getLogFile();
if (($fd = fopen($logFile, 'a')) === false) { if (($fd = fopen($logFile, 'a')) === false) {
$fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a'); $fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a');
} }
static $uid, $passkey, $env, $sequence;
if (is_null($uid)) { if (is_null($uid)) {
$sequence = 0; $sequence = 0;
if (IN_NEXUS) { if (IN_NEXUS) {

View File

@@ -106,7 +106,7 @@ class Install
$filename = basename($path); $filename = basename($path);
$count = preg_match('/create_(.*)_table.php/', $filename, $matches); $count = preg_match('/create_(.*)_table.php/', $filename, $matches);
if ($count) { if ($count) {
$tables[$matches[1]] = ''; $tables[$matches[1]] = $filename;
} }
} }
return $tables; return $tables;

View File

@@ -62,7 +62,7 @@ if ($currentStep == 3) {
try { try {
// $install->createTable($shouldCreateTable); // $install->createTable($shouldCreateTable);
if (!WITH_LARAVEL) { if (!WITH_LARAVEL) {
throw new \RuntimeException('Larvel is not avaliable.'); throw new \RuntimeException('Laravel is not avaliable.');
} }
$command = "php " . ROOT_PATH . "artisan install:migrate"; $command = "php " . ROOT_PATH . "artisan install:migrate";
$result = exec($command, $output, $result_code); $result = exec($command, $output, $result_code);

View File

@@ -81,7 +81,7 @@ $seeder = ($left == 0) ? "yes" : "no";
if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){ if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){
$res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror,passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); $res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror,passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
$az = $currentUser = mysql_fetch_array($res); $az = $currentUser = mysql_fetch_array($res);
do_log("[check passkey], currentUser: " . nexus_json_encode($currentUser)); do_log("[check passkey], currentUser: " . nexus_json_encode($currentUser), 'error');
$Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950); $Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950);
} }
if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL"); if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL");
@@ -117,8 +117,8 @@ if (!$torrent) {
$start = strpos($queryString, $firstNeedle) + strlen($firstNeedle); $start = strpos($queryString, $firstNeedle) + strlen($firstNeedle);
$end = strpos($queryString, "&", $start); $end = strpos($queryString, "&", $start);
$infoHashUrlEncode = substr($queryString, $start, $end - $start); $infoHashUrlEncode = substr($queryString, $start, $end - $start);
do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString"); do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString", 'error');
do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode"); do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode", 'error');
err("torrent not registered with this tracker"); err("torrent not registered with this tracker");
} }
@@ -471,7 +471,7 @@ $examRep = new \App\Repositories\ExamRepository();
try { try {
$examRep->addProgress($userid, $torrentid, $examIndexData); $examRep->addProgress($userid, $torrentid, $examIndexData);
} catch (\Exception $exception) { } catch (\Exception $exception) {
do_log("add exam progress fail: " . $exception->getMessage()); do_log("add exam progress fail: " . $exception->getMessage(), 'critical');
} }
benc_resp($rep_dict); benc_resp($rep_dict);