Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 88 | Revision 133 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
78 lars 1
<?php
2
 
3
	//$Id: hn.class.php 109 2008-05-09 22:19:52Z lars $
109 lars 4
	/**
5
	 * @author Lars Tiefland
6
	 * @copyright 2008
7
	 * @package	openvzadmin
8
	 **/
78 lars 9
	class HN
10
	{
81 lars 11
		protected $id;
78 lars 12
		protected $ip;
13
		protected $name;
14
		protected $ve_start;
15
		protected $ve_end;
16
 
85 lars 17
		function __construct($ip=NULL,$name="",$ve_start="101",$ve_end="199")
78 lars 18
		{
81 lars 19
			global $db;
20
			if(!is_null($ip))
21
			{
22
				$sql="SELECT * FROM hardwarenodes WHERE ip='$ip'";
23
				$res=$db->query($sql);
24
				$row=$res->fetchRow();
25
				$this->id=$row["id"];
26
				$this->ip=$row["ip"];
27
				$this->name=$row["h_name"];
28
				$this->ve_start=$row["ve_start"];
29
				$this->ve_end=$row["ve_end"];
30
			}
31
			else
32
			{
33
				$this->id=0;
34
				$this->ip=$ip;
85 lars 35
				$this->name=$name;
36
				$this->ve_start=$ve_start;
37
				$this->ve_end=$ve_end;
81 lars 38
			}
78 lars 39
		}
40
 
81 lars 41
		function toArray()
42
		{
43
			$out["id"]=$this->id;
44
			$out["ip"]=$this->ip;
86 lars 45
			$out["name"]=$this->name;
46
			$out["ve_start"]=$this->ve_start;
47
			$out["ve_end"]=$this->ve_end;
81 lars 48
			return $out;
49
		}
50
 
51
		static function getHN($hn_id=1)
52
		{
53
			global $db;
84 lars 54
			$sql="SELECT * FROM hardwarenodes WHERE id=$hn_id";
81 lars 55
			$res=$db->query($sql);
56
			$row=$res->fetchRow();
57
			$hn=new HN($row["ip"]);
58
			return $hn->toArray();
59
		}
60
 
78 lars 61
		static function getHNs()
62
		{
63
			global $db;
80 lars 64
			$sql="SELECT id, h_name FROM hardwarenodes";
78 lars 65
			$res=$db->query($sql);
66
			$out[-1]="Bitte w&auml;hlen!";
67
			while($row=$res->fetchRow())
68
			{
80 lars 69
				$out[$row["id"]]=$row["h_name"];
78 lars 70
			}
71
			return $out;
72
		}
73
	}
74
?>