Revision 168 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?php//$Id: ip.class.php 169 2011-07-10 19:12:37Z lars $/*** @author Lars Tiefland* @copyright 2007* @package openvz_admin**/class IP{protected $ip;protected $hn;protected $dns;protected $gw;function __construct( $ip = null, $hn = 0, $dns = 0, $gw = 0 ){global $db;if ( ! is_null( $ip ) ){$sql = "SELECT * FROM ips WHERE ip='$ip'";$res = $db->query( $sql );$row = $res->fetchRow();$this->ip = $row["ip"];$this->hn = $row["hn"];$this->dns = $row["dns"];$this->gw = $row["gs"];}else{$this->ip = $ip;$this->hn = $hn;$this->dns = $dns;$this->gw = $gw;}}function toArray(){$out["ip"] = $this->ip;$out["dns"] = $this->dns;$out["gw"] = $this->gw;$out["hn"] = $this->hn;return $out;}static function getIP( $ip_id ){global $db;$sql = "SELECT * FROM ips WHERE id=$ip_id";$res = $db->query( $sql );$row = $res->fetchRow();$ip = new IP( $row["ip"] );return $ip->toArray();}static function getIPs( $hn = 1, $used = 0, $dns = 0, $gw = 0 ){global $db;$sql = "SELECT id, ip FROM ips WHERE dns=$dns AND gw=$gw AND hn=$hn";$res = $db->query( $sql );$out[-1] = "Bitte wählen!";while ( $row = $res->fetchRow() ){if ( ! $used ){$sql2 = "SELECT * FROM host_2_ip WHERE ip='" . $row["id"] ."'";$res2 = $db->query( $sql2 );if ( ! $res2->numRows() ){$out[$row["id"]] = $row["ip"];}}}return $out;}}?>