1 <?php
3 class opsiware extends plugin
4 {
5 private $opsi;
6 private $SW_info;
7 private $HW_info;
8 private $hostId;
9 private $type = 0;
10 private $init_failed = FALSE;
12 public function __construct($config,$hostId)
13 {
14 $this->config = $config;
15 $this->opsi = new opsi($config);
16 $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
17 $this->init();
18 }
20 private function init()
21 {
22 $err = FALSE;
23 if(!$err){
24 $this->HW_info = $this->opsi->get_client_hardware($this->hostId);
25 $err |= $this->opsi->is_error();
26 }
27 if(!$err){
28 $this->SW_info = $this->opsi->get_client_software($this->hostId);
29 $err |= $this->opsi->is_error();
30 }
31 $this->init_failed = $err;
32 }
34 public function execute()
35 {
36 if(isset($_POST['reinit']) && $this->init_failed){
37 $this->init();
38 }
39 if(isset($_GET['type'])) $this->type = $_GET['type'];
41 $smarty = get_smarty();
42 $smarty->assign("init_failed",$this->init_failed);
43 if($this->init_failed){
44 $smarty->assign("type", $this->type);
45 $smarty->assign("message",$this->opsi->get_error());
46 return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
47 }
49 $smarty->assign("type", $this->type);
51 if($this->type == 1){
52 $smarty->assign("info", $this->HW_info);
53 }else{
54 $smarty->assign("info", $this->SW_info);
55 }
56 return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
57 }
58 }
59 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
60 ?>