');
$this->tagClose('div', 3);
}
protected function getProvider(int $provider)
{
$select = $this->dbConnect()->prepare("SELECT `name` FROM `providers` WHERE `id` = ? LIMIT 1;");
$select->execute([$provider]);
$row = $select->fetch(PDO::FETCH_ASSOC);
if (!empty($row)) {//Yes
return $row['name'];
} else {//NO
return null;
}
}
protected function getLocation(int $location)
{
$select = $this->dbConnect()->prepare("SELECT `name` FROM `locations` WHERE `id` = ? LIMIT 1;");
$select->execute([$location]);
$row = $select->fetch(PDO::FETCH_ASSOC);
if (!empty($row)) {//Yes
return $row['name'];
} else {//NO
return null;
}
}
public function serverDetails(string $id)
{
$select = $this->dbConnect()->prepare("SELECT id, hostname, location, provider, ipv4, ipv6, `cpu`, cpu_type, cpu_freq, ram, ram_type, swap, swap_type, `disk`, disk_type, bandwidth, bandwidth_type, gb5_single, gb5_multi, gb5_id, aes_ni, amd_v, is_dedicated, is_cpu_dedicated, was_special, os, still_have, DATE_FORMAT(`owned_since`, '%M %Y') as owned_since FROM `servers` WHERE `id` = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
return json_encode($data);
}
public function serverData(string $id)
{
$select = $this->dbConnect()->prepare("SELECT `has_yabs`, `has_st` FROM `servers` WHERE `id` = ? LIMIT 1;");
$select->execute([$id]);
$row = $select->fetch();
if ($row['has_yabs'] == 1 && $row['has_st'] == 1) {
$select = $this->dbConnect()->prepare("
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type,bandwidth,bandwidth_type,gb5_single,gb5_multi,gb5_id,aes_ni,amd_v,
is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,has_st,ns1,ns2,DATE_FORMAT(`owned_since`, '%M %Y') as owned_since, `owned_since` as owned_since_raw, `4k`,`4k_type`,`64k`,`64k_type`,`512k`,`512k_type`,`1m`,`1m_type`,
loc.name as location,send,send_type,recieve,recieve_type,price,currency,term,as_usd,per_month,next_dd,pr.name as provider
FROM servers INNER JOIN disk_speed ds on servers.id = ds.server_id
INNER JOIN speed_tests st on servers.id = st.server_id INNER JOIN locations loc on servers.location = loc.id
INNER JOIN providers pr on servers.provider = pr.id INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
$sel_st = $this->dbConnect()->prepare("SELECT `location`, `send`, `send_type`, `recieve`, `recieve_type` FROM `speed_tests` WHERE `server_id` = ? ORDER BY `datetime` DESC LIMIT 8;");
$sel_st->execute([$id]);
$speed_tests = $sel_st->fetchAll(PDO::FETCH_ASSOC);
$final = array_merge($speed_tests, $data);
return json_encode($final);
} elseif ($row['has_yabs'] == 1 && $row['has_st'] == 0) {
$select = $this->dbConnect()->prepare("
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type,bandwidth,bandwidth_type,gb5_single,gb5_multi,gb5_id,aes_ni,amd_v,
is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,has_st,ns1,ns2,DATE_FORMAT(`owned_since`, '%M %Y') as owned_since, `owned_since` as owned_since_raw, `4k`,`4k_type`,`64k`,`64k_type`,`512k`,`512k_type`,`1m`,`1m_type`,
loc.name as location,price,currency,term,as_usd,per_month,next_dd,pr.name as provider
FROM servers INNER JOIN disk_speed ds on servers.id = ds.server_id
INNER JOIN locations loc on servers.location = loc.id
INNER JOIN providers pr on servers.provider = pr.id INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
return json_encode($data);
} else {
$select = $this->dbConnect()->prepare("
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,swap,swap_type,`disk`,disk_type,
bandwidth,bandwidth_type,gb5_single,gb5_multi,gb5_id,aes_ni,amd_v,is_dedicated,is_cpu_dedicated,was_special,os,ssh_port,still_have,tags,notes,virt,has_yabs,ns1,ns2,
DATE_FORMAT(`owned_since`, '%M %Y') as owned_since,loc.name as location,price,currency,term,as_usd,per_month,next_dd,pr.name as provider
FROM servers INNER JOIN locations loc on servers.location = loc.id
INNER JOIN providers pr on servers.provider = pr.id INNER JOIN pricing on servers.id = pricing.server_id WHERE servers.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
return json_encode($data);
}
}
public function sharedHostingData(string $id)
{
$select = $this->dbConnect()->prepare("
SELECT shared_hosting.id as server_id, domain, domains_limit, emails, disk, disk_type, disk_as_gb, ftp, db, bandwidth, provider, location, was_special,
still_have, type, `owned_since` as owned_since_raw, DATE_FORMAT(`owned_since`, '%M %Y') as owned_since,loc.name as location,price,currency,term,as_usd,per_month,next_dd,pr.name as provider
FROM shared_hosting INNER JOIN locations loc on shared_hosting.location = loc.id
INNER JOIN providers pr on shared_hosting.provider = pr.id INNER JOIN pricing on shared_hosting.id = pricing.server_id WHERE shared_hosting.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
return json_encode($data);
}
public function domainData(string $id)
{
$select = $this->dbConnect()->prepare("
SELECT domains.id as server_id, domain, attached_to, ns1, ns2, still_have, `owned_since` as owned_since_raw, DATE_FORMAT(`owned_since`, '%M %Y') as owned_since,price,currency,term,as_usd,per_month,next_dd,pr.name as provider
FROM domains INNER JOIN providers pr on domains.provider = pr.id INNER JOIN pricing on domains.id = pricing.server_id WHERE domains.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
return json_encode($data);
}
protected function serverCards()
{
if (self::SRV_SORT_TYPE == 'HOSTNAME_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `hostname` DESC;");
} elseif (self::SRV_SORT_TYPE == 'HOSTNAME_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `hostname`;");
} elseif (self::SRV_SORT_TYPE == 'OWNED_SINCE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `owned_since` DESC;");
} elseif (self::SRV_SORT_TYPE == 'OWNED_SINCE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` ORDER BY `owned_since`;");
} elseif (self::SRV_SORT_TYPE == 'PRICE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `as_usd` DESC;");
} elseif (self::SRV_SORT_TYPE == 'PRICE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `as_usd`;");
} elseif (self::SRV_SORT_TYPE == 'DUE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `next_dd` DESC;");
} elseif (self::SRV_SORT_TYPE == 'DUE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers` INNER JOIN `pricing` ON servers.id = pricing.server_id ORDER BY `next_dd`;");
} else {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `servers`;");
}
$select->execute();
$count = $select->rowCount();
if ($count > 0) {
$this->HTMLPhrase('h4', 'card-section-header', 'Servers
' . $count . '');
}
$this->tagOpen('div', 'row');
while ($row = $select->fetch(PDO::FETCH_ASSOC)) {
$this->vpsCard($row['id']);
}
$this->tagClose('div');
}
protected function sharedHostingCards()
{
if (self::SH_SORT_TYPE == 'DOMAIN_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `domain` DESC;");
} elseif (self::SH_SORT_TYPE == 'DOMAIN_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `domain`;");
} elseif (self::SH_SORT_TYPE == 'OWNED_SINCE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `owned_since` DESC;");
} elseif (self::SH_SORT_TYPE == 'OWNED_SINCE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` ORDER BY `owned_since`;");
} elseif (self::SH_SORT_TYPE == 'PRICE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `as_usd` DESC;");
} elseif (self::SH_SORT_TYPE == 'PRICE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `as_usd`;");
} elseif (self::SH_SORT_TYPE == 'DUE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `next_dd` DESC;");
} elseif (self::SH_SORT_TYPE == 'DUE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting` INNER JOIN `pricing` ON shared_hosting.id = pricing.server_id ORDER BY `next_dd`;");
} else {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `shared_hosting`;");
}
$select->execute();
$count = $select->rowCount();
if ($count > 0) {
$this->HTMLPhrase('h4', 'card-section-header', 'Shared hosting
' . $count . '');
}
$this->tagOpen('div', 'row');
while ($row = $select->fetch(PDO::FETCH_ASSOC)) {
$this->SharedHostingCard($row['id']);
}
$this->tagClose('div');
}
protected function domainCards()
{
if (self::DC_SORT_TYPE == 'DOMAIN_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `domain` DESC;");
} elseif (self::DC_SORT_TYPE == 'DOMAIN_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `domain`;");
} elseif (self::DC_SORT_TYPE == 'OWNED_SINCE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `owned_since` DESC;");
} elseif (self::DC_SORT_TYPE == 'OWNED_SINCE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` ORDER BY `owned_since`;");
} elseif (self::DC_SORT_TYPE == 'PRICE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `as_usd` DESC;");
} elseif (self::DC_SORT_TYPE == 'PRICE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `as_usd`;");
} elseif (self::DC_SORT_TYPE == 'DUE_DESC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `next_dd` DESC;");
} elseif (self::DC_SORT_TYPE == 'DUE_ASC') {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains` INNER JOIN `pricing` ON domains.id = pricing.server_id ORDER BY `next_dd`;");
} else {
$select = $this->dbConnect()->prepare("SELECT `id` FROM `domains`;");
}
$select->execute();
$count = $select->rowCount();
if ($count > 0) {
$this->HTMLPhrase('h4', 'card-section-header', 'Domains
' . $count . '');
}
$this->tagOpen('div', 'row');
while ($row = $select->fetch(PDO::FETCH_ASSOC)) {
$this->domainCard($row['id']);
}
$this->tagClose('div');
}
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`,
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;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
($data['was_special'] == 1) ? $special = ' special-card' : $special = '';
(is_null($data['next_dd'])) ? $dd_class = 'no-dd' : $dd_class = 'dd-text';
$this->colOpen('col-12 col-sm-6 col-md-4 col-xl-3');
$this->tagOpen("div", "card obj-card$special");
$this->tagOpen('div', 'card-header');
$this->rowColOpen('row text-center', 'col-12 col-xl-10');
$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']));
$this->tagClose('div', 3);
$this->tagOpen('div', 'card-body');
$this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']));
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h6', 'provider', $data['provider']);
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h6', 'location', $data['location']);
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('p', $dd_class, "Due in {$this->processDueDate($data['id'], $data['term'], $data['next_dd'])} days");
$this->tagClose('div', 2);
$this->rowColOpen('row cpu-row', 'col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '' . $data['cpu'] . '
@' . $this->mhzToGhz($data['cpu_freq']) . '
Ghz');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '
' . $data['virt'] . '');
$this->tagClose('div', 2);
$this->rowColOpen('row mem-disk-row', 'col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '' . $data['ram'] . '
' . $data['ram_type'] . '');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '' . $data['disk'] . '
' . $data['disk_type'] . '');
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-6');
$this->outputString('
More');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('
Edit');
$this->tagClose('div', 5);
}
protected function SharedHostingCard(string $id)
{
$select = $this->dbConnect()->prepare("
SELECT shared_hosting.id,shared_hosting.domain,shared_hosting.disk_as_gb,shared_hosting.type,shared_hosting.was_special,locations.name as location,providers.name as provider,pricing.price,pricing.currency,pricing.term,pricing.next_dd
FROM shared_hosting INNER JOIN locations on shared_hosting.location = locations.id INNER JOIN providers on shared_hosting.provider = providers.id
INNER JOIN pricing on shared_hosting.id = pricing.server_id WHERE shared_hosting.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
($data['was_special'] == 1) ? $special = ' special-card' : $special = '';
(is_null($data['next_dd'])) ? $dd_class = 'no-dd' : $dd_class = 'dd-text';
$this->colOpen('col-12 col-sm-6 col-md-4 col-xl-3');
$this->tagOpen("div", "card obj-card$special");
$this->tagOpen('div', 'card-header');
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h4', 'hostname-header', $data['domain']);;
$this->tagClose('div', 3);
$this->tagOpen('div', 'card-body');
$this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']));
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h6', 'provider', $data['provider']);
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h6', 'location', $data['location']);
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('p', $dd_class, "Due in {$this->processDueDate($data['id'], $data['term'], $data['next_dd'])} days");
$this->tagClose('div', 2);
$this->rowColOpen('row mem-disk-row', 'col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '
' . $data['type'] . '');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('
');
$this->HTMLphrase('p', 'value', '
' . $data['disk_as_gb'] . 'GB');
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-6');
$this->outputString('More');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('Edit');
$this->tagClose('div', 5);
}
protected function domainCard(string $id)
{
$select = $this->dbConnect()->prepare("
SELECT domains.id,domains.domain,domains.attached_to,providers.name as provider, pricing.price,pricing.currency,pricing.term,pricing.next_dd
FROM domains INNER JOIN providers on domains.provider = providers.id
INNER JOIN pricing on domains.id = pricing.server_id WHERE domains.id = ? LIMIT 1;");
$select->execute([$id]);
$data = $select->fetchAll(PDO::FETCH_ASSOC)[0];
(is_null($data['next_dd'])) ? $dd_class = 'no-dd' : $dd_class = 'dd-text';
$this->colOpen('col-12 col-sm-6 col-md-4 col-xl-3');
$this->tagOpen("div", "card obj-card");
$this->tagOpen('div', 'card-header');
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h4', 'hostname-header', $data['domain']);
$this->tagClose('div', 3);
$this->tagOpen('div', 'card-body');
$this->HTMLphrase('h6', 'price', '$' . $data['price'] . ' ' . $data['currency'] . ' ' . $this->paymentTerm($data['term']));
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('h6', 'provider', $data['provider']);
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-12');
$this->HTMLphrase('p', $dd_class, "Due in {$this->processDueDate($data['id'], $data['term'], $data['next_dd'])} days");
$this->tagClose('div', 2);
$this->rowColOpen('row text-center', 'col-6');
$this->outputString('More');
$this->tagClose('div');
$this->colOpen('col-6');
$this->outputString('Edit');
$this->tagClose('div', 5);
}
public function editServerModal()
{
$this->outputString('');
$this->outputString('
');
$this->tagOpen('div', 'modal-content');
$this->tagOpen('div', 'modal-header');
$this->outputString('');
$this->outputString('