');
$this->tagOpen('div', 'modal-header');
$this->outputString('');
@@ -689,7 +692,7 @@ class idlers extends helperFunctions
if ($row['has_yabs'] == 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,still_have,tags,virt,has_yabs,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`,
+ 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, `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
@@ -704,7 +707,7 @@ class idlers extends helperFunctions
} 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,still_have,tags,virt,has_yabs,ns1,ns2,
+ 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;");
@@ -1042,12 +1045,17 @@ class idlers extends helperFunctions
$this->tagClose('select');
$this->tagClose('div', 3);
- $this->rowColOpen('form-row', 'col-12');
+ $this->rowColOpen('form-row', 'col-12 col-md-6');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('Virt');
$this->selectElement('me_virt');
$this->virtSelectOptions();
$this->tagClose('select');
+ $this->tagClose('div', 2);
+ $this->colOpen('col-12 col-md-6');
+ $this->tagOpen('div', 'input-group');
+ $this->inputPrepend('SSH Port');
+ $this->textInput('me_ssh_port');
$this->tagClose('div', 3);
$this->rowColOpen('form-row', 'col-12');
@@ -1055,7 +1063,6 @@ class idlers extends helperFunctions
$this->inputPrepend('IPv4');
$this->textInput('me_ipv4');
$this->tagClose('div', 3);
-
$this->rowColOpen('form-row', 'col-12');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('IPv6');
@@ -1121,6 +1128,18 @@ class idlers extends helperFunctions
$this->tagClose('select');
$this->tagClose('div', 3);
+ $this->rowColOpen('form-row', 'col-12');
+ $this->htmlPhrase('p', 'm-desc', 'Notes:');
+ $this->outputString("
");
+ $this->tagClose('div', 2);
+
+ $this->rowColOpen('form-row', 'col-12');
+ $this->htmlPhrase('p', 'm-desc', 'Update YABs disk & network speeds:');
+ $this->outputString("
");
+ $this->tagClose('div', 2);
+
$this->rowColOpen('form-row', 'col-12');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('Tags');
@@ -1682,14 +1701,19 @@ class idlers extends helperFunctions
$this->outputString('
');
$this->tagClose('div', 2);
- $this->rowColOpen('form-row', 'col-12 col-md-6');
+ $this->rowColOpen('form-row', 'col-12 col-md-4');
+ $this->tagOpen('div', 'input-group');
+ $this->inputPrepend('SSH');
+ $this->numberInput('ssh_port', '22', 'form-control', true, 1, 999999, 1);
+ $this->tagClose('div', 2);
+ $this->colOpen('col-12 col-md-4');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('Virt');
$this->selectElement('virt');
$this->virtSelectOptions();
$this->tagClose('select');
$this->tagClose('div', 2);
- $this->colOpen('col-12 col-md-6');
+ $this->colOpen('col-12 col-md-4');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('OS');
$this->selectElement('os');
@@ -1801,7 +1825,7 @@ class idlers extends helperFunctions
} else {//NO
$insert = $this->dbConnect()->prepare('INSERT INTO `locations` (`name`) VALUES (?);');
$insert->execute([$provider]);
- return $db->lastInsertId();
+ return $this->dbConnect()->lastInsertId();
}
}
@@ -1815,7 +1839,7 @@ class idlers extends helperFunctions
} else {//NO
$insert = $this->dbConnect()->prepare('INSERT INTO `providers` (`name`) VALUES (?);');
$insert->execute([$provider]);
- return $db->lastInsertId();
+ return $this->dbConnect()->lastInsertId();
}
}
@@ -1892,6 +1916,13 @@ class idlers extends helperFunctions
$this->outputString('
' . $data['ns2'] . '
');
$this->tagClose('div', 2);
+ $this->rowColOpen('row m-row', 'col-4');
+ $this->HTMLphrase('p', 'm-desc', 'SSH Port');
+ $this->tagClose('div');
+ $this->colOpen('col-8');
+ $this->HTMLphrase('p', 'm-value', '
' . $data['ssh_port'] . '
');
+ $this->tagClose('div', 2);
+
$this->rowColOpen('row m-row', 'col-4');
$this->HTMLphrase('p', 'm-desc', 'Bandwidth');
$this->tagClose('div');
@@ -2095,6 +2126,18 @@ class idlers extends helperFunctions
}
}
}
+
+ $this->rowColOpen('row m-section-row', 'col-12 text-center');
+ $this->htmlPhrase('p', 'm-section-text', 'Notes');
+ $this->outputString("
");
+ $this->tagClose('div', 2);
+
$this->rowColOpen('row m-section-row', 'col-12 text-center');
$this->HTMLphrase('p', 'm-section-text', 'Tags');
$this->tagClose('div', 2);
@@ -2109,9 +2152,16 @@ class idlers extends helperFunctions
$this->tagClose('ul');
$this->tagClose('div', 3);
if (file_exists("yabs/{$data['server_id']}.txt")) {
- $this->rowColOpen('row', 'col-12 text-center');
+ $this->rowColOpen('row text-center', 'col-12 col-md-6');
$this->outputString('
View YABs');
- $this->tagClose('div', 2);
+ $this->tagClose('div');
+ $this->colOpen('col-12 col-md-6');
+ $this->outputString('
Close');
+ $this->tagClose('div',2);
+ } else {
+ $this->rowColOpen('row text-center', 'col-12');
+ $this->outputString('
Close');
+ $this->tagClose('div',2);
}
}
@@ -2705,6 +2755,9 @@ class idlers extends helperFunctions
$this->outputString(file_get_contents("yabs/$item_id.txt"));
$this->tagClose('textarea');
$this->tagClose('form');
+ $this->rowColOpen('row text-center', 'col-12');
+ $this->outputString('
Close YABs');
+ $this->tagClose('div',2);
}
}
@@ -2730,8 +2783,8 @@ class itemInsert extends idlers
(empty($data['ipv6'])) ? $ipv6 = null : $ipv6 = $data['ipv6'];
$location_id = $this->handleLocation($data['location']);
$provider_id = $this->handleProvider($data['provider']);
- $insert = $this->dbConnect()->prepare('INSERT IGNORE INTO `servers` (id, hostname, location, provider, ipv4,ipv6, owned_since, os, is_cpu_dedicated, is_dedicated, was_special, bandwidth, virt, has_yabs, ns1, ns2) VALUES (?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)');
- $insert->execute([$item_id, $data['hostname'], $location_id, $provider_id, $data['ipv4'], $ipv6, $data['owned_since'], $data['os'], $dedi_cpu, $dedi, $offer, $data['bandwidth'], $data['virt'], $data['has_yabs'], $data['ns1'], $data['ns2']]);
+ $insert = $this->dbConnect()->prepare('INSERT IGNORE INTO `servers` (id, hostname, location, provider, ipv4,ipv6, owned_since, os, is_cpu_dedicated, is_dedicated, was_special, bandwidth, virt, has_yabs, ns1, ns2, ssh_port) VALUES (?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)');
+ $insert->execute([$item_id, $data['hostname'], $location_id, $provider_id, $data['ipv4'], $ipv6, $data['owned_since'], $data['os'], $dedi_cpu, $dedi, $offer, $data['bandwidth'], $data['virt'], $data['has_yabs'], $data['ns1'], $data['ns2'], $data['ssh_port']]);
$this->insertPrice($data['price'], $data['currency'], $data['term'], $data['next_due_date']);
return $item_id;
}
@@ -2749,8 +2802,8 @@ class itemInsert extends idlers
($data['disk_type'] == 'TB') ? $disk_gb = $this->TBtoGB($data['disk']) : $disk_gb = $data['disk'];
$location_id = $this->handleLocation($data['location']);
$provider_id = $this->handleProvider($data['provider']);
- $insert = $this->dbConnect()->prepare('INSERT IGNORE INTO `servers` (id, hostname, location, provider, ipv4,ipv6, owned_since, os, is_cpu_dedicated, is_dedicated, was_special, bandwidth, virt, cpu, cpu_freq, ram, ram_type, swap, swap_type, disk, disk_type, ram_mb, swap_mb, disk_gb, ns1, ns2) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
- $insert->execute([$item_id, $data['hostname'], $location_id, $provider_id, $data['ipv4'], $ipv6, $data['owned_since'], $data['os'], $dedi_cpu, $dedi, $offer, $data['bandwidth'], $data['virt'], $data['cpu_amount'], $data['cpu_speed'], $data['ram'], $data['ram_type'], $data['swap'], $data['swap_type'], $data['disk'], $data['disk_type'], $ram_mb, $swap_mb, $disk_gb, $data['ns1'], $data['ns2']]);
+ $insert = $this->dbConnect()->prepare('INSERT IGNORE INTO `servers` (id, hostname, location, provider, ipv4,ipv6, owned_since, os, is_cpu_dedicated, is_dedicated, was_special, bandwidth, virt, cpu, cpu_freq, ram, ram_type, swap, swap_type, disk, disk_type, ram_mb, swap_mb, disk_gb, ns1, ns2, ssh_port) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
+ $insert->execute([$item_id, $data['hostname'], $location_id, $provider_id, $data['ipv4'], $ipv6, $data['owned_since'], $data['os'], $dedi_cpu, $dedi, $offer, $data['bandwidth'], $data['virt'], $data['cpu_amount'], $data['cpu_speed'], $data['ram'], $data['ram_type'], $data['swap'], $data['swap_type'], $data['disk'], $data['disk_type'], $ram_mb, $swap_mb, $disk_gb, $data['ns1'], $data['ns2'], $data['ssh_port']]);
$this->insertPrice($data['price'], $data['currency'], $data['term'], $data['next_due_date']);
return $item_id;
}
@@ -2924,8 +2977,8 @@ class itemUpdate extends idlers
} elseif ($data['me_non_active'] == 'on') {
$this->updateActiveStatus(0);
}
- $update = $this->dbConnect()->prepare("UPDATE `servers` SET `hostname` = ?,`ipv4` = ?,`ipv6` = ?,`cpu` = ?,`bandwidth` = ?,`disk` = ?,`ram` = ?,`ram_type` = ?,`swap` = ?,`swap_type` = ?, `virt` = ?, `tags` = ?, `owned_since` = ?, `ns1` = ?, `ns2` = ? WHERE `id`= ? LIMIT 1;");
- return $update->execute([$data['me_hostname'], $data['me_ipv4'], $data['me_ipv6'], $data['me_cpu_amount'], $data['me_bandwidth'], $data['me_disk'], $data['me_ram'], $data['me_ram_type'], $data['me_swap'], $data['me_swap_type'], $data['me_virt'], $data['me_tags'], $data['me_owned_since'], $data['me_ns1'], $data['me_ns2'], $this->item_id]);
+ $update = $this->dbConnect()->prepare("UPDATE `servers` SET `hostname` = ?,`ipv4` = ?,`ipv6` = ?,`cpu` = ?,`bandwidth` = ?,`disk` = ?,`ram` = ?,`ram_type` = ?,`swap` = ?,`swap_type` = ?, `virt` = ?, `tags` = ?, `owned_since` = ?, `ns1` = ?, `ns2` = ?, `ssh_port` = ?, `notes` = ? WHERE `id`= ? LIMIT 1;");
+ return $update->execute([$data['me_hostname'], $data['me_ipv4'], $data['me_ipv6'], $data['me_cpu_amount'], $data['me_bandwidth'], $data['me_disk'], $data['me_ram'], $data['me_ram_type'], $data['me_swap'], $data['me_swap_type'], $data['me_virt'], $data['me_tags'], $data['me_owned_since'], $data['me_ns1'], $data['me_ns2'], $data['me_ssh_port'], $data['me_notes'], $this->item_id]);
}
public function updateServerPricingFromModal()
@@ -3011,4 +3064,67 @@ class itemUpdate extends idlers
return $update->execute([$status, $this->item_id]);
}
+ public function updateYabsData(bool $save_yabs = true)
+ {//YABS data handler
+ $file_name = 'yabsFromForm.txt';
+ $logfile = fopen($file_name, "w") or die("Unable to open file!");
+ fwrite($logfile, $this->data['me_yabs']);
+ if ($save_yabs) {
+ $this->saveYABS($this->data['me_yabs'], "{$this->item_id}_" . date('Y-m-d') . ".txt");
+ }
+ fclose($logfile);
+ $file = @fopen($file_name, 'r');
+ if ($file) {
+ $array = explode("\n", fread($file, filesize($file_name)));
+ }
+ if (strpos($array[0], '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #') !== false || count($array) < 50) {
+ $io_3 = explode(' ', preg_replace('!\s+!', ' ', $array[24]));
+ $io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[30]));
+ (strpos($array[12], 'Enabled') !== false) ? $aes_ni = 1 : $aes_ni = 0;
+ (strpos($array[13], 'Enabled') !== false) ? $vm_amd_v = 1 : $vm_amd_v = 0;
+ $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($this->item_id, $this->floatValue($io_3[2]), $io_3[3], $this->floatValue($io_3[6]), $io_3[7], $this->floatValue($io_6[2]), $io_6[3], $this->floatValue($io_6[6]), $io_6[7], $d4k_as_mbps, $d64k_as_mbps, $d512k_as_mbps, $d1m_as_mbps);
+ $insert = $this->dbConnect()->prepare("INSERT IGNORE INTO `disk_speed` (`server_id`, `4k`, `4k_type`, `64k`, `64k_type`, `512k`, `512k_type`, `1m`, `1m_type`, `4k_as_mbps`, `64k_as_mbps`, `512k_as_mbps`, `1m_as_mbps`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?);");
+ $insert->execute([$this->item_id, $disk_test_arr[1], $disk_test_arr[2], $disk_test_arr[3], $disk_test_arr[4], $disk_test_arr[5], $disk_test_arr[6], $disk_test_arr[7], $disk_test_arr[8], $disk_test_arr[9], $disk_test_arr[10], $disk_test_arr[11], $disk_test_arr[12]]);
+ if ($array[45] == "Geekbench 5 Benchmark Test:\r") {
+ //No ipv6
+ //Has short ipv4 network speed testing (-r)
+ $start_st = 36;
+ $end_st = 43;
+ } elseif ($array[40] == "Geekbench 5 Benchmark Test:\r") {
+ //No ipv6
+ //Has full ipv4 network speed testing
+ $start_st = 36;
+ $end_st = 38;
+ } elseif ($array[40] == "iperf3 Network Speed Tests (IPv6):\r") {
+ //HAS ipv6
+ //Has short ipv4 & ipv6 network speed testing
+ $start_st = 36;
+ $end_st = 38;
+ } elseif ($array[55] == "Geekbench 5 Benchmark Test:\r") {
+ //HAS ipv6
+ //Has full ipv4 & ipv6 network speed testing
+ $start_st = 36;
+ $end_st = 43;
+ }
+ for ($i = $start_st; $i <= $end_st; $i++) {
+ if (strpos($array[$i], 'busy') !== false) {
+ //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']);
+ $insert = $this->dbConnect()->prepare('INSERT IGNORE INTO `speed_tests` (`server_id`, `location`, `send`, `send_type`,`send_as_mbps`, `recieve`,`recieve_type`, `recieve_as_mbps`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
+ $insert->execute([$this->item_id, $this->yabsSpeedLoc($data)['location'], $this->yabsSpeedValues($data)['send'], $this->yabsSpeedValues($data)['send_type'], $send_as_mbps, $this->yabsSpeedValues($data)['receive'], $this->yabsSpeedValues($data)['receive_type'], $recieve_as_mbps]);
+ }
+ }
+ return true;
+ } else {//Not formatted right
+ return false;
+ }
+ }
+
}
\ No newline at end of file
diff --git a/my_idlers.sql b/my_idlers.sql
index 6b6c219..d95249c 100644
--- a/my_idlers.sql
+++ b/my_idlers.sql
@@ -13,21 +13,21 @@ USE `idlers`;
-- Dumping structure for table my_idlers.disk_speed
CREATE TABLE IF NOT EXISTS `disk_speed`
(
- `server_id` char(8) NOT NULL,
- `4k` float DEFAULT NULL,
- `4k_type` char(4) DEFAULT NULL,
- `4k_as_mbps` float DEFAULT NULL,
- `64k` float DEFAULT NULL,
- `64k_type` char(4) DEFAULT NULL,
- `64k_as_mbps` float DEFAULT NULL,
- `512k` float DEFAULT NULL,
- `512k_type` char(4) DEFAULT NULL,
- `512k_as_mbps` float DEFAULT NULL,
- `1m` float DEFAULT NULL,
- `1m_type` char(4) DEFAULT NULL,
- `1m_as_mbps` float DEFAULT NULL,
- `datetime` datetime DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`server_id`)
+ `server_id` char(8) NOT NULL,
+ `4k` float DEFAULT NULL,
+ `4k_type` char(4) DEFAULT NULL,
+ `4k_as_mbps` float DEFAULT NULL,
+ `64k` float DEFAULT NULL,
+ `64k_type` char(4) DEFAULT NULL,
+ `64k_as_mbps` float DEFAULT NULL,
+ `512k` float DEFAULT NULL,
+ `512k_type` char(4) DEFAULT NULL,
+ `512k_as_mbps` float DEFAULT NULL,
+ `1m` float DEFAULT NULL,
+ `1m_type` char(4) DEFAULT NULL,
+ `1m_as_mbps` float DEFAULT NULL,
+ `datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ UNIQUE KEY `Index 1` (`server_id`, `datetime`)
) ENGINE = InnoDB
DEFAULT CHARSET = latin1;
@@ -322,9 +322,11 @@ CREATE TABLE IF NOT EXISTS `servers`
`is_cpu_dedicated` tinyint(1) DEFAULT '0',
`was_special` tinyint(1) DEFAULT '0',
`os` int(11) DEFAULT NULL,
+ `ssh_port` int(11) DEFAULT '22',
`still_have` tinyint(1) DEFAULT '1',
`owned_since` date DEFAULT NULL,
`tags` varchar(255) DEFAULT NULL,
+ `notes` varchar(255) DEFAULT NULL,
`has_yabs` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `Index 2` (`ipv4`, `hostname`, `ipv6`)
diff --git a/update.sql b/update.sql
index 1f2e341..df9097f 100644
--- a/update.sql
+++ b/update.sql
@@ -1,2 +1,14 @@
ALTER TABLE `disk_speed`
- ADD COLUMN `datetime` DATETIME NULL DEFAULT CURRENT_TIMESTAMP AFTER `1m_as_mbps`;
\ No newline at end of file
+ ADD COLUMN `datetime` DATETIME NULL DEFAULT CURRENT_TIMESTAMP AFTER `1m_as_mbps`;
+
+ALTER TABLE `servers`
+ ADD COLUMN `ssh_port` INT(11) NULL DEFAULT '22' AFTER `os`;
+
+ALTER TABLE `servers`
+ ADD COLUMN `notes` VARCHAR(255) NULL DEFAULT NULL AFTER `tags`;
+
+ALTER TABLE `disk_speed`
+ DROP PRIMARY KEY;
+
+ALTER TABLE `disk_speed`
+ ADD UNIQUE INDEX `Index 1` (`server_id`, `datetime`);
\ No newline at end of file