Merge pull request #16 from cp6/dev

1.4 changes
This commit is contained in:
corbpie 2021-02-06 23:23:26 +11:00 committed by GitHub
commit 7e9d237fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 477 additions and 105 deletions

View File

@ -90,22 +90,25 @@ or
### Screenshots
[![Screenshot1](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data.jpg)
[![My idlers screenshot1](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-cards.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-cards.jpg)
[![My idlers screenshot2](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-table.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-table.jpg)
[![screenshot2](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-MORE-1.1.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-MORE-1.1.jpg)
[![My idlers screenshot3](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-more-modal.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-more-modal.jpg)
[![My idlers screenshot4](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-edit-modal.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-edit-modal.jpg)
[![screenshot3](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-EDIT-1.1.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-EDIT-1.1.jpg)
[![My idlers screenshot5](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-order-servers.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-order-servers.jpg)
[![My idlers screenshot6](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-search.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-search.jpg)
[![screenshot4](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-order-table.png)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-order-table.png)
[![My idlers screenshot7](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-summary-card.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-summary-card.jpg)
[![My idlers screenshot8](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-compare-two-servers.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-compare-two-servers.jpg)
[![screenshot5](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-tally-card.png)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-tally-card.png)
[![screenshot6](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-table-view.png)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-data-table-view.png)
[![My idlers screenshot9](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-server-from-yabs.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-server-from-yabs.jpg)
[![My idlers screenshot10](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-shared-hosting.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-shared-hosting.jpg)
[![Auto complete location](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-location.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-location.gif)

View File

@ -51,6 +51,9 @@ body {
.container {
max-width: 720px
}
.nav-link {
padding: .5rem 0.45rem;
}
}
@media (min-width: 992px) {
@ -1184,10 +1187,27 @@ button.close {
background: #00ff340f;
}
.objects-table th:first-child, .objects-table td:first-child {
.objects-table th:first-child, .objects-table td:first-child, .compare-table th:first-child, .compare-table td:first-child {
position: sticky;
left: 0;
background-color: #f6f6f6;
text-align: left;
}
.compare-table td, .compare-table th {
text-align: center;
}
.plus-td {
background: #71ed7136;
}
.neg-td {
background: #ed827136;
}
.equal-td {
background: #6189ff26;
}
.table-btn {
@ -1540,4 +1560,10 @@ input:checked + .slider:before {
.modal-lg {
max-width: 800px;
}
}
@media (max-width: 700px) {
.nav-link {
padding: 0.5rem 0.45rem;
}
}

View File

@ -18,6 +18,30 @@ jQuery Tags
CUSTOM SCRIPTS/FUNCS
*/
function YABSdebug(result){
if (result == 1){
return 'Success';
} else if (result == 2){
return 'Wrong version';
} else if (result == 3){
return 'Didnt start at right spot';
} else if (result == 4){
return 'Not correct format';
} else if (result == 5){
return 'Not a correct YABs command output';
} else if (result == 6){
return 'GeekBench 5 only allowed';
} else if (result == 7){
return 'GeekBench test failed';
} else if (result == 8){
return 'Didnt copy output correctly';
} else if (result == 9){
return 'Less than 50 lines';
} else {
return 'Unknown '+result;
}
}
$(document).ready(function () {
$("#yabsForm").submit(function (e) {
e.preventDefault(e);
@ -26,7 +50,11 @@ $(document).ready(function () {
url: "calls.php",
data: $("#yabsForm").serialize(),
success: function (result) {
location.reload();
if (result.length == 1) {
alert('ERROR: ' + YABSdebug(result));
} else {
location.reload();
}
}
});
});
@ -155,8 +183,37 @@ $(document).ready(function () {
} else if ($("#tableViewDiv").hasClass("active")){
loadTable();
}
//Compare section
$("#compare_s1").change(function () {
var server1_id = $("#compare_s1 option:selected").val();
var server2_id = $("#compare_s2 option:selected").val();
if (server2_id.length !== 0) {
compareTableCall(server1_id, server2_id);
}
});
$("#compare_s2").change(function () {
var server2_id = $("#compare_s2 option:selected").val();
var server1_id = $("#compare_s1 option:selected").val();
if (server1_id.length !== 0) {
compareTableCall(server1_id, server2_id);
}
});
});
function compareTableCall(id1, id2) {
$("#compareTableDiv").empty();
$.ajax({
type: "GET",
url: "calls.php",
data: {"type": "compare_table", "server1": id1, "server2": id2},
success: function (result) {
$("#compareTableDiv").append(result);
}
});
}
function loadCards(){
$.ajax({
type: "GET",

View File

@ -46,6 +46,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} elseif ($_GET['type'] == 'object_tables') {
header('Content-Type: text/html; charset=utf-8');
echo $idle->objectTables();
} elseif ($_GET['type'] == 'compare_table') {
header('Content-Type: text/html; charset=utf-8');
echo $idle->compareTable($_GET['server1'], $_GET['server2']);
}
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
@ -56,8 +59,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_POST['action']) && $_POST['action'] == 'insert') {//From an insert 'type' form
$insert = new itemInsert($_POST);
if (isset($_POST['from_yabs'])) {//From add form YABs
$insert->insertBasicWithYabs();//Insert basic data from form
$insert->insertYabsData();//Insert YABs data from the form
$id = $insert->insertBasicWithYabs();//Insert basic data from form
$response_code = $insert->insertYabsData();//Insert YABs data from the form
if ($response_code != 1) {
header('Content-Type: text/html; charset=utf-8');
$update = new itemUpdate(array('me_server_id' => $id));
$update->deleteObjectData();
echo $response_code;
exit;
}
} elseif (isset($_POST['manual'])) {//From add form manual
$insert->insertBasic();
} elseif (isset($_POST['shared_hosting_form'])) {//From shared hosting form

464
class.php
View File

@ -19,6 +19,8 @@ class idlersConfig
const COLOR_TABLE = true;
const DEFAULT_VIEW = 'CARDS';//CARDS or TABLE
const SAVE_YABS_OUTPUT = true;//true or false
}
class elementHelpers extends idlersConfig
@ -566,6 +568,20 @@ class helperFunctions extends elementHelpers
$date = new DateTime($ahead_date);
return $date->diff($today)->format("%a");
}
protected function deleteYabsForId(string $id)
{
if ($handle = opendir("yabs/")) {
while (false !== ($file = readdir($handle))) {
if ('.' === $file) continue;
if (strpos($file, $id) !== false) {
unlink("yabs/$file");
}
}
closedir($handle);
}
}
}
class idlers extends helperFunctions
@ -596,7 +612,7 @@ class idlers extends helperFunctions
protected function pageContents()
{
$this->navTabs(array('Services', 'Add', 'Order', 'Info', 'Search'), array('#services', '#add_server', '#order', '#info', '#search'));
$this->navTabs(array('Services', 'Add', 'Order', 'Info', 'Search', 'Compare'), array('#services', '#add_server', '#order', '#info', '#search', '#compare'));
$this->outputString('<div id="myTabContent" class="tab-content">');
$this->outputString('<div class="tab-pane server-cards fade active show" id="services">');
$this->viewSwitcherIcon();
@ -649,6 +665,10 @@ class idlers extends helperFunctions
$this->outputString('<div class="tab-pane fade" id="search">');
$this->searchDiv();
$this->tagClose('div');
$this->outputString('<div class="tab-pane fade" id="compare">');
$this->compareSection();
$this->tagClose('div', 2);
$this->editServerModal();
@ -722,22 +742,23 @@ class idlers extends helperFunctions
$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,label,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`,
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,ram_mb,swap,swap_type,swap_mb,`disk`,disk_type,disk_gb,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,label,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`,`4k_as_mbps`,`64k`,`64k_type`,
`64k_as_mbps`,`512k`,`512k_type`,`512k_as_mbps`,`1m`,`1m_type`,`1m_as_mbps`,
loc.name as location,send,send_type,recieve,recieve_type,price,currency,term,as_usd,per_month,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 = $this->dbConnect()->prepare("SELECT `location`, `send`, `send_type`,`send_as_mbps`, `recieve`, `recieve_type`, `recieve_as_mbps` 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,
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,ram_mb,swap,swap_type,swap_mb,`disk`,disk_type,disk_gb,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,label,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,usd_per_month,next_dd,pr.name as provider
FROM servers INNER JOIN disk_speed ds on servers.id = ds.server_id
@ -748,7 +769,7 @@ class idlers extends helperFunctions
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,
SELECT servers.id as server_id,hostname,ipv4,ipv6,`cpu`,cpu_type,cpu_freq,ram,ram_type,ram_mb,swap,swap_type,swap_mb,`disk`,disk_type,disk_gb,
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,label,has_st,
DATE_FORMAT(`owned_since`, '%M %Y') as owned_since,loc.name as location,price,currency,term,as_usd,per_month,usd_per_month,next_dd,pr.name as provider
FROM servers INNER JOIN locations loc on servers.location = loc.id
@ -2079,6 +2100,7 @@ class idlers extends helperFunctions
public function mainPage()
{
$this->checkPHPversion();//Check PHP version. Wont load if not PHP 7.4 or above
$this->pageHead();
$this->pageContents();
$this->pageFooter();
@ -2569,7 +2591,11 @@ class idlers extends helperFunctions
$this->HTMLphrase('p', 'm-desc', 'Attached to');
$this->tagClose('div');
$this->colOpen('col-8');
$this->outputString('<code><p class="m-value">' . $this->idToObjectName($data['attached_to']) . '</p></code>');
if (!is_null($data['attached_to']) && !empty($data['attached_to'])) {
$this->outputString('<code><p class="m-value">' . $this->idToObjectName($data['attached_to']) . '</p></code>');
} else {
$this->outputString('');
}
$this->tagClose('div', 2);
@ -3136,6 +3162,236 @@ class idlers extends helperFunctions
}
return $id;
}
protected function checkPHPversion()
{
if (version_compare(PHP_VERSION, '7.4') === -1) {
echo "<script type='text/javascript'>alert('My idlers requires PHP 7.4 as a minimum version. You have " . PHP_VERSION . " installed');</script>";
exit;
}
}
//Compare functions
protected function compatibleComparesSelect()
{
$select = $this->dbConnect()->prepare("SELECT `id`, `hostname` FROM `servers` WHERE `has_yabs` = 1 AND `has_st` = 1 ORDER BY `hostname`;");
$select->execute();
$rows = $select->fetchAll(PDO::FETCH_ASSOC);
$this->rowColOpen('form-row', 'col-12 col-md-6 mm-col');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('Server 1');
$this->selectElement('compare_s1');
$this->selectOption('', '', true);//Empty
foreach ($rows as $aserver) {
$this->selectOption($aserver['hostname'], $aserver['id']);
}
$this->tagClose('select');
$this->tagClose('div', 2);
$this->colOpen('col-12 col-md-6 mm-col');
$this->tagOpen('div', 'input-group');
$this->inputPrepend('Server 2');
$this->selectElement('compare_s2');
$this->selectOption('', '', true);
foreach ($rows as $aserver) {
$this->selectOption($aserver['hostname'], $aserver['id']);
}
$this->tagClose('select');
$this->tagClose('div', 3);
}
protected function compareSection()
{
$this->compatibleComparesSelect();
$this->tagOpen('div', '', 'compareTableDiv');
$this->tagClose('div');
}
protected function tableRowCompare(string $val1, string $val2, string $value_type = '', bool $is_int = true)
{
$value_append = '<span class="data-type">' . $value_type . '</span>';
if ($is_int) {
$val1 = intval($val1);
$val2 = intval($val2);
}
if ($val1 > $val2) {//val1 is greater than val2
$result = '+' . ($val1 - $val2);
if (!empty($value_type)) {
$result = '+' . ($val1 - $val2) . $value_append;
$val1 = $val1 . $value_append;
$val2 = $val2 . $value_append;
}
$this->tableTd('td-nowrap', $val1);
$this->tableTd('td-nowrap plus-td', $result);
$this->tableTd('td-nowrap', $val2);
} elseif ($val1 < $val2) {//val1 is less than val2
$result = '-' . ($val2 - $val1);
if (!empty($value_type)) {
$result = '-' . ($val2 - $val1) . $value_append;
$val1 = $val1 . $value_append;
$val2 = $val2 . $value_append;
}
$this->tableTd('td-nowrap', $val1);
$this->tableTd('td-nowrap neg-td', $result);
$this->tableTd('td-nowrap', $val2);
} else {//Equal
$result = 0;
if (!empty($value_type)) {
$result = '0' . $value_append;
$val1 = $val1 . $value_append;
$val2 = $val2 . $value_append;
}
$this->tableTd('td-nowrap', $val1);
$this->tableTd('td-nowrap equal-td', $result);
$this->tableTd('td-nowrap', $val2);
}
}
public function compareTable(string $server1_id, string $server2_id)
{
$server1_data = json_decode($this->serverData($server1_id), true);
$server2_data = json_decode($this->serverData($server2_id), true);
$this->tableHeader(array('', $server1_data['hostname'], 'DIF', $server2_data['hostname']), 'table compare-table', 'compareTable');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'CPU count');
$this->tableRowCompare($server1_data['cpu'], $server2_data['cpu']);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'CPU freq');
$this->tableRowCompare($this->mhzToGhz($server1_data['cpu_freq']), $this->mhzToGhz($server2_data['cpu_freq']), 'Ghz', false);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Ram');
$this->tableRowCompare($server1_data['ram_mb'], $server2_data['ram_mb'], 'MB');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Swap');
$this->tableRowCompare($server1_data['swap_mb'], $server2_data['swap_mb'], 'MB');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Disk');
$this->tableRowCompare($server1_data['disk_gb'], $server2_data['disk_gb'], 'GB');
$this->tagClose('tr');
if ($server1_data['has_yabs'] == 1 && $server2_data['has_yabs'] == 1) {
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'GB5 single');
$this->tableRowCompare($server1_data['gb5_single'], $server2_data['gb5_single']);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'GB5 multi');
$this->tableRowCompare($server1_data['gb5_multi'], $server2_data['gb5_multi']);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', '4k disk');
$this->tableRowCompare($server1_data['4k_as_mbps'], $server2_data['4k_as_mbps'], 'MB/s');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', '64k disk');
$this->tableRowCompare($server1_data['64k_as_mbps'], $server2_data['64k_as_mbps'], 'MB/s');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', '512k disk');
$this->tableRowCompare($server1_data['512k_as_mbps'], $server2_data['512k_as_mbps'], 'MB/s');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', '1m disk');
$this->tableRowCompare($server1_data['1m_as_mbps'], $server2_data['1m_as_mbps'], 'MB/s');
$this->tagClose('tr');
}
if ($server1_data['has_st'] == 1 && $server2_data['has_st'] == 1) {
if (isset($server1_data[0]) && isset($server2_data[0])) {
if ($server1_data[0]['location'] == $server2_data[0]['location']) {
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[0]['location'] . ' send');
$this->tableRowCompare($server1_data[0]['send_as_mbps'], $server2_data[0]['send_as_mbps'], 'MBps');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[0]['location'] . ' recieve');
$this->tableRowCompare($server1_data[0]['recieve_as_mbps'], $server2_data[0]['recieve_as_mbps'], 'MBps');
$this->tagClose('tr');
}
}
if (isset($server1_data[1]) && isset($server2_data[1])) {
if ($server1_data[1]['location'] == $server2_data[1]['location']) {
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[1]['location'] . ' send');
$this->tableRowCompare($server1_data[1]['send_as_mbps'], $server2_data[1]['send_as_mbps'], 'MBps');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[1]['location'] . ' recieve');
$this->tableRowCompare($server1_data[1]['recieve_as_mbps'], $server2_data[1]['recieve_as_mbps'], 'MBps');
$this->tagClose('tr');
}
}
if (isset($server1_data[2]) && isset($server2_data[2])) {
if ($server1_data[2]['location'] == $server2_data[2]['location']) {
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[2]['location'] . ' send');
$this->tableRowCompare($server1_data[2]['send_as_mbps'], $server2_data[2]['send_as_mbps'], 'MBps');
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', $server1_data[2]['location'] . ' recieve');
$this->tableRowCompare($server1_data[2]['recieve_as_mbps'], $server2_data[2]['recieve_as_mbps'], 'MBps');
$this->tagClose('tr');
}
}
}
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'USD p/m');
$this->tableRowCompare($server1_data['usd_per_month'], $server2_data['usd_per_month'], 'p/m', false);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Actual price');
$this->tableTd('td-nowrap', $server1_data['price'] . '<span class="data-type">' . $server1_data['currency'] . '</span>' . ' ' . $this->paymentTerm($server1_data['term']));
$this->tableTd('td-nowrap equal-td', '');
$this->tableTd('td-nowrap', $server2_data['price'] . '<span class="data-type">' . $server2_data['currency'] . '</span>' . ' ' . $this->paymentTerm($server2_data['term']));
$this->tagClose('tr');
$this->tagOpen('tr');
if ($server1_data['price'] > 0 && $server2_data['price'] > 0) {
$this->tableTd('td-nowrap', 'CPU per USD');
$this->tableRowCompare(number_format(($server1_data['usd_per_month'] / $server1_data['cpu']), 2), number_format(($server2_data['usd_per_month'] / $server2_data['cpu']), 2), '', false);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Disk GB per USD');
$this->tableRowCompare(($server1_data['disk_gb'] / $server1_data['usd_per_month']), ($server2_data['disk_gb'] / $server2_data['usd_per_month']), 'GB', true);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Ram MB per USD');
$this->tableRowCompare(($server1_data['ram_mb'] / $server1_data['usd_per_month']), ($server2_data['ram_mb'] / $server2_data['usd_per_month']), 'MB', true);
$this->tagClose('tr');
if ($server1_data['has_yabs'] == 1 && $server2_data['has_yabs'] == 1) {
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'GB5 single per USD');
$this->tableRowCompare(($server1_data['gb5_single'] / $server1_data['usd_per_month']), ($server2_data['gb5_single'] / $server2_data['usd_per_month']), '', true);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'GB5 multi per USD');
$this->tableRowCompare(($server1_data['gb5_multi'] / $server1_data['usd_per_month']), ($server2_data['gb5_multi'] / $server2_data['usd_per_month']), '', true);
$this->tagClose('tr');
}
}
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Location');
$this->tableTd('td-nowrap', $server1_data['location']);
$this->tableTd('td-nowrap equal-td', '');
$this->tableTd('td-nowrap', $server2_data['location']);
$this->tagClose('tr');
$this->tagOpen('tr');
$this->tableTd('td-nowrap', 'Provider');
$this->tableTd('td-nowrap', $server1_data['provider']);
$this->tableTd('td-nowrap equal-td', '');
$this->tableTd('td-nowrap', $server2_data['provider']);
$this->tagClose('tr');
$this->tableTd('td-nowrap', 'Owned since');
$this->tableTd('td-nowrap', $server1_data['owned_since']);
$this->tableTd('td-nowrap equal-td', '');
$this->tableTd('td-nowrap', $server2_data['owned_since']);
$this->tagClose('tr');
$this->outputString('</tbody></table></div>');
}
}
class itemInsert extends idlers
@ -3213,14 +3469,11 @@ class itemInsert extends idlers
return $domain_id;
}
public function insertYabsData(bool $save_yabs = true)
public function insertYabsData()
{//YABS data handler
$file_name = 'yabsFromForm.txt';
$logfile = fopen($file_name, "w") or die("Unable to open file!");
fwrite($logfile, $this->data['yabs']);
if ($save_yabs) {
$this->saveYABS($this->data['yabs'], "{$this->item_id}.txt");
}
fclose($logfile);
$file = @fopen($file_name, 'r');
if ($file) {
@ -3228,95 +3481,117 @@ class itemInsert extends idlers
//echo json_encode($array);
//exit;
}
if (strpos($array[0], '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #') !== false || count($array) < 50) {
if (count($array) < 50) {
return 9;//Less than 50 lines
}
if (strpos($array[0], '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #') !== false) {
if ($array[1] == "\r") {
return 8;//Didnt copy output correctly
}
$version_array = explode(' ', preg_replace('!\s+!', ' ', $this->trimRemoveR($array[2])));
$version = $version_array[1];//YABs version
$cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[10], ': ')));
$cpu_spec = explode(' ', strstr($array[11], ': '));//: 2 @ 3792.872 MHz
$cpu_cores = $cpu_spec[1];
$cpu_freq = $cpu_spec[3];
$ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[14], ': ')));
$ram = floatval($ram_line);
$ram_type = $this->datatype($ram_line);
$swap_line = $this->trimRemoveR(str_replace(':', '', strstr($array[15], ': ')));
$swap = floatval($swap_line);
$swap_type = $this->datatype($swap_line);
$disk_line = $this->trimRemoveR(str_replace(':', '', strstr($array[16], ': ')));
$disk = floatval($disk_line);
$disk_type = $this->datatype($disk_line);
$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);
$this->insertDiskTest($disk_test_arr);
if ($array[45] == "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has short ipv4 network speed testing (-r)
$start_st = 36;
$end_st = 43;
$gb_s = 49;
$gb_m = 50;
$gb_url = 51;
} elseif ($array[40] == "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has full ipv4 network speed testing
$start_st = 36;
$end_st = 38;
$gb_s = 44;
$gb_m = 45;
$gb_url = 46;
} elseif ($array[40] == "iperf3 Network Speed Tests (IPv6):\r") {
//HAS ipv6
//Has short ipv4 & ipv6 network speed testing
$start_st = 36;
$end_st = 38;
$gb_s = 52;
$gb_m = 53;
$gb_url = 54;
} elseif ($array[55] == "Geekbench 5 Benchmark Test:\r") {
//HAS ipv6
//Has full ipv4 & ipv6 network speed testing
$start_st = 36;
$end_st = 43;
$gb_s = 59;
$gb_m = 60;
$gb_url = 61;
}
$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 = substr($geek_full_url[3], strrpos($geek_full_url[3], '/') + 1);//
$has_a_speed_test = false;
for ($i = $start_st; $i <= $end_st; $i++) {
if (strpos($array[$i], 'busy') !== false) {
//Has a "busy" result, No insert
if ($version == 'v2020-12-29') {
$cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[10], ': ')));
$cpu_spec = explode(' ', strstr($array[11], ': '));//: 2 @ 3792.872 MHz
$cpu_cores = $cpu_spec[1];
$cpu_freq = $cpu_spec[3];
$ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[14], ': ')));
$ram = floatval($ram_line);
$ram_type = $this->datatype($ram_line);
$swap_line = $this->trimRemoveR(str_replace(':', '', strstr($array[15], ': ')));
$swap = floatval($swap_line);
$swap_type = $this->datatype($swap_line);
$disk_line = $this->trimRemoveR(str_replace(':', '', strstr($array[16], ': ')));
$disk = floatval($disk_line);
$disk_type = $this->datatype($disk_line);
$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);
$this->insertDiskTest($disk_test_arr);
if (isset($array[40])) {
if ($array[45] == "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has short ipv4 network speed testing (-r)
$start_st = 36;
$end_st = 43;
$gb_s = 49;
$gb_m = 50;
$gb_url = 51;
} elseif ($array[45] == "Geekbench 4 Benchmark Test:\r") {
return 6;//GeekBench 5 only allowed
} elseif ($array[45] == "Geekbench 5 test failed. Run manually to determine cause.") {
return 7;//GeekBench test failed
} elseif ($array[40] == "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has full ipv4 network speed testing
$start_st = 36;
$end_st = 38;
$gb_s = 44;
$gb_m = 45;
$gb_url = 46;
} elseif ($array[40] == "iperf3 Network Speed Tests (IPv6):\r") {
//HAS ipv6
//Has short ipv4 & ipv6 network speed testing
$start_st = 36;
$end_st = 38;
$gb_s = 52;
$gb_m = 53;
$gb_url = 54;
} elseif ($array[55] == "Geekbench 5 Benchmark Test:\r") {
//HAS ipv6
//Has full ipv4 & ipv6 network speed testing
$start_st = 36;
$end_st = 43;
$gb_s = 59;
$gb_m = 60;
$gb_url = 61;
} else {
return 5;//Not correct YABs command output
}
} 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 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]);
$has_a_speed_test = true;
return 4;//Not correct format
}
$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 = substr($geek_full_url[3], strrpos($geek_full_url[3], '/') + 1);//
$has_a_speed_test = false;
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 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]);
$has_a_speed_test = true;
}
}
if ($has_a_speed_test) {
$update_st = $this->dbConnect()->prepare('UPDATE `servers` SET `has_st` = 1 WHERE `id` = ? LIMIT 1;');
$update_st->execute([$this->item_id]);
}
($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;
$update = $this->dbConnect()->prepare('UPDATE `servers` SET `cpu` = ?, `cpu_freq` = ?, `cpu_type` = ?, ram = ?, ram_type = ?, swap = ?, swap_type = ?, disk = ?, disk_type = ?, `aes_ni` = ?, `amd_v` = ?, gb5_single = ?, gb5_multi = ?, gb5_id = ?, ram_mb = ?, swap_mb = ?, disk_gb = ? WHERE `id` = ? LIMIT 1;');
$update->execute([$cpu_cores, $cpu_freq, $cpu, $ram, $ram_type, $swap, $swap_type, $disk, $disk_type, $aes_ni, $vm_amd_v, $geekbench_single, $geekbench_multi, $gb5_id, $ram_mb, $swap_mb, $disk_gb, $this->item_id]);
if (self::SAVE_YABS_OUTPUT) {
$this->saveYABS($this->data['yabs'], "{$this->item_id}.txt");
}
return 1;
} else {
return 2;//Wrong version
}
if ($has_a_speed_test) {
$update_st = $this->dbConnect()->prepare('UPDATE `servers` SET `has_st` = 1 WHERE `id` = ? LIMIT 1;');
$update_st->execute([$this->item_id]);
}
($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;
$update = $this->dbConnect()->prepare('UPDATE `servers` SET `cpu` = ?, `cpu_freq` = ?, `cpu_type` = ?, ram = ?, ram_type = ?, swap = ?, swap_type = ?, disk = ?, disk_type = ?, `aes_ni` = ?, `amd_v` = ?, gb5_single = ?, gb5_multi = ?, gb5_id = ?, ram_mb = ?, swap_mb = ?, disk_gb = ? WHERE `id` = ? LIMIT 1;');
$update->execute([$cpu_cores, $cpu_freq, $cpu, $ram, $ram_type, $swap, $swap_type, $disk, $disk_type, $aes_ni, $vm_amd_v, $geekbench_single, $geekbench_multi, $gb5_id, $ram_mb, $swap_mb, $disk_gb, $this->item_id]);
return true;
} else {
//Not formatted right
return false;
return 3;//Didnt start at right spot
}
}
@ -3435,6 +3710,7 @@ class itemUpdate extends idlers
$del_disk->execute([$item_id]);
$del_speed = $this->dbConnect()->prepare("DELETE FROM `speed_tests` WHERE `server_id` = ?;");
$del_speed->execute([$item_id]);
$this->deleteYabsForId($item_id);//Delete saved YABs
}
}