diff --git a/assets/css/style.css b/assets/css/style.css index b998a9d..f38fd27 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -1290,6 +1290,18 @@ button.close { color: #537cf7; } +.os-icon { + color: #6f6b6b; +} + +.green-fa { + color: #51bf51; +} + +.red-fa { + color: #bf5151; +} + .tab-pane { margin-top: .8rem } diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index 0a48a5a..dfd7019 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -294,6 +294,25 @@ $(document).on("click", "#fillIpv4", function () { } }); +$(document).on("click", "#checkUpStatus", function () { + var host_name = $(this).attr('value'); + var icon = $(this).children().first(); + if (host_name) { + $.ajax({ + type: "GET", + url: "check_up.php", + data: {"type": "check_up", "host": host_name}, + success: function (result) { + if (result == 1) { + icon.addClass("green-fa"); + } else { + icon.addClass("red-fa"); + } + } + }); + } +}); + $('#virt').change(function(){ if($(this).val() == 'DEDI'){ $('#dedi_cpu').prop("checked", true); diff --git a/calls.php b/calls.php index d6b5490..8e7bf9f 100644 --- a/calls.php +++ b/calls.php @@ -38,6 +38,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } elseif ($_GET['type'] == 'dns_search') { $idle->getIpForDomain($_GET['hostname'], $_GET['type']); + } elseif ($_GET['type'] == 'check_up') { + echo $idle->checkIsUp($_GET['host']); } } } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { @@ -64,7 +66,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } elseif ($_POST['type'] == 'server_modal_edit') {//Update the server info $update->updateServerFromModal(); $update->updateServerPricingFromModal(); - if (!is_null($_POST['me_yabs']) && !empty($_POST['me_yabs'])){ + if (!is_null($_POST['me_yabs']) && !empty($_POST['me_yabs'])) { $update->updateYabsData(); } } elseif ($_POST['type'] == 'shared_hosting_modal_edit') {//Update the shared hosting info diff --git a/class.php b/class.php index 5cdabd3..5e95f23 100644 --- a/class.php +++ b/class.php @@ -859,7 +859,7 @@ class idlers extends helperFunctions protected function vpsCard(string $id) { $select = $this->dbConnect()->prepare(" - SELECT servers.id,servers.hostname,servers.`cpu`,servers.cpu_freq,servers.ram,servers.ram_type,servers.`disk`, + SELECT servers.id,servers.hostname,servers.ipv4,servers.`cpu`,servers.cpu_freq,servers.ram,servers.ram_type,servers.`disk`, servers.disk_type,servers.os,servers.virt,servers.was_special,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd FROM servers INNER JOIN locations on servers.location = locations.id INNER JOIN providers on servers.provider = providers.id INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;"); @@ -874,7 +874,8 @@ class idlers extends helperFunctions $this->HTMLphrase('h4', 'hostname-header', $data['hostname']); $this->tagClose('div'); $this->colOpen('col-12 col-xl-2 os-col'); - $this->outputString($this->osIntToIcon($data['os'])); + (empty($data['ipv4']) || is_null($data['ipv4'])) ? $host = $data['hostname'] : $host = $data['ipv4']; + $this->outputString('' . $this->osIntToIcon($data['os']) . ''); $this->tagClose('div', 3); $this->tagOpen('div', 'card-body'); $this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term'])); @@ -2799,6 +2800,17 @@ class idlers extends helperFunctions return "";//Doesnt exist/null/empty/invalid } + public function checkIsUp(string $host, int $port = 80, int $wait_time = 1): int + {//Check if host/ip is "up" + if ($fp = @fsockopen($host, $port, $errCode, $errStr, $wait_time)) { + $result = 1; + } else { + $result = 0; + } + @fclose($fp); + return $result; + } + } class itemInsert extends idlers