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'); $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; $nth = 0;
$num = $nth & 1; $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 = [
$html_tmp=$hres[1];
$vars=array(
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'keyid' => $item['idx'], 'keyid' => $item['idx'],
'keyname' => $item['name'], 'keyname' => $item['name'],
'keysrc' => $item['authkey'], 'keysrc' => $item['authkey'],
'deltitle'=>' title="'.$this->translate('Delete').'"', '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, $hres[1]);
}
$html .= $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,38 +1,35 @@
<?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;
$html = '';
$html_tpl = '';
$hres = $this->getTableChunk('baseslist','tbody'); $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; $num = $nth & 1;
if(!empty($bases)) foreach($bases as $base)
{ foreach($bases as $base){
$idle = 1; $idle = 1;
//print_r($node);exit; if($node['nodename'] != 'local'){
if($node['nodename']!='local')
{
$idle = $this->check_locktime($node['ip']); $idle = $this->check_locktime($node['ip']);
} }
$ids[] = $base['idx']; $ids[] = $base['idx'];
$id = 'base'.$base['ver'].'-'.$base['arch'].'-'.$base['stable']; $id = 'base'.$base['ver'].'-'.$base['arch'].'-'.$base['stable'];
if($hres!==false) if($hres !== false){
{ $vars = [
$html_tpl=$hres[1];
$vars=array(
'id' => $id, 'id' => $id,
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'node' => $node['nodename'], 'node' => $node['nodename'],
@@ -46,35 +43,26 @@ if(!empty($nodes))foreach($nodes as $node)
'date' => $base['date'], 'date' => $base['date'],
'jstatus' => '', 'jstatus' => '',
'maintenance' => ($idle == 0) ? ' maintenance' : '', 'maintenance' => ($idle == 0) ? ' maintenance' : '',
'deltitle'=>$this->translate('Delete'), 'deltitle' => $this->translate('Delete')
); ];
foreach($vars as $var=>$val)
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl);
foreach($vars as $var => $val){
$html_tpl = str_replace('#'.$var.'#', $val, $hres[1]);
}
$html .= $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);
}
$html_tpl=str_replace(array("\n","\r","\t"),'',$hres[1]);
if($hres!==false)
{
$vars=array(
'nth-num' => 'nth0', 'nth-num' => 'nth0',
'status' => '', 'status' => '',
//'jstatus' => $this->translate('Updating'), //'jstatus' => $this->translate('Updating'),
@@ -82,27 +70,19 @@ if($hres!==false)
'desktop' => ' s-off', 'desktop' => ' s-off',
'maintenance' => ' maintenance busy', 'maintenance' => ' maintenance busy',
'updtitle' => $this->translate('Update'), '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); $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, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id' => 'baseslist', 'id' => 'baseslist',
'tasks' => $tasks, 'tasks' => $tasks,
'template'=>$html_tpl, 'template' => $html_tpl
)); ];
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'baseslist',
'tasks'=>$tasks,
'template'=>$html_tpl,
);

View File

@@ -1,52 +1,49 @@
<?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 = [];
$jail_ids=array();
$nth = 0; $nth = 0;
$html = '';
$html_tpl_1 = '';
$hres = $this->getTableChunk('bhyveslist','tbody'); $hres = $this->getTableChunk('bhyveslist','tbody');
if(!empty($nodes))foreach($nodes as $node)
{ foreach($nodes as $node){
$db1 = new Db('base', $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;", []); $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;
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']); $status = $this->check_vmonline($bhyve['jname']);
$jname=$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';
$vars=array( if($bhyve['bhyve_vnc_tcp_bind'] != '127.0.0.1'){
$vnc_port_status = 'black';
}
$vars = [
'jname' => $bhyve['jname'], 'jname' => $bhyve['jname'],
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'desktop' => '', 'desktop' => '',
@@ -67,36 +64,29 @@ if(!empty($nodes))foreach($nodes as $node)
'vnc_title' => $this->translate('Open VNC'), 'vnc_title' => $this->translate('Open VNC'),
'reboot_title' => $this->translate('Restart bhyve'), 'reboot_title' => $this->translate('Restart bhyve'),
'vnc_port' => $vnc_port, 'vnc_port' => $vnc_port,
'vnc_port_status'=>$vnc_port_status, '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);
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; $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);
}
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]);
if($hres!==false)
{
$vars=array(
'nth-num' => 'nth0', 'nth-num' => 'nth0',
'vm_status' => $this->translate('Creating'), 'vm_status' => $this->translate('Creating'),
'icon' => 'spin6 animate-spin', 'icon' => 'spin6 animate-spin',
@@ -105,42 +95,31 @@ if($hres!==false)
'protected' => 'icon-cancel', 'protected' => 'icon-cancel',
'protitle' => '', 'protitle' => '',
'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_1 = str_replace('#'.$var.'#', $val, $html_tpl_1); $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 bhyve') 'title' => $this->translate('Protected bhyve')
) ]
); ];
/* $included_result_array = [
echo json_encode(array( 'tbody' => str_replace(["\n","\r","\t"], '', $html),
'tbody'=>$html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id' => 'bhyveslist', 'id' => 'bhyveslist',
'tasks' => $tasks, 'tasks' => $tasks,
'template' => $html_tpl_1, 'template' => $html_tpl_1,
'protected'=>$protected, '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);
}
return $tpl;
}
$res = [
// 'item' => [
0 => [
'id' => 1, 'id' => 1,
'name' => 'test', 'name' => 'test',
'path' => 'test/test/', 'path' => 'test/test/',
'type'=>'клетка', 'type' => 'клетка'
) ]
// ) // ]
); ];
$images = $this->getImportedImages(); $images = $this->getImportedImages();
$html = ''; $html = '';
$html_tpl_1 = '';
$nth = 0; $nth = 0;
$num = $nth & 1; $num = $nth & 1;
$html_tpl = ''; $html_tpl = '';
$hres = $this->getTableChunk('impslist','tbody'); $hres = $this->getTableChunk('impslist','tbody');
if($hres!==false) if($hres !== false){
{ $html_tpl_1 = replaceVars($hres[1], [
$html_tmp=$hres[1];
$html_tmp=replaceVars($html_tmp,array(
'deltitle' => ' title="'.$this->translate('Delete').'"', 'deltitle' => ' title="'.$this->translate('Delete').'"',
'dnldtitle' => ' title="'.$this->translate('Download').'"', 'dnldtitle' => ' title="'.$this->translate('Download').'"',
'imptitle'=>' title="'.$this->translate('Create').'"') 'imptitle' => ' title="'.$this->translate('Create').'"'
); ]);
$html_tpl_1=$html_tmp;
} }
if(!empty($images)) foreach($images as $item) foreach($images as $item){
{ if(!isset($item['type'])){
if(!isset($item['type'])) $item['type']='unknown'; $item['type'] = 'unknown';
}
//$hres=$this->getTableChunk('impslist','tbody'); //$hres=$this->getTableChunk('impslist','tbody');
if($hres!==false) if($hres !== false){
{ $html_tpl = $html_tpl_1;
/*
$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']; $filename = $this->media_import.$item['name'];
$sizefilename = $filename.'.size'; $sizefilename = $filename.'.size';
if(file_exists($sizefilename)) if(file_exists($sizefilename)){
{
$size = file_get_contents($sizefilename); $size = file_get_contents($sizefilename);
} else { } else {
$size = filesize($filename); $size = filesize($filename);
} }
$filesize = $this->fileSizeConvert($size, 1024, true); $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, []); $busy = $this->_db_tasks->selectOne($query, []);
$jstatus = ''; $jstatus = '';
$jbusy = ''; $jbusy = '';
if($busy['busy']==1) if($busy['busy'] == 1){
{
$jstatus = $this->translate('Exporting'); $jstatus = $this->translate('Exporting');
$jbusy = 'busy'; $jbusy = 'busy';
} }
$vars=array( $vars = [
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'id' => $item['name'], 'id' => $item['name'],
'jname' => $item['name'], 'jname' => $item['name'],
'impsize' => $filesize, 'impsize' => $filesize,
'jstatus' => $jstatus, 'jstatus' => $jstatus,
'busy' => $jbusy, '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_tpl = str_replace('#'.$var.'#', $val, $html_tpl);
// $html_tmp=str_replace('#'.$var.'#',$val,$html_tmp); }
$html .= $html_tpl; $html .= $html_tpl;
} }
} }
function replaceVars($tpl,$vars) $included_result_array = [
{
foreach($vars as $var=>$val)
$tpl=str_replace('#'.$var.'#',$val,$tpl);
return $tpl;
}
/*
echo json_encode(array(
'tbody' => $html, 'tbody' => $html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id' => 'impslist', 'id' => 'impslist',
'template'=>$html_tpl_1, 'template' => $html_tpl_1
)); ];
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'impslist',
'template'=>$html_tpl_1,
);

View File

@@ -1,62 +1,50 @@
<?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;
} }
$html='';
//$hres=$this->getTableChunk('jailslist','thead');
//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');
$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));
} }
$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]; $html_tpl = $hres[1];
$status = $jail['status']; $status = $jail['status'];
$vars=array( $vars = [
'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'=>$jname, 'jname' => $jail['jname'],
'vnc_port' => $vnc_port, 'vnc_port' => $vnc_port,
'vnc_port_status'=>$vnc_port_status, 'vnc_port_status' => 'grey',
'status' => $status, 'status' => $status,
'jstatus' => $this->translate($statuses[$status]), 'jstatus' => $this->translate($statuses[$status]),
'icon' => ($status == 0) ? 'play' : 'stop', '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').'"', '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') $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; $html .= $html_tpl;
} }
@@ -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,25 +96,17 @@ 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);
}
//echo '<pre>';print_r($tasks);exit;
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]);
if($hres!==false)
{
$vars=array(
'nth-num' => 'nth0', 'nth-num' => 'nth0',
'status' => '', 'status' => '',
'jstatus' => $this->translate('Creating'), 'jstatus' => $this->translate('Creating'),
@@ -135,42 +116,31 @@ if($hres!==false)
'protected' => 'icon-cancel', 'protected' => 'icon-cancel',
'protitle' => '', 'protitle' => '',
'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_1 = str_replace('#'.$var.'#', $val, $html_tpl_1); $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,
'tbody'=>$html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id' => 'jailslist', 'id' => 'jailslist',
'tasks' => $tasks, 'tasks' => $tasks,
'template' => $html_tpl_1, 'template' => $html_tpl_1,
'protected'=>$protected, '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,32 +1,29 @@
<?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 {
$description = $this->translate('no data').'&hellip; ('.$file_name.')';
}
$lst[] = ['helper' => $helper, 'description' => $description];
} else { } else {
$hlst[] = $helper; $hlst[] = $helper;
} }
@@ -36,26 +33,25 @@ if(empty($hash))
$html_tpl = ''; $html_tpl = '';
$empty_logo = '/images/logo/empty.png'; $empty_logo = '/images/logo/empty.png';
$hres = $this->getTableChunk('helpers','tbody'); $hres = $this->getTableChunk('helpers','tbody');
if($hres!==false) $html_tpl=$hres[1]; if($hres !== false){
$html_tpl = $hres[1];
if(!empty($lst) && !empty($html_tpl)) }
{ if(!empty($lst) && !empty($html_tpl)){
foreach($lst as $item) foreach($lst as $item){
{
$tpl = $html_tpl; $tpl = $html_tpl;
$logo_file = 'images/logo/'.$item['helper'].'.png'; $logo_file = 'images/logo/'.$item['helper'].'.png';
$logo = file_exists($this->realpath_public.$logo_file) ? '/'.$logo_file : $empty_logo; $logo = file_exists($this->realpath_public.$logo_file) ? '/'.$logo_file : $empty_logo;
$vars=array( $vars = [
'nth-num' => 'nth0', 'nth-num' => 'nth0',
'logo' => $logo, 'logo' => $logo,
'name' => $item['helper'], 'name' => $item['helper'],
'description' => $item['description'], '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); $tpl = str_replace('#'.$var.'#', $val, $tpl);
}
$html .= $tpl; $html .= $tpl;
} }
} else { } else {
@@ -64,40 +60,27 @@ if(empty($hash))
// Определяем список хелперов, доступных для установки в клетку // Определяем список хелперов, доступных для установки в клетку
$helpers_list_html = '<ul class="helpers-list">'; $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 = 'images/logo/'.$item.'.png';
$logo = file_exists($this->realpath_public.$logo_file) ? '/'.$logo_file : $empty_logo; $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 .= '<li><input type="checkbox" name="'.$item.'" id="'.$item.'"><label for="'.$item.'"><img src="'.$logo.'" />&nbsp; '.$item.'</label></li>';
} }
$helpers_list_html .= '</ul>'; $helpers_list_html .= '</ul>';
$html = str_replace(["\n","\r","\t"], '', $html);
$html=str_replace(array("\n","\r","\t"),'',$html); $included_result_array = [
/*
echo json_encode(array(
'tbody' => $html, 'tbody' => $html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id' => 'helperslist', 'id' => 'helperslist',
'helpers_list'=>$helpers_list_html, 'helpers_list' => $helpers_list_html
)); ];
*/
$included_result_array=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;
} }
@@ -106,8 +89,7 @@ if(empty($hash))
$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,7 +1,5 @@
<?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>

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

@@ -16,20 +16,18 @@ function getSslPage($url) {
curl_close($ch); curl_close($ch);
return $result; return $result;
} }
$file = getSslPage($api_ip.'/clusters'); $file = getSslPage($api_ip.'/clusters');
$html = ''; $html = '';
$res = json_decode($file, true); $res = json_decode($file, true);
$nth = 0; $nth = 0;
$hres = $this->getTableChunk('k8slist','tbody'); $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; $num = $nth & 1;
$html_tpl = $hres[1]; $html_tpl = $hres[1];
$vars=array( $vars = [
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'name' => $cluster['name'], 'name' => $cluster['name'],
'cluster' => $cluster['cluster'], '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').'"', //'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') $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; $html .= $html_tpl;
$nth++; $nth++;
} }
}
$html_tpl_1=str_replace(array("\n","\r","\t"),'',$hres[1]); $html_tpl_1 = str_replace(["\n","\r","\t"], '', $hres[1]);
if($hres!==false) if($hres !== false){
{ $vars = [
$vars=array(
'nth-num' => 'nth0', 'nth-num' => 'nth0',
'status' => '', 'status' => '',
'jstatus' => $this->translate('Creating'), 'jstatus' => $this->translate('Creating'),
@@ -69,14 +65,15 @@ if($hres!==false)
'protected' => 'icon-cancel', 'protected' => 'icon-cancel',
'protitle' => '', 'protitle' => '',
'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_1 = str_replace('#'.$var.'#', $val, $html_tpl_1); $html_tpl_1 = str_replace('#'.$var.'#', $val, $html_tpl_1);
} }
}
$included_result_array=array( $included_result_array = [
'tbody' => $html, 'tbody' => $html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
@@ -84,4 +81,4 @@ $included_result_array=array(
//'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

@@ -4,45 +4,34 @@ $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]; $html_tmp = $hres[1];
$vars=array( $vars = [
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'mediaid' => $item['idx'], 'mediaid' => $item['idx'],
'medianame' => $item['name'], 'medianame' => $item['name'],
'mediapath' => $item['path'], 'mediapath' => $item['path'],
'jname' => $item['jname'], '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_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,5 +1,5 @@
<?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,
@@ -9,33 +9,31 @@ $res_array=array(
'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) $res_array['offline-nodes']++; else $res_array['online-nodes']++; if($idle == 0){
$res_array['offline-nodes']++;
} else {
$res_array['online-nodes']++;
}
$nodenames[] = $node['nodename']; $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===false) if($ndb->error){
{ $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;
} }
@@ -43,20 +41,17 @@ if(!empty($nodenames))foreach($nodenames as $name)
$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,26 +1,21 @@
<?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)
{ if(!$db->error){
$nth = 0; $nth = 0;
$num = $nth & 1; $num = $nth & 1;
if(!empty($res)) foreach($res as $item) 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=array( $vars = [
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'logid' => $item['id'], 'logid' => $item['id'],
'logcmd' => $this->colorizeCmd($item['cmd']), 'logcmd' => $this->colorizeCmd($item['cmd']),
@@ -28,57 +23,45 @@ if($res!==false)
'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); $logsize = filesize($logfile);
$vars['logsize'] = $this->fileSizeConvert($logsize,1024,true); $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,21 +12,17 @@ date_joined TIMESTAMP DATE DEFAULT (datetime('now','localtime'))
); );
*/ */
$html='';
$db = new Db('clonos'); $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", []); $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;
$vars=array(
'id' => $r['id'], 'id' => $r['id'],
'login' => $r['username'], 'login' => $r['username'],
'first_name' => $r['first_name'], 'first_name' => $r['first_name'],
@@ -36,29 +32,16 @@ if(!empty($res))foreach($res as $r)
'is_active' => ($r['is_active']==1) ? 'icon-ok' : '', 'is_active' => ($r['is_active']==1) ? 'icon-ok' : '',
'edit_title' => $this->translate('edit_title'), 'edit_title' => $this->translate('edit_title'),
'delete_title' => $this->translate('delete_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_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),
/*
echo json_encode(array(
'tbody'=>$html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id'=>'userslist', '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,20 +1,17 @@
<?php <?php
$html='';
$db = new Db('base','local'); $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", []); $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];
if(!empty($res))foreach($res as $r)
{ foreach($res as $r){
$html_tpl1 = $html_tpl; $html_tpl1 = $html_tpl;
$vars=array( $vars = [
'id' => $r['id'], 'id' => $r['id'],
'name' => $r['name'], 'name' => $r['name'],
'description' => $r['description'], 'description' => $r['description'],
@@ -23,27 +20,17 @@ if(!empty($res))foreach($res as $r)
'pkg_vm_cpus' => $r['pkg_vm_cpus'], 'pkg_vm_cpus' => $r['pkg_vm_cpus'],
'owner' => $r['owner'], 'owner' => $r['owner'],
'edit_title' => $this->translate('edit_title'), 'edit_title' => $this->translate('edit_title'),
'delete_title'=>$this->translate('delete_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_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),
/*
echo json_encode(array(
'tbody'=>$html,
'error' => false, 'error' => false,
'func' => 'fillTable', 'func' => 'fillTable',
'id'=>'packageslist', 'id' => 'packageslist'
)); ];
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'packageslist',
);

View File

@@ -2,46 +2,35 @@
$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($res!==false)
{ if(!$db->error){
$nth = 0; $nth = 0;
$num = $nth & 1; $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]; $html_tmp = $hres[1];
$vars=array( $vars = [
'nth-num' => 'nth'.$num, 'nth-num' => 'nth'.$num,
'netid' => $item['idx'], 'netid' => $item['idx'],
'netname' => $item['name'], 'netname' => $item['name'],
'network'=> $item['vpnet'], '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_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>