Merge pull request #62 from cp6/Development

Development (2.1.6)
This commit is contained in:
corbpie 2022-09-22 13:31:20 +10:00 committed by GitHub
commit e0f9f27414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 209 additions and 639 deletions

View File

@ -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.
[![Generic badge](https://img.shields.io/badge/version-2.1.5-blue.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Laravel-9.0-red.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/PHP-8.1-purple.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Bootstrap-5.1-pink.svg)](https://shields.io/)
[![Generic badge](https://img.shields.io/badge/version-2.1.6-blue.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Laravel-9.0-red.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/PHP-8.1-purple.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Bootstrap-5.1-pink.svg)](https://shields.io/)
<img src="https://raw.githubusercontent.com/cp6/my-idlers/main/public/My%20Idlers%20logo.jpg" width="128" height="128" />
@ -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

View File

@ -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)
{
//
}
}

View File

@ -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']));
}

View File

@ -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'));
}

View File

@ -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)
{
//
}
}

View File

@ -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']));
}

View File

@ -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']));
}

View File

@ -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']));
}

View File

@ -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']));
}

View File

@ -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);
}
}

View File

@ -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();
});
}

View File

@ -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();
});
}

View File

@ -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();
});
}

View File

@ -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();
});
}

View File

@ -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 "<i class='fas fa-expand' title='{$os_name}'></i>";
} else if ($os <= 3) {//Centos
return "<i class='fab fa-centos os-icon' title='{$os_name}'></i>";
} elseif ($os > 3 && $os <= 6) {//Debain
} elseif ($os > 7 && $os <= 11) {//Debain
return "<i class='fab fa-linux os-icon' title='{$os_name}'></i>";
} elseif ($os > 6 && $os < 10) {//Fedora
} elseif ($os > 12 && $os < 15) {//Fedora
return "<i class='fab fa-fedora os-icon' title='{$os_name}'></i>";
} elseif ($os > 10 && $os < 13) {//FreeBSD
} elseif ($os > 14 && $os < 18) {//FreeBSD
return "<i class='fab fa-linux os-icon' title='{$os_name}'></i>";
} elseif ($os > 13 && $os < 16) {//OpenBSD
} elseif ($os > 17 && $os < 21) {//OpenBSD
return "<i class='fab fa-linux os-icon' title='{$os_name}'></i>";
} elseif ($os > 15 && $os < 21) {//Ubuntu
} elseif ($os > 25 && $os < 32) {//Ubuntu
return "<i class='fab fa-ubuntu os-icon' title='{$os_name}'></i>";
} elseif ($os > 20 && $os < 26) {//Windows
} elseif ($os > 32 && $os < 38) {//Windows
return "<i class='fab fa-windows os-icon' title='{$os_name}'></i>";
} else {//OTHER ISO CUSTOM etc
return "<i class='fas fa-compact-disc os-icon' title='{$os_name}'></i>";

View File

@ -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();
});
}

View File

@ -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;
}

View File

@ -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');
}
}
}

View File

@ -0,0 +1,18 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('yabs', function($table)
{
$table->integer('gb5_single')->nullable()->change();
$table->integer('gb5_multi')->nullable()->change();
$table->integer('gb5_id')->nullable()->change();
});
}
};

View File

@ -1,9 +1,5 @@
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@if ($message = Session::get('error'))
<div class="alert alert-danger" role="alert">
<p class="my-1">{{ $message }}</p>
</div>
@endif

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Unauthorized'))
@section('code', '401')
@section('message', __('Unauthorized'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Forbidden'))
@section('code', '403')
@section('message', __($exception->getMessage() ?: 'Forbidden'))

View File

@ -1,51 +1,5 @@
@section('title') {{'Error'}}
@if(isset($status))
{{$status}}
@else
404
@endif
@endsection
@section('style')
<style>
.page-not-found-div {
height: 100vh;
}
@extends('errors::minimal')
.page-not-found-div h1 {
font-size: 8rem;
color: #e73974;
}
.page-not-found-div h3 {
font-size: 2.5rem;
}
.page-not-found-div .center-div {
width: 100%;
padding: 0.2rem;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
@endsection
<x-app-layout>
<div class="page-not-found-div">
<div class="center-div">
@if(isset($status))
<h1>{{$status}}</h1>
@else
<h1>Error</h1>
@endif
@if(isset($title))
<h3 class="mt-2">{{$title}}</h3>
@endif
@if(isset($message))
<p class="mt-4">{{$message}}</p>
@endif
<p class="mt-4"><a href="{{route('/')}}" class="text-decoration-none">Go home</a></p>
</div>
</div>
</x-app-layout>
@section('title', __('Not Found'))
@section('code', '404')
@section('message', __('Page not Found'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Page Expired'))
@section('code', '419')
@section('message', __('Page Expired'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Too Many Requests'))
@section('code', '429')
@section('message', __('Too Many Requests'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Server Error'))
@section('code', '500')
@section('message', __('Server Error'))

View File

@ -0,0 +1,5 @@
@extends('errors::minimal')
@section('title', __('Service Unavailable'))
@section('code', '503')
@section('message', __('Service Unavailable'))

View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title')</title>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.content {
text-align: center;
}
.title {
font-size: 36px;
padding: 20px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title">
@yield('message')
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@yield('title')</title>
<style>
@charset "UTF-8";h1,p{margin-top:0}.container,.row{--bs-gutter-x:1.5rem;--bs-gutter-y:0}.row,body{display:flex}.main,.sub{text-align:center!important}:root{--bs-body-color-rgb:33,37,41;--bs-body-bg-rgb:255,255,255;--bs-font-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg,rgba(255, 255, 255, 0.15),rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-bg:#fff;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-2xl:2rem;--bs-border-radius-pill:50rem;--bs-link-color:#0d6efd;--bs-link-hover-color:#0a58ca;--bs-code-color:#d63384;--bs-highlight-bg:#fff3cd}*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}.main,h1{font-weight:500;line-height:1.2}h1{margin-bottom:.5rem;font-size:calc(1.375rem + 1.5vw)}p{margin-bottom:1rem}a{color:var(--bs-link-color);color:#277dfd;text-decoration:none}a:hover{color:var(--bs-link-hover-color)}.container,.row>*{width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5)}.container{margin-right:auto;margin-left:auto}@media (min-width:576px){.container{max-width:540px}}@media (min-width:768px){.container{max-width:720px}}@media (min-width:992px){.container{max-width:960px}}@media (min-width:1200px){h1{font-size:2.5rem}.container{max-width:1140px}}@media (min-width:1400px){.container{max-width:1320px}}.row{flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;max-width:100%;margin-top:var(--bs-gutter-y)}.visually-hidden-focusable:not(:focus):not(:focus-within){position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.w-100{width:100%!important}.justify-content-center{justify-content:center!important}.m-auto{margin:auto!important}body,html{height:100%}body{align-items:center;background-color:#fbfbfb}.main{font-size:2.1rem;padding-bottom:.8rem!important;margin-bottom:0;padding-top:.2rem!important}.sub{font-size:1rem;font-weight:300;color:#000000a8}
</style>
</head>
<body>
<main class="w-100 m-auto">
<div class="container">
<div class="row justify-content-center">
<h1 class="main">@yield('code')</h1>
<p class="sub">@yield('message'). <a href="{{route('/')}}">Go home</a></p>
</div>
</div>
</main>
</body>
</html>

View File

@ -88,13 +88,21 @@
<tr>
<td class="td-nowrap">GB5 single</td>
<td class="td-nowrap">{{$yabs1_data[0]->gb5_single}}</td>
{!! \App\Models\Server::tableRowCompare($yabs1_data[0]->gb5_single, $yabs2_data[0]->gb5_single, '') !!}
@if(!is_null($yabs1_data[0]->gb5_single) && !is_null($yabs2_data[0]->gb5_single))
{!! \App\Models\Server::tableRowCompare($yabs1_data[0]->gb5_single, $yabs2_data[0]->gb5_single, '') !!}
@else
<td>-</td>
@endif
<td class="td-nowrap">{{$yabs2_data[0]->gb5_single}}</td>
</tr>
<tr>
<td class="td-nowrap">GB5 multi</td>
<td class="td-nowrap">{{$yabs1_data[0]->gb5_multi}}</td>
{!! \App\Models\Server::tableRowCompare($yabs1_data[0]->gb5_multi, $yabs2_data[0]->gb5_multi, '') !!}
@if(!is_null($yabs1_data[0]->gb5_multi) && !is_null($yabs2_data[0]->gb5_multi))
{!! \App\Models\Server::tableRowCompare($yabs1_data[0]->gb5_multi, $yabs2_data[0]->gb5_multi, '') !!}
@else
<td>-</td>
@endif
<td class="td-nowrap">{{$yabs2_data[0]->gb5_multi}}</td>
</tr>
<tr>
@ -181,7 +189,7 @@
</td>
</tr>
@endif
@if($yabs1_data[0]->network_speed[3]->location === $yabs2_data[0]->network_speed[3]->location)
@if(isset($yabs1_data[0]->network_speed[3]) && $yabs1_data[0]->network_speed[3]->location === $yabs2_data[0]->network_speed[3]->location)
<tr>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[3]->location}} send</td>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[3]->send_as_mbps}}<span
@ -199,7 +207,7 @@
</td>
</tr>
@endif
@if($yabs1_data[0]->network_speed[4]->location === $yabs2_data[0]->network_speed[4]->location)
@if(isset($yabs1_data[0]->network_speed[4]) && $yabs1_data[0]->network_speed[4]->location === $yabs2_data[0]->network_speed[4]->location)
<tr>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[4]->location}} send</td>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[4]->send_as_mbps}}<span
@ -217,7 +225,7 @@
</td>
</tr>
@endif
@if($yabs1_data[0]->network_speed[4]->location === $yabs2_data[0]->network_speed[5]->location)
@if(isset($yabs1_data[0]->network_speed[4]) && $yabs1_data[0]->network_speed[4]->location === $yabs2_data[0]->network_speed[5]->location)
<tr>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[4]->location}} send</td>
<td class="td-nowrap">{{$yabs1_data[0]->network_speed[4]->send_as_mbps}}<span

View File

@ -13,7 +13,6 @@
<div class="container" id="app">
<x-delete-confirm-modal></x-delete-confirm-modal>
<x-card class="shadow mt-3">
<a href="{{ route('yabs.create') }}" class="btn btn-primary mb-3">Add YABs</a>
<a href="{{ route('yabs.compare-choose') }}" class="btn btn-success mb-3">Compare YABs</a>
<x-errors-alert></x-errors-alert>
<x-success-alert></x-success-alert>