/** * Confirm * * Verify that the IP's do not already exist in the pool, then confirm * the new IP address with the user before continuing. */ function confirm() { $begin_ip = ip2long($this->post['begin_address']); $end_ip = ip2long($this->post['end_address']); if ($end_ip == 0 || $end_ip < $begin_ip) { // If the beginning IP is not less than the ending IP, then only the // beginning IP is going to be added to the database. $end_ip = $begin_ip; } // Verify that there will be no duplicates for ($ip = $begin_ip; $ip <= $end_ip; $ip++) { try { load_IPAddressDBO($ip); throw new SWUserException("[DUPLICATE_IP]"); } catch (DBNoRowsFoundException $e) { } } // Store the IP's to be added to the database in the session for ($ip = $begin_ip; $ip <= $end_ip; $ip++) { $ip_dbo = new IPAddressDBO(); $ip_dbo->setIP($ip); $ip_dbo->setServerID($this->get['server']->getID()); $this->session['ip_dbo_array'][] = $ip_dbo; } $this->session['begin_ip'] = new IPAddressDBO(); $this->session['begin_ip']->setIP($begin_ip); $this->session['end_ip'] = new IPAddressDBO(); $this->session['end_ip']->setIP($end_ip); // Show the confirmation page $this->setTemplate("confirm"); }
/** * Load multiple IPAddressDBO's from database * * @param string $filter A WHERE clause * @param string $sortby Field name to sort results by * @param string $sortdir Direction to sort in (ASEC or DESC) * @param int $limit Limit the number of results * @param int $start Record number to start the results at * @return array Array of InvoiceDBO's */ function &load_array_IPAddressDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null) { $DB = DBConnection::getDBConnection(); // Build query $sql = $DB->build_select_sql("ipaddress", "*", $filter, $sortby, $sortdir, $limit, $start); // Run query if (!($result = @mysql_query($sql, $DB->handle()))) { // Query error throw new DBException(mysql_error($DB->handle())); } if (mysql_num_rows($result) == 0) { // No services found throw new DBNoRowsFoundException(); } // Build an array of DBOs from the result set $dbo_array = array(); while ($data = mysql_fetch_array($result)) { // Create and initialize a new DBO with the data from the DB $dbo = new IPAddressDBO(); $dbo->load($data); // Add HostingServiceDBO to array $dbo_array[] = $dbo; } return $dbo_array; }