Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 57 | Revision 61 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
26 lars 1
<?php
2
	//$Id$
3
/**
4
 * @author Lars Tiefland
5
 * @copyright 2007
6
 
7
 */
8
 
9
 
10
	class IP
11
	{
12
		protected $ip;
13
		protected $used;
14
		protected $dns;
15
		protected $gw;
29 lars 16
		function __construct($ip=NULL, $used=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"];
25
				$this->used=$row["used"];
26
				$this->dns=$row["dns"];
27
				$this->gw=$row["gs"];
28
			}
29
			else
30
			{
31
				$this->ip=$ip;
32
				$this->used=$used;
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;
43
			$out["used"]=$this->used;
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
 
43 lars 57
		static function getIPs($used=0, $dns=0, $gw=0)
26 lars 58
		{
59
			global $db;
27 lars 60
			$sql="SELECT id, ip FROM ips WHERE used=$used AND dns=$dns AND gw=$gw";
26 lars 61
			$res=$db->query($sql);
38 lars 62
			$out[-1]="Bitte w&auml;hlen!";
26 lars 63
			while($row=$res->fetchRow())
64
			{
29 lars 65
				$out[$row["id"]]=$row["ip"];
26 lars 66
			}
67
			return $out;
68
		}
69
	}
70
?>