refactoring wip

This commit is contained in:
olevole
2020-11-04 08:37:44 +00:00
parent 4e4a01749d
commit 3e47ff1bbd
17 changed files with 324 additions and 127 deletions

View File

@@ -187,81 +187,110 @@ class ClonOS {
} }
unset($_POST); unset($_POST);
// functions, running without parameters
$new_array=array();
$cfunc='ccmd_'.$this->mode; $cfunc='ccmd_'.$this->mode;
if(method_exists($this,$cfunc)) if(method_exists($this,$cfunc))
{ {
$ccmd_res=array(); $ccmd_res=array();
$ccmd_res=$this->$cfunc(); $ccmd_res=$this->$cfunc();
//print_r($ccmd_res);
//return; if(is_array($ccmd_res))
$new_array=array_merge($this->sys_vars,$ccmd_res);
else
{
echo json_encode($ccmd_res);
return;
}
echo json_encode($new_array);
return;
} }
$included_result_array='';
switch($this->mode){ switch($this->mode){
case 'login': echo json_encode($this->login()); return; //case 'login': echo json_encode($this->login()); return;
case 'getTasksStatus': echo json_encode($this->_getTasksStatus($this->form['jsonObj'])); return; case 'getTasksStatus': echo json_encode($this->_getTasksStatus($this->form['jsonObj'])); return;
case 'getJsonPage': if(file_exists($this->json_name)) include($this->json_name); else echo '{}'; return;
case 'freejname': echo json_encode($this->getFreeJname()); break; /*
case '_getJsonPage':
if(file_exists($this->json_name))
{
include($this->json_name);
if(is_array($included_result_array))
{
$new_array=array_merge($this->sys_vars,$included_result_array);
echo json_encode($new_array);
return;
} else echo '{}';
} else echo '{}'; return;
*/
//case 'freejname': echo json_encode($this->getFreeJname()); break;
case 'helpersAdd': echo json_encode($this->helpersAdd($this->mode)); return; case 'helpersAdd': echo json_encode($this->helpersAdd($this->mode)); return;
case 'addHelperGroup': echo json_encode($this->addHelperGroup($this->mode)); return; case 'addHelperGroup': echo json_encode($this->addHelperGroup($this->mode)); return;
case 'addJailHelperGroup': echo json_encode($this->addJailHelperGroup()); return; //case 'addJailHelperGroup': echo json_encode($this->addJailHelperGroup()); return;
case 'deleteJailHelperGroup': echo json_encode($this->deleteJailHelperGroup()); return; //case 'deleteJailHelperGroup': echo json_encode($this->deleteJailHelperGroup()); return;
case 'deleteHelperGroup': echo json_encode($this->deleteHelperGroup($this->mode)); return; case 'deleteHelperGroup': echo json_encode($this->deleteHelperGroup($this->mode)); return;
case 'jailRestart': echo json_encode($this->jailRestart()); return; //case 'jailRestart': echo json_encode($this->jailRestart()); return;
case 'jailStart': echo json_encode($this->jailStart()); return; //case 'jailStart': echo json_encode($this->jailStart()); return;
case 'jailStop': echo json_encode($this->jailStop()); return; //case 'jailStop': echo json_encode($this->jailStop()); return;
case 'jailRemove': echo json_encode($this->jailRemove()); return; //case 'jailRemove': echo json_encode($this->jailRemove()); return;
case 'saveJailHelperValues': echo json_encode($this->saveJailHelperValues()); return; //case 'saveJailHelperValues': echo json_encode($this->saveJailHelperValues()); return;
case 'saveHelperValues': $redirect='/jailscontainers/'; case 'saveHelperValues': $redirect='/jailscontainers/';
case 'jailAdd': if(!isset($redirect)) $redirect=''; echo json_encode($this->jailAdd($redirect)); return; case 'jailAdd': if(!isset($redirect)) $redirect=''; echo json_encode($this->jailAdd($redirect)); return;
case 'jailClone': echo json_encode($this->jailClone()); return; //case 'jailClone': echo json_encode($this->jailClone()); return;
case 'jailRename': echo json_encode($this->jailRename()); return; //case 'jailRename': echo json_encode($this->jailRename()); return;
case 'bhyveRename': echo json_encode($this->bhyveRename()); return; //case 'bhyveRename': echo json_encode($this->bhyveRename()); return;
case 'jailEdit': echo json_encode($this->jailEdit()); return; //case 'jailEdit': echo json_encode($this->jailEdit()); return;
case 'jailEditVars': echo json_encode($this->jailEditVars()); return; //case 'jailEditVars': echo json_encode($this->jailEditVars()); return;
case 'jailCloneVars': echo json_encode($this->jailCloneVars()); return; //case 'jailCloneVars': echo json_encode($this->jailCloneVars()); return;
case 'jailRenameVars': echo json_encode($this->jailRenameVars()); return; //case 'jailRenameVars': echo json_encode($this->jailRenameVars()); return;
case 'bhyveRenameVars': echo json_encode($this->bhyveRenameVars()); return; //case 'bhyveRenameVars': echo json_encode($this->bhyveRenameVars()); return;
case 'bhyveRestart': echo json_encode($this->bhyveRestart()); return; //case 'bhyveRestart': echo json_encode($this->bhyveRestart()); return;
case 'bhyveStart': echo json_encode($this->bhyveStart()); return; //case 'bhyveStart': echo json_encode($this->bhyveStart()); return;
case 'bhyveStop': echo json_encode($this->bhyveStop()); return; //case 'bhyveStop': echo json_encode($this->bhyveStop()); return;
case 'bhyveAdd': echo json_encode($this->bhyveAdd()); return; //case 'bhyveAdd': echo json_encode($this->bhyveAdd()); return;
case 'bhyveRemove': echo json_encode($this->bhyveRemove()); return; //case 'bhyveRemove': echo json_encode($this->bhyveRemove()); return;
case 'bhyveEdit': echo json_encode($this->bhyveEdit()); return; //case 'bhyveEdit': echo json_encode($this->bhyveEdit()); return;
case 'bhyveEditVars': echo json_encode($this->bhyveEditVars()); return; //case 'bhyveEditVars': echo json_encode($this->bhyveEditVars()); return;
case 'bhyveObtain': echo json_encode($this->bhyveObtain()); return; //case 'bhyveObtain': echo json_encode($this->bhyveObtain()); return;
case 'bhyveClone': echo json_encode($this->bhyveClone()); return; //case 'bhyveClone': echo json_encode($this->bhyveClone()); return;
case 'authkeyAdd': echo json_encode($this->authkeyAdd()); return; //case 'authkeyAdd': echo json_encode($this->authkeyAdd()); return;
case 'authkeyRemove': echo json_encode($this->authkeyRemove()); return; //case 'authkeyRemove': echo json_encode($this->()); return;
case 'vpnetAdd': echo json_encode($this->vpnetAdd()); return; //case 'vpnetAdd': echo json_encode($this->vpnetAdd()); return;
case 'vpnetRemove': echo json_encode($this->vpnetRemove()); return; //case 'vpnetRemove': echo json_encode($this->vpnetRemove()); return;
case 'updateBhyveISO': echo json_encode($this->updateBhyveISO()); return; //case 'updateBhyveISO': echo json_encode($this->updateBhyveISO()); return;
/*
case 'mediaAdd': case 'mediaAdd':
//echo json_encode($this->mediaAdd()); //echo json_encode($this->mediaAdd());
return; return;
case 'mediaRemove': echo json_encode($this->mediaRemove()); return; */
case 'logLoad': echo json_encode($this->logLoad()); return; //case 'mediaRemove': echo json_encode($this->mediaRemove()); return;
case 'logFlush': echo json_encode($this->logFlush()); return; //case 'logLoad': echo json_encode($this->logLoad()); return;
case 'basesCompile': echo json_encode($this->basesCompile()); return; //case 'logFlush': echo json_encode($this->logFlush()); return;
case 'repoCompile': echo json_encode($this->repoCompile()); return; //case 'basesCompile': echo json_encode($this->basesCompile()); return;
case 'srcUpdate': echo json_encode($this->srcUpdate()); return; //case 'repoCompile': echo json_encode($this->repoCompile()); return;
case 'srcRemove': echo json_encode($this->srcRemove()); return; //case 'srcUpdate': echo json_encode($this->srcUpdate()); return;
case 'baseRemove': echo json_encode($this->baseRemove()); return; //case 'srcRemove': echo json_encode($this->srcRemove()); return;
case 'usersAdd': echo json_encode($this->usersAdd()); return; //case 'baseRemove': echo json_encode($this->baseRemove()); return;
case 'usersEdit': echo json_encode($this->usersEdit()); return; //case 'usersAdd': echo json_encode($this->usersAdd()); return;
case 'userRemove': echo json_encode($this->userRemove()); return; //case 'usersEdit': echo json_encode($this->usersEdit()); return;
case 'userGetInfo': echo json_encode($this->userGetInfo()); return; //case 'userRemove': echo json_encode($this->userRemove()); return;
case 'userEditInfo': echo json_encode($this->userEditInfo()); return; //case 'userGetInfo': echo json_encode($this->userGetInfo()); return;
case 'vmTemplateAdd': echo json_encode($this->vmTemplateAdd()); return; //case 'userEditInfo': echo json_encode($this->userEditInfo()); return;
case 'vmTemplateEditInfo': echo json_encode($this->vmTemplateEditInfo()); return; //case 'vmTemplateAdd': echo json_encode($this->vmTemplateAdd()); return;
case 'vmTemplateEdit': echo json_encode($this->vmTemplateEdit()); return; //case 'vmTemplateEditInfo': echo json_encode($this->vmTemplateEditInfo()); return;
case 'vmTemplateRemove': echo json_encode($this->vmTemplateRemove()); return; //case 'vmTemplateEdit': echo json_encode($this->vmTemplateEdit()); return;
case 'getImportedImageInfo': echo json_encode($this->getImportedImageInfo()); return; //case 'vmTemplateRemove': echo json_encode($this->vmTemplateRemove()); return;
case 'imageImport': echo json_encode($this->imageImport()); return; //case 'getImportedImageInfo': echo json_encode($this->getImportedImageInfo()); return;
case 'imageExport': echo json_encode($this->imageExport()); return; //case 'imageImport': echo json_encode($this->imageImport()); return;
case 'imageRemove': echo json_encode($this->imageRemove()); return; //case 'imageExport': echo json_encode($this->imageExport()); return;
case 'getSummaryInfo': echo json_encode($this->getSummaryInfo()); return; //case 'imageRemove': echo json_encode($this->imageRemove()); return;
//case 'getSummaryInfo': echo json_encode($this->getSummaryInfo()); return;
/* case 'saveHelperValues': /* case 'saveHelperValues':
echo json_encode($this->saveHelperValues()); echo json_encode($this->saveHelperValues());
@@ -271,10 +300,25 @@ class ClonOS {
} }
} }
function ccmd_login(){ function ccmd_getJsonPage()
return array('hi'=>'hello'); {
$included_result_array=false;
if(file_exists($this->json_name))
{
include($this->json_name);
if(is_array($included_result_array))
{
$new_array=array_merge($this->sys_vars,$included_result_array);
echo json_encode($new_array);
exit;
}
}
echo '{}';
exit;
} }
function login(){
function ccmd_login(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
return $this->userRegisterCheck($form); return $this->userRegisterCheck($form);
@@ -563,7 +607,7 @@ class ClonOS {
return $obj; return $obj;
} }
function jailRename() { function ccmd_jailRename() {
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$host_hostname=$form['host_hostname']; $host_hostname=$form['host_hostname'];
@@ -587,7 +631,7 @@ class ClonOS {
return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode); return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode);
} }
function jailClone() { function ccmd_jailClone() {
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
@@ -676,7 +720,7 @@ class ClonOS {
return $arr; return $arr;
} }
function saveJailHelperValues(){ function ccmd_saveJailHelperValues(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
@@ -869,7 +913,7 @@ class ClonOS {
return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'mode'=>$this->mode,'redirect'=>$redirect,'db_path'=>$db_path); //,'html'=>$html return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'mode'=>$this->mode,'redirect'=>$redirect,'db_path'=>$db_path); //,'html'=>$html
} }
function jailRenameVars(){ function ccmd_jailRenameVars(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!');
@@ -902,7 +946,7 @@ class ClonOS {
return $res; return $res;
} }
function jailCloneVars(){ function ccmd_jailCloneVars(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!');
@@ -934,7 +978,7 @@ class ClonOS {
return $res; return $res;
} }
function jailEditVars(){ function ccmd_jailEditVars(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!');
@@ -959,7 +1003,7 @@ class ClonOS {
$res['jail_id']=$form['jail_id']; $res['jail_id']=$form['jail_id'];
return $res; return $res;
} }
function jailEdit(){ function ccmd_jailEdit(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$str=array(); $str=array();
@@ -980,7 +1024,7 @@ class ClonOS {
return $res; return $res;
} }
function jailStart(){ //$name function ccmd_jailStart(){ //$name
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
@@ -992,7 +1036,7 @@ class ClonOS {
//.' cbsd_queue_name=/clonos/'.$cbsd_queue_name.'/'); // autoflush=2 //.' cbsd_queue_name=/clonos/'.$cbsd_queue_name.'/'); // autoflush=2
return $res; return $res;
} }
function jailStop(){ //$name function ccmd_jailStop(){ //$name
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1004,7 +1048,8 @@ class ClonOS {
return $res; return $res;
} }
function jailRestart(){ //$name //function jailRestart(){ //$name
function ccmd_jailRestart(){ //$name
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1014,7 +1059,7 @@ class ClonOS {
return $res; return $res;
} }
function jailRemove(){ //$name function ccmd_jailRemove(){ //$name
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1024,7 +1069,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveClone(){ function ccmd_bhyveClone(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
@@ -1109,7 +1154,7 @@ class ClonOS {
return array('html'=>$html); return array('html'=>$html);
} }
function bhyveEditVars(){ function ccmd_bhyveEditVars(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!');
@@ -1137,10 +1182,10 @@ class ClonOS {
$res['error']=false; $res['error']=false;
$res['dialog']=$form['dialog']; $res['dialog']=$form['dialog'];
$res['jail_id']=$form['jail_id']; $res['jail_id']=$form['jail_id'];
$res['iso_list']=$this->updateBhyveISO($form['jail_id']); $res['iso_list']=$this->ccmd_updateBhyveISO($form['jail_id']);
return $res; return $res;
} }
function bhyveRename(){ function ccmd_bhyveRename(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$old_name=$form['oldJail']; $old_name=$form['oldJail'];
@@ -1160,7 +1205,7 @@ class ClonOS {
return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode); return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode);
} }
function bhyveRenameVars(){ function ccmd_bhyveRenameVars(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!');
@@ -1188,7 +1233,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveEdit(){ function ccmd_bhyveEdit(){
$form=$this->form; $form=$this->form;
$str=array(); $str=array();
@@ -1240,7 +1285,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveAdd(){ function ccmd_bhyveAdd(){
$form=$this->form; $form=$this->form;
@@ -1353,7 +1398,7 @@ class ClonOS {
return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode); return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode);
} }
function bhyveObtain(){ function ccmd_bhyveObtain(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
@@ -1381,6 +1426,7 @@ class ClonOS {
} }
$key_name='/usr/home/olevole/.ssh/authorized_keys'; $key_name='/usr/home/olevole/.ssh/authorized_keys';
if(!isset($form['vm_authkey'])) $form['vm_authkey']=0;
$key_id=(int)$form['vm_authkey']; $key_id=(int)$form['vm_authkey'];
$db=new Db('base','authkey'); $db=new Db('base','authkey');
@@ -1390,6 +1436,7 @@ class ClonOS {
//if($nres['name']!==false) $key_name=$nres['name']; //if($nres['name']!==false) $key_name=$nres['name'];
$nres=$db->selectAssoc('SELECT authkey FROM authkey WHERE idx='.$key_id); $nres=$db->selectAssoc('SELECT authkey FROM authkey WHERE idx='.$key_id);
if($nres['authkey']!==false) $authkey=$nres['authkey']; if($nres['authkey']!==false) $authkey=$nres['authkey'];
//var_dump($nres);exit;
$user_pw=(!empty($form['user_password']))?' ci_user_pw_user='.$form['user_password'].' ':''; $user_pw=(!empty($form['user_password']))?' ci_user_pw_user='.$form['user_password'].' ':'';
@@ -1437,7 +1484,7 @@ class ClonOS {
return array('errorMessage'=>$err,'jail_id'=>$form['vm_name'],'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode); return array('errorMessage'=>$err,'jail_id'=>$form['vm_name'],'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode);
} }
function bhyveStart(){ function ccmd_bhyveStart(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1447,7 +1494,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveStop(){ function ccmd_bhyveStop(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1457,7 +1504,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveRestart(){ function ccmd_bhyveRestart(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1467,7 +1514,7 @@ class ClonOS {
return $res; return $res;
} }
function bhyveRemove(){ // $name function ccmd_bhyveRemove(){ // $name
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$name=$form['jname']; $name=$form['jname'];
@@ -1477,7 +1524,7 @@ class ClonOS {
return $res; return $res;
} }
function authkeyAdd(){ function ccmd_authkeyAdd(){
$form=$this->form; $form=$this->form;
@@ -1508,7 +1555,7 @@ class ClonOS {
return array('keyname'=>$form['keyname'],'html'=>$html); return array('keyname'=>$form['keyname'],'html'=>$html);
} }
function authkeyRemove(){ function ccmd_authkeyRemove(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$db=new Db('base','authkey'); $db=new Db('base','authkey');
@@ -1520,7 +1567,7 @@ class ClonOS {
return array('error'=>false,'auth_id'=>$form['auth_id']); return array('error'=>false,'auth_id'=>$form['auth_id']);
} }
function vpnetAdd(){ function ccmd_vpnetAdd(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
@@ -1551,7 +1598,7 @@ class ClonOS {
return array('netname'=>$form['netname'],'html'=>$html); return array('netname'=>$form['netname'],'html'=>$html);
} }
function vpnetRemove(){ function ccmd_vpnetRemove(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$db=new Db('base','vpnet'); $db=new Db('base','vpnet');
@@ -1563,7 +1610,7 @@ class ClonOS {
return array('error'=>false,'vpnet_id'=>$form['vpnet_id']); return array('error'=>false,'vpnet_id'=>$form['vpnet_id']);
} }
function mediaRemove(){ function ccmd_mediaRemove(){
$form=$this->form; $form=$this->form;
$db=new Db('base','storage_media'); $db=new Db('base','storage_media');
if(!$db->isConnected()) return array('error'=>true,'res'=>'Database error'); if(!$db->isConnected()) return array('error'=>true,'res'=>'Database error');
@@ -1592,7 +1639,7 @@ class ClonOS {
return $arr; return $arr;
} }
function srcRemove(){ function ccmd_srcRemove(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$ver=$form['jname']; $ver=$form['jname'];
@@ -1604,7 +1651,7 @@ class ClonOS {
return $res; return $res;
} }
function srcUpdate(){ function ccmd_srcUpdate(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
$ver=$form['jname']; $ver=$form['jname'];
@@ -1654,7 +1701,7 @@ class ClonOS {
return array('html'=>$html,'arr'=>$res); return array('html'=>$html,'arr'=>$res);
} }
function baseRemove(){ //$id function ccmd_baseRemove(){ //$id
//$id=str_replace('base','',$id); //$id=str_replace('base','',$id);
//base10.3-amd64-0 //base10.3-amd64-0
$form=$this->form; $form=$this->form;
@@ -1673,7 +1720,7 @@ class ClonOS {
return $res; return $res;
} }
function basesCompile(){ function ccmd_basesCompile(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
if(!isset($form['sources']) || !is_numeric($form['sources'])) return array('error'=>true,'errorMessage'=>'Wrong OS type selected!'); if(!isset($form['sources']) || !is_numeric($form['sources'])) return array('error'=>true,'errorMessage'=>'Wrong OS type selected!');
@@ -1761,7 +1808,7 @@ class ClonOS {
return array('html'=>$html,'arr'=>$res); return array('html'=>$html,'arr'=>$res);
} }
function repoCompile(){ function ccmd_repoCompile(){
$form=$this->form; $form=$this->form;
$username=$this->_user_info['username']; $username=$this->_user_info['username'];
if(!isset($form['version']) || !is_numeric($form['version'])) return array('error'=>true,'errorMessage'=>'Wrong OS type input!'); if(!isset($form['version']) || !is_numeric($form['version'])) return array('error'=>true,'errorMessage'=>'Wrong OS type input!');
@@ -1815,7 +1862,7 @@ class ClonOS {
return array('errorMessage'=>'','jail_id'=>'base'.$bid,'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode,'txt_status'=>$this->translate('Fetching')); return array('errorMessage'=>'','jail_id'=>'base'.$bid,'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode,'txt_status'=>$this->translate('Fetching'));
} }
function logLoad(){ function ccmd_logLoad(){
$form=$this->_vars['form_data']; $form=$this->_vars['form_data'];
$log_id=$form['log_id']; $log_id=$form['log_id'];
if(!is_numeric($log_id)) return array('error'=>'Log ID must be a number'); if(!is_numeric($log_id)) return array('error'=>'Log ID must be a number');
@@ -1846,7 +1893,7 @@ class ClonOS {
return array('error'=>'Log file is not exists!'); return array('error'=>'Log file is not exists!');
} }
function logFlush(){ function ccmd_logFlush(){
$res=$this->cbsd_cmd('task mode=flushall'); $res=$this->cbsd_cmd('task mode=flushall');
return $res; return $res;
} }
@@ -1885,7 +1932,8 @@ class ClonOS {
return array('error'=>false); return array('error'=>false);
} }
function addJailHelperGroup(){ //function addJailHelperGroup(){
function ccmd_addJailHelperGroup(){
// $form=$this->form; // $form=$this->form;
if($this->uri_chunks[0]!='jailscontainers' || empty($this->uri_chunks[1]) || empty($this->url_hash)) return array('error'=>true,'errorMessage'=>'Bad url!'); if($this->uri_chunks[0]!='jailscontainers' || empty($this->uri_chunks[1]) || empty($this->url_hash)) return array('error'=>true,'errorMessage'=>'Bad url!');
$jail_id=$this->uri_chunks[1]; $jail_id=$this->uri_chunks[1];
@@ -1941,7 +1989,8 @@ class ClonOS {
return array('db_path'=>$db_path,'html'=>$res['html']); return array('db_path'=>$db_path,'html'=>$res['html']);
} }
function deleteJailHelperGroup(){ //function deleteJailHelperGroup(){
function ccmd_deleteJailHelperGroup(){
$form=$this->form; $form=$this->form;
if(!isset($this->uri_chunks[1]) || !isset($this->url_hash)) return array('error'=>true,'errorMessage'=>'Bad url!'); if(!isset($this->uri_chunks[1]) || !isset($this->url_hash)) return array('error'=>true,'errorMessage'=>'Bad url!');
@@ -2007,7 +2056,8 @@ class ClonOS {
exit; exit;
} }
function getFreeJname($in_helper=false,$type='jail'){ //function getFreeJname($in_helper=false,$type='jail'){
function ccmd_getFreeJname($in_helper=false,$type='jail'){
$arr=array(); $arr=array();
$add_cmd=($in_helper)?' default_jailname='.$this->url_hash:''; $add_cmd=($in_helper)?' default_jailname='.$this->url_hash:'';
$add_cmd1=' default_jailname='.$type; $add_cmd1=' default_jailname='.$type;
@@ -2103,7 +2153,7 @@ class ClonOS {
return $html; return $html;
} }
function updateBhyveISO($iso=''){ function ccmd_updateBhyveISO($iso=''){
$db=new Db('base','storage_media'); $db=new Db('base','storage_media');
$res=$db->select('SELECT * FROM media WHERE type="iso"'); $res=$db->select('SELECT * FROM media WHERE type="iso"');
if($res===false || empty($res)) return array(); //array('error'=>true,'error_message'=>'Profile ISO is not find!'); if($res===false || empty($res)) return array(); //array('error'=>true,'error_message'=>'Profile ISO is not find!');
@@ -2140,7 +2190,7 @@ class ClonOS {
return $html; return $html;
} }
function usersAdd(){ function ccmd_usersAdd(){
$form=$this->form; $form=$this->form;
$res=$this->userRegister($form); $res=$this->userRegister($form);
@@ -2153,7 +2203,7 @@ class ClonOS {
return array('form'=>$form); return array('form'=>$form);
} }
function usersEdit(){ function ccmd_usersEdit(){
$form=$this->form; $form=$this->form;
if(!isset($form['user_id']) || !is_numeric($form['user_id']) || $form['user_id']<1) if(!isset($form['user_id']) || !is_numeric($form['user_id']) || $form['user_id']<1)
@@ -2299,7 +2349,7 @@ class ClonOS {
return array('error'=>true); return array('error'=>true);
} }
function userRemove(){ function ccmd_userRemove(){
$form=$this->form; $form=$this->form;
$id=$form['user_id']; $id=$form['user_id'];
@@ -2313,7 +2363,7 @@ class ClonOS {
} }
} }
function userEditInfo(){ function ccmd_userEditInfo(){
$form=$this->form; $form=$this->form;
if(!isset($form['user_id'])) return array('error'=>true,'error_message'=>'incorrect data!'); if(!isset($form['user_id'])) return array('error'=>true,'error_message'=>'incorrect data!');
@@ -2333,7 +2383,7 @@ class ClonOS {
} }
function userGetInfo(){ function ccmd_userGetInfo(){
$db=new Db('clonos'); $db=new Db('clonos');
if(!$db->isConnected()) return array('DB connection error!'); if(!$db->isConnected()) return array('DB connection error!');
@@ -2345,7 +2395,7 @@ class ClonOS {
return $this->_user_info['username']; return $this->_user_info['username'];
} }
function vmTemplateAdd(){ function ccmd_vmTemplateAdd(){
$form=$this->form; $form=$this->form;
$db=new Db('base','local'); $db=new Db('base','local');
@@ -2368,7 +2418,7 @@ class ClonOS {
return $this->messageError('sql error!',$res); return $this->messageError('sql error!',$res);
} }
function vmTemplateEditInfo(){ function ccmd_vmTemplateEditInfo(){
$form=$this->form; $form=$this->form;
if(!isset($form['template_id'])) return $this->messageError('incorrect data!'); if(!isset($form['template_id'])) return $this->messageError('incorrect data!');
@@ -2381,7 +2431,7 @@ class ClonOS {
return $this->messageSuccess(array('vars'=>$res,'template_id'=>(int)$tpl_id)); return $this->messageSuccess(array('vars'=>$res,'template_id'=>(int)$tpl_id));
} }
function vmTemplateEdit(){ function ccmd_vmTemplateEdit(){
$form=$this->form; $form=$this->form;
$id=$form['template_id']; $id=$form['template_id'];
@@ -2408,7 +2458,7 @@ class ClonOS {
} }
function vmTemplateRemove(){ function ccmd_vmTemplateRemove(){
$form=$this->form; $form=$this->form;
$id=$form['template_id']; $id=$form['template_id'];
@@ -2451,7 +2501,7 @@ class ClonOS {
return $files; return $files;
} }
function getImportedImageInfo(){ function ccmd_getImportedImageInfo(){
$form=$this->form; $form=$this->form;
$name=$form['id']; $name=$form['id'];
$info=$this->getImageInfo($name); $info=$this->getImageInfo($name);
@@ -2494,7 +2544,7 @@ class ClonOS {
$jail=$db->selectAssoc("SELECT jname FROM jails WHERE jname='{$db->escape($jname)}'"); $jail=$db->selectAssoc("SELECT jname FROM jails WHERE jname='{$db->escape($jname)}'");
if($jname==$jail['jname']){ if($jname==$jail['jname']){
$jres=$this->getFreeJname(false,$type); $jres=$this->ccmd_getFreeJname(false,$type);
if($jres['error']) return $this->messageError('Something wrong...'); if($jres['error']) return $this->messageError('Something wrong...');
$jname=$jres['freejname']; $jname=$jres['freejname'];
$name_comment='* '.$this->translate('Since imported name already exist, we are change it'); $name_comment='* '.$this->translate('Since imported name already exist, we are change it');
@@ -2513,7 +2563,7 @@ class ClonOS {
return $val; return $val;
} }
function imageExport(){ function ccmd_imageExport(){
// cbsd jexport jname=XXX dstdir=<path_to_imported_dir> // cbsd jexport jname=XXX dstdir=<path_to_imported_dir>
$form=$this->form; $form=$this->form;
$jname=$form['id']; $jname=$form['id'];
@@ -2525,7 +2575,7 @@ class ClonOS {
return $res; return $res;
} }
function imageImport(){ function ccmd_imageImport(){
$form=$this->form; $form=$this->form;
$file_id=$form['file_id']; $file_id=$form['file_id'];
@@ -2551,7 +2601,7 @@ class ClonOS {
return $res; return $res;
} }
function imageRemove(){ function ccmd_imageRemove(){
$form=$this->form; $form=$this->form;
$cmd='cbsd imgremove path='.$this->media_import.' img='.$form['jname']; $cmd='cbsd imgremove path='.$this->media_import.' img='.$form['jname'];
@@ -2561,7 +2611,7 @@ class ClonOS {
return $res; return $res;
} }
function getSummaryInfo(){ function ccmd_getSummaryInfo(){
$form=$this->form; $form=$this->form;
if(!isset($form['mode'])) $form['mode']=''; if(!isset($form['mode'])) $form['mode']='';
$mode=$form['mode']; $mode=$form['mode'];

View File

@@ -843,7 +843,8 @@ var clonos={
}, },
getFreeJname:function() getFreeJname:function()
{ {
this.loadData('freejname',$.proxy(this.onGetFreeJname,this)); //this.loadData('freejname',$.proxy(this.onGetFreeJname,this));
this.loadData('getFreeJname',$.proxy(this.onGetFreeJname,this));
}, },
onGetFreeJname:function(data) onGetFreeJname:function(data)
{ {
@@ -902,7 +903,7 @@ var clonos={
} }
$.post(path,posts, $.post(path,posts,
$.proxy(function(data){this.onLoadDataAuthorize(return_func,data);$('.spinner').hide();},this) //return_func(data) $.proxy(function(data){this.onLoadDataAuthorize(return_func,data);$('.spinner').hide();},this) //return_func(data)
); ).fail($.proxy(function(data){this.onErrorLoadData(return_func,data)},this));
}, },
onLoadDataAuthorize:function(return_func,data) onLoadDataAuthorize:function(return_func,data)
{ {
@@ -916,8 +917,13 @@ var clonos={
{ {
this.authorized=false; this.authorized=false;
this.loginFadeIn(); this.loginFadeIn();
this.clearPageInfo();
return; return;
} }
if(typeof data['authorized']!='undefined')
{
this.authorized=data.authorized;
}
if(typeof data.error!='undefined') if(typeof data.error!='undefined')
{ {
@@ -938,6 +944,11 @@ var clonos={
return_func(data); return_func(data);
}, },
onErrorLoadData:function(return_func,data)
{
var msg='Sorry, but the system detected an error:\n\n* '+data.status+' '+data.statusText+' *\n\nWe think You need to contact your system administrator. Check PHP log file.';
alert(msg);
},
/* loadData1:function() /* loadData1:function()
{ {
@@ -1651,7 +1662,7 @@ var clonos={
bodyClick:function(event) bodyClick:function(event)
{ {
//debugger; //debugger;
//if(!this.authorized) location.reload(); if(!this.authorized) {location.reload();return;}
var target=event.target; var target=event.target;
if($(target).parents('form').length>0) if($(target).parents('form').length>0)
{ {
@@ -2135,6 +2146,13 @@ var clonos={
$('#user-login').html('guest'); $('#user-login').html('guest');
this.loginFadeIn(); this.loginFadeIn();
this.dataReload();
},
clearPageInfo:function()
{
$('.tsimple tbody').empty();
//$('#cdown #cinfo .left').html('');
$('div.main').removeClass('asplit');
}, },
ddmenu_interval:null, ddmenu_interval:null,

View File

@@ -29,11 +29,18 @@ if($res!==false)
$html.=$html_tmp; $html.=$html_tmp;
} }
} }
/*
echo json_encode(array( echo json_encode(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

@@ -88,7 +88,7 @@ if($hres!==false)
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( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -96,4 +96,13 @@ echo json_encode(array(
'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

@@ -123,6 +123,7 @@ $protected=array(
) )
); );
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -132,3 +133,14 @@ echo json_encode(array(
'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

@@ -91,6 +91,7 @@ function replaceVars($tpl,$vars)
return $tpl; return $tpl;
} }
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -98,3 +99,12 @@ echo json_encode(array(
'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

@@ -85,9 +85,18 @@ if($res['retval']==0)
$html=str_replace(array("\n","\r","\t"),'',$html); $html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
'func'=>'fillTable', 'func'=>'fillTable',
'id'=>'instanceslist', 'id'=>'instanceslist',
)); ));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'instanceslist',
);

View File

@@ -148,6 +148,7 @@ $protected=array(
) )
); );
/*
echo json_encode(array( echo json_encode(array(
// 'thead'=>$thead, // 'thead'=>$thead,
'tbody'=>$html, 'tbody'=>$html,
@@ -158,3 +159,13 @@ echo json_encode(array(
'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

@@ -74,6 +74,7 @@ if(empty($hash))
$html=str_replace(array("\n","\r","\t"),'',$html); $html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -81,12 +82,25 @@ if(empty($hash))
'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',array('jname'=>$jail_name,'helper'=>$hash));
if($db->error) {echo json_encode(array('error'=>true,'errorMessage'=>'No helper database!'));return;} if($db->error)
{
//echo json_encode(array('error'=>true,'errorMessage'=>'No helper database!'));
$included_result_array=array('error'=>true,'errorMessage'=>'No helper database!');
return;
}
$db_path=$db->getFileName(); $db_path=$db->getFileName();
$form=new Forms($jail_name,$hash,$db_path); $form=new Forms($jail_name,$hash,$db_path);
@@ -95,4 +109,8 @@ if(empty($hash))
} }
echo json_encode(array('html'=>$res['html'],'func'=>'fillTab')); //,'currents'=>$res['currents'] //echo json_encode(array('html'=>$res['html'],'func'=>'fillTab')); //,'currents'=>$res['currents']
$included_result_array=array(
'html'=>$res['html'],
'func'=>'fillTab'
);

View File

@@ -30,11 +30,19 @@ if($res!==false)
$html.=$html_tmp; $html.=$html_tmp;
} }
} }
/*
echo json_encode(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,3 +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();

View File

@@ -34,7 +34,8 @@ if(!empty($nodenames))foreach($nodenames as $name)
$ndb=new Db('base',trim($name)); $ndb=new Db('base',trim($name));
if($ndb===false) if($ndb===false)
{ {
echo json_encode(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;
} }
@@ -57,4 +58,5 @@ if($res_array['average']>0)
$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); //echo json_encode($res_array);
$included_result_array=$res_array;

View File

@@ -85,6 +85,7 @@ if($hres!==false)
$html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); $html_tpl=str_replace('#'.$var.'#',$val,$html_tpl);
} }
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -92,4 +93,13 @@ echo json_encode(array(
'id'=>'srcslist', 'id'=>'srcslist',
'tasks'=>$tasks, 'tasks'=>$tasks,
'template'=>$html_tpl, 'template'=>$html_tpl,
)); ));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'srcslist',
'tasks'=>$tasks,
'template'=>$html_tpl,
);

View File

@@ -60,10 +60,18 @@ if($res!==false)
} }
} }
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
'func'=>'fillTable', 'func'=>'fillTable',
'id'=>'taskloglist', 'id'=>'taskloglist',
)); ));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'taskloglist',
);
} }

View File

@@ -45,6 +45,7 @@ if(!empty($res))foreach($res as $r)
$html=str_replace(array("\n","\r","\t"),'',$html); $html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, 'tbody'=>$html,
'error'=>false, 'error'=>false,
@@ -54,3 +55,10 @@ echo json_encode(array(
//'template'=>$html_tpl_1, //'template'=>$html_tpl_1,
//'protected'=>$protected, //'protected'=>$protected,
)); ));
*/
$included_result_array=array(
'tbody'=>$html,
'error'=>false,
'func'=>'fillTable',
'id'=>'userslist',
);

View File

@@ -33,9 +33,17 @@ if(!empty($res))foreach($res as $r)
$html=str_replace(array("\n","\r","\t"),'',$html); $html=str_replace(array("\n","\r","\t"),'',$html);
/*
echo json_encode(array( echo json_encode(array(
'tbody'=>$html, '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

@@ -30,10 +30,18 @@ if($res!==false)
} }
} }
/*
echo json_encode(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',
);
} }