setup-options.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Setup options
  4. *
  5. * @package backupmodx
  6. * @subpackage build
  7. *
  8. * @var array $options
  9. * @var xPDOObject $object
  10. */
  11. // Defaults
  12. $defaults = array(
  13. 'cronKey' => substr(md5(openssl_random_pseudo_bytes(20)), -12),
  14. 'targetPath' => '{core_path}backup/',
  15. );
  16. $output = '';
  17. $values = array();
  18. switch ($options[xPDOTransport::PACKAGE_ACTION]) {
  19. case xPDOTransport::ACTION_INSTALL:
  20. $output .= '<h2>Install BackupMODX</h2>
  21. <p>BackupMODX will be installed. Please review the install options carefully.</p><br>';
  22. $output .= '<div id="target">
  23. <label for="target_path">Backup Target Path:</label>
  24. <input type="text" name="targetPath" id="target_path" width="450" value="' . $defaults['targetPath'] . '" />
  25. </div>
  26. <br><br>';
  27. $output .= '<div id="calendar">
  28. <label for="cron_key">Cron Security Key:</label>
  29. <input type="text" name="cronKey" id="cron_key" width="450" value="' . $defaults['cronKey'] . '" />
  30. </div>
  31. <br><br>';
  32. break;
  33. case xPDOTransport::ACTION_UPGRADE:
  34. $setting = $modx->getObject('modSystemSetting', array('key' => 'backupmodx.cronKey'));
  35. $values['cronKey'] = ($setting) ? $setting->get('value') : $defaults['cronKey'];
  36. unset($setting);
  37. $setting = $modx->getObject('modSystemSetting', array('key' => 'backupmodx.targetPath'));
  38. $values['targetPath'] = ($setting) ? $setting->get('value') : $defaults['targetPath'];
  39. unset($setting);
  40. $output .= '<h2>Upgrade BackupMODX</h2>
  41. <p>BackupMODX will be upgraded. Please review the install options carefully.</p><br>';
  42. $output .= '<div id="target">
  43. <label for="target_path">Backup Target Path:</label>
  44. <input type="text" name="targetPath" id="target_path" width="450" value="' . $values['targetPath'] . '" />
  45. </div>
  46. <br><br>';
  47. $output .= '<div id="calendar">
  48. <label for="cron_key">Cron Security Key:</label>
  49. <input type="text" name="cronKey" id="cron_key" width="450" value="' . $values['cronKey'] . '" />
  50. </div>
  51. <br><br>';
  52. break;
  53. case xPDOTransport::ACTION_UNINSTALL:
  54. break;
  55. }
  56. return $output;