diff --git a/README.md b/README.md index 62b77182..bc0e2735 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ - PayPal Integration - Stripe Integration +- Referral System - Email Verification - Audit Log - Admin Dashboard diff --git a/app/Classes/Settings/Misc.php b/app/Classes/Settings/Misc.php index beaa3a44..415a0615 100644 --- a/app/Classes/Settings/Misc.php +++ b/app/Classes/Settings/Misc.php @@ -37,6 +37,11 @@ class Misc 'mailencryption' => 'nullable|string', 'mailfromadress' => 'nullable|string', 'mailfromname' => 'nullable|string', + 'enable_referral' => 'nullable|string', + 'referral_reward' => 'nullable|numeric', + 'referral_allowed' => 'nullable|string', + 'referral_percentage' => 'nullable|numeric', + 'referral_mode' => 'nullable|string', ]); if ($validator->fails()) { @@ -69,6 +74,12 @@ class Misc "SETTINGS::MAIL:ENCRYPTION" => "mailencryption", "SETTINGS::MAIL:FROM_ADDRESS" => "mailfromadress", "SETTINGS::MAIL:FROM_NAME" => "mailfromname", + "SETTINGS::REFERRAL::ENABLED" => "enable_referral", + "SETTINGS::REFERRAL::REWARD" => "referral_reward", + "SETTINGS::REFERRAL::ALLOWED" => "referral_allowed", + "SETTINGS::REFERRAL:MODE" => "referral_mode", + "SETTINGS::REFERRAL:PERCENTAGE" => "referral_percentage" + ]; diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index c7cf8a1e..8d3a0d23 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -19,6 +19,8 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use LaravelDaily\Invoices\Classes\Buyer; use LaravelDaily\Invoices\Classes\InvoiceItem; @@ -179,9 +181,25 @@ class PaymentController extends Controller } - //update role + //update role give Referral-reward if ($user->role == 'member') { $user->update(['role' => 'client']); + + if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits"){ + if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){ + $ref_user = User::findOrFail($ref_user->referral_id); + $increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"",""); + $ref_user->increment('credits', $increment); + + //LOGS REFERRALS IN THE ACTIVITY LOG + activity() + ->performedOn($user) + ->causedBy($ref_user) + ->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')'); + } + + } + } //store payment @@ -326,9 +344,25 @@ class PaymentController extends Controller $user->increment('server_limit', $shopProduct->quantity); } - //update role + //update role give Referral-reward if ($user->role == 'member') { $user->update(['role' => 'client']); + + if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits"){ + if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){ + $ref_user = User::findOrFail($ref_user->referral_id); + $increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"",""); + $ref_user->increment('credits', $increment); + + //LOGS REFERRALS IN THE ACTIVITY LOG + activity() + ->performedOn($user) + ->causedBy($ref_user) + ->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')'); + } + + } + } //store paid payment @@ -431,9 +465,25 @@ class PaymentController extends Controller $user->increment('server_limit', $shopProduct->quantity); } - //update role + //update role give Referral-reward if ($user->role == 'member') { $user->update(['role' => 'client']); + + if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both")&& $shopProduct->type=="Credits"){ + if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){ + $ref_user = User::findOrFail($ref_user->referral_id); + $increment = number_format($shopProduct->quantity/100*config("SETTINGS::REFERRAL:PERCENTAGE"),0,"",""); + $ref_user->increment('credits', $increment); + + //LOGS REFERRALS IN THE ACTIVITY LOG + activity() + ->performedOn($user) + ->causedBy($ref_user) + ->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')'); + } + + } + } //update payment db entry status diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 7c293a58..963069ad 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -8,6 +8,7 @@ use App\Http\Controllers\Controller; use App\Models\Settings; use App\Models\User; use App\Notifications\DynamicNotification; +use Illuminate\Support\Facades\DB; use Spatie\QueryBuilder\QueryBuilder; use Exception; use Illuminate\Contracts\Foundation\Application; @@ -52,8 +53,18 @@ class UserController extends Controller */ public function show(User $user) { + //QUERY ALL REFERRALS A USER HAS + //i am not proud of this at all. + $allReferals = array(); + $referrals = DB::table("user_referrals")->where("referral_id","=",$user->id)->get(); + foreach($referrals as $referral){ + array_push($allReferals, $allReferals["id"] = User::query()->findOrFail($referral->registered_user_id)); + } + array_pop($allReferals); + return view('admin.users.show')->with([ - 'user' => $user + 'user' => $user, + 'referrals' => $allReferals ]); } @@ -258,6 +269,9 @@ class UserController extends Controller ->addColumn('servers', function (User $user) { return $user->servers->count(); }) + ->addColumn('referrals', function (User $user) { + return DB::table('user_referrals')->where("referral_id","=",$user->id)->count(); + }) ->addColumn('discordId', function (User $user) { return $user->discordUser ? $user->discordUser->id : ''; }) @@ -307,7 +321,7 @@ class UserController extends Controller ->orderColumn('last_seen', function ($query) { $query->orderBy('last_seen', "desc"); }) - ->rawColumns(['avatar', 'name', 'credits', 'role', 'usage', 'actions', 'last_seen']) + ->rawColumns(['avatar', 'name', 'credits', 'role', 'usage', 'referrals', 'actions', 'last_seen']) ->make(true); } } diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 62ee244e..a25b9873 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -8,6 +8,8 @@ use App\Http\Controllers\Controller; use App\Models\DiscordUser; use App\Models\Settings; use App\Models\User; +use App\Notifications\ReferralNotification; +use Carbon\Carbon; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Contracts\Routing\ResponseFactory; @@ -17,6 +19,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; use Illuminate\Validation\Rule; @@ -227,7 +230,17 @@ class UserController extends Controller return $user; } - + /** + * Create a unique Referral Code for User + * @return string + */ + protected function createReferralCode(){ + $referralcode = STR::random(8); + if (User::where('referral_code', '=', $referralcode)->exists()) { + $this->createReferralCode(); + } + return $referralcode; + } /** * @throws ValidationException */ @@ -245,6 +258,7 @@ class UserController extends Controller 'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150), 'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1), 'password' => Hash::make($request->input('password')), + 'referral_code' => $this->createReferralCode(), ]); $response = Pterodactyl::client()->post('/application/users', [ @@ -269,7 +283,25 @@ class UserController extends Controller $user->update([ 'pterodactyl_id' => $response->json()['attributes']['id'] ]); + //INCREMENT REFERRAL-USER CREDITS + if(!empty($request->input("referral_code"))){ + $ref_code = $request->input("referral_code"); + $new_user = $user->id; + if($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) { + if(config("SETTINGS::REFERRAL:MODE") == "register" || config("SETTINGS::REFERRAL:MODE") == "both") { + $ref_user->increment('credits', config("SETTINGS::REFERRAL::REWARD")); + $ref_user->notify(new ReferralNotification($ref_user->id, $new_user)); + } + //INSERT INTO USER_REFERRALS TABLE + DB::table('user_referrals')->insert([ + 'referral_id' => $ref_user->id, + 'registered_user_id' => $user->id, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now() + ]); + } + } $user->sendEmailVerificationNotification(); return $user; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index c4c3ba2a..5a805987 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -6,10 +6,15 @@ use App\Classes\Pterodactyl; use App\Http\Controllers\Controller; use App\Models\Settings; use App\Models\User; +use App\Notifications\ReferralNotification; use App\Providers\RouteServiceProvider; +use Carbon\Carbon; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\App; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Illuminate\Validation\ValidationException; @@ -78,6 +83,18 @@ class RegisterController extends Controller return Validator::make($data, $validationRules); } + /** + * Create a unique Referral Code for User + * @return string + */ + protected function createReferralCode(){ + $referralcode = STR::random(8); + if (User::where('referral_code', '=', $referralcode)->exists()) { + $this->createReferralCode(); + } + return $referralcode; + } + /** * Create a new user instance after a valid registration. * @@ -92,6 +109,8 @@ class RegisterController extends Controller 'credits' => config('SETTINGS::USER:INITIAL_CREDITS', 150), 'server_limit' => config('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1), 'password' => Hash::make($data['password']), + 'referral_code' => $this->createReferralCode(), + ]); $response = Pterodactyl::client()->post('/application/users', [ @@ -116,7 +135,31 @@ class RegisterController extends Controller 'pterodactyl_id' => $response->json()['attributes']['id'] ]); + //INCREMENT REFERRAL-USER CREDITS + if(!empty($data['referral_code'])){ + $ref_code = $data['referral_code']; + $new_user = $user->id; + if($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) { + if(config("SETTINGS::REFERRAL:MODE") == "sign-up" || config("SETTINGS::REFERRAL:MODE") == "both") { + $ref_user->increment('credits', config("SETTINGS::REFERRAL::REWARD")); + $ref_user->notify(new ReferralNotification($ref_user->id, $new_user)); + //LOGS REFERRALS IN THE ACTIVITY LOG + activity() + ->performedOn($user) + ->causedBy($ref_user) + ->log('gained '. config("SETTINGS::REFERRAL::REWARD").' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for sign-up-referral of '.$user->name.' (ID:'.$user->id.')'); + } + //INSERT INTO USER_REFERRALS TABLE + DB::table('user_referrals')->insert([ + 'referral_id' => $ref_user->id, + 'registered_user_id' => $user->id, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now() + ]); + } + + } return $user; } diff --git a/app/Http/Controllers/Auth/SocialiteController.php b/app/Http/Controllers/Auth/SocialiteController.php index c2418ce8..c91a18f3 100644 --- a/app/Http/Controllers/Auth/SocialiteController.php +++ b/app/Http/Controllers/Auth/SocialiteController.php @@ -7,6 +7,7 @@ use App\Models\DiscordUser; use App\Models\Settings; use App\Models\User; use App\Models\Voucher; +use Exception; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Http; use Laravel\Socialite\Facades\Socialite; @@ -35,17 +36,29 @@ class SocialiteController extends Controller $guildId = config("SETTINGS::DISCORD:GUILD_ID"); $roleId = config("SETTINGS::DISCORD:ROLE_ID"); - //save / update discord_users - if (is_null($user->discordUser)) { - //create discord user in db - DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id])); - //update user - Auth::user()->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD')); - Auth::user()->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD')); - Auth::user()->update(['discord_verified_at' => now()]); - } else { - $user->discordUser->update($discord->user); - } + //save / update discord_users + + //check if discord account is already linked to an cpgg account + if (is_null($user->discordUser)) { + $discordLinked = DiscordUser::where('id', '=', $discord->id)->first(); + if ($discordLinked !== null) { + return redirect()->route('profile.index')->with( + 'error', + 'Discord account already linked!' + ); + } + + //create discord user in db + DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id])); + + //update user + Auth::user()->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD')); + Auth::user()->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD')); + Auth::user()->update(['discord_verified_at' => now()]); + + } else { + $user->discordUser->update($discord->user); + } //force user into discord server //TODO Add event on failure, to notify ppl involved diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index c48ea1de..7853c1ac 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -2,11 +2,6 @@ namespace App\Http\Controllers; -use Illuminate\Contracts\View\Factory; -use Illuminate\Contracts\View\View; -use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Auth; class NotificationController extends Controller @@ -15,7 +10,6 @@ class NotificationController extends Controller public function index() { $notifications = Auth::user()->notifications()->paginate(); - return view('notifications.index')->with([ 'notifications' => $notifications ]); @@ -31,4 +25,13 @@ class NotificationController extends Controller 'notification' => $notification ]); } + + public function readAll(){ + $notifications = Auth::user()->notifications()->get(); + foreach($notifications as $notification){ + $notification->markAsRead(); + } + return redirect()->back(); + + } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 57709b62..dce3e96a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -16,11 +16,26 @@ class ProfileController extends Controller /** Display a listing of the resource. */ public function index() { + switch (Auth::user()->role) { + case 'admin': + $badgeColor = 'badge-danger'; + break; + case 'mod': + $badgeColor = 'badge-info'; + break; + case 'client': + $badgeColor = 'badge-success'; + break; + default: + $badgeColor = 'badge-secondary'; + break; + } return view('profile.index')->with([ 'user' => Auth::user(), 'credits_reward_after_verify_discord' => config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD'), 'force_email_verification' => config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION'), 'force_discord_verification' => config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION'), + 'badgeColor' => $badgeColor, ]); } diff --git a/app/Models/User.php b/app/Models/User.php index 3767cf4e..5f8af024 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -60,7 +60,8 @@ class User extends Authenticatable implements MustVerifyEmail 'pterodactyl_id', 'discord_verified_at', 'avatar', - 'suspended' + 'suspended', + 'referral_code' ]; /** @@ -195,7 +196,7 @@ class User extends Authenticatable implements MustVerifyEmail */ public function unSuspend() { - foreach ($this->servers as $server) { + foreach ($this->getServersWithProduct() as $server) { if ($this->credits >= $server->product->getHourlyPrice()) { $server->unSuspend(); } @@ -232,14 +233,19 @@ class User extends Authenticatable implements MustVerifyEmail * @return string */ public function creditUsage() - { + { $usage = 0; - - foreach ($this->Servers as $server) { + foreach ($this->getServersWithProduct() as $server) { $usage += $server->product->price; } return number_format($usage, 2, '.', ''); + } + + private function getServersWithProduct() { + return $this->servers() + ->with('product') + ->get(); } /** diff --git a/app/Notifications/ReferralNotification.php b/app/Notifications/ReferralNotification.php new file mode 100644 index 00000000..1f48df37 --- /dev/null +++ b/app/Notifications/ReferralNotification.php @@ -0,0 +1,59 @@ +user = User::findOrFail($user); + $this->ref_user = User::findOrFail($ref_user); + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + return ['database']; + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + 'title' => __("Someone registered using your Code!"), + 'content' => " +
You received ".config('SETTINGS::REFERRAL::REWARD')." ".config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME')."
+because ".$this->ref_user->name." registered with your Referral-Code!
+Thank you very much for supporting us!.
+".config('app.name', 'Laravel')."
+ ", + ]; + } +} diff --git a/config/app.php b/config/app.php index 7f38ae77..4eb2700b 100644 --- a/config/app.php +++ b/config/app.php @@ -4,7 +4,7 @@ use App\Models\Settings; return [ - 'version' => '0.7.5', + 'version' => '0.7.6', /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2022_06_02_081655_referral_code.php b/database/migrations/2022_06_02_081655_referral_code.php new file mode 100644 index 00000000..15cca0b7 --- /dev/null +++ b/database/migrations/2022_06_02_081655_referral_code.php @@ -0,0 +1,56 @@ +doesntExist()) { + DB::table("users") + ->where("id", "=", $userid) + ->update(['referral_code' => $random]); + }else{ + $this->generateCode($userid); + } + } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function (Blueprint $table) { + $table->string('referral_code')->lenght(8)->nullable(); + }); + + $existing_user = User::where('referral_code', '')->orWhere('referral_code', NULL)->get(); + + foreach ($existing_user as $user) { + $this->generateCode($user->id); + } + } + + + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('referral_code'); + }); + } + +} diff --git a/database/migrations/2022_06_02_091921_table-user-referrals.php b/database/migrations/2022_06_02_091921_table-user-referrals.php new file mode 100644 index 00000000..a6fdbd83 --- /dev/null +++ b/database/migrations/2022_06_02_091921_table-user-referrals.php @@ -0,0 +1,35 @@ +unsignedBigInteger('referral_id'); + $table->unsignedBigInteger('registered_user_id'); + $table->foreign('referral_id')->references('id')->on('users')->onDelete('cascade');; + $table->foreign('registered_user_id')->references('id')->on('users')->onDelete('cascade');; + $table->timestamps(); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_referrals'); + } +} diff --git a/database/seeders/Seeds/SettingsSeeder.php b/database/seeders/Seeds/SettingsSeeder.php index 31ada4a3..e37a4d25 100644 --- a/database/seeders/Seeds/SettingsSeeder.php +++ b/database/seeders/Seeds/SettingsSeeder.php @@ -24,7 +24,7 @@ class SettingsSeeder extends Seeder ]); Settings::firstOrCreate([ - 'key' => 'SETTINGS::USER:NITIAL_SERVER_LIMIT', + 'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT', ], [ 'value' => '1', 'type' => 'integer', @@ -465,5 +465,40 @@ class SettingsSeeder extends Seeder 'type' => 'string', 'description' => 'Mailer From Name' ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::REFERRAL::ENABLED', + ], [ + 'value' =>"true", + 'type' => 'string', + 'description' => 'Enable or disable the referral system' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::REFERRAL::REWARD', + ], [ + 'value' =>100, + 'type' => 'integer', + 'description' => 'Credit reward a user should receive when a user registers with his referral code' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::REFERRAL::ALLOWED', + ], [ + 'value' =>"client", + 'type' => 'string', + 'description' => 'Who should be allowed to to use the referral code. all/client' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::REFERRAL:MODE', + ], [ + 'value' =>"sign-up", + 'type' => 'string', + 'description' => 'Whether referrals get Credits on User-Registration or if a User buys credits' + ]); + Settings::firstOrCreate([ + 'key' => 'SETTINGS::REFERRAL:PERCENTAGE', + ], [ + 'value' =>100, + 'type' => 'integer', + 'description' => 'The Percentage Value a referred user gets' + ]); } } diff --git a/public/favicon.ico b/public/favicon.ico index fc80d88d..fa49b96a 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/images/bitsec.png b/public/images/bitsec.png deleted file mode 100644 index e7ea69b7..00000000 Binary files a/public/images/bitsec.png and /dev/null differ diff --git a/public/images/controlpanel_logo.png b/public/images/controlpanel_logo.png new file mode 100644 index 00000000..8a68b5fb Binary files /dev/null and b/public/images/controlpanel_logo.png differ diff --git a/public/install/forms.php b/public/install/forms.php index b737b031..70562a0a 100644 --- a/public/install/forms.php +++ b/public/install/forms.php @@ -269,8 +269,8 @@ if (isset($_POST['createUser'])) { } - - $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP)"; + $random = generateRandomString(); + $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')"; diff --git a/public/install/functions.php b/public/install/functions.php index 82df4017..10baf2e7 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -139,3 +139,14 @@ function wh_log($log_msg) // if you don't add `FILE_APPEND`, the file will be erased each time you add a log file_put_contents($log_file_data, "[" . date('h:i:s') . "] " . $log_msg . "\n", FILE_APPEND); } + + +function generateRandomString($length = 8) { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; +} diff --git a/public/install/index.php b/public/install/index.php index c15dfa63..562e4a3b 100644 --- a/public/install/index.php +++ b/public/install/index.php @@ -143,7 +143,7 @@ echo $cardheader; + value="controlpaneluser" class="form-control">{{__('All notifications')}}
{{ $user->email }} @if ($user->hasVerifiedEmail()) + class="text-success fas fa-check-circle"> @else - + @endif
@@ -95,193 +99,237 @@ {{ $user->Credits() }}{{ __('By verifying your discord account, you receive extra Credits and increased Server amounts') }} -
- @endif + @enderror{{ __('You are verified!') }}
+ @error('new_password') +{{ $user->discordUser->id }} +
{{ __('By verifying your discord account, you receive extra Credits and increased Server amounts') }}
-{{ __('You are verified!') }}
+{{ $user->discordUser->id }} +
+