PageRenderTime 70ms CodeModel.GetById 43ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/duplicator/files/installer/view.step2.php

https://bitbucket.org/nathancorbier/wastark.com
PHP | 244 lines | 203 code | 31 blank | 10 comment | 11 complexity | eb8f3772056dfc9a11466c6793b0d572 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. $dbh = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']);
  3. $all_tables = DupUtil::get_database_tables($dbh);
  4. $active_plugins = DupUtil::get_active_plugins($dbh);
  5. $old_path = $GLOBALS['FW_WPROOT'];
  6. $new_path = DupUtil::set_safe_path($GLOBALS['CURRENT_ROOT_PATH']);
  7. $new_path = ((strrpos($old_path, '/') + 1) == strlen($old_path)) ? DupUtil::add_slash($new_path) : $new_path;
  8. ?>
  9. <script type="text/javascript">
  10. /** **********************************************
  11. * METHOD:
  12. * Timeout (10000000 = 166 minutes) */
  13. Duplicator.runUpdate = function() {
  14. if ( $.trim($("#url_new").val()) == "" ) {alert("The 'New URL' field is required!"); return false;}
  15. if ( $.trim($("#siteurl").val()) == "" ) {alert("The 'Site URL' field is required!"); return false;}
  16. $.ajax({
  17. type: "POST",
  18. timeout: 10000000,
  19. dataType: "json",
  20. url: window.location.href,
  21. data: $('#dup-step2-input-form').serialize(),
  22. beforeSend: function() {
  23. Duplicator.showProgressBar();
  24. $('#dup-step2-input-form').hide();
  25. $('#dup-step2-result-form').show();
  26. },
  27. success: function(data){
  28. if (data.step2.pass == 1) {
  29. $("#ajax-url_new").val($("#url_new").val());
  30. $("#ajax-json").val(escape(JSON.stringify(data)));
  31. setTimeout(function(){$('#dup-step2-result-form').submit();}, 100);
  32. $('#progress-area').fadeOut(1800);
  33. } else {
  34. Duplicator.hideProgressBar();
  35. }
  36. },
  37. error: function(xhr) {
  38. var status = "<b>server code:</b> " + xhr.status + "<br/><b>status:</b> " + xhr.statusText + "<br/><b>response:</b> " + xhr.responseText;
  39. $('#ajaxerr-data').html(status);
  40. Duplicator.hideProgressBar();
  41. }
  42. });
  43. }
  44. /** **********************************************
  45. * METHOD: Returns the windows active url */
  46. Duplicator.getNewURL = function(id) {
  47. var filename= window.location.pathname.split('/').pop() || 'installer.php' ;
  48. $("#" + id).val(window.location.href.replace(filename, ''));
  49. }
  50. /** **********************************************
  51. * METHOD: Allows user to edit the package url */
  52. Duplicator.editOldURL = function() {
  53. var msg = 'This is the URL that was generated when the package was created.\n'
  54. msg += 'Changing this value may cause issues with the install process.\n\n';
  55. msg += 'Only modify this value if you know exactly what the value should be.\n';
  56. msg += 'See "General Settings" in the WordPress Administrator for more details.\n\n';
  57. msg += 'Are you sure you want to continue?';
  58. if (confirm(msg)) {
  59. $("#url_old").removeAttr('readonly');
  60. $("#url_old").removeClass('readonly');
  61. $('#edit_url_old').hide('slow');
  62. }
  63. }
  64. /** **********************************************
  65. * METHOD: Allows user to edit the package path */
  66. Duplicator.editOldPath = function() {
  67. var msg = 'This is the SERVER URL that was generated when the package was created.\n'
  68. msg += 'Changing this value may cause issues with the install process.\n\n';
  69. msg += 'Only modify this value if you know exactly what the value should be.\n';
  70. msg += 'Are you sure you want to continue?';
  71. if (confirm(msg)) {
  72. $("#path_old").removeAttr('readonly');
  73. $("#path_old").removeClass('readonly');
  74. $('#edit_path_old').hide('slow');
  75. }
  76. }
  77. //DOCUMENT LOAD
  78. $(document).ready(function() {
  79. Duplicator.getNewURL('url_new');
  80. Duplicator.getNewURL('siteurl');
  81. });
  82. </script>
  83. <!-- =========================================
  84. VIEW: STEP 2- INPUT -->
  85. <form id='dup-step2-input-form' method="post" class="content-form">
  86. <input type="hidden" name="action_ajax" value="2" />
  87. <input type="hidden" name="action_step" value="2" />
  88. <input type="hidden" name="logging" value="<?php echo $_POST['logging'] ?>" />
  89. <input type="hidden" name="package_name" value="<?php echo $_POST['package_name'] ?>" />
  90. <input type="hidden" name="json" value="<?php echo $_POST['json']; ?>" />
  91. <input type="hidden" name="dbhost" value="<?php echo $_POST['dbhost'] ?>" />
  92. <input type="hidden" name="dbuser" value="<?php echo $_POST['dbuser'] ?>" />
  93. <input type="hidden" name="dbpass" value="<?php echo $_POST['dbpass'] ?>" />
  94. <input type="hidden" name="dbname" value="<?php echo $_POST['dbname'] ?>" />
  95. <input type="hidden" name="dbcharset" value="<?php echo $_POST['dbcharset'] ?>" />
  96. <input type="hidden" name="dbcollate" value="<?php echo $_POST['dbcollate'] ?>" />
  97. <h3>Step 2: Table Data
  98. <div class="dup-logfile-link"><a href="installer-log.txt" target="_blank">installer-log.txt</a></div>
  99. </h3><hr size="1"/><br/>
  100. <div class="title-header">Old Settings</div>
  101. <table width="100%" border="0" cellspacing="1" cellpadding="1" class="table-inputs">
  102. <tr valign="top">
  103. <td style="width:80px">URL</td>
  104. <td>
  105. <input type="text" name="url_old" id="url_old" value="<?php echo $GLOBALS['FW_URL_OLD'] ?>" readonly="true" class="readonly" />
  106. <a href="javascript:Duplicator.editOldURL()" id="edit_url_old" style="font-size:12px">edit</a>
  107. </td>
  108. </tr>
  109. <tr valign="top">
  110. <td>Path</td>
  111. <td>
  112. <input type="text" name="path_old" id="path_old" value="<?php echo $old_path ?>" readonly="true" class="readonly" />
  113. <a href="javascript:Duplicator.editOldPath()" id="edit_path_old" style="font-size:12px">edit</a>
  114. </td>
  115. </tr>
  116. </table>
  117. <div class="title-header" style="margin-top:8px">New Settings</div>
  118. <table width="100%" border="0" cellspacing="1" cellpadding="1" class="table-inputs">
  119. <tr>
  120. <td style="width:80px">URL</td>
  121. <td>
  122. <input type="text" name="url_new" id="url_new" value="<?php echo $GLOBALS['FW_URL_NEW'] ?>" />
  123. <a href="javascript:Duplicator.getNewURL('url_new')" style="font-size:12px">get</a>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td>Path</td>
  128. <td><input type="text" name="path_new" id="path_new" value="<?php echo $new_path ?>" /></td>
  129. </tr>
  130. <tr>
  131. <td>Title</td>
  132. <td><input type="text" name="blogname" id="blogname" value="<?php echo $GLOBALS['FW_BLOGNAME'] ?>" /></td>
  133. </tr>
  134. </table><br/>
  135. <!-- ADVANCED OPTIONS -->
  136. <a href="javascript:void(0)" onclick="$('#dup-step2-adv-opts').toggle(250)"><b>Advanced Options...</b></a>
  137. <div id='dup-step2-adv-opts' style="display:none;">
  138. <table width="100%" border="0" cellspacing="1" cellpadding="1" >
  139. <tr>
  140. <td valign="top" style="width:80px">Site URL</td>
  141. <td>
  142. <input type="text" name="siteurl" id="siteurl" value="" />
  143. <a href="javascript:Duplicator.getNewURL('siteurl')" style="font-size:12px">get</a><br/>
  144. </td>
  145. </tr>
  146. </table><br/>
  147. <table>
  148. <tr>
  149. <td style="padding-right:10px">
  150. Scan Tables
  151. <div class="dup-step2-allnonelinks">
  152. <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',true);" />[All]</a>
  153. <a href="javascript:void(0)" onclick="$('#tables option').prop('selected',false);" />[None]</a>
  154. </div><br style="clear:both" />
  155. <select id="tables" name="tables[]" multiple="multiple" style="width:315px; height:100px">
  156. <?php
  157. foreach( $all_tables as $table ) {
  158. echo '<option selected="selected" value="' . DupUtil::esc_html_attr( $table ) . '">' . $table . '</option>';
  159. }
  160. ?>
  161. </select>
  162. </td>
  163. <td valign="top">
  164. Activate Plugins
  165. <div class="dup-step2-allnonelinks">
  166. <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',true);" />[All]</a>
  167. <a href="javascript:void(0)" onclick="$('#plugins option').prop('selected',false);" />[None]</a>
  168. </div><br style="clear:both" />
  169. <select id="plugins" name="plugins[]" multiple="multiple" style="width:315px; height:100px">
  170. <?php
  171. foreach ($active_plugins as $plugin) {
  172. echo '<option selected="selected" value="' . DupUtil::esc_html_attr( $plugin ) . '">' . dirname($plugin) . '</option>';
  173. }
  174. ?>
  175. </select>
  176. </td>
  177. </tr>
  178. </table><br/>
  179. <input type="checkbox" name="postguid" id="postguid" value="1" /> <label for="postguid">Keep Post GUID unchanged?</label><br/>
  180. <br/><br/><br/><br/>
  181. </div>
  182. <div class="dup-footer-buttons">
  183. <input id="dup-step2-next" type="button" value=" Update Tables " onclick="Duplicator.runUpdate()" />
  184. </div>
  185. </form>
  186. <!-- =========================================
  187. VIEW: STEP 2 - AJAX RESULT -->
  188. <form id='dup-step2-result-form' method="post" class="content-form" style="display:none">
  189. <input type="hidden" name="action_step" value="3" />
  190. <input type="hidden" name="package_name" value="<?php echo $_POST['package_name'] ?>" />
  191. <!-- Set via jQuery -->
  192. <input type="hidden" name="url_new" id="ajax-url_new" />
  193. <input type="hidden" name="json" id="ajax-json" />
  194. <h3>Step 2: Update Table Data
  195. <div class="dup-logfile-link"><a href="installer-log.txt" target="_blank">installer-log.txt</a></div>
  196. </h3><hr size="1"/>
  197. <!-- PROGRESS BAR -->
  198. <div id="progress-area">
  199. <div style="width:500px; margin:auto">
  200. <h3>Processing Data Replacement Please Wait...</h3>
  201. <div id="progress-bar"></div>
  202. <i>This may take several minutes</i>
  203. </div>
  204. </div>
  205. <!-- AJAX SYSTEM ERROR -->
  206. <div id="ajaxerr-area" style="display:none">
  207. <p>Please try again an issue has occurred.</p>
  208. <div style="padding: 0px 10px 10px 10px;">
  209. <div id="ajaxerr-data">An unknown issue has occurred with the data replacement setup process. Please see the installer-log.txt file for more details.</div>
  210. <i style='font-size:11px'>See online help for more details at <a href='http://lifeinthegrid.com/support' target='_blank'>support.lifeinthegrid.com</a></i>
  211. </div>
  212. </div>
  213. </form>