function getFreeIp($num) { if (!$num) { return; } if (!$this->isOn('freeflag')) { return null; } $res = null; $list = $this->getIndividualIpList(); $sq = new Sqlite(null, 'tmpipassign'); $ctime = time(); $ctime -= 100; $sq->rawQuery("delete from tmpipassign where (ddate + 0) < {$ctime}"); $pingip = null; foreach ($list as $l) { $p = $sq->getRowsWhere("nname = '{$l}'"); if ($p) { continue; } if (ippool::checkIfAlreadyAssigned('vps', $l)) { //log_log("ip_pool", "$l is already assigned skipping...\n"); continue; } if ($num <= 100) { try { full_validate_ipaddress($l); } catch (exception $e) { log_log("ip_pool", "Can ping {$l}... Skipping...\n"); $pingip[] = $l; continue; } } $res[] = $l; if (count($res) >= $num) { return $res; } } $writeflag = false; if (!$res) { $this->freeflag = 'dull'; $writeflag = true; } if ($pingip) { $writeflag = true; foreach ($pingip as $p) { $op = new ippoolpingip_a(null, null, $p); $this->ippoolpingip_a[$p] = $op; } } if ($writeflag) { $this->setUpdateSubaction(); $this->write(); } return $res; }
static function continueForm($parent, $class, $param, $continueaction) { global $gbl, $sgbl, $login, $ghtml; /* if(!eregi("^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$", $param['nname'])) { throw new lxException('invalid_domain_name', 'nname'); } */ if (!cse($param['nname'], ".vm")) { $param['nname'] .= ".vm"; } $param['nname'] = strtolower($param['nname']); if ($param['one_ipaddress_f']) { full_validate_ipaddress($param['one_ipaddress_f']); } /* if (!preg_match("/[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+]/i", $param['nname'])) { throw new lxException('domain_name_invalid', 'nname'); } */ if (isOn($param['send_welcome_f'])) { if (!$param['contactemail']) { throw new lxexception("sending_welcome_needs_contactemail", array('contactemail', 'send_welcome_f'), ''); } if (!validate_email($param['contactemail'])) { throw new lxexception("contactemail_is_not_valid_email_address", 'contactemail', ''); } } if ($param['resourceplan_f'] === 'continue_without_plan') { $vlist['__c_subtitle_quota'] = 'Quota'; $qvlist = getQuotaListForClass('vps'); $vlist = lx_merge_good($vlist, $qvlist); $ret['param'] = $param; $ret['variable'] = $vlist; $ret['action'] = "Add"; } else { $template = getFromAny(array($login, $parent), 'resourceplan', $param['resourceplan_f']); $param['use_resourceplan_f'] = 'on'; if (!$template) { throw new lxexception("the_template_doesnt_exist", 'resourceplan_f', $param['resourceplan_f']); } $ret['action'] = 'addnow'; $ret['param'] = $param; return $ret; } return $ret; }