Added save YABs to file constant

Added save YABs to file constant which was previously a function param
This commit is contained in:
cp6 2021-02-01 14:31:12 +11:00
parent bdf013ce05
commit e6fa1dc0ea

View File

@ -19,6 +19,8 @@ class idlersConfig
const COLOR_TABLE = true; const COLOR_TABLE = true;
const DEFAULT_VIEW = 'CARDS';//CARDS or TABLE const DEFAULT_VIEW = 'CARDS';//CARDS or TABLE
const SAVE_YABS_OUTPUT = true;//true or false
} }
class elementHelpers extends idlersConfig class elementHelpers extends idlersConfig
@ -3209,14 +3211,11 @@ class itemInsert extends idlers
return $domain_id; return $domain_id;
} }
public function insertYabsData(bool $save_yabs = true) public function insertYabsData()
{//YABS data handler {//YABS data handler
$file_name = 'yabsFromForm.txt'; $file_name = 'yabsFromForm.txt';
$logfile = fopen($file_name, "w") or die("Unable to open file!"); $logfile = fopen($file_name, "w") or die("Unable to open file!");
fwrite($logfile, $this->data['yabs']); fwrite($logfile, $this->data['yabs']);
if ($save_yabs) {
$this->saveYABS($this->data['yabs'], "{$this->item_id}.txt");
}
fclose($logfile); fclose($logfile);
$file = @fopen($file_name, 'r'); $file = @fopen($file_name, 'r');
if ($file) { if ($file) {
@ -3326,6 +3325,9 @@ class itemInsert extends idlers
($disk_type == 'TB') ? $disk_gb = $this->TBtoGB($disk) : $disk_gb = $disk; ($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 = $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]); $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; return 1;
} else { } else {
return 2;//Wrong version return 2;//Wrong version