Subversion-Projekte lars-tiefland.openvz_admin

Revision

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