Subversion-Projekte lars-tiefland.inventar

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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