@yield('code')
+@yield('message'). Go home
+diff --git a/README.md b/README.md
index 51cc44c..1682817 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Despite what the name infers this self hosted web app isn't just for storing idl
a [YABs](https://github.com/masonr/yet-another-bench-script) output you can get disk & network speed values along with
GeekBench 5 scores to do easier comparing and sorting.
-[](https://shields.io/) [](https://shields.io/) [](https://shields.io/) [](https://shields.io/)
+[](https://shields.io/) [](https://shields.io/) [](https://shields.io/) [](https://shields.io/)
@@ -20,14 +20,12 @@ GeekBench 5 scores to do easier comparing and sorting.
[Cloud Five Limited](https://cloud-v.net/) for providing the hosting for demo installation.
-## 2.1.5 changes (7th September 2022):
+## 2.1.6 changes (22th September 2022):
-#### Note:
-yabs.sh now has JSON formatted response and it is possible to POST the output directly from calling the script.
+#### You can no longer use the form to submit YABS results
+yabs.sh now has JSON formatted response and can POST the output directly from calling the script.
-This will become the only method to add YABS results but using the form method still works for now.
-
-This version updates the yabs/ POST API to include the server id and your api key:
+With My idlers you can use your API key and the server id to directly POST the benchmark result
`http://domain.com/api/yabs/tnSJLyhz/USERAPIKEYISHERE`
@@ -42,11 +40,17 @@ php artisan route:cache
php artisan cache:clear
```
-* Added YABS JSON parsing
-* Updated store YABS API function (Uses yabs.sh JSON)
-* Updated YABS POST API request (Uses yabs.sh JSON)
-* Updated server show page to display code to run and post a YABS on server
-* Updated pricing model insertPricing() func
+* Removed old method and functions for adding a YABS result
+* Fixed YABS JSON parser disk being the ram value
+* Fixed YABS JSON parser disk conversion (MB & GB)
+* Fixed YABS JSON parser RAM conversion (MB & GB)
+* Fixed OS icons for server index page (showing wrongly)
+* Added custom HTTP error pages
+* Updated yabs table for gb5 values to be nullable
+* Updated error alert component
+* Updated posting YABS now clears relevant caches
+* Updated models and controllers to use first()
+* Update yabs compare view blade for nullable values
## Requires
diff --git a/app/Http/Controllers/DiskSpeedController.php b/app/Http/Controllers/DiskSpeedController.php
index af0540d..15c1dd5 100644
--- a/app/Http/Controllers/DiskSpeedController.php
+++ b/app/Http/Controllers/DiskSpeedController.php
@@ -7,23 +7,5 @@ use Illuminate\Http\Request;
class DiskSpeedController extends Controller
{
- public function index()
- {
- //
- }
- public function create()
- {
- //
- }
-
- public function store(Request $request)
- {
- //
- }
-
- public function destroy(DiskSpeed $diskSpeed)
- {
- //
- }
}
diff --git a/app/Http/Controllers/DomainsController.php b/app/Http/Controllers/DomainsController.php
index 06d172e..18dc838 100644
--- a/app/Http/Controllers/DomainsController.php
+++ b/app/Http/Controllers/DomainsController.php
@@ -22,7 +22,7 @@ class DomainsController extends Controller
public function show(Domains $domain)
{//Need to modern
- $domain_info = Domains::domain($domain->id)[0];
+ $domain_info = Domains::domain($domain->id);
return view('domains.show', compact(['domain_info']));
}
@@ -67,7 +67,7 @@ class DomainsController extends Controller
public function edit(Domains $domain)
{
- $domain_info = Domains::domain($domain->id)[0];
+ $domain_info = Domains::domain($domain->id);
return view('domains.edit', compact(['domain_info']));
}
diff --git a/app/Http/Controllers/MiscController.php b/app/Http/Controllers/MiscController.php
index 5100381..92cacb8 100644
--- a/app/Http/Controllers/MiscController.php
+++ b/app/Http/Controllers/MiscController.php
@@ -25,7 +25,7 @@ class MiscController extends Controller
public function show(Misc $misc)
{
- $misc_data = Misc::misc($misc->id)[0];
+ $misc_data = Misc::misc($misc->id);
return view('misc.show', compact(['misc_data']));
}
@@ -58,7 +58,7 @@ class MiscController extends Controller
public function edit(Misc $misc)
{
- $misc_data = Misc::misc($misc->id)[0];
+ $misc_data = Misc::misc($misc->id);
return view('misc.edit', compact('misc_data'));
}
diff --git a/app/Http/Controllers/NetworkSpeedController.php b/app/Http/Controllers/NetworkSpeedController.php
index df8487d..8698fb1 100644
--- a/app/Http/Controllers/NetworkSpeedController.php
+++ b/app/Http/Controllers/NetworkSpeedController.php
@@ -7,18 +7,4 @@ use Illuminate\Http\Request;
class NetworkSpeedController extends Controller
{
- public function index()
- {
- //
- }
-
- public function show(NetworkSpeed $networkSpeed)
- {
- //
- }
-
- public function destroy(NetworkSpeed $networkSpeed)
- {
- //
- }
}
diff --git a/app/Http/Controllers/ResellerController.php b/app/Http/Controllers/ResellerController.php
index f74949c..a6086a0 100644
--- a/app/Http/Controllers/ResellerController.php
+++ b/app/Http/Controllers/ResellerController.php
@@ -29,7 +29,6 @@ class ResellerController extends Controller
public function store(Request $request)
{
-
$request->validate([
'domain' => 'required|min:4',
'reseller_type' => 'required',
@@ -94,13 +93,13 @@ class ResellerController extends Controller
public function show(Reseller $reseller)
{
- $reseller = Reseller::resellerHosting($reseller->id)[0];
+ $reseller = Reseller::resellerHosting($reseller->id);
return view('reseller.show', compact(['reseller']));
}
public function edit(Reseller $reseller)
{
- $reseller = Reseller::resellerHosting($reseller->id)[0];
+ $reseller = Reseller::resellerHosting($reseller->id);
return view('reseller.edit', compact(['reseller']));
}
diff --git a/app/Http/Controllers/SeedBoxesController.php b/app/Http/Controllers/SeedBoxesController.php
index b6182f6..73c7109 100644
--- a/app/Http/Controllers/SeedBoxesController.php
+++ b/app/Http/Controllers/SeedBoxesController.php
@@ -78,13 +78,13 @@ class SeedBoxesController extends Controller
public function show(SeedBoxes $seedbox)
{
- $seedbox_data = SeedBoxes::seedbox($seedbox->id)[0];
+ $seedbox_data = SeedBoxes::seedbox($seedbox->id);
return view('seedboxes.show', compact(['seedbox_data']));
}
public function edit(SeedBoxes $seedbox)
{
- $seedbox_data = SeedBoxes::seedbox($seedbox->id)[0];
+ $seedbox_data = SeedBoxes::seedbox($seedbox->id);
return view('seedboxes.edit', compact(['seedbox_data']));
}
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index 1058447..9074f7a 100644
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -118,14 +118,14 @@ class ServerController extends Controller
public function show(Server $server)
{
- $server_data = Server::server($server->id)[0];
+ $server_data = Server::server($server->id);
return view('servers.show', compact(['server_data']));
}
public function edit(Server $server)
{
- $server_data = Server::server($server->id)[0];
+ $server_data = Server::server($server->id);
return view('servers.edit', compact(['server_data']));
}
diff --git a/app/Http/Controllers/SharedController.php b/app/Http/Controllers/SharedController.php
index 4067bb9..b83e6f7 100644
--- a/app/Http/Controllers/SharedController.php
+++ b/app/Http/Controllers/SharedController.php
@@ -90,13 +90,13 @@ class SharedController extends Controller
public function show(Shared $shared)
{
- $shared = Shared::sharedHosting($shared->id)[0];
+ $shared = Shared::sharedHosting($shared->id);
return view('shared.show', compact(['shared']));
}
public function edit(Shared $shared)
{
- $shared = Shared::sharedHosting($shared->id)[0];
+ $shared = Shared::sharedHosting($shared->id);
return view('shared.edit', compact(['shared']));
}
diff --git a/app/Http/Controllers/YabsController.php b/app/Http/Controllers/YabsController.php
index 4c2e6c6..daa7a48 100644
--- a/app/Http/Controllers/YabsController.php
+++ b/app/Http/Controllers/YabsController.php
@@ -22,100 +22,12 @@ class YabsController extends Controller
public function create()
{
- $Servers = Server::all();
- return view('yabs.create', compact(['Servers']));
+ abort(404);//Use new YABS json output POST method -s "URL"
}
public function store(Request $request)
{
- $process = new Process();
-
- $yabs = $process->yabsOutputAsJson($request->server_id, $request->yabs);
-
- if (isset($yabs['error_id'])) {
- return back()->withErrors(["yabs" => 'Problem inserting YABs. Error id ' . $yabs['error_id']])->withInput();
- }
- //No errors, do insert
-
- $yabs_id = Str::random(8);
-
- Yabs::create([
- 'id' => $yabs_id,
- 'server_id' => $request->server_id,
- 'has_ipv6' => $yabs['has_ipv6'],
- 'aes' => $yabs['aes'],
- 'vm' => $yabs['vm'],
- 'output_date' => $yabs['output_date'],
- 'cpu_cores' => $yabs['cpu_cores'],
- 'cpu_freq' => $yabs['cpu_freq'],
- 'cpu_model' => $yabs['cpu'],
- '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'],
- 'uptime' => $yabs['uptime'],
- 'distro' => $yabs['distro'],
- 'kernel' => $yabs['kernel']
- ]);
-
- DiskSpeed::create([
- 'id' => $yabs_id,
- 'server_id' => $request->server_id,
- 'd_4k' => $yabs['disk_speed']['4k_total'],
- 'd_4k_type' => $yabs['disk_speed']['4k_total_type'],
- 'd_4k_as_mbps' => $yabs['disk_speed']['4k_total_mbps'],
- 'd_64k' => $yabs['disk_speed']['64k_total'],
- 'd_64k_type' => $yabs['disk_speed']['64k_total_type'],
- 'd_64k_as_mbps' => $yabs['disk_speed']['64k_total_mbps'],
- 'd_512k' => $yabs['disk_speed']['512k_total'],
- 'd_512k_type' => $yabs['disk_speed']['512k_total_type'],
- 'd_512k_as_mbps' => $yabs['disk_speed']['512k_total_mbps'],
- 'd_1m' => $yabs['disk_speed']['1m_total'],
- 'd_1m_type' => $yabs['disk_speed']['1m_total_type'],
- 'd_1m_as_mbps' => $yabs['disk_speed']['1m_total_mbps']
- ]);
-
- foreach ($yabs['network_speed'] as $y) {
- NetworkSpeed::create([
- 'id' => $yabs_id,
- 'server_id' => $request->server_id,
- 'location' => $y['location'],
- 'send' => $y['send'],
- 'send_type' => $y['send_type'],
- 'send_as_mbps' => $y['send_type_mbps'],
- 'receive' => $y['receive'],
- 'receive_type' => $y['receive_type'],
- 'receive_as_mbps' => $y['receive_type_mbps']
- ]);
- }
-
- $update_server = DB::table('servers')
- ->where('id', $request->server_id)
- ->update([
- 'ram' => $yabs['ram'],
- 'ram_type' => $yabs['ram_type'],
- 'ram_as_mb' => ($yabs['ram_type'] === 'GB') ? ($yabs['ram'] * 1024) : $yabs['ram'],
- 'disk' => $yabs['disk'],
- 'disk_type' => $yabs['disk_type'],
- 'disk_as_gb' => ($yabs['disk_type'] === 'TB') ? ($yabs['disk'] * 1024) : $yabs['disk'],
- 'cpu' => $yabs['cpu_cores'],
- 'has_yabs' => 1
- ]);
-
- Cache::forget('all_active_servers');//all servers cache
- Cache::forget('non_active_servers');//all servers cache
- Cache::forget('all_yabs');//Forget the all YABs cache
-
- return redirect()->route('yabs.index')
- ->with('success', 'Success inserting YABs');
+ abort(404);//Storing YABS now done through APiController
}
public function show(Yabs $yab)
@@ -145,7 +57,13 @@ class YabsController extends Controller
public function chooseYabsCompare()
{
$all_yabs = Yabs::allYabs();
- return view('yabs.choose-compare', compact('all_yabs'));
+
+ if (isset($all_yabs[1])){
+ return view('yabs.choose-compare', compact('all_yabs'));
+ }
+
+ return redirect()->route('yabs.index')
+ ->with('error', 'You need atleast 2 YABS to do a compare');
}
public function compareYabs($yabs1, $yabs2)
@@ -171,5 +89,4 @@ class YabsController extends Controller
return Yabs::buildYabsArray($all_yabs);
}
-
}
diff --git a/app/Models/Domains.php b/app/Models/Domains.php
index 64d76c1..c6cb7d0 100644
--- a/app/Models/Domains.php
+++ b/app/Models/Domains.php
@@ -31,7 +31,7 @@ class Domains extends Model
{//Single domains and relationships (no using joins)
return Cache::remember("domain.$domain_id", now()->addMonth(1), function () use ($domain_id) {
return Domains::where('id', $domain_id)
- ->with(['provider', 'price', 'labels', 'labels.label'])->get();
+ ->with(['provider', 'price', 'labels', 'labels.label'])->first();
});
}
diff --git a/app/Models/Misc.php b/app/Models/Misc.php
index bcd9459..91af70b 100644
--- a/app/Models/Misc.php
+++ b/app/Models/Misc.php
@@ -29,7 +29,7 @@ class Misc extends Model
{//Single misc and relationships (no using joins)
return Cache::remember("misc.$misc_id", now()->addMonth(1), function () use ($misc_id) {
return Misc::where('id', $misc_id)
- ->with(['price'])->get();
+ ->with(['price'])->first();
});
}
diff --git a/app/Models/Reseller.php b/app/Models/Reseller.php
index ecb81c7..9b3ae08 100644
--- a/app/Models/Reseller.php
+++ b/app/Models/Reseller.php
@@ -30,7 +30,7 @@ class Reseller extends Model
{//Single reseller hosting and relationships (no using joins)
return Cache::remember("reseller_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) {
return Reseller::where('id', $shared_id)
- ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
+ ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->first();
});
}
diff --git a/app/Models/SeedBoxes.php b/app/Models/SeedBoxes.php
index 9924c2d..7df318f 100644
--- a/app/Models/SeedBoxes.php
+++ b/app/Models/SeedBoxes.php
@@ -30,7 +30,7 @@ class SeedBoxes extends Model
{//Single seedbox and relationships (no using joins)
return Cache::remember("seedbox.$seedbox_id", now()->addMonth(1), function () use ($seedbox_id) {
return SeedBoxes::where('id', $seedbox_id)
- ->with(['location', 'provider', 'price', 'labels.label'])->get();
+ ->with(['location', 'provider', 'price', 'labels.label'])->first();
});
}
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 683679c..c19d8d0 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -37,7 +37,7 @@ class Server extends Model
{//Single server and relationships (no using joins)
return Cache::remember("server.$server_id", now()->addMonth(1), function () use ($server_id) {
return Server::where('id', $server_id)
- ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'labels.label'])->get();
+ ->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'labels.label'])->first();
});
}
@@ -91,17 +91,17 @@ class Server extends Model
return "";
} else if ($os <= 3) {//Centos
return "";
- } elseif ($os > 3 && $os <= 6) {//Debain
+ } elseif ($os > 7 && $os <= 11) {//Debain
return "";
- } elseif ($os > 6 && $os < 10) {//Fedora
+ } elseif ($os > 12 && $os < 15) {//Fedora
return "";
- } elseif ($os > 10 && $os < 13) {//FreeBSD
+ } elseif ($os > 14 && $os < 18) {//FreeBSD
return "";
- } elseif ($os > 13 && $os < 16) {//OpenBSD
+ } elseif ($os > 17 && $os < 21) {//OpenBSD
return "";
- } elseif ($os > 15 && $os < 21) {//Ubuntu
+ } elseif ($os > 25 && $os < 32) {//Ubuntu
return "";
- } elseif ($os > 20 && $os < 26) {//Windows
+ } elseif ($os > 32 && $os < 38) {//Windows
return "";
} else {//OTHER ISO CUSTOM etc
return "";
diff --git a/app/Models/Shared.php b/app/Models/Shared.php
index b02ccb3..769e766 100644
--- a/app/Models/Shared.php
+++ b/app/Models/Shared.php
@@ -30,7 +30,7 @@ class Shared extends Model
{//Single shared hosting and relationships (no using joins)
return Cache::remember("shared_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) {
return Shared::where('id', $shared_id)
- ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->get();
+ ->with(['location', 'provider', 'price', 'ips', 'labels', 'labels.label'])->first();
});
}
diff --git a/app/Models/Yabs.php b/app/Models/Yabs.php
index 8ee2fe4..0aa9c40 100644
--- a/app/Models/Yabs.php
+++ b/app/Models/Yabs.php
@@ -196,7 +196,7 @@ class Yabs extends Model
$yabs_id = Str::random(8);
- if ($ram > 10) {
+ if ($ram > 999999) {
$ram_f = ($ram / 1024 / 1024);
$ram_type = 'GB';
} else {
@@ -204,11 +204,11 @@ class Yabs extends Model
$ram_type = 'MB';
}
- if ($disk > 10000) {
- $disk_f = ($ram / 1024 / 1024);
+ if ($disk > 100000000) {
+ $disk_f = ($disk / 1024 / 1024 / 1024);
$disk_type = 'TB';
} else {
- $disk_f = ($ram / 1024);
+ $disk_f = ($disk / 1024 / 1024);
$disk_type = 'GB';
}
@@ -242,23 +242,23 @@ class Yabs extends Model
//Fio
foreach ($data['fio'] as $ds) {
if ($ds['bs'] === '4k') {
- $d4k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw'];
- $d4k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s';
+ $d4k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
+ $d4k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d4k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '64k') {
- $d64k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw'];
- $d64k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s';
+ $d64k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
+ $d64k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d64k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '512k') {
- $d512k = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw'];
- $d512k_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s';
+ $d512k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
+ $d512k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d512k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '1m') {
- $d1m = ($ds['speed_rw'] > 1000000) ? ($ds['speed_rw'] / 1000) : $ds['speed_rw'];
- $d1m_type = ($ds['speed_rw'] > 1000000) ? 'GB/s' : 'MB/s';
+ $d1m = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
+ $d1m_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d1m_mbps = self::KBstoMBs($ds['speed_rw']);
}
}
@@ -314,6 +314,11 @@ class Yabs extends Model
'has_yabs' => 1
]);
+ Cache::forget("yabs.$yabs_id");
+ Cache::forget("all_yabs");
+ Cache::forget("server.$server_id");
+ Cache::forget("all_servers");
+
} catch (Exception $e) {//Not valid JSON
return false;
}
diff --git a/app/Process.php b/app/Process.php
index 0d3e7a3..4bd0e95 100644
--- a/app/Process.php
+++ b/app/Process.php
@@ -44,406 +44,4 @@ class Process
return "unknown";
}
}
-
- private function floatValue(string $string): float
- {//Keeps only numbers and . AKA a float
- return preg_replace('/[^0-9,.]/', '', trim($string));
- }
-
- private function intValue(string $string): int
- {//Keeps only numbers AKA an int
- return (int)preg_replace('/[^0-9]/', '', trim($string));
- }
-
- private function removeFloat(string $string): string
- {//Removes float from a string
- return ltrim(preg_replace('/[^A-Za-z\-,.]/', '', $string), '.');
- }
-
- private function trimRemoveR(string $string): string
- {//Removes \r and does a trim()
- return trim(str_replace("\r", '', $string));
- }
-
- private function datatype(string $string): string
- {//Formats data type (ram and disk)
- if (str_contains($string, 'M')) {
- return 'MB';//Megabytes
- } elseif (str_contains($string, 'G')) {
- return 'GB';//Gigabytes
- } elseif (str_contains($string, 'K')) {
- return 'KB';//Kilobytes
- } elseif (str_contains($string, 'T')) {
- return 'TB';//TeraBytes
- } elseif (str_contains($string, 'B')) {
- return 'BT';//Bytes
- } else {
- return "GB";
- }
- }
-
- private function GBtoMB(string $gb): float
- {//Gigabyte to Megabyte conversion
- return ($gb * 1024);
- }
-
- private function TBtoGB(string $tb): float
- {//Terabyte to Gigabyte conversion
- return ($tb * 1024);
- }
-
- private function GBpstoMBps(string $gbps, bool $format = false): float
- {//Gigabits to Megabits
- if ($format) {
- return (float)number_format(((float)$gbps * 1024), 3);
- }
- return (float)$gbps * 1024;
- }
-
- private function diskSpeedAsMbps(string $type, string $value): float
- {//If value type GB/s convert to MB/s, KB/s to MB/s
- if ($type === "GB/s") {
- return $this->GBpstoMBps($value);
- }
- if ($type === "KB/s") {
- return (float)($value / 1024);
- }
- return $value;
- }
-
- private function networkSpeedAsMbps(string $type, string $value): float
- {//If value type GBps convert to MB/s
- if ($type === "GBps") {
- return $this->GBpstoMBps($value);
- }
- return $value;
- }
-
- private function yabsSpeedValues(array $data): array
- {//Formats YABs speed test for speed value and type as array
- $data = explode('|', implode($data));
- if ($data[2] === 'busy') {
- $send = $send_type = NULL;
- } else {
- $send = (float)$data[2];
- if ($this->removeFloat($data[2]) === 'Mbitssec') {
- $send_type = "MBps";
- } elseif ($this->removeFloat($data[2]) === 'Gbitssec') {
- $send_type = "GBps";
- } elseif ($this->removeFloat($data[2]) === 'Kbitssec') {
- $send_type = "KBps";
- } else {
- $send_type = $this->removeFloat($data[2]);
- }
- }
- if ($data[3] === 'busy') {
- $receive = $receive_type = NULL;
- } else {
- $receive = (float)$data[3];
- if ($this->removeFloat($data[3]) === 'Mbitssec') {
- $receive_type = "MBps";
- } elseif ($this->removeFloat($data[3]) === 'Gbitssec') {
- $receive_type = "GBps";
- } elseif ($this->removeFloat($data[3]) === 'Kbitssec') {
- $receive_type = "KBps";
- } else {
- $receive_type = $this->removeFloat($data[3]);
- }
- }
- return array('send' => $send, 'send_type' => $send_type, 'receive' => $receive, 'receive_type' => $receive_type);
- }
-
- private function yabsSpeedLoc(array $data): array
- {//Formats YABs speed test provider and location as array
- if ($data[1] === '|') {
- $provider = $data[0];
- } else {
- $provider = $data[0] . ' ' . $data[1];
- }
- if ($data[2] !== '|') {
- $location = $data[2] . ' ' . str_replace(',', '', $data[3]);
- } else {
- $location = $data[3] . ' ' . str_replace(',', '', $data[4]);
- }
- return array('provider' => $provider, 'location' => $location);
- }
-
- public function yabsOutputAsJson(string $server_id, string $data_from_form): array
- {
- $allowed_versions = ['v2021-12-28', 'v2022-02-18', 'v2022-04-30', 'v2022-05-06', 'v2022-06-11', 'v2022-08-20'];
-
- $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);
- 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);//Good for debugging the lines
-
- if (count($array) < 46) {
- return array('error_id' => 9, 'error_message' => 'Less than 46 lines');
- }
-
- if (str_contains($array[0], "# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #")) {
- if (!str_contains($array[1],"# Yet-Another-Bench-Script #")) {
- return array('error_id' => 8, 'error_message' => 'Didnt copy output correctly');
- }
-
- $version_array = explode(' ', preg_replace('!\s+!', ' ', $this->trimRemoveR($array[2])));
- if (in_array($version_array[1], $allowed_versions, true)) {//YABs version is allowed
- if ($version_array[1] === 'v2022-05-06' || $version_array[1] === 'v2022-06-11') {//These versions added in more responses
- $cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[11], ': ')));
- $cpu_spec = explode(' ', strstr($array[12], ': '));//: 2 @ 3792.872 MHz
- $ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[15], ': ')));
- $ram = (float)$ram_line;
- $ram_type = $this->datatype($ram_line);
- $swap_line = $this->trimRemoveR(str_replace(':', '', strstr($array[16], ': ')));
- $swap = (float)$swap_line;
- $swap_type = $this->datatype($swap_line);
- $disk_line = $this->trimRemoveR(str_replace(':', '', strstr($array[17], ': ')));
- $disk = (float)$disk_line;
- $disk_type = $this->datatype($disk_line);
- $io_3 = explode(' ', preg_replace('!\s+!', ' ', $array[27]));
- $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
- $ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[14], ': ')));
- $ram = (float)$ram_line;
- $ram_type = $this->datatype($ram_line);
- $swap_line = $this->trimRemoveR(str_replace(':', '', strstr($array[15], ': ')));
- $swap = (float)$swap_line;
- $swap_type = $this->datatype($swap_line);
- $disk_line = $this->trimRemoveR(str_replace(':', '', strstr($array[16], ': ')));
- $disk = (float)$disk_line;
- $disk_type = $this->datatype($disk_line);
- $io_3 = explode(' ', preg_replace('!\s+!', ' ', $array[24]));
- $io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[30]));
- (str_contains($array[12], 'Enabled')) ? $aes_ni = true : $aes_ni = false;
- (str_contains($array[13], 'Enabled')) ? $vm_amd_v = true : $vm_amd_v = false;
- }
- $cpu_cores = $cpu_spec[1];
- $cpu_freq = $cpu_spec[3];
-
-
- $d4k_as_mbps = $this->diskSpeedAsMbps($io_3[3], $this->floatValue($io_3[2]));
- $d64k_as_mbps = $this->diskSpeedAsMbps($io_3[7], $this->floatValue($io_3[6]));
- $d512k_as_mbps = $this->diskSpeedAsMbps($io_6[3], $this->floatValue($io_6[2]));
- $d1m_as_mbps = $this->diskSpeedAsMbps($io_6[7], $this->floatValue($io_6[6]));
- $disk_test_arr = array(
- '4k_total' => $this->floatValue($io_3[2]),
- '4k_total_type' => $io_3[3],
- '4k_total_mbps' => $d4k_as_mbps,
- '64k_total' => $this->floatValue($io_3[6]),
- '64k_total_type' => $io_3[7],
- '64k_total_mbps' => $d64k_as_mbps,
- '512k_total' => $this->floatValue($io_6[2]),
- '512k_total_type' => $io_6[3],
- '512k_total_mbps' => $d512k_as_mbps,
- '1m_total' => $this->floatValue($io_6[6]),
- '1m_total_type' => $io_6[7],
- '1m_total_mbps' => $d1m_as_mbps,
- );
-
- if (isset($array[40])) {
- if ($version_array[1] === 'v2022-05-06' || $version_array[1] === 'v2022-06-11') {
- if (str_contains($array[43], "Geekbench 5 Benchmark Test:")) {
- //No ipv6
- //Has short ipv4 network speed testing (-r)
- $has_ipv6 = false;
- $start_st = 39;
- $end_st = 41;
- $gb_s = 47;
- $gb_m = 48;
- $gb_url = 49;
- } elseif (str_contains($array[45], "Geekbench 4 Benchmark Test:")) {
- return array('error_id' => 6, 'error_message' => 'GeekBench 5 only allowed');
- } elseif ($array[45] === "Geekbench 5 test failed. Run manually to determine cause.\r") {
- return array('error_id' => 7, 'error_message' => 'GeekBench test failed');
- } elseif (str_contains($array[46], "Geekbench 5 Benchmark Test:")) {
- //No ipv6
- //Has full ipv4 network speed testing
- $has_ipv6 = false;
- $start_st = 39;
- $end_st = 44;
- $gb_s = 44;
- $gb_m = 45;
- $gb_url = 46;
- } elseif (str_contains($array[47], "Geekbench 5 Benchmark Test:")) {
- //No ipv6
- //Has full ipv4 network speed testing
- $has_ipv6 = false;
- $start_st = 39;
- $end_st = 45;
- $gb_s = 51;
- $gb_m = 52;
- $gb_url = 53;
- } elseif (str_contains($array[43], "iperf3 Network Speed Tests (IPv6):")) {
- //HAS ipv6
- //Has short ipv4 & ipv6 network speed testing
- $has_ipv6 = true;
- $start_st = 39;
- $end_st = 41;
- $gb_s = 55;
- $gb_m = 56;
- $gb_url = 57;
- } elseif (str_contains($array[56], "Geekbench 5 Benchmark Test:")) {
- //HAS ipv6
- //Has full ipv4 & ipv6 network speed testing
- $has_ipv6 = true;
- $start_st = 39;
- $end_st = 44;
- $gb_s = 60;
- $gb_m = 61;
- $gb_url = 62;
- } elseif (str_contains($array[59], "Geekbench 5 Benchmark Test:")) {
- //HAS ipv6
- //Has full ipv4 & ipv6 network speed testing
- $has_ipv6 = true;
- $start_st = 39;
- $end_st = 45;
- $gb_s = 63;
- $gb_m = 64;
- $gb_url = 65;
- } else {
- return array('error_id' => 5, 'error_message' => 'Not correct YABs command output');
- }
- } else {
- if (str_contains($array[45], "Geekbench 5 Benchmark Test:")) {
- //No ipv6
- //Has short ipv4 network speed testing (-r)
- $has_ipv6 = false;
- $start_st = 36;
- $end_st = 43;
- $gb_s = 49;
- $gb_m = 50;
- $gb_url = 51;
- } elseif (str_contains($array[45], "Geekbench 4 Benchmark Test:")) {
- return array('error_id' => 6, 'error_message' => 'GeekBench 5 only allowed');
- } elseif (str_contains($array[45], "Geekbench 5 test failed. Run manually to determine cause.")) {
- return array('error_id' => 7, 'error_message' => 'GeekBench test failed');
- } elseif (str_contains($array[40], "Geekbench 5 Benchmark Test:")) {
- //No ipv6
- //Has full ipv4 network speed testing
- $has_ipv6 = false;
- $start_st = 36;
- $end_st = 38;
- $gb_s = 44;
- $gb_m = 45;
- $gb_url = 46;
- } elseif (str_contains($array[40], "iperf3 Network Speed Tests (IPv6):")) {
- //HAS ipv6
- //Has short ipv4 & ipv6 network speed testing
- $has_ipv6 = true;
- $start_st = 36;
- $end_st = 38;
- $gb_s = 52;
- $gb_m = 53;
- $gb_url = 54;
- } elseif (str_contains($array[56], "Geekbench 5 Benchmark Test:")) {
- //HAS ipv6
- //Has full ipv4 & ipv6 network speed testing
- $has_ipv6 = true;
- $start_st = 36;
- $end_st = 43;
- $gb_s = 60;
- $gb_m = 61;
- $gb_url = 62;
- } else {
- return array('error_id' => 5, 'error_message' => 'Not correct YABs command output');
- }
- }
- } else {
- return array('error_id' => 4, 'error_message' => 'Not correct formatting');
- }
- $geekbench_single = $this->intValue($array[$gb_s]);
- $geekbench_multi = $this->intValue($array[$gb_m]);
- $geek_full_url = explode(' ', preg_replace('!\s+!', ' ', $array[$gb_url]));
- $gb5_id = (int)substr($geek_full_url[3], strrpos($geek_full_url[3], '/') + 1);//
- $has_a_speed_test = false;
-
- ($ram_type === 'GB') ? $ram_mb = $this->GBtoMB($ram) : $ram_mb = $ram;
- ($swap_type === 'GB') ? $swap_mb = $this->GBtoMB($swap) : $swap_mb = $swap;
- ($disk_type === 'TB') ? $disk_gb = $this->TBtoGB($disk) : $disk_gb = $disk;
-
- $date = date_create($array[6]);
-
- $output = [
- 'id' => $server_id,
- 'has_ipv6' => $has_ipv6,
- 'output_date' => date_format($date, 'Y-m-d H:i:s'),
- 'process_date' => date('Y-m-d H:i:s'),
- 'cpu_cores' => (int)$cpu_cores,
- 'cpu_freq' => (float)$cpu_freq,
- 'cpu' => $cpu,
- 'ram' => $ram,
- 'ram_type' => $ram_type,
- 'ram_mb' => $ram_mb,
- 'swap' => $swap,
- 'swap_type' => $swap_type,
- 'swap_mb' => $swap_mb,
- 'disk' => $disk,
- 'disk_type' => $disk_type,
- 'disk_gb' => $disk_gb,
- 'aes' => $aes_ni,
- 'vm' => $vm_amd_v,
- 'GB5_single' => $geekbench_single,
- 'GB5_mult' => $geekbench_multi,
- 'GB5_id' => $gb5_id,
- 'uptime' => $uptime ?? null,
- 'distro' => $distro ?? null,
- 'kernel' => $kernel ?? null,
- ];
-
- $output['disk_speed'] = $disk_test_arr;
-
- $speed_test_arr = array();
-
- for ($i = $start_st; $i <= $end_st; $i++) {
- if (str_contains($array[$i], 'busy')) {
- //Has a "busy" result, No insert
- } else {
- $data = explode(' ', preg_replace('!\s+!', ' ', $array[$i]));
- $send_as_mbps = $this->networkSpeedAsMbps($this->yabsSpeedValues($data)['send_type'], $this->yabsSpeedValues($data)['send']);
- $recieve_as_mbps = $this->networkSpeedAsMbps($this->yabsSpeedValues($data)['receive_type'], $this->yabsSpeedValues($data)['receive']);
- $speed_test_arr[] = array(
- 'location' => $this->yabsSpeedLoc($data)['location'],
- 'send' => $this->yabsSpeedValues($data)['send'],
- 'send_type' => $this->yabsSpeedValues($data)['send_type'],
- 'send_type_mbps' => $send_as_mbps,
- 'receive' => $this->yabsSpeedValues($data)['receive'],
- 'receive_type' => $this->yabsSpeedValues($data)['receive_type'],
- 'receive_type_mbps' => $recieve_as_mbps
- );
- $has_a_speed_test = true;
- }
- }
-
- if ($has_a_speed_test) {
- $output['network_speed'] = $speed_test_arr;
- }
- return $output;
- } else {
- return array('error_id' => 4, 'error_message' => 'Wrong YABs version');
- }
- } else {
- return array('error_id' => 3, 'error_message' => 'Didnt start at right spot');
- }
- }
-
-
}
diff --git a/database/migrations/2022_09_22_020501_update_yabs_table.php b/database/migrations/2022_09_22_020501_update_yabs_table.php
new file mode 100644
index 0000000..985347f
--- /dev/null
+++ b/database/migrations/2022_09_22_020501_update_yabs_table.php
@@ -0,0 +1,18 @@
+integer('gb5_single')->nullable()->change();
+ $table->integer('gb5_multi')->nullable()->change();
+ $table->integer('gb5_id')->nullable()->change();
+ });
+ }
+};
diff --git a/resources/views/components/errors-alert.blade.php b/resources/views/components/errors-alert.blade.php
index f89787e..e4c357a 100644
--- a/resources/views/components/errors-alert.blade.php
+++ b/resources/views/components/errors-alert.blade.php
@@ -1,9 +1,5 @@
-@if ($errors->any())
-
{{ $message }}
+{{$message}}
- @endif - -@yield('message'). Go home
+