Subversion-Projekte lars-tiefland.openvz_admin

Revision

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

<?php

        //$Id: hn.class.php 109 2008-05-09 22:19:52Z lars $
        /**
         * @author Lars Tiefland
         * @copyright 2008
         * @package     openvzadmin
         **/
        class HN
        {
                protected $id;
                protected $ip;
                protected $name;
                protected $ve_start;
                protected $ve_end;
                
                function __construct($ip=NULL,$name="",$ve_start="101",$ve_end="199")
                {
                        global $db;
                        if(!is_null($ip))
                        {
                                $sql="SELECT * FROM hardwarenodes WHERE ip='$ip'";
                                $res=$db->query($sql);
                                $row=$res->fetchRow();
                                $this->id=$row["id"];
                                $this->ip=$row["ip"];
                                $this->name=$row["h_name"];
                                $this->ve_start=$row["ve_start"];
                                $this->ve_end=$row["ve_end"];
                        }
                        else
                        {
                                $this->id=0;
                                $this->ip=$ip;
                                $this->name=$name;
                                $this->ve_start=$ve_start;
                                $this->ve_end=$ve_end;
                        }
                }
                
                function toArray()
                {
                        $out["id"]=$this->id;
                        $out["ip"]=$this->ip;
                        $out["name"]=$this->name;
                        $out["ve_start"]=$this->ve_start;
                        $out["ve_end"]=$this->ve_end;
                        return $out;
                }

                static function getHN($hn_id=1)
                {
                        global $db;
                        $sql="SELECT * FROM hardwarenodes WHERE id=$hn_id";
                        $res=$db->query($sql);
                        $row=$res->fetchRow();
                        $hn=new HN($row["ip"]);
                        return $hn->toArray();
                }
                
                static function getHNs()                
                {
                        global $db;
                        $sql="SELECT id, h_name FROM hardwarenodes";
                        $res=$db->query($sql);
                        $out[-1]="Bitte w&auml;hlen!";
                        while($row=$res->fetchRow())
                        {
                                $out[$row["id"]]=$row["h_name"];
                        }
                        return $out;
                }
        }
?>