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)  

imagemanagementpage.class.php
Go to the documentation of this file.
1 <?php
23 {
29  public $node = 'image';
37  public function __construct($name = '')
38  {
42  $this->name = 'Image Management';
46  parent::__construct($this->name);
50  $this->menu['multicast'] = sprintf(
51  '%s %s',
52  self::$foglang['Multicast'],
53  self::$foglang['Image']
54  );
58  $SizeServer = self::getSetting('FOG_FTP_IMAGE_SIZE');
62  global $id;
63  global $sub;
67  if ($id) {
71  $this->subMenu = array(
72  "$this->linkformat#image-gen" => self::$foglang['General'],
73  "$this->linkformat#image-storage" => sprintf(
74  '%s %s',
75  self::$foglang['Storage'],
76  self::$foglang['Group']
77  ),
78  $this->membership => self::$foglang['Membership'],
79  $this->delformat => self::$foglang['Delete'],
80  );
84  $this->notes = array(
85  self::$foglang['Images'] => $this->obj->get('name'),
86  self::$foglang['LastCaptured'] => $this->obj->get('deployed'),
87  self::$foglang['DeployMethod'] => (
88  $this->obj->get('format') ?
89  _('Partimage') :
90  _('Partclone')
91  ),
92  self::$foglang['ImageType'] => (
93  $this->obj->getImageType() ?
94  $this->obj->getImageType() :
95  self::$foglang['NoAvail']
96  ),
97  _('Primary Storage Group') => $this->obj->getStorageGroup()->get(
98  'name'
99  )
100  );
101  }
108  self::$HookManager
109  ->processEvent(
110  'SUB_MENULINK_DATA',
111  array(
112  'menu' => &$this->menu,
113  'submenu' => &$this->subMenu,
114  'id' => &$this->id,
115  'notes' => &$this->notes,
116  'object' => &$this->obj,
117  'linkformat' => &$this->linkformat,
118  'delformat' => &$this->delformat,
119  'membership' => &$this->membership
120  )
121  );
125  $this->headerData = array(
126  '',
127  '',
128  '<label for="toggler">'
129  . '<input type="checkbox" name="toggle-checkbox" '
130  . 'class="toggle-checkboxAction" id="toggler"/>'
131  . '</label>',
132  _('Image Name'),
133  _('Storage Group'),
134  _('Image Size: ON CLIENT'),
135  );
140  if ($SizeServer) {
141  array_push(
142  $this->headerData,
143  _('Image Size: ON SERVER')
144  );
145  }
149  array_push(
150  $this->headerData,
151  _('Captured')
152  );
156  $this->templates = array(
157  '${protected}',
158  '${enabled}',
159  '<label for="toggler1">'
160  . '<input type="checkbox" name="image[]" '
161  . 'value="${id}" class="toggle-action" id="'
162  . 'toggler1"/></label>',
163  '<a href="?node='
164  . $this->node
165  . '&sub=edit&id=${id}" '
166  . 'data-toggle="tooltip" data-placement="right" '
167  . 'title="'
168  . _('Edit')
169  . ': ${name} '
170  . _('Last captured')
171  . ': ${deployed}">${name} - ${id}</a>'
172  . '<br/>'
173  . '<small>${image_type}</small>'
174  . '<br/>'
175  . '<small>${type}</small>',
176  '${storageGroup}',
177  '${size}',
178  );
183  if ($SizeServer) {
184  array_push(
185  $this->templates,
186  '${serv_size}'
187  );
188  }
192  array_push(
193  $this->templates,
194  '${deployed}'
195  );
199  $this->attributes = array(
200  array(
201  'width' => 5,
202  'class' => 'filter-false'
203  ),
204  array(
205  'width' => 5,
206  'class' => 'filter-false'
207  ),
208  array(
209  'width' => 16,
210  'class' => 'filter-false'
211  ),
212  array(),
213  array(
214  'class' => 'col-xs-1'
215  ),
216  array(
217  'class' => 'col-xs-1'
218  ),
219  );
224  if ($SizeServer) {
225  array_push(
226  $this->attributes,
227  array(
228  'class' => 'col-xs-1'
229  )
230  );
231  }
235  array_push(
236  $this->attributes,
237  array('class' => 'col-xs-1')
238  );
246  self::$returnData = function (&$Image) use ($SizeServer) {
250  $imageSize = self::formatByteSize(
251  array_sum(
252  explode(
253  ':',
254  $Image->size
255  )
256  )
257  );
264  $id = $Image->id;
268  $name = $Image->name;
272  $description = $Image->description;
276  $storageGroup = $Image->storagegroupname;
280  $os = $Image->osname;
284  if (!$os) {
285  $os = _('Not set');
286  }
290  $date = $Image->deployed;
295  if (self::validDate($date)) {
296  $date = self::formatTime($date, 'Y-m-d H:i:s');
297  } else {
298  $date = _('Invalid date');
299  }
303  $imageType = $Image->imagetypename;
307  $imagePartitionType = $Image->imageparttypename;
311  $path = $Image->path;
312  $serverSize = 0;
316  if ($SizeServer) {
317  $serverSize = self::formatByteSize($Image->srvsize);
318  }
324  if ($Image->protected < 1) {
325  $protected = sprintf(
326  '<i class="fa fa-unlock fa-1x icon hand" '
327  . 'data-toggle="tooltip" data-placement="right" '
328  . 'title="%s"></i>',
329  _('Not protected')
330  );
331  } else {
332  $protected = sprintf(
333  '<i class="fa fa-lock fa-1x icon hand" '
334  . 'data-toggle="tooltip" data-placement="right" '
335  . 'title="%s"></i>',
336  _('Protected')
337  );
338  }
342  if ($Image->isEnabled) {
343  $enabled = '<i class="fa fa-check-circle green" '
344  . 'title="'
345  . _('Enabled')
346  . '" data-toggle="tooltip" data-placement="top">'
347  . '</i>';
348  } else {
349  $enabled
350  = '<i class="fa fa-times-circle red" '
351  . 'title="'
352  . _('Disabled')
353  . '" data-toggle="tooltip" data-placement="top">'
354  . '</i>';
355  }
360  switch ($Image->format) {
361  case 0:
362  $type = _('Partclone Compressed');
363  break;
364  case 1:
365  $type = _('Partimage');
366  break;
367  case 2:
368  $type = _('Partclone Compressed 200MiB split');
369  break;
370  case 3:
371  $type = _('Partclone Uncompressed');
372  break;
373  case 4:
374  $type = _('Partclone Uncompressed 200MiB split');
375  break;
376  case 5:
377  $type = _('ZSTD Compressed');
378  break;
379  case 6:
380  $type = _('ZSTD Compressed 200MiB split');
381  break;
382  }
386  $this->data[] = array(
387  'id' => $id,
388  'name' => $name,
389  'description' => $description,
390  'storageGroup' => $storageGroup,
391  'os' => $os,
392  'deployed' => $date,
393  'size' => $imageSize,
394  'serv_size' => $serverSize,
395  'image_type' => $imageType,
396  'image_partition_type' => $imagePartitionType,
397  'protected' => $protected,
398  'type' => $type,
399  'enabled' => $enabled
400  );
404  unset(
405  $id,
406  $name,
407  $description,
408  $storageGroup,
409  $os,
410  $date,
411  $imageSize,
412  $serverSize,
413  $imageType,
414  $imagePartitionType,
415  $protected,
416  $type,
417  $Image
418  );
419  };
420  }
427  public function add()
428  {
433  $storagegroup = (int)filter_input(INPUT_POST, 'storagegroup');
434  $os = (int)filter_input(INPUT_POST, 'os');
435  $imagetype = (int)filter_input(INPUT_POST, 'imagetype');
436  $imagepartitiontype = (int)filter_input(INPUT_POST, 'imagepartitiontype');
437  $compress = (int)filter_input(INPUT_POST, 'compress');
438  $imagemanage = filter_input(INPUT_POST, 'imagemanage');
439  $name = filter_input(INPUT_POST, 'name');
440  $desc = filter_input(INPUT_POST, 'description');
441  $file = filter_input(INPUT_POST, 'file');
445  $this->title = _('New Image');
449  $this->attributes = array(
450  array('class' => 'col-xs-4'),
451  array('class' => 'col-xs-8 form-group'),
452  );
456  $this->templates = array(
457  '${field}',
458  '${input}',
459  );
463  if ($storagegroup > 0) {
464  $sgID = $storagegroup;
465  } else {
466  $sgID = @min(self::getSubObjectIDs('StorageGroup'));
467  }
471  $StorageGroup = new StorageGroup($sgID);
472  $StorageGroups = self::getClass('StorageGroupManager')
473  ->buildSelectBox(
474  $sgID,
475  '',
476  'id'
477  );
481  $StorageNode = $StorageGroup->getMasterStorageNode();
482  $OSs = self::getClass('OSManager')
483  ->buildSelectBox($os);
484  $itID = 1;
485  if ($imagetype > 0) {
486  $itID = $imagetype;
487  }
488  $ImageTypes = self::getClass('ImageTypeManager')
489  ->buildSelectBox(
490  $itID,
491  '',
492  'id'
493  );
494  $iptID = 1;
495  if ($imagepartitiontype > 0) {
496  $iptID = $imagepartitiontype;
497  } else {
498  $iptID = 1;
499  }
500  $ImagePartitionTypes = self::getClass('ImagePartitionTypeManager')
501  ->buildSelectBox(
502  $iptID,
503  '',
504  'id'
505  );
506  $compression = self::getSetting('FOG_PIGZ_COMP');
507  if ($compress < 0 || $compress > 23) {
508  $compression = $compress;
509  }
510  if (!isset($imagemanage)) {
511  $imagemanage = self::getSetting('FOG_IMAGE_COMPRESSION_FORMAT_DEFAULT');
512  }
513  $format = sprintf(
514  '<select name="imagemanage" id="imagemanage" class="form-control">'
515  . '<option value="0"%s>%s</option>'
516  . '<option value="1"%s>%s</option>'
517  . '<option value="2"%s>%s</option>'
518  . '<option value="3"%s>%s</option>'
519  . '<option value="4"%s>%s</option>'
520  . '<option value="5"%s>%s</option>'
521  . '<option value="6"%s>%s</option>'
522  . '</select>',
523  (
524  $imagemanage == 0 ?
525  ' selected' :
526  ''
527  ),
528  _('Partclone Gzip'),
529  (
530  $imagemanage == 1 ?
531  ' selected' :
532  ''
533  ),
534  _('Partimage'),
535  (
536  $imagemanage == 2 ?
537  ' selected' :
538  ''
539  ),
540  _('Partclone Gzip Split 200MiB'),
541  (
542  $imagemanage == 3 ?
543  ' selected' :
544  ''
545  ),
546  _('Partclone Uncompressed'),
547  (
548  $imagemanage == 4 ?
549  ' selected' :
550  ''
551  ),
552  _('Partclone Uncompressed Split 200MiB'),
553  (
554  !isset($imagemanage) || $imagemanage == 5 ?
555  ' selected' :
556  ''
557  ),
558  _('Partclone Zstd'),
559  (
560  $imagemanage == 6 ?
561  ' selected' :
562  ''
563  ),
564  _('Partclone Zstd Split 200MiB')
565  );
566  $fields = array(
567  '<label for="iName">'
568  . _('Image Name')
569  . '</label>' => '<div class="input-group">'
570  . '<input class="form-control imagename-input" type="text" '
571  . 'name="name" id="iName" '
572  . 'value="'
573  . $name
574  . '"/>'
575  . '</div>',
576  '<label for="description">'
577  . _('Image Description')
578  . '</label>' => '<div class="input-group">'
579  . '<textarea name="description" class="form-control imagedesc-input" '
580  . 'id="description">'
581  . $description
582  . '</textarea>',
583  '<label for="storagegroup">'
584  . _('Storage Group')
585  . '</label>' => $StorageGroups,
586  '<label for="os">'
587  . _('Operating System')
588  . '</label>' => $OSs,
589  '<label for="iFile">'
590  . _('Image Path')
591  . '</label>' => '<div class="input-group">'
592  . '<span class="input-group-addon">'
593  . $StorageNode->get('path')
594  . '/'
595  . '</span>'
596  . '<input type="text" class="form-control imagefile-input" '
597  . 'name="file" id="iFile" '
598  . 'value="'
599  . $file
600  . '"/>',
601  '<label for="imagetype">'
602  . _('Image Type')
603  . '</label>&nbsp;&nbsp;<i class="icon fa fa-info-circle '
604  . 'fa-lg hand" data-toggle="tooltip" data-placement="right" '
605  . 'data-html="true" data-trigger="click" style="size:+3; color:#337ab7;" '
606  . 'title="Image Type is a very important setting and can have '
607  . 'major impact on how your imaging works or fails. Please read '
608  . 'more about the different image types and how to use those '
609  . '<a href=\'https://wiki.fogproject.org/wiki/index.php?title=Managing_FOG#Images\' '
610  . 'target=\'_blank\'>in our wiki</a> before you chose!"></i>' => $ImageTypes,
611  '<label for="imagepartitiontype">'
612  . _('Partition')
613  . '</label>' => $ImagePartitionTypes,
614  '<label for="isEnabled">'
615  . _('Image Enabled')
616  . '</label>' => '<input type="checkbox" '
617  . 'name="isEnabled" id="isEnabled" checked/>',
618  '<label for="toRep">'
619  . _('Replicate?')
620  . '</label>' => '<input type="checkbox" '
621  . 'name="toReplicate" id="toRep" checked/>',
622  '<label for="pigzcomp">'
623  . _('Compression')
624  . '</label>' => '<div class="col-xs-8">'
625  . '<div class="rangegen pigz"></div>'
626  . '</div>'
627  . '<div class="col-xs-2">'
628  . '<div class="input-group">'
629  . '<input type="text" name="compress" class="form-control '
630  . 'showVal pigz" maxsize="2" value="'
631  . $compression
632  . '" id="pigzcomp" readonly/>'
633  . '</div>'
634  . '</div>',
635  '<label for="imagemanage">'
636  . _('Image Manager')
637  . '</label>' => $format,
638  '<label for="add">'
639  . _('Create Image')
640  . '</label>' => '<button class="btn btn-info btn-block" type="submit" '
641  . 'id="add" name="add">'
642  . _('Add')
643  . '</button>'
644  );
645  self::$HookManager
646  ->processEvent(
647  'IMAGE_FIELDS',
648  array(
649  'fields' => &$fields,
650  'Image' => self::getClass('Image')
651  )
652  );
653  array_walk($fields, $this->fieldsToData);
654  unset($fields);
655  self::$HookManager
656  ->processEvent(
657  'IMAGE_ADD',
658  array(
659  'headerData' => &$this->headerData,
660  'data' => &$this->data,
661  'templates' => &$this->templates,
662  'attributes' => &$this->attributes
663  )
664  );
665  echo '<div class="col-xs-9">';
666  echo '<div class="panel panel-info">';
667  echo '<div class="panel-heading text-center">';
668  echo '<h4 class="title">';
669  echo $this->title;
670  echo '</h4>';
671  echo '</div>';
672  echo '<div class="panel-body">';
673  echo '<form class="form-horizontal" method="post" action="'
674  . $this->formAction
675  . '">';
676  $this->render(12);
677  echo '</form>';
678  echo '</div>';
679  echo '</div>';
680  echo '</div>';
681  }
687  public function addPost()
688  {
689  self::$HookManager->processEvent('IMAGE_ADD_POST');
690  $file = trim(
691  filter_input(INPUT_POST, 'file')
692  );
693  $name = trim(
694  filter_input(INPUT_POST, 'name')
695  );
696  $desc = trim(
697  filter_input(INPUT_POST, 'description')
698  );
699  $storagegroup = (int)filter_input(INPUT_POST, 'storagegroup');
700  $os = (int)filter_input(INPUT_POST, 'os');
701  $imagetype = (int)filter_input(INPUT_POST, 'imagetype');
702  $imagepartitiontype = (int)filter_input(INPUT_POST, 'imagepartitiontype');
703  $imagemanage = (int)filter_input(INPUT_POST, 'imagemanage');
704  $compress = (int)filter_input(INPUT_POST, 'compress');
705  $isenabled = (int)isset($_POST['isEnabled']);
706  $torep = (int)isset($_POST['toReplicate']);
707  try {
708  if (self::getClass('ImageManager')->exists($name)) {
709  throw new Exception(_('An image already exists with this name!'));
710  }
711  if ($file == 'postdownloadscripts'
712  || $file == 'dev'
713  ) {
714  throw new Exception(
715  sprintf(
716  '%s, %s.',
717  _('Please choose a different name'),
718  _('this one is reserved for FOG')
719  )
720  );
721  }
722  if (self::getClass('ImageManager')->exists($file, '', 'path')) {
723  throw new Exception(
724  sprintf(
725  '%s, %s.',
726  _('Please choose a different path'),
727  _('this one is already in use by another image')
728  )
729  );
730  }
731  $Image = self::getClass('Image')
732  ->set('name', $name)
733  ->set('description', $desc)
734  ->set('osID', $os)
735  ->set('path', $file)
736  ->set('imageTypeID', $imagetype)
737  ->set('imagePartitionTypeID', $imagepartitiontype)
738  ->set('compress', $compress)
739  ->set('isEnabled', $isenabled)
740  ->set('format', $imagemanage)
741  ->set('toReplicate', $torep)
742  ->addGroup($storagegroup);
743  if (!$Image->save()) {
744  throw new Exception(_('Add image failed!'));
745  }
750  $Image->setPrimaryGroup($storagegroup);
751  $hook = 'IMAGE_ADD_SUCCESS';
752  $msg = json_encode(
753  array(
754  'msg' => _('Image added!'),
755  'title' => _('Image Create Success')
756  )
757  );
758  } catch (Exception $e) {
759  $hook = 'IMAGE_ADD_FAIL';
760  $msg = json_encode(
761  array(
762  'error' => $e->getMessage(),
763  'title' => _('Image Create Fail')
764  )
765  );
766  }
767  self::$HookManager
768  ->processEvent(
769  $hook,
770  array('Image' => &$Image)
771  );
772  unset($Image);
773  echo $msg;
774  exit;
775  }
781  public function imageGeneral()
782  {
783  unset(
784  $this->data,
785  $this->form,
786  $this->templates,
787  $this->attributes,
788  $this->headerData
789  );
790  $this->attributes = array(
791  array('class' => 'col-xs-4'),
792  array('class' => 'col-xs-8 form-group'),
793  );
794  $this->templates = array(
795  '${field}',
796  '${input}',
797  );
798  $StorageNode = $this
799  ->obj
800  ->getStorageGroup()
801  ->getMasterStorageNode();
802  $osID = (int)filter_input(INPUT_POST, 'os');
803  if ($osID < 1) {
804  $osID = $this->obj->get('osID');
805  }
806  $OSs = self::getClass('OSManager')
807  ->buildSelectBox(
808  $osID,
809  '',
810  'id'
811  );
812  $itID = (int)filter_input(INPUT_POST, 'imagetype');
813  if ($itID < 1) {
814  $itID = $this->obj->get('imageTypeID');
815  }
816  $ImageTypes = self::getClass('ImageTypeManager')
817  ->buildSelectBox(
818  $itID,
819  '',
820  'id'
821  );
822  $iptID = (
823  filter_input(INPUT_POST, 'imagepartitiontype') ?: $this->obj->get(
824  'imagePartitionTypeID'
825  )
826  );
827  $ImagePartitionTypes = self::getClass('ImagePartitionTypeManager')
828  ->buildSelectBox(
829  $iptID,
830  '',
831  'id'
832  );
833  $compression = (
834  filter_input(INPUT_POST, 'compress') ?: $this->obj->get('compress')
835  );
836  $imagemanage = (
837  filter_input(INPUT_POST, 'imagemanage') ?: $this->obj->get('format')
838  );
839  $name = (
840  filter_input(INPUT_POST, 'name') ?: $this->obj->get('name')
841  );
842  $desc = (
843  filter_input(INPUT_POST, 'description') ?: $this->obj->get('description')
844  );
845  $isen = (int)isset($_POST['isEnabled']);
846  if (!$isen) {
847  $isen = $this->obj->get('isEnabled');
848  }
849  if ($isen) {
850  $isen = ' checked';
851  } else {
852  $isen = '';
853  }
854  $torep = (int)isset($_POST['toReplicate']);
855  if (!$torep) {
856  $torep = $this->obj->get('toReplicate');
857  }
858  if ($torep) {
859  $torep = ' checked';
860  } else {
861  $torep = '';
862  }
863  $toprot = (int)isset($_POST['protected_image']);
864  if (!$toprot) {
865  $toprot = $this->obj->get('protected');
866  }
867  if ($toprot) {
868  $toprot = ' checked';
869  } else {
870  $toprot = '';
871  }
872  $file = trim(
873  filter_input(INPUT_POST, 'file')
874  );
875  if (!$file) {
876  $file = $this->obj->get('path');
877  }
878  $format = sprintf(
879  '<select name="imagemanage" id="imagemanage" class="form-control">'
880  . '<option value="0"%s>%s</option>'
881  . '<option value="1"%s>%s</option>'
882  . '<option value="2"%s>%s</option>'
883  . '<option value="3"%s>%s</option>'
884  . '<option value="4"%s>%s</option>'
885  . '<option value="5"%s>%s</option>'
886  . '<option value="6"%s>%s</option>'
887  . '</select>',
888  (
889  !$imagemanage ?
890  ' selected' :
891  ''
892  ),
893  _('Partclone Gzip'),
894  (
895  $imagemanage == 1 ?
896  ' selected' :
897  ''
898  ),
899  _('Partimage'),
900  (
901  $imagemanage == 2 ?
902  ' selected' :
903  ''
904  ),
905  _('Partclone Gzip Split 200MiB'),
906  (
907  $imagemanage == 3 ?
908  ' selected' :
909  ''
910  ),
911  _('Partclone Uncompressed'),
912  (
913  $imagemanage == 4 ?
914  ' selected' :
915  ''
916  ),
917  _('Partclone Uncompressed Split 200MiB'),
918  (
919  $imagemanage == 5 ?
920  ' selected' :
921  ''
922  ),
923  _('Partclone Zstd'),
924  (
925  $imagemanage == 6 ?
926  ' selected' :
927  ''
928  ),
929  _('Partclone Zstd Split 200MiB')
930  );
931  $fields = array(
932  '<label for="iName">'
933  . _('Image Name')
934  . '</label>' => '<div class="input-group">'
935  . '<input class="form-control imagename-input" type="text" '
936  . 'name="name" id="iName" '
937  . 'value="'
938  . $name
939  . '"/>'
940  . '</div>',
941  '<label for="description">'
942  . _('Image Description')
943  . '</label>' => '<div class="input-group">'
944  . '<textarea name="description" class="form-control imagedesc-input" '
945  . 'id="description">'
946  . $desc
947  . '</textarea>',
948  '<label for="os">'
949  . _('Operating System')
950  . '</label>' => $OSs,
951  '<label for="iFile">'
952  . _('Image Path')
953  . '</label>' => '<div class="input-group">'
954  . '<span class="input-group-addon">'
955  . $StorageNode->get('path')
956  . '/'
957  . '</span>'
958  . '<input type="text" class="form-control imagefile-input" '
959  . 'name="file" id="iFile" '
960  . 'value="'
961  . $file
962  . '"/>',
963  '<label for="imagetype">'
964  . _('Image Type')
965  . '</label>&nbsp;&nbsp;<i class="icon fa fa-info-circle '
966  . 'fa-lg hand" data-toggle="tooltip" data-placement="right" '
967  . 'data-html="true" data-trigger="click" style="size:+3; color:#337ab7;" '
968  . 'title="Image Type is a very important setting and can have '
969  . 'major impact on how your imaging works or fails. Please read '
970  . 'more about the different image types and how to use those '
971  . '<a href=\'https://wiki.fogproject.org/wiki/index.php?title=Managing_FOG#Images\' '
972  . 'target=\'_blank\'>in our wiki</a> before you chose!"></i>' => $ImageTypes,
973  '<label for="imagepartitiontype">'
974  . _('Partition')
975  . '</label>' => $ImagePartitionTypes,
976  '<label for="protectimage">'
977  . _('Protected')
978  . '</label>' => '<input type="checkbox" '
979  . 'name="protected_image" id="protectimage"'
980  . $toprot
981  . '/>',
982  '<label for="isEnabled">'
983  . _('Image Enabled')
984  . '</label>' => '<input type="checkbox" '
985  . 'name="isEnabled" id="isEnabled"'
986  . $isen
987  . '/>',
988  '<label for="toRep">'
989  . _('Replicate?')
990  . '</label>' => '<input type="checkbox" '
991  . 'name="toReplicate" id="toRep" '
992  . $torep
993  . '/>',
994  '<label for="pigzcomp">'
995  . _('Compression')
996  . '</label>' => '<div class="col-xs-8">'
997  . '<div class="rangegen pigz"></div>'
998  . '</div>'
999  . '<div class="col-xs-2">'
1000  . '<div class="input-group">'
1001  . '<input type="text" name="compress" class="form-control '
1002  . 'showVal pigz" maxsize="2" value="'
1003  . $compression
1004  . '" id="pigzcomp" readonly/>'
1005  . '</div>'
1006  . '</div>',
1007  '<label for="imagemanage">'
1008  . _('Image Manager')
1009  . '</label>' => $format,
1010  '<label for="updategen">'
1011  . _('Make Changes?')
1012  . '</label>' => '<button class="btn btn-info btn-block" type="submit" '
1013  . 'id="updategen" name="update">'
1014  . _('Update')
1015  . '</button>'
1016  );
1017  self::$HookManager
1018  ->processEvent(
1019  'IMAGE_FIELDS',
1020  array(
1021  'fields' => &$fields,
1022  'Image' => &$this->obj
1023  )
1024  );
1025  array_walk($fields, $this->fieldsToData);
1026  self::$HookManager
1027  ->processEvent(
1028  'IMAGE_EDIT',
1029  array(
1030  'headerData' => &$this->headerData,
1031  'data' => &$this->data,
1032  'templates' => &$this->templates,
1033  'attributes' => &$this->attributes
1034  )
1035  );
1036  echo '<!-- General -->';
1037  echo '<div class="tab-pane fade in active" id="image-gen">';
1038  echo '<div class="panel panel-info">';
1039  echo '<div class="panel-heading text-center">';
1040  echo '<h4 class="title">';
1041  echo _('Image General');
1042  echo '</h4>';
1043  echo '</div>';
1044  echo '<div class="panel-body">';
1045  echo '<form class="form-horizontal" method="post" action="'
1046  . $this->formAction
1047  . '&tab=image-gen">';
1048  $this->render(12);
1049  echo '</form>';
1050  echo '</div>';
1051  echo '</div>';
1052  echo '</div>';
1053  unset(
1054  $this->data,
1055  $this->form,
1056  $this->templates,
1057  $this->attributes,
1058  $this->headerData
1059  );
1060  }
1066  public function imageStoragegroups()
1067  {
1068  unset(
1069  $this->data,
1070  $this->form,
1071  $this->templates,
1072  $this->attributes,
1073  $this->headerData
1074  );
1075  $this->headerData = array(
1076  '<label for="toggler2">'
1077  . '<input type="checkbox" name="toggle-checkboxgroup1" '
1078  . 'class="toggle-checkbox1" id="toggler2"/>'
1079  . '</label>',
1080  _('Storage Group Name')
1081  );
1082  $this->templates = array(
1083  '<label for="sg-${storageGroup_id}">'
1084  . '<input type="checkbox" name="storagegroup[]" class='
1085  . '"toggle-group" id="sg-${storageGroup_id}" '
1086  . 'value="${storageGroup_id}"/>'
1087  . '</label>',
1088  '<a href="?node=storage&editStorageGroup&id=${storageGroup_id}">'
1089  . '${storageGroup_name}'
1090  . '</a>'
1091  );
1092  $this->attributes = array(
1093  array(
1094  'class' => 'filter-false',
1095  'width' => 16
1096  ),
1097  array(),
1098  );
1099  Route::listem('storagegroup');
1100  $StorageGroups = json_decode(
1101  Route::getData()
1102  );
1103  $StorageGroups = $StorageGroups->storagegroups;
1104  foreach ((array)$StorageGroups as &$StorageGroup) {
1105  $groupinme = in_array(
1106  $StorageGroup->id,
1107  $this->obj->get('storagegroups')
1108  );
1109  if ($groupinme) {
1110  continue;
1111  }
1112  $this->data[] = array(
1113  'storageGroup_id' => $StorageGroup->id,
1114  'storageGroup_name' => $StorageGroup->name,
1115  );
1116  unset($StorageGroup);
1117  }
1118  self::$HookManager->processEvent(
1119  'IMAGE_ADD_STORAGE_GROUP',
1120  array(
1121  'data' => &$this->data,
1122  'headerData' => &$this->headerData,
1123  'templates' => &$this->templates,
1124  'attributes' => &$this->attributes
1125  )
1126  );
1127  echo '<!-- Storage Groups -->';
1128  echo '<div class="tab-pane fade" id="image-storage">';
1129  echo '<div class="panel panel-info">';
1130  echo '<div class="panel-heading text-center">';
1131  echo '<h4 class="title">';
1132  echo _('Image Storage Groups');
1133  echo '</h4>';
1134  echo '</div>';
1135  echo '<div class="panel-body">';
1136  echo '<form class="form-horizontal" method="post" action="'
1137  . $this->formAction
1138  . '&tab=image-storage">';
1139  if (is_array($this->data) && count($this->data)) {
1140  echo '<div class="text-center">';
1141  echo '<div class="checkbox">';
1142  echo '<label for="groupMeShow">';
1143  echo '<input type="checkbox" name="groupMeShow" '
1144  . 'id="groupMeShow"/>';
1145  echo _('Check here to see what storage groups can be added');
1146  echo '</label>';
1147  echo '</div>';
1148  echo '</div>';
1149  echo '<br/>';
1150  echo '<div class="hiddeninitially groupNotInMe panel panel-info" '
1151  . 'id="groupNotInMe">';
1152  echo '<div class="panel-heading text-center">';
1153  echo '<h4 class="title">';
1154  echo _('Add Storage Groups');
1155  echo '</h4>';
1156  echo '</div>';
1157  echo '<div class="panel-body">';
1158  $this->render(12);
1159  echo '<div class="form-group">';
1160  echo '<label for="updategroups" class="control-label col-xs-4">';
1161  echo _('Add selected storage groups');
1162  echo '</label>';
1163  echo '<div class="col-xs-8">';
1164  echo '<button type="submit" name="updategroups" class='
1165  . '"btn btn-info btn-block" id="updategroups">'
1166  . _('Add')
1167  . '</button>';
1168  echo '</div>';
1169  echo '</div>';
1170  echo '</div>';
1171  echo '</div>';
1172  }
1173  unset(
1174  $this->data,
1175  $this->headerData,
1176  $this->templates,
1177  $this->attributes
1178  );
1179  $this->headerData = array(
1180  '<label for="toggler3">'
1181  . '<input type="checkbox" name="toggle-checkbox" '
1182  . 'class="toggle-checkboxAction" id="toggler3"/>'
1183  . '</label>',
1184  '',
1185  _('Storage Group Name')
1186  );
1187  $this->templates = array(
1188  '<label for="sg1-${storageGroup_id}">'
1189  . '<input type="checkbox" name="storagegroup-rm[]" class='
1190  . '"toggle-group" id="sg1-${storageGroup_id}" '
1191  . 'value="${storageGroup_id}"/>'
1192  . '</label>',
1193  '<div class="radio">'
1194  . '<input type="radio" class="default" '
1195  . 'name="primary" id="group${storageGroup_id}" '
1196  . 'value="${storageGroup_id}" ${is_primary}/>'
1197  . '<label for="group${storageGroup_id}">'
1198  . '</label>'
1199  . '</div>',
1200  '<a href="?node=storage&editStorageGroup&id=${storageGroup_id}">'
1201  . '${storageGroup_name}'
1202  . '</a>'
1203  );
1204  $this->attributes = array(
1205  array(
1206  'class' => 'filter-false',
1207  'width' => 16
1208  ),
1209  array(
1210  'class' => 'filter-false',
1211  'width' => 16
1212  ),
1213  array(),
1214  );
1215  foreach ((array)$StorageGroups as &$StorageGroup) {
1216  $groupinme = in_array(
1217  $StorageGroup->id,
1218  $this->obj->get('storagegroups')
1219  );
1220  if (!$groupinme) {
1221  continue;
1222  }
1223  $this->data[] = array(
1224  'storageGroup_id' => $StorageGroup->id,
1225  'storageGroup_name' => $StorageGroup->name,
1226  'is_primary' => (
1227  $this->obj->getPrimaryGroup($StorageGroup->id) ?
1228  ' checked' :
1229  ''
1230  )
1231  );
1232  unset($StorageGroup);
1233  }
1234  if (is_array($this->data) && count($this->data) > 0) {
1235  self::$HookManager->processEvent(
1236  'IMAGE_EDIT_STORAGE_GROUP',
1237  array(
1238  'data' => &$this->data,
1239  'headerData' => &$this->headerData,
1240  'templates' => &$this->templates,
1241  'attributes' => &$this->attributes
1242  )
1243  );
1244  echo '<div class="panel panel-info">';
1245  echo '<div class="panel-heading text-center">';
1246  echo '<h4 class="title">';
1247  echo _('Update/Remove Storage Groups');
1248  echo '</h4>';
1249  echo '</div>';
1250  echo '<div class="panel-body">';
1251  $this->render(12);
1252  echo '<div class="form-group">';
1253  echo '<label for="primarysel" class="control-label col-xs-4">';
1254  echo _('Update primary group');
1255  echo '</label>';
1256  echo '<div class="col-xs-8">';
1257  echo '<button type="submit" name="primarysel" class='
1258  . '"btn btn-info btn-block" id="primarysel">'
1259  . _('Update')
1260  . '</button>';
1261  echo '</div>';
1262  echo '</div>';
1263  echo '<div class="form-group">';
1264  echo '<label for="groupdel" class="control-label col-xs-4">';
1265  echo _('Remove selected groups');
1266  echo '</label>';
1267  echo '<div class="col-xs-8">';
1268  echo '<button type="submit" name="groupdel" class='
1269  . '"btn btn-danger btn-block" id="groupdel">'
1270  . _('Remove')
1271  . '</button>';
1272  echo '</div>';
1273  echo '</div>';
1274  echo '</div>';
1275  echo '</div>';
1276  }
1277  echo '</form>';
1278  echo '</div>';
1279  echo '</div>';
1280  echo '</div>';
1281  unset(
1282  $this->data,
1283  $this->form,
1284  $this->templates,
1285  $this->attributes,
1286  $this->headerData
1287  );
1288  }
1294  public function edit()
1295  {
1296  echo '<div class="col-xs-9 tab-content">';
1297  $this->imageGeneral();
1298  $this->imageStoragegroups();
1299  echo '</div>';
1300  }
1306  public function editPost()
1307  {
1308  self::$HookManager
1309  ->processEvent(
1310  'IMAGE_EDIT_POST',
1311  array(
1312  'Image' => &$this->obj
1313  )
1314  );
1315  global $tab;
1316  $name = trim(
1317  filter_input(INPUT_POST, 'name')
1318  );
1319  $file = trim(
1320  filter_input(INPUT_POST, 'file')
1321  );
1322  $desc = trim(
1323  filter_input(INPUT_POST, 'description')
1324  );
1325  $os = (int)filter_input(INPUT_POST, 'os');
1326  $imagetype = (int)filter_input(INPUT_POST, 'imagetype');
1327  $imagepartitiontype = (int)filter_input(INPUT_POST, 'imagepartitiontype');
1328  $imagemanage = (int)filter_input(INPUT_POST, 'imagemanage');
1329  $protected = (int)isset($_POST['protected_image']);
1330  $isEnabled = (int)isset($_POST['isEnabled']);
1331  $toReplicate = (int)isset($_POST['toReplicate']);
1332  $compress = (int)filter_input(INPUT_POST, 'compress');
1333  $items = filter_input_array(
1334  INPUT_POST,
1335  array(
1336  'storagegroup' => array(
1337  'flags' => FILTER_REQUIRE_ARRAY
1338  ),
1339  'storagegroup-rm' => array(
1340  'flags' => FILTER_REQUIRE_ARRAY
1341  )
1342  )
1343  );
1344  $storagegroup = $items['storagegroup'];
1345  $storagegrouprm = $items['storagegroup-rm'];
1346  $primary = (int)filter_input(
1347  INPUT_POST,
1348  'primary'
1349  );
1350  try {
1351  switch ($tab) {
1352  case 'image-gen':
1353  if ($this->obj->get('name') != $name
1354  && self::getClass('ImageManager')->exists(
1355  $name,
1356  $this->obj->get('id')
1357  )
1358  ) {
1359  throw new Exception(
1360  _('An image already exists with this name!')
1361  );
1362  }
1363  if ($file == 'postdownloadscripts'
1364  || $file == 'dev'
1365  ) {
1366  throw new Exception(
1367  sprintf(
1368  '%s, %s.',
1369  _('Please choose a different name'),
1370  _('this one is reserved for FOG')
1371  )
1372  );
1373  }
1374  $exists = self::getClass('ImageManager')
1375  ->exists(
1376  $file,
1377  '',
1378  'path'
1379  );
1380  if ($this->obj->get('path') != $file
1381  && $exists
1382  ) {
1383  throw new Exception(
1384  sprintf(
1385  '%s, %s.',
1386  _('Please choose a different path'),
1387  _('this one is already in use by another image')
1388  )
1389  );
1390  }
1391  $this
1392  ->obj
1393  ->set('name', $name)
1394  ->set('description', $desc)
1395  ->set('osID', $os)
1396  ->set('path', $file)
1397  ->set('imageTypeID', $imagetype)
1398  ->set('imagePartitionTypeID', $imagepartitiontype)
1399  ->set('format', $imagemanage)
1400  ->set('protected', $protected)
1401  ->set('compress', $compress)
1402  ->set('isEnabled', $isEnabled)
1403  ->set('toReplicate', $toReplicate);
1404  break;
1405  case 'image-storage':
1406  if (isset($_POST['updategroups'])) {
1407  $this->obj->addGroup($storagegroup);
1408  } elseif (isset($_POST['primarysel'])) {
1409  $this->obj->setPrimaryGroup($primary);
1410  } elseif (isset($_POST['groupdel'])) {
1411  $groupdel = count($storagegrouprm);
1412  $ingroups = count($this->obj->get('storagegroups'));
1413  if ($groupdel < 1) {
1414  throw new Exception(
1415  _('No groups selected to be removed')
1416  );
1417  }
1418  if ($ingroups < 2) {
1419  throw new Exception(
1420  _('You must have at least one group associated')
1421  );
1422  }
1423  $this
1424  ->obj
1425  ->removeGroup(
1426  $storagegrouprm
1427  );
1428  }
1429  break;
1430  }
1431  if (!$this->obj->save()) {
1432  throw new Exception(
1433  _('Image update failed!')
1434  );
1435  }
1436  $hook = 'IMAGE_UPDATE_SUCCESS';
1437  $msg = json_encode(
1438  array(
1439  'msg' => _('Image updated!'),
1440  'title' => _('Image Update Success')
1441  )
1442  );
1443  } catch (Exception $e) {
1444  $hook = 'IMAGE_UPDATE_FAIL';
1445  $msg = json_encode(
1446  array(
1447  'error' => $e->getMessage(),
1448  'title' => _('Image Update Fail')
1449  )
1450  );
1451  }
1452  self::$HookManager
1453  ->processEvent(
1454  $hook,
1455  array('Image' => &$this->obj)
1456  );
1457  echo $msg;
1458  exit;
1459  }
1466  public function multicast()
1467  {
1468  unset(
1469  $this->data,
1470  $this->form,
1471  $this->headerData,
1472  $this->templates,
1473  $this->attributes
1474  );
1475  $this->title = self::$foglang['Multicast'];
1476  $this->attributes = array(
1477  array('class' => 'col-xs-4'),
1478  array('class' => 'col-xs-8 form-group'),
1479  );
1480  $this->templates = array(
1481  '${field}',
1482  '${input}',
1483  );
1484  $name = filter_input(INPUT_POST, 'name');
1485  $count = (int)filter_input(INPUT_POST, 'count');
1486  $timeout = (int)filter_input(INPUT_POST, 'timeout');
1487  $image = (int)filter_input(INPUT_POST, 'image');
1488  $fields = array(
1489  '<label for="iName">'
1490  . _('Session Name')
1491  . '</label>' => '<div class="input-group">'
1492  . '<input class="form-control" type="text" name="name" id="iName" '
1493  . 'autocomplete="off" value="'
1494  . $name
1495  . '"/>'
1496  . '</div>',
1497  '<label for="iCount">'
1498  . _('Client Count')
1499  . '</label>' => '<div class="input-group">'
1500  . '<input class="form-control" type="number" name="count" id="iCount" '
1501  . 'autocomplete="off" value="'
1502  . $count
1503  . '"/>'
1504  . '</div>',
1505  '<label for="iTimeout">'
1506  . _('Timeout')
1507  . ' ('
1508  . _('minutes')
1509  . ')'
1510  . '</label>' => '<div class="input-group">'
1511  . '<input class="form-control" type="number" name=timeout" '
1512  . 'id="iTimeout" autocomplete="off" value="'
1513  . $timeout
1514  . '"/>'
1515  . '</div>',
1516  '<label for="image">'
1517  . _('Select Image')
1518  . '</label>' => self::getClass('ImageManager')->buildSelectBox(
1519  $image,
1520  '',
1521  'name'
1522  ),
1523  '<label for="start">'
1524  . _('Start Session')
1525  . '</label>' => '<button class="btn btn-info btn-block" type="submit" '
1526  . 'name="start" id="start">'
1527  . _('Start')
1528  . '</button>'
1529  );
1530  array_walk(
1531  $fields,
1532  $this->fieldsToData
1533  );
1534  self::$HookManager
1535  ->processEvent(
1536  'IMAGE_MULTICAST_SESS',
1537  array(
1538  'headerData' => &$this->headerData,
1539  'data' => &$this->data,
1540  'templates' => &$this->templates,
1541  'attributes' => &$this->attributes
1542  )
1543  );
1544  echo '<div class="col-xs-9">';
1545  echo '<div class="panel panel-info">';
1546  echo '<div class="panel-heading text-center">';
1547  echo '<h4 class="title">';
1548  echo _('Multicast Image');
1549  echo '</h4>';
1550  echo '</div>';
1551  echo '<div class="panel-body">';
1552  echo '<form class="form-horizontal" method="post" action="'
1553  . $this->formAction
1554  . '">';
1555  echo '<div class="panel panel-info">';
1556  echo '<div class="panel-heading text-center">';
1557  echo '<h4 class="title">';
1558  echo _('Start Multicast Session');
1559  echo '</h4>';
1560  echo '</div>';
1561  echo '<div class="panel-body">';
1562  $this->render(12);
1563  echo '</div>';
1564  echo '</div>';
1565  unset(
1566  $this->form,
1567  $this->data,
1568  $this->headerData,
1569  $this->templates,
1570  $this->attributes
1571  );
1572  $this->headerData = array(
1573  _('Task Name'),
1574  _('Clients'),
1575  _('Start Time'),
1576  _('Percent'),
1577  _('State'),
1578  _('Stop Task'),
1579  );
1580  $this->attributes = array(
1581  array(),
1582  array(),
1583  array(),
1584  array(),
1585  array('class' => 'text-center'),
1586  array('class'=>'filter-false'),
1587  );
1588  $this->templates = array(
1589  '${mc_name}<br/><small>${image_name}:${os}</small>',
1590  '${mc_count}',
1591  '<small>${mc_start}</small>',
1592  '${mc_percent}',
1593  '<i class="fa fa-${mc_state}"></i>',
1594  '<a href="?node='
1595  . $this->node
1596  . '&sub=stop&mcid=${mc_id}" '
1597  . 'title="'
1598  . _('Remove')
1599  . '" data-toggle="tooltip" data-placement="top">'
1600  . '<i class="fa fa-minus-circle"></i>'
1601  . '</a>'
1602  );
1603  $find = array(
1604  'stateID' => self::fastmerge(
1605  (array)self::getQueuedStates(),
1606  (array)self::getProgressState()
1607  )
1608  );
1609  Route::active('multicastsession');
1610  $MulticastSessions = json_decode(
1611  Route::getData()
1612  );
1613  $MulticastSessions = $MulticastSessions->multicastsessions;
1614  foreach ((array)$MulticastSessions as &$MulticastSession) {
1615  $Image = $MulticastSession->image;
1616  if (!$Image->id) {
1617  continue;
1618  }
1619  $this->data[] = array(
1620  'mc_name' => $MulticastSession->name,
1621  'mc_count' => $MulticastSession->sessclients,
1622  'image_name' => $Image->name,
1623  'os' => $Image->os->name,
1624  'mc_start' => self::formatTime(
1625  $MulticastSession->starttime,
1626  'Y-m-d H:i:s'
1627  ),
1628  'mc_percent' => $MulticastSession->percent,
1629  'mc_state' => $MulticastSession->state->icon,
1630  'mc_id' => $MulticastSession->id,
1631  );
1632  unset($MulticastSession);
1633  }
1634  self::$HookManager
1635  ->processEvent(
1636  'IMAGE_MULTICAST_START',
1637  array(
1638  'data' => &$this->data,
1639  'headerData' => &$this->headerData,
1640  'templates' => &$this->templates,
1641  'attributes' => &$this->attributes
1642  )
1643  );
1644  echo '<div class="panel panel-info">';
1645  echo '<div class="panel-heading text-center">';
1646  echo '<h4 class="title">';
1647  echo _('Current Sessions');
1648  echo '</h4>';
1649  echo '</div>';
1650  echo '<div class="panel-body">';
1651  $this->render(12);
1652  echo '</div>';
1653  echo '</div>';
1654  echo '</form>';
1655  echo '</div>';
1656  echo '</div>';
1657  echo '</div>';
1658  }
1664  public function multicastPost()
1665  {
1666  try {
1667  $name = trim(
1668  filter_input(INPUT_POST, 'name')
1669  );
1670  $image = (int)filter_input(INPUT_POST, 'image');
1671  $timeout = (int)filter_input(INPUT_POST, 'timeout');
1672  $count = (int)filter_input(INPUT_POST, 'count');
1673  if (!$name) {
1674  throw new Exception(_('Please input a session name'));
1675  }
1676  if (count($count) < 1) {
1677  $count = self::getClass('HostManager')->count();
1678  }
1679  if (!$image) {
1680  throw new Exception(_('Please choose an image'));
1681  }
1682  if (self::getClass('MulticastSessionManager')->exists($name)) {
1683  throw new Exception(_('Session with that name already exists'));
1684  }
1685  if (self::getClass('HostManager')->exists($name)) {
1686  throw new Exception(
1687  _('Session name cannot be the same as an existing hostname')
1688  );
1689  }
1690  if ($timeout > 0) {
1691  self::setSetting('FOG_UDPCAST_MAXWAIT', $timeout);
1692  }
1693  $countmc = self::getClass('MulticastSessionManager')
1694  ->count(
1695  array(
1696  'stateID' => self::fastmerge(
1697  (array)self::getQueuedStates(),
1698  (array)self::getProgressState()
1699  )
1700  )
1701  );
1702  $countmctot = self::getSetting('FOG_MULTICAST_MAX_SESSIONS');
1703  $Image = new Image($image);
1704  $StorageGroup = $Image->getStorageGroup();
1705  $StorageNode = $StorageGroup->getMasterStorageNode();
1706  if ($countmc >= $countmctot) {
1707  throw new Exception(
1708  sprintf(
1709  '%s<br/>%s %s %s<br/>%s %s',
1710  _('Please wait until a slot is open'),
1711  _('There are currently'),
1712  $countmc,
1713  _('tasks in queue'),
1714  _('Your server only allows'),
1715  $countmctot
1716  )
1717  );
1718  }
1719  $MulticastSession = self::getClass('MulticastSession')
1720  ->set('name', $name)
1721  ->set('port', self::getSetting('FOG_UDPCAST_STARTINGPORT'))
1722  ->set('image', $Image->get('id'))
1723  ->set('stateID', 0)
1724  ->set('sessclients', $count)
1725  ->set('isDD', $Image->get('imageTypeID'))
1726  ->set('starttime', self::formatTime('now', 'Y-m-d H:i:s'))
1727  ->set('interface', $StorageNode->get('interface'))
1728  ->set('logpath', $Image->get('path'))
1729  ->set('storagegroupID', $StorageNode->get('id'))
1730  ->set('clients', -2);
1731  if (!$MulticastSession->save()) {
1732  self::setMessage(_('Failed to create Session'));
1733  }
1734  $randomnumber = mt_rand(24576, 32766)*2;
1735  while ($randomnumber == $MulticastSession->get('port')) {
1736  $randomnumber = mt_rand(24576, 32766)*2;
1737  }
1738  self::setSetting('FOG_UDPCAST_STARTINGPORT', $randomnumber);
1740  sprintf(
1741  '%s<br/>%s %s %s',
1742  _('Multicast session created'),
1743  $MulticastSession->get('name'),
1744  _('has been started on port'),
1745  $MulticastSession->get('port')
1746  )
1747  );
1748  } catch (Exception $e) {
1749  self::setMessage($e->getMessage());
1750  }
1752  sprintf(
1753  '?node=%s&sub=multicast',
1754  $this->node
1755  )
1756  );
1757  }
1763  public function stop()
1764  {
1765  $mcid = (int)filter_input(INPUT_GET, 'mcid');
1766  if ($mcid < 1) {
1768  sprintf('?node=%s&sub=multicast', $this->node)
1769  );
1770  }
1771  self::getClass('MulticastSessionManager')->cancel($mcid);
1773  sprintf(
1774  '%s%s',
1775  _('Cancelled task'),
1776  (
1777  count($mcid) !== 1 ?
1778  's' :
1779  ''
1780  )
1781  )
1782  );
1783  self::redirect(sprintf('?node=%s&sub=multicast', $this->node));
1784  }
1785 }
FOGPage\render
render($colsize=9)
Definition: fogpage.class.php:605
ImageManagementPage
Definition: imagemanagementpage.class.php:23
exit
exit
Definition: download.php:102
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
FOGBase\formatByteSize
static formatByteSize($size)
Definition: fogbase.class.php:1025
ImageManagementPage\stop
stop()
Definition: imagemanagementpage.class.php:1763
Route\active
static active($class)
Definition: route.class.php:1104
$file
if(isset($_REQUEST['legclient'])) if(isset($_REQUEST['newclient'])) if(isset($_REQUEST['fogprep'])) if(isset($_REQUEST['fogcrypt'])) if(isset($_REQUEST['smartinstaller'])) if(!file_exists($filename)) $file
Definition: download.php:61
FOGPage\$title
$title
Definition: fogpage.class.php:49
ImageManagementPage\add
add()
Definition: imagemanagementpage.class.php:427
ImageManagementPage\editPost
editPost()
Definition: imagemanagementpage.class.php:1306
Image
Definition: image.class.php:23
$exists
$exists
Definition: check_node_exists.php:26
$items
$items
Definition: boot.php:24
ImageManagementPage\addPost
addPost()
Definition: imagemanagementpage.class.php:687
FOGPage\$name
$name
Definition: fogpage.class.php:31
ImageManagementPage\multicastPost
multicastPost()
Definition: imagemanagementpage.class.php:1664
FOGBase\formatTime
static formatTime($time, $format=false, $utc=false)
Definition: fogbase.class.php:1124
ImageManagementPage\$node
$node
Definition: imagemanagementpage.class.php:29
ImageManagementPage\__construct
__construct($name='')
Definition: imagemanagementpage.class.php:37
FOGBase\redirect
static redirect($url='')
Definition: fogbase.class.php:831
FOGPage
Definition: fogpage.class.php:25
ImageManagementPage\multicast
multicast()
Definition: imagemanagementpage.class.php:1466
$path
if(!is_string($_GET['path'])) $path
Definition: getfiles.php:31
Route\getData
static getData()
Definition: route.class.php:1173
$count
$count
Definition: locationcheck.php:25
ImageManagementPage\imageGeneral
imageGeneral()
Definition: imagemanagementpage.class.php:781
FOGPage\$id
$id
Definition: fogpage.class.php:43
Route\listem
static listem( $class, $sortby='name', $bypass=false, $find=array(), $item='')
Definition: route.class.php:429
ImageManagementPage\imageStoragegroups
imageStoragegroups()
Definition: imagemanagementpage.class.php:1066
$Image
$Image
Definition: hostinfo.php:37
StorageGroup
Definition: storagegroup.class.php:23
$foglang
$foglang['Display']
Definition: text.php:22
$msg
if($Host->isValid()) $msg
Definition: hostnameloop.php:42
ImageManagementPage\edit
edit()
Definition: imagemanagementpage.class.php:1294
FOGBase\setMessage
static setMessage($txt, $data=array())
Definition: fogbase.class.php:784
FOGBase\setSetting
static setSetting($key, $value)
Definition: fogbase.class.php:2093
FOGBase\getSetting
static getSetting($key)
Definition: fogbase.class.php:2063
FOGPage\membership
membership()
Definition: fogpage.class.php:3403