Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 43 | Revision 57 | 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
		{
49
			$sql="SELECT * FROM ips WHERE id=$ip_id";
50
			$res=$db->query($sql);
51
			$row=$res->fetchRow();
52
			$this->ip=$row["ip"];
53
			$this->used=$row["used"];
54
			$this->dns=$row["dns"];
55
			$this->gw=$row["gs"];
56
			return $this->toArray();
57
		}
58
 
43 lars 59
		static function getIPs($used=0, $dns=0, $gw=0)
26 lars 60
		{
61
			global $db;
27 lars 62
			$sql="SELECT id, ip FROM ips WHERE used=$used AND dns=$dns AND gw=$gw";
26 lars 63
			$res=$db->query($sql);
38 lars 64
			$out[-1]="Bitte w&auml;hlen!";
26 lars 65
			while($row=$res->fetchRow())
66
			{
29 lars 67
				$out[$row["id"]]=$row["ip"];
26 lars 68
			}
69
			return $out;
70
		}
71
	}
72
?>