/bp-forums/bbpress/bb-admin/upgrade.php

  1. <?php 
  2. // Remove these lines if you want to upgrade and are using safe mode 
  3. if ( ini_get('safe_mode') ) 
  4. die("You're running in safe mode which does not allow this upgrade 
  5. script to set a running time limit. Depending on the size of your 
  6. database and on which parts of the script you are running, the script 
  7. can take quite some time to run (or it could take just a few seconds). 
  8. To throw caution to the wind and run the script in safe mode anyway,  
  9. remove the first few lines of code in the <code>bb-admin/upgrade.php</code> 
  10. file. Backups are always a good idea."); 
  11. // Stop removing lines 
  12.  
  13. // Very old (pre 0.7) installs may need further upgrade utilities. 
  14. // Post to http://lists.bbpress.org/mailman/listinfo/bbdev if needed 
  15.  
  16. require('../bb-load.php'); 
  17. require( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' ); 
  18.  
  19. $step = 'unrequired'; 
  20.  
  21. $forced = false; 
  22. if ( isset( $_POST['force'] ) && 1 == $_POST['force'] ) { 
  23. $forced = true; 
  24. } elseif ( isset( $_GET['force'] ) && 1 == $_GET['force'] ) { 
  25. $forced = true; 
  26.  
  27. if ( bb_get_option( 'bb_db_version' ) > bb_get_option_from_db( 'bb_db_version' ) || $forced ) { 
  28.  
  29. $forced_input = ''; 
  30. if ( $forced ) { 
  31. $forced_input = '<input type="hidden" name="force" value="1" />'; 
  32.  
  33. $step = 'required'; 
  34.  
  35. if ( strtolower( $_SERVER['REQUEST_METHOD']) == 'post' ) { 
  36.  
  37. bb_check_admin_referer( 'bbpress-upgrader' ); 
  38.  
  39. define('BB_UPGRADING', true); 
  40.  
  41. $bbdb->hide_errors(); 
  42.  
  43. $messages = bb_upgrade_all(); 
  44.  
  45. $bbdb->show_errors(); 
  46.  
  47. $upgrade_log = array(__('Beginning upgrade…')); 
  48. if (is_array($messages['messages'])) { 
  49. $upgrade_log = array_merge($upgrade_log, $messages['messages']); 
  50. $upgrade_log[] = '>>> ' . __('Done'); 
  51.  
  52. $error_log = array(); 
  53. if (is_array($messages['errors'])) { 
  54. $error_log = $messages['errors']; 
  55.  
  56. if ( bb_get_option( 'bb_db_version' ) === bb_get_option_from_db( 'bb_db_version' ) && !count($error_log) ) { 
  57. $step = 'complete'; 
  58. } else { 
  59. $step = 'error'; 
  60.  
  61. wp_cache_flush(); 
  62.  
  63.  
  64. bb_install_header( __('bbPress database upgrade'), false, true ); 
  65. ?> 
  66. <script type="text/javascript" charset="utf-8"> 
  67. function toggleAdvanced(toggle, target) { 
  68. var toggleObj = document.getElementById(toggle); 
  69. var targetObj = document.getElementById(target); 
  70. if (toggleObj.checked) { 
  71. targetObj.style.display = 'block'; 
  72. } else { 
  73. targetObj.style.display = 'none'; 
  74. </script> 
  75. <?php 
  76. switch ($step) { 
  77. case 'unrequired': 
  78. ?> 
  79. <p class="last"> 
  80. <?php printf( __('Nothing to upgrade. <a href="%s">Get back to work!</a>'), bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ); ?> 
  81. </p> 
  82. <?php 
  83. break; 
  84.  
  85. case 'required' 
  86. ?> 
  87. <div class="open"> 
  88. <h2><?php _e('Database upgrade required'); ?></h2> 
  89. <div> 
  90. <form action="<?php bb_uri('bb-admin/upgrade.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" method="post"> 
  91. <p class="error"> 
  92. <?php _e('It looks like your database is out-of-date. You can upgrade it here.'); ?> 
  93. </p> 
  94. <fieldset class="buttons"> 
  95. <?php bb_nonce_field( 'bbpress-upgrader' ); ?> 
  96. <?php echo $forced_input; ?> 
  97. <label for="upgrade_next" class="forward"> 
  98. <input class="button" id="upgrade_next" type="submit" value="<?php _e( 'Upgrade database' ); ?>" /> 
  99. </label> 
  100. </fieldset> 
  101. </form> 
  102. </div> 
  103. </div> 
  104. <?php 
  105. break; 
  106.  
  107. case 'complete': 
  108. ?> 
  109. <div class="open"> 
  110. <h2><?php _e('Database upgrade complete'); ?></h2> 
  111. <div> 
  112. <form action="<?php bb_uri('bb-admin/', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" method="get"> 
  113. <p class="message"> 
  114. <?php _e('Your database has been successfully upgraded, enjoy!'); ?> 
  115. </p> 
  116. <fieldset> 
  117. <label class="has-label for-toggle" for="upgrade_log_container_toggle"> 
  118. <span> 
  119. <?php _e('Show upgrade messages'); ?> 
  120. <input class="checkbox" type="checkbox" id="upgrade_log_container_toggle" value="1" onclick="toggleAdvanced('upgrade_log_container_toggle', 'upgrade_log_container');" /> 
  121. </span> 
  122. <div class="clear"></div> 
  123. </label> 
  124. </fieldset> 
  125. <div class="toggle" id="upgrade_log_container" style="display:none;"> 
  126. <fieldset> 
  127. <label class="has-label for-textarea" for="upgrade_log"> 
  128. <span><?php _e('Upgrade log'); ?></span> 
  129. <textarea id="upgrade_log" class="short"><?php echo(join("\n", $upgrade_log)); ?></textarea> 
  130. </label> 
  131. </fieldset> 
  132. </div> 
  133. <fieldset class="buttons"> 
  134. <label for="upgrade_next" class="back"> 
  135. <input class="button" id="upgrade_back" type="button" value="<?php _e( '« Go back to forums' ); ?>" onclick="location.href='<?php echo esc_js( bb_get_uri() ); ?>'; return false;" /> 
  136. </label> 
  137. <label for="upgrade_next" class="forward"> 
  138. <input class="button" id="upgrade_next" type="submit" value="<?php _e( 'Go to admin' ); ?>" /> 
  139. </label> 
  140. </fieldset> 
  141. </form> 
  142. </div> 
  143. </div> 
  144. <?php 
  145. break; 
  146.  
  147. case 'error': 
  148. ?> 
  149. <div class="open"> 
  150. <h2><?php _e('Database upgrade failed'); ?></h2> 
  151. <div> 
  152. <form action="<?php bb_uri('bb-admin/upgrade.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" method="post"> 
  153. <p class="error"> 
  154. <?php _e('The upgrade process seems to have failed. Check the upgrade messages below for more information.<br /><br />Attempting to go to the admin area without resolving the listed errors will return you to this upgrade page.'); ?> 
  155. </p> 
  156. <fieldset> 
  157. <?php bb_nonce_field( 'bbpress-upgrader' ); ?> 
  158. <?php echo $forced_input; ?> 
  159. <label class="has-label for-toggle" for="upgrade_log_container_toggle" style="margin-bottom: 1.9em;"> 
  160. <span> 
  161. <?php _e('Show upgrade messages'); ?> 
  162. <input class="checkbox" type="checkbox" id="upgrade_log_container_toggle" value="1" onclick="toggleAdvanced('upgrade_log_container_toggle', 'upgrade_log_container');" /> 
  163. </span> 
  164. <div class="clear"></div> 
  165. </label> 
  166. </fieldset> 
  167. <div class="toggle" id="upgrade_log_container" style="display:none;"> 
  168. <fieldset> 
  169. <?php 
  170. if (count($error_log)) { 
  171. ?> 
  172. <label class="has-label for-textarea" for="error_log"> 
  173. <span><?php _e('Error log'); ?></span> 
  174. <textarea id="error_log" class="short"><?php echo(join("\n", $error_log)); ?></textarea> 
  175. </label> 
  176. <?php 
  177. ?> 
  178. <label class="has-label for-textarea" for="upgrade_log"> 
  179. <span><?php _e('Upgrade log'); ?></span> 
  180. <textarea id="upgrade_log" class="short"><?php echo(join("\n", $upgrade_log)); ?></textarea> 
  181. </label> 
  182. </fieldset> 
  183. </div> 
  184. <fieldset class="buttons"> 
  185. <label for="upgrade_next" class="back"> 
  186. <input class="button" id="upgrade_back" type="button" value="<?php _e( '« Go back to forums' ); ?>" onclick="location.href='<?php echo esc_js( bb_get_uri() ); ?>'; return false;" /> 
  187. </label> 
  188. <label for="upgrade_next" class="forward"> 
  189. <input class="button" id="upgrade_next" type="submit" value="<?php _e( 'Try again' ); ?>" /> 
  190. </label> 
  191. </fieldset> 
  192. </form> 
  193. </div> 
  194. </div> 
  195. <?php 
  196. break; 
  197.  
  198. bb_install_footer(); 
  199. ?> 
.