Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 30 | Revision 37 | 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
 
30 lars 47
		static function getIPs($used=1, $dns=0, $gw=0)
26 lars 48
		{
49
			global $db;
27 lars 50
			$sql="SELECT id, ip FROM ips WHERE used=$used AND dns=$dns AND gw=$gw";
26 lars 51
			$res=$db->query($sql);
52
			while($row=$res->fetchRow())
53
			{
29 lars 54
				$out[$row["id"]]=$row["ip"];
26 lars 55
			}
56
			return $out;
57
		}
58
	}
59
?>