mirror of
https://github.com/optim-enterprises-bv/control-pane.git
synced 2025-10-30 17:37:59 +00:00
* WIP
This commit is contained in:
@@ -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',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -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 !== false){
|
||||||
$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,
|
|
||||||
);
|
|
||||||
@@ -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 !== false){
|
||||||
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,
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user