Revision 109 | Revision 134 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?php//$Id: hn.class.php 133 2008-05-22 16:48:38Z lars $/*** @author Lars Tiefland* @copyright 2008* @package openvzadmin**/class HN{protected $id;protected $ip;protected $name;protected $ve_start;protected $ve_end;var $status;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"];$this->status=$this->getStatus();}else{$this->id=0;$this->ip=$ip;$this->name=$name;$this->ve_start=$ve_start;$this->ve_end=$ve_end;$this->status="online";}}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ählen!";while($row=$res->fetchRow()){$out[$row["id"]]=$row["h_name"];}return $out;}function getStatus(){$cmd="ping $this->name -c1";exec($cmd, $out, $ret);if($ret){$status="offline";}else{$status="online";}return $status;}}?>