mirror of
				https://github.com/optim-enterprises-bv/control-pane.git
				synced 2025-10-31 01:47:52 +00:00 
			
		
		
		
	auto-sync
This commit is contained in:
		| @@ -1,5 +1,4 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| require_once("cbsd.php"); | require_once("cbsd.php"); | ||||||
| require_once('config.php'); | require_once('config.php'); | ||||||
| require_once('localization.php'); | require_once('localization.php'); | ||||||
| @@ -1634,8 +1633,12 @@ class ClonOS { | |||||||
| 	function ccmd_srcRemove(){ | 	function ccmd_srcRemove(){ | ||||||
| 		$ver=str_replace('src','',$this->formform['jname']); | 		$ver=str_replace('src','',$this->formform['jname']); | ||||||
| 		if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); | 		if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); | ||||||
|  | //		return CBSD::run( | ||||||
|  | //			'task owner='.$username.' mode=new {cbsd_loc} removesrc inter=0 ver=%s jname=#src%s', | ||||||
|  | //			array($this->_user_info['username'], $ver, $ver) | ||||||
|  | //		); | ||||||
| 		return CBSD::run( | 		return CBSD::run( | ||||||
| 			'task owner='.$username.' mode=new {cbsd_loc} removesrc inter=0 ver=%s jname=#src%s', | 			'task owner='.$username.' mode=new {cbsd_loc} removesrc inter=0 ver=%s jname=src%s', | ||||||
| 			array($this->_user_info['username'], $ver, $ver) | 			array($this->_user_info['username'], $ver, $ver) | ||||||
| 		); | 		); | ||||||
| 	} | 	} | ||||||
| @@ -1644,8 +1647,12 @@ class ClonOS { | |||||||
| 		$ver=str_replace('src','',$this->form['jname']); | 		$ver=str_replace('src','',$this->form['jname']); | ||||||
| 		$stable=(preg_match('#\.\d#',$ver))?0:1; | 		$stable=(preg_match('#\.\d#',$ver))?0:1; | ||||||
| 		if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); | 		if(empty($ver)) return array('error'=>true,'errorMessage'=>'Version of sources is emtpy!'); | ||||||
|  | //		return CBSD::run( | ||||||
|  | //			'task owner=%s mode=new {cbsd_loc} srcup stable=%s inter=0 ver=%s jname=#src%s', | ||||||
|  | //			array($this->_user_info['username'], $stable, $ver, $ver) | ||||||
|  | //		); | ||||||
| 		return CBSD::run( | 		return CBSD::run( | ||||||
| 			'task owner=%s mode=new {cbsd_loc} srcup stable=%s inter=0 ver=%s jname=#src%s', | 			'task owner=%s mode=new {cbsd_loc} srcup stable=%s inter=0 ver=%s jname=src%s', | ||||||
| 			array($this->_user_info['username'], $stable, $ver, $ver) | 			array($this->_user_info['username'], $stable, $ver, $ver) | ||||||
| 		); | 		); | ||||||
| 	} | 	} | ||||||
| @@ -1693,10 +1700,24 @@ class ClonOS { | |||||||
| 		$arch=$res[2]; | 		$arch=$res[2]; | ||||||
| 		$stable=$res[3]; | 		$stable=$res[3]; | ||||||
|  |  | ||||||
| 		return $this->CBSD::run( | 		$username=$this->_user_info['username']; | ||||||
| 			'task owner=%s mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=#%s', |  | ||||||
| 			array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname']) | 		$remove_cmd="task owner={$username} mode=new /usr/local/bin/cbsd removebase inter=0 stable={$stable} ver={$ver} arch={$arch} jname=#".$this->form['jname']; | ||||||
| 		); |  | ||||||
|  | 		Utils::clonos_syslog("cmd.php removeBase cmd:". $remove_cmd); | ||||||
|  |  | ||||||
|  | //		return $this->CBSD::run( | ||||||
|  | //			'task owner=%s mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=#%s', | ||||||
|  | //			array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname']) | ||||||
|  | //		); | ||||||
|  | //		$res=CBSD::run('task owner=%s mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=#%s',array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname'])); | ||||||
|  | 		$res=CBSD::run('task owner=%s mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=%s',array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname'])); | ||||||
|  |  | ||||||
|  | 		return $res; | ||||||
|  |  | ||||||
|  | //		return $this->CBSD::run('task owner=%s mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=#%s',array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname'])); | ||||||
|  | //		return $this->CBSD::run('task owner={$username} mode=new {cbsd_loc} removebase inter=0 stable=%s ver=%s arch=%s jname=#%s',array($this->_user_info['username'], $stable, $ver, $arch, $this->form['jname'])); | ||||||
|  | //		return $this->CBSD::run($remove_cmd); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	function ccmd_basesCompile(){ | 	function ccmd_basesCompile(){ | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| { | { | ||||||
|     "require": { |     "require": { | ||||||
|         "sentry/sdk": "^3.2" |         "sentry/sdk": "^3.3" | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ class Db { | |||||||
| 				break; | 				break; | ||||||
| 			case 'helper': | 			case 'helper': | ||||||
| 				if(is_array($database)){ | 				if(is_array($database)){ | ||||||
| 					///usr/jails/jails-system/cbsdpuppet1/helpers/redis.sqlite | 					//usr/jails/jails-system/cbsdpuppet1/helpers/redis.sqlite | ||||||
| 					$file_name=$this->_workdir.'/jails-system/'.$database['jname'].'/helpers/'.$database['helper'].".sqlite"; | 					$file_name=$this->_workdir.'/jails-system/'.$database['jname'].'/helpers/'.$database['helper'].".sqlite"; | ||||||
| 					$connect='sqlite:'.$file_name; | 					$connect='sqlite:'.$file_name; | ||||||
| 				} else { | 				} else { | ||||||
|   | |||||||
| @@ -176,7 +176,7 @@ class Forms | |||||||
|  |  | ||||||
| 	function getInputAutofill($arr) | 	function getInputAutofill($arr) | ||||||
| 	{ | 	{ | ||||||
| 		if(isset($arr['link'])){ | 		if(isset($arr['link']) && $arr['link']!=''){ | ||||||
| 			$id=$arr['link'];	//$arr['param'].'-'. | 			$id=$arr['link'];	//$arr['param'].'-'. | ||||||
| 			$tpl='<datalist id="'.$id.'">'; | 			$tpl='<datalist id="'.$id.'">'; | ||||||
| 			$opts = $this->fetch_from_db($arr['link']); | 			$opts = $this->fetch_from_db($arr['link']); | ||||||
|   | |||||||
| @@ -3,6 +3,8 @@ | |||||||
| $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 = ''; | ||||||
|  | $html_tpl = ''; | ||||||
|  |  | ||||||
|  |  | ||||||
| if($res !== false){ | if($res !== false){ | ||||||
| 	$nth = 0; | 	$nth = 0; | ||||||
| @@ -19,10 +21,12 @@ if($res !== false){ | |||||||
| 				'deltitle' => ' title="'.$this->translate('Delete').'"' | 				'deltitle' => ' title="'.$this->translate('Delete').'"' | ||||||
| 			]; | 			]; | ||||||
|  |  | ||||||
|  | 			$html_tpl=$hres[1]; | ||||||
|  |  | ||||||
| 			foreach($vars as $var => $val){ | 			foreach($vars as $var => $val){ | ||||||
| 				$html_tmp = str_replace('#'.$var.'#', $val, $hres[1]); | 				$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl); | ||||||
| 			} | 			} | ||||||
| 			$html .= $html_tmp; | 			$html .= $html_tpl; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,108 +1,97 @@ | |||||||
| <?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; |  | ||||||
| 		if(!empty($bases)) foreach($bases as $base) | foreach($nodes as $node){ | ||||||
| 		{ |  | ||||||
| 			$idle=1; | 	$db1 = new Db('base', $node['nodename']); | ||||||
| 			//print_r($node);exit; | 	if(!$db1->error){ | ||||||
| 			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)", []); | ||||||
| 				$idle=$this->check_locktime($node['ip']); | 		$num = $nth & 1; | ||||||
|  |  | ||||||
|  | 		foreach($bases as $base){ | ||||||
|  |  | ||||||
|  | 			Utils::clonos_syslog("bases a.json.php base loop: base id=". $base['idx']); | ||||||
|  | 			$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 = [ | ||||||
|  | 					'id' => $id, | ||||||
|  | 					'nth-num' => 'nth'.$num, | ||||||
|  | 					'node' => $node['nodename'], | ||||||
|  | 					'name' => $base['name'], | ||||||
|  | 					'platform' => $base['platform'], | ||||||
|  | 					'arch' => $base['arch'], | ||||||
|  | 					'targetarch' => $base['targetarch'], | ||||||
|  | 					'version' => $base['ver'], | ||||||
|  | 					'version1' => ($base['stable']==1) ? 'stable' : 'release', | ||||||
|  | 					'elf' => $base['elf'], | ||||||
|  | 					'date' => $base['date'], | ||||||
|  | 					'jstatus' => '', | ||||||
|  | 					'maintenance' => ($idle == 0) ? ' maintenance' : '', | ||||||
|  | 					'deltitle' => $this->translate('Delete') | ||||||
|  | 				]; | ||||||
|  |  | ||||||
|  | 				Utils::clonos_syslog("bases a.json.php base loop: hres != false: ". implode(",", $vars)); | ||||||
| 				$html_tpl=$hres[1]; | 				$html_tpl=$hres[1]; | ||||||
| 				$vars=array( |  | ||||||
| 					'id'=>$id, |  | ||||||
| 					'nth-num'=>'nth'.$num, |  | ||||||
| 					'node'=>$node['nodename'], |  | ||||||
| 					'name'=>$base['name'], |  | ||||||
| 					'platform'=>$base['platform'], |  | ||||||
| 					'arch'=>$base['arch'], |  | ||||||
| 					'targetarch'=>$base['targetarch'], |  | ||||||
| 					'version'=>$base['ver'], |  | ||||||
| 					'version1'=>($base['stable']==1)?'stable':'release', |  | ||||||
| 					'elf'=>$base['elf'], |  | ||||||
| 					'date'=>$base['date'], |  | ||||||
| 					'jstatus'=>'', |  | ||||||
| 					'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); | 					Utils::clonos_syslog("bases a.json.php replace [#".$var."#] by val: ".$val." hres = ". $hres[1]); | ||||||
| 				 | 					$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl); | ||||||
| 				$html.=$html_tpl; | //					$html .= $html_tpl; | ||||||
|  | 					Utils::clonos_syslog("bases a.json.php replace result: ".$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, |  | ||||||
| ); |  | ||||||
| @@ -67,8 +67,10 @@ foreach($nodes as $node){ | |||||||
| 					'vnc_port_status' => $vnc_port_status | 					'vnc_port_status' => $vnc_port_status | ||||||
| 				]; | 				]; | ||||||
|  |  | ||||||
|  | 				$html_tpl=$hres[1]; | ||||||
|  |  | ||||||
| 				foreach($vars as $var => $val){ | 				foreach($vars as $var => $val){ | ||||||
| 					$html_tpl = str_replace('#'.$var.'#', $val, $hres[1]); | 					$html_tpl = str_replace('#'.$var.'#', $val, $html_tpl); | ||||||
| 				} | 				} | ||||||
| 				if($node != 'local'){ | 				if($node != 'local'){ | ||||||
| 					$html_tpl = str_replace('<span class="icon-cog"></span>', '', $html_tpl); | 					$html_tpl = str_replace('<span class="icon-cog"></span>', '', $html_tpl); | ||||||
|   | |||||||
| @@ -53,3 +53,13 @@ $html.='<h1>Helper: '.$hash.'</h1>'.$res_html; | |||||||
| // Undefined property: ClonOS::$html in /usr/local/www/clonos/public/pages/instance_jail/helpers.php on line 49 | // Undefined property: ClonOS::$html in /usr/local/www/clonos/public/pages/instance_jail/helpers.php on line 49 | ||||||
| //return array('html'=>$this->html); | //return array('html'=>$this->html); | ||||||
| echo json_encode(array('html'=>$html,'func'=>'fillTab')); | echo json_encode(array('html'=>$html,'func'=>'fillTab')); | ||||||
|  |  | ||||||
|  | /* | ||||||
|  | $included_result_array=array( | ||||||
|  | 	'tbody'=>$html, | ||||||
|  | 	'error'=>false, | ||||||
|  | 	'func'=>'fillTable', | ||||||
|  | 	'id'=>'instanceslist', | ||||||
|  | ); | ||||||
|  | */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,8 +24,11 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){ | |||||||
| 	// https://www.php.net/manual/en/features.file-upload.php | 	// https://www.php.net/manual/en/features.file-upload.php | ||||||
| 	// Undefined | Multiple Files | $_FILES Corruption Attack | 	// Undefined | Multiple Files | $_FILES Corruption Attack | ||||||
| 	// If this request falls under any of them, treat it invalid. | 	// If this request falls under any of them, treat it invalid. | ||||||
| 	if (!isset($_FILES['file']['error']) || is_array($_FILES['file']['error'])) { | 	if ( | ||||||
| 		echo json_encode( array( 'status'=>'Upload Fail: An error occurred!')); | 		!isset($_FILES['file']['error']) || | ||||||
|  | 		is_array($_FILES['file']['error']) | ||||||
|  | 	) { | ||||||
|  | 		echo json_encode(array('status' => 'Upload Fail: An error occurred!';)); | ||||||
| 		exit; | 		exit; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 olevole
					olevole