diff --git a/php/clonos.php b/php/clonos.php index fa87603f..fdc67c90 100644 --- a/php/clonos.php +++ b/php/clonos.php @@ -187,81 +187,110 @@ class ClonOS { } unset($_POST); + + // functions, running without parameters + $new_array=array(); $cfunc='ccmd_'.$this->mode; if(method_exists($this,$cfunc)) { $ccmd_res=array(); $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){ - 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 '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 'addHelperGroup': echo json_encode($this->addHelperGroup($this->mode)); return; - case 'addJailHelperGroup': echo json_encode($this->addJailHelperGroup()); return; - case 'deleteJailHelperGroup': echo json_encode($this->deleteJailHelperGroup()); return; + //case 'addJailHelperGroup': echo json_encode($this->addJailHelperGroup()); return; + //case 'deleteJailHelperGroup': echo json_encode($this->deleteJailHelperGroup()); return; case 'deleteHelperGroup': echo json_encode($this->deleteHelperGroup($this->mode)); return; - case 'jailRestart': echo json_encode($this->jailRestart()); return; - case 'jailStart': echo json_encode($this->jailStart()); return; - case 'jailStop': echo json_encode($this->jailStop()); return; - case 'jailRemove': echo json_encode($this->jailRemove()); return; - case 'saveJailHelperValues': echo json_encode($this->saveJailHelperValues()); return; + //case 'jailRestart': echo json_encode($this->jailRestart()); return; + //case 'jailStart': echo json_encode($this->jailStart()); return; + //case 'jailStop': echo json_encode($this->jailStop()); return; + //case 'jailRemove': echo json_encode($this->jailRemove()); return; + //case 'saveJailHelperValues': echo json_encode($this->saveJailHelperValues()); return; case 'saveHelperValues': $redirect='/jailscontainers/'; case 'jailAdd': if(!isset($redirect)) $redirect=''; echo json_encode($this->jailAdd($redirect)); return; - case 'jailClone': echo json_encode($this->jailClone()); return; - case 'jailRename': echo json_encode($this->jailRename()); return; - case 'bhyveRename': echo json_encode($this->bhyveRename()); return; - case 'jailEdit': echo json_encode($this->jailEdit()); return; - case 'jailEditVars': echo json_encode($this->jailEditVars()); return; - case 'jailCloneVars': echo json_encode($this->jailCloneVars()); return; - case 'jailRenameVars': echo json_encode($this->jailRenameVars()); return; - case 'bhyveRenameVars': echo json_encode($this->bhyveRenameVars()); return; - case 'bhyveRestart': echo json_encode($this->bhyveRestart()); return; - case 'bhyveStart': echo json_encode($this->bhyveStart()); return; - case 'bhyveStop': echo json_encode($this->bhyveStop()); return; - case 'bhyveAdd': echo json_encode($this->bhyveAdd()); return; - case 'bhyveRemove': echo json_encode($this->bhyveRemove()); return; - case 'bhyveEdit': echo json_encode($this->bhyveEdit()); return; - case 'bhyveEditVars': echo json_encode($this->bhyveEditVars()); return; - case 'bhyveObtain': echo json_encode($this->bhyveObtain()); return; - case 'bhyveClone': echo json_encode($this->bhyveClone()); return; - case 'authkeyAdd': echo json_encode($this->authkeyAdd()); return; - case 'authkeyRemove': echo json_encode($this->authkeyRemove()); return; - case 'vpnetAdd': echo json_encode($this->vpnetAdd()); return; - case 'vpnetRemove': echo json_encode($this->vpnetRemove()); return; - case 'updateBhyveISO': echo json_encode($this->updateBhyveISO()); return; + //case 'jailClone': echo json_encode($this->jailClone()); return; + //case 'jailRename': echo json_encode($this->jailRename()); return; + //case 'bhyveRename': echo json_encode($this->bhyveRename()); return; + //case 'jailEdit': echo json_encode($this->jailEdit()); return; + //case 'jailEditVars': echo json_encode($this->jailEditVars()); return; + //case 'jailCloneVars': echo json_encode($this->jailCloneVars()); return; + //case 'jailRenameVars': echo json_encode($this->jailRenameVars()); return; + //case 'bhyveRenameVars': echo json_encode($this->bhyveRenameVars()); return; + //case 'bhyveRestart': echo json_encode($this->bhyveRestart()); return; + //case 'bhyveStart': echo json_encode($this->bhyveStart()); return; + //case 'bhyveStop': echo json_encode($this->bhyveStop()); return; + //case 'bhyveAdd': echo json_encode($this->bhyveAdd()); return; + //case 'bhyveRemove': echo json_encode($this->bhyveRemove()); return; + //case 'bhyveEdit': echo json_encode($this->bhyveEdit()); return; + //case 'bhyveEditVars': echo json_encode($this->bhyveEditVars()); return; + //case 'bhyveObtain': echo json_encode($this->bhyveObtain()); return; + //case 'bhyveClone': echo json_encode($this->bhyveClone()); return; + //case 'authkeyAdd': echo json_encode($this->authkeyAdd()); return; + //case 'authkeyRemove': echo json_encode($this->()); return; + //case 'vpnetAdd': echo json_encode($this->vpnetAdd()); return; + //case 'vpnetRemove': echo json_encode($this->vpnetRemove()); return; + //case 'updateBhyveISO': echo json_encode($this->updateBhyveISO()); return; + /* case 'mediaAdd': //echo json_encode($this->mediaAdd()); return; - case 'mediaRemove': echo json_encode($this->mediaRemove()); return; - case 'logLoad': echo json_encode($this->logLoad()); return; - case 'logFlush': echo json_encode($this->logFlush()); return; - case 'basesCompile': echo json_encode($this->basesCompile()); return; - case 'repoCompile': echo json_encode($this->repoCompile()); return; - case 'srcUpdate': echo json_encode($this->srcUpdate()); return; - case 'srcRemove': echo json_encode($this->srcRemove()); return; - case 'baseRemove': echo json_encode($this->baseRemove()); return; - case 'usersAdd': echo json_encode($this->usersAdd()); return; - case 'usersEdit': echo json_encode($this->usersEdit()); return; - case 'userRemove': echo json_encode($this->userRemove()); return; - case 'userGetInfo': echo json_encode($this->userGetInfo()); return; - case 'userEditInfo': echo json_encode($this->userEditInfo()); return; - case 'vmTemplateAdd': echo json_encode($this->vmTemplateAdd()); return; - case 'vmTemplateEditInfo': echo json_encode($this->vmTemplateEditInfo()); return; - case 'vmTemplateEdit': echo json_encode($this->vmTemplateEdit()); return; - case 'vmTemplateRemove': echo json_encode($this->vmTemplateRemove()); return; - case 'getImportedImageInfo': echo json_encode($this->getImportedImageInfo()); return; - case 'imageImport': echo json_encode($this->imageImport()); return; - case 'imageExport': echo json_encode($this->imageExport()); return; - case 'imageRemove': echo json_encode($this->imageRemove()); return; - case 'getSummaryInfo': echo json_encode($this->getSummaryInfo()); return; + */ + //case 'mediaRemove': echo json_encode($this->mediaRemove()); return; + //case 'logLoad': echo json_encode($this->logLoad()); return; + //case 'logFlush': echo json_encode($this->logFlush()); return; + //case 'basesCompile': echo json_encode($this->basesCompile()); return; + //case 'repoCompile': echo json_encode($this->repoCompile()); return; + //case 'srcUpdate': echo json_encode($this->srcUpdate()); return; + //case 'srcRemove': echo json_encode($this->srcRemove()); return; + //case 'baseRemove': echo json_encode($this->baseRemove()); return; + //case 'usersAdd': echo json_encode($this->usersAdd()); return; + //case 'usersEdit': echo json_encode($this->usersEdit()); return; + //case 'userRemove': echo json_encode($this->userRemove()); return; + //case 'userGetInfo': echo json_encode($this->userGetInfo()); return; + //case 'userEditInfo': echo json_encode($this->userEditInfo()); return; + //case 'vmTemplateAdd': echo json_encode($this->vmTemplateAdd()); return; + //case 'vmTemplateEditInfo': echo json_encode($this->vmTemplateEditInfo()); return; + //case 'vmTemplateEdit': echo json_encode($this->vmTemplateEdit()); return; + //case 'vmTemplateRemove': echo json_encode($this->vmTemplateRemove()); return; + //case 'getImportedImageInfo': echo json_encode($this->getImportedImageInfo()); return; + //case 'imageImport': echo json_encode($this->imageImport()); return; + //case 'imageExport': echo json_encode($this->imageExport()); return; + //case 'imageRemove': echo json_encode($this->imageRemove()); return; + //case 'getSummaryInfo': echo json_encode($this->getSummaryInfo()); return; /* case 'saveHelperValues': echo json_encode($this->saveHelperValues()); @@ -271,10 +300,25 @@ class ClonOS { } } - function ccmd_login(){ - return array('hi'=>'hello'); + function ccmd_getJsonPage() + { + $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']; return $this->userRegisterCheck($form); @@ -563,7 +607,7 @@ class ClonOS { return $obj; } - function jailRename() { + function ccmd_jailRename() { $form=$this->_vars['form_data']; $host_hostname=$form['host_hostname']; @@ -587,7 +631,7 @@ class ClonOS { return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode); } - function jailClone() { + function ccmd_jailClone() { $form=$this->_vars['form_data']; $username=$this->_user_info['username']; @@ -676,7 +720,7 @@ class ClonOS { return $arr; } - function saveJailHelperValues(){ + function ccmd_saveJailHelperValues(){ $form=$this->form; $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 } - function jailRenameVars(){ + function ccmd_jailRenameVars(){ $form=$this->_vars['form_data']; if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); @@ -902,7 +946,7 @@ class ClonOS { return $res; } - function jailCloneVars(){ + function ccmd_jailCloneVars(){ $form=$this->_vars['form_data']; if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); @@ -934,7 +978,7 @@ class ClonOS { return $res; } - function jailEditVars(){ + function ccmd_jailEditVars(){ $form=$this->_vars['form_data']; 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']; return $res; } - function jailEdit(){ + function ccmd_jailEdit(){ $form=$this->_vars['form_data']; $str=array(); @@ -980,7 +1024,7 @@ class ClonOS { return $res; } - function jailStart(){ //$name + function ccmd_jailStart(){ //$name $form=$this->_vars['form_data']; $username=$this->_user_info['username']; @@ -992,7 +1036,7 @@ class ClonOS { //.' cbsd_queue_name=/clonos/'.$cbsd_queue_name.'/'); // autoflush=2 return $res; } - function jailStop(){ //$name + function ccmd_jailStop(){ //$name $form=$this->_vars['form_data']; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1004,7 +1048,8 @@ class ClonOS { return $res; } - function jailRestart(){ //$name + //function jailRestart(){ //$name + function ccmd_jailRestart(){ //$name $form=$this->_vars['form_data']; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1014,7 +1059,7 @@ class ClonOS { return $res; } - function jailRemove(){ //$name + function ccmd_jailRemove(){ //$name $form=$this->_vars['form_data']; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1024,7 +1069,7 @@ class ClonOS { return $res; } - function bhyveClone(){ + function ccmd_bhyveClone(){ $form=$this->_vars['form_data']; $username=$this->_user_info['username']; @@ -1109,7 +1154,7 @@ class ClonOS { return array('html'=>$html); } - function bhyveEditVars(){ + function ccmd_bhyveEditVars(){ $form=$this->_vars['form_data']; if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); @@ -1137,10 +1182,10 @@ class ClonOS { $res['error']=false; $res['dialog']=$form['dialog']; $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; } - function bhyveRename(){ + function ccmd_bhyveRename(){ $form=$this->_vars['form_data']; $old_name=$form['oldJail']; @@ -1160,7 +1205,7 @@ class ClonOS { return array('errorMessage'=>$err,'jail_id'=>$form['jname'],'taskId'=>$taskId,'mode'=>$this->mode); } - function bhyveRenameVars(){ + function ccmd_bhyveRenameVars(){ $form=$this->_vars['form_data']; if(!isset($form['jail_id'])) return array('error'=>true,'error_message'=>'Bad jail id!'); @@ -1188,7 +1233,7 @@ class ClonOS { return $res; } - function bhyveEdit(){ + function ccmd_bhyveEdit(){ $form=$this->form; $str=array(); @@ -1240,7 +1285,7 @@ class ClonOS { return $res; } - function bhyveAdd(){ + function ccmd_bhyveAdd(){ $form=$this->form; @@ -1353,7 +1398,7 @@ class ClonOS { return array('errorMessage'=>$err,'jail_id'=>$jid,'taskId'=>$taskId,'html'=>$html,'mode'=>$this->mode); } - function bhyveObtain(){ + function ccmd_bhyveObtain(){ $form=$this->_vars['form_data']; $username=$this->_user_info['username']; @@ -1381,6 +1426,7 @@ class ClonOS { } $key_name='/usr/home/olevole/.ssh/authorized_keys'; + if(!isset($form['vm_authkey'])) $form['vm_authkey']=0; $key_id=(int)$form['vm_authkey']; $db=new Db('base','authkey'); @@ -1390,6 +1436,7 @@ class ClonOS { //if($nres['name']!==false) $key_name=$nres['name']; $nres=$db->selectAssoc('SELECT authkey FROM authkey WHERE idx='.$key_id); if($nres['authkey']!==false) $authkey=$nres['authkey']; + //var_dump($nres);exit; $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); } - function bhyveStart(){ + function ccmd_bhyveStart(){ $form=$this->form; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1447,7 +1494,7 @@ class ClonOS { return $res; } - function bhyveStop(){ + function ccmd_bhyveStop(){ $form=$this->form; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1457,7 +1504,7 @@ class ClonOS { return $res; } - function bhyveRestart(){ + function ccmd_bhyveRestart(){ $form=$this->form; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1467,7 +1514,7 @@ class ClonOS { return $res; } - function bhyveRemove(){ // $name + function ccmd_bhyveRemove(){ // $name $form=$this->form; $username=$this->_user_info['username']; $name=$form['jname']; @@ -1477,7 +1524,7 @@ class ClonOS { return $res; } - function authkeyAdd(){ + function ccmd_authkeyAdd(){ $form=$this->form; @@ -1508,7 +1555,7 @@ class ClonOS { return array('keyname'=>$form['keyname'],'html'=>$html); } - function authkeyRemove(){ + function ccmd_authkeyRemove(){ $form=$this->_vars['form_data']; $db=new Db('base','authkey'); @@ -1520,7 +1567,7 @@ class ClonOS { return array('error'=>false,'auth_id'=>$form['auth_id']); } - function vpnetAdd(){ + function ccmd_vpnetAdd(){ $form=$this->_vars['form_data']; @@ -1551,7 +1598,7 @@ class ClonOS { return array('netname'=>$form['netname'],'html'=>$html); } - function vpnetRemove(){ + function ccmd_vpnetRemove(){ $form=$this->_vars['form_data']; $db=new Db('base','vpnet'); @@ -1563,7 +1610,7 @@ class ClonOS { return array('error'=>false,'vpnet_id'=>$form['vpnet_id']); } - function mediaRemove(){ + function ccmd_mediaRemove(){ $form=$this->form; $db=new Db('base','storage_media'); if(!$db->isConnected()) return array('error'=>true,'res'=>'Database error'); @@ -1592,7 +1639,7 @@ class ClonOS { return $arr; } - function srcRemove(){ + function ccmd_srcRemove(){ $form=$this->form; $username=$this->_user_info['username']; $ver=$form['jname']; @@ -1604,7 +1651,7 @@ class ClonOS { return $res; } - function srcUpdate(){ + function ccmd_srcUpdate(){ $form=$this->form; $username=$this->_user_info['username']; $ver=$form['jname']; @@ -1654,7 +1701,7 @@ class ClonOS { return array('html'=>$html,'arr'=>$res); } - function baseRemove(){ //$id + function ccmd_baseRemove(){ //$id //$id=str_replace('base','',$id); //base10.3-amd64-0 $form=$this->form; @@ -1673,7 +1720,7 @@ class ClonOS { return $res; } - function basesCompile(){ + function ccmd_basesCompile(){ $form=$this->form; $username=$this->_user_info['username']; 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); } - function repoCompile(){ + function ccmd_repoCompile(){ $form=$this->form; $username=$this->_user_info['username']; 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')); } - function logLoad(){ + function ccmd_logLoad(){ $form=$this->_vars['form_data']; $log_id=$form['log_id']; 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!'); } - function logFlush(){ + function ccmd_logFlush(){ $res=$this->cbsd_cmd('task mode=flushall'); return $res; } @@ -1885,7 +1932,8 @@ class ClonOS { return array('error'=>false); } - function addJailHelperGroup(){ + //function addJailHelperGroup(){ + function ccmd_addJailHelperGroup(){ // $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!'); $jail_id=$this->uri_chunks[1]; @@ -1941,7 +1989,8 @@ class ClonOS { return array('db_path'=>$db_path,'html'=>$res['html']); } - function deleteJailHelperGroup(){ + //function deleteJailHelperGroup(){ + function ccmd_deleteJailHelperGroup(){ $form=$this->form; if(!isset($this->uri_chunks[1]) || !isset($this->url_hash)) return array('error'=>true,'errorMessage'=>'Bad url!'); @@ -2007,7 +2056,8 @@ class ClonOS { 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(); $add_cmd=($in_helper)?' default_jailname='.$this->url_hash:''; $add_cmd1=' default_jailname='.$type; @@ -2103,7 +2153,7 @@ class ClonOS { return $html; } - function updateBhyveISO($iso=''){ + function ccmd_updateBhyveISO($iso=''){ $db=new Db('base','storage_media'); $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!'); @@ -2140,7 +2190,7 @@ class ClonOS { return $html; } - function usersAdd(){ + function ccmd_usersAdd(){ $form=$this->form; $res=$this->userRegister($form); @@ -2153,7 +2203,7 @@ class ClonOS { return array('form'=>$form); } - function usersEdit(){ + function ccmd_usersEdit(){ $form=$this->form; if(!isset($form['user_id']) || !is_numeric($form['user_id']) || $form['user_id']<1) @@ -2299,7 +2349,7 @@ class ClonOS { return array('error'=>true); } - function userRemove(){ + function ccmd_userRemove(){ $form=$this->form; $id=$form['user_id']; @@ -2313,7 +2363,7 @@ class ClonOS { } } - function userEditInfo(){ + function ccmd_userEditInfo(){ $form=$this->form; 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'); if(!$db->isConnected()) return array('DB connection error!'); @@ -2345,7 +2395,7 @@ class ClonOS { return $this->_user_info['username']; } - function vmTemplateAdd(){ + function ccmd_vmTemplateAdd(){ $form=$this->form; $db=new Db('base','local'); @@ -2368,7 +2418,7 @@ class ClonOS { return $this->messageError('sql error!',$res); } - function vmTemplateEditInfo(){ + function ccmd_vmTemplateEditInfo(){ $form=$this->form; 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)); } - function vmTemplateEdit(){ + function ccmd_vmTemplateEdit(){ $form=$this->form; $id=$form['template_id']; @@ -2408,7 +2458,7 @@ class ClonOS { } - function vmTemplateRemove(){ + function ccmd_vmTemplateRemove(){ $form=$this->form; $id=$form['template_id']; @@ -2451,7 +2501,7 @@ class ClonOS { return $files; } - function getImportedImageInfo(){ + function ccmd_getImportedImageInfo(){ $form=$this->form; $name=$form['id']; $info=$this->getImageInfo($name); @@ -2494,7 +2544,7 @@ class ClonOS { $jail=$db->selectAssoc("SELECT jname FROM jails WHERE jname='{$db->escape($jname)}'"); if($jname==$jail['jname']){ - $jres=$this->getFreeJname(false,$type); + $jres=$this->ccmd_getFreeJname(false,$type); if($jres['error']) return $this->messageError('Something wrong...'); $jname=$jres['freejname']; $name_comment='* '.$this->translate('Since imported name already exist, we are change it'); @@ -2513,7 +2563,7 @@ class ClonOS { return $val; } - function imageExport(){ + function ccmd_imageExport(){ // cbsd jexport jname=XXX dstdir= $form=$this->form; $jname=$form['id']; @@ -2525,7 +2575,7 @@ class ClonOS { return $res; } - function imageImport(){ + function ccmd_imageImport(){ $form=$this->form; $file_id=$form['file_id']; @@ -2551,7 +2601,7 @@ class ClonOS { return $res; } - function imageRemove(){ + function ccmd_imageRemove(){ $form=$this->form; $cmd='cbsd imgremove path='.$this->media_import.' img='.$form['jname']; @@ -2561,7 +2611,7 @@ class ClonOS { return $res; } - function getSummaryInfo(){ + function ccmd_getSummaryInfo(){ $form=$this->form; if(!isset($form['mode'])) $form['mode']=''; $mode=$form['mode']; diff --git a/public/js/clonos.js b/public/js/clonos.js index c09376e9..1b9f8183 100644 --- a/public/js/clonos.js +++ b/public/js/clonos.js @@ -843,7 +843,8 @@ var clonos={ }, 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) { @@ -902,7 +903,7 @@ var clonos={ } $.post(path,posts, $.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) { @@ -916,8 +917,13 @@ var clonos={ { this.authorized=false; this.loginFadeIn(); + this.clearPageInfo(); return; } + if(typeof data['authorized']!='undefined') + { + this.authorized=data.authorized; + } if(typeof data.error!='undefined') { @@ -938,6 +944,11 @@ var clonos={ 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() { @@ -1651,7 +1662,7 @@ var clonos={ bodyClick:function(event) { //debugger; - //if(!this.authorized) location.reload(); + if(!this.authorized) {location.reload();return;} var target=event.target; if($(target).parents('form').length>0) { @@ -2135,6 +2146,13 @@ var clonos={ $('#user-login').html('guest'); this.loginFadeIn(); + this.dataReload(); + }, + clearPageInfo:function() + { + $('.tsimple tbody').empty(); + //$('#cdown #cinfo .left').html(''); + $('div.main').removeClass('asplit'); }, ddmenu_interval:null, diff --git a/public/pages/authkey/a.json.php b/public/pages/authkey/a.json.php index 93de9de0..3ab3a0f9 100644 --- a/public/pages/authkey/a.json.php +++ b/public/pages/authkey/a.json.php @@ -29,11 +29,18 @@ if($res!==false) $html.=$html_tmp; } } - + /* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'authkeyslist', )); + */ + $included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'authkeyslist', + ); } \ No newline at end of file diff --git a/public/pages/bases/a.json.php b/public/pages/bases/a.json.php index 2a015281..f2abbbec 100644 --- a/public/pages/bases/a.json.php +++ b/public/pages/bases/a.json.php @@ -88,7 +88,7 @@ if($hres!==false) foreach($vars as $var=>$val) $html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); } - +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -96,4 +96,13 @@ echo json_encode(array( 'id'=>'baseslist', 'tasks'=>$tasks, 'template'=>$html_tpl, -)); \ No newline at end of file +)); +*/ +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'baseslist', + 'tasks'=>$tasks, + 'template'=>$html_tpl, +); \ No newline at end of file diff --git a/public/pages/bhyvevms/a.json.php b/public/pages/bhyvevms/a.json.php index 8681717e..e250ff52 100644 --- a/public/pages/bhyvevms/a.json.php +++ b/public/pages/bhyvevms/a.json.php @@ -123,6 +123,7 @@ $protected=array( ) ); +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -132,3 +133,14 @@ echo json_encode(array( '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, +); diff --git a/public/pages/imported/a.json.php b/public/pages/imported/a.json.php index 88b63d95..d736aef1 100644 --- a/public/pages/imported/a.json.php +++ b/public/pages/imported/a.json.php @@ -91,6 +91,7 @@ function replaceVars($tpl,$vars) return $tpl; } +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -98,3 +99,12 @@ echo json_encode(array( 'id'=>'impslist', 'template'=>$html_tpl_1, )); +*/ + +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'impslist', + 'template'=>$html_tpl_1, +); \ No newline at end of file diff --git a/public/pages/instance_jail/a.json.php b/public/pages/instance_jail/a.json.php index 68853b3d..e69cc963 100644 --- a/public/pages/instance_jail/a.json.php +++ b/public/pages/instance_jail/a.json.php @@ -85,9 +85,18 @@ if($res['retval']==0) $html=str_replace(array("\n","\r","\t"),'',$html); +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'instanceslist', )); +*/ + +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'instanceslist', +); \ No newline at end of file diff --git a/public/pages/jailscontainers/a.json.php b/public/pages/jailscontainers/a.json.php index 3f4c2494..30f663f5 100644 --- a/public/pages/jailscontainers/a.json.php +++ b/public/pages/jailscontainers/a.json.php @@ -148,6 +148,7 @@ $protected=array( ) ); +/* echo json_encode(array( // 'thead'=>$thead, 'tbody'=>$html, @@ -158,3 +159,13 @@ echo json_encode(array( 'template'=>$html_tpl_1, 'protected'=>$protected, )); +*/ +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'jailslist', + 'tasks'=>$tasks, + 'template'=>$html_tpl_1, + 'protected'=>$protected, +); \ No newline at end of file diff --git a/public/pages/jailscontainers/helpers.json.php b/public/pages/jailscontainers/helpers.json.php index fa1fa3b1..56323b59 100644 --- a/public/pages/jailscontainers/helpers.json.php +++ b/public/pages/jailscontainers/helpers.json.php @@ -74,6 +74,7 @@ if(empty($hash)) $html=str_replace(array("\n","\r","\t"),'',$html); + /* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -81,12 +82,25 @@ if(empty($hash)) 'id'=>'helperslist', 'helpers_list'=>$helpers_list_html, )); + */ + $included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'helperslist', + 'helpers_list'=>$helpers_list_html, + ); return; }else{ # Открываем настройки хелпера $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(); $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'] \ No newline at end of file +//echo json_encode(array('html'=>$res['html'],'func'=>'fillTab')); //,'currents'=>$res['currents'] +$included_result_array=array( + 'html'=>$res['html'], + 'func'=>'fillTab' +); \ No newline at end of file diff --git a/public/pages/media/a.json.php b/public/pages/media/a.json.php index 01805096..4d60f4e0 100644 --- a/public/pages/media/a.json.php +++ b/public/pages/media/a.json.php @@ -30,11 +30,19 @@ if($res!==false) $html.=$html_tmp; } } - + + /* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'mediaslist', )); + */ + $included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'mediaslist', + ); } \ No newline at end of file diff --git a/public/pages/nodes/a.json.php b/public/pages/nodes/a.json.php index 511947c2..fd1390b6 100644 --- a/public/pages/nodes/a.json.php +++ b/public/pages/nodes/a.json.php @@ -1,3 +1,4 @@ select("select group_concat(ip,'; ') from nodelist"); // nodes.php \ No newline at end of file +//echo '{}'; +//$ips=$db1->select("select group_concat(ip,'; ') from nodelist"); // nodes.php +$included_result_array=array(); \ No newline at end of file diff --git a/public/pages/overview/a.json.php b/public/pages/overview/a.json.php index a7c105c2..0c7f2163 100644 --- a/public/pages/overview/a.json.php +++ b/public/pages/overview/a.json.php @@ -34,7 +34,8 @@ if(!empty($nodenames))foreach($nodenames as $name) $ndb=new Db('base',trim($name)); 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; } @@ -57,4 +58,5 @@ if($res_array['average']>0) $res_array['sum-ram']=$this->fileSizeConvert((int) $res_array['sum-ram'],1024,true); -echo json_encode($res_array); \ No newline at end of file +//echo json_encode($res_array); +$included_result_array=$res_array; \ No newline at end of file diff --git a/public/pages/sources/a.json.php b/public/pages/sources/a.json.php index 8c15a5cb..f1b018da 100644 --- a/public/pages/sources/a.json.php +++ b/public/pages/sources/a.json.php @@ -85,6 +85,7 @@ if($hres!==false) $html_tpl=str_replace('#'.$var.'#',$val,$html_tpl); } +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -92,4 +93,13 @@ echo json_encode(array( 'id'=>'srcslist', 'tasks'=>$tasks, 'template'=>$html_tpl, -)); \ No newline at end of file +)); +*/ +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'srcslist', + 'tasks'=>$tasks, + 'template'=>$html_tpl, +); \ No newline at end of file diff --git a/public/pages/tasklog/a.json.php b/public/pages/tasklog/a.json.php index 453f50bc..c20abccc 100644 --- a/public/pages/tasklog/a.json.php +++ b/public/pages/tasklog/a.json.php @@ -60,10 +60,18 @@ if($res!==false) } } + /* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'taskloglist', )); + */ + $included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'taskloglist', + ); } \ No newline at end of file diff --git a/public/pages/users/a.json.php b/public/pages/users/a.json.php index b1a9897d..94bb8256 100644 --- a/public/pages/users/a.json.php +++ b/public/pages/users/a.json.php @@ -45,6 +45,7 @@ if(!empty($res))foreach($res as $r) $html=str_replace(array("\n","\r","\t"),'',$html); +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, @@ -54,3 +55,10 @@ echo json_encode(array( //'template'=>$html_tpl_1, //'protected'=>$protected, )); +*/ +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'userslist', +); \ No newline at end of file diff --git a/public/pages/vm_packages/a.json.php b/public/pages/vm_packages/a.json.php index f4678aba..62e71640 100644 --- a/public/pages/vm_packages/a.json.php +++ b/public/pages/vm_packages/a.json.php @@ -33,9 +33,17 @@ if(!empty($res))foreach($res as $r) $html=str_replace(array("\n","\r","\t"),'',$html); +/* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'packageslist', )); +*/ +$included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'packageslist', +); \ No newline at end of file diff --git a/public/pages/vpnet/a.json.php b/public/pages/vpnet/a.json.php index 31c0bad7..752686fe 100644 --- a/public/pages/vpnet/a.json.php +++ b/public/pages/vpnet/a.json.php @@ -30,10 +30,18 @@ if($res!==false) } } + /* echo json_encode(array( 'tbody'=>$html, 'error'=>false, 'func'=>'fillTable', 'id'=>'vpnetslist', )); + */ + $included_result_array=array( + 'tbody'=>$html, + 'error'=>false, + 'func'=>'fillTable', + 'id'=>'vpnetslist', + ); } \ No newline at end of file