index.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. if (cfr('ROOT')) {
  3. set_time_limit(0);
  4. $updateManager = new UpdateManager();
  5. $messages = new UbillingMessageHelper();
  6. if (ubRouting::checkGet('checkupdates')) {
  7. $localSystemVersion = wr_getLocalSystemVersion();
  8. $latestRelease = wr_GetReleaseInfo('STABLE');
  9. $latestNightlyBuild = wr_GetReleaseInfo('CURRENT');
  10. $latestReleaseLabel = wr_RenderUpdateInfo($latestRelease, 'STABLE');
  11. $latestNightlyBuildLabel = wr_RenderUpdateInfo($latestNightlyBuild, 'CURRENT');
  12. $styleStable = ($localSystemVersion == $latestRelease) ? 'success' : 'warning';
  13. $styleNightly = ($localSystemVersion == $latestNightlyBuild) ? 'success' : 'warning';
  14. $stableUpbradable = ($localSystemVersion == $latestRelease) ? false : true;
  15. $nightlyUpgradable = ($localSystemVersion == $latestNightlyBuild) ? false : true;
  16. $remoteReleasesInfo = $messages->getStyledMessage($latestReleaseLabel, $styleStable);
  17. $remoteReleasesInfo .= $messages->getStyledMessage($latestNightlyBuildLabel, $styleNightly);
  18. //upgrade controls here
  19. $upgradeControls = '';
  20. if ($stableUpbradable) {
  21. $upgradeControls .= wf_Link($updateManager::URL_ME . '&' . $updateManager::ROUTE_AUTOSYSUPGRADE . '=STABLE', wf_img('skins/icon_ok.gif') . ' ' . __('Upgrade to stable release'), false, 'ubButton') . ' ';
  22. }
  23. if ($nightlyUpgradable) {
  24. $upgradeControls .= wf_Link($updateManager::URL_ME . '&' . $updateManager::ROUTE_AUTOSYSUPGRADE . '=CURRENT', wf_img('skins/icon_cache.png') . ' ' . __('Upgrade to nightly build'), false, 'ubButton') . ' ';
  25. }
  26. $remoteReleasesInfo .= wf_delimiter(0);
  27. $remoteReleasesInfo .= $upgradeControls;
  28. die($remoteReleasesInfo);
  29. }
  30. //automatic upgrade
  31. if (ubRouting::checkGet($updateManager::ROUTE_AUTOSYSUPGRADE)) {
  32. $updateBranch = ubRouting::get($updateManager::ROUTE_AUTOSYSUPGRADE);
  33. $currentSystemVersion = wr_getLocalSystemVersion();
  34. $updateBranchVersion = wr_GetReleaseInfo($updateBranch);
  35. if ($currentSystemVersion and $updateBranchVersion) {
  36. if ($currentSystemVersion != $updateBranchVersion) {
  37. //running upgrade process
  38. if (ubRouting::checkPost($updateManager::PROUTE_UPGRADEAGREE)) {
  39. $upgradeResult = $updateManager->performAutoUpgrade($updateBranch);
  40. if ($upgradeResult) {
  41. show_error($upgradeResult);
  42. } else {
  43. ubRouting::nav($updateManager::URL_ME);
  44. }
  45. } else {
  46. //confirmation form
  47. $confirmationLabel = __('This will update your WolfRecorder') . ' ' . __('from') . ' ' . $currentSystemVersion . ' ' . __('to') . ' ' . $updateBranchVersion;
  48. $confirmationLabel .= wf_delimiter(0);
  49. $confirmationInputs = $confirmationLabel;
  50. $confirmationInputs .= wf_CheckInput($updateManager::PROUTE_UPGRADEAGREE, __('I`m ready'), true, false);
  51. $confirmationInputs .= wf_Submit(__('System update'));
  52. $confirmationForm = wf_Form('', 'POST', $confirmationInputs, 'glamour');
  53. $confirmationForm .= wf_FormDisabler();
  54. show_window(__('System update'), $confirmationForm);
  55. }
  56. } else {
  57. show_info(__('Current system version') . ': ' . $currentSystemVersion);
  58. if ($updateBranch == 'STABLE') {
  59. show_info(__('Latest stable WolfRecorder release is') . ': ' . $currentSystemVersion);
  60. }
  61. if ($updateBranch == 'CURRENT') {
  62. show_info(__('Latest nightly WolfRecorder build is') . ': ' . $updateBranchVersion);
  63. }
  64. show_success(__('Your software version is already up to date'));
  65. }
  66. } else {
  67. show_error(__('Something went wrong'));
  68. }
  69. show_window('', wf_BackLink($updateManager::URL_ME));
  70. } else {
  71. if (!ubRouting::checkGet('applysql') and ! ubRouting::checkGet('showconfigs')) {
  72. //updates check
  73. show_window('', $updateManager->renderVersionInfo());
  74. //available updates lists render
  75. show_window(__('Database schema updates'), $updateManager->renderSqlDumpsList());
  76. show_window(__('Configuration files updates'), $updateManager->renderConfigsList());
  77. } else {
  78. //mysql dumps applying interface
  79. if (ubRouting::checkGet('applysql')) {
  80. show_window(__('Database schema updates'), $updateManager->applyMysqlDump(ubRouting::get('applysql')));
  81. }
  82. if (ubRouting::checkGet('showconfigs')) {
  83. show_window(__('Configuration files updates'), $updateManager->applyConfigOptions(ubRouting::get('showconfigs')));
  84. }
  85. }
  86. }
  87. } else {
  88. show_error(__('Access denied'));
  89. }