fogproject  1.5.9
About: FOG is a Linux-based network computer cloning solution for Windows, Mac OSX and various Linux distributions that ties together a few open-source tools with a PHP-based web interface. FOG doesn’t use any boot disks, or CDs; everything is done via TFTP and PXE.
  Fossies Dox: fogproject-1.5.9.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

hostinfo.php
Go to the documentation of this file.
1 <?php
22 require '../commons/base.inc.php';
23 header('Content-Type: text/plain');
24 try {
25  FOGCore::getHostItem(false);
26  $Task = FOGCore::$Host->get('task');
27  if (FOGCore::$useragent) {
28  throw new Exception(_('Cannot view from browser'));
29  }
30  if (!$Task->isValid()) {
31  throw new Exception(_('Invalid tasking!'));
32  }
34  'TaskType',
35  $Task->get('typeID')
36  );
37  $Image = $Task->getImage();
39  if ($TaskType->isMulticast()) {
40  $MulticastSession = FOGCore::getClass(
41  'MulticastSession',
42  @max(
44  'MulticastSessionAssociation',
45  array('taskID' => $Task->get('id')),
46  'msID'
47  )
48  )
49  );
50  $taskImgID = $Task->get('imageID');
51  $mcImgID = $MulticastSession->get('image');
52  if ($taskImgID != $mcImgID) {
53  $Task
54  ->set('imageID', $mcImgID)
55  ->save();
57  ->set('imageID', $mcImgID);
58  $Image = new Image($mcImgID);
59  }
60  $port = $MulticastSession->get('port');
61  }
62  $StorageGroup = $StorageNode = null;
63  $HookManager->processEvent(
64  'BOOT_TASK_NEW_SETTINGS',
65  array(
66  'Host' => &FOGCore::$Host,
67  'StorageNode' => &$StorageNode,
68  'StorageGroup' => &$StorageGroup
69  )
70  );
71  if (!$StorageGroup || !$StorageGroup->isValid()) {
72  $StorageGroup = $Image->getStorageGroup();
73  }
74  if (!$StorageNode || !$StorageNode->isValid()) {
75  $StorageNode = $StorageGroup->getOptimalStorageNode();
76  }
77  $osid = $Image->get('osID');
78  $storage = sprintf(
79  '%s:/%s/%s',
80  trim($StorageNode->get('ip')),
81  trim($StorageNode->get('path'), '/'),
82  (
83  $TaskType->isCapture() ?
84  'dev/' :
85  ''
86  )
87  );
88  $storageip = FOGCore::resolveHostname(
89  $StorageNode
90  ->get('ip')
91  );
92  $img = $Image
93  ->get('path');
94  $imgFormat = $Image
95  ->get('format');
96  $imgType = $Image
97  ->getImageType()
98  ->get('type');
99  $imgPartitionType = $Image
100  ->getImagePartitionType()
101  ->get('type');
102  $imgid = $Image
103  ->get('id');
104  $PIGZ_COMP = $Image
105  ->get('compress');
106  $shutdown = intval(
107  (bool)$Task
108  ->get('shutdown')
109  );
110  list(
111  $ignorepg,
112  $pct,
113  $hostearly,
114  $ftp
116  'Service',
117  array(
118  'name' => array(
119  'FOG_CAPTUREIGNOREPAGEHIBER',
120  'FOG_CAPTURERESIZEPCT',
121  'FOG_CHANGE_HOSTNAME_EARLY',
122  'FOG_TFTP_HOST'
123  )
124  ),
125  'value',
126  false,
127  'AND',
128  'name',
129  false,
130  ''
131  );
132  $ftp = (
133  $StorageNode->isValid() ?
134  $StorageNode->get('ip') :
135  $ftp
136  );
137  if (!$pct < 100
138  && !$pct > 4
139  ) {
140  $pct = 5;
141  }
142  if ($TaskType->get('id') === 11) {
143  $winuser = $Task
144  ->get('passreset');
145  }
146  }
148  ->get('kernelDevice');
150  ->get('inventory');
151  $mac = $_REQUEST['mac'];
153  ->getMyMacs();
154  $clientMacs = array_filter(
155  (array)FOGCore::parseMacList(
156  implode('|', (array)$MACs),
157  false,
158  true
159  )
160  );
161  $pass = FOGCore::$Host->get('ADPass');
163  if ($test_base64 = base64_decode($passtest)) {
164  if (mb_detect_encoding($test_base64, 'utf-8', true)) {
165  $pass = $test_base64;
166  } elseif (mb_detect_encoding($passtest, 'utf-8', true)) {
167  $pass = $passtest;
168  }
169  }
170  $productKey = FOGCore::$Host->get('productKey');
172  if ($test_base64 = base64_decode($productKeytest)) {
173  if (mb_detect_encoding($test_base64, 'utf-8', true)) {
174  $productKey = $test_base64;
175  } elseif (mb_detect_encoding($productKeytest, 'utf-8', true)) {
177  }
178  }
179  $repFields = array(
180  // Imaging items to set
181  'mac' => $mac,
182  'ftp' => $ftp,
183  'osid' => $osid,
184  'storage' => $storage,
185  'storageip' => $storageip,
186  'img' => $img,
187  'imgFormat' => $imgFormat,
188  'imgType' => $imgType,
189  'imgPartitionType' => $imgPartitionType,
190  'imgid' => $imgid,
191  'PIGZ_COMP' => sprintf(
192  '-%s',
193  $PIGZ_COMP
194  ),
195  'shutdown' => $shutdown,
196  'hostearly' => $hostearly,
197  'pct' => $pct,
198  'ignorepg' => $ignorepg,
199  'winuser' => $winuser,
200  // Really only needed for multicast
201  'port' => $port,
202  // Implicit device to use
203  'fdrive' => $fdrive,
204  // Exposed other elements
205  'hostname' => FOGCore::$Host->get('name'),
206  'hostdesc' => FOGCore::$Host->get('description'),
207  'hostip' => FOGCore::$Host->get('ip'),
208  'hostimageid' => FOGCore::$Host->get('imageID'),
209  'hostbuilding' => FOGCore::$Host->get('building'),
210  'hostusead' => FOGCore::$Host->get('useAD'),
211  'hostaddomain' => FOGCore::$Host->get('ADDomain'),
212  'hostaduser' => FOGCore::$Host->get('ADUser'),
213  'hostadpass' => trim($pass),
214  'hostadou' => str_replace(';', '', FOGCore::$Host->get('ADOU')),
215  'hostproductkey' => trim($productKey),
216  'imagename' => $Image->get('name'),
217  'imagedesc' => $Image->get('description'),
218  'imageosid' => $osid,
219  'imagepath' => $img,
220  'primaryuser' => $Inventory->get('primaryUser'),
221  'othertag' => $Inventory->get('other1'),
222  'othertag1' => $Inventory->get('other2'),
223  'sysman' => $Inventory->get('sysman'),
224  'sysproduct' => $Inventory->get('sysproduct'),
225  'sysserial' => $Inventory->get('sysserial'),
226  'mbman' => $Inventory->get('mbman'),
227  'mbserial' => $Inventory->get('mbserial'),
228  'mbasset' => $Inventory->get('mbasset'),
229  'mbproductname' => $Inventory->get('mbproductname'),
230  'caseman' => $Inventory->get('caseman'),
231  'caseserial' => $Inventory->get('caseserial'),
232  'caseasset' => $Inventory->get('caseasset'),
233  );
234  $TaskArgs = preg_split(
235  '#[\s]+#',
236  trim($TaskType->get('kernelArgs'))
237  );
238  foreach ((array)$TaskArgs as $key => &$val) {
239  $val = trim($val);
240  if (strpos($val, '=') === false) {
241  continue;
242  }
243  $nums = explode('=', $val);
244  if (count($nums) > 0) {
245  $repFields[$nums[0]] = $nums[1];
246  }
247  unset($val);
248  }
249  $HookManager->processEvent(
250  'HOST_INFO_EXPOSE',
251  array(
252  'repFields' => &$repFields,
253  'Host'=>&FOGCore::$Host
254  )
255  );
256  foreach ((array)$repFields as $key => &$val) {
257  printf(
258  "[[ -z $%s ]] && export %s=%s\n",
259  $key,
260  $key,
261  escapeshellarg($val)
262  );
263  unset($val);
264  }
265 } catch (Exception $e) {
266  echo $e->getMessage();
267  exit(1);
268 }
exit
exit
Definition: download.php:102
TaskType\isCapture
isCapture($nums=false)
Definition: tasktype.class.php:150
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
$repFields
if($test_base64=base64_decode($productKeytest)) $repFields
Definition: hostinfo.php:179
$clientMacs
$clientMacs
Definition: hostinfo.php:154
Image
Definition: image.class.php:23
$val
$val
Definition: check_node_exists.php:25
$fdrive
if($TaskType->isInitNeededTasking()) $fdrive
Definition: hostinfo.php:147
TaskType\isInitNeededTasking
isInitNeededTasking($nums=false)
Definition: tasktype.class.php:180
FOGController\get
get($key='')
Definition: fogcontroller.class.php:207
$passtest
$passtest
Definition: hostinfo.php:162
$mac
$mac
Definition: hostinfo.php:151
FOGBase\resolveHostname
static resolveHostname($host)
Definition: fogbase.class.php:2497
$TaskType
if(FOGCore::$useragent) if(! $Task->isValid()) $TaskType
Definition: hostinfo.php:33
$MACs
$MACs
Definition: hostinfo.php:152
FOGBase\aesdecrypt
static aesdecrypt( $encdata, $key=false, $enctype='aes-128-cbc')
Definition: fogbase.class.php:1536
FOGBase\parseMacList
static parseMacList( $stringlist, $image=false, $client=false)
Definition: fogbase.class.php:1696
$productKeytest
$productKeytest
Definition: hostinfo.php:171
TaskType\isMulticast
isMulticast($nums=false)
Definition: tasktype.class.php:285
$Image
$Image
Definition: hostinfo.php:37
$Task
$Task
Definition: hostinfo.php:26
FOGBase\$useragent
static $useragent
Definition: fogbase.class.php:79
FOGBase\getSubObjectIDs
static getSubObjectIDs( $object='Host', $findWhere=array(), $getField='id', $not=false, $operator='AND', $orderBy='name', $groupBy=false, $filter='array_unique')
Definition: fogbase.class.php:2006
FOGBase\getHostItem
static getHostItem( $service=true, $encoded=false, $hostnotrequired=false, $returnmacs=false, $override=false, $mac=false)
Definition: fogbase.class.php:503
FOGBase\$Host
static $Host
Definition: fogbase.class.php:312
$TaskArgs
$TaskArgs
Definition: hostinfo.php:234
$productKey
if($test_base64=base64_decode($passtest)) $productKey
Definition: hostinfo.php:170
$Inventory
$Inventory
Definition: hostinfo.php:149
$pass
$pass
Definition: hostinfo.php:161