diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index c474492..9314c2d 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -30,6 +30,7 @@ class SettingsController extends Controller 'show_server_value_location' => 'required|boolean', 'show_server_value_price' => 'required|boolean', 'show_server_value_yabs' => 'required|boolean', + 'save_yabs_as_txt' => 'required|boolean', 'default_currency' => 'required', 'default_server_os' => 'required', 'due_soon_amount' => 'required|integer|between:0,12', @@ -49,6 +50,7 @@ class SettingsController extends Controller 'show_server_value_location' => $request->show_server_value_location, 'show_server_value_price' => $request->show_server_value_price, 'show_server_value_yabs' => $request->show_server_value_yabs, + 'save_yabs_as_txt' => $request->save_yabs_as_txt, 'default_currency' => $request->default_currency, 'default_server_os' => $request->default_server_os, 'due_soon_amount' => $request->due_soon_amount, diff --git a/app/Http/Controllers/YabsController.php b/app/Http/Controllers/YabsController.php index 048f301..4c2e6c6 100644 --- a/app/Http/Controllers/YabsController.php +++ b/app/Http/Controllers/YabsController.php @@ -52,12 +52,18 @@ class YabsController extends Controller 'ram' => $yabs['ram'], 'ram_type' => $yabs['ram_type'], 'ram_mb' => $yabs['ram_mb'], + 'swap' => $yabs['swap'], + 'swap_type' => $yabs['swap_type'], + 'swap_mb' => $yabs['swap_mb'], 'disk' => $yabs['disk'], 'disk_type' => $yabs['disk_type'], 'disk_gb' => $yabs['disk_gb'], 'gb5_single' => $yabs['GB5_single'], 'gb5_multi' => $yabs['GB5_mult'], - 'gb5_id' => $yabs['GB5_id'] + 'gb5_id' => $yabs['GB5_id'], + 'uptime' => $yabs['uptime'], + 'distro' => $yabs['distro'], + 'kernel' => $yabs['kernel'] ]); DiskSpeed::create([ diff --git a/app/Models/Settings.php b/app/Models/Settings.php index 300f66b..913d183 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -36,6 +36,7 @@ class Settings extends Model Session::put('show_server_value_yabs', $settings[0]->show_server_value_yabs ?? 0); Session::put('show_server_value_provider', $settings[0]->show_server_value_provider ?? 0); Session::put('show_server_value_location', $settings[0]->show_server_value_location ?? 0); + Session::put('save_yabs_as_txt', $settings[0]->save_yabs_as_txt ?? 0); Session::put('default_currency', $settings[0]->default_currency ?? 'USD'); Session::put('default_server_os', $settings[0]->default_server_os ?? 1); Session::put('due_soon_amount', $settings[0]->due_soon_amount ?? 6); diff --git a/app/Models/Yabs.php b/app/Models/Yabs.php index e15f0a6..130a4ac 100644 --- a/app/Models/Yabs.php +++ b/app/Models/Yabs.php @@ -15,7 +15,7 @@ class Yabs extends Model protected $table = 'yabs'; - protected $fillable = ['id', 'server_id', 'has_ipv6', 'aes', 'vm', 'output_date', 'cpu_cores', 'cpu_freq', 'cpu_model', 'ram', 'ram_type', 'ram_mb', 'disk', 'disk_type', 'disk_gb', 'gb5_single', 'gb5_multi', 'gb5_id', '4k', '4k_type', '4k_as_mbps', '64k', '64k_type', '64k_as_mbps', '512k', '512k_type', '512k_as_mbps', '1m', '1m_type', '1m_as_mbps', 'location', 'send', 'send_type', 'send_as_mbps', 'receive', 'receive_type', 'receive_as_mbps']; + protected $fillable = ['id', 'server_id', 'has_ipv6', 'aes', 'vm', 'output_date', 'cpu_cores', 'cpu_freq', 'cpu_model', 'ram', 'ram_type', 'ram_mb', 'disk', 'disk_type', 'disk_gb', 'gb5_single', 'gb5_multi', 'gb5_id', '4k', '4k_type', '4k_as_mbps', '64k', '64k_type', '64k_as_mbps', '512k', '512k_type', '512k_as_mbps', '1m', '1m_type', '1m_as_mbps', 'location', 'send', 'send_type', 'send_as_mbps', 'receive', 'receive_type', 'receive_as_mbps', 'uptime', 'distro', 'kernel', 'swap', 'swap_type', 'swap_mb']; public static function yabs(string $yabs_id) { @@ -54,14 +54,17 @@ class Yabs extends Model foreach ($data->network_speed as $ns) { $speed_tests[] = array( 'location' => $ns->location, - 'send' => $ns->send.' '.$ns->send_type, - 'receive' => $ns->receive.' '.$ns->receive_type, + 'send' => $ns->send . ' ' . $ns->send_type, + 'receive' => $ns->receive . ' ' . $ns->receive_type, ); } return array( 'date_time' => $data->output_date, 'location' => $data->server->location->name, 'provider' => $data->server->provider->name, + 'uptime' => $data->uptime, + 'distro' => $data->distro, + 'kernel' => $data->kernel, 'cpu' => array( 'cores' => $data->cpu_cores, 'speed_mhz' => $data->cpu_freq, @@ -72,17 +75,21 @@ class Yabs extends Model 'GB5_multi' => $data->gb5_multi, ), 'ram' => array( - 'amount' => $data->ram.' '.$data->ram_type, + 'amount' => $data->ram . ' ' . $data->ram_type, 'mb' => $data->ram_mb, + 'swap' => array( + 'amount' => $data->swap ?? null . ' ' . $data->swap_type ?? null, + 'mb' => $data->swap_mb ?? null, + ), ), 'disk' => array( - 'amount' => $data->disk.' '.$data->disk_type, + 'amount' => $data->disk . ' ' . $data->disk_type, 'gb' => $data->disk_gb, 'speed_tests' => array( - '4k' => $data->disk_speed->d_4k.' '.$data->disk_speed->d_4k_type, - '64k' => $data->disk_speed->d_64k.' '.$data->disk_speed->d_64k_type, - '512k' => $data->disk_speed->d_512k.' '.$data->disk_speed->d_512k_type, - '1m' => $data->disk_speed->d_1m.' '.$data->disk_speed->d_1m_type, + '4k' => $data->disk_speed->d_4k . ' ' . $data->disk_speed->d_4k_type, + '64k' => $data->disk_speed->d_64k . ' ' . $data->disk_speed->d_64k_type, + '512k' => $data->disk_speed->d_512k . ' ' . $data->disk_speed->d_512k_type, + '1m' => $data->disk_speed->d_1m . ' ' . $data->disk_speed->d_1m_type, ), ), 'network' => array( diff --git a/app/Process.php b/app/Process.php index 1c7e636..dc82dfb 100644 --- a/app/Process.php +++ b/app/Process.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Storage; class Process @@ -169,22 +170,24 @@ class Process public function yabsOutputAsJson(string $server_id, string $data_from_form): array { - $file_name = 'tempYabs.txt'; - $allowed_versions = ['v2021-12-28', 'v2022-02-18', 'v2022-04-30', 'v2022-05-06', 'v2022-06-11']; + $file_name = date('Y') . '/' . date('m') . '/' . time() . '.txt'; + Storage::disk('local')->put($file_name, $data_from_form); $file = Storage::disk('local')->get($file_name); if ($file) { $array = explode("\n", $file); - Storage::disk('local')->delete($file_name);//Delete file + if (!Session::get('save_yabs_as_txt')) {//Check if we want YABs txt to stay + Storage::disk('local')->delete($file_name);//Delete file + } } else { return array('error_id' => 10, 'error_message' => 'Issue writing/reading txt file'); } - //dd($array); + //dd($array);//Good for debugging the lines if (count($array) < 46) { return array('error_id' => 9, 'error_message' => 'Less than 46 lines'); @@ -213,6 +216,9 @@ class Process $io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[33])); (str_contains($array[13], 'Enabled')) ? $aes_ni = true : $aes_ni = false; (str_contains($array[14], 'Enabled')) ? $vm_amd_v = true : $vm_amd_v = false; + $uptime = str_replace(["Uptime : ", "\r"], '', $array[10]); + $distro = str_replace(["Distro : ", "\r"], '', $array[18]); + $kernel = str_replace(["Kernel : ", "\r"], '', $array[19]); } else { $cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[10], ': '))); $cpu_spec = explode(' ', strstr($array[11], ': '));//: 2 @ 3792.872 MHz @@ -304,7 +310,7 @@ class Process $gb_s = 60; $gb_m = 61; $gb_url = 62; - }elseif ($array[59] === "Geekbench 5 Benchmark Test:\r") { + } elseif ($array[59] === "Geekbench 5 Benchmark Test:\r") { //HAS ipv6 //Has full ipv4 & ipv6 network speed testing $has_ipv6 = true; @@ -397,7 +403,10 @@ class Process 'vm' => $vm_amd_v, 'GB5_single' => $geekbench_single, 'GB5_mult' => $geekbench_multi, - 'GB5_id' => $gb5_id + 'GB5_id' => $gb5_id, + 'uptime' => $uptime ?? null, + 'distro' => $distro ?? null, + 'kernel' => $kernel ?? null, ]; $output['disk_speed'] = $disk_test_arr; diff --git a/database/migrations/2022_07_20_011250_add_columns_to_yabs_table.php b/database/migrations/2022_07_20_011250_add_columns_to_yabs_table.php new file mode 100644 index 0000000..c89e1c8 --- /dev/null +++ b/database/migrations/2022_07_20_011250_add_columns_to_yabs_table.php @@ -0,0 +1,31 @@ +string('uptime')->nullable()->default(null)->after('gb5_id'); + $table->string('distro')->nullable()->default(null)->after('gb5_id'); + $table->string('kernel')->nullable()->default(null)->after('gb5_id'); + $table->float('swap')->nullable()->default(null)->after('ram_mb'); + $table->char('swap_type', 2)->nullable()->default(null)->after('ram_mb'); + $table->float('swap_mb')->nullable()->default(null)->after('ram_mb'); + }); + } + + public function down() + { + Schema::table('yabs', function (Blueprint $table) { + $table->dropColumn('uptime'); + $table->dropColumn('distro'); + $table->dropColumn('kernel'); + $table->dropColumn('swap'); + $table->dropColumn('swap_type', 2); + $table->dropColumn('swap_mb'); + }); + } +}; diff --git a/database/migrations/2022_07_20_015804_add_column_to_settings_table.php b/database/migrations/2022_07_20_015804_add_column_to_settings_table.php new file mode 100644 index 0000000..f94fe56 --- /dev/null +++ b/database/migrations/2022_07_20_015804_add_column_to_settings_table.php @@ -0,0 +1,22 @@ +boolean('save_yabs_as_txt')->default(false)->after('show_server_value_yabs'); + }); + } + + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('save_yabs_as_txt'); + }); + } +}; diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php index b1ac953..2a7c9ab 100644 --- a/resources/views/settings/index.blade.php +++ b/resources/views/settings/index.blade.php @@ -107,6 +107,22 @@ +
+
+
+
Save YABs input to txt
+ +
+
+

Only if Show servers to public is YES do these apply: