mirror of
				https://github.com/optim-enterprises-bv/control-pane.git
				synced 2025-10-31 01:47:52 +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) | 			foreach($vars as $var => $val){ | ||||||
| 				$html_tmp=str_replace('#'.$var.'#',$val,$html_tmp); | 				$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', |  | ||||||
| 	); |  | ||||||
| } | } | ||||||
| @@ -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) |  | ||||||
| 	{ |  | ||||||
| 		$bases=$db1->select("SELECT idx,platform,name,arch,targetarch,ver,stable,elf,date FROM bsdbase order by cast(ver AS int)", []); |  | ||||||
|  |  | ||||||
| 		$num=$nth & 1; | foreach($nodes as $node){ | ||||||
| 		if(!empty($bases)) foreach($bases as $base) |  | ||||||
| 		{ | 	$db1 = new Db('base', $node['nodename']); | ||||||
| 			$idle=1; | 	if($db1->error !== false){ | ||||||
| 			//print_r($node);exit; |  | ||||||
| 			if($node['nodename']!='local') | 		$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=$this->check_locktime($node['ip']); |  | ||||||
|  | 		foreach($bases as $base){ | ||||||
|  | 			$idle = 1; | ||||||
|  | 			if($node['nodename'] != 'local'){ | ||||||
|  | 				$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]; | 					'id' => $id, | ||||||
| 				$vars=array( | 					'nth-num' => 'nth'.$num, | ||||||
| 					'id'=>$id, | 					'node' => $node['nodename'], | ||||||
| 					'nth-num'=>'nth'.$num, | 					'name' => $base['name'], | ||||||
| 					'node'=>$node['nodename'], | 					'platform' => $base['platform'], | ||||||
| 					'name'=>$base['name'], | 					'arch' => $base['arch'], | ||||||
| 					'platform'=>$base['platform'], | 					'targetarch' => $base['targetarch'], | ||||||
| 					'arch'=>$base['arch'], | 					'version' => $base['ver'], | ||||||
| 					'targetarch'=>$base['targetarch'], | 					'version1' => ($base['stable']==1) ? 'stable' : 'release', | ||||||
| 					'version'=>$base['ver'], | 					'elf' => $base['elf'], | ||||||
| 					'version1'=>($base['stable']==1)?'stable':'release', | 					'date' => $base['date'], | ||||||
| 					'elf'=>$base['elf'], | 					'jstatus' => '', | ||||||
| 					'date'=>$base['date'], | 					'maintenance' => ($idle == 0) ? ' maintenance' : '', | ||||||
| 					'jstatus'=>'', | 					'deltitle' => $this->translate('Delete') | ||||||
| 					'maintenance'=>($idle==0)?' maintenance':'', | 				]; | ||||||
| 					'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, $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); | 		'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; | ||||||
|  | 		foreach($bhyves as $bhyve){ | ||||||
|  | 			if($hres !== false){ | ||||||
|  |  | ||||||
| 		$num=$nth & 1; | 				$status = $this->check_vmonline($bhyve['jname']); | ||||||
| 		if(!empty($bhyves)) foreach($bhyves as $bhyve) | 				$vnc_port_status = 'grey'; | ||||||
| 		{ |  | ||||||
|  |  | ||||||
| 			if($hres!==false) | 				if($status == 1){ | ||||||
| 			{ | 					$vnc_port_file = $this->workdir.'/jails-system/'.$bhyve['jname'].'/vnc_port'; | ||||||
| 				$html_tpl=$hres[1]; | 					if(file_exists($vnc_port_file)){ | ||||||
| 				$status=$this->check_vmonline($bhyve['jname']); | 						$vnc_port = trim(file_get_contents($vnc_port_file)); | ||||||
|  |  | ||||||
| 				$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)) |  | ||||||
| 					{ |  | ||||||
| 						$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'){ | ||||||
| 					'jname'=>$bhyve['jname'], | 					$vnc_port_status = 'black'; | ||||||
| 					'nth-num'=>'nth'.$num, | 				} | ||||||
| 					'desktop'=>'', |  | ||||||
| 					'maintenance'=>'', |  | ||||||
| 					'node'=>$node, |  | ||||||
| 					'vm_name'=>'', |  | ||||||
| 					'vm_ram'=>$this->fileSizeConvert($bhyve['vm_ram']), |  | ||||||
| 					'vm_cpus'=>$bhyve['vm_cpus'], |  | ||||||
| 					'vm_os_type'=>$bhyve['vm_os_type'], |  | ||||||
| 					'vm_status'=>$this->translate($statuses[$status]), |  | ||||||
| 					'desktop'=>($status==0)?' s-off':' s-on', |  | ||||||
| 					'icon'=>($status==0)?'play':'stop', |  | ||||||
| 					'protected'=>($bhyve['protected']==1)?'icon-lock':'icon-cancel', |  | ||||||
| 					'protitle'=>' title="'.$this->translate('Delete').'"', |  | ||||||
| //					'maintenance'=>($status==3)?' maintenance':'', |  | ||||||
| //					'protected'=>($jail['protected']==1)?'icon-lock':'icon-cancel', |  | ||||||
| //					'protitle'=>($jail['protected']==1)?' title="'.$this->translate('Protected jail').'"':' title="'.$this->translate('Delete').'"', |  | ||||||
| 					'vnc_title'=>$this->translate('Open VNC'), |  | ||||||
| 					'reboot_title'=>$this->translate('Restart bhyve'), |  | ||||||
| 					'vnc_port'=>$vnc_port, |  | ||||||
| 					'vnc_port_status'=>$vnc_port_status, |  | ||||||
| 				); |  | ||||||
|  |  | ||||||
| 				foreach($vars as $var=>$val) | 				$vars = [ | ||||||
| 					$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); | 					'jname' => $bhyve['jname'], | ||||||
|  | 					'nth-num' => 'nth'.$num, | ||||||
|  | 					'desktop' => '', | ||||||
|  | 					'maintenance' => '', | ||||||
|  | 					'node' => $node, | ||||||
|  | 					'vm_name' => '', | ||||||
|  | 					'vm_ram' => $this->fileSizeConvert($bhyve['vm_ram']), | ||||||
|  | 					'vm_cpus' => $bhyve['vm_cpus'], | ||||||
|  | 					'vm_os_type' => $bhyve['vm_os_type'], | ||||||
|  | 					'vm_status' => $this->translate($statuses[$status]), | ||||||
|  | 					'desktop' => ($status == 0) ? ' s-off' : ' s-on', | ||||||
|  | 					'icon' => ($status == 0) ? 'play' : 'stop', | ||||||
|  | 					'protected' => ($bhyve['protected'] == 1) ? 'icon-lock' : 'icon-cancel', | ||||||
|  | 					'protitle' => ' title="'.$this->translate('Delete').'"', | ||||||
|  | //					'maintenance' => ($status == 3) ? ' maintenance' : '', | ||||||
|  | //					'protected' => ($jail['protected'] == 1 ) ? 'icon-lock' : 'icon-cancel', | ||||||
|  | //					'protitle' => ($jail['protected'] == 1) ? ' title="'.$this->translate('Protected jail').'"' : ' title="'.$this->translate('Delete').'"', | ||||||
|  | 					'vnc_title' => $this->translate('Open VNC'), | ||||||
|  | 					'reboot_title' => $this->translate('Restart bhyve'), | ||||||
|  | 					'vnc_port' => $vnc_port, | ||||||
|  | 					'vnc_port_status' => $vnc_port_status | ||||||
|  | 				]; | ||||||
|  |  | ||||||
| 				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) | $included_result_array = [ | ||||||
| 		$html_tpl_1=str_replace('#'.$var.'#',$val,$html_tpl_1); | 	'tbody' => str_replace(["\n","\r","\t"], '', $html), | ||||||
| } | 	'error' => false, | ||||||
|  | 	'func' => 'fillTable', | ||||||
| $protected=array( | 	'id' => 'bhyveslist', | ||||||
| 	0=>array( | 	'tasks' => $tasks, | ||||||
| 		'icon'=>'icon-cancel', | 	'template' => $html_tpl_1, | ||||||
| 		'title'=>$this->translate('Delete') | 	'protected' => $protected | ||||||
| 	), | ]; | ||||||
| 	1=>array( |  | ||||||
| 		'icon'=>'icon-lock', |  | ||||||
| 		'title'=>$this->translate('Protected bhyve') |  | ||||||
| 	) |  | ||||||
| ); |  | ||||||
|  |  | ||||||
| /* |  | ||||||
| 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
	 Momchil Bozhinov
					Momchil Bozhinov