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

/wp-content/plugins/duplicator/installer/build/main.installer.php

https://gitlab.com/juanito.abelo/nlmobile
PHP | 315 lines | 217 code | 39 blank | 59 comment | 28 complexity | 25298ae60661f07dc5104ae4a33795d5 MD5 | raw file
  1. <?php
  2. /*
  3. Copyright 2011-16 lifeinthegrid.com
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License, version 2, as
  6. published by the Free Software Foundation.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. SOURCE CONTRIBUTORS:
  15. Gaurav Aggarwal
  16. David Coveney of Interconnect IT Ltd
  17. https://github.com/interconnectit/Search-Replace-DB/
  18. */
  19. if (file_exists('dtoken.php')) {
  20. //This is most likely inside the snapshot folder.
  21. //DOWNLOAD ONLY: (Only enable download from within the snapshot directory)
  22. if (isset($_GET['get']) && isset($_GET['file'])) {
  23. //Clean the input, strip out anything not alpha-numeric or "_.", so restricts
  24. //only downloading files in same folder, and removes risk of allowing directory
  25. //separators in other charsets (vulnerability in older IIS servers), also
  26. //strips out anything that might cause it to use an alternate stream since
  27. //that would require :// near the front.
  28. $filename = preg_replace('/[^a-zA-Z0-9_.]*/','',$_GET['file']);
  29. if (strlen($filename) && file_exists($filename) && (strstr($filename, '_installer.php'))) {
  30. //Attempt to push the file to the browser
  31. header('Content-Description: File Transfer');
  32. header('Content-Type: application/octet-stream');
  33. header('Content-Disposition: attachment; filename=installer.php');
  34. header('Content-Transfer-Encoding: binary');
  35. header('Expires: 0');
  36. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  37. header('Pragma: public');
  38. header('Content-Length: ' . filesize($filename));
  39. //FIXME: We should consider removing all error supression like this
  40. //as it makes troubleshooting a wild goose chase for times that the
  41. //script failes on such a line. The same can and should be accomplished
  42. //at the server level by turning off displaying errors in PHP.
  43. @ob_clean();
  44. @flush();
  45. if (@readfile($filename) == false) {
  46. $data = file_get_contents($filename);
  47. if ($data == false) {
  48. die("Unable to read installer file. The server currently has readfile and file_get_contents disabled on this server. Please contact your server admin to remove this restriction");
  49. } else {
  50. print $data;
  51. }
  52. }
  53. } else {
  54. header("HTTP/1.1 404 Not Found", true, 404);
  55. header("Status: 404 Not Found");
  56. }
  57. }
  58. //Prevent Access from rovers or direct browsing in snapshop directory, or when
  59. //requesting to download a file, should not go past this point.
  60. exit;
  61. }
  62. ?>
  63. <?php if (false) : ?>
  64. <!DOCTYPE html>
  65. <html>
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  68. <title>Error: PHP is not running</title>
  69. </head>
  70. <body>
  71. <h2>Error: PHP is not running</h2>
  72. <p>Duplicator requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
  73. </body>
  74. </html>
  75. <?php endif; ?>
  76. <?php
  77. /* ==============================================================================================
  78. ADVANCED FEATURES - Allows admins to perform aditional logic on the import.
  79. $GLOBALS['REPLACE_LIST']
  80. Add additional search and replace items to step 2 for the serialize engine.
  81. Place directly below $GLOBALS['REPLACE_LIST'] variable below your items
  82. EXAMPLE:
  83. array_push($GLOBALS['REPLACE_LIST'], array('search' => 'https://oldurl/', 'replace' => 'https://newurl/'));
  84. array_push($GLOBALS['REPLACE_LIST'], array('search' => 'ftps://oldurl/', 'replace' => 'ftps://newurl/'));
  85. ================================================================================================= */
  86. //COMPARE VALUES
  87. $GLOBALS['FW_CREATED'] = '%fwrite_created%';
  88. $GLOBALS['FW_VERSION_DUP'] = '%fwrite_version_dup%';
  89. $GLOBALS['FW_VERSION_WP'] = '%fwrite_version_wp%';
  90. $GLOBALS['FW_VERSION_DB'] = '%fwrite_version_db%';
  91. $GLOBALS['FW_VERSION_PHP'] = '%fwrite_version_php%';
  92. $GLOBALS['FW_VERSION_OS'] = '%fwrite_version_os%';
  93. //GENERAL
  94. $GLOBALS['FW_TABLEPREFIX'] = '%fwrite_wp_tableprefix%';
  95. $GLOBALS['FW_URL_OLD'] = '%fwrite_url_old%';
  96. $GLOBALS['FW_URL_NEW'] = '%fwrite_url_new%';
  97. $GLOBALS['FW_PACKAGE_NAME'] = '%fwrite_package_name%';
  98. $GLOBALS['FW_PACKAGE_NOTES'] = '%fwrite_package_notes%';
  99. $GLOBALS['FW_SECURE_NAME'] = '%fwrite_secure_name%';
  100. $GLOBALS['FW_DBHOST'] = '%fwrite_dbhost%';
  101. $GLOBALS['FW_DBHOST'] = empty($GLOBALS['FW_DBHOST']) ? 'localhost' : $GLOBALS['FW_DBHOST'];
  102. $GLOBALS['FW_DBPORT'] = '%fwrite_dbport%';
  103. $GLOBALS['FW_DBPORT'] = empty($GLOBALS['FW_DBPORT']) ? 3306 : $GLOBALS['FW_DBPORT'];
  104. $GLOBALS['FW_DBNAME'] = '%fwrite_dbname%';
  105. $GLOBALS['FW_DBUSER'] = '%fwrite_dbuser%';
  106. $GLOBALS['FW_DBPASS'] = '%fwrite_dbpass%';
  107. $GLOBALS['FW_SSL_ADMIN'] = '%fwrite_ssl_admin%';
  108. $GLOBALS['FW_SSL_LOGIN'] = '%fwrite_ssl_login%';
  109. $GLOBALS['FW_CACHE_WP'] = '%fwrite_cache_wp%';
  110. $GLOBALS['FW_CACHE_PATH'] = '%fwrite_cache_path%';
  111. $GLOBALS['FW_BLOGNAME'] = '%fwrite_blogname%';
  112. $GLOBALS['FW_WPROOT'] = '%fwrite_wproot%';
  113. $GLOBALS['FW_DUPLICATOR_VERSION'] = '%fwrite_duplicator_version%';
  114. $GLOBALS['FW_OPTS_DELETE'] = json_decode("%fwrite_opts_delete%", true);
  115. //DATABASE SETUP: all time in seconds
  116. $GLOBALS['DB_MAX_TIME'] = 5000;
  117. $GLOBALS['DB_MAX_PACKETS'] = 268435456;
  118. ini_set('mysql.connect_timeout', '5000');
  119. //PHP SETUP: all time in seconds
  120. ini_set('memory_limit', '2048M');
  121. ini_set("max_execution_time", '5000');
  122. ini_set("max_input_time", '5000');
  123. ini_set('default_socket_timeout', '5000');
  124. @set_time_limit(0);
  125. $GLOBALS['DBCHARSET_DEFAULT'] = 'utf8';
  126. $GLOBALS['DBCOLLATE_DEFAULT'] = 'utf8_general_ci';
  127. //UPDATE TABLE SETTINGS
  128. $GLOBALS['REPLACE_LIST'] = array();
  129. /* ================================================================================================
  130. END ADVANCED FEATURES: Do not edit below here.
  131. =================================================================================================== */
  132. //CONSTANTS
  133. define("DUPLICATOR_INIT", 1);
  134. define("DUPLICATOR_SSDIR_NAME", 'wp-snapshots'); //This should match DUPLICATOR_SSDIR_NAME in duplicator.php
  135. //SHARED POST PARMS
  136. $_POST['action_step'] = isset($_POST['action_step']) ? $_POST['action_step'] : "1";
  137. /* Host has several combinations :
  138. localhost | localhost:55 | localhost: | http://localhost | http://localhost:55 */
  139. $_POST['dbhost'] = isset($_POST['dbhost']) ? trim($_POST['dbhost']) : null;
  140. $_POST['dbport'] = isset($_POST['dbport']) ? trim($_POST['dbport']) : 3306;
  141. $_POST['dbuser'] = isset($_POST['dbuser']) ? trim($_POST['dbuser']) : null;
  142. $_POST['dbpass'] = isset($_POST['dbpass']) ? trim($_POST['dbpass']) : null;
  143. $_POST['dbname'] = isset($_POST['dbname']) ? trim($_POST['dbname']) : null;
  144. $_POST['dbcharset'] = isset($_POST['dbcharset']) ? trim($_POST['dbcharset']) : $GLOBALS['DBCHARSET_DEFAULT'];
  145. $_POST['dbcollate'] = isset($_POST['dbcollate']) ? trim($_POST['dbcollate']) : $GLOBALS['DBCOLLATE_DEFAULT'];
  146. //GLOBALS
  147. $GLOBALS["SQL_FILE_NAME"] = "installer-data.sql";
  148. $GLOBALS["LOG_FILE_NAME"] = "installer-log.txt";
  149. $GLOBALS['SEPERATOR1'] = str_repeat("********", 10);
  150. $GLOBALS['LOGGING'] = isset($_POST['logging']) ? $_POST['logging'] : 1;
  151. $GLOBALS['CURRENT_ROOT_PATH'] = dirname(__FILE__);
  152. $GLOBALS['CHOWN_ROOT_PATH'] = @chmod("{$GLOBALS['CURRENT_ROOT_PATH']}", 0755);
  153. $GLOBALS['CHOWN_LOG_PATH'] = @chmod("{$GLOBALS['CURRENT_ROOT_PATH']}/{$GLOBALS['LOG_FILE_NAME']}", 0644);
  154. $GLOBALS['URL_SSL'] = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? true : false;
  155. $GLOBALS['URL_PATH'] = ($GLOBALS['URL_SSL']) ? "https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}" : "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
  156. //Restart log if user starts from step 1
  157. if ($_POST['action_step'] == 1) {
  158. $GLOBALS['LOG_FILE_HANDLE'] = @fopen($GLOBALS['LOG_FILE_NAME'], "w+");
  159. } else {
  160. $GLOBALS['LOG_FILE_HANDLE'] = @fopen($GLOBALS['LOG_FILE_NAME'], "a+");
  161. }
  162. ?>
  163. @@CLASS.LOGGING.PHP@@
  164. @@CLASS.UTILS.PHP@@
  165. @@CLASS.CONF.WP.PHP@@
  166. @@CLASS.CONF.SRV.PHP@@
  167. @@CLASS.SERIALIZER.PHP@@
  168. <?php
  169. if (isset($_POST['action_ajax'])) {
  170. switch ($_POST['action_ajax']) {
  171. case "1" :
  172. ?> @@AJAX.STEP1.PHP@@ <?php break;
  173. case "2" :
  174. ?> @@AJAX.STEP2.PHP@@ <?php
  175. break;
  176. }
  177. @fclose($GLOBALS["LOG_FILE_HANDLE"]);
  178. die("");
  179. }
  180. ?>
  181. <!DOCTYPE html>
  182. <html>
  183. <head>
  184. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  185. <meta name="robots" content="noindex,nofollow">
  186. <title>Wordpress Duplicator</title>
  187. @@INC.LIBS.CSS.PHP@@
  188. @@INC.CSS.PHP@@
  189. @@INC.LIBS.JS.PHP@@
  190. @@INC.JS.PHP@@
  191. </head>
  192. <body>
  193. <div id="content">
  194. <!-- =========================================
  195. HEADER TEMPLATE: Common header on all steps -->
  196. <table cellspacing="0" class="header-wizard">
  197. <tr>
  198. <td style="width:100%;">
  199. <div style="font-size:22px; padding:5px 0px 0px 0px">
  200. <!-- !!DO NOT CHANGE/EDIT OR REMOVE PRODUCT NAME!!
  201. If your interested in Private Label Rights please contact us at the URL below to discuss
  202. customizations to product labeling: http://lifeinthegrid.com -->
  203. &nbsp; Duplicator - Installer
  204. </div>
  205. </td>
  206. <td style="white-space:nowrap; text-align:right">
  207. <select id="dup-hlp-lnk">
  208. <option value="null"> - Online Resources -</option>
  209. <option value="http://lifeinthegrid.com/duplicator-docs">&raquo; Knowledge Base</option>
  210. <option value="http://lifeinthegrid.com/duplicator-guide">&raquo; User Guide</option>
  211. <option value="http://lifeinthegrid.com/duplicator-faq">&raquo; Common FAQs</option>
  212. <option value="http://lifeinthegrid.com/duplicator-hosts">&raquo; Approved Hosts</option>
  213. </select>
  214. </td>
  215. </tr>
  216. <tr>
  217. <td>
  218. <?php if (isset($_GET['help'])) :?>
  219. <div style="margin:4px 0px 10px 15px; font-size:18px">
  220. Help Overview
  221. </div>
  222. <?php else : ?>
  223. <?php
  224. $step1CSS = ($_POST['action_step'] <= 1) ? "active-step" : "complete-step";
  225. $step2CSS = ($_POST['action_step'] == 2) ? "active-step" : "";
  226. $step3CSS = "";
  227. if ($_POST['action_step'] == 3) {
  228. $step2CSS = "complete-step";
  229. $step3CSS = "active-step";
  230. }
  231. ?>
  232. <div id="dup-wiz">
  233. <div id="dup-wiz-steps">
  234. <div class="<?php echo $step1CSS; ?>"><a><span>1</span> Deploy</a></div>
  235. <div class="<?php echo $step2CSS; ?>"><a><span>2</span> Update </a></div>
  236. <div class="<?php echo $step3CSS; ?>"><a><span>3</span> Test </a></div>
  237. </div>
  238. </div>
  239. <?php endif; ?>
  240. </td>
  241. <td style="white-space:nowrap">
  242. <i style='font-size:11px; color:#999'>
  243. version: <?php echo $GLOBALS['FW_DUPLICATOR_VERSION'] ?>&nbsp;&nbsp;<a href="installer.php?help=1" target="_blank">[Help]</a>
  244. </i> &nbsp;
  245. </td>
  246. </tr>
  247. </table>
  248. <!-- =========================================
  249. FORM DATA: Data Steps -->
  250. <div id="content-inner">
  251. <?php
  252. if (! isset($_GET['help'])) {
  253. switch ($_POST['action_step']) {
  254. case "1" :
  255. ?> @@VIEW.STEP1.PHP@@ <?php
  256. break;
  257. case "2" :
  258. ?> @@VIEW.STEP2.PHP@@ <?php
  259. break;
  260. case "3" :
  261. ?> @@VIEW.STEP3.PHP@@ <?php
  262. break;
  263. }
  264. } else {
  265. ?> @@VIEW.HELP.PHP@@ <?php
  266. }
  267. ?>
  268. </div>
  269. </div><br/>
  270. </body>
  271. </html>