"; } else if ($os <= 3) {//Centos return ""; } elseif ($os > 3 && $os <= 6) {//Debain return ""; } elseif ($os > 6 && $os < 10) {//Fedora return ""; } elseif ($os > 10 && $os < 13) {//FreeBSD return ""; } elseif ($os > 13 && $os < 16) {//OpenBSD return ""; } elseif ($os > 15 && $os < 21) {//Ubuntu return ""; } elseif ($os > 20 && $os < 26) {//Windows return ""; } else {//OTHER ISO CUSTOM etc return ""; } } public static function osIdAsString($os) { if ($os === "0") { return "None"; } elseif ($os === "1") { return "CentOS 7"; } elseif ($os === "2") { return "CentOS 8"; } elseif ($os === "3") { return "CentOS"; } elseif ($os === "4") { return "Debian 9"; } elseif ($os === "5") { return "Debian 10"; } elseif ($os === "6") { return "Debian"; } elseif ($os === "7") { return "Fedora 32"; } elseif ($os === "8") { return "Fedora 33"; } elseif ($os === "9") { return "Fedora"; } elseif ($os === "10") { return "FreeBSD 11.4"; } elseif ($os === "11") { return "FreeBSD 12.1"; } elseif ($os === "12") { return "FreeBSD"; } elseif ($os === "13") { return "OpenBSD 6.7"; } elseif ($os === "14") { return "OpenBSD 6.8"; } elseif ($os === "15") { return "OpenBSD"; } elseif ($os == "16") { return "Ubuntu 16.04"; } elseif ($os === "17") { return "Ubuntu 18.04"; } elseif ($os === "18") { return "Ubuntu 20.04"; } elseif ($os === "19") { return "Ubuntu 20.10"; } elseif ($os === "20") { return "Ubuntu"; } elseif ($os === "21") { return "Windows Server 2008"; } elseif ($os === "22") { return "Windows Server 2012"; } elseif ($os === "23") { return "Windows Server 2016"; } elseif ($os === "24") { return "Windows Server 2019"; } elseif ($os === "25") { return "Windows 10"; } elseif ($os === "26") { return "Custom"; } elseif ($os === "27") { return "Other"; } else { return "Unknown"; } } public static function tableRowCompare(string $val1, string $val2, string $value_type = '', bool $is_int = true) { //+303MBps $str = '' . $value_type . ''; if ($is_int) { $val1 = (int)$val1; $val2 = (int)$val2; } if ($val1 > $val2) {//val1 is greater than val2 $result = '+' . ($val1 - $val2); if (!empty($value_type)) { $result = '+' . ($val1 - $val2) . $value_append; } $str .= 'plus-td">' . $result . ''; } elseif ($val1 < $val2) {//val1 is less than val2 $result = '-' . ($val2 - $val1); if (!empty($value_type)) { $result = '-' . ($val2 - $val1) . $value_append; } $str .= 'neg-td">' . $result . ''; } else {//Equal $result = 0; if (!empty($value_type)) { $result = '0' . $value_append; } $str .= 'equal-td">' . $result . ''; } return $str; } public static function serverRelatedCacheForget(): void { Cache::forget('services_count');//Main page services_count cache Cache::forget('due_soon');//Main page due_soon cache Cache::forget('recently_added');//Main page recently_added cache Cache::forget('all_active_servers');//all servers cache Cache::forget('non_active_servers');//all servers cache Cache::forget('servers_summary');//servers summary cache Cache::forget('public_server_data');//public servers Cache::forget('all_pricing');//All pricing Cache::forget('services_count_all'); Cache::forget('pricing_breakdown'); } public static function serverSpecificCacheForget(string $server_id): void { Cache::forget("server_show_data.$server_id");//data for show Cache::forget("ip_addresses.$server_id");//ips for server Cache::forget("labels_for_service.$server_id");//labels for server Cache::forget("service_pricing.$server_id");//Pricing } public static function activeServersDataIndexPage() { return Cache::remember('all_active_servers', now()->addMonth(1), function () { return DB::table('servers as s') ->join('pricings as pr', 's.id', '=', 'pr.service_id') ->join('providers as p', 's.provider_id', '=', 'p.id') ->join('locations as l', 's.location_id', '=', 'l.id') ->join('os as o', 's.os_id', '=', 'o.id') ->where('s.active', '=', 1) ->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']); }); } public static function nonActiveServersDataIndexPage() { return Cache::remember('non_active_servers', now()->addMonth(1), function () { return DB::table('servers as s') ->join('pricings as pr', 's.id', '=', 'pr.service_id') ->join('providers as p', 's.provider_id', '=', 'p.id') ->join('locations as l', 's.location_id', '=', 'l.id') ->join('os as o', 's.os_id', '=', 'o.id') ->where('s.active', '=', 0) ->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']); }); } public static function serverDataShowPage(string $server_id) { return Cache::remember("server_show_data.$server_id", now()->addDay(1), function () use ($server_id) { return DB::table('servers as s') ->join('pricings as pr', 's.id', '=', 'pr.service_id') ->join('providers as p', 's.provider_id', '=', 'p.id') ->join('locations as l', 's.location_id', '=', 'l.id') ->join('os as o', 's.os_id', '=', 'o.id') ->Leftjoin('yabs as y', 's.id', '=', 'y.server_id') ->Leftjoin('disk_speed as ds', 'y.id', '=', 'ds.id') ->where('s.id', '=', $server_id) ->get(['s.*', 'p.name as provider', 'l.name as location', 'o.name as os_name', 'pr.*', 'y.*', 'ds.*']); }); } public static function publicServerData() { return Cache::remember('public_server_data', now()->addMonth(1), function () { return DB::table('servers as s') ->Join('pricings as pr', 's.id', '=', 'pr.service_id') ->Join('providers as p', 's.provider_id', '=', 'p.id') ->Join('locations as l', 's.location_id', '=', 'l.id') ->Join('os as o', 's.os_id', '=', 'o.id') ->LeftJoin('ips as i', 's.id', '=', 'i.service_id') ->LeftJoin('yabs as y', 's.id', '=', 'y.server_id') ->LeftJoin('disk_speed as ds', 'y.id', '=', 'ds.id') ->where('s.show_public', '=', 1) ->get(['pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'pr.service_id', 'p.name as provider_name', 'l.name as location', 'o.name as os_name', 'y.*', 'y.id as yabs_id', 'ds.*', 's.*', 'i.address as ip', 'i.is_ipv4']); }); } public static function serverCompareData(string $server_id) { return Cache::remember("server_compare.$server_id", now()->addMonth(1), function () use ($server_id) { return DB::table('servers as s') ->join('pricings as pr', 's.id', '=', 'pr.service_id') ->join('providers as p', 's.provider_id', '=', 'p.id') ->join('locations as l', 's.location_id', '=', 'l.id') ->Join('yabs as y', 's.id', '=', 'y.server_id') ->Join('disk_speed as ds', 'y.id', '=', 'ds.id') ->where('s.id', '=', $server_id) ->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*', 'y.*', 'y.id as yabs_id', 'ds.*']); }); } public static function serverYabsAmount(string $server_id): int { return DB::table('yabs') ->where('server_id', '=', $server_id) ->get()->count(); } }