public function __construct() { $this->error = new Error(); $this->user = '******'; $this->pass = '******'; $this->host = 'localhost'; $this->target_db = 'piercemoore'; try { if (!$this->_connect(true)) { throw new Exception("Connection to '{$this->host}' failed. Error: " . self::getError()); } if (!$this->_select($this->target_db)) { throw new Exception("Connection to database '{$this->target_db}' failed. Error: " . self::getError()); } } catch (Exception $e) { error::fullHalt($e->getMessage(), __FUNCTION__, __LINE__); } }
public function deleteIPBlock($start_ip, $type = 'block') { list($start_ip, $type) = db::prepare(func_get_args()); $ip_type = self::getIPType($start_ip); $start_ip = self::ipToLong($start_ip); switch ($type) { case 'block': $table = 'ip_blocks'; break; case 'allocation': $table = 'allocations'; break; default: $table = 'ip_blocks'; break; } $sql = "DELETE FROM {$table} WHERE `starting_ip` = '{$start_ip}'"; try { if (!($q = db::query($sql, 1, 1))) { throw new exception("Unable to delete IPv{$ip_type} block '" . self::longToIP($start_ip) . "'. MySQL reports: " . db::getError()); } else { return true; } } catch (exception $e) { error::fullHalt($e->getMessage(), __FUNCTION__, __LINE__); } return false; }