update fix deadcode, security

This commit is contained in:
baodev0
2026-09-28 08:26:29 +07:00
parent 3af59bd9c5
commit 82080b5b84
452 changed files with 4857 additions and 26289 deletions
@@ -1,114 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Models\OrderItem;
use Illuminate\Console\Command;
class CheckOrderItemAddons extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'check:order-addons {order_item_id : Order Item ID to check}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check addons for a specific order item';
/**
* Execute the console command.
*/
public function handle()
{
$orderItemId = $this->argument('order_item_id');
$this->info("🔍 Checking addons for Order Item ID: {$orderItemId}");
try {
$orderItem = OrderItem::with(['addons.addonItems'])->find($orderItemId);
if (!$orderItem) {
$this->error("❌ Order Item not found with ID: {$orderItemId}");
return 1;
}
$this->info("📋 Order Item Details:");
$this->info(" - ID: {$orderItem->id}");
$this->info(" - Product ID: {$orderItem->product_id}");
$this->info(" - Product Type: {$orderItem->product_type}");
$this->info(" - Server Name: {$orderItem->server_name}");
$this->info("\n🔍 Addons Information:");
if ($orderItem->addons && $orderItem->addons->count() > 0) {
$this->info(" - Total Addons: {$orderItem->addons->count()}");
foreach ($orderItem->addons as $index => $addon) {
$this->info("\n 📦 Addon #" . ($index + 1) . ":");
$this->info(" - Order Addon ID: {$addon->id}");
$this->info(" - Addon ID: {$addon->addon_id}");
$this->info(" - Quantity (qty): {$addon->qty}");
$this->info(" - Price: {$addon->price}");
if ($addon->addonItems) {
$this->info(" - Addon Name: {$addon->addonItems->name}");
$this->info(" - Addon Price: {$addon->addonItems->price}");
$this->info(" - Addon Step: {$addon->addonItems->step}");
$this->info(" - Addon Prefix: {$addon->addonItems->prefix}");
} else {
$this->warn(" ⚠️ AddonItems relationship not found!");
}
}
// Process addons like in the job
$addonData = [
'cpu' => 0,
'ram' => 0,
'disk' => 0
];
foreach ($orderItem->addons as $orderAddon) {
$addon = $orderAddon->addonItems;
if (!$addon) continue;
$addonName = strtolower(trim($addon->name));
$quantity = (int) $orderAddon->qty;
switch ($addonName) {
case 'cpu':
$addonData['cpu'] += $quantity;
break;
case 'ram':
$addonData['ram'] += $quantity;
break;
case 'disk':
case 'ssd':
$addonData['disk'] += $quantity;
break;
}
}
$this->info("\n📊 Processed Addon Data:");
$this->info(" - CPU: {$addonData['cpu']}");
$this->info(" - RAM: {$addonData['ram']}GB");
$this->info(" - Disk: {$addonData['disk']}GB");
$this->info(" - Has Addons: " . (array_sum($addonData) > 0 ? 'Yes' : 'No'));
} else {
$this->warn("⚠️ No addons found for this order item");
}
return 0;
} catch (\Exception $e) {
$this->error("❌ Exception: " . $e->getMessage());
return 1;
}
}
}
@@ -1,53 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Http\Facade\SignRSA;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
class EncryptVCenterPasswords extends Command
{
protected $signature = 'vcenter:encrypt-passwords';
protected $description = 'Re-encrypt vCenter passwords from Laravel encrypted cast to SignRSA format';
public function handle(): int
{
$rows = DB::table('module_vcenter')->get(['id', 'password']);
$fixed = 0;
foreach ($rows as $row) {
if (!$row->password) continue;
// Try to decrypt as Laravel encrypted cast (from previous migration)
$plainPassword = null;
try {
$plainPassword = Crypt::decryptString($row->password);
$this->info("vCenter #{$row->id}: detected Laravel encrypted password, will re-encrypt with SignRSA");
} catch (\Exception) {
// Not Laravel encrypted — check if it's already SignRSA or plain text
$decrypted = SignRSA::DecryptFunc($row->password);
if ($decrypted) {
$this->info("vCenter #{$row->id}: already SignRSA encrypted, skipping");
continue;
}
// Plain text password
$plainPassword = $row->password;
$this->info("vCenter #{$row->id}: detected plain text password, will encrypt with SignRSA");
}
if ($plainPassword) {
$encrypted = SignRSA::EncryptFunc($plainPassword);
DB::table('module_vcenter')
->where('id', $row->id)
->update(['password' => $encrypted]);
$fixed++;
$this->info("vCenter #{$row->id}: re-encrypted successfully");
}
}
$this->info("Done. Fixed {$fixed} password(s).");
return 0;
}
}
-30
View File
@@ -1,30 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class FreshExcept extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:fresh-except';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
//
}
}
-51
View File
@@ -1,51 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Models\vCenter;
use Illuminate\Console\Command;
class ListVCenters extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'list:vcenters';
/**
* The console command description.
*
* @var string
*/
protected $description = 'List all vCenters in the database';
/**
* Execute the console command.
*/
public function handle()
{
$this->info("🔍 Listing all vCenters:");
try {
$vcenters = vCenter::all();
if ($vcenters->count() === 0) {
$this->warn("⚠️ No vCenters found in database");
return 0;
}
foreach ($vcenters as $vcenter) {
$status = $vcenter->status == 1 ? '✅ Active' : '❌ Inactive';
$this->info(" ID: {$vcenter->id} | Host: {$vcenter->host} | User: {$vcenter->user} | Status: {$status}");
}
return 0;
} catch (\Exception $e) {
$this->error("❌ Exception: " . $e->getMessage());
return 1;
}
}
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Http\Services\Hosting;
use Illuminate\Console\Command;
class LoginServerCheck extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'Login:Check';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
}
}