Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 29 | Revision 33 | 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
		{
29 lars 18
			if(!is_null($ip))
19
			{
20
				$sql="SELECT * FROM ips WHERE ip='$ip'";
21
				$res=$db->query($sql);
22
				$row=$res->fetchRow();
23
				$this->ip=$row["ip"];
24
				$this->used=$row["used"];
25
				$this->dns=$row["dns"];
26
				$this->gw=$row["gs"];
27
			}
28
			else
29
			{
30
				$this->ip=$ip;
31
				$this->used=$used;
32
				$this->dns=$dns;
33
				$this->gw=$gw;
34
			}
26 lars 35
		}
36
 
37
		function toArray()
38
		{
39
			$out["ip"]=$this->ip;
40
			$out["dns"]=$this->dns;
41
			$out["gw"]=$this->gw;
42
			$out["used"]=$this->used;
43
			return $out;
44
		}
45
 
30 lars 46
		static function getIPs($used=1, $dns=0, $gw=0)
26 lars 47
		{
48
			global $db;
27 lars 49
			$sql="SELECT id, ip FROM ips WHERE used=$used AND dns=$dns AND gw=$gw";
26 lars 50
			$res=$db->query($sql);
51
			while($row=$res->fetchRow())
52
			{
29 lars 53
				$out[$row["id"]]=$row["ip"];
26 lars 54
			}
55
			return $out;
56
		}
57
	}
58
?>