This commit is contained in:
Momchil Bozhinov
2022-08-05 17:02:04 +03:00
parent a514093616
commit 89370fc39c
4 changed files with 284 additions and 361 deletions

View File

@@ -2,45 +2,34 @@
$db = new Db('base','authkey');
$res = $db->select('SELECT idx,name,authkey FROM authkey;', []);
$html = '';
if($res!==false)
{
if($res !== false){
$nth = 0;
$num = $nth & 1;
if(!empty($res)) foreach($res as $item)
{
foreach($res as $item){
$hres = $this->getTableChunk('authkeyslist', 'tbody');
if($hres!==false)
{
$html_tmp=$hres[1];
$vars=array(
if($hres !== false){
$vars = [
'nth-num' => 'nth'.$num,
'keyid' => $item['idx'],
'keyname' => $item['name'],
'keysrc' => $item['authkey'],
'deltitle'=>' title="'.$this->translate('Delete').'"',
);
foreach($vars as $var=>$val)
$html_tmp=str_replace('#'.$var.'#',$val,$html_tmp);
'deltitle' => ' title="'.$this->translate('Delete').'"'
];
foreach($vars as $var => $val){
$html_tmp = str_replace('#'.$var.'#', $val, $hres[1]);
}
$html .= $html_tmp;
}
}
/*
echo json_encode(array(
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id'=>'authkeyslist',
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'authkeyslist',
);
'id' => 'authkeyslist'
];
}

View File

@@ -1,38 +1,35 @@
<?php
$html='';
$db = new Db('base','nodes');
$nodes = $db->select('select nodename,ip from nodelist order by nodename desc', []);
$nodes[]=array('nodename'=>'local');
$nodes[] = ['nodename' => 'local'];
$nodes = array_reverse($nodes);
$ids=array();
$ids = [];
$nth = 0;
$html = '';
$html_tpl = '';
$hres = $this->getTableChunk('baseslist','tbody');
if(!empty($nodes))foreach($nodes as $node)
{
$db1=new Db('base',$node['nodename']);
if($db1!==false)
{
$bases=$db1->select("SELECT idx,platform,name,arch,targetarch,ver,stable,elf,date FROM bsdbase order by cast(ver AS int)", []);
foreach($nodes as $node){
$db1 = new Db('base', $node['nodename']);
if($db1->error !== false){
$bases = $db1->select("SELECT idx,platform,name,arch,targetarch,ver,stable,elf,date FROM bsdbase order by cast(ver AS int)", []);
$num = $nth & 1;
if(!empty($bases)) foreach($bases as $base)
{
foreach($bases as $base){
$idle = 1;
//print_r($node);exit;
if($node['nodename']!='local')
{
if($node['nodename'] != 'local'){
$idle = $this->check_locktime($node['ip']);
}
$ids[] = $base['idx'];
$id = 'base'.$base['ver'].'-'.$base['arch'].'-'.$base['stable'];
if($hres!==false)
{
$html_tpl=$hres[1];
$vars=array(
if($hres !== false){
$vars = [
'id' => $id,
'nth-num' => 'nth'.$num,
'node' => $node['nodename'],
@@ -46,35 +43,26 @@ if(!empty($nodes))foreach($nodes as $node)
'date' => $base['date'],
'jstatus' => '',
'maintenance' => ($idle == 0) ? ' maintenance' : '',
'deltitle'=>$this->translate('Delete'),
);
foreach($vars as $var=>$val)
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl);
'deltitle' => $this->translate('Delete')
];
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $hres[1]);
}
$html .= $html_tpl;
}
//$ids[]='#base'.$bid;
$ids[]='#'.$id;
}
$nth++;
}
}
$html=str_replace(array("\n","\r","\t"),'',$html);
$tasks = (empty($ids)) ? '' : $tasks = $this->getRunningTasks($ids);
$tasks='';
if(!empty($ids))
{
$tasks=$this->getRunningTasks($ids);
}
$html_tpl=str_replace(array("\n","\r","\t"),'',$hres[1]);
if($hres!==false)
{
$vars=array(
if($hres! == false){
$html_tpl = str_replace(["\n","\r","\t"]), '', $hres[1]);
$vars = [
'nth-num' => 'nth0',
'status' => '',
//'jstatus' => $this->translate('Updating'),
@@ -82,27 +70,19 @@ if($hres!==false)
'desktop' => ' s-off',
'maintenance' => ' maintenance busy',
'updtitle' => $this->translate('Update'),
'deltitle'=>$this->translate('Delete'),
);
'deltitle' => $this->translate('Delete')
];
foreach($vars as $var=>$val)
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl);
}
/*
echo json_encode(array(
'tbody'=>$html,
}
$included_result_array = [
'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
'func' => 'fillTable',
'id' => 'baseslist',
'tasks' => $tasks,
'template'=>$html_tpl,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'baseslist',
'tasks'=>$tasks,
'template'=>$html_tpl,
);
'template' => $html_tpl
];

View File

@@ -1,52 +1,49 @@
<?php
$html='';
//$hres=$this->getTableChunk('jailslist','thead');
//if($hres!==false) $thead=$hres[1];
$db = new Db('base','nodes');
$res = $db->select('select nodename from nodelist', []);
$nodes=array('local');
if(!empty($res))foreach($res as $val) $nodes[]=$val['nodename'];
$nodes = ['local'];
foreach($res as $val){
$nodes[] = $val['nodename'];
}
$statuses=array('Not Launched','Launched','unknown-1','Maintenance','unknown-3','unknown-4','unknown-5','unknown-6');
$allnodes=array();
$jail_ids=array();
$statuses = ['Not Launched','Launched','unknown-1','Maintenance','unknown-3','unknown-4','unknown-5','unknown-6'];
$allnodes = [];
$jail_ids = [];
$nth = 0;
$html = '';
$html_tpl_1 = '';
$hres = $this->getTableChunk('bhyveslist','tbody');
if(!empty($nodes))foreach($nodes as $node)
{
foreach($nodes as $node){
$db1 = new Db('base', $node);
if($db1!==false)
{
if($db1->error !== false){
$bhyves = $db1->select("SELECT jname,vm_ram,vm_cpus,vm_os_type,hidden,protected,bhyve_vnc_tcp_bind FROM bhyve where hidden!=1 order by jname asc;", []);
//$allnodes[$node]=$bhyves;
$num = $nth & 1;
if(!empty($bhyves)) foreach($bhyves as $bhyve)
{
foreach($bhyves as $bhyve){
if($hres !== false){
if($hres!==false)
{
$html_tpl=$hres[1];
$status = $this->check_vmonline($bhyve['jname']);
$jname=$bhyve['jname'];
$vnc_port_status = 'grey';
$vnc_ip=$bhyve['bhyve_vnc_tcp_bind'];
if($status==1)
{
$vnc_port_file=$this->workdir.'/jails-system/'.$jname.'/vnc_port';
if(file_exists($vnc_port_file))
{
if($status == 1){
$vnc_port_file = $this->workdir.'/jails-system/'.$bhyve['jname'].'/vnc_port';
if(file_exists($vnc_port_file)){
$vnc_port = trim(file_get_contents($vnc_port_file));
}
} else {
$vnc_port = '';
}
if($vnc_ip!='127.0.0.1') $vnc_port_status='black';
$vars=array(
if($bhyve['bhyve_vnc_tcp_bind'] != '127.0.0.1'){
$vnc_port_status = 'black';
}
$vars = [
'jname' => $bhyve['jname'],
'nth-num' => 'nth'.$num,
'desktop' => '',
@@ -67,36 +64,29 @@ if(!empty($nodes))foreach($nodes as $node)
'vnc_title' => $this->translate('Open VNC'),
'reboot_title' => $this->translate('Restart bhyve'),
'vnc_port' => $vnc_port,
'vnc_port_status'=>$vnc_port_status,
);
foreach($vars as $var=>$val)
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl);
if($node!='local') $html_tpl=str_replace('<span class="icon-cog"></span>','',$html_tpl);
'vnc_port_status' => $vnc_port_status
];
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $hres[1]);
}
if($node != 'local'){
$html_tpl = str_replace('<span class="icon-cog"></span>', '', $html_tpl);
}
$html .= $html_tpl;
}
$bhyve_ids[] = $bhyve['jname'];
}
$nth++;
}
}
$html=str_replace(array("\n","\r","\t"),'',$html);
$tasks = (empty($bhyve_ids)) ? '' : $this->getRunningTasks($bhyve_ids);
$tasks='';
if(!empty($bhyve_ids))
{
$tasks=$this->getRunningTasks($bhyve_ids);
}
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]);
if($hres!==false)
{
$vars=array(
if($hres !== false){
$html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
$vars = [
'nth-num' => 'nth0',
'vm_status' => $this->translate('Creating'),
'icon' => 'spin6 animate-spin',
@@ -105,42 +95,31 @@ if($hres!==false)
'protected' => 'icon-cancel',
'protitle' => '',
'vnc_title' => $this->translate('Open VNC'),
'reboot_title'=>$this->translate('Restart jail'),
);
'reboot_title' => $this->translate('Restart jail')
];
foreach($vars as $var=>$val)
foreach($vars as $var => $val){
$html_tpl_1 = str_replace('#'.$var.'#', $val, $html_tpl_1);
}
}
$protected=array(
0=>array(
$protected = [
0 => [
'icon' => 'icon-cancel',
'title' => $this->translate('Delete')
),
1=>array(
],
1 => [
'icon' => 'icon-lock',
'title' => $this->translate('Protected bhyve')
)
);
]
];
/*
echo json_encode(array(
'tbody'=>$html,
$included_result_array = [
'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
'func' => 'fillTable',
'id' => 'bhyveslist',
'tasks' => $tasks,
'template' => $html_tpl_1,
'protected'=>$protected,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'bhyveslist',
'tasks'=>$tasks,
'template'=>$html_tpl_1,
'protected'=>$protected,
);
'protected' => $protected
];

View File

@@ -1,110 +1,85 @@
<?php
$res=array(
// 'item'=>array(
0=>array(
function replaceVars($tpl,$vars){
foreach($vars as $var => $val){
$tpl = str_replace('#'.$var.'#', $val, $tpl);
}
return $tpl;
}
$res = [
// 'item' => [
0 => [
'id' => 1,
'name' => 'test',
'path' => 'test/test/',
'type'=>'клетка',
)
// )
);
'type' => 'клетка'
]
// ]
];
$images = $this->getImportedImages();
$html = '';
$html_tpl_1 = '';
$nth = 0;
$num = $nth & 1;
$html_tpl = '';
$hres = $this->getTableChunk('impslist','tbody');
if($hres!==false)
{
$html_tmp=$hres[1];
$html_tmp=replaceVars($html_tmp,array(
if($hres !== false){
$html_tpl_1 = replaceVars($hres[1], [
'deltitle' => ' title="'.$this->translate('Delete').'"',
'dnldtitle' => ' title="'.$this->translate('Download').'"',
'imptitle' => ' title="'.$this->translate('Create').'"')
);
$html_tpl_1=$html_tmp;
];
}
if(!empty($images)) foreach($images as $item)
{
if(!isset($item['type'])) $item['type']='unknown';
foreach($images as $item){
if(!isset($item['type'])){
$item['type'] = 'unknown';
}
//$hres=$this->getTableChunk('impslist','tbody');
if($hres!==false)
{
/*
$html_tmp=$hres[1];
$html_tmp=replaceVars($html_tmp,array(
'deltitle'=>' title="'.$this->translate('Delete').'"',
'dnldtitle'=>' title="'.$this->translate('Download').'"',
'imptitle'=>' title="'.$this->translate('Create').'"')
);
$html_tpl=$html_tmp;
*/
$html_tpl=$html_tmp;
if($hres !== false){
$html_tpl = $html_tpl_1;
$filename = $this->media_import.$item['name'];
$sizefilename = $filename.'.size';
if(file_exists($sizefilename))
{
if(file_exists($sizefilename)){
$size = file_get_contents($sizefilename);
} else {
$size = filesize($filename);
}
$filesize = $this->fileSizeConvert($size, 1024, true);
$query="select count(*) as busy from taskd where status<2 and jname='${item['jname']}'";
$query = "select count(*) as busy from taskd where status<2 and jname='".$item['jname']."'";
$busy = $this->_db_tasks->selectOne($query, []);
$jstatus = '';
$jbusy = '';
if($busy['busy']==1)
{
if($busy['busy'] == 1){
$jstatus = $this->translate('Exporting');
$jbusy = 'busy';
}
$vars=array(
$vars = [
'nth-num' => 'nth'.$num,
'id' => $item['name'],
'jname' => $item['name'],
'impsize' => $filesize,
'jstatus' => $jstatus,
'busy' => $jbusy,
'imptype'=>$this->translate($item['type']),
);
'imptype' => $this->translate($item['type'])
];
foreach($vars as $var=>$val)
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl);
// $html_tmp=str_replace('#'.$var.'#',$val,$html_tmp);
}
$html .= $html_tpl;
}
}
function replaceVars($tpl,$vars)
{
foreach($vars as $var=>$val)
$tpl=str_replace('#'.$var.'#',$val,$tpl);
return $tpl;
}
/*
echo json_encode(array(
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id' => 'impslist',
'template'=>$html_tpl_1,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'impslist',
'template'=>$html_tpl_1,
);
'template' => $html_tpl_1
];