Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 99 | Revision 162 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
26 lars 1
<?php
2
	//$Id: ip.class.php 109 2008-05-09 22:19:52Z lars $
109 lars 3
	/**
4
 	* @author Lars Tiefland
5
 	* @copyright 2007
6
 	* @package	openvz_admin
7
 	**/
26 lars 8
	class IP
9
	{
10
		protected $ip;
99 lars 11
		protected $hn;
26 lars 12
		protected $dns;
13
		protected $gw;
99 lars 14
		function __construct($ip=NULL, $hn=0, $dns=0, $gw=0)
26 lars 15
		{
33 lars 16
			global $db;
29 lars 17
			if(!is_null($ip))
18
			{
19
				$sql="SELECT * FROM ips WHERE ip='$ip'";
20
				$res=$db->query($sql);
21
				$row=$res->fetchRow();
22
				$this->ip=$row["ip"];
99 lars 23
				$this->hn=$row["hn"];
29 lars 24
				$this->dns=$row["dns"];
25
				$this->gw=$row["gs"];
26
			}
27
			else
28
			{
29
				$this->ip=$ip;
99 lars 30
				$this->hn=$hn;
29 lars 31
				$this->dns=$dns;
32
				$this->gw=$gw;
33
			}
26 lars 34
		}
35
 
36
		function toArray()
37
		{
38
			$out["ip"]=$this->ip;
39
			$out["dns"]=$this->dns;
40
			$out["gw"]=$this->gw;
99 lars 41
			$out["hn"]=$this->hn;
26 lars 42
			return $out;
43
		}
44
 
56 lars 45
		static function getIP($ip_id)
46
		{
57 lars 47
			global $db;
56 lars 48
			$sql="SELECT * FROM ips WHERE id=$ip_id";
49
			$res=$db->query($sql);
50
			$row=$res->fetchRow();
58 lars 51
			$ip=new IP($row["ip"]);
52
			return $ip->toArray();
56 lars 53
		}
54
 
99 lars 55
		static function getIPs($hn=1, $used=0, $dns=0, $gw=0)
26 lars 56
		{
57
			global $db;
99 lars 58
			$sql="SELECT id, ip FROM ips WHERE dns=$dns AND gw=$gw AND hn=$hn";
26 lars 59
			$res=$db->query($sql);
38 lars 60
			$out[-1]="Bitte w&auml;hlen!";
26 lars 61
			while($row=$res->fetchRow())
62
			{
90 lars 63
				if(!$used)
64
				{
92 lars 65
					$sql2="SELECT * FROM host_2_ip WHERE ip='".$row["id"]."'";
90 lars 66
					$res2=$db->query($sql2);
67
					if(!$res2->numRows())
68
					{
69
						$out[$row["id"]]=$row["ip"];
70
					}
71
				}
26 lars 72
			}
73
			return $out;
74
		}
75
	}
76
?>