Merge pull request #58 from bozhinov/Public

* Cosmetics
This commit is contained in:
Oleg Ginzburg
2022-12-11 01:16:02 +03:00
committed by GitHub
24 changed files with 757 additions and 994 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,83 +1,72 @@
<?php <?php
$jail_name='';
if(isset($this->uri_chunks[1])) $jail_name=$this->uri_chunks[1]; if(isset($this->uri_chunks[1])){
if(!empty($jail_name)) $jail_name = $this->uri_chunks[1];
{
include('helpers.json.php'); include('helpers.json.php');
return; return;
} }
$db = new Db('base','nodes');
$res = $db->select('select nodename from nodelist', []);
$nodes = ['local'];
foreach($res as $val){
$nodes[] = $val['nodename'];
}
$html=''; $html = '';
//$hres=$this->getTableChunk('jailslist','thead'); $html_tpl_1 = '';
//if($hres!==false) $thead=$hres[1]; $statuses = ['Not Launched','Launched','unknown-1','Maintenance','unknown-3','unknown-4','unknown-5','unknown-6'];
$allnodes = [];
$jail_ids = [];
$nth = 0;
$hres = $this->getTableChunk('jailslist','tbody');
$db=new Db('base','nodes'); foreach($nodes as $node){
$res=$db->select('select nodename from nodelist', []); $db1 = new Db('base', $node);
$nodes=array('local'); if(!$db1->error){
if(!empty($res))foreach($res as $val) $nodes[]=$val['nodename'];
$statuses=array('Not Launched','Launched','unknown-1','Maintenance','unknown-3','unknown-4','unknown-5','unknown-6'); $jails = $db1->select("SELECT jname,ip4_addr,status,protected FROM jails WHERE emulator!='bhyve' and hidden!=1 order by jname asc;", []);
$allnodes=array(); $allnodes[$node] = $jails;
$num = $nth & 1;
$jail_ids=array(); foreach($jails as $jail){
$nth=0; if($hres !== false){
$hres=$this->getTableChunk('jailslist','tbody'); $vnc_port = '';
if(!empty($nodes))foreach($nodes as $node) $vnc_port_file = $this->workdir.'/jails-system/'.$jail['jname'].'/vnc_port';
{ if(file_exists($vnc_port_file)){
$db1=new Db('base',$node); $vnc_port = trim(file_get_contents($vnc_port_file));
if($db1!==false)
{
$jails=$db1->select("SELECT jname,ip4_addr,status,protected FROM jails WHERE emulator!='bhyve' and hidden!=1 order by jname asc;", []);
Utils::clonos_syslog("jailscontainers a.json.php:" . "SELECT jname,ip4_addr,status,protected FROM jails WHERE emulator!='bhyve' and hidden!=1 order by jname asc;");
$allnodes[$node]=$jails;
$num=$nth & 1;
if(!empty($jails)) foreach($jails as $jail)
{
if($hres!==false)
{
$jname=$jail['jname'];
$vnc_port_status='grey';
$vnc_port='';
$vnc_port_file=$this->workdir.'/jails-system/'.$jname.'/vnc_port';
if(file_exists($vnc_port_file))
{
$vnc_port=trim(file_get_contents($vnc_port_file));
} }
$html_tpl = $hres[1];
$html_tpl=$hres[1]; $status = $jail['status'];
$status=$jail['status']; $vars = [
$vars=array( 'nth-num' => 'nth'.$num,
'nth-num'=>'nth'.$num, 'node' => $node,
'node'=>$node, 'ip4_addr' => str_replace(',',',<wbr />', $jail['ip4_addr']),
'ip4_addr'=>str_replace(',',',<wbr />',$jail['ip4_addr']), 'jname' => $jail['jname'],
'jname'=>$jname, 'vnc_port' => $vnc_port,
'vnc_port'=>$vnc_port, 'vnc_port_status' => 'grey',
'vnc_port_status'=>$vnc_port_status, 'status' => $status,
'status'=>$status, 'jstatus' => $this->translate($statuses[$status]),
'jstatus'=>$this->translate($statuses[$status]), 'icon' => ($status == 0) ? 'play' : 'stop',
'icon'=>($status==0)?'play':'stop', 'desktop' => ($status == 0) ? ' s-off' : ' s-on',
'desktop'=>($status==0)?' s-off':' s-on', 'maintenance' => ($status == 3) ? ' maintenance' : '',
'maintenance'=>($status==3)?' maintenance':'', 'protected' => ($jail['protected'] == 1) ? 'icon-lock' : 'icon-cancel',
'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel', 'protitle' => ($jail['protected'] == 1) ? ' title="'.$this->translate('Protected jail').'"' : ' title="'.$this->translate('Delete').'"',
'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"', 'vnc_title' => $this->translate('Open VNC'),
'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 = str_replace('#'.$var.'#', $val, $html_tpl);
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); }
if($node != 'local'){
if($node!='local') $html_tpl=str_replace('<span class="icon-cog"></span>','',$html_tpl); $html_tpl = str_replace('<span class="icon-cog"></span>', '', $html_tpl);
}
$html.=$html_tpl; $html .= $html_tpl;
} }
$jail_ids[]=$jail['jname']; $jail_ids[] = $jail['jname'];
/* /*
$jname=$jail['jname']; $jname=$jail['jname'];
$jail_ids[]=$jname; $jail_ids[]=$jname;
@@ -93,7 +82,7 @@ if(!empty($nodes))foreach($nodes as $node)
$reboot_title=$this->translate('Restart jail'); $reboot_title=$this->translate('Restart jail');
$html.= $html.=
<<<EOT <<<EOT
<tr class="nth{$num}{$desktop}{$maintenance}" id="{$jname}"> <tr class="nth{$num}{$desktop}{$maintenance}" id="{$jail['jname']}">
<td>{$node}</td> <td>{$node}</td>
<td class="txtleft">{$jail['jname']}</td> <td class="txtleft">{$jail['jname']}</td>
<td class="txtleft jname">{$jail['ip4_addr']}</td> <td class="txtleft jname">{$jail['ip4_addr']}</td>
@@ -107,70 +96,51 @@ if(!empty($nodes))foreach($nodes as $node)
EOT; EOT;
*/ */
} }
$nth++; $nth++;
} else { } else {
Utils::clonos_syslog("jailscontainers a.json.php: DB1 FALSE"); Utils::clonos_syslog("jailscontainers a.json.php: DB1 FALSE");
} }
} }
$html=str_replace(array("\n","\r","\t"),'',$html); $tasks = (empty($jail_ids)) ? '' : $this->getRunningTasks($jail_ids);
$tasks=''; if($hres !== false){
if(!empty($jail_ids)) $html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
{ $vars = [
$tasks=$this->getRunningTasks($jail_ids); 'nth-num' => 'nth0',
} 'status' => '',
//echo '<pre>';print_r($tasks);exit; 'jstatus' => $this->translate('Creating'),
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]); 'icon' => 'spin6 animate-spin',
if($hres!==false) 'desktop' => ' s-off',
{ 'maintenance' => ' maintenance busy',
$vars=array( 'protected' => 'icon-cancel',
'nth-num'=>'nth0', 'protitle' => '',
'status'=>'', 'vnc_title' => $this->translate('Open VNC'),
'jstatus'=>$this->translate('Creating'), 'reboot_title' => $this->translate('Restart jail')
'icon'=>'spin6 animate-spin', ];
'desktop'=>' s-off',
'maintenance'=>' maintenance busy', foreach($vars as $var => $val){
'protected'=>'icon-cancel', $html_tpl_1 = str_replace('#'.$var.'#', $val, $html_tpl_1);
'protitle'=>'', }
'vnc_title'=>$this->translate('Open VNC'),
'reboot_title'=>$this->translate('Restart jail'),
);
foreach($vars as $var=>$val)
$html_tpl_1=str_replace('#'.$var.'#',$val,$html_tpl_1);
} }
$protected=array( $protected = [
0=>array( 0 => [
'icon'=>'icon-cancel', 'icon' => 'icon-cancel',
'title'=>$this->translate('Delete') 'title' => $this->translate('Delete')
), ],
1=>array( 1 => [
'icon'=>'icon-lock', 'icon' => 'icon-lock',
'title'=>$this->translate('Protected jail') 'title' => $this->translate('Protected jail')
) ]
); ];
/* $included_result_array = [
echo json_encode(array( 'tbody' => str_replace(["\n","\r","\t"], '', $html),
// 'thead'=>$thead, 'error' => false,
'tbody'=>$html, 'func' => 'fillTable',
'error'=>false, 'id' => 'jailslist',
'func'=>'fillTable', 'tasks' => $tasks,
'id'=>'jailslist', 'template' => $html_tpl_1,
'tasks'=>$tasks, 'protected' => $protected
'template'=>$html_tpl_1, ];
'protected'=>$protected,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'jailslist',
'tasks'=>$tasks,
'template'=>$html_tpl_1,
'protected'=>$protected,
);

View File

@@ -1,19 +1,17 @@
<?php <?php
if(isset($clonos->uri_chunks[1])) if(isset($clonos->uri_chunks[1])){
{
include('helpers.php'); include('helpers.php');
return; return;
} }
$clonos->useDialogs([
$clonos->useDialogs(array(
'vnc', 'vnc',
'jail-settings', 'jail-settings',
'jail-settings-config-menu', 'jail-settings-config-menu',
'jail-import', 'jail-import',
'jail-clone', 'jail-clone',
'jail-rename', 'jail-rename',
)); ]);
?> ?>
<h1>Jail containers:</h1> <h1>Jail containers:</h1>

View File

@@ -1,113 +1,95 @@
<?php <?php
$hash=$this->url_hash; $hash = $this->url_hash;
if(empty($hash)) if(empty($hash)){
{
# Узнаём список хелперов # Узнаём список хелперов
$jails_helpers=array(); $jails_helpers = [];
$db=new Db('clonos'); $db = new Db('clonos');
if($db!==false) if (!$db->error){
{ $res = $db->select("select module from jails_helpers_list", []);
$query="select module from jails_helpers_list"; if(!empty($res)){
if(!$db->error) foreach($res as $r){
{ $jails_helpers[] = $r['module'];
$res=$db->select($query, []);
if(!empty($res))
{
foreach($res as $r) $jails_helpers[]=$r['module'];
} }
} }
} }
$lst = [];
$lst=array(); foreach($jails_helpers as $helper){
if(!empty($jails_helpers)) foreach($jails_helpers as $helper) $db = new Db('helper', ['jname' => $jail_name, 'helper' => $helper]);
{
$db=new Db('helper',array('jname'=>$jail_name,'helper'=>$helper));
if(!$db->error) // !error — значит хелпер установлен if(!$db->error) // !error — значит хелпер установлен
{ {
$res=$db->selectOne("select longdesc from system", []); $res = $db->selectOne("select longdesc from system", []);
if(isset($res['longdesc'])) $description=$res['longdesc']; else $description=$this->translate('no data').'&hellip; ('.$file_name.')'; if(isset($res['longdesc'])){
$lst[]=array('helper'=>$helper,'description'=>$description); $description = $res['longdesc'];
}else{ } else {
$hlst[]=$helper; $description = $this->translate('no data').'&hellip; ('.$file_name.')';
}
$lst[] = ['helper' => $helper, 'description' => $description];
} else {
$hlst[] = $helper;
} }
} }
$html='';
$html_tpl='';
$empty_logo='/images/logo/empty.png';
$hres=$this->getTableChunk('helpers','tbody');
if($hres!==false) $html_tpl=$hres[1];
if(!empty($lst) && !empty($html_tpl))
{
foreach($lst as $item)
{
$tpl=$html_tpl;
$logo_file='images/logo/'.$item['helper'].'.png';
$logo=file_exists($this->realpath_public.$logo_file)?'/'.$logo_file:$empty_logo;
$vars=array(
'nth-num'=>'nth0',
'logo'=>$logo,
'name'=>$item['helper'],
'description'=>$item['description'],
'opentitle'=>$this->translate('Open'),
);
foreach($vars as $var=>$val)
$tpl=str_replace('#'.$var.'#',$val,$tpl);
$html.=$tpl;
}
}else{
$html='<tr><td colspan="3">'.$this->translate('No installed helpers').'</td></tr>';
}
// Определяем список хелперов, доступных для установки в клетку
$helpers_list_html='<ul class="helpers-list">';
if(!empty($hlst)) foreach($hlst as $item)
{
$logo_file='images/logo/'.$item.'.png';
$logo=file_exists($this->realpath_public.$logo_file)?'/'.$logo_file:$empty_logo;
$helpers_list_html.='<li><input type="checkbox" name="'.$item.'" id="'.$item.'"><label for="'.$item.'"><img src="'.$logo.'" />&nbsp; '.$item.'</label></li>';
}
$helpers_list_html.='</ul>';
$html=str_replace(array("\n","\r","\t"),'',$html);
/* $html = '';
echo json_encode(array( $html_tpl = '';
'tbody'=>$html, $empty_logo = '/images/logo/empty.png';
'error'=>false, $hres = $this->getTableChunk('helpers','tbody');
'func'=>'fillTable', if($hres !== false){
'id'=>'helperslist', $html_tpl = $hres[1];
'helpers_list'=>$helpers_list_html, }
)); if(!empty($lst) && !empty($html_tpl)){
*/ foreach($lst as $item){
$included_result_array=array( $tpl = $html_tpl;
'tbody'=>$html, $logo_file = 'images/logo/'.$item['helper'].'.png';
'error'=>false, $logo = file_exists($this->realpath_public.$logo_file) ? '/'.$logo_file : $empty_logo;
'func'=>'fillTable', $vars = [
'id'=>'helperslist', 'nth-num' => 'nth0',
'helpers_list'=>$helpers_list_html, 'logo' => $logo,
); 'name' => $item['helper'],
'description' => $item['description'],
'opentitle' => $this->translate('Open')
];
foreach($vars as $var => $val){
$tpl = str_replace('#'.$var.'#', $val, $tpl);
}
$html .= $tpl;
}
} else {
$html = '<tr><td colspan="3">'.$this->translate('No installed helpers').'</td></tr>';
}
// Определяем список хелперов, доступных для установки в клетку
$helpers_list_html = '<ul class="helpers-list">';
foreach($hlst as $item){
$logo_file = 'images/logo/'.$item.'.png';
$logo = file_exists($this->realpath_public.$logo_file) ? '/'.$logo_file : $empty_logo;
$helpers_list_html .= '<li><input type="checkbox" name="'.$item.'" id="'.$item.'"><label for="'.$item.'"><img src="'.$logo.'" />&nbsp; '.$item.'</label></li>';
}
$helpers_list_html .= '</ul>';
$html = str_replace(["\n","\r","\t"], '', $html);
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id' => 'helperslist',
'helpers_list' => $helpers_list_html
];
return; return;
}else{ } else {
# Открываем настройки хелпера # Открываем настройки хелпера
$db=new Db('helper',array('jname'=>$jail_name,'helper'=>$hash)); $db = new Db('helper', ['jname' => $jail_name, 'helper' => $hash]);
if($db->error) if($db->error){
{ $included_result_array = ['error' => true,'errorMessage' => 'No helper database!'];
//echo json_encode(array('error'=>true,'errorMessage'=>'No helper database!'));
$included_result_array=array('error'=>true,'errorMessage'=>'No helper database!');
return; return;
} }
$db_path=$db->getFileName(); $db_path = $db->getFileName();
$res_html=(new Forms($jail_name,$hash,$db_path))->generate(); $res_html = (new Forms($jail_name, $hash, $db_path))->generate();
$res_html='<h1>'.$this->translate('Helper settings: '.$hash).'</h1>'.$res_html; $res_html = '<h1>'.$this->translate('Helper settings: '.$hash).'</h1>'.$res_html;
} }
//echo json_encode(array('html'=>$res_html,'func'=>'fillTab')); $included_result_array = [
$included_result_array=array( 'html' => $res_html,
'html'=>$res_html, 'func' => 'fillTab'
'func'=>'fillTab' ];
);

View File

@@ -1,10 +1,8 @@
<?php <?php
$clonos->useDialogs(array( $clonos->useDialogs(['helpers-add']);
'helpers-add',
));
?> ?>
<h1><?php echo $clonos->translate('Helpers list for jail'),': ',$clonos->uri_chunks[1]; ?></h1> <h1><?php echo $clonos->translate('Helpers list for jail'), ': ', $clonos->uri_chunks[1]; ?></h1>
<div id="tab1"> <div id="tab1">
<p><span class="top-button icon-plus id:helpers-add"><?php echo $clonos->translate('Add helper'); ?></span></p> <p><span class="top-button icon-plus id:helpers-add"><?php echo $clonos->translate('Add helper'); ?></span></p>

View File

@@ -1,19 +1,17 @@
<?php <?php
if(isset($clonos->uri_chunks[1])) if(isset($clonos->uri_chunks[1])){
{
include('helpers.php'); include('helpers.php');
return; return;
} }
$clonos->useDialogs([
$clonos->useDialogs(array(
'vnc', 'vnc',
'jail-settings', 'jail-settings',
'jail-settings-config-menu', 'jail-settings-config-menu',
'jail-import', 'jail-import',
'jail-clone', 'jail-clone',
'jail-rename', 'jail-rename'
)); ]);
?> ?>
<h1>Контейнеры:</h1> <h1>Контейнеры:</h1>

View File

@@ -2,86 +2,83 @@
/* hardcode API ip. Change it later */ /* hardcode API ip. Change it later */
//$api_ip='https://bitclouds.convectix.com:1443'; //$api_ip='https://bitclouds.convectix.com:1443';
$api_ip='http://144.76.225.238'; $api_ip = 'http://144.76.225.238';
function getSslPage($url) { function getSslPage($url) {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch); $result = curl_exec($ch);
curl_close($ch); curl_close($ch);
return $result; return $result;
}
$file=getSslPage($api_ip.'/clusters');
$html='';
$res=json_decode($file,true);
$nth=0;
$hres=$this->getTableChunk('k8slist','tbody');
if(!empty($res) && isset($res['clusters']))foreach($res['clusters'] as $cluster)
{
$num=$nth & 1;
$html_tpl=$hres[1];
$vars=array(
'nth-num'=>'nth'.$num,
'name'=>$cluster['name'],
'cluster'=>$cluster['cluster'],
'masters'=>$cluster['masters'],
'workers'=>$cluster['workers'],
'bhyves'=>join('; ',$cluster['bhyves']),
//'jstatus'=>$this->translate($statuses[$status]),
//'icon'=>($status==0)?'play':'stop',
//'desktop'=>($status==0)?' s-off':' s-on',
//'maintenance'=>($status==3)?' maintenance':'',
//'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel',
//'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"',
//'vnc_title'=>$this->translate('Open VNC'),
//'reboot_title'=>$this->translate('Restart jail'),
);
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);
$html.=$html_tpl;
$nth++;
} }
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]); $file = getSslPage($api_ip.'/clusters');
if($hres!==false) $html = '';
{ $res = json_decode($file, true);
$vars=array( $nth = 0;
'nth-num'=>'nth0', $hres = $this->getTableChunk('k8slist','tbody');
'status'=>'',
'jstatus'=>$this->translate('Creating'), if(!empty($res) && isset($res['clusters'])){
'icon'=>'spin6 animate-spin', foreach($res['clusters'] as $cluster){
'desktop'=>' s-off', $num = $nth & 1;
'maintenance'=>' maintenance busy', $html_tpl = $hres[1];
'protected'=>'icon-cancel', $vars = [
'protitle'=>'', 'nth-num' => 'nth'.$num,
'vnc_title'=>$this->translate('Open VNC'), 'name' => $cluster['name'],
'reboot_title'=>$this->translate('Restart jail'), 'cluster' => $cluster['cluster'],
); 'masters' => $cluster['masters'],
'workers' => $cluster['workers'],
foreach($vars as $var=>$val) 'bhyves' => join('; ',$cluster['bhyves']),
$html_tpl_1=str_replace('#'.$var.'#',$val,$html_tpl_1); //'jstatus'=>$this->translate($statuses[$status]),
//'icon'=>($status==0)?'play':'stop',
//'desktop'=>($status==0)?' s-off':' s-on',
//'maintenance'=>($status==3)?' maintenance':'',
//'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel',
//'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"',
//'vnc_title'=>$this->translate('Open VNC'),
//'reboot_title'=>$this->translate('Restart jail'),
];
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);
$html .= $html_tpl;
$nth++;
}
} }
$included_result_array=array( $html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
'tbody'=>$html, if($hres !== false){
'error'=>false, $vars = [
'func'=>'fillTable', 'nth-num' => 'nth0',
'id'=>'k8slist', 'status' => '',
'jstatus' => $this->translate('Creating'),
'icon' => 'spin6 animate-spin',
'desktop' => ' s-off',
'maintenance' => ' maintenance busy',
'protected' => 'icon-cancel',
'protitle' => '',
'vnc_title' => $this->translate('Open VNC'),
'reboot_title' => $this->translate('Restart jail')
];
foreach($vars as $var => $val){
$html_tpl_1 = str_replace('#'.$var.'#', $val, $html_tpl_1);
}
}
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id' => 'k8slist',
//'tasks'=>$tasks, //'tasks'=>$tasks,
'template'=>$html_tpl_1, 'template' => $html_tpl_1,
//'protected'=>$protected, //'protected'=>$protected,
); ];

View File

@@ -1,16 +1,5 @@
<?php <?php
/* $clonos->useDialogs(['k8s-new']);
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
$clonos->useDialogs(array(
'k8s-new',
));
?> ?>
<h1>K8S Сlusters:</h1> <h1>K8S Сlusters:</h1>
<p><span class="top-button icon-plus id:k8s-new">Создать Kubernetes</span></p> <p><span class="top-button icon-plus id:k8s-new">Создать Kubernetes</span></p>

View File

@@ -1,15 +1,5 @@
<?php <?php
/* $clonos->useDialogs(['k8s-new']);
if(isset($clonos->uri_chunks[1]))
{
include('helpers.php');
return;
}
*/
$clonos->useDialogs(array(
'k8s-new',
));
/* /*
Модуль kubernetes использует в работе преднастроенный образ Linux, который не входит в базовую установку ClonOS. Модуль kubernetes использует в работе преднастроенный образ Linux, который не входит в базовую установку ClonOS.

View File

@@ -1,48 +1,37 @@
<?php <?php
$db=new Db('base','storage_media'); $db = new Db('base', 'storage_media');
$res=$db->select('SELECT idx,name,path,jname FROM media where type="iso"', []); $res = $db->select('SELECT idx,name,path,jname FROM media where type="iso"', []);
$html=''; $html = '';
if($res!==false) if($res !== false){
{ $nth = 0;
$nth=0; $num = $nth & 1;
$num=$nth & 1;
if(!empty($res)) foreach($res as $item) foreach($res as $item){
{ $hres = $this->getTableChunk('mediaslist','tbody');
$hres=$this->getTableChunk('mediaslist','tbody'); if($hres !== false){
if($hres!==false) $html_tmp = $hres[1];
{ $vars = [
$html_tmp=$hres[1]; 'nth-num' => 'nth'.$num,
$vars=array( 'mediaid' => $item['idx'],
'nth-num'=>'nth'.$num, 'medianame' => $item['name'],
'mediaid'=>$item['idx'], 'mediapath' => $item['path'],
'medianame'=>$item['name'], 'jname' => $item['jname'],
'mediapath'=>$item['path'], 'deltitle' => ' title="'.$this->translate('Delete').'"'
'jname'=>$item['jname'], ];
'deltitle'=>' title="'.$this->translate('Delete').'"',
); foreach($vars as $var => $val){
$html_tmp = str_replace('#'.$var.'#', $val, $html_tmp);
foreach($vars as $var=>$val) }
$html_tmp=str_replace('#'.$var.'#',$val,$html_tmp); $html .= $html_tmp;
$html.=$html_tmp;
} }
} }
/* $included_result_array = [
echo json_encode(array( 'tbody' => $html,
'tbody'=>$html, 'error' => false,
'error'=>false, 'func' => 'fillTable',
'func'=>'fillTable', 'id' => 'mediaslist'
'id'=>'mediaslist', ];
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'mediaslist',
);
} }

View File

@@ -1,4 +1,4 @@
<?php <?php
//echo '{}'; //echo '{}';
//$ips=$db1->select("select group_concat(ip,'; ') from nodelist", []); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> nodes.php //$ips=$db1->select("select group_concat(ip,'; ') from nodelist", []); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> nodes.php
$included_result_array=array(); $included_result_array = [];

View File

@@ -1,62 +1,57 @@
<?php <?php
$res_array=array( $res_array = [
'num-nodes'=>1, 'num-nodes' => 1,
'online-nodes'=>1, 'online-nodes' => 1,
'offline-nodes'=>0, 'offline-nodes' => 0,
'num-jails'=>0, 'num-jails' => 0,
'num-cores'=>0, 'num-cores' => 0,
'average'=>0, 'average' => 0,
'sum-ram'=>0, 'sum-ram' => 0,
'sum-storage'=>'Unknown', 'sum-storage' => 'Unknown',
'error'=>false, 'error' => false,
'error_message'=>'', 'error_message' => ''
); ];
$nodenames=array('local'); $nodenames = ['local'];
$db=new Db('base','nodes'); $db = new Db('base','nodes');
$nodes=$db->select('select nodename,ip from nodelist', []); $nodes = $db->select('select nodename,ip from nodelist', []);
if(!empty($nodes))foreach($nodes as $node) foreach($nodes as $node){
{ $idle = $this->check_locktime($node['ip']);
$idle=$this->check_locktime($node['ip']); if($idle == 0){
if($idle==0) $res_array['offline-nodes']++; else $res_array['online-nodes']++; $res_array['offline-nodes']++;
} else {
$nodenames[]=$node['nodename']; $res_array['online-nodes']++;
}
$nodenames[] = $node['nodename'];
} }
// extra+1: мы предполагаем, что сервер с WEB интерфейсом // extra+1: мы предполагаем, что сервер с WEB интерфейсом
// также играет роль ноды - ее можно использовать полноценно со // также играет роль ноды - ее можно использовать полноценно со
// всеми ресурсами // всеми ресурсами
$res_array['num-nodes']=count($nodes)+1; $res_array['num-nodes'] = count($nodes) + 1;
if(!empty($nodenames))foreach($nodenames as $name) foreach($nodenames as $name){
{ $ndb = new Db('base', trim($name));
$ndb=new Db('base',trim($name)); if($ndb->error){
if($ndb===false) $included_result_array = ['error' => true, 'error_message' => $ndb->error_message];
{
//echo json_encode(array('error'=>true,'error_message'=>$ndb->error_message));
$included_result_array=array('error'=>true,'error_message'=>$ndb->error_message);
exit; exit;
} }
$jcounts=$ndb->selectOne('SELECT COUNT(*) as count FROM jails;', []); $jcounts = $ndb->selectOne('SELECT COUNT(*) as count FROM jails;', []);
$res_array['num-jails']+=$jcounts['count']; $res_array['num-jails'] += $jcounts['count'];
$counts=$ndb->select('SELECT ncpu,physmem,cpufreq FROM local;', []); $counts = $ndb->select('SELECT ncpu,physmem,cpufreq FROM local;', []);
if(!empty($counts))foreach($counts as $cel) foreach($counts as $cel){
{ $res_array['num-cores'] += $cel['ncpu'];
$res_array['num-cores']+=$cel['ncpu']; $res_array['sum-ram'] += $cel['physmem'];
$res_array['sum-ram']+=$cel['physmem']; $res_array['average'] += $cel['cpufreq'];
$res_array['average']+=$cel['cpufreq'];
} }
} }
if($res_array['average']>0) if($res_array['average'] > 0){
{ $res_array['average'] = $this->GhzConvert($res_array['average']/($res_array['num-nodes']?:1));
$res_array['average']=$this->GhzConvert($res_array['average']/($res_array['num-nodes']?:1));
} }
$res_array['sum-ram']=$this->fileSizeConvert((int) $res_array['sum-ram'],1024,true); $res_array['sum-ram'] = $this->fileSizeConvert((int) $res_array['sum-ram'], 1024, true);
//echo json_encode($res_array); $included_result_array = $res_array;
$included_result_array=$res_array;

View File

@@ -16,7 +16,7 @@ $hres_set = ($hres !== false);
foreach($nodes as $node){ foreach($nodes as $node){
$db1 = new Db('base', $node['nodename']); $db1 = new Db('base', $node['nodename']);
if($db1->error !== false){ if(!$db1->error){
$bases = $db1->select("SELECT idx,name,platform,ver,rev,date FROM bsdsrc ORDER BY CAST(ver AS int)", []); $bases = $db1->select("SELECT idx,name,platform,ver,rev,date FROM bsdsrc ORDER BY CAST(ver AS int)", []);
$num = $nth & 1; $num = $nth & 1;

View File

@@ -1,84 +1,67 @@
<?php <?php
$username=$this->_user_info['username']; $username = $this->_user_info['username'];
$db = new Db('base','cbsdtaskd');
$db=new Db('base','cbsdtaskd'); $res = $db->select("SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner=? ORDER BY id DESC", array([$username]));
$res=$db->select("SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner=? ORDER BY id DESC", array([$username]));
$html=''; $html='';
if($res!==false)
{
$nth=0;
$num=$nth & 1;
if(!empty($res)) foreach($res as $item) if(!$db->error){
{ $nth = 0;
$num = $nth & 1;
foreach($res as $item){
//Utils::clonos_syslog("tasklog: HTML"); //Utils::clonos_syslog("tasklog: HTML");
$hres=$this->getTableChunk('tasklog','tbody'); $hres = $this->getTableChunk('tasklog','tbody');
if($hres!==false) if($hres !== false){
{ $html_tmp = $hres[1];
$html_tmp=$hres[1]; $vars = [
$vars=array( 'nth-num' => 'nth'.$num,
'nth-num'=>'nth'.$num, 'logid' => $item['id'],
'logid'=>$item['id'], 'logcmd' => $this->colorizeCmd($item['cmd']),
'logcmd'=>$this->colorizeCmd($item['cmd']), 'logstarttime' => date("d.m.Y H:i", strtotime($item['st_time'])),
'logstarttime'=>date("d.m.Y H:i",strtotime($item['st_time'])), 'logendtime' => date("d.m.Y H:i", strtotime($item['end_time'])),
'logendtime'=>date("d.m.Y H:i",strtotime($item['end_time'])), 'logstatus' => $item['status'],
'logstatus'=>$item['status'], 'logerrcode' => $item['errcode'],
'logerrcode'=>$item['errcode'], 'logsize'=>'0 B'
'logsize'=>'0 B', ];
);
$logsize = 0;
$logsize=0; $logfile = $item['logfile'];
$logfile=$item['logfile']; if(file_exists($logfile)){
if(file_exists($logfile)) $logsize = filesize($logfile);
{ $vars['logsize'] = $this->fileSizeConvert($logsize,1024,true);
$logsize=filesize($logfile);
$vars['logsize']=$this->fileSizeConvert($logsize,1024,true);
} }
//if($logsize>0) $vars['logfile']='<span class="link openlog" title="'.$this->translate('Open log').'">'.$vars['logfile'].'</span>'; //if($logsize>0) $vars['logfile']='<span class="link openlog" title="'.$this->translate('Open log').'">'.$vars['logfile'].'</span>';
$vars['buttvalue'] = $this->translate('Open');
$vars['buttvalue']=$this->translate('Open'); $disabled = 'disabled';
$disabled='disabled';
if($logsize>0) // && $logsize<204800 if($logsize>0) // && $logsize<204800
{ {
$disabled=''; $disabled='';
} }
$vars['disabled']=$disabled; $vars['disabled'] = $disabled;
$status = '';
$status=''; if($item['status'] == 1) $status=' progress';
if($item['status']==1) $status=' progress'; if($item['status'] == 2 && $item['errcode'] == 0) $status=' ok';
if($item['status']==2 && $item['errcode']==0) $status=' ok'; if($item['status'] == 2 && $item['errcode'] != 0) $status=' error';
if($item['status']==2 && $item['errcode']!=0) $status=' error'; $vars['status'] = $status;
$vars['status']=$status;
foreach($vars as $var => $val){
foreach($vars as $var=>$val) $html_tmp = str_replace('#'.$var.'#', $val, $html_tmp);
$html_tmp=str_replace('#'.$var.'#',$val,$html_tmp); }
$html .= $html_tmp;
$html.=$html_tmp;
//Utils::clonos_syslog("tasklog: HTML: ". $html); //Utils::clonos_syslog("tasklog: HTML: ". $html);
} }
} else { } //else {
Utils::clonos_syslog("tasklog: \$res query empty result:". "SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='". $username."' ORDER BY id DESC;"); // Utils::clonos_syslog("tasklog: \$res query empty result:". "SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='". $username."' ORDER BY id DESC;");
} //}
/*
echo json_encode(array( $included_result_array = [
'tbody'=>$html, 'tbody' => $html,
'error'=>false, 'error' => false,
'func'=>'fillTable', 'func' => 'fillTable',
'id'=>'taskloglist', 'id' => 'taskloglist'
)); ];
*/ }// else {
$included_result_array=array( // Utils::clonos_syslog("tasklog: \$res query failed:". "SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='". $username."' ORDER BY id DESC;");
'tbody'=>$html, //}
'error'=>false,
'func'=>'fillTable',
'id'=>'taskloglist',
);
} else {
Utils::clonos_syslog("tasklog: \$res query failed:". "SELECT id,st_time,end_time,cmd,status,errcode,logfile FROM taskd WHERE owner='". $username."' ORDER BY id DESC;");
}

View File

@@ -12,53 +12,36 @@ date_joined TIMESTAMP DATE DEFAULT (datetime('now','localtime'))
); );
*/ */
$html=''; $db = new Db('clonos');
$db=new Db('clonos'); if(!$db->error){
if($db!==false) $res = $db->select("select id,username,first_name,last_name,date_joined,last_login,is_active from auth_user order by date_joined desc", []);
{
$res=$db->select("select id,username,first_name,last_name,date_joined,last_login,is_active from auth_user order by date_joined desc", []);
} }
$nth=0; $html = '';
$hres=$this->getTableChunk('users','tbody'); $hres = $this->getTableChunk('users','tbody');
$html_tpl=$hres[1]; foreach($res as $r){
if(!empty($res))foreach($res as $r) $html_tpl1 = $hres[1];
{ $vars = [
$html_tpl1=$html_tpl; 'id' => $r['id'],
$vars=array( 'login' => $r['username'],
'id'=>$r['id'], 'first_name' => $r['first_name'],
'login'=>$r['username'], 'last_name' => $r['last_name'],
'first_name'=>$r['first_name'], 'date_joined' => $r['date_joined'],
'last_name'=>$r['last_name'], 'last_login' => $r['last_login'],
'date_joined'=>$r['date_joined'], 'is_active' => ($r['is_active']==1) ? 'icon-ok' : '',
'last_login'=>$r['last_login'], 'edit_title' => $this->translate('edit_title'),
'is_active'=>($r['is_active']==1)?'icon-ok':'', 'delete_title' => $this->translate('delete_title'),
'edit_title'=>$this->translate('edit_title'), ];
'delete_title'=>$this->translate('delete_title'), foreach($vars as $var => $val){
); $html_tpl1 = str_replace('#'.$var.'#', $val, $html_tpl1);
foreach($vars as $var=>$val) }
$html_tpl1=str_replace('#'.$var.'#',$val,$html_tpl1); $html .= $html_tpl1;
$html.=$html_tpl1;
} }
$included_result_array = [
$html=str_replace(array("\n","\r","\t"),'',$html); 'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
/* 'func' => 'fillTable',
echo json_encode(array( 'id' => 'userslist'
'tbody'=>$html, ];
'error'=>false,
'func'=>'fillTable',
'id'=>'userslist',
//'tasks'=>$tasks,
//'template'=>$html_tpl_1,
//'protected'=>$protected,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'userslist',
);

View File

@@ -1,7 +1,5 @@
<?php <?php
$clonos->useDialogs(array( $clonos->useDialogs(['users-new']);
'users-new',
));
?> ?>
<h1>User management</h1> <h1>User management</h1>

View File

@@ -1,7 +1,5 @@
<?php <?php
$clonos->useDialogs(array( $clonos->useDialogs(['users-new']);
'users-new',
));
?> ?>
<h1>Пользователи CBSD</h1> <h1>Пользователи CBSD</h1>

View File

@@ -1,49 +1,36 @@
<?php <?php
$html=''; $db = new Db('base','local');
$db=new Db('base','local'); if(!$db->error){
if($db!==false) $res = $db->select("select id,name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus,owner from vmpackages order by name asc", []);
{
$res=$db->select("select id,name,description,pkg_vm_ram,pkg_vm_disk,pkg_vm_cpus,owner from vmpackages order by name asc", []);
} }
$nth=0; $html = '';
$hres=$this->getTableChunk('packages','tbody'); $hres = $this->getTableChunk('packages','tbody');
$html_tpl = $hres[1];
$html_tpl=$hres[1]; foreach($res as $r){
if(!empty($res))foreach($res as $r) $html_tpl1 = $html_tpl;
{ $vars = [
$html_tpl1=$html_tpl; 'id' => $r['id'],
$vars=array( 'name' => $r['name'],
'id'=>$r['id'], 'description' => $r['description'],
'name'=>$r['name'], 'pkg_vm_ram' => $r['pkg_vm_ram'],
'description'=>$r['description'], 'pkg_vm_disk' => $r['pkg_vm_disk'],
'pkg_vm_ram'=>$r['pkg_vm_ram'], 'pkg_vm_cpus' => $r['pkg_vm_cpus'],
'pkg_vm_disk'=>$r['pkg_vm_disk'], 'owner' => $r['owner'],
'pkg_vm_cpus'=>$r['pkg_vm_cpus'], 'edit_title' => $this->translate('edit_title'),
'owner'=>$r['owner'], 'delete_title' => $this->translate('delete_title')
'edit_title'=>$this->translate('edit_title'), ];
'delete_title'=>$this->translate('delete_title'), foreach($vars as $var => $val){
); $html_tpl1 = str_replace('#'.$var.'#', $val, $html_tpl1);
foreach($vars as $var=>$val) }
$html_tpl1=str_replace('#'.$var.'#',$val,$html_tpl1); $html .= $html_tpl1;
$html.=$html_tpl1;
} }
$included_result_array = [
$html=str_replace(array("\n","\r","\t"),'',$html); 'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
/* 'func' => 'fillTable',
echo json_encode(array( 'id' => 'packageslist'
'tbody'=>$html, ];
'error'=>false,
'func'=>'fillTable',
'id'=>'packageslist',
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'packageslist',
);

View File

@@ -1,47 +1,36 @@
<?php <?php
$db=new Db('base','vpnet'); $db = new Db('base','vpnet');
$res=$db->select('SELECT idx,name,vpnet FROM vpnet', []); $res = $db->select('SELECT idx,name,vpnet FROM vpnet', []);
$html = '';
$html=''; if(!$db->error){
if($res!==false) $nth = 0;
{ $num = $nth & 1;
$nth=0;
$num=$nth & 1;
if(!empty($res)) foreach($res as $item) foreach($res as $item){
{ $hres = $this->getTableChunk('vpnetslist','tbody');
$hres=$this->getTableChunk('vpnetslist','tbody'); if($hres !== false){
if($hres!==false) $html_tmp = $hres[1];
{ $vars = [
$html_tmp=$hres[1]; 'nth-num' => 'nth'.$num,
$vars=array( 'netid' => $item['idx'],
'nth-num'=>'nth'.$num, 'netname' => $item['name'],
'netid'=>$item['idx'], 'network'=> $item['vpnet'],
'netname'=>$item['name'], 'deltitle' => ' title="'.$this->translate('Delete').'"'
'network'=>$item['vpnet'], ];
'deltitle'=>' title="'.$this->translate('Delete').'"',
); foreach($vars as $var => $val){
$html_tmp = str_replace('#'.$var.'#', $val, $html_tmp);
foreach($vars as $var=>$val) }
$html_tmp=str_replace('#'.$var.'#',$val,$html_tmp); $html .= $html_tmp;
$html.=$html_tmp;
} }
} }
/* $included_result_array = [
echo json_encode(array( 'tbody' => $html,
'tbody'=>$html, 'error' => false,
'error'=>false, 'func' => 'fillTable',
'func'=>'fillTable', 'id' => 'vpnetslist'
'id'=>'vpnetslist', ];
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'vpnetslist',
);
} }

View File

@@ -1,7 +1,5 @@
<?php <?php
$clonos->useDialogs(array( $clonos->useDialogs(['vpnet']);
'vpnet',
));
?> ?>
<h1>Subnet list</h1> <h1>Subnet list</h1>

View File

@@ -1,7 +1,5 @@
<?php <?php
$clonos->useDialogs(array( $clonos->useDialogs(['vpnet']);
'vpnet',
));
?> ?>
<h1>Список подсетей</h1> <h1>Список подсетей</h1>