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)  

fogconfigurationpage.class.php
Go to the documentation of this file.
1 <?php
23 {
29  public $node = 'about';
37  public function __construct($name = '')
38  {
39  $this->name = 'FOG Configuration';
40  parent::__construct($this->name);
41  $this->menu = array(
42  'home' => self::$foglang['Home'],
43  'license' => self::$foglang['License'],
44  'kernelUpdate' => self::$foglang['KernelUpdate'],
45  'pxemenu' => self::$foglang['PXEBootMenu'],
46  'customizepxe' => self::$foglang['PXEConfiguration'],
47  'newMenu' => self::$foglang['NewMenu'],
48  'clientupdater' => self::$foglang['ClientUpdater'],
49  'maclist' => self::$foglang['MACAddrList'],
50  'settings' => self::$foglang['FOGSettings'],
51  'logviewer' => self::$foglang['LogViewer'],
52  'config' => self::$foglang['ConfigSave'],
53  'http://www.sf.net/projects/freeghost' => self::$foglang['FOGSFPage'],
54  'https://fogproject.org' => self::$foglang['FOGWebPage'],
55  'https://github.com/fogproject/fogproject.git' => _(
56  'FOG Project on Github'
57  ),
58  'https://github.com/fogproject/fog-client.git' => _(
59  'FOG Client on Github'
60  ),
61  'https://wiki.fogproject.org/wiki/index.php' => _('FOG Wiki'),
62  'https://forums.fogproject.org' => _('FOG Forums'),
63  'https://www.paypal.com/cgi-bin/webscr?i'
64  . 'item_name=Donation+to+FOG+-+A+Free+Cloning+'
65  . 'Solution&cmd=_donations&business=fogproject'
66  . '.org%40gmail.com' => _('Donate to FOG'),
67  );
68  self::$HookManager
69  ->processEvent(
70  'SUB_MENULINK_DATA',
71  array(
72  'menu' => &$this->menu,
73  'submenu' => &$this->subMenu,
74  'id' => &$this->id,
75  'notes'=>&$this->notes
76  )
77  );
78  }
85  public function index()
86  {
87  $this->version();
88  }
94  public function version()
95  {
96  $this->title = _('FOG Version Information');
97  echo '<div class="col-xs-9">';
98  echo '<div class="panel panel-info">';
99  echo '<div class="panel-heading text-center">';
100  echo '<h4 class="title">';
101  echo $this->title;
102  echo '</h4>';
103  echo '</div>';
104  echo '<div class="panel-body placehere" vers="'
105  . FOG_VERSION
106  . '">';
107  echo '</div>';
108  echo '</div>';
109  echo '</div>';
110  echo '<div class="col-xs-9">';
111  echo '<div class="panel panel-info">';
112  echo '<div class="panel-heading text-center">';
113  echo '<h4 class="title">';
114  echo _('Kernel Versions');
115  echo '</h4>';
116  echo '</div>';
117  echo '<div class="panel-body">';
118  Route::listem('storagenode');
119  $StorageNodes = json_decode(
121  );
122  $StorageNodes = $StorageNodes->storagenodes;
123  $urls = array();
124  foreach ((array)$StorageNodes as &$StorageNode) {
125  $url = $urls[] = filter_var(
126  sprintf(
127  '%s://%s/fog/status/kernelvers.php',
128  self::$httpproto,
129  $StorageNode->ip
130  ),
131  FILTER_SANITIZE_URL
132  );
133  if (!self::getClass('StorageNode', $StorageNode->id)->get('online')) {
134  continue;
135  }
136  echo '<a id="'
137  . $StorageNode->name
138  . '" class="expand_trigger btn btn-info btn-block"'
139  . 'href="#'
140  . $StorageNode->name
141  . '">';
142  echo '<h4 class="title kernversionupdate">';
143  echo $StorageNode->name;
144  echo ' ';
145  echo _('FOG Version');
146  echo ': ()';
147  echo '</h4>';
148  echo '</a>';
149  echo '<div id="'
150  . $StorageNode->name
151  . '" class="hidefirst">';
152  echo '<pre class="kernvers" urlcall="';
153  echo $url;
154  echo '">';
155  echo '</pre>';
156  echo '</div>';
157  unset($StorageNode);
158  }
159  echo '</div>';
160  echo '</div>';
161  echo '</div>';
162  }
168  public function license()
169  {
170  $this->title = _('FOG License Information');
171  $file = './languages/'
172  . self::$locale
173  . '.UTF-8/gpl-3.0.txt';
174  $contents = file_get_contents($file);
175  $contents = preg_replace('!\r?\n!', '<br/>', $contents);
176  echo '<div class="col-xs-9">';
177  echo '<div class="panel panel-info">';
178  echo '<div class="panel-heading text-center">';
179  echo '<h4 class="title">';
180  echo _('GNU Gneral Public License');
181  echo '</h4>';
182  echo '</div>';
183  echo '<div class="panel-body text-justify">';
184  echo $contents;
185  echo '</div>';
186  echo '</div>';
187  echo '</div>';
188  }
194  public function kernel()
195  {
196  $this->kernelUpdatePost();
197  }
203  public function kernelUpdate()
204  {
205  $url = 'https://fogproject.org/kernels/kernelupdate_bootstrap.php';
206  $htmlData = self::$FOGURLRequests->process($url);
207  echo '<div class="col-xs-9">';
208  echo '<div class="panel panel-info">';
209  echo '<div class="panel-heading text-center">';
210  echo '<h4 class="title">';
211  echo _('Kernel Update');
212  echo '</h4>';
213  echo '</div>';
214  echo '<div class="panel-body">';
215  printf(
216  '%s %s %s. %s, %s, %s %s. %s, %s %s, %s.',
217  _('This section allows you to update'),
218  _('the Linux kernel which is used to'),
219  _('boot the client computers'),
220  _('In FOG'),
221  _('this kernel holds all the drivers for the client computer'),
222  _('so if you are unable to boot a client you may wish to'),
223  _('update to a newer kernel which may have more drivers built in'),
224  _('This installation process may take a few minutes'),
225  _('as FOG will attempt to go out to the internet'),
226  _('to get the requested Kernel'),
227  _('so if it seems like the process is hanging please be patient')
228  );
229  echo '</div>';
230  echo '<div class="panel-body">';
231  echo $htmlData[0];
232  echo '</div>';
233  echo '</div>';
234  echo '</div>';
235  }
241  public function kernelUpdatePost()
242  {
243  global $node;
244  global $sub;
245  if (!isset($_POST['install']) && $sub == 'kernelUpdate') {
246  $url = 'https://fogproject.org/kernels/kernelupdate_bootstrap.php';
247  $htmlData = self::$FOGURLRequests->process($url);
248  echo $htmlData[0];
249  } elseif (isset($_POST['install'])) {
250  $_SESSION['allow_ajax_kdl'] = true;
251  $dstName = filter_input(INPUT_POST, 'dstName');
252  $_SESSION['dest-kernel-file'] = trim(
253  basename(
254  $dstName
255  )
256  );
257  $_SESSION['tmp-kernel-file'] = sprintf(
258  '%s%s%s%s',
259  DS,
260  trim(
261  sys_get_temp_dir(),
262  DS
263  ),
264  DS,
265  basename($_SESSION['dest-kernel-file'])
266  );
267  $file = filter_input(INPUT_GET, 'file');
268  $_SESSION['dl-kernel-file'] = base64_decode(
269  $file
270  );
271  if (file_exists($_SESSION['tmp-kernel-file'])) {
272  unlink($_SESSION['tmp-kernel-file']);
273  }
274  echo '<div class="col-xs-9">';
275  echo '<div class="kerninfo">';
276  echo '<div class="panel panel-info">';
277  echo '<div class="panel-heading text-center">';
278  echo '<h4 class="title">';
279  echo _('Downloading Kernel');
280  echo '</h4>';
281  echo '</div>';
282  echo '<div class="panel-body">';
283  echo '<i class="fa fa-cog fa-2x fa-spin"></i>';
284  echo ' ';
285  echo _('Starting process');
286  echo '</div>';
287  echo '</div>';
288  echo '</div>';
289  echo '</div>';
290  echo '</div>';
291  } else {
292  $file = filter_input(INPUT_GET, 'file');
293  $arch = filter_input(INPUT_GET, 'arch');
294  $tmpFile = basename(
295  $file
296  );
297  $tmpArch = (
298  $arch == 64 ?
299  'bzImage' :
300  'bzImage32'
301  );
302  $formstr = "?node={$node}&sub=kernelUpdate";
303  echo '<div class="col-xs-9">';
304  echo '<div class="panel panel-info">';
305  echo '<div class="panel-heading text-center">';
306  echo '<h4 class="title">';
307  echo _('Save Kernel');
308  echo '</h4>';
309  echo '</div>';
310  echo '<div class="panel-body">';
311  echo '<form class="form-horizontal" method="post" action="';
312  $formstr;
313  echo '">';
314  echo '<input type="hidden" name="file" value="';
315  echo $tmpFile;
316  echo '"/>';
317  echo '<div class="col-xs-4">';
318  echo '<label class="control-label" for="dstName">';
319  echo _('Kernel Name');
320  echo '</label>';
321  echo '</div>';
322  echo '<div class="col-xs-8">';
323  echo '<div class="input-group">';
324  echo '<input class="form-control" type="text" name="dstName" id='
325  . '"dstName" value="'
326  . $tmpArch
327  . '"/>';
328  echo '</div>';
329  echo '</div>';
330  echo '<div class="col-xs-4">';
331  echo '<label class="control-label" for="install">';
332  echo _('Install Kernel');
333  echo '</label>';
334  echo '</div>';
335  echo '<div class="col-xs-8">';
336  echo '<button type="submit" class="btn btn-info btn-block" id='
337  . '"install" name="install">';
338  echo _('Install');
339  echo '</button>';
340  echo '</div>';
341  echo '</form>';
342  echo '</div>';
343  echo '</div>';
344  echo '</div>';
345  }
346  }
352  public function pxemenu()
353  {
354  $this->title = _('FOG PXE Boot Menu Configuration');
355  unset($this->headerData);
356  $this->attributes = array(
357  array('class' => 'col-xs-4'),
358  array('class' => 'col-xs-6 form-group'),
359  array('class' => 'col-xs-2')
360  );
361  $this->templates = array(
362  '${field}',
363  '${input}',
364  '${span}',
365  );
366  $ServicesToSee = array(
367  'FOG_ADVANCED_MENU_LOGIN',
368  'FOG_BOOT_EXIT_TYPE',
369  'FOG_EFI_BOOT_EXIT_TYPE',
370  'FOG_IPXE_BG_FILE',
371  'FOG_IPXE_HOST_CPAIRS',
372  'FOG_IPXE_INVALID_HOST_COLOURS',
373  'FOG_IPXE_MAIN_COLOURS',
374  'FOG_IPXE_MAIN_CPAIRS',
375  'FOG_IPXE_MAIN_FALLBACK_CPAIRS',
376  'FOG_IPXE_VALID_HOST_COLOURS',
377  'FOG_KEY_SEQUENCE',
378  'FOG_NO_MENU',
379  'FOG_PXE_ADVANCED',
380  'FOG_PXE_HIDDENMENU_TIMEOUT',
381  'FOG_PXE_MENU_HIDDEN',
382  'FOG_PXE_MENU_TIMEOUT',
383  );
384  list(
385  $advLogin,
386  $exitNorm,
387  $exitEfi,
388  $bgfile,
389  $hostCpairs,
390  $hostInvalid,
391  $mainColors,
392  $mainCpairs,
393  $mainFallback,
394  $hostValid,
395  $bootKeys,
396  $noMenu,
397  $advanced,
398  $hideTimeout,
399  $hidChecked,
400  $timeout
402  'Service',
403  array(
404  'name' => $ServicesToSee
405  ),
406  'value',
407  false,
408  'AND',
409  'name',
410  false,
411  ''
412  );
413  $advLogin = $advLogin ? ' checked' : '';
414  $exitNorm = Service::buildExitSelector(
415  'bootTypeExit',
416  $exitNorm,
417  false,
418  'bootTypeExit'
419  );
420  $exitEfi = Service::buildExitSelector(
421  'efiBootTypeExit',
422  $exitEfi,
423  false,
424  'efiBootTypeExit'
425  );
426  $bootKeys = self::getClass('KeySequenceManager')
427  ->buildSelectBox($bootKeys);
428  $noMenu = (
429  $noMenu ?
430  ' checked' :
431  ''
432  );
433  $hidChecked = (
434  $hidChecked ?
435  ' checked' :
436  ''
437  );
438  $fieldsToData = function (&$input, &$field) {
439  $this->data[] = array(
440  'field' => $field,
441  'input' => (
442  is_array($input) ?
443  $input[0] :
444  $input
445  ),
446  'span' => (
447  is_array($input) ?
448  $input[1] :
449  ''
450  )
451  );
452  unset($input, $field);
453  };
454  // Menu based changes.
455  $fields = array(
456  '<label for="mainColors">'
457  . _('Main Colors')
458  . '</label>' => array(
459  '<div class="input-group">'
460  . '<textarea id="mainColors" name="mainColors" class="form-control">'
461  . $mainColors
462  . '</textarea>'
463  . '</div>',
464  '<i class="fa fa-question hand" title="'
465  . _('Option specifies the color settings of the main menu items')
466  . '." data-toggle="tooltip" data-placement="right"></i>'
467  ),
468  '<label for="hostValid">'
469  . _('Valid Host Colors')
470  . '<label>' => array(
471  '<div class="input-group">'
472  . '<textarea id="hostValid" class="form-control" name="hostValid">'
473  . $hostValid
474  . '</textarea>'
475  . '</div>',
476  '<i class="fa fa-question hand" title="'
477  . _('Option specifies the color text on the menu if the host')
478  . ' '
479  . _('is valid')
480  . '." data-toggle="tooltip" data-placement="right"></i>'
481  ),
482  '<label for="hostInvalid">'
483  . _('Invalid Host Colors')
484  . '</label>' => array(
485  '<div class="input-group">'
486  . '<textarea name="hostInvalid" class="form-control" id='
487  . '"hostInvalid">'
488  . $hostInvalid
489  . '</textarea>'
490  . '</div>',
491  '<i class="fa fa-question hand" title="'
492  . _('Option specifies the color text on the menu if the host')
493  . ' '
494  . _('is invalid')
495  . '." data-toggle="tooltip" data-placement="right"></i>'
496  ),
497  '<label for="mainCpairs">'
498  . _('Main pairings')
499  . '</label>' => array(
500  '<div class="input-group">'
501  . '<textarea id="mainCpairs" name="mainCpairs" class='
502  . '"form-control">'
503  . $mainCpairs
504  . '</textarea>'
505  . '</div>',
506  '<i class="fa fa-question hand" title="'
507  . _('Option specifies the pairings of colors to')
508  . ' '
509  . _('present and where/how they need to display')
510  . '." data-toggle="tooltip" data-placement="right"></i>'
511  ),
512  '<label for="mainFallback">'
513  . _('Main fallback pairings')
514  . '</label>' => array(
515  '<div class="input-group">'
516  . '<textarea class="form-control" id="mainFallback" name='
517  . '"mainFallback">'
518  . $mainFallback
519  . '</textarea>'
520  . '</div>',
521  '<i class="fa fa-question hand" title="'
522  . _('Option specifies the pairings as a fallback')
523  . '." data-toggle="tooltip" data-placement="right"></i>'
524  ),
525  '<label for="hostCpairs">'
526  . _('Host pairings')
527  . '</label>' => array(
528  '<div class="input-group">'
529  . '<textarea class="form-control" id="hostCPairs" name="hostCpairs">'
530  . $hostCpairs
531  . '</textarea>'
532  . '</div>',
533  '<i class="fa fa-question hand" title="'
534  . _('Option specifies the pairings after host checks')
535  . '." data-toggle="tooltip" data-placement="right"></i>'
536  ),
537  '<label for="timeout">'
538  . _('Menu Timeout')
539  . ' ('
540  . _('in seconds')
541  . ')'
542  . '</label>' => array(
543  '<div class="input-group">'
544  . '<input type="text" id="timeout" name="timeout" value="'
545  . $timeout
546  . '" class="form-control"/>'
547  . '</div>',
548  '<i class="fa fa-question hand" title="'
549  . _('Option specifies the menu timeout')
550  . '. '
551  . _('This is set in seconds and causes the default option')
552  . ' '
553  . _('to be booted if no keys are pressed when the menu is')
554  . ' '
555  . _('open')
556  . '." data-toggle="tooltip" data-placement="right"></i>'
557  ),
558  '<label for="bgfile">'
559  . _('Menu Background File')
560  . '</label>' => array(
561  '<div class="input-group">'
562  . '<input type="text" id="bgfile" name="bgfile" value="'
563  . $bgfile
564  . '" class="form-control"/>'
565  . '</div>',
566  '<i class="fa fa-question hand" title="'
567  . _('Option specifies the background file to use')
568  . ' '
569  . _('for the menu background')
570  . '." data-toggle="tooltip" data-placement="right"></i>'
571  ),
572  '<label for="menuSet">'
573  . _('Make Changes?')
574  . '</label>' => '<button type="submit" id="menuSet" class="'
575  . 'btn btn-info btn-block" name="updatemenuset">'
576  . _('Update')
577  . '</button>'
578  );
579  self::$HookManager->processEvent(
580  'IPXE_MENU_SETTINGS_FIELDS',
581  array(
582  'fields' => &$fields
583  )
584  );
585  array_walk($fields, $fieldsToData);
586  self::$HookManager->processEvent(
587  'IPXE_MENU_SETTINGS',
588  array(
589  'data' => &$this->data,
590  'templates' => &$this->templates,
591  'attributes' => &$this->attributes
592  )
593  );
594  echo '<div class="col-xs-9">';
595  echo '<div class="panel panel-info">';
596  echo '<div class="panel-heading text-center">';
597  echo '<h4 class="title">';
598  echo _('iPXE Menu Settings');
599  echo '</h4>';
600  echo '</div>';
601  echo '<div class="panel-body">';
602  echo '<form class="form-horizontal" method="post" action="'
603  . $this->formAction
604  . '">';
605  echo '<div class="panel panel-info">';
606  echo '<div class="panel-heading text-center expand_trigger hand" id='
607  . '"menusettings">';
608  echo '<h4 class="title">';
609  echo _('Menu colors, pairings, settings');
610  echo '</h4>';
611  echo '</div>';
612  echo '<div class="panel-body hidefirst" id="menusettings">';
613  $this->render(12);
614  echo '</div>';
615  echo '</div>';
616  $this->data = array();
617  $fields = array(
618  '<label for="nomenu">'
619  . _('No Menu')
620  . '</label>' => array(
621  '<input type="checkbox" id="nomenu" name="nomenu"'
622  . $noMenu
623  . '/>',
624  '<i class="fa fa-question hand" title="'
625  . _('Option sets if there will even')
626  . ' '
627  . _('be the presence of a menu')
628  . ' '
629  . _('to the client systems')
630  . '. '
631  . _('If there is not a task set')
632  . ', '
633  . _('it boots to the first device')
634  . ', '
635  . _('if there is a task')
636  . ', '
637  . _('it performs that task')
638  . '." data-toggle="tooltip" data-placement="right"></i>'
639  ),
640  '<label for="hidemenu">'
641  . _('Hide Menu')
642  . '</label>' => array(
643  '<input type="checkbox" id="hidemenu" name="hidemenu"'
644  . $hidChecked
645  . '/>',
646  '<i class="fa fa-question hand" title="'
647  . _('Option sets the key sequence')
648  . '. '
649  . _('If none is specified')
650  . ', '
651  . _('ESC is defaulted')
652  . '. '
653  . _('Login with the FOG credentials and you will see the menu')
654  . '. '
655  . _('Otherwise it will just boot like normal')
656  . '." data-toggle="tooltip" data-placement="right"></i>'
657  ),
658  '<label for="hidetimeout">'
659  . _('Hide Menu Timeout')
660  . '</label>' => array(
661  '<div class="input-group">'
662  . '<input type="text" id="hidetimeout" name="hidetimeout" '
663  . 'value="'
664  . $hideTimeout
665  . '" class="form-control"/>'
666  . '</div>',
667  '<i class="fa fa-question hand" title="'
668  . _('Option specifies the timeout value for the hidden menu system')
669  . '." data-toggle="tooltip" data-placement="right"></i>'
670  ),
671  '<label for="keysequence">'
672  . _('Boot Key Sequence')
673  . '</label>' => array(
674  $bootKeys,
675  '<i class="fa fa-question hand" title="'
676  . _('Option sets the ipxe keysequence to enter to gain menu')
677  . ' '
678  . _('access to the hidden menu system')
679  . '." data-toggle="tooltip" data-placement="right"></i>'
680  ),
681  '<label for="hideSet">'
682  . _('Make Changes?')
683  . '</label>' => '<button type="submit" id="hideSet" class="'
684  . 'btn btn-info btn-block" name="updatehideset">'
685  . _('Update')
686  . '</button>'
687  );
688  self::$HookManager->processEvent(
689  'IPXE_HIDENOMENU_SETTINGS_FIELDS',
690  array(
691  'fields' => &$fields
692  )
693  );
694  array_walk($fields, $fieldsToData);
695  self::$HookManager->processEvent(
696  'IPXE_HIDENOMENU_SETTINGS',
697  array(
698  'data' => &$this->data,
699  'templates' => &$this->templates,
700  'attributes' => &$this->attributes
701  )
702  );
703  echo '<div class="panel panel-info">';
704  echo '<div class="panel-heading text-center expand_trigger hand" id="'
705  . 'menuhidesettings">';
706  echo '<h4 class="title">';
707  echo _('Menu Hide/No Menu settings');
708  echo '</h4>';
709  echo '</div>';
710  echo '<div class="panel-body hidefirst" id="menuhidesettings">';
711  $this->render(12);
712  echo '</div>';
713  echo '</div>';
714  $this->data = array();
715  $fields = array(
716  '<label for="bootTypeExit">'
717  . _('Exit to Hard Drive Type')
718  . '</label>' => array(
719  $exitNorm,
720  '<i class="fa fa-question hand" title="'
721  . _('Option specifies the legacy boot exit method ipxe will use')
722  . '." data-toggle="tooltip" data-placement="right"></i>'
723  ),
724  '<label for="efiBootTypeExit">'
725  . _('Exit to Hard Drive Type(EFI)')
726  . '</label>' => array(
727  $exitEfi,
728  '<i class="fa fa-question hand" title="'
729  . _('Option specifies the efi boot exit method ipxe will use')
730  . '." data-toggle="tooltip" data-placement="right"></i>'
731  ),
732  '<label for="exitSet">'
733  . _('Make Changes?')
734  . '</label>' => '<button type="submit" id="exitSet" class="'
735  . 'btn btn-info btn-block" name="updatebootexit">'
736  . _('Update')
737  . '</button>'
738  );
739  self::$HookManager->processEvent(
740  'IPXE_EXITTYPE_SETTINGS_FIELDS',
741  array(
742  'fields' => &$fields
743  )
744  );
745  array_walk($fields, $fieldsToData);
746  self::$HookManager->processEvent(
747  'IPXE_EXITTYPE_SETTINGS',
748  array(
749  'data' => &$this->data,
750  'templates' => &$this->templates,
751  'attributes' => &$this->attributes
752  )
753  );
754  echo '<div class="panel panel-info">';
755  echo '<div class="panel-heading text-center expand_trigger hand" id="'
756  . 'menuexitsettings">';
757  echo '<h4 class="title">';
758  echo _('Boot Exit settings');
759  echo '</h4>';
760  echo '</div>';
761  echo '<div class="panel-body hidefirst" id="menuexitsettings">';
762  $this->render(12);
763  echo '</div>';
764  echo '</div>';
765  $this->data = array();
766  $fields = array(
767  '<label for="advlog">'
768  . _('Advanced Menu Login')
769  . '</label>' => array(
770  '<input type="checkbox" id="advlog" name="advmenulogin"'
771  . $advLogin
772  . '/>',
773  '<i class="fa fa-question hand" title="'
774  . _('Option below enforces a login system')
775  . ' '
776  . _('for the advanced menu parameters')
777  . '. '
778  . _('If off')
779  . ', '
780  . _('no login will appear')
781  . '. '
782  . _('If on')
783  . ', '
784  . _('it will enforce login to gain access to the advanced')
785  . ' '
786  . _('menu system')
787  . '." data-toggle="tooltip" data-placement="right"></i>'
788  ),
789  '<label for="advtext">'
790  . _('Advanced menu command')
791  . '</label>' => array(
792  '<div class="input-group">'
793  . '<textarea id="advtext" class="form-control" name="adv">'
794  . $advanced
795  . '</textarea>'
796  . '</div>',
797  '<i class="fa fa-question hand" title="'
798  . _('Add any custom text you would like')
799  . ' '
800  . _('the advanced menu to use')
801  . '. '
802  . _('This is ipxe script commands to operate with')
803  . '." data-toggle="tooltip" data-placement="right"></i>'
804  ),
805  '<label for="advSet">'
806  . _('Make Changes?')
807  . '</label>' => '<button type="submit" id="advSet" class="'
808  . 'btn btn-info btn-block" name="updateadvset">'
809  . _('Update')
810  . '</button>'
811  );
812  self::$HookManager->processEvent(
813  'IPXE_ADVANCED_SETTINGS_FIELDS',
814  array(
815  'fields' => &$fields
816  )
817  );
818  array_walk($fields, $fieldsToData);
819  self::$HookManager->processEvent(
820  'IPXE_ADVANCED_SETTINGS',
821  array(
822  'data' => &$this->data,
823  'templates' => &$this->templates,
824  'attributes' => &$this->attributes
825  )
826  );
827  echo '<div class="panel panel-info">';
828  echo '<div class="panel-heading text-center expand_trigger hand" id="'
829  . 'advancedmenusettings">';
830  echo '<h4 class="title">';
831  echo _('Advanced Menu settings');
832  echo '</h4>';
833  echo '</div>';
834  echo '<div class="panel-body hidefirst" id="advancedmenusettings">';
835  $this->render(12);
836  echo '</div>';
837  echo '</div>';
838  echo '</form>';
839  echo '</div>';
840  echo '</div>';
841  echo '</div>';
842  }
848  public function pxemenuPost()
849  {
850  try {
851  if (isset($_POST['updatemenuset'])) {
852  $mainColors = filter_input(
853  INPUT_POST,
854  'mainColors'
855  );
856  $hostValid = filter_input(
857  INPUT_POST,
858  'hostValid'
859  );
860  $hostInvalid = filter_input(
861  INPUT_POST,
862  'hostInvalid'
863  );
864  $mainCpairs = filter_input(
865  INPUT_POST,
866  'mainCpairs'
867  );
868  $mainFallback = filter_input(
869  INPUT_POST,
870  'mainFallback'
871  );
872  $hostCpairs = filter_input(
873  INPUT_POST,
874  'hostCpairs'
875  );
876  $timeout = trim(
877  filter_input(INPUT_POST, 'timeout')
878  );
879  $timeoutt = (is_numeric($timeout) && $timeout >= 0);
880  if (!$timeoutt) {
881  throw new Exception(_('Invalid Timeout Value'));
882  }
883  $bgfile = filter_input(
884  INPUT_POST,
885  'bgfile'
886  );
887  $ServicesToEdit = array(
888  'FOG_IPXE_MAIN_COLOURS' => $mainColors,
889  'FOG_IPXE_VALID_HOST_COLOURS' => $hostValid,
890  'FOG_IPXE_INVALID_HOST_COLOURS' => $hostInvalid,
891  'FOG_IPXE_MAIN_CPAIRS' => $mainCpairs,
892  'FOG_IPXE_MAIN_FALLBACK_CPAIRS' => $mainFallback,
893  'FOG_IPXE_HOST_CPAIRS' => $hostCpairs,
894  'FOG_PXE_MENU_TIMEOUT' => $timeout,
895  'FOG_IPXE_BG_FILE' => $bgfile
896  );
897  }
898  if (isset($_POST['updatehideset'])) {
899  $noMenu = (int)isset($_POST['nomenu']);
900  $hideMenu = (int)isset($_POST['hidemenu']);
901  $hidetimeout = trim(
902  filter_input(INPUT_POST, 'hidetimeout')
903  );
904  $hidetimeoutt = (is_numeric($hidetimeout) && $hidetimeout >= 0);
905  if (!$hidetimeoutt) {
906  throw new Exception(_('Invalid Timeout Value'));
907  }
908  $keysequence = filter_input(
909  INPUT_POST,
910  'keysequence'
911  );
912  $ServicesToEdit = array(
913  'FOG_NO_MENU' => $noMenu,
914  'FOG_PXE_MENU_HIDDEN' => $hideMenu,
915  'FOG_PXE_HIDDENMENU_TIMEOUT' => $hidetimeout,
916  'FOG_KEY_SEQUENCE' => $keysequence
917  );
918  }
919  if (isset($_POST['updatebootexit'])) {
920  $bootTypeExit = filter_input(
921  INPUT_POST,
922  'bootTypeExit'
923  );
924  $efiBootTypeExit = filter_input(
925  INPUT_POST,
926  'efiBootTypeExit'
927  );
928  $ServicesToEdit = array(
929  'FOG_BOOT_EXIT_TYPE' => $bootTypeExit,
930  'FOG_EFI_BOOT_EXIT_TYPE' => $efiBootTypeExit
931  );
932  }
933  if (isset($_POST['updateadvset'])) {
934  $advmenulogin = filter_input(
935  INPUT_POST,
936  'advmenulogin'
937  );
938  $adv = filter_input(
939  INPUT_POST,
940  'adv'
941  );
942  $ServicesToEdit = array(
943  'FOG_ADVANCED_MENU_LOGIN' => $advmenulogin,
944  'FOG_PXE_ADVANCED' => $adv,
945  );
946  }
947  ksort($ServicesToEdit);
948  $ids = self::getSubObjectIDs(
949  'Service',
950  array(
951  'name' => array_keys($ServicesToEdit)
952  )
953  );
954  $items = array();
955  $iteration = 0;
956  foreach ($ServicesToEdit as $key => &$value) {
957  $items[] = array($ids[$iteration], $key, $value);
958  $iteration++;
959  unset($value);
960  }
961  if (count($items) > 0) {
962  self::getClass('ServiceManager')
963  ->insertBatch(
964  array(
965  'id',
966  'name',
967  'value'
968  ),
969  $items
970  );
971  }
972  $msg = json_encode(
973  array(
974  'msg' => _('iPXE Settings updated successfully!'),
975  'title' => _('iPXE Update Success')
976  )
977  );
978  } catch (Exception $e) {
979  $msg = json_encode(
980  array(
981  'error' => $e->getMessage(),
982  'title' => _('iPXE Update Fail')
983  )
984  );
985  }
986  echo $msg;
987  exit;
988  }
994  public function customizepxe()
995  {
996  $this->title = self::$foglang['PXEMenuCustomization'];
997  $this->templates = array(
998  '${field}',
999  '${input}',
1000  );
1001  Route::listem('pxemenuoptions');
1002  $Menus = json_decode(
1003  Route::getData()
1004  );
1005  $Menus = $Menus->pxemenuoptionss;
1006  echo '<div class="col-xs-9">';
1007  echo '<div class="panel panel-info">';
1008  echo '<div class="panel-heading text-center">';
1009  echo '<h4 class="title">';
1010  echo $this->title;
1011  echo '</h4>';
1012  echo '</div>';
1013  echo '<div class="panel-body">';
1014  echo _('This item allows you to edit all of the iPXE Menu items as you');
1015  echo ' ';
1016  echo _('see fit');
1017  echo '. ';
1018  echo _('Mind you');
1019  echo ', ';
1020  echo _('iPXE syntax is very finicky when it comes to editing');
1021  echo '. ';
1022  echo _('If you need help understanding what items are needed please');
1023  echo ' ';
1024  echo _('see the forums or lookup the commands and scripts available');
1025  echo ' ';
1026  echo _('from');
1027  echo ' ';
1028  echo '<a href="http://ipxe.org">';
1029  echo 'ipxe.org';
1030  echo '</a>';
1031  echo '.';
1032  echo '<hr/>';
1033  foreach ((array)$Menus as &$Menu) {
1034  $divTab = preg_replace(
1035  '#[^\w\-]#',
1036  '_',
1037  $Menu->name
1038  );
1039  $menuid = in_array(
1040  $Menu->id,
1041  range(1, 13)
1042  );
1043  $menuDefault = (
1044  $Menu->default ?
1045  ' checked' :
1046  ''
1047  );
1048  $hotKey = (
1049  $Menu->hotkey ?
1050  ' checked' :
1051  ''
1052  );
1053  $keySeq = $Menu->keysequence;
1054  $fields = array(
1055  '<label for="menu_item'
1056  . $divTab
1057  . '">'
1058  . _('Menu Item')
1059  . '</label>' => '<div class="input-group">'
1060  . '<input type="text" class="form-control" value="'
1061  . $Menu->name
1062  . '" name="menu_item" id="menu_item'
1063  . $divTab
1064  . '"/>'
1065  . '</div>',
1066  '<label for="menu_description'
1067  . $divTab
1068  . '">'
1069  . _('Description')
1070  . '</label>' => '<div class="input-group">'
1071  . '<textarea name="menu_description" id="menu_description'
1072  . $divTab
1073  . '" class="form-control">'
1074  . $Menu->description
1075  . '</textarea>'
1076  . '</div>',
1077  '<label for="menu_params'
1078  . $divTab
1079  . '">'
1080  . _('Parameters')
1081  . '</label>' => '<div class="input-group">'
1082  . '<textarea name="menu_params" id="menu_params'
1083  . $divTab
1084  . '" class="form-control">'
1085  . $Menu->params
1086  . '</textarea>'
1087  . '</div>',
1088  '<label for="menu_options'
1089  . $divTab
1090  . '">'
1091  . _('Boot Options')
1092  . '</label>' => '<div class="input-group">'
1093  . '<input type="text" name="menu_options" id="'
1094  . 'menu_options'
1095  . $divTab
1096  . '" value="'
1097  . $Menu->args
1098  . '" class="form-control"/>'
1099  . '</div>',
1100  '<label for="menudef'
1101  . $divTab
1102  . '">'
1103  . _('Default Item')
1104  . '</label>' => '<input type="checkbox" name="menu_default" id="'
1105  . 'menudef'
1106  . $divTab
1107  . '"'
1108  . $menuDefault
1109  . '/>',
1110  '<label for="hotkey'
1111  . $divTab
1112  . '">'
1113  . _('Hot Key Enabled')
1114  . '</label>' => '<input type="checkbox" name="hotkey" id="hotkey'
1115  . $divTab
1116  . '"'
1117  . $hotKey
1118  . '/>',
1119  '<label for="menu_hotkey'
1120  . $divTab
1121  . '">'
1122  . _('Hot Key to use')
1123  . '</label>' => '<div class="input-group">'
1124  . '<input type="text" name="keysequence" value="'
1125  . $keySeq
1126  . '" class="form-control" id="menu_hotkey'
1127  . $divTab
1128  . '"/>'
1129  . '</div>',
1130  '<label for="menu_regsel'
1131  . $divTab
1132  . '">'
1133  . _('Menu Show with')
1134  . '</label>' => '<div class="input-group">'
1135  . self::getClass(
1136  'PXEMenuOptionsManager'
1137  )->regSelect(
1138  $Menu->regMenu,
1139  'menu_regsel'
1140  . $divTab
1141  )
1142  . '</div>',
1143  '<label for="menu_id'
1144  . $divTab
1145  . '">'
1146  . _('Make Changes?')
1147  . '</label>'
1148  . '<input type="hidden" name="menu_id" value="'
1149  . $Menu->id
1150  . '"/>' => '<button name="saveform" type="submit" class="'
1151  . 'btn btn-info btn-block" id="menu_id'
1152  . $divTab
1153  . '">'
1154  . self::$foglang['Submit']
1155  . '</button>',
1156  (
1157  !$menuid ?
1158  '<label for="menu_del'
1159  . $divTab
1160  . '">'
1161  . _('Delete Menu Item')
1162  . '</label>'
1163  . '<input type="hidden" name="rmid" value="'
1164  . $Menu->id
1165  . '"/>' :
1166  ''
1167  ) => (
1168  !$menuid ?
1169  '<button name="delform" type="submit" class="'
1170  . 'btn btn-danger btn-block" id="menu_del'
1171  . $divTab
1172  . '">'
1173  . self::$foglang['Delete']
1174  . '</button>' :
1175  ''
1176  ),
1177  );
1178  $fields = array_filter($fields);
1179  array_walk($fields, $this->fieldsToData);
1180  self::$HookManager->processEvent(
1181  sprintf(
1182  'BOOT_ITEMS_%s',
1183  $divTab
1184  ),
1185  array(
1186  'data' => &$this->data,
1187  'templates' => &$this->templates,
1188  'attributes' => &$this->attributes,
1189  'headerData' => &$this->headerData
1190  )
1191  );
1192  echo '<div class="panel panel-info">';
1193  echo '<div class="panel-heading text-center expand_trigger '
1194  . 'hand" id="pxeItem_'
1195  . $divTab
1196  . '">';
1197  echo '<h4 class="title">';
1198  echo $Menu->name;
1199  echo '</h4>';
1200  echo '</div>';
1201  echo '<div class="panel-body hidefirst" id="pxeItem_'
1202  . $divTab
1203  . '">';
1204  echo '<form class="form-horizontal" method="post" action="'
1205  . $this->formAction
1206  . '">';
1207  echo $this->render(12);
1208  echo '</form>';
1209  echo '</div>';
1210  echo '</div>';
1211  unset(
1212  $this->data,
1213  $Menu
1214  );
1215  }
1216  echo '</div>';
1217  echo '</div>';
1218  echo '</div>';
1219  }
1225  public function customizepxePost()
1226  {
1227  $menuid = filter_input(
1228  INPUT_POST,
1229  'menu_id'
1230  );
1231  if (isset($_POST['saveform'])) {
1232  $menu_item = filter_input(
1233  INPUT_POST,
1234  'menu_item'
1235  );
1236  $menu_desc = filter_input(
1237  INPUT_POST,
1238  'menu_description'
1239  );
1240  $menu_params = filter_input(
1241  INPUT_POST,
1242  'menu_params'
1243  );
1244  $menu_options = filter_input(
1245  INPUT_POST,
1246  'menu_options'
1247  );
1248  $menu_regmenu = filter_input(
1249  INPUT_POST,
1250  'menu_regmenu'
1251  );
1252  $menu_hotkey = (int)isset($_POST['hotkey']);
1253  $menu_key = filter_input(
1254  INPUT_POST,
1255  'keysequence'
1256  );
1257  $menu_default = (int)isset($_POST['menu_default']);
1258  self::getClass('PXEMenuOptionsManager')
1259  ->update(
1260  array(
1261  'id' => $menuid
1262  ),
1263  '',
1264  array(
1265  'name' => $menu_item,
1266  'description' => $menu_desc,
1267  'params' => $menu_params,
1268  'regMenu' => $menu_regmenu,
1269  'args' => $menu_options,
1270  'default' => $menu_default,
1271  'hotkey' => $menu_hotkey,
1272  'keysequence' => $menu_key
1273  )
1274  );
1275  if ($menu_default) {
1276  $MenuIDs = self::getSubObjectIDs('PXEMenuOptions');
1277  natsort($MenuIDs);
1278  $MenuIDs = array_unique(
1279  array_diff(
1280  $MenuIDs,
1281  (array)$menuid
1282  )
1283  );
1284  natsort($MenuIDs);
1285  self::getClass('PXEMenuOptionsManager')
1286  ->update(
1287  array(
1288  'id' => $MenuIDs
1289  ),
1290  '',
1291  array(
1292  'default' => '0'
1293  )
1294  );
1295  }
1296  unset($MenuIDs);
1297  $DefMenuIDs = self::getSubObjectIDs(
1298  'PXEMenuOptions',
1299  array('default' => 1)
1300  );
1301  if (!count($DefMenuIDs)) {
1302  self::getClass('PXEMenuOptions', 1)
1303  ->set('default', 1)
1304  ->save();
1305  }
1306  unset($DefMenuIDs);
1307  $msg = json_encode(
1308  array(
1309  'msg' => _("$menu_item successfully updated!"),
1310  'title' => _('iPXE Item Update Success')
1311  )
1312  );
1313  }
1314  if (isset($_POST['delform'])) {
1315  $rmid = filter_input(
1316  INPUT_POST,
1317  'rmid'
1318  );
1319  $menuname = self::getClass(
1320  'PXEMenuOptions',
1321  $rmid
1322  );
1323  if ($menuname->destroy()) {
1324  $msg = json_encode(
1325  array(
1326  'msg' => $menuname->get('name')
1327  . ' '
1328  . _('successfully removed!'),
1329  'title' => _('iPXE Item Remove Success')
1330  )
1331  );
1332  }
1333  $countDefault = self::getClass('PXEMenuOptionsManager')
1334  ->count(
1335  array(
1336  'default' => 1
1337  )
1338  );
1339  if ($countDefault == 0
1340  || $countDefault > 1
1341  ) {
1342  self::getClass('PXEMenuOptions', 1)
1343  ->set('default', 1)
1344  ->save();
1345  }
1346  }
1347  echo $msg;
1348  exit;
1349  }
1355  public function newMenu()
1356  {
1357  $this->title = _('Create New iPXE Menu Entry');
1358  $this->templates = array(
1359  '${field}',
1360  '${input}',
1361  );
1362  $menu_item = filter_input(
1363  INPUT_POST,
1364  'menu_item'
1365  );
1366  $menu_desc = filter_input(
1367  INPUT_POST,
1368  'menu_description'
1369  );
1370  $menu_params = filter_input(
1371  INPUT_POST,
1372  'menu_params'
1373  );
1374  $menu_options = filter_input(
1375  INPUT_POST,
1376  'menu_options'
1377  );
1378  $menu_regmenu = filter_input(
1379  INPUT_POST,
1380  'menu_regmenu'
1381  );
1382  $menu_hotkey = (
1383  isset($_POST['hotkey']) ?
1384  ' checked' :
1385  ''
1386  );
1387  $menu_key = filter_input(
1388  INPUT_POST,
1389  'keysequence'
1390  );
1391  $menu_default = (
1392  isset($_POST['menu_default']) ?
1393  ' checked' :
1394  ''
1395  );
1396  $fields = array(
1397  '<label for="menu_item">'
1398  . _('Menu Item')
1399  . '</label>' => '<div class="input-group">'
1400  . '<input type="text" class="form-control" value="'
1401  . '" name="menu_item" id="menu_item'
1402  . $menu_item
1403  . '"/>'
1404  . '</div>',
1405  '<label for="menu_description">'
1406  . _('Description')
1407  . '</label>' => '<div class="input-group">'
1408  . '<textarea name="menu_description" id="menu_description'
1409  . '" class="form-control">'
1410  . $menu_desc
1411  . '</textarea>'
1412  . '</div>',
1413  '<label for="menu_params">'
1414  . _('Parameters')
1415  . '</label>' => '<div class="input-group">'
1416  . '<textarea name="menu_params" id="menu_params'
1417  . '" class="form-control">'
1418  . $menu_params
1419  . '</textarea>'
1420  . '</div>',
1421  '<label for="menu_options">'
1422  . _('Boot Options')
1423  . '</label>' => '<div class="input-group">'
1424  . '<input type="text" name="menu_options" id="'
1425  . 'menu_options'
1426  . '" value="'
1427  . $menu_options
1428  . '" class="form-control"/>'
1429  . '</div>',
1430  '<label for="menudef">'
1431  . _('Default Item')
1432  . '</label>' => '<input type="checkbox" name="menu_default" id="'
1433  . 'menudef'
1434  . '"'
1435  . $menu_default
1436  . '/>',
1437  '<label for="hotkey">'
1438  . _('Hot Key Enabled')
1439  . '</label>' => '<input type="checkbox" name="hotkey" id="hotkey'
1440  . '"'
1441  . $menu_hotkey
1442  . '/>',
1443  '<label for="menu_hotkey">'
1444  . _('Hot Key to use')
1445  . '</label>' => '<div class="input-group">'
1446  . '<input type="text" name="keysequence" value="'
1447  . $menu_key
1448  . '" class="form-control" id="menu_hotkey'
1449  . '"/>'
1450  . '</div>',
1451  '<label for="menu_regsel">'
1452  . _('Menu Show with')
1453  . '</label>' => '<div class="input-group">'
1454  . self::getClass(
1455  'PXEMenuOptionsManager'
1456  )->regSelect(
1457  $menu_regmenu,
1458  'menu_regsel'
1459  )
1460  . '</div>',
1461  '<label for="menu_id'
1462  . '">'
1463  . _('Make Changes?')
1464  . '</label>'
1465  . '<input type="hidden" name="menu_id" value="'
1466  . '"/>' => '<button name="saveform" type="submit" class="'
1467  . 'btn btn-info btn-block" id="menu_id'
1468  . '">'
1469  . self::$foglang['Submit']
1470  . '</button>',
1471  );
1472  $fields = array_filter($fields);
1473  array_walk($fields, $this->fieldsToData);
1474  self::$HookManager
1475  ->processEvent(
1476  'BOOT_ITEMS_ADD',
1477  array(
1478  'data' => &$this->data,
1479  'templates' => &$this->templates,
1480  'attributes' => &$this->attributes,
1481  'headerData' => &$this->headerData
1482  )
1483  );
1484  echo '<div class="col-xs-9">';
1485  echo '<div class="panel panel-info">';
1486  echo '<div class="panel-heading text-center">';
1487  echo '<h4 class="title">';
1488  echo _('New iPXE Menu');
1489  echo '</h4>';
1490  echo '</div>';
1491  echo '<div class="panel-body">';
1492  echo '<form class="form-horizontal" method="post" action="'
1493  . $this->formAction
1494  . '">';
1495  $this->render(12);
1496  echo '</form>';
1497  echo '</div>';
1498  echo '</div>';
1499  echo '</div>';
1500  }
1506  public function newMenuPost()
1507  {
1508  $menu_item = filter_input(
1509  INPUT_POST,
1510  'menu_item'
1511  );
1512  $menu_desc = filter_input(
1513  INPUT_POST,
1514  'menu_description'
1515  );
1516  $menu_params = filter_input(
1517  INPUT_POST,
1518  'menu_params'
1519  );
1520  $menu_options = filter_input(
1521  INPUT_POST,
1522  'menu_options'
1523  );
1524  $menu_regmenu = filter_input(
1525  INPUT_POST,
1526  'menu_regmenu'
1527  );
1528  $menu_hotkey = (int)isset($_POST['hotkey']);
1529  $menu_key = filter_input(
1530  INPUT_POST,
1531  'keysequence'
1532  );
1533  $menu_default = (int)isset($_POST['menu_default']);
1534  try {
1535  if (!$menu_item) {
1536  throw new Exception(_('Menu Item or title cannot be blank'));
1537  }
1538  if (!$menu_desc) {
1539  throw new Exception(_('A description needs to be set'));
1540  }
1541  if ($menu_default) {
1542  self::getClass('PXEMenuOptionsManager')
1543  ->update(
1544  '',
1545  '',
1546  array(
1547  'default' => 0
1548  )
1549  );
1550  }
1551  $Menu = self::getClass('PXEMenuOptions')
1552  ->set('name', $menu_item)
1553  ->set('description', $menu_desc)
1554  ->set('params', $menu_params)
1555  ->set('regMenu', $menu_regmenu)
1556  ->set('args', $menu_options)
1557  ->set('default', $menu_default);
1558  if (!$Menu->save()) {
1559  throw new Exception(_('iPXE Item create failed!'));
1560  }
1561  $countDefault = self::getClass('PXEMenuOptionsManager')
1562  ->count(
1563  array(
1564  'default' => 1
1565  )
1566  );
1567  if ($countDefault == 0 || $countDefault > 1) {
1568  self::getClass('PXEMenuOptions', 1)
1569  ->set('default', 1)
1570  ->save();
1571  }
1572  $hook = 'MENU_ADD_SUCCESS';
1573  $msg = json_encode(
1574  array(
1575  'msg' => _('iPXE Item added!'),
1576  'title' => _('iPXE Item Create Success')
1577  )
1578  );
1579  } catch (Exception $e) {
1580  $hook = 'MENU_ADD_FAIL';
1581  $msg = json_encode(
1582  array(
1583  'error' => $e->getMessage(),
1584  'title' => _('iPXE Item Create Fail')
1585  )
1586  );
1587  }
1588  self::$HookManager
1589  ->processEvent(
1590  $hook,
1591  array(
1592  'Menu' => &$Menu
1593  )
1594  );
1595  unset($Menu);
1596  echo $msg;
1597  exit;
1598  }
1606  public function clientupdater($formNeeded = true)
1607  {
1608  $this->title = _('FOG Client Service Updater');
1609  $this->headerData = array(
1610  _('Delete'),
1611  _('Module Name'),
1612  _('Module MD5'),
1613  _('Module Type'),
1614  );
1615  $this->templates = array(
1616  '<input type="checkbox" name="delcu[]" class='
1617  . '"delid" id="delcuid${client_id}" value='
1618  . '"${client_id}"/>',
1619  '<input type="hidden" name="name" value='
1620  . '"FOG_CLIENT_CLIENTUPDATER_ENABLED"/>${name}',
1621  '${module}',
1622  '${type}'
1623  );
1624  $this->attributes = array(
1625  array(),
1626  array(),
1627  array(),
1628  array(
1629  'class' => 'filter-false'
1630  )
1631  );
1632  Route::listem('clientupdater');
1633  $ClientUpdates = json_decode(
1634  Route::getData()
1635  );
1636  $ClientUpdates = $ClientUpdates->clientupdaters;
1637  foreach ((array)$ClientUpdates as &$ClientUpdate) {
1638  $this->data[] = array(
1639  'name' => $ClientUpdate->name,
1640  'module' => $ClientUpdate->md5,
1641  'type' => $ClientUpdate->type,
1642  'client_id' => $ClientUpdate->id,
1643  'id' => $ClientUpdate->id,
1644  );
1645  unset($ClientUpdate);
1646  }
1647  self::$HookManager
1648  ->processEvent(
1649  'CLIENT_UPDATE',
1650  array(
1651  'data' => &$this->data,
1652  'templates' => &$this->templates,
1653  'attributes' => &$this->attributes,
1654  'headerData' => &$this->headerData
1655  )
1656  );
1657  if ($formNeeded) {
1658  echo '<div class="col-xs-9">';
1659  echo '<form class="form-horizontal" method="post" action="'
1660  . $this->formAction
1661  . '&tab=clientupdater" enctype="multipart/form-data">';
1662  }
1663  echo '<div class="panel panel-info">';
1664  echo '<div class="panel-heading text-center">';
1665  echo '<h4 class="title">';
1666  echo _('Current files');
1667  echo '</h4>';
1668  echo '</div>';
1669  echo '<div class="panel-body">';
1670  echo _('NOTICE');
1671  echo ': ';
1672  echo _('The below items are only used for the old client.');
1673  echo ' ';
1674  echo _('Old clients are the clients that came with FOG');
1675  echo ' ';
1676  echo _('Version 1.2.0 and earlier');
1677  echo '<hr/>';
1678  echo _('This section allows you to update the modules and');
1679  echo ' ';
1680  echo _('config files that run on the client computers.');
1681  echo ' ';
1682  echo _('The clients will checkin with the server from time');
1683  echo ' ';
1684  echo _('to time to see if a new module is published.');
1685  echo ' ';
1686  echo _('If a new module is published the client will');
1687  echo ' ';
1688  echo _('download the module and use it on the next');
1689  echo ' ';
1690  echo _('time the service is started.');
1691  echo '<hr/>';
1692  $this->render(12);
1693  unset(
1694  $this->data,
1695  $this->form,
1696  $this->headerData,
1697  $this->templates,
1698  $this->attributes
1699  );
1700  $this->templates = array(
1701  '${field}',
1702  '${input}'
1703  );
1704  $this->attributes = array(
1705  array('class' => 'col-xs-4'),
1706  array('class' => 'col-xs-8 form-group')
1707  );
1708  $fields = array(
1709  '<label for="file">'
1710  . _('Upload file')
1711  . ' '
1712  . _('Max Size')
1713  . ': '
1714  . ini_get('post_max_size')
1715  . '</label>' => '<div class="input-group">'
1716  . '<label class="input-group-btn">'
1717  . '<span class="btn btn-info">'
1718  . _('Browse')
1719  . '<input type="file" class="hidden" multiple name='
1720  . '"module[]" id="file"/>'
1721  . '</span>'
1722  . '</label>'
1723  . '<input type="text" class="form-control filedisp" readonly/>'
1724  . '</div>'
1725  );
1726  array_walk($fields, $this->fieldsToData);
1727  self::$HookManager
1728  ->processEvent(
1729  'CLIENT_UPDATE',
1730  array(
1731  'data' => &$this->data,
1732  'templates' => &$this->templates,
1733  'attributes' => &$this->attributes
1734  )
1735  );
1736  $this->render(12);
1737  echo '<div class="form-group">';
1738  echo '<label class="control-label col-xs-4" for="deletecu">';
1739  echo _('Delete Selected Items');
1740  echo '</label>';
1741  echo '<div class="col-xs-8">';
1742  echo '<button class="btn btn-danger btn-block" type="submit" id="deletecu" '
1743  . 'name="deletecu">';
1744  echo _('Delete');
1745  echo '</button>';
1746  echo '</div>';
1747  echo '</div>';
1748  echo '<div class="form-group">';
1749  echo '<label class="control-label col-xs-4" for="upload">';
1750  echo _('Make Changes');
1751  echo '</label>';
1752  echo '<div class="col-xs-8">';
1753  echo '<button class="btn btn-info btn-block" type="submit" id="upload" '
1754  . 'name="upload">';
1755  echo _('Update');
1756  echo '</button>';
1757  echo '</div>';
1758  echo '</div>';
1759  unset(
1760  $this->data,
1761  $this->form,
1762  $this->headerData,
1763  $this->templates,
1764  $this->attributes
1765  );
1766  echo '</div>';
1767  echo '</div>';
1768  if ($formNeeded) {
1769  echo '</form>';
1770  echo '</div>';
1771  }
1772  }
1778  public function clientupdaterPost()
1779  {
1780  try {
1781  if (isset($_POST['deletecu'])) {
1782  $delcus = filter_input_array(
1783  INPUT_POST,
1784  array(
1785  'delcu' => array(
1786  'flags' => FILTER_REQUIRE_ARRAY
1787  )
1788  )
1789  );
1790  $delcus = $delcus['delcu'];
1791  self::getClass('ClientUpdaterManager')
1792  ->destroy(array('id' => $delcus));
1793  echo json_encode(
1794  array(
1795  'msg' => _('Item removed successfully!'),
1796  'title' => _('Client Modules Change Success')
1797  )
1798  );
1799  exit;
1800  }
1801  if (isset($_POST['upload'])) {
1802  if (count($_FILES['module']['tmp_name']) < 1) {
1803  throw new Exception(_('No file uploaded!'));
1804  }
1805  $error = $_FILES['module']['error'];
1806  foreach ((array)$error as &$err) {
1807  if ($err > 0) {
1808  throw new UploadException($err);
1809  }
1810  unset($err);
1811  }
1812  $tmpfiles = $_FILES['module']['tmp_name'];
1813  foreach ((array)$tmpfiles as $index => &$tmp_name) {
1814  if (!file_exists($tmp_name)) {
1815  continue;
1816  }
1817  if (!($md5 = md5_file($tmp_name))) {
1818  continue;
1819  }
1820  $filename = basename(
1821  $_FILES['module']['name'][$index]
1822  );
1823  $fp = fopen(
1824  $tmp_name,
1825  'rb'
1826  );
1827  $content = fread(
1828  $fp,
1829  self::getFilesize($tmp_name)
1830  );
1831  fclose($fp);
1832  $finfo = new finfo(FILEINFO_MIME);
1833  $f = $finfo->file($tmp_name);
1834  self::getClass('ClientUpdater')
1835  ->set('name', $filename)
1836  ->load('name')
1837  ->set('md5', $md5)
1838  ->set('type', $f)
1839  ->set('file', $content)
1840  ->save();
1841  }
1842  global $tab;
1844  $this->formAction
1845  );
1846  }
1847  $msg = json_encode(
1848  array(
1849  'msg' => _('Modules added/updated successfully!'),
1850  'title' => _('Client Modules Change Success')
1851  )
1852  );
1853  } catch (Exception $e) {
1854  $msg = json_encode(
1855  array(
1856  'error' => $e->getMessage(),
1857  'title' => _('Client Modules Change Fail')
1858  )
1859  );
1860  }
1861  echo $msg;
1862  exit;
1863  }
1869  public function maclist()
1870  {
1871  $this->title = _('MAC Address Manufacturer Listing');
1872  echo '<div class="col-xs-9">';
1873  echo '<div class="panel panel-info">';
1874  echo '<div class="panel-heading text-center">';
1875  echo '<h4 class="title">';
1876  echo $this->title;
1877  echo '</h4>';
1878  echo '</div>';
1879  echo '<div class="panel-body text-center">';
1880  echo _(
1881  'This section allows you to import known mac address makers '
1882  . 'into the FOG database for easier identification'
1883  );
1884  echo '<br/>';
1885  echo '<div class="row">';
1886  echo _('Current Records');
1887  echo ': ';
1888  echo self::getMACLookupCount();
1889  echo '</div>';
1890  echo '<br/>';
1891  echo '<div class="row">';
1892  echo '<a href="http://standards-oui.ieee.org/oui.txt">';
1893  echo 'http://standards-oui.ieee.org/oui.txt';
1894  echo '</a>';
1895  echo '</div>';
1896  echo '<br/>';
1897  echo '<div class="row">';
1898  echo '<div id="delete"></div>';
1899  echo '<div id="update"></div>';
1900  echo '<div class="form-group col-xs-offset-4 col-xs-2">';
1901  echo '<button class="macButtons btn btn-danger btn-block" type='
1902  . '"button" id="macButtonDel">';
1903  echo _('Delete MACs');
1904  echo '</button>';
1905  echo '</div>';
1906  echo '<div class="form-group col-xs-2">';
1907  echo '<button class="macButtons btn btn-info btn-block" type='
1908  . '"button" id="macButtonUp">';
1909  echo _('Update MACs');
1910  echo '</button>';
1911  echo '</div>';
1912  echo '</div>';
1913  echo '</div>';
1914  echo '</div>';
1915  echo '</div>';
1916  }
1922  public function maclistPost()
1923  {
1924  if (isset($_GET['update'])) {
1926  $url = 'http://standards-oui.ieee.org/oui.txt';
1927  if (($fh = fopen($url, 'rb')) === false) {
1928  throw new Exception(_('Could not read temp file'));
1929  }
1930  $items = array();
1931  $start = 18;
1932  $imported = 0;
1933  $pat = '#^([0-9a-fA-F]{2}[:-]){2}([0-9a-fA-F]{2}).*$#';
1934  while (($line = fgets($fh, 4096)) !== false) {
1935  $line = trim($line);
1936  if (!preg_match($pat, $line)) {
1937  continue;
1938  }
1939  $mac = trim(
1940  substr(
1941  $line,
1942  0,
1943  8
1944  )
1945  );
1946  $mak = trim(
1947  substr(
1948  $line,
1949  $start,
1950  strlen($line) - $start
1951  )
1952  );
1953  if (strlen($mac) != 8
1954  || strlen($mak) < 1
1955  ) {
1956  continue;
1957  }
1958  $items[] = array(
1959  $mac,
1960  $mak
1961  );
1962  }
1963  fclose($fh);
1964  if (count($items) > 0) {
1965  list(
1966  $first_id,
1967  $affected_rows
1968  ) = self::getClass('OUIManager')
1969  ->insertBatch(
1970  array(
1971  'prefix',
1972  'name'
1973  ),
1974  $items
1975  );
1976  $imported += $affected_rows;
1977  unset($items);
1978  }
1979  unset($first_id);
1980  }
1981  if (isset($_GET['clear'])) {
1983  }
1985  self::redirect('?node=about&sub=maclist');
1986  }
1992  public function settings()
1993  {
1994  $ServiceNames = array(
1995  'FOG_REGISTRATION_ENABLED',
1996  'FOG_PXE_MENU_HIDDEN',
1997  'FOG_QUICKREG_AUTOPOP',
1998  'FOG_CLIENT_AUTOUPDATE',
1999  'FOG_CLIENT_AUTOLOGOFF_ENABLED',
2000  'FOG_CLIENT_CLIENTUPDATER_ENABLED',
2001  'FOG_CLIENT_DIRECTORYCLEANER_ENABLED',
2002  'FOG_CLIENT_DISPLAYMANAGER_ENABLED',
2003  'FOG_CLIENT_GREENFOG_ENABLED',
2004  'FOG_CLIENT_HOSTREGISTER_ENABLED',
2005  'FOG_CLIENT_HOSTNAMECHANGER_ENABLED',
2006  'FOG_CLIENT_POWERMANAGEMENT_ENABLED',
2007  'FOG_CLIENT_PRINTERMANAGER_ENABLED',
2008  'FOG_CLIENT_SNAPIN_ENABLED',
2009  'FOG_CLIENT_TASKREBOOT_ENABLED',
2010  'FOG_CLIENT_USERCLEANUP_ENABLED',
2011  'FOG_CLIENT_USERTRACKER_ENABLED',
2012  'FOG_ADVANCED_STATISTICS',
2013  'FOG_CHANGE_HOSTNAME_EARLY',
2014  'FOG_DISABLE_CHKDSK',
2015  'FOG_HOST_LOOKUP',
2016  'FOG_CAPTUREIGNOREPAGEHIBER',
2017  'FOG_USE_ANIMATION_EFFECTS',
2018  'FOG_USE_LEGACY_TASKLIST',
2019  'FOG_USE_SLOPPY_NAME_LOOKUPS',
2020  'FOG_PLUGINSYS_ENABLED',
2021  'FOG_FORMAT_FLAG_IN_GUI',
2022  'FOG_NO_MENU',
2023  'FOG_ALWAYS_LOGGED_IN',
2024  'FOG_ADVANCED_MENU_LOGIN',
2025  'FOG_TASK_FORCE_REBOOT',
2026  'FOG_EMAIL_ACTION',
2027  'FOG_FTP_IMAGE_SIZE',
2028  'FOG_KERNEL_DEBUG',
2029  'FOG_ENFORCE_HOST_CHANGES',
2030  'FOG_LOGIN_INFO_DISPLAY',
2031  'MULTICASTGLOBALENABLED',
2032  'SCHEDULERGLOBALENABLED',
2033  'PINGHOSTGLOBALENABLED',
2034  'IMAGESIZEGLOBALENABLED',
2035  'IMAGEREPLICATORGLOBALENABLED',
2036  'SNAPINREPLICATORGLOBALENABLED',
2037  'SNAPINHASHGLOBALENABLED',
2038  'FOG_QUICKREG_IMG_WHEN_REG',
2039  'FOG_QUICKREG_PROD_KEY_BIOS',
2040  'FOG_TASKING_ADV_SHUTDOWN_ENABLED',
2041  'FOG_TASKING_ADV_WOL_ENABLED',
2042  'FOG_TASKING_ADV_DEBUG_ENABLED',
2043  'FOG_API_ENABLED',
2044  'FOG_IMAGE_LIST_MENU',
2045  'FOG_REAUTH_ON_DELETE',
2046  'FOG_REAUTH_ON_EXPORT'
2047  );
2048  self::$HookManager
2049  ->processEvent(
2050  'SERVICE_NAMES',
2051  array(
2052  'ServiceNames' => &$ServiceNames
2053  )
2054  );
2055  $this->title = _('FOG System Settings');
2056  unset(
2057  $this->data,
2058  $this->form,
2059  $this->headerData,
2060  $this->templates,
2061  $this->attributes
2062  );
2063  echo '<div class="col-xs-9">';
2064  echo '<div class="panel panel-info">';
2065  echo '<div class="panel-heading text-center">';
2066  echo '<h4 class="title">';
2067  echo $this->title;
2068  echo '</h4>';
2069  echo '</div>';
2070  echo '<div class="panel-body">';
2071  echo '<form class="form-horizontal" method="post" action="'
2072  . $this->formAction
2073  . '" enctype="multipart/form-data">';
2074  echo _('This section allows you to customize or alter')
2075  . ' '
2076  . _('the way in which FOG operates')
2077  . '. '
2078  . _('Please be very careful changing any of the following settings')
2079  . ', '
2080  . _('as they can cause issues that are difficult to troubleshoot')
2081  . '.';
2082  echo '<hr/>';
2083  $this->attributes = array(
2084  array('class' => 'col-xs-4'),
2085  array('class' => 'col-xs-6 form-group'),
2086  array('class' => 'col-xs-2'),
2087  );
2088  $this->templates = array(
2089  '${field}',
2090  '${input}',
2091  '${span}',
2092  );
2093  echo '<div class="col-xs-12">';
2094  echo '<div class="panel panel-info">';
2095  echo '<div class="panel-heading text-center trigger_expand hand">';
2096  echo '<h4 class="title">';
2097  echo _('Expand All');
2098  echo '</h4>';
2099  echo '</div>';
2100  echo '</div>';
2101  $catset = false;
2102  Route::listem('service', 'category', true);
2103  $Services = json_decode(
2104  Route::getData()
2105  );
2106  $Services = $Services->services;
2107  $divTab = false;
2108  foreach ((array)$Services as &$Service) {
2109  $curcat = $Service->category;
2110  if (!$divTab) {
2111  $divTab = preg_replace(
2112  '#[^\w\-]#',
2113  '_',
2114  $Service->category
2115  );
2116  }
2117  if ($curcat != $catset) {
2118  if ($catset !== false) {
2119  $this->data[] = array(
2120  'field' => '<label for='
2121  . '"'
2122  . $divTab
2123  . '">'
2124  . _('Make Changes?')
2125  . '</label>',
2126  'input' => '<button class="'
2127  . 'btn btn-info btn-block" type="submit" '
2128  . 'name="'
2129  . $divTab
2130  . '" id="'
2131  . $divTab
2132  . '">'
2133  . _('Update')
2134  . '</button>',
2135  'span' => ''
2136  );
2137  $this->render(12);
2138  unset($this->data);
2139  echo '</div>';
2140  echo '</div>';
2141  $divTab = preg_replace(
2142  '#[^\w\-]#',
2143  '_',
2144  $Service->category
2145  );
2146  }
2147  echo '<div class="panel panel-info">';
2148  echo '<div class="panel-heading text-center expand_trigger '
2149  . 'hand" id="'
2150  . $divTab
2151  . '">';
2152  echo '<h4 class="title">';
2153  echo $Service->category;
2154  echo '</h4>';
2155  echo '</div>';
2156  echo '<div class="panel-body hidefirst" id="'
2157  . $divTab
2158  . '">';
2159  }
2160  switch ($Service->name) {
2161  case 'FOG_PIGZ_COMP':
2162  $type = '<div class="col-xs-8">'
2163  . '<div class="rangegen pigz"></div>'
2164  . '</div>'
2165  . '<div class="col-xs-4">'
2166  . '<div class="input-group">'
2167  . '<input type="text" name="${service_id}" class="form-control '
2168  . 'showVal pigz" maxsize="2" value="${service_value}" id='
2169  . '"${service_name}" readonly/>'
2170  . '</div>'
2171  . '</div>';
2172  break;
2173  case 'FOG_KERNEL_LOGLEVEL':
2174  $type = '<div class="col-xs-8">'
2175  . '<div class="rangegen loglvl"></div>'
2176  . '</div>'
2177  . '<div class="col-xs-4">'
2178  . '<div class="input-group">'
2179  . '<input type="text" name="${service_id}" class="form-control '
2180  . 'showVal loglvl" maxsize="2" value="${service_value}" id='
2181  . '"${service_name}" readonly/>'
2182  . '</div>'
2183  . '</div>';
2184  break;
2185  case 'FOG_INACTIVITY_TIMEOUT':
2186  $type = '<div class="col-xs-8">'
2187  . '<div class="rangegen inact"></div>'
2188  . '</div>'
2189  . '<div class="col-xs-4">'
2190  . '<div class="input-group">'
2191  . '<input type="text" name="${service_id}" class="form-control '
2192  . 'showVal inact" maxsize="2" value="${service_value}" id='
2193  . '"${service_name}" readonly/>'
2194  . '</div>'
2195  . '</div>';
2196  break;
2197  case 'FOG_REGENERATE_TIMEOUT':
2198  $type = '<div class="col-xs-8">'
2199  . '<div class="rangegen regen"></div>'
2200  . '</div>'
2201  . '<div class="col-xs-4">'
2202  . '<div class="input-group">'
2203  . '<input type="text" name="${service_id}" class="form-control '
2204  . 'showVal regen" maxsize="5" value="${service_value}" id='
2205  . '"${service_name}" readonly/>'
2206  . '</div>'
2207  . '</div>';
2208  break;
2209  case 'FOG_IMAGE_COMPRESSION_FORMAT_DEFAULT':
2210  $vals = array(
2211  _('Partclone Gzip') => 0,
2212  _('Partclone Gzip Split 200MiB') => 2,
2213  _('Partclone Uncompressed') => 3,
2214  _('Partclone Uncompressed Split 200MiB') => 4,
2215  _('Partclone Zstd') => 5,
2216  _('Partclone Zstd Split 200MiB') => 6
2217  );
2218  ob_start();
2219  foreach ((array)$vals as $view => &$value) {
2220  printf(
2221  '<option value="%s"%s>%s</option>',
2222  $value,
2223  (
2224  $Service->value == $value ?
2225  ' selected' :
2226  ''
2227  ),
2228  $view
2229  );
2230  unset($value);
2231  }
2232  unset($vals);
2233  $type = '<div class="input-group">'
2234  . '<select name="${service_id}" '
2235  . 'autocomplete="off" '
2236  . 'class="form-control" id="${service_name}">'
2237  . ob_get_clean()
2238  . '</select>'
2239  . '</div>';
2240  break;
2241  case 'FOG_VIEW_DEFAULT_SCREEN':
2242  $screens = array('SEARCH','LIST');
2243  ob_start();
2244  foreach ((array)$screens as &$viewop) {
2245  printf(
2246  '<option value="%s"%s>%s</option>',
2247  strtolower($viewop),
2248  (
2249  $Service->value == strtolower($viewop) ?
2250  ' selected' :
2251  ''
2252  ),
2253  $viewop
2254  );
2255  unset($viewop);
2256  }
2257  unset($screens);
2258  $type = '<div class="input-group">'
2259  . '<select name="${service_id}" '
2260  . 'autocomplete="off" '
2261  . 'class="form-control" id="${service_name}">'
2262  . ob_get_clean()
2263  . '</select>'
2264  . '</div>';
2265  break;
2266  case 'FOG_MULTICAST_DUPLEX':
2267  $duplexTypes = array(
2268  'HALF_DUPLEX' => '--half-duplex',
2269  'FULL_DUPLEX' => '--full-duplex',
2270  );
2271  ob_start();
2272  foreach ((array)$duplexTypes as $types => &$val) {
2273  printf(
2274  '<option value="%s"%s>%s</option>',
2275  $val,
2276  (
2277  $Service->value == $val ?
2278  ' selected' :
2279  ''
2280  ),
2281  $types
2282  );
2283  unset($val);
2284  }
2285  $type = '<div class="input-group">'
2286  . '<select name="${service_id}" '
2287  . 'autocomplete="off" '
2288  . 'class="form-control" id="${service_name}">'
2289  . ob_get_clean()
2290  . '</select>'
2291  . '</div>';
2292  break;
2293  case 'FOG_BOOT_EXIT_TYPE':
2294  case 'FOG_EFI_BOOT_EXIT_TYPE':
2295  $type = '<div class="input-group">'
2297  $Service->id,
2298  $Service->value,
2299  false,
2300  $Service->name
2301  )
2302  . '</div>';
2303  break;
2304  case 'FOG_DEFAULT_LOCALE':
2305  $locale = self::getSetting('FOG_DEFAULT_LOCALE');
2306  ob_start();
2307  $langs =& self::$foglang['Language'];
2308  foreach ($langs as $lang => &$humanreadable) {
2309  printf(
2310  '<option value="%s"%s>%s</option>',
2311  $lang,
2312  (
2313  $locale == $lang
2314  || $locale == self::$foglang['Language'][$lang] ?
2315  ' selected' :
2316  ''
2317  ),
2318  $humanreadable
2319  );
2320  unset($humanreadable);
2321  }
2322  $type = '<div class="input-group">'
2323  . '<select name="${service_id}" '
2324  . 'autocomplete="off" '
2325  . 'class="form-control" id="${service_name}">'
2326  . ob_get_clean()
2327  . '</select>'
2328  . '</div>';
2329  break;
2330  case 'FOG_QUICKREG_IMG_ID':
2331  $type = '<div class="input-group">'
2332  . self::getClass('ImageManager')->buildSelectBox(
2333  $Service->value,
2334  $Service->id
2335  )
2336  . '</div>';
2337  break;
2338  case 'FOG_QUICKREG_GROUP_ASSOC':
2339  $type = '<div class="input-group">'
2340  . self::getClass('GroupManager')->buildSelectBox(
2341  $Service->value,
2342  $Service->id
2343  )
2344  . '</div>';
2345  break;
2346  case 'FOG_KEY_SEQUENCE':
2347  $type = '<div class="input-group">'
2348  . self::getClass('KeySequenceManager')
2349  ->buildSelectBox(
2350  $Service->value,
2351  $Service->id
2352  )
2353  . '</div>';
2354  break;
2355  case 'FOG_QUICKREG_OS_ID':
2356  $ImageName = _('No image specified');
2357  if ($Service->value > 0) {
2358  $ImageName = self::getClass(
2359  'Image',
2360  $Service->value
2361  )->get('name');
2362  }
2363  $type = '<p id="${service_name}">'
2364  . $ImageName
2365  . '</p>';
2366  break;
2367  case 'FOG_TZ_INFO':
2368  $dt = self::niceDate('now', $utc);
2369  $tzIDs = DateTimeZone::listIdentifiers();
2370  ob_start();
2371  echo '<div class="input-group">';
2372  echo '<select name="${service_id}" class="form-control" '
2373  . 'id="${service_name}">';
2374  foreach ((array)$tzIDs as $i => &$tz) {
2375  $current_tz = self::getClass('DateTimeZone', $tz);
2376  $offset = $current_tz->getOffset($dt);
2377  $transition = $current_tz->getTransitions(
2378  $dt->getTimestamp(),
2379  $dt->getTimestamp()
2380  );
2381  $abbr = $transition[0]['abbr'];
2382  $offset = sprintf(
2383  '%+03d:%02u',
2384  floor($offset / 3600),
2385  floor(abs($offset) % 3600 / 60)
2386  );
2387  printf(
2388  '<option value="%s"%s>%s [%s %s]</option>',
2389  $tz,
2390  (
2391  $Service->value == $tz ?
2392  ' selected' :
2393  ''
2394  ),
2395  $tz,
2396  $abbr,
2397  $offset
2398  );
2399  unset(
2400  $current_tz,
2401  $offset,
2402  $transition,
2403  $abbr,
2404  $offset,
2405  $tz
2406  );
2407  }
2408  echo '</select>';
2409  echo '</div>';
2410  $type = ob_get_clean();
2411  break;
2412  case ('FOG_API_TOKEN' === $Service->name ||
2413  (preg_match('#pass#i', $Service->name)
2414  && !preg_match('#(valid|min)#i', $Service->name))):
2415  $type = '<div class="input-group">';
2416  switch ($Service->name) {
2417  case 'FOG_API_TOKEN':
2418  $type .= '<input type="password" name="${service_id}" value="'
2419  . '${service_base64val}" autocomplete="off" class='
2420  . '"form-control token"'
2421  . 'id="${service_name}" readonly/>'
2422  . '<div class="input-group-btn">'
2423  . '<button class='
2424  . '"btn btn-warning resettoken" type="button">'
2425  . _('Reset Token')
2426  . '</button>'
2427  . '</div>';
2428  break;
2429  case 'FOG_STORAGENODE_MYSQLPASS':
2430  $type .= '<input type="text" name="${service_id}" value="'
2431  . '${service_value}" autocomplete="off" class='
2432  . '"form-control" id="${service_name}"/>';
2433  break;
2434  case 'FOG_AD_DEFAULT_PASSWORD':
2435  $type .= '<input name="${service_id}" type="password" value="'
2436  . ($Service->value ? '********************************' : '')
2437  . '" autocomplete="off" class='
2438  . '"form-control" id="${service_name}"/>';
2439  break;
2440  default:
2441  $type .= '<input type="password" name="${service_id}" value="'
2442  . '${service_value}" autocomplete="off" class='
2443  . '"form-control" id="${service_name}"/>';
2444  }
2445  $type .= '</div>';
2446  break;
2447  case (in_array($Service->name, $ServiceNames)):
2448  $type = '<input type="checkbox" name="${service_id}" value="1" '
2449  . 'id="${service_name}"'
2450  . (
2451  $Service->value ?
2452  ' checked' :
2453  ''
2454  )
2455  . '/>';
2456  break;
2457  case 'FOG_COMPANY_TOS':
2458  case 'FOG_AD_DEFAULT_OU':
2459  $type = '<div class="input-group">'
2460  . '<textarea name="${service_id}" class='
2461  . '"form-control" id="${service_name}">'
2462  . '${service_value}'
2463  . '</textarea>'
2464  . '</div>';
2465  break;
2466  case 'FOG_CLIENT_BANNER_IMAGE':
2467  $type = '<div class="input-group">'
2468  . '<label class="input-group-btn">'
2469  . '<span class="btn btn-info">'
2470  . _('Browse')
2471  . '<input type="file" class="hidden" name='
2472  . '"${service_id}" id="${service_name}"/>'
2473  . '</span>'
2474  . '</label>'
2475  . '<input type="text" class="form-control filedisp" '
2476  . 'value="${service_value}" readonly/>'
2477  . '<input type="hidden" class="filedisp" '
2478  . 'value="${service_value}" name="banner"/>'
2479  . '</div>';
2480  break;
2481  case 'FOG_CLIENT_BANNER_SHA':
2482  $type = '<div class="input-group">'
2483  . '<input class="form-control" name="${service_id}" type='
2484  . '"text" value="${service_value}" id="${service_name}"'
2485  . ' readonly/>'
2486  . '</div>';
2487  break;
2488  case 'FOG_COMPANY_COLOR':
2489  $type = '<div class="input-group">'
2490  . '<input name="${service_id}" type="text" maxlength="6" value='
2491  . '"${service_value}" id="${service_name}" class='
2492  . '"jscolor {required:false} {refine: false} form-control"/>'
2493  . '</div>';
2494  break;
2495  default:
2496  $type = '<div class="input-group">'
2497  . '<input id="${service_name}" type="text" name="${service_id}" '
2498  . 'value="${service_value}" autocomplete="off" '
2499  . 'class="form-control">'
2500  . '</div>';
2501  break;
2502  }
2503  $this->data[] = array(
2504  'field' => '<label for="${service_name}">'
2505  . '${label_name}'
2506  . '</label>',
2507  'input' => (
2508  count(
2509  explode(
2510  chr(10),
2511  $Service->value
2512  )
2513  ) <= 1 ?
2514  $type :
2515  '<div class="input-group">'
2516  . '<textarea name="${service_id}" '
2517  . 'class="form-control" id="${service_name}">'
2518  . '${service_value}'
2519  . '</textarea>'
2520  . '</div>'
2521  ),
2522  'span' => '<i class="icon fa fa-question hand" title='
2523  . '"${service_desc}" data-toggle='
2524  . '"tooltip" data-placement="right"></i>',
2525  'id' => $Service->id,
2526  'service_id' => $Service->id,
2527  'service_name' => $Service->name,
2528  'label_name' => str_replace(
2529  array('FOG_', '_'),
2530  array('', ' '),
2531  $Service->name
2532  ),
2533  'service_value' => $Service->value,
2534  'service_base64val' => base64_encode($Service->value),
2535  'service_desc' => $Service->description,
2536  );
2537  self::$HookManager
2538  ->processEvent(
2539  sprintf(
2540  'CLIENT_UPDATE_%s',
2541  $divTab
2542  ),
2543  array(
2544  'data' => &$this->data,
2545  'templates' => &$this->templates,
2546  'attributes' => &$this->attributes
2547  )
2548  );
2549  $catset = $Service->category;
2550  unset($options, $Service);
2551  }
2552  $this->data[] = array(
2553  'field' => '<label for='
2554  . '"'
2555  . $divTab
2556  . '">'
2557  . _('Make Changes?')
2558  . '</label>',
2559  'input' => '<button class="'
2560  . 'btn btn-info btn-block" type="submit" '
2561  . 'name="'
2562  . $divTab
2563  . '" id="'
2564  . $divTab
2565  . '">'
2566  . _('Update')
2567  . '</button>',
2568  'span' => ''
2569  );
2570  $this->render(12);
2571  unset($this->data);
2572  echo '</div>';
2573  echo '</div>';
2574  echo '</form>';
2575  }
2581  public function getOSID()
2582  {
2583  $imageid = (int)filter_input(INPUT_POST, 'image_id');
2584  $osname = self::getClass(
2585  'Image',
2586  $imageid
2587  )->getOS()->get('name');
2588  echo json_encode($osname ? $osname : _('No Image specified'));
2589  exit;
2590  }
2596  public function settingsPost()
2597  {
2598  $checkbox = array(0,1);
2599  $regenrange = range(0, 24, .25);
2600  array_shift($regenrange);
2601  $needstobenumeric = array(
2602  // API System
2603  'FOG_API_ENABLED' => $checkbox,
2604  // FOG Boot Settings
2605  'FOG_PXE_MENU_TIMEOUT' => true,
2606  'FOG_PXE_MENU_HIDDEN' => $checkbox,
2607  'FOG_PIGZ_COMP' => range(0, 22),
2608  'FOG_KEY_SEQUENCE' => range(1, 35),
2609  'FOG_NO_MENU' => $checkbox,
2610  'FOG_ADVANCED_MENU_LOGIN' => $checkbox,
2611  'FOG_KERNEL_DEBUG' => $checkbox,
2612  'FOG_PXE_HIDDENMENU_TIMEOUT' => true,
2613  'FOG_REGISTRATION_ENABLED' => $checkbox,
2614  'FOG_KERNEL_LOGLEVEL' => range(0, 7),
2615  'FOG_WIPE_TIMEOUT' => true,
2616  'FOG_IMAGE_LIST_MENU' => $checkbox,
2617  // FOG Email Settings
2618  'FOG_EMAIL_ACTION' => $checkbox,
2619  // FOG Linux Service Logs
2620  'SERVICE_LOG_SIZE' => true,
2621  // FOG Linux Service Sleep Times
2622  'PINGHOSTSLEEPTIME' => true,
2623  'SERVICESLEEPTIME' => true,
2624  'SNAPINREPSLEEPTIME' => true,
2625  'SCHEDULERSLEEPTIME' => true,
2626  'IMAGEREPSLEEPTIME' => true,
2627  'MULTICASESLEEPTIME' => true,
2628  // FOG Quick Registration
2629  'FOG_QUICKREG_AUTOPOP' => $checkbox,
2630  'FOG_QUICKREG_IMG_ID' => self::fastmerge(
2631  (array)0,
2632  self::getSubObjectIDs('Image')
2633  ),
2634  'FOG_QUICKREG_SYS_NUMBER' => true,
2635  'FOG_QUICKREG_GROUP_ASSOC' => self::fastmerge(
2636  (array)0,
2637  self::getSubObjectIDs('Group')
2638  ),
2639  'FOG_QUICKREG_PROD_KEY_BIOS' => $checkbox,
2640  // FOG Service
2641  'FOG_CLIENT_CHECKIN_TIME' => true,
2642  'FOG_CLIENT_MAXSIZE' => true,
2643  'FOG_GRACE_TIMEOUT' => true,
2644  'FOG_CLIENT_AUTOUPDATE' => $checkbox,
2645  // FOG Service - Auto Log Off
2646  'FOG_CLIENT_AUTOLOGOFF_ENABLED' => $checkbox,
2647  'FOG_CLIENT_AUTOLOGOFF_MIN' => true,
2648  // FOG Service - Client Updater
2649  'FOG_CLIENT_CLIENTUPDATER_ENABLED' => $checkbox,
2650  // FOG Service - Directory Cleaner
2651  'FOG_CLIENT_DIRECTORYCLEANER_ENABLED' => $checkbox,
2652  // FOG Service - Display manager
2653  'FOG_CLIENT_DISPLAYMANAGER_ENABLED' => $checkbox,
2654  'FOG_CLIENT_DISPLAYMANAGER_X' => true,
2655  'FOG_CLIENT_DISPLAYMANAGER_Y' => true,
2656  'FOG_CLIENT_DISPLAYMANAGER_R' => true,
2657  // FOG Service - Green Fog
2658  'FOG_CLIENT_GREENFOG_ENABLED' => $checkbox,
2659  // FOG Service - Host Register
2660  'FOG_CLIENT_HOSTREGISTER_ENABLED' => $checkbox,
2661  'FOG_QUICKREG_MAX_PENDING_MACS' => true,
2662  // FOG Service - Hostname Changer
2663  'FOG_CLIENT_HOSTNAMECHANGER_ENABLED' => $checkbox,
2664  // FOG Service - Power Management
2665  'FOG_CLIENT_POWERMANAGEMENT_ENABLED' => $checkbox,
2666  // FOG Service - Printer Manager
2667  'FOG_CLIENT_PRINTERMANAGER_ENABLED' => $checkbox,
2668  // FOG Service - Snapins
2669  'FOG_CLIENT_SNAPIN_ENABLED' => $checkbox,
2670  // FOG Service - Task Reboot
2671  'FOG_CLIENT_TASKREBOOT_ENABLED' => $checkbox,
2672  'FOG_TASK_FORCE_ENABLED' => $checkbox,
2673  // FOG Service - User Cleanup
2674  'FOG_CLIENT_USERCLEANUP_ENABLED' => $checkbox,
2675  // FOG Service - User Tracker
2676  'FOG_CLIENT_USERTRACKER_ENABLED' => $checkbox,
2677  // FOG View Settings
2678  'FOG_DATA_RETURNED' => true,
2679  // General Settings
2680  'FOG_USE_SLOPPY_NAME_LOOKUPS' => $checkbox,
2681  'FOG_CAPTURERESIZEPCT' => true,
2682  'FOG_CHECKIN_TIMEOUT' => true,
2683  'FOG_CAPTUREIGNOREPAGEHIBER' => $checkbox,
2684  'FOG_USE_ANIMATION_EFFECTS' => $checkbox,
2685  'FOG_USE_LEGACY_TASKLIST' => $checkbox,
2686  'FOG_HOST_LOOKUP' => $checkbox,
2687  'FOG_ADVANCED_STATISTICS' => $checkbox,
2688  'FOG_DISABLE_CHKDSK' => $checkbox,
2689  'FOG_CHANGE_HOSTNAME_EARLY' => $checkbox,
2690  'FOG_FORMAT_FLAG_IN_GUI' => $checkbox,
2691  'FOG_MEMORY_LIMIT' => true,
2692  'FOG_SNAPIN_LIMIT' => true,
2693  'FOG_FTP_IMAGE_SIZE' => $checkbox,
2694  'FOG_FTP_PORT' => range(1, 65535),
2695  'FOG_FTP_TIMEOUT' => true,
2696  'FOG_BANDWIDTH_TIME' => true,
2697  'FOG_URL_BASE_CONNECT_TIMEOUT' => true,
2698  'FOG_URL_BASE_TIMEOUT' => true,
2699  'FOG_URL_AVAILABLE_TIMEOUT' => true,
2700  'FOG_TASKING_ADV_SHUTDOWN_ENABLED' => $checkbox,
2701  'FOG_TASKING_ADV_WOL_ENABLED' => $checkbox,
2702  'FOG_TASKING_ADV_DEBUG_ENABLED' => $checkbox,
2703  'FOG_IMAGE_COMPRESSION_FORMAT_DEFAULT' => self::fastmerge(
2704  (array)0,
2705  range(2, 6)
2706  ),
2707  'FOG_REAUTH_ON_DELETE' => $checkbox,
2708  'FOG_REAUTH_ON_EXPORT' => $checkbox,
2709  // Login Settings
2710  'FOG_ALWAYS_LOGGED_IN' => $checkbox,
2711  'FOG_INACTIVITY_TIMEOUT' => range(1, 24),
2712  'FOG_REGENERATE_TIMEOUT' => $regenrange,
2713  // Multicast Settings
2714  'FOG_UDPCAST_STARTINGPORT' => range(1, 65535),
2715  'FOG_MULTICASE_MAX_SESSIONS' => true,
2716  'FOG_UDPCAST_MAXWAIT' => true,
2717  'FOG_MULTICAST_PORT_OVERRIDE' => range(0, 65535),
2718  // Plugin System
2719  'FOG_PLUGINSYS_ENABLED' => $checkbox,
2720  // Proxy Settings
2721  'FOG_PROXY_PORT' => range(0, 65535),
2722  // User Management
2723  'FOG_USER_MINPASSLENGTH' => true,
2724  );
2725  $needstobeip = array(
2726  // Multicast Settings
2727  'FOG_MULTICAST_ADDRESS' => true,
2728  'FOG_MULTICAST_RENDEZVOUS' => true,
2729  // Proxy Settings
2730  'FOG_PROXY_IP' => true,
2731  );
2732  unset($findWhere, $setWhere);
2733  Route::listem('service', 'id', true);
2734  $Services = json_decode(
2735  Route::getData()
2736  );
2737  $Services = $Services->services;
2738  try {
2739  foreach ((array)$Services as $index => &$Service) {
2740  $divTab = preg_replace(
2741  '#[^\w\-]#',
2742  '_',
2743  $Service->category
2744  );
2745  if (!isset($_POST[$divTab])) {
2746  continue;
2747  }
2748  $key = trim(
2749  $Service->id
2750  );
2751  $val = trim(
2752  $Service->value
2753  );
2754  $name = trim(
2755  $Service->name
2756  );
2757  $set = filter_var($_POST[$key]);
2758  if (isset($needstobenumeric[$name])) {
2759  if ($needstobenumeric[$name] === true
2760  && !is_numeric($set)
2761  ) {
2762  $set = 0;
2763  }
2764  if ($needstobenumeric[$name] !== true
2765  && !in_array($set, $needstobenumeric[$name])
2766  ) {
2767  $set = 0;
2768  }
2769  }
2770  if (isset($needstobeip[$name])
2771  && !filter_var($set, FILTER_VALIDATE_IP)
2772  ) {
2773  $set = '';
2774  }
2775  switch ($name) {
2776  case 'FOG_AD_DEFAULT_PASSWORD':
2777  $set = (
2778  preg_match('/^\*{32}$/', $set) ?
2780  $set
2781  );
2782  break;
2783  case 'FOG_API_TOKEN':
2784  $set = base64_decode($set);
2785  break;
2786  case 'FOG_MEMORY_LIMIT':
2787  if ($set < 128) {
2788  $set = 128;
2789  }
2790  break;
2791  case 'FOG_CLIENT_BANNER_SHA':
2792  continue 2;
2793  case 'FOG_CLIENT_BANNER_IMAGE':
2794  $banner = filter_input(INPUT_POST, 'banner');
2795  $set = $banner;
2796  if (!$banner) {
2797  self::setSetting('FOG_CLIENT_BANNER_SHA', '');
2798  }
2799  if (!($_FILES[$key]['name']
2800  && file_exists($_FILES[$key]['tmp_name']))
2801  ) {
2802  continue 2;
2803  }
2804  $set = preg_replace(
2805  '/[^-\w\.]+/',
2806  '_',
2807  trim(basename($_FILES[$key]['name']))
2808  );
2809  $src = sprintf(
2810  '%s/%s',
2811  dirname($_FILES[$key]['tmp_name']),
2812  basename($_FILES[$key]['tmp_name'])
2813  );
2814  list(
2815  $width,
2816  $height,
2817  $type,
2818  $attr
2819  ) = getimagesize($src);
2820  if ($width != 650) {
2821  throw new Exception(
2822  _('Width must be 650 pixels.')
2823  );
2824  }
2825  if ($height != 120) {
2826  throw new Exception(
2827  _('Height must be 120 pixels.')
2828  );
2829  }
2830  $dest = sprintf(
2831  '%s%smanagement%sother%s%s',
2832  BASEPATH,
2833  DS,
2834  DS,
2835  DS,
2836  $set
2837  );
2838  $hash = hash_file(
2839  'sha512',
2840  $src
2841  );
2842  if (!move_uploaded_file($src, $dest)) {
2843  self::setSetting('FOG_CLIENT_BANNER_SHA', '');
2844  $set = '';
2845  } else {
2846  self::setSetting('FOG_CLIENT_BANNER_SHA', $hash);
2847  }
2848  break;
2849  }
2850  $items[] = array($key, $name, $set);
2851  unset($Service, $index);
2852  }
2853  if (count($items) > 0) {
2854  self::getClass('ServiceManager')
2855  ->insertBatch(
2856  array(
2857  'id',
2858  'name',
2859  'value'
2860  ),
2861  $items
2862  );
2863  }
2864  $msg = json_encode(
2865  array(
2866  'msg' => _('Settings successfully stored!'),
2867  'title' => _('Settings Update Success')
2868  )
2869  );
2870  if (isset($_POST['Rebranding'])) {
2871  echo '<div class="col-xs-9">';
2872  echo '<div class="panel panel-success">';
2873  echo '<div class="panel-heading text-center">';
2874  echo '<h4 class="title">';
2875  echo _('Service Setting Update Success');
2876  echo '</h4>';
2877  echo '</div>';
2878  echo '<div class="panel-body">';
2879  echo _('Rebranding element has been successfully updated!');
2880  echo '</div>';
2881  echo '</div>';
2882  echo '</div>';
2883  return;
2884  }
2885  } catch (Exception $e) {
2886  $msg = json_encode(
2887  array(
2888  'error' => $e->getMessage(),
2889  'title' => _('Settings Update Fail')
2890  )
2891  );
2892  if (isset($_POST['Rebranding'])) {
2893  echo '<div class="col-xs-9">';
2894  echo '<div class="panel panel-warning">';
2895  echo '<div class="panel-heading text-center">';
2896  echo '<h4 class="title">';
2897  echo _('Service Setting Update Failed');
2898  echo '</h4>';
2899  echo '</div>';
2900  echo '<div class="panel-body">';
2901  echo $e->getMessage();
2902  echo '</div>';
2903  echo '</div>';
2904  echo '</div>';
2905  return;
2906  }
2907  }
2908  if (isset($_POST['Rebranding'])) {
2910  $this->formAction
2911  );
2912  }
2913  echo $msg;
2914  exit;
2915  }
2921  public function logviewer()
2922  {
2923  Route::listem('storagegroup');
2924  $StorageGroups = json_decode(
2925  Route::getData()
2926  );
2927  $StorageGroups = $StorageGroups->storagegroups;
2928  foreach ((array)$StorageGroups as &$StorageGroup) {
2929  if (count($StorageGroup->enablednodes) < 1) {
2930  continue;
2931  }
2932  $nodeIDs = self::getSubObjectIDs(
2933  'StorageNode',
2934  array(
2935  'id' => $StorageGroup->enablednodes,
2936  'isMaster' => 1
2937  )
2938  );
2939  if (count($nodeIDs ?: []) != 1) {
2940  continue;
2941  }
2942  Route::indiv(
2943  'storagenode',
2944  array_shift($nodeIDs),
2945  'logfiles'
2946  );
2947  $StorageNode = json_decode(
2948  Route::getData()
2949  );
2950  if (!$StorageNode->isEnabled) {
2951  continue;
2952  }
2953  $fogfiles = json_decode(
2954  json_encode($StorageNode->logfiles),
2955  true
2956  );
2957  try {
2958  $apacheerrlog = preg_grep(
2959  '#(error\.log$|.*error_log$)#i',
2960  $fogfiles
2961  );
2962  $apacheacclog = preg_grep(
2963  '#(access\.log$|.*access_log$)#i',
2964  $fogfiles
2965  );
2966  $multicastlog = preg_grep(
2967  '#(multicast.log$)#i',
2968  $fogfiles
2969  );
2970  $multicastlog = array_shift($multicastlog);
2971  $schedulerlog = preg_grep(
2972  '#(fogscheduler.log$)#i',
2973  $fogfiles
2974  );
2975  $schedulerlog = array_shift($schedulerlog);
2976  $imgrepliclog = preg_grep(
2977  '#(fogreplicator.log$)#i',
2978  $fogfiles
2979  );
2980  $imgrepliclog = array_shift($imgrepliclog);
2981  $imagesizelog = preg_grep(
2982  '#(fogimagesize.log$)#i',
2983  $fogfiles
2984  );
2985  $imagesizelog = array_shift($imagesizelog);
2986  $snapinreplog = preg_grep(
2987  '#(fogsnapinrep.log$)#i',
2988  $fogfiles
2989  );
2990  $snapinreplog = array_shift($snapinreplog);
2991  $snapinhashlog = preg_grep(
2992  '#(fogsnapinhash.log$)#i',
2993  $fogfiles
2994  );
2995  $snapinhashlog = array_shift($snapinhashlog);
2996  $pinghostlog = preg_grep(
2997  '#(pinghosts.log$)#i',
2998  $fogfiles
2999  );
3000  $pinghostlog = array_shift($pinghostlog);
3001  $svcmasterlog = preg_grep(
3002  '#(servicemaster.log$)#i',
3003  $fogfiles
3004  );
3005  $svcmasterlog = array_shift($svcmasterlog);
3006  $imgtransferlogs = preg_grep(
3007  '#(fogreplicator.log.transfer)#i',
3008  $fogfiles
3009  );
3010  $snptransferlogs = preg_grep(
3011  '#(fogsnapinrep.log.transfer)#i',
3012  $fogfiles
3013  );
3014  $files[$StorageNode->name] = array(
3015  (
3016  $svcmasterlog ?
3017  _('Service Master') :
3018  null
3019  )=> (
3020  $svcmasterlog ?
3021  $svcmasterlog :
3022  null
3023  ),
3024  (
3025  $multicastlog ?
3026  _('Multicast') :
3027  null
3028  ) => (
3029  $multicastlog ?
3030  $multicastlog :
3031  null
3032  ),
3033  (
3034  $schedulerlog ?
3035  _('Scheduler') :
3036  null
3037  ) => (
3038  $schedulerlog ?
3039  $schedulerlog :
3040  null
3041  ),
3042  (
3043  $imgrepliclog ?
3044  _('Image Replicator') :
3045  null
3046  ) => (
3047  $imgrepliclog ?
3048  $imgrepliclog :
3049  null
3050  ),
3051  (
3052  $imagesizelog ?
3053  _('Image Size') :
3054  null
3055  ) => (
3056  $imagesizelog ?
3057  $imagesizelog :
3058  null
3059  ),
3060  (
3061  $snapinreplog ?
3062  _('Snapin Replicator') :
3063  null
3064  ) => (
3065  $snapinreplog ?
3066  $snapinreplog :
3067  null
3068  ),
3069  (
3070  $snapinhashlog ?
3071  _('Snapin Hash') :
3072  null
3073  ) => (
3074  $snapinhashlog ?
3075  $snapinhashlog :
3076  null
3077  ),
3078  (
3079  $pinghostlog ?
3080  _('Ping Hosts') :
3081  null
3082  ) => (
3083  $pinghostlog ?
3084  $pinghostlog :
3085  null
3086  ),
3087  );
3088  $logtype = 'error';
3089  $logparse = function (&$log) use (&$files, $StorageNode, &$logtype) {
3090  $str = sprintf(
3091  '%s %s log (%s)',
3092  (
3093  preg_match('#nginx#i', $log) ?
3094  'NGINX' :
3095  (
3096  preg_match('#apache|httpd#', $log) ?
3097  'Apache' :
3098  (
3099  preg_match('#fpm#i', $log) ?
3100  'PHP-FPM' :
3101  ''
3102  )
3103  )
3104  ),
3105  $logtype,
3106  basename($log)
3107  );
3108  $files[$StorageNode->name][_($str)] = $log;
3109  };
3110  array_map($logparse, (array)$apacheerrlog);
3111  $logtype = 'access';
3112  array_map($logparse, (array)$apacheacclog);
3113  foreach ((array)$imgtransferlogs as &$file) {
3115  $file,
3116  'transfer.',
3117  '.log'
3118  );
3119  $str = sprintf(
3120  '%s %s',
3121  $str,
3122  _('Image Transfer Log')
3123  );
3124  $files[$StorageNode->name][$str] = $file;
3125  unset($file);
3126  }
3127  foreach ((array)$snptransferlogs as &$file) {
3129  $file,
3130  'transfer.',
3131  '.log'
3132  );
3133  $str = sprintf(
3134  '%s %s',
3135  $str,
3136  _('Snapin Transfer Log')
3137  );
3138  $files[$StorageNode->name][$str] = $file;
3139  unset($file);
3140  }
3141  $files[$StorageNode->name] = array_filter(
3142  (array)$files[$StorageNode->name]
3143  );
3144  } catch (Exception $e) {
3145  $files[$StorageNode->name] = array(
3146  $e->getMessage() => null,
3147  );
3148  }
3149  $ip[$StorageNode->name] = $StorageNode->ip;
3150  self::$HookManager
3151  ->processEvent(
3152  'LOG_VIEWER_HOOK',
3153  array(
3154  'files' => &$files,
3155  'StorageNode' => &$StorageNode
3156  )
3157  );
3158  unset($StorageGroup);
3159  }
3160  unset($StorageGroups);
3161  ob_start();
3162  foreach ((array)$files as $nodename => &$filearray) {
3163  $first = true;
3164  foreach ((array)$filearray as $value => &$file) {
3165  if ($first) {
3166  printf(
3167  '<option disabled> ------- %s ------- </option>',
3168  $nodename
3169  );
3170  $first = false;
3171  }
3172  printf(
3173  '<option value="%s||%s"%s>%s</option>',
3174  base64_encode($ip[$nodename]),
3175  $file,
3176  (
3177  $value == $_POST['logtype'] ?
3178  ' selected' :
3179  ''
3180  ),
3181  $value
3182  );
3183  unset($file);
3184  }
3185  unset($filearray);
3186  }
3187  unset($files);
3188  $logOpts = ob_get_clean();
3189  $vals = array(
3190  20,
3191  50,
3192  100,
3193  200,
3194  400,
3195  500,
3196  1000
3197  );
3198  ob_start();
3199  foreach ((array)$vals as $i => &$value) {
3200  printf(
3201  '<option value="%s"%s>%s</option>',
3202  $value,
3203  (
3204  $value == $_POST['n'] ?
3205  ' selected' :
3206  ''
3207  ),
3208  $value
3209  );
3210  unset($value);
3211  }
3212  unset($vals);
3213  $lineOpts = ob_get_clean();
3214  $this->title = _('FOG Log Viewer');
3215  echo '<div class="col-xs-9">';
3216  echo '<div class="panel panel-info">';
3217  echo '<div class="panel-heading text-center">';
3218  echo '<h4 class="title">';
3219  echo $this->title;
3220  echo '</h4>';
3221  echo '</div>';
3222  echo '<div class="panel-body">';
3223  echo '<form class="form-horizontal" method="post" action="'
3224  . $this->formAction
3225  . '">';
3226  echo '<div class="col-xs-4">';
3227  echo '<label class="control-label" for="logToView">';
3228  echo _('File') .': ';
3229  echo '</label>';
3230  echo '<select name="logtype" class="form-control" id="logToView">';
3231  echo $logOpts;
3232  echo '</select>';
3233  echo '</div>';
3234  echo '<div class="col-xs-4">';
3235  echo '<label class="control-label" for="linesToView">';
3236  echo _('Lines') .': ';
3237  echo '</label>';
3238  echo '<select name="n" class="form-control" id="linesToView">';
3239  echo $lineOpts;
3240  echo '</select>';
3241  echo '</div>';
3242  echo '<div class="col-xs-2">';
3243  echo '<div class="checkbox">';
3244  echo '<label for="reverse">';
3245  echo '<input type="checkbox" name="reverse" id="reverse"/>';
3246  echo _('Reverse the file: (newest on top)');
3247  echo '</label>';
3248  echo '</div>';
3249  echo '</div>';
3250  echo '<div class="col-xs-2">';
3251  echo '<button type="button" id="logpause" class="btn btn-info btn-block">';
3252  echo _('Pause');
3253  echo '</button>';
3254  echo '</div>';
3255  echo '<div class="col-xs-12">';
3256  echo '<div id="logsGoHere"></div>';
3257  echo '</div>';
3258  echo '</form>';
3259  echo '</div>';
3260  echo '</div>';
3261  echo '</div>';
3262  }
3268  public function config()
3269  {
3270  self::$HookManager->processEvent('IMPORT');
3271  $this->title = _('Configuration Import/Export');
3272  $report = self::getClass('ReportMaker');
3273  $_SESSION['foglastreport'] = serialize($report);
3274  unset(
3275  $this->data,
3276  $this->form,
3277  $this->headerData,
3278  $this->templates,
3279  $this->attributes
3280  );
3281  $this->attributes = array(
3282  array('class' => 'col-xs-4'),
3283  array('class' => 'col-xs-8 form-group'),
3284  );
3285  $this->templates = array(
3286  '${field}',
3287  '${input}',
3288  );
3289  $this->data[] = array(
3290  'field' => '<label for="export">'
3291  . _('Export Database?')
3292  . '</label>',
3293  'input' => '<div class="hiddeninitially" id="exportDiv"></div>'
3294  . '<button type="submit" name="export" class="'
3295  . 'btn btn-info btn-block" id="export">'
3296  . _('Export')
3297  . '</button>'
3298  );
3299  echo '<div class="col-xs-9">';
3300  echo '<div class="panel panel-info">';
3301  echo '<div class="panel-heading text-center">';
3302  echo '<h4 class="title">';
3303  echo $this->title;
3304  echo '</h4>';
3305  echo '</div>';
3306  echo '<div class="panel-body">';
3307  echo '<div class="panel panel-info">';
3308  echo '<div class="panel-heading text-center">';
3309  echo '<h4 class="title">';
3310  echo _('Export Database');
3311  echo '</h4>';
3312  echo '</div>';
3313  echo '<div class="panel-body">';
3314  echo '<form class="form-horizontal" method="post" action='
3315  . '"export.php?type=sql">';
3316  $this->render(12);
3317  $this->data = array();
3318  $this->data[] = array(
3319  'field' => '<label for="import">'
3320  . _('Import Database?')
3321  . '<br/>'
3322  . _('Max Size')
3323  . ': '
3324  . ini_get('post_max_size')
3325  . '</label>',
3326  'input' => '<div class="input-group">'
3327  . '<label class="input-group-btn">'
3328  . '<span class="btn btn-info">'
3329  . _('Browse')
3330  . '<input type="file" class="hidden" name='
3331  . '"dbFile" id="import"/>'
3332  . '</span>'
3333  . '</label>'
3334  . '<input type="text" class="form-control filedisp" readonly/>'
3335  . '</div>'
3336  );
3337  $this->data[] = array(
3338  'field' => '<label for="importbtn">'
3339  . _('Import Database?')
3340  . '</label>',
3341  'input' => '<button type="submit" name="importbtn" class="'
3342  . 'btn btn-info btn-block" id="importbtn">'
3343  . _('Import')
3344  . '</button>'
3345  );
3346  echo '</form>';
3347  echo '</div>';
3348  echo '</div>';
3349  echo '<div class="panel panel-info">';
3350  echo '<div class="panel-heading text-center">';
3351  echo '<h4 class="title">';
3352  echo _('Import Database');
3353  echo '</h4>';
3354  echo '</div>';
3355  echo '<div class="panel-body">';
3356  echo '<form class="form-horizontal" method="post" action="'
3357  . $this->formAction
3358  . '" enctype="multipart/form-data">';
3359  $this->render(12);
3360  echo '</form>';
3361  echo '</div>';
3362  echo '</div>';
3363  echo '</div>';
3364  echo '</div>';
3365  echo '</div>';
3366  }
3372  public function configPost()
3373  {
3374  self::$HookManager->processEvent('IMPORT_POST');
3375  $Schema = self::getClass('Schema');
3376  try {
3377  if ($_FILES['dbFile']['error'] > 0) {
3378  throw new UploadException($_FILES['dbFile']['error']);
3379  }
3380  $original = $Schema->exportdb('', false);
3381  $tmp_name = htmlentities(
3382  $_FILES['dbFile']['tmp_name'],
3383  ENT_QUOTES,
3384  'utf-8'
3385  );
3386  $dir_name = dirname($tmp_name);
3387  $tmp_name = basename($tmp_name);
3388  $filename = sprintf(
3389  '%s%s%s',
3390  $dir_name,
3391  DS,
3392  $tmp_name
3393  );
3394  $result = self::getClass('Schema')->importdb($filename);
3395  echo '<div class="col-xs-9">';
3396  if ($result === true) {
3397  echo '<div class="panel panel-success">';
3398  echo '<div class="panel-heading text-center">';
3399  echo '<h4 class="title">';
3400  echo _('Import Successful');
3401  echo '</h4>';
3402  echo '</div>';
3403  echo '<div class="panel-body">';
3404  echo _('Database imported and added successfully!');
3405  echo '</div>';
3406  echo '</div>';
3407  } else {
3408  $origres = $result;
3409  $result = $Schema->importdb($original);
3410  unlink($original);
3411  unset($original);
3412  echo '<div class="panel panel-warning">';
3413  echo '<div class="panel-heading text-center">';
3414  echo '<h4 class="title">';
3415  echo _('Import Failed');
3416  echo '</h4>';
3417  echo '</div>';
3418  echo '<div class="panel-body">';
3419  echo _('There were errors during import!');
3420  echo '<br/>';
3421  echo '<br/>';
3422  echo '<pre>';
3423  echo $origres;
3424  echo '</pre>';
3425  if ($result === true) {
3426  echo '<div class="panel panel-success">';
3427  echo '<div class="panel-heading text-center">';
3428  echo _('Database Reverted');
3429  echo '</div>';
3430  echo '<div class="panel-body">';
3431  echo _('Database changes reverted!');
3432  echo '</div>';
3433  echo '</div>';
3434  } else {
3435  echo '<div class="panel panel-danger">';
3436  echo '<div class="panel-heading text-center">';
3437  echo '<h4 class="title">';
3438  echo _('Database Failure');
3439  echo '</h4>';
3440  echo '</div>';
3441  echo '<div class="panel-body">';
3442  echo _('Errors on revert detected!');
3443  echo '<br/>';
3444  echo '<br/>';
3445  echo '<pre>';
3446  echo $result;
3447  echo '</pre>';
3448  echo '</div>';
3449  echo '</div>';
3450  }
3451  echo '</div>';
3452  echo '</div>';
3453  }
3454  echo '</div>';
3455  } catch (Exception $e) {
3456  self::setMessage($e->getMessage());
3457  self::redirect($this->formAction);
3458  }
3459  }
3460 }
FOGBase\niceDate
static niceDate($date='now', $utc=false)
Definition: fogbase.class.php:1105
FOGPage\render
render($colsize=9)
Definition: fogpage.class.php:605
exit
exit
Definition: download.php:102
FOGConfigurationPage\maclist
maclist()
Definition: fogconfigurationpage.class.php:1869
Service\buildExitSelector
static buildExitSelector( $name='', $selected='', $nullField=false, $id='')
Definition: service.class.php:198
FOGBase\getClass
static getClass($class, $data='', $props=false)
Definition: fogbase.class.php:439
FOGConfigurationPage\newMenuPost
newMenuPost()
Definition: fogconfigurationpage.class.php:1506
FOGConfigurationPage\getOSID
getOSID()
Definition: fogconfigurationpage.class.php:2581
FOGConfigurationPage\clientupdater
clientupdater($formNeeded=true)
Definition: fogconfigurationpage.class.php:1606
$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
FOGConfigurationPage\logviewer
logviewer()
Definition: fogconfigurationpage.class.php:2921
FOGConfigurationPage\pxemenuPost
pxemenuPost()
Definition: fogconfigurationpage.class.php:848
$urls
$urls
Definition: mainversion.php:28
FOGConfigurationPage\version
version()
Definition: fogconfigurationpage.class.php:94
FOGPage\$title
$title
Definition: fogpage.class.php:49
FOGConfigurationPage
Definition: fogconfigurationpage.class.php:23
FOGConfigurationPage\customizepxePost
customizepxePost()
Definition: fogconfigurationpage.class.php:1225
FOGConfigurationPage\kernelUpdate
kernelUpdate()
Definition: fogconfigurationpage.class.php:203
FOGConfigurationPage\clientupdaterPost
clientupdaterPost()
Definition: fogconfigurationpage.class.php:1778
Route\indiv
static indiv($class, $id, $item='')
Definition: route.class.php:562
FOGConfigurationPage\$node
$node
Definition: fogconfigurationpage.class.php:29
FOGBase\stringBetween
static stringBetween($string, $start, $end)
Definition: fogbase.class.php:2164
$items
$items
Definition: boot.php:24
$val
$val
Definition: check_node_exists.php:25
FOGPage\$name
$name
Definition: fogpage.class.php:31
FOGConfigurationPage\pxemenu
pxemenu()
Definition: fogconfigurationpage.class.php:352
FOGConfigurationPage\index
index()
Definition: fogconfigurationpage.class.php:85
FOGBase\$locale
static $locale
Definition: fogbase.class.php:31
FOGConfigurationPage\license
license()
Definition: fogconfigurationpage.class.php:168
FOGBase\getMACLookupCount
static getMACLookupCount()
Definition: fogbase.class.php:2486
FOGConfigurationPage\kernel
kernel()
Definition: fogconfigurationpage.class.php:194
$mac
$mac
Definition: hostinfo.php:151
FOGConfigurationPage\maclistPost
maclistPost()
Definition: fogconfigurationpage.class.php:1922
FOGConfigurationPage\kernelUpdatePost
kernelUpdatePost()
Definition: fogconfigurationpage.class.php:241
FOGConfigurationPage\settings
settings()
Definition: fogconfigurationpage.class.php:1992
$report
$report
Definition: export.php:23
FOGConfigurationPage\config
config()
Definition: fogconfigurationpage.class.php:3268
FOGConfigurationPage\newMenu
newMenu()
Definition: fogconfigurationpage.class.php:1355
$str
if(! $Image->isValid()) $str
Definition: progress.php:41
FOGConfigurationPage\__construct
__construct($name='')
Definition: fogconfigurationpage.class.php:37
FOGBase\redirect
static redirect($url='')
Definition: fogbase.class.php:831
FOGPage
Definition: fogpage.class.php:25
FOGConfigurationPage\customizepxe
customizepxe()
Definition: fogconfigurationpage.class.php:994
Route\getData
static getData()
Definition: route.class.php:1173
FOGPage\$fieldsToData
$fieldsToData
Definition: fogpage.class.php:171
UploadException
Definition: uploadexception.class.php:23
FOGConfigurationPage\configPost
configPost()
Definition: fogconfigurationpage.class.php:3372
Route\listem
static listem( $class, $sortby='name', $bypass=false, $find=array(), $item='')
Definition: route.class.php:429
FOGConfigurationPage\settingsPost
settingsPost()
Definition: fogconfigurationpage.class.php:2596
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
$foglang
$foglang['Display']
Definition: text.php:22
FOGBase\resetRequest
static resetRequest()
Definition: fogbase.class.php:983
FOGBase\clearMACLookupTable
static clearMACLookupTable()
Definition: fogbase.class.php:2475
$msg
if($Host->isValid()) $msg
Definition: hostnameloop.php:42
$url
$url
Definition: kernelvers.php:27
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
$ip
if(!(isset($_POST['ip']) &&is_string($_POST['ip']))) if(!(isset($_POST['file']) &&is_string($_POST['file']))) if(!(isset($_POST['lines']) &&is_numeric($_POST['lines']))) if(!(isset($_POST['reverse']) &&is_numeric($_POST['reverse']))) $ip
Definition: logtoview.php:149