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

@@ -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){
$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){
$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;
'imptitle' => ' title="'.$this->translate('Create').'"'
]);
}
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
];

View File

@@ -1,62 +1,50 @@
<?php
$jail_name='';
if(isset($this->uri_chunks[1])) $jail_name=$this->uri_chunks[1];
if(!empty($jail_name))
{
if(isset($this->uri_chunks[1])){
$jail_name = $this->uri_chunks[1];
include('helpers.json.php');
return;
}
$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'];
$statuses=array('Not Launched','Launched','unknown-1','Maintenance','unknown-3','unknown-4','unknown-5','unknown-6');
$allnodes=array();
$jail_ids=array();
$nth=0;
$hres=$this->getTableChunk('jailslist','tbody');
if(!empty($nodes))foreach($nodes as $node)
{
$db1=new Db('base',$node);
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));
$nodes = ['local'];
foreach($res as $val){
$nodes[] = $val['nodename'];
}
$html = '';
$html_tpl_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');
foreach($nodes as $node){
$db1 = new Db('base', $node);
if(!$db1->error){
$jails = $db1->select("SELECT jname,ip4_addr,status,protected FROM jails WHERE emulator!='bhyve' and hidden!=1 order by jname asc;", []);
$allnodes[$node] = $jails;
$num = $nth & 1;
foreach($jails as $jail){
if($hres !== false){
$vnc_port = '';
$vnc_port_file = $this->workdir.'/jails-system/'.$jail['jname'].'/vnc_port';
if(file_exists($vnc_port_file)){
$vnc_port = trim(file_get_contents($vnc_port_file));
}
$html_tpl = $hres[1];
$status = $jail['status'];
$vars=array(
$vars = [
'nth-num' => 'nth'.$num,
'node' => $node,
'ip4_addr' => str_replace(',',',<wbr />', $jail['ip4_addr']),
'jname'=>$jname,
'jname' => $jail['jname'],
'vnc_port' => $vnc_port,
'vnc_port_status'=>$vnc_port_status,
'vnc_port_status' => 'grey',
'status' => $status,
'jstatus' => $this->translate($statuses[$status]),
'icon' => ($status == 0) ? 'play' : 'stop',
@@ -66,13 +54,14 @@ if(!empty($nodes))foreach($nodes as $node)
'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)
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);
}
if($node != 'local'){
$html_tpl = str_replace('<span class="icon-cog"></span>', '', $html_tpl);
}
$html .= $html_tpl;
}
@@ -93,7 +82,7 @@ if(!empty($nodes))foreach($nodes as $node)
$reboot_title=$this->translate('Restart jail');
$html.=
<<<EOT
<tr class="nth{$num}{$desktop}{$maintenance}" id="{$jname}">
<tr class="nth{$num}{$desktop}{$maintenance}" id="{$jail['jname']}">
<td>{$node}</td>
<td class="txtleft">{$jail['jname']}</td>
<td class="txtleft jname">{$jail['ip4_addr']}</td>
@@ -107,25 +96,17 @@ if(!empty($nodes))foreach($nodes as $node)
EOT;
*/
}
$nth++;
} else {
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(!empty($jail_ids))
{
$tasks=$this->getRunningTasks($jail_ids);
}
//echo '<pre>';print_r($tasks);exit;
$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',
'status' => '',
'jstatus' => $this->translate('Creating'),
@@ -135,42 +116,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 jail')
)
);
]
];
/*
echo json_encode(array(
// 'thead'=>$thead,
'tbody'=>$html,
$included_result_array = [
'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
'func' => 'fillTable',
'id' => 'jailslist',
'tasks' => $tasks,
'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,
);
'protected' => $protected
];

View File

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

View File

@@ -1,32 +1,29 @@
<?php
$hash = $this->url_hash;
if(empty($hash))
{
if(empty($hash)){
# Узнаём список хелперов
$jails_helpers=array();
$jails_helpers = [];
$db = new Db('clonos');
if($db!==false)
{
$query="select module from jails_helpers_list";
if(!$db->error)
{
$res=$db->select($query, []);
if(!empty($res))
{
foreach($res as $r) $jails_helpers[]=$r['module'];
if (!$db->error){
$res = $db->select("select module from jails_helpers_list", []);
if(!empty($res)){
foreach($res as $r){
$jails_helpers[] = $r['module'];
}
}
}
$lst=array();
if(!empty($jails_helpers)) foreach($jails_helpers as $helper)
{
$db=new Db('helper',array('jname'=>$jail_name,'helper'=>$helper));
$lst = [];
foreach($jails_helpers as $helper){
$db = new Db('helper', ['jname' => $jail_name, 'helper' => $helper]);
if(!$db->error) // !error — значит хелпер установлен
{
$res = $db->selectOne("select longdesc from system", []);
if(isset($res['longdesc'])) $description=$res['longdesc']; else $description=$this->translate('no data').'&hellip; ('.$file_name.')';
$lst[]=array('helper'=>$helper,'description'=>$description);
if(isset($res['longdesc'])){
$description = $res['longdesc'];
} else {
$description = $this->translate('no data').'&hellip; ('.$file_name.')';
}
$lst[] = ['helper' => $helper, 'description' => $description];
} else {
$hlst[] = $helper;
}
@@ -36,26 +33,25 @@ if(empty($hash))
$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)
{
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(
$vars = [
'nth-num' => 'nth0',
'logo' => $logo,
'name' => $item['helper'],
'description' => $item['description'],
'opentitle'=>$this->translate('Open'),
);
'opentitle' => $this->translate('Open')
];
foreach($vars as $var=>$val)
foreach($vars as $var => $val){
$tpl = str_replace('#'.$var.'#', $val, $tpl);
}
$html .= $tpl;
}
} else {
@@ -64,40 +60,27 @@ if(empty($hash))
// Определяем список хелперов, доступных для установки в клетку
$helpers_list_html = '<ul class="helpers-list">';
if(!empty($hlst)) foreach($hlst as $item)
{
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);
$html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array(
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id' => 'helperslist',
'helpers_list'=>$helpers_list_html,
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'helperslist',
'helpers_list'=>$helpers_list_html,
);
'helpers_list' => $helpers_list_html
];
return;
} else {
# Открываем настройки хелпера
$db=new Db('helper',array('jname'=>$jail_name,'helper'=>$hash));
if($db->error)
{
//echo json_encode(array('error'=>true,'errorMessage'=>'No helper database!'));
$included_result_array=array('error'=>true,'errorMessage'=>'No helper database!');
$db = new Db('helper', ['jname' => $jail_name, 'helper' => $hash]);
if($db->error){
$included_result_array = ['error' => true,'errorMessage' => 'No helper database!'];
return;
}
@@ -106,8 +89,7 @@ if(empty($hash))
$res_html = '<h1>'.$this->translate('Helper settings: '.$hash).'</h1>'.$res_html;
}
//echo json_encode(array('html'=>$res_html,'func'=>'fillTab'));
$included_result_array=array(
$included_result_array = [
'html' => $res_html,
'func' => 'fillTab'
);
];

View File

@@ -1,7 +1,5 @@
<?php
$clonos->useDialogs(array(
'helpers-add',
));
$clonos->useDialogs(['helpers-add']);
?>
<h1><?php echo $clonos->translate('Helpers list for jail'), ': ', $clonos->uri_chunks[1]; ?></h1>

View File

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

View File

@@ -16,20 +16,18 @@ function getSslPage($url) {
curl_close($ch);
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)
{
if(!empty($res) && isset($res['clusters'])){
foreach($res['clusters'] as $cluster){
$num = $nth & 1;
$html_tpl = $hres[1];
$vars=array(
$vars = [
'nth-num' => 'nth'.$num,
'name' => $cluster['name'],
'cluster' => $cluster['cluster'],
@@ -44,22 +42,20 @@ if(!empty($res) && isset($res['clusters']))foreach($res['clusters'] as $cluster)
//'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)
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]);
if($hres!==false)
{
$vars=array(
$html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
if($hres !== false){
$vars = [
'nth-num' => 'nth0',
'status' => '',
'jstatus' => $this->translate('Creating'),
@@ -69,14 +65,15 @@ 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);
}
}
$included_result_array=array(
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
@@ -84,4 +81,4 @@ $included_result_array=array(
//'tasks'=>$tasks,
'template' => $html_tpl_1,
//'protected'=>$protected,
);
];

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
<?php
//echo '{}';
//$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,5 +1,5 @@
<?php
$res_array=array(
$res_array = [
'num-nodes' => 1,
'online-nodes' => 1,
'offline-nodes' => 0,
@@ -9,33 +9,31 @@ $res_array=array(
'sum-ram' => 0,
'sum-storage' => 'Unknown',
'error' => false,
'error_message'=>'',
);
'error_message' => ''
];
$nodenames=array('local');
$nodenames = ['local'];
$db = new Db('base','nodes');
$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']);
if($idle==0) $res_array['offline-nodes']++; else $res_array['online-nodes']++;
if($idle == 0){
$res_array['offline-nodes']++;
} else {
$res_array['online-nodes']++;
}
$nodenames[] = $node['nodename'];
}
// extra+1: мы предполагаем, что сервер с WEB интерфейсом
// также играет роль ноды - ее можно использовать полноценно со
// всеми ресурсами
$res_array['num-nodes'] = count($nodes) + 1;
if(!empty($nodenames))foreach($nodenames as $name)
{
foreach($nodenames as $name){
$ndb = new Db('base', trim($name));
if($ndb===false)
{
//echo json_encode(array('error'=>true,'error_message'=>$ndb->error_message));
$included_result_array=array('error'=>true,'error_message'=>$ndb->error_message);
if($ndb->error){
$included_result_array = ['error' => true, 'error_message' => $ndb->error_message];
exit;
}
@@ -43,20 +41,17 @@ if(!empty($nodenames))foreach($nodenames as $name)
$res_array['num-jails'] += $jcounts['count'];
$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['sum-ram'] += $cel['physmem'];
$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['sum-ram'] = $this->fileSizeConvert((int) $res_array['sum-ram'], 1024, true);
//echo json_encode($res_array);
$included_result_array = $res_array;

View File

@@ -16,7 +16,7 @@ $hres_set = ($hres !== false);
foreach($nodes as $node){
$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)", []);
$num = $nth & 1;

View File

@@ -1,26 +1,21 @@
<?php
$username = $this->_user_info['username'];
$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]));
$html='';
if($res!==false)
{
if(!$db->error){
$nth = 0;
$num = $nth & 1;
if(!empty($res)) foreach($res as $item)
{
foreach($res as $item){
//Utils::clonos_syslog("tasklog: HTML");
$hres = $this->getTableChunk('tasklog','tbody');
if($hres!==false)
{
if($hres !== false){
$html_tmp = $hres[1];
$vars=array(
$vars = [
'nth-num' => 'nth'.$num,
'logid' => $item['id'],
'logcmd' => $this->colorizeCmd($item['cmd']),
@@ -28,57 +23,45 @@ if($res!==false)
'logendtime' => date("d.m.Y H:i", strtotime($item['end_time'])),
'logstatus' => $item['status'],
'logerrcode' => $item['errcode'],
'logsize'=>'0 B',
);
'logsize'=>'0 B'
];
$logsize = 0;
$logfile = $item['logfile'];
if(file_exists($logfile))
{
if(file_exists($logfile)){
$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>';
$vars['buttvalue'] = $this->translate('Open');
$disabled = 'disabled';
if($logsize>0) // && $logsize<204800
{
$disabled='';
}
$vars['disabled'] = $disabled;
$status = '';
if($item['status'] == 1) $status=' progress';
if($item['status'] == 2 && $item['errcode'] == 0) $status=' ok';
if($item['status'] == 2 && $item['errcode'] != 0) $status=' error';
$vars['status'] = $status;
foreach($vars as $var=>$val)
foreach($vars as $var => $val){
$html_tmp = str_replace('#'.$var.'#', $val, $html_tmp);
}
$html .= $html_tmp;
//Utils::clonos_syslog("tasklog: HTML: ". $html);
}
} 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;");
}
/*
echo json_encode(array(
} //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;");
//}
$included_result_array = [
'tbody' => $html,
'error' => false,
'func' => 'fillTable',
'id'=>'taskloglist',
));
*/
$included_result_array=array(
'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;");
}
'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,21 +12,17 @@ date_joined TIMESTAMP DATE DEFAULT (datetime('now','localtime'))
);
*/
$html='';
$db = new Db('clonos');
if($db!==false)
{
if(!$db->error){
$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');
$html_tpl=$hres[1];
if(!empty($res))foreach($res as $r)
{
$html_tpl1=$html_tpl;
$vars=array(
foreach($res as $r){
$html_tpl1 = $hres[1];
$vars = [
'id' => $r['id'],
'login' => $r['username'],
'first_name' => $r['first_name'],
@@ -36,29 +32,16 @@ if(!empty($res))foreach($res as $r)
'is_active' => ($r['is_active']==1) ? 'icon-ok' : '',
'edit_title' => $this->translate('edit_title'),
'delete_title' => $this->translate('delete_title'),
);
foreach($vars as $var=>$val)
];
foreach($vars as $var => $val){
$html_tpl1 = str_replace('#'.$var.'#', $val, $html_tpl1);
}
$html .= $html_tpl1;
}
$html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array(
'tbody'=>$html,
$included_result_array = [
'tbody' => str_replace(["\n","\r","\t"], '', $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',
);
'id' => 'userslist'
];

View File

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

View File

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

View File

@@ -1,20 +1,17 @@
<?php
$html='';
$db = new Db('base','local');
if($db!==false)
{
if(!$db->error){
$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');
$html_tpl = $hres[1];
if(!empty($res))foreach($res as $r)
{
foreach($res as $r){
$html_tpl1 = $html_tpl;
$vars=array(
$vars = [
'id' => $r['id'],
'name' => $r['name'],
'description' => $r['description'],
@@ -23,27 +20,17 @@ if(!empty($res))foreach($res as $r)
'pkg_vm_cpus' => $r['pkg_vm_cpus'],
'owner' => $r['owner'],
'edit_title' => $this->translate('edit_title'),
'delete_title'=>$this->translate('delete_title'),
);
foreach($vars as $var=>$val)
'delete_title' => $this->translate('delete_title')
];
foreach($vars as $var => $val){
$html_tpl1 = str_replace('#'.$var.'#', $val, $html_tpl1);
}
$html .= $html_tpl1;
}
$html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array(
'tbody'=>$html,
$included_result_array = [
'tbody' => str_replace(["\n","\r","\t"], '', $html),
'error' => false,
'func' => 'fillTable',
'id'=>'packageslist',
));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'packageslist',
);
'id' => 'packageslist'
];

View File

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

View File

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

View File

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