예제 #1
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $parent = $this->getParentO();
     switch ($subaction) {
         case "copyplan":
             $clist = get_namelist_from_objectlist($parent->getList('client'));
             $clist[] = $parent->nname;
             $vlist['copy_clientname_f'] = array('s', $clist);
             $vlist['realname_f'] = array('m', $this->realname);
             return $vlist;
         case "account":
             $total = $this->getAccountList();
             $total = lx_array_merge($total);
             $vlist['account'] = array('M', implode(" ", $total));
             $vlist['__v_button'] = array();
             return $vlist;
         case "limit_s":
         case "limit":
             $vlist = getQuotaListForClass('client');
             $vlist['__m_message_pre'] = "resourceplan_change_pre";
             // This is patently wrong. In update, the object is inititialized properly and we are suppsed to get the quota for the specific type of object and not for the class.... Changing it to $this.
             $sgbl->method = 'post';
             return $vlist;
         case "dnstemplatelist":
             $parent = $this->getParentO();
             $nlist = domainBase::getDnsTemplateList($parent);
             $vlist['dnstemplate_list'] = array('U', $nlist);
             return $vlist;
         case "pserver_s":
             $parent = $this->getParentO();
             $list = null;
             $serverlist = client::getPserverListPriv();
             if ($this->isLogin() || !$this->isRightParent()) {
                 foreach ($serverlist as $s) {
                     $slist = "{$s}_list";
                     $vlist["{$s}_list"] = array('M', $this->listpriv->{$slist});
                 }
                 $vlist['__v_button'] = array();
                 //$vlist['dbtype_list'] = array('M', $this->listpriv->dbtype_list);
                 return $vlist;
             } else {
                 $vlist['server_detail_f'] = null;
                 foreach ($serverlist as $s) {
                     $slist = "{$s}_list";
                     $vlist["{$s}_list"] = null;
                     if ($parent->isAdmin()) {
                         $plist = $parent->getServerList(strtilfirst($s, "pserver"));
                     } else {
                         $plist = $parent->listpriv->{$slist};
                     }
                     if ($parent->isAdmin()) {
                         unset($parent->listpriv->{$slist});
                     }
                     $list = lx_array_merge(array($list, $plist));
                 }
                 $vlist['server_detail_f'] = array('M', pservercore::createServerInfo($list));
                 //$vlist['dbtype_list'] = null;
                 return $vlist;
             }
         case "ipaddress":
             dprintr($this->listpriv->ipaddress_list);
             $parent = $this->getParentO();
             if ($this->isLogin() || !$this->isRightParent()) {
                 $vlist['ipaddress_list'] = array('M', $this->getIpaddress($this->listpriv->webpserver_list));
                 $vlist['__v_button'] = array();
             } else {
                 if (check_if_many_server()) {
                     dprintr($this->listpriv->webpserver_list);
                     $iplist = $parent->getIpaddress($this->listpriv->webpserver_list);
                 } else {
                     $iplist = $parent->getIpaddress(array('localhost'));
                 }
                 dprintr($iplist);
                 $vlist['ipaddress_list'] = array('Q', $iplist);
             }
             return $vlist;
         case "description":
             if ($this->islogin()) {
                 throw new lxException('you_cannot_set_your_own_limit', '');
             }
             $vlist['disable_per'] = array('s', array('off', '95', '100', '110', '120', '130'));
             if ($sgbl->isHyperVm() && $sgbl->isDebug()) {
                 //$vlist['centralbackup_flag'] = null;
             }
             $vlist['description'] = null;
             //$vlist['share_status'] = null;
             if (!$this->isRightParent()) {
                 $this->convertToUnmodifiable($vlist);
             }
             return $vlist;
         case "changerealname":
             $vlist['realname'] = null;
             return $vlist;
         case "ostemplatelist":
             getResourceOstemplate($vlist);
             return $vlist;
     }
     return parent::updateform($subaction, $param);
 }
예제 #2
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     switch ($subaction) {
         case "installatron":
             $vlist['__v_button'] = array();
             return $vlist;
         case "ostemplatelist":
             getResourceOstemplate($vlist, 'all');
             $vlist['__v_updateall_button'] = array();
             return $vlist;
         case "createinvoice_m":
             $vlist['month'] = null;
             return $vlist;
         case "createinvoice_s":
             $vlist['month'] = array('s', $this->getInvoiceMonthList());
             return $vlist;
         case "search_engine":
             $vlist['se_url'] = array('M', "http://");
             $vlist['se_email'] = null;
             return $vlist;
         case "cron_mailto":
             $vlist['cron_mailto'] = null;
             return $vlist;
         case "default_domain":
             $vlist['default_domain'] = array('s', add_disabled(get_namelist_from_objectlist($this->getList('domain'))));
             return $vlist;
         case "shell_access":
             $res[] = "/bin/bash";
             $res[] = "/usr/bin/lxjailshell";
             $res = add_disabled($res);
             $vlist['nname'] = array('M', null);
             $vlist['disable_system_flag'] = null;
             $vlist['shell'] = array('s', $res);
             $vlist['__v_updateall_button'] = array();
             return $vlist;
         case "generate_csr":
             include "lib/countrycode.inc";
             foreach ($gl_country_code as $key => $name) {
                 $temp[$key] = $name;
             }
             $s = new sslcert(null, null, null);
             $this->ssl_data_b = new ssl_data_b(null, null, null);
             $vlist['contactemail'] = array('M', null);
             $vlist["ssl_data_b_s_commonName_r"] = null;
             $vlist["ssl_data_b_s_emailAddress_r"] = null;
             $vlist["ssl_data_b_s_countryName_r"] = array('A', $temp);
             $vlist["ssl_data_b_s_stateOrProvinceName_r"] = null;
             $vlist["ssl_data_b_s_localityName_r"] = null;
             $vlist["ssl_data_b_s_organizationName_r"] = null;
             $vlist["ssl_data_b_s_organizationalUnitName_r"] = null;
             return $vlist;
         case "domainpserver":
             if ($this->isAdmin()) {
                 $parent = $this;
             } else {
                 $parent = $this->getParentO();
             }
             self::getDomainServerVlist($parent, $this, $vlist);
             return $vlist;
         case "forcedeletepserver":
             if_not_admin_complain_and_exit();
             $list = get_namelist_from_objectlist($this->getList('pserver'));
             $vlist['pserver_delete_f'] = array('s', array_remove($list, "localhost"));
             return $vlist;
         case "deleteorphanedvps":
             $sq = new Sqlite(null, 'vps');
             $slist = get_namelist_from_objectlist($this->getList('pserver'));
             $res = $sq->getTable(array('nname', 'syncserver', 'parent_clname'));
             $list = null;
             foreach ($res as $r) {
                 if (!array_search_bool($r['syncserver'], $slist)) {
                     $list[$r['nname']] = "{$r['nname']} ({$r['syncserver']}) (orphaned)";
                 }
             }
             if ($list) {
                 $vlist['vps_delete_f'] = array('A', $list);
             } else {
                 $vlist['vps_delete_f'] = array('M', 'No Orphaned vm');
             }
             return $vlist;
         case "multivpscreate":
             $vlist['vps_basename_f'] = null;
             $vlist['vps_admin_password_f'] = null;
             $vlist['vps_count_f'] = null;
             $vlist['vps_template_name_f'] = array('s', get_namelist_from_objectlist($this->getList('vpstemplate')));
             return $vlist;
         case "disable_url":
             $vlist['disable_url'] = array('m', array('pretext' => 'http://'));
             return $vlist;
         case "message":
             $vlist['wall_from_f'] = array('M', $login->nname);
             $vlist['send_to_f'] = array('M', $this->nname);
             $vlist['wall_subject_f'] = null;
             $vlist['wall_message_f'] = null;
             $vlist['__v_button'] = 'Send';
             return $vlist;
         case "skeleton":
             $vlist['skeletonarchive'] = array('M', null);
             $vlist['skeletonarchive_f'] = null;
             return $vlist;
         case "wall":
             $vlist['wall_from_f'] = array('M', $this->nname);
             //Can't do this. If he has 10000 client, this itelf will hang the machine.
             //$vlist['send_to_f'] = array('M', $namlist);
             $vlist['wall_subject_f'] = null;
             $vlist['wall_message_f'] = null;
             $vlist['__v_button'] = 'Send';
             return $vlist;
         case "dnstemplatelist":
             $parent = $this->getParentO();
             $nlist = domain::getDnsTemplateList($parent);
             $vlist['dnstemplate_list'] = array('U', $nlist);
             $vlist['__v_updateall_button'] = array();
             return $vlist;
         case "information":
             $vlist['nname'] = array('M', $this->nname);
             if ($this->isAdmin()) {
                 $gen = $login->getObject('general');
                 $this->disable_admin = $gen->disable_admin;
                 $vlist['disable_admin'] = null;
             }
             if ($this->isLogin()) {
                 $vlist['cttype'] = array('M', $this->cttype);
             } else {
                 $parent = $this->getParentO();
                 $res = null;
                 if (check_if_many_server()) {
                     $ctlist = array('reseller', 'customer', 'wholesale');
                 } else {
                     $ctlist = array('reseller', 'customer');
                 }
                 foreach ($ctlist as $v) {
                     if ($parent->isGte($v)) {
                         continue;
                     }
                     $res[] = $v;
                 }
                 if ($res) {
                     $vlist['cttype'] = array('s', $res);
                 } else {
                     $vlist['cttype'] = array('M', $this->cttype);
                 }
             }
             $vlist['ddate'] = array('M', @date('d-m-Y', $this->ddate));
             if (!$this->isAdmin()) {
                 $vlist['parent_name_f'] = array('M', $this->getParentName());
             }
             $vlist['contactemail'] = "";
             if (!$this->isLogin()) {
                 $vlist['text_comment'] = null;
             }
             return $vlist;
         case "license":
             $lic = $login->getObject('license')->licensecom_b;
             if ($login->isAdmin()) {
                 $vlist['lic_pserver_num_f'] = array('M', $lic->lic_pserver_num);
                 $vlist['lic_client_num_f'] = array('M', $lic->lic_client_num);
                 $vlist['lic_maindomain_num_f'] = array('M', $lic->lic_maindomain_num);
             } else {
                 $vlist['lic_node_num_f'] = array('M', $lic->node_num);
             }
             $vlist['lic_live_support_f'] = array('M', $lic->lic_live_support);
             //$vlist['lic_ipaddress_f'] = array('M', $lic->lic_ipaddress);
             $vlist['lic_client_f'] = array('M', $lic->lic_client);
             //$vlist['lic_current_f'] = array('t', lfile_get_contents('__path_program_etc/license.txt'));
             $vlist['license_upload_f'] = null;
             return $vlist;
         case "ipaddress":
             $parent = $this->getParentO();
             if ($this->isLogin() || !$this->isRightParent()) {
                 $vlist['ipaddress_list'] = array('M', $this->getIpaddress($this->listpriv->webpserver_list));
                 $vlist['__v_button'] = array();
             } else {
                 if (check_if_many_server()) {
                     dprintr($this->listpriv->webpserver_list);
                     $iplist = $parent->getIpaddress($this->listpriv->webpserver_list);
                 } else {
                     $iplist = $parent->getIpaddress(array('localhost'));
                 }
                 dprintr($iplist);
                 $vlist['ipaddress_list'] = array('Q', $iplist);
             }
             return $vlist;
         case "pserver_s":
             $parent = $this->getParentO();
             $list = null;
             $serverlist = client::getPserverListPriv();
             if ($this->isLogin() || !$this->isRightParent()) {
                 foreach ($serverlist as $s) {
                     $slist = "{$s}_list";
                     $vlist["{$s}_list"] = array('M', $this->listpriv->{$slist});
                 }
                 $vlist['__v_button'] = array();
                 //$vlist['dbtype_list'] = array('M', $this->listpriv->dbtype_list);
                 return $vlist;
             } else {
                 $vlist['server_detail_f'] = null;
                 foreach ($serverlist as $s) {
                     $slist = "{$s}_list";
                     // Hack.. Actually, admin's listpriv should be empty so that the __get inside the listpriv will get automatically called.
                     if ($parent->isAdmin()) {
                         unset($parent->listpriv->{$slist});
                     }
                     $vlist["{$s}_list"] = null;
                     $list = lx_array_merge(array($list, $parent->getServerList(strtilfirst($s, "pserver"))));
                 }
                 $sinfo = pservercore::createServerInfo($list);
                 $sinfo = get_warning_for_server_info($parent, $sinfo);
                 $vlist['server_detail_f'] = array('M', $sinfo);
                 //$vlist['dbtype_list'] = null;
                 return $vlist;
             }
         case "description":
             $vlist['description'] = null;
             //$vlist['share_status'] = null;
             if (!$this->isRightParent()) {
                 $this->convertToUnmodifiable($vlist);
             }
             return $vlist;
     }
     return parent::updateform($subaction, $param);
 }
예제 #3
0
 function updateform($subaction, $param)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $parent = $this->getParentO();
     $gen = $login->getObject('general')->generalmisc_b;
     switch ($subaction) {
         case "recovervps":
             /*
             		if (!lxfile_exists("{$this->getOstemplatePath()}/{$this->ostemplate}.tar.gz")) {
             			$list = exec_class_method("vps__{$this->ttype}", "getOsTemplatelist");
             			$vlist['recover_ostemplate'] = array('A', $list);
             		}
             */
             $vlist['recover_confirm_f'] = null;
             return $vlist;
         case "mount":
             $vlist['confirm_f'] = array('M', "confirm");
             return $vlist;
         case "macaddress":
             $vlist['macaddress'] = null;
             return $vlist;
         case "ostemplatelist":
             getResourceOstemplate($vlist, $this->ttype);
             $vlist['__v_updateall_button'] = array();
             return $vlist;
         case "hardpoweroff":
             $vlist['confirm_f'] = array("M", "Confirm");
             return $vlist;
         case "reboot":
             $vlist['reboot_confirm_f'] = null;
             //  array("f", "Confirm");
             $vlist['__v_button'] = 'Reboot';
             return $vlist;
         case "shutdown":
             $vlist['poweroff_confirm_f'] = null;
             //  array("f", "Confirm");
             $vlist['__v_button'] = 'Power OFF';
             return $vlist;
         case "mainipaddress":
             $vlist['mainipaddress'] = array('s', get_namelist_from_objectlist($this->vmipaddress_a));
             return $vlist;
         case "livemigrate":
             $serverlist = $login->getServerList($this->get__table());
             $rs = null;
             foreach ($serverlist as $l) {
                 $driverapp = $gbl->getSyncClass(null, $l, 'vps');
                 if ($driverapp === 'openvz') {
                     $rs[] = $l;
                 }
             }
             $serverlist = $rs;
             if (!$this->checkIfLockedForAction('livemigrate')) {
                 if ($this->olddeleteflag === 'doing') {
                     $this->olddeleteflag = 'program_interrupted';
                     $this->setUpdateSubaction();
                 }
             }
             $vlist['olddeleteflag'] = array('M', null);
             $vlist['server_detail_f'] = array('M', pserver::createServerInfo($serverlist, $this->get__table()));
             $vlist['syncserver'] = array('s', $serverlist);
             return $vlist;
         case "append_inittab":
             $vlist['text_inittab'] = array('t', $this->text_inittab);
             return $vlist;
         case "append_xen_config":
             $vlist['text_xen_config'] = array('t', $this->text_xen_config);
             return $vlist;
         case "changelocation":
             if ($this->isXen()) {
                 return $this->formChangeLocationXen();
             } else {
                 return $this->formChangeLocationOpenvz();
             }
             break;
         case "createuser":
             $this->username = str_replace(".", "", $this->nname);
             $vlist['username'] = array('M', null);
             return $vlist;
         case "changeosimagename":
             $vlist['ostemplate'] = null;
             return $vlist;
         case "clonevps":
             $vlist['__v_button'] = array();
             return $vlist;
         case "createtemplate":
             $stem = explode("-", $this->ostemplate);
             if ($this->isWindows()) {
                 $name = "{$stem[0]}-";
             } else {
                 $name = "{$stem[0]}-{$stem[1]}-{$stem[2]}-";
             }
             $vlist['newostemplate_name_f'] = array("m", array("pretext" => $name));
             $vlist['__v_button'] = 'Create';
             return $vlist;
         case "rebuild":
             if ($this->isWindows()) {
                 $type = "img";
             } else {
                 $type = "tar.gz";
             }
             $ostlist = vps::getVpsOsimage($this, $this->ttype, $type);
             $vlist['ostemplate'] = array('A', $ostlist);
             if ($this->isNotWindows() && $this->priv->isOn('backup_flag')) {
                 //$vlist['rebuild_backup_f'] = null;
             }
             $vlist['rebuild_confirm_f'] = null;
             return $vlist;
             /*		case "installkloxo":
             			$this->kloxo_type = 'master';
             			$vlist['rebuild_confirm_f'] = null;
             			$vlist['__v_button'] = 'Install';
             			return $vlist;
             */
         /*		case "installkloxo":
         			$this->kloxo_type = 'master';
         			$vlist['rebuild_confirm_f'] = null;
         			$vlist['__v_button'] = 'Install';
         			return $vlist;
         */
         case "commandcenter":
             return $this->commandCenter($param);
         case "fixdev":
             $vlist['fixdev_confirm_f'] = null;
             return $vlist;
         case "rootpassword":
             if ($this->isXen()) {
                 $vlist['__m_message_pre'] = 'xen_restart_message';
             }
             $vlist['rootpassword'] = null;
             return $vlist;
             //ONly for Template...
         //ONly for Template...
         case "description":
             $vlist['description'] = null;
             //$vlist['share_status'] = null;
             if (!$this->isRightParent()) {
                 $this->convertToUnmodifiable($vlist);
             }
             return $vlist;
         case "timezone":
             $vlist['timezone'] = array('s', pserver::getTimeZoneList());
             return $vlist;
         case "information":
             $vlist['nname'] = array('M', $this->nname);
             $vlist['corerootdir'] = array('M', $this->corerootdir);
             $vlist['ddate'] = array('M', @date('d-m-Y', $this->ddate));
             //			$vlist['kloxo_flag'] = null;
             if ($login->isAdmin() && $this->isXen()) {
                 $vlist['nosaveconfig_flag'] = null;
             }
             if (!$this->isXen()) {
                 $vlist['vpsid'] = array('M', $this->vpsid);
             }
             if ($this->isXen() && $login->isAdmin()) {
                 $vlist['vcpu_number'] = array('s', range(1, 10));
             }
             if ($login->isAdmin()) {
                 $use_slaves = "__use-slaves-backup-server__";
                 if (!$this->centralbackup_server) {
                     $this->centralbackup_server = $use_slaves;
                 }
                 $sq = new Sqlite(null, "centralbackupserver");
                 $list = get_namelist_from_arraylist($sq->getTable(array('nname')));
                 $list = lx_merge_good(array($use_slaves), $list);
                 //$vlist['centralbackup_flag'] = null;
                 $vlist['centralbackup_server'] = array('s', $list);
             }
             $vlist['ostemplate'] = array('M', null);
             $vlist['parent_name_f'] = array('M', $this->getParentName());
             //$vlist['dbtype_list'] = array('M', $this->listpriv->dbtype_list);
             $vlist['contactemail'] = "";
             if (!$this->isLogin()) {
                 $vlist['text_comment'] = null;
             }
             return $vlist;
             // Only for template. For the main guy, it comes as 'rebuild'
         // Only for template. For the main guy, it comes as 'rebuild'
         case "network":
             if ($this->isXen()) {
                 $vlist['__m_message_pre'] = 'xen_restart_message';
             }
             if (!$this->isLogin() || !$gen->isOn('disable_hostname_change')) {
                 $vlist['hostname'] = null;
             }
             if ($this->isXen()) {
                 if (!$this->networknetmask) {
                     $this->networknetmask = "255.255.255.0";
                 }
                 $vlist['networkgateway'] = null;
                 $vlist['networknetmask'] = null;
                 if ($login->priv->isOn('ip_manage_flag') || $login->isAdmin()) {
                     $vlist['networkbridge'] = array('s', array("__automatic__", "xenbr0", "xenbr1", "xenbr2", "xenbr3", "xenbr4"));
                 }
             }
             $iplist = $this->vmipaddress_a;
             $iplist = implode(", ", get_namelist_from_objectlist($iplist, 'nname'));
             $vlist['one_ipaddress_f'] = array('M', $iplist);
             $vlist['nameserver'] = null;
             return $vlist;
         case "ostemplate":
             $driverapp = $gbl->getSyncClass($this->__masterserver, $this->listpriv->vpspserver_sing, 'vps');
             $ostlist = rl_exec_get(null, $this->listpriv->vpspserver_sing, array("vps__{$driverapp}", "getOsTemplatelist"));
             $ostlist = lx_merge_good(array('--defer-osimage--' => '--defer-osimage--'), $ostlist);
             $vlist['ostemplate'] = array('A', $ostlist);
             return $vlist;
         case "changesyncserver":
             $sq = new Sqlite(null, 'pserver');
             $list = $sq->getTable(array('nname'));
             $list = get_namelist_from_arraylist($list);
             $vlist['syncserver'] = array('s', $list);
             $gbl->__ajax_refresh = true;
             return $vlist;
             // Only for template...
         // Only for template...
         case "vpspserver_s":
             $listpriv = $parent->listpriv;
             $vlist['server_detail_f'] = array('M', pserver::createServerInfo($listpriv->vpspserver_list, "vps"));
             $parent = $this->getParentO();
             $vlist['vpspserver_sing'] = null;
             if (!$this->isRightParent()) {
                 $this->convertToUnmodifiable($vlist);
             }
             return $vlist;
     }
     return parent::updateform($subaction, $param);
 }