Subversion-Projekte lars-tiefland.openvz_admin

Revision

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