function updateform($subaction, $param) { global $gbl, $sgbl, $login, $ghtml; $sq = new Sqlite(null, 'web'); $list = $sq->getRowsWhere("syncserver = '{$this->syncserver}'", array('nname')); $dlist = get_namelist_from_arraylist($list, 'nname'); if (!$login->isAdmin()) { $sq = new Sqlite(null, 'domain'); $nlist = $sq->getRowsWhere("parent_clname = '{$login->getClName()}'", array('nname')); $ndlist = get_namelist_from_arraylist($nlist); foreach ($dlist as $k => $v) { if (!array_search_bool($v, $ndlist)) { unset($dlist[$k]); } } } if ($dlist) { $dlist = add_disabled($dlist); $vlist['domain'] = array('s', $dlist); } else { $vlist['domain'] = array('M', "No Domain"); $vlist['__v_button'] = array(); } return $vlist; }
function updateWht() { $res = $this->main->__var_whitelist; $res = merge_array_object_not_deleted($res, $this->main); $list = get_namelist_from_arraylist($res, 'ipaddress'); $rmt = new Remote(); $rmt->data = $list; lfile_put_serialize("__path_home_root/lxguard/whitelist.info", $rmt); lxshell_return("__path_php_path", "../bin/common/lxguard.php"); }
function createExtraVariables() { $this->__var_system_username = $this->getParentO()->username; $sq = new Sqlite(null, 'davuser'); $list = $sq->getRowsWhere("parent_clname = '{$this->parent_clname}'", array("username", "realpass")); $this->__var_davuser = $list; $sq = new Sqlite(null, 'web'); $list = $sq->getRowsWhere("syncserver = '{$this->getParentO()->syncserver}'", array('nname')); $this->__var_domlist = get_namelist_from_arraylist($list); }
static function initThisOutOfBand($parent, $iclass, $mclass, $rclass) { $sq = new Sqlite(null, $iclass); $res = $sq->getRowsWhere("parent_clname = '{$parent->getClName()}'", array("nname")); $res = get_namelist_from_arraylist($res); $ret = null; foreach ($res as $r) { $ret[] = "or"; $ret[] = array('parent_clname', '=', "'{$mclass}-{$r}'"); } unset($ret[0]); return $ret; }
function dbactionAdd() { global $gbl, $sgbl, $login; if (if_demo()) { return; } $_filepath = "__path_home_root/lxguard/hostdeny.info"; $result = $this->main->__var_hostlist; $result = merge_array_object_not_deleted($result, $this->main); $list = get_namelist_from_arraylist($result, 'hostname', 'hostname'); dprintr($list); lfile_put_serialize($_filepath, $list); lxshell_return("__path_php_path", "../bin/common/lxguard.php"); }
static function getDnsTemplateList($parent) { $res = $parent->dnstemplate_list; dprintr($res); if (!$res) { $sq = new Sqlite(null, "dnstemplate"); $res = $sq->getTable(); $res = get_namelist_from_arraylist($res); } if (!$res) { throw new lxException("err_no_dns_template", '', ''); } return $res; }
function get_local_application_version_list() { $list = allinstallapp__linux::getListofApps(); $list = get_namelist_from_arraylist($list); foreach ($list as $k => $v) { if (csb($v, "__title")) { continue; } $info = allinstallapp::getAllInformation($v); $ret[$v] = $info['pversion']; } $loc = new Remote(); $loc->applist = $ret; return $loc; }
static function addform($parent, $class, $typetd = null) { global $gbl, $sgbl, $login, $ghtml; $vlist['client'] = array('M', $parent->nname); $sq = new Sqlite(null, 'invoice'); $res = $sq->getRowsWhere("client = '{$parent->nname}'", array("month")); $list = get_namelist_from_arraylist($res, 'month'); $list = array_reverse($list); $vlist['month'] = array('s', $list); $vlist['amount'] = null; $vlist['paymentgw'] = null; $vlist['transactionid'] = null; $ret['variable'] = $vlist; $ret['action'] = 'add'; return $ret; }
function createExtraVariables() { global $gbl, $sgbl, $login, $ghtml; $gen = $login->getObject('general')->generalmisc_b; $port = $login->getObject('general')->portconfig_b; $webstatsprog = $gen->webstatisticsprogram; if (!$webstatsprog) { $webstatsprog = "awstats"; } $this->__var_statsprog = $webstatsprog; $ol = array("index.php", "index.html", "index.shtml", "index.htm", "default.htm", "Default.aspx", "Default.asp", "index.pl"); if (!isset($login->getObject('genlist')->dirindexlist_a)) { $this->__var_index_list = $ol; } else { $dirin = $login->getObject('genlist')->dirindexlist_a; $list = get_namelist_from_objectlist($dirin); $this->__var_index_list = lx_array_merge(array($list, $ol)); } // $this->__var_sslport = $port->sslport; // if (!$this->__var_sslport) $this->__var_sslport = "7777"; $this->__var_sslport = isset($port->sslport) ? $port->sslport : "7777"; // $this->__var_nonsslport = $port->nonsslport; // if (!$this->__var_nonsslport) $this->__var_nonsslport = "7778"; $this->__var_nonsslport = isset($port->nonsslport) ? $port->nonsslport : "7778"; // if (!$this->docroot) { $this->docroot = $this->nname; } // if (!$this->corelocation) { $this->corelocation = "__path_customer_root"; } if (!isset($this->docroot)) { $this->docroot = $this->nname; } if (!isset($this->corelocation)) { $this->corelocation = "__path_customer_root"; } $this->__var_extrabasedir = $gen->extrabasedir; $this->__var_dirprotect = $this->getList("dirprotect"); if (!$this->isDeleted()) { if ($this->getParentO()) { $parent = $this->getParentO()->getParentO(); } if ($parent) { $this->__var_disable_url = $parent->disable_url; } } //$dvlist = $this->getList('davuser'); $dvlist = null; foreach ((array) $dvlist as $v) { $ndvlist[$v->directory][] = null; } //$this->__var_davuser = $ndvlist; $this->__var_davuser = null; if (!$this->customer_name) { if ($this->getRealClientParentO()) { $this->customer_name = $this->getRealClientParentO()->getPathFromName(); } } $this->__var_railspp = $this->getList('rubyrails'); $mydb = new Sqlite($this->__masterserver, 'ipaddress'); $syncserver = $this->syncserver ? $this->syncserver : 'localhost'; $string = "syncserver = '{$syncserver}'"; $this->__var_ipssllist = $mydb->getRowsWhere($string, array('ipaddr', 'nname')); $this->__var_addonlist = $this->getTrueParentO()->getList('addondomain'); if (!isset($this->__var_sysuserpassword)) { $this->__var_sysuserpassword['realpass'] = $this->getParentO()->realpass; } $dipdb = new Sqlite(null, "domainipaddress"); $string = "syncserver = '{$syncserver}' "; $domainip = $dipdb->getRowsWhere($string, array('domain', 'ipaddr')); $this->__var_domainipaddress = get_namelist_from_arraylist($domainip, 'ipaddr', 'domain'); $ipdb = new Sqlite($this->__masterserver, 'ipaddress'); $string = "syncserver = '{$syncserver}' "; $iplist = $ipdb->getRowsWhere($string, array('ipaddr')); $this->__var_ipaddress = $iplist; $mydb = new Sqlite($this->__masterserver, "web"); /* This is to ensure that the excess domainipaddress entries are filtered out. $siplist = get_namelist_from_arraylist($iplist, 'ipaddr'); foreach($this->__var_domainipaddress as $k) { if (!isset($siplist[$k])) { unset($this->__var_domainipaddress[$k]); } } */ if ($this->dbaction === 'update' && $this->subaction !== 'full_update' && $this->subaction !== 'fixipdomain') { return; } if ($this->dbaction === 'add') { $this->__var_parent_contactemail = $this->getTrueParentO()->getTrueParentO()->contactemail; $this->__var_clientname = $this->getTrueParentO()->getTrueParentO()->nname; } $string = "syncserver = '{$syncserver}'"; $this->__var_vdomain_list = $mydb->getRowsWhere($string, array('nname', 'ipaddress')); /* $string = "ttype='forward' AND syncserver = '$syncserver'" ; $this->__var_fdomain_list = $mydb->getRowsWhere($string, array('nname')); */ // new -- related to apache/lighttpd new structure $mmaildb = new Sqlite($this->__masterserver, 'mmail'); $syncserver = $this->syncserver ? $this->syncserver : 'localhost'; $string = "syncserver = '{$syncserver}'"; $this->__var_mmaillist = $mmaildb->getRowsWhere($string, array('nname', 'parent_clname', 'webmailprog', 'webmail_url', 'remotelocalflag')); }
function updateform($subaction, $param) { global $gbl, $sgbl, $login, $ghtml; switch ($subaction) { case "centralbackupconfig": $list = $login->getList('centralbackupserver'); $list = get_namelist_from_objectlist($list); $vlist['centralbackupserver'] = array('s', add_disabled($list)); $vlist['internalnetworkip'] = null; $vlist['tmpdir'] = null; //$vlist['__v_updateall_button'] = array(); return $vlist; case "commandcenter": return $this->commandCenter($param); break; case "timezone": $vlist['timezone'] = array('s', pserver::getTimeZoneList()); return $vlist; case "ssl_key": $this->createPublicPrivate(); $this->setUpdateSubaction(); $vlist['text_public_key'] = array('t', null); return $vlist; case "switchprogram": $this->web_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'web'); $this->dns_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'dns'); $this->spam_driver = $gbl->getSyncClass($this->__masterserver, $this->nname, 'spam'); $vlist['web_driver'] = array('s', array('apache', 'lighttpd')); $vlist['dns_driver'] = array('s', array('bind', 'djbdns')); $vlist['spam_driver'] = array('s', array('spamassassin', 'bogofilter')); return $vlist; case "mysqlpasswordreset": $vlist['newpassword_f'] = null; return $vlist; case "importvps": $vlist['importvps'] = array('M', 'Import Vpses on this server?'); $vlist['__v_button'] = "Import"; return $vlist; case "importhypervmvps": $vlist['importvps'] = array('M', 'Import HyperVM Vpses on this server?'); $vlist['__v_button'] = "Import"; return $vlist; case "savevpsdata": $vlist['__v_button'] = "Save"; return $vlist; case "information": $sq = new Sqlite(null, 'client'); $res = $sq->getRowsWhere("cttype = 'wholesale'", null, array('nname')); $clientlist = get_namelist_from_arraylist($res); $vlist['description'] = null; $vlist['realhostname'] = null; if ($sgbl->isHyperVm()) { $list = get_namelist_from_objectlist($login->getList('datacenter')); if (!$list) { $list[] = '--no-dc--'; $this->datacenter = '--no-dc--'; } $vlist['datacenter'] = array('s', $list); $newclientlist = lx_array_merge(array(array('--unassigned--'), $clientlist)); if ($this->nname === 'localhost') { $vlist['clientname'] = array('M', $login->getKeyword('master_cannot_be_assigned')); } else { $vlist['clientname'] = array('s', $newclientlist); } } if ($sgbl->isHyperVm()) { $vlist['max_vps_num'] = null; } $this->setDefaultValue("load_threshold", "20"); $vlist['load_threshold'] = null; return $vlist; case "backupconfig": return $vlist; case "phpsmtp": $vlist['pserverconf_b_s_usesmtp'] = null; $vlist['pserverconf_b_s_smtpserver'] = null; $vlist['pserverconf_b_s_smtpport'] = null; $vlist['pserverconf_b_s_smtpuseauth'] = null; $vlist['pserverconf_b_s_smtpuser'] = null; $vlist['pserverconf_b_s_smtppass'] = null; return $vlist; case "cron_mailto": $vlist['cron_mailto'] = null; return $vlist; case "vpslist": $vlist['used_vpslist_f'] = array('M', $this->getUsed()); $vlist['__v_button'] = array(); return $vlist; case "showused": $res = $this->createUsedDomainList(); foreach ($res as $k => $v) { $var = "used_domainlist_{$k}_f"; $vlist[$var] = array('M', $this->{$var}); } $vlist['__v_button'] = array(); return $vlist; case "update": $vlist['nname'] = array('M', null); $vlist['password'] = null; return $vlist; case "poweroff": // --- issue 612 - Hide password in reboot / shutdown server // $vlist['retype_admin_p_f'] = null; $vlist['__v_button'] = 'Poweroff'; return $vlist; case "reboot": // --- issue 612 - Hide password in reboot / shutdown server // $vlist['retype_admin_p_f'] = null; $vlist['__v_button'] = 'Reboot'; return $vlist; case "dbpassword": $vlist['dbadmin'] = null; $vlist['dbpassword'] = null; return $vlist; } return parent::updateform($subaction, $param); }
function getDomainAlist(&$alist) { $rd = null; if ($this->default_domain && !$this->isDisabled('default_domain')) { $d = new Domain(null, null, $this->default_domain); $d->get(); if ($d->dbaction === 'clean' && $d->parent_clname === $this->getClName()) { $rd = $d; } } if (!$rd) { $sq = new Sqlite(null, 'domain'); $list = $sq->getRowsWhere("parent_clname = '{$this->getClName()}'", array('nname')); if ($list) { $list = get_namelist_from_arraylist($list); $dname = getFirstFromList($list); $d = new Domain(null, null, $dname); $d->get(); $rd = $d; } } if (!$rd) { return; } $this->getAlistFromChild($rd, $alist); try { $m = $this->getFromList('mailaccount', "postmaster@{$rd->nname}"); } catch (exception $e) { return; } $alist['__title_mailaccount'] = "Mailaccount {$m->nname}"; //$alist[] = "a=addform&c=mailaccount"; $malist = $m->createShowAlist($rslist); foreach ($malist as $k => $a) { if (csb($k, "__title")) { //$alist[$k] = $a; } else { if (is_string($a)) { $alist[] = "j[class]=mailaccount&j[nname]={$m->nname}&{$a}"; } else { if (!csb($a->url, "http")) { $a->url = "j[class]=mailaccount&j[nname]={$m->nname}&{$a->url}"; } $alist[] = $a; } } } }
function backup_main() { global $argc, $argv; global $gbl, $login, $ghtml; $gbl->__restore_flag = true; if ($argc === 1) { print "Usage: {$argv['0']} --restore/--list --accounts='domain-<domain1.com>,client-<client1>,domain-<domain2.com>' <backup-file> [--switchserverlist='oldserver1:newserver1,oldserver2:newserver2']\n Use --accounts=all to restore everything.\n"; exit; } initProgram("admin"); $object = $login; $opt = parse_opt($argv); if (isset($opt['class']) && isset($opt['name'])) { $object = new $opt['class'](null, null, $opt['name']); $object->get(); if ($object->dbaction === 'add') { log_error("{$opt['class']} doesnt exist"); print "{$opt['class']} doesnt exist\n"; exit; } } $class = $opt['class']; $name = $opt['name']; if (lx_core_lock("{$class}-{$name}.restore")) { print "Another Restore for the same class is happening..\n"; exit; } $backup = $object->getObject('lxbackup'); if (isset($opt['switchserverlist'])) { $sq = new Sqlite(null, "pserver"); $serverlist = $sq->getTable(); $serverlist = get_namelist_from_arraylist($serverlist); $server = $opt['switchserverlist']; $list = explode(",", $server); foreach ($list as $l) { if (!$l) { continue; } $q = explode(":", $l); $rlist[$q[0]] = $q[1]; if (!array_search_bool($q[1], $serverlist)) { print "The server {$q[1]} doesn't exist in the server system here\n"; exit; } } $param['switchserverlist'] = $rlist; dprint("\n"); } else { $param['switchserverlist'] = null; } /* if (!testAllServersWithMessage()) { $backup->restorestage = "Failed due to: could not connect to slave servers"; clearLxbackup($backup); exit; } */ $file = $opt['final']; //$param = get_variable($opt); if (isset($opt['list'])) { $gbl->__var_list_flag = true; $param['_accountselect'] = null; } else { if (isset($opt['restore'])) { $gbl->__var_list_flag = false; if (!isset($opt['accounts'])) { print "Restore option needs accounts that are to be restored. --accounts='domain-domain.com,client:clientname'... Use --list to find out all the domain/clients in the backup archive.\n"; clearLxbackup($backup); exit; } $account = $opt['accounts']; //$account = str_replace(":", "_s_vv_p_", $account); $account = str_replace(":", "-", $account); $accountlist = explode(",", $account); $param['_accountselect'] = $accountlist; } else { print "Usage: {$argv['0']} <--list/--restore --accounts=> <filename>\n"; clearLxbackup($backup); exit; } } if (isset($opt['priority']) && $opt['priority'] === 'low') { sleep(20); } dprintr($param); //dprint($file); try { $backup->doUpdateRestore($file, $param); $backup->restorestage = 'done'; } catch (exception $e) { log_error("Restore Failed. Reason: {$e->__full_message} \n"); print "Restore Failed. Reason: {$e->__full_message} \n"; $mess = $e->__full_message; mail($object->contactemail, "Restore Failed..", "Restore Failed for {$object->nname} with the Message {$mess}"); $backup->restorestage = "Restore failed due to {$mess}"; } clearLxbackup($backup); }
static function getIpaddressList($parent) { $db = new Sqlite($parent->__masterserver, 'ipaddress'); $res = $db->getTable(array('ipaddr')); $res = get_namelist_from_arraylist($res, 'ipaddr'); return $res; }
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); }
static function VerifyString($parent, $param) { $ip = $param['ipaddr']; if (!self::isValidIpaddress($ip)) { throw new lxexception("ipaddress_invalid", 'ipaddr'); } if ($param['gateway']) { if (!self::isValidIpaddress($param['gateway'])) { throw new lxexception("gateway_invalid", 'gateway'); } } if (!self::isValidIpaddress($param['netmask'])) { throw new lxexception("netmask_invalid", 'netmask'); } $sq = new Sqlite($parent->__masterserver, "ipaddress"); $res = $sq->getRowsWhere("syncserver = '{$parent->nname}'"); $list = get_namelist_from_arraylist($res, "ipaddr"); if (array_search_bool($ip, $list)) { throw new lxexception("ipaddress_already_configured", 'ipaddr'); } $ret = lxshell_return("ping", "-n", "-c", "1", "-w", "5", $ip); // If the return status is 1, the ping fail and nobody uses. But if return is 0, somebody is using the IP if (intval($ret) !== 1) { throw new lxexception($ret . 'Another host is using the IP ' . $ip . ' and it is responding to the IP ping. Please you will ensure to use an available IP to add.', 'ipaddr'); } }
static function VerifyString($parent, $param) { if (!self::isValidIpaddress($param['ipaddr'])) { throw new lxexception("ipaddress_invalid", 'ipaddr'); } if ($param['gateway']) { if (!self::isValidIpaddress($param['gateway'])) { throw new lxexception("gateway_invalid", 'gateway'); } } if (!self::isValidIpaddress($param['netmask'])) { throw new lxexception("netmask_invalid", 'netmask'); } $sq = new Sqlite($parent->__masterserver, "ipaddress"); $res = $sq->getRowsWhere("syncserver = '{$parent->nname}'"); $list = get_namelist_from_arraylist($res, "ipaddr"); if (array_search_bool($param['ipaddr'], $list)) { throw new lxexception("ipaddress_already_configured", 'ipaddr'); } $ret = lxshell_return("ping", "-n", "-c", "1", "-w", "5", $param['ipaddr']); if (!$ret) { throw new lxexception("some_other_host_uses_this_ip", 'ipaddr'); } }
function updatesaveVPSData($param) { $sq = new Sqlite(null, "vps"); $list = $sq->getRowsWhere("syncserver = '{$this->nname}'", array("nname")); $list = get_namelist_from_arraylist($list); foreach ($list as $l) { $vps = new VPS(null, $this->nname, $l); $vps->get(); $data[$l] = $vps; } $this->__var_vpsdata = $data; $param['some_f'] = 'a'; return $param; }
include_once "htmllib/lib/include.php"; initProgram('admin'); $slave = $argv[1]; $sq = new Sqlite(null, 'pserver'); if (!$sq->getRowsWhere("nname = '{$slave}'")) { print "No slave by {$slave}\n"; exit; } $driverapp = $gbl->getSyncClass(null, $slave, 'vps'); if ($driverapp !== 'openvz') { print "driver for {$slave} not openvz\n"; exit; } $shift = $argv[2]; if (!$shift) { $shift = 1000; } $sq = new Sqlite(null, 'vps'); $res = $sq->getRowsWhere("syncserver = '{$slave}'", array('nname')); $list = get_namelist_from_arraylist($res); foreach ($list as $l) { $o = new Vps(null, $slave, $l); $o->get(); $param['vpsid'] = $o->vpsid + $shift; print "Moving {$o->nname} from {$o->vpsid} to {$param['vpsid']}\n"; $o->updatechangeVPSid($param); $o->vpsid = $param['vpsid']; $o->setUpdateSubaction('changevpsid'); $o->was(); }
function getAccountList() { global $gbl, $sgbl, $login, $ghtml; $sq = new Sqlite(null, 'client'); $res = $sq->getRowsWhere("resourceplan_used = '{$this->nname}'", array('nname')); $total['client'] = get_namelist_from_arraylist($res); if ($sgbl->isHyperVm()) { $sq = new Sqlite(null, 'vps'); $res = $sq->getRowsWhere("resourceplan_used = '{$this->nname}'", array('nname')); $vlist = get_namelist_from_arraylist($res); $total['vps'] = $vlist; } return $total; }
static function createListSlist($parent) { $nlist['nname'] = null; $nlist['parent_clname'] = null; $nlist['dtype'] = array('s', array('--any--', 'maindomain', 'subdomain')); if (check_if_many_server()) { $sql = new Sqlite($parent->__masterserver, "pserver"); $res = $sql->getTable(array('nname')); $rs = get_namelist_from_arraylist($res); $rs = lx_array_merge(array(array('--any--'), $rs)); $nlist['webpserver'] = array('s', $rs); $nlist['mmailpserver'] = array('s', $rs); $nlist['dnspserver'] = array('s', $rs); } return $nlist; }
static function createListSlist($parent) { global $gbl, $sgbl, $login, $ghtml; $nlist['nname'] = null; $nlist['contactemail'] = null; $nlist['resourceplan_used'] = null; if ($sgbl->isKloxo()) { $nlist['default_domain'] = null; } $nlist['status'] = array('s', array('--any--', 'on', 'off')); $nlist['cttype'] = array('s', array('--any--', 'reseller', 'customer')); $nlist['traffic_usage_q'] = array('s', array('--any--', 'overquota', 'underquota')); if (check_if_many_server()) { $sql = new Sqlite($parent->__masterserver, "pserver"); $res = $sql->getTable(array('nname')); $rs = get_namelist_from_arraylist($res); $rs = lx_merge_good(array('--any--'), $rs); $nlist['websyncserver'] = array('s', $rs); $nlist['mmailsyncserver'] = array('s', $rs); //$nlist['coma_dnssyncserver_list'] = array('s', $rs); } return $nlist; }
function testAllServers() { $sq = new Sqlite(null, 'pserver'); $res = $sq->getTable(array('nname')); $nlist = get_namelist_from_arraylist($res); $flist = null; foreach ($nlist as $l) { try { rl_exec_get(null, $l, 'test_remote_func', null); } catch (exception $e) { $flist[$l] = $e->getMessage(); } } if ($flist) { throw new lxException($e->getMessage(), '', $flist); } }