Backup and Restore WordPress – WPBackItUp Backup Plugin - Version 1.15.3

Version Description

*Release Date - November 16, 2017

  • FIX: Fix minor issue with admin notice
Download this release

Release Info

Developer cssimmon
Plugin Icon 128x128 Backup and Restore WordPress – WPBackItUp Backup Plugin
Version 1.15.3
Comparing to
See all releases

Code changes from version 1.15.2 to 1.15.3

Files changed (297) hide show
  1. assets/banner-772x250.jpg +0 -0
  2. assets/icon-128x128.png +0 -0
  3. assets/icon-256x256.png +0 -0
  4. assets/screenshot-1.png +0 -0
  5. assets/screenshot-2.png +0 -0
  6. assets/screenshot-3.png +0 -0
  7. assets/screenshot-4.png +0 -0
  8. assets/screenshot-5.png +0 -0
  9. assets/screenshot-6.png +0 -0
  10. assets/screenshot-7.png +0 -0
  11. {tags/1.12.1/css → css}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  12. {tags/1.12.1/css → css}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  13. {tags/1.12.1/css → css}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  14. {tags/1.12.1/css → css}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  15. {tags/1.12.1/css → css}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  16. {tags/1.12.1/css → css}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  17. {tags/1.12.1/css → css}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  18. {tags/1.12.1/css → css}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  19. {tags/1.12.1/css → css}/images/ui-icons_222222_256x240.png +0 -0
  20. {tags/1.12.1/css → css}/images/ui-icons_2e83ff_256x240.png +0 -0
  21. {tags/1.12.1/css → css}/images/ui-icons_454545_256x240.png +0 -0
  22. {tags/1.12.1/css → css}/images/ui-icons_888888_256x240.png +0 -0
  23. {tags/1.12.1/css → css}/images/ui-icons_cd0a0a_256x240.png +0 -0
  24. {tags/1.10.0/css → css}/index.html +0 -0
  25. {tags/1.12.1/css → css}/jquery-ui.min.css +0 -0
  26. {tags/1.15.1/css → css}/keen-ui.min.css +0 -0
  27. {tags/1.15.1/css → css}/vue-tabs.min.css +0 -0
  28. {tags/1.15.1/css → css}/wp-backitup-admin.min.css +0 -0
  29. {tags/1.10.0/images → extensions}/index.html +0 -0
  30. {tags/1.14.0/images → images}/active_plugins_1.14.png +0 -0
  31. {tags/1.13.2/images → images}/backup_inprogress.png +0 -0
  32. {tags/1.13.2/images → images}/backup_retention.png +0 -0
  33. {tags/1.13.2/images → images}/backup_scheduler.png +0 -0
  34. {tags/1.13.2/images → images}/email_notifications.png +0 -0
  35. {tags/1.13.2/images → images}/error.png +0 -0
  36. {tags/1.13.2/images → images}/icon.png +0 -0
  37. {tags/1.13.2/images → images}/icon32.png +0 -0
  38. {tags/1.10.0 → images}/index.html +0 -0
  39. {tags/1.13.2/images → images}/info.png +0 -0
  40. {tags/1.0.6/images → images}/loader.gif +0 -0
  41. {tags/1.13.2/images → images}/restore_success.png +0 -0
  42. {tags/1.13.2/images → images}/single-file-download.png +0 -0
  43. {tags/1.13.2/images → images}/success.png +0 -0
  44. {tags/1.13.2/images → images}/support_page.png +0 -0
  45. {tags/1.13.2/images → images}/support_portal.png +0 -0
  46. {tags/1.13.2/images → images}/upload_success.png +0 -0
  47. {tags/1.13.2/images → images}/warning.png +0 -0
  48. {tags/1.13.2/images → images}/wpbackitup-logo-small.png +0 -0
  49. {tags/1.13.2/images → images}/wpbackitup-logo.png +0 -0
  50. tags/1.10.0/js/index.html → index.html +0 -0
  51. {tags/1.10.0/lib/includes → js}/index.html +0 -0
  52. {tags/1.15.1/js → js}/keen-ui.min.js +0 -0
  53. {tags/1.15.1/js → js}/sweetalert.min.js +0 -0
  54. {tags/1.15.1/js → js}/vue.min.js +0 -0
  55. {tags/1.15.1/js → js}/wp-backitup-admin.min.js +0 -0
  56. {tags/1.14.3/lib → lib}/background-processing/class-async-request.php +0 -0
  57. {tags/1.13.5/lib → lib}/background-processing/class-background-process.php +0 -0
  58. {tags/1.14.6/lib → lib}/background-processing/class-cleanup-processor.php +0 -0
  59. {tags/1.14.5/lib → lib}/background-processing/class-directory-cleanup-processor.php +0 -0
  60. {tags/1.14.5/lib → lib}/background-processing/class-file-cleanup-processor.php +0 -0
  61. {tags/1.14.5/lib → lib}/background-processing/class-processors.php +0 -0
  62. {tags/1.14.3/lib → lib}/background-processing/class-task-processor.php +0 -0
  63. {tags/1.15.1/lib → lib}/includes/class-admin-notice.php +0 -0
  64. {trunk/lib → lib}/includes/class-admin-notices.php +0 -0
  65. {tags/1.15.1/lib → lib}/includes/class-api.php +0 -0
  66. {tags/1.15.1/lib → lib}/includes/class-backup.php +0 -0
  67. {tags/1.15.1/lib → lib}/includes/class-cleanup.php +0 -0
  68. {tags/1.15.1/lib → lib}/includes/class-database.php +0 -0
  69. {tags/1.14.0/lib → lib}/includes/class-download-log.php +0 -0
  70. {tags/1.14.3/lib → lib}/includes/class-encryption.php +0 -0
  71. {tags/1.14.3/lib → lib}/includes/class-filesystem.php +0 -0
  72. {tags/1.15.1/lib → lib}/includes/class-job-item.php +0 -0
  73. {tags/1.15.1/lib → lib}/includes/class-job-task.php +0 -0
  74. {tags/1.15.1/lib → lib}/includes/class-job.php +0 -0
  75. {tags/1.14.3/lib → lib}/includes/class-license.php +0 -0
  76. {tags/1.15.1/lib → lib}/includes/class-logger.php +0 -0
  77. {tags/1.15.1/lib → lib}/includes/class-loggerV2.php +0 -0
  78. {tags/1.14.3/lib → lib}/includes/class-mutex.php +0 -0
  79. {tags/1.12.1/lib → lib}/includes/class-recursivefilteriterator.php +0 -0
  80. {tags/1.14.3/lib → lib}/includes/class-scheduler.php +0 -0
  81. {tags/1.14.3/lib → lib}/includes/class-sql.php +0 -0
  82. {tags/1.15.1/lib → lib}/includes/class-utility.php +0 -0
  83. {tags/1.15.1/lib → lib}/includes/class-wpbackitup-admin.php +0 -0
  84. {tags/1.14.3/lib → lib}/includes/class-zip.php +0 -0
  85. {tags/1.14.3/lib → lib}/includes/handler_download.php +0 -0
  86. {tags/1.14.3/lib → lib}/includes/handler_upload.php +0 -0
  87. {tags/1.10.9/lib → lib}/includes/handler_viewlog.php +0 -0
  88. {tags/1.10.0/lib → lib/includes}/index.html +0 -0
  89. {tags/1.15.1/lib → lib}/includes/job_backup.php +0 -0
  90. {tags/1.15.1/lib → lib}/includes/job_restore.php +0 -0
  91. {tags/1.14.3/lib → lib}/includes/update_database.php +0 -0
  92. {tags/1.14.3/lib → lib}/includes/update_plugin.php +0 -0
  93. {tags/1.10.0/logs → lib}/index.html +0 -0
  94. tags/1.10.0/license.txt → license.txt +0 -0
  95. {tags/1.10.0/views → logs}/index.html +0 -0
  96. trunk/readme.txt → readme.txt +1 -1
  97. tags/1.0.6/backups/status.log +0 -1
  98. tags/1.0.6/css/wp-backitup.css +0 -52
  99. tags/1.0.6/includes/admin_page.php +0 -1
  100. tags/1.0.6/includes/backup.php +0 -78
  101. tags/1.0.6/includes/download.php +0 -18
  102. tags/1.0.6/includes/functions.php +0 -113
  103. tags/1.0.6/includes/recurse_zip.php +0 -1
  104. tags/1.0.6/js/wp-backitup.js +0 -48
  105. tags/1.0.6/readme.txt +0 -119
  106. tags/1.0.6/wp-backitup.php +0 -75
  107. tags/1.0.7/backups/status.log +0 -1
  108. tags/1.0.7/css/wp-backitup.css +0 -52
  109. tags/1.0.7/images/loader.gif +0 -0
  110. tags/1.0.7/includes/admin_page.php +0 -1
  111. tags/1.0.7/includes/backup.php +0 -78
  112. tags/1.0.7/includes/download.php +0 -18
  113. tags/1.0.7/includes/functions.php +0 -176
  114. tags/1.0.7/includes/recurse_zip.php +0 -1
  115. tags/1.0.7/includes/restore.php +0 -312
  116. tags/1.0.7/js/ajaxfileupload.js +0 -201
  117. tags/1.0.7/js/wp-backitup.js +0 -69
  118. tags/1.0.7/readme.txt +0 -120
  119. tags/1.0.7/screenshots/screenshot-1.png +0 -0
  120. tags/1.0.7/screenshots/screenshot-2.png +0 -0
  121. tags/1.0.7/screenshots/screenshot-3.png +0 -0
  122. tags/1.0.7/wp-backitup.php +0 -75
  123. tags/1.0.8/backups/status.log +0 -1
  124. tags/1.0.8/css/wp-backitup.css +0 -63
  125. tags/1.0.8/images/icon.png +0 -0
  126. tags/1.0.8/images/icon32.png +0 -0
  127. tags/1.0.8/images/loader.gif +0 -0
  128. tags/1.0.8/includes/admin_page.php +0 -1
  129. tags/1.0.8/includes/backup.php +0 -78
  130. tags/1.0.8/includes/download.php +0 -18
  131. tags/1.0.8/includes/functions.php +0 -145
  132. tags/1.0.8/includes/recurse_zip.php +0 -1
  133. tags/1.0.8/js/wp-backitup.js +0 -69
  134. tags/1.0.8/readme.txt +0 -152
  135. tags/1.0.8/screenshots/screenshot-1.png +0 -0
  136. tags/1.0.8/screenshots/screenshot-2.png +0 -0
  137. tags/1.0.8/screenshots/screenshot-3.png +0 -0
  138. tags/1.0.8/wp-backitup.php +0 -77
  139. tags/1.0.9/backups/status.log +0 -1
  140. tags/1.0.9/css/wp-backitup.css +0 -63
  141. tags/1.0.9/images/icon.png +0 -0
  142. tags/1.0.9/images/icon32.png +0 -0
  143. tags/1.0.9/images/loader.gif +0 -0
  144. tags/1.0.9/includes/admin_page.php +0 -1
  145. tags/1.0.9/includes/backup.php +0 -78
  146. tags/1.0.9/includes/download.php +0 -18
  147. tags/1.0.9/includes/functions.php +0 -145
  148. tags/1.0.9/includes/recurse_zip.php +0 -1
  149. tags/1.0.9/js/wp-backitup.js +0 -69
  150. tags/1.0.9/readme.txt +0 -158
  151. tags/1.0.9/screenshots/screenshot-1.png +0 -0
  152. tags/1.0.9/screenshots/screenshot-2.png +0 -0
  153. tags/1.0.9/screenshots/screenshot-3.png +0 -0
  154. tags/1.0.9/wp-backitup.php +0 -147
  155. tags/1.1.0/backups/status.log +0 -1
  156. tags/1.1.0/css/wp-backitup.css +0 -63
  157. tags/1.1.0/images/icon.png +0 -0
  158. tags/1.1.0/images/icon32.png +0 -0
  159. tags/1.1.0/images/loader.gif +0 -0
  160. tags/1.1.0/includes/admin_page.php +0 -1
  161. tags/1.1.0/includes/backup.php +0 -78
  162. tags/1.1.0/includes/download.php +0 -18
  163. tags/1.1.0/includes/functions.php +0 -145
  164. tags/1.1.0/includes/recurse_zip.php +0 -1
  165. tags/1.1.0/js/wp-backitup.js +0 -69
  166. tags/1.1.0/readme.txt +0 -164
  167. tags/1.1.0/screenshots/screenshot-1.png +0 -0
  168. tags/1.1.0/screenshots/screenshot-2.png +0 -0
  169. tags/1.1.0/screenshots/screenshot-3.png +0 -0
  170. tags/1.1.0/wp-backitup.php +0 -135
  171. tags/1.1.1/backups/status.log +0 -1
  172. tags/1.1.1/css/admin-style.css +0 -63
  173. tags/1.1.1/css/wp-backitup.css +0 -63
  174. tags/1.1.1/images/icon.png +0 -0
  175. tags/1.1.1/images/icon32.png +0 -0
  176. tags/1.1.1/images/loader.gif +0 -0
  177. tags/1.1.1/includes/admin_page.php +0 -1
  178. tags/1.1.1/includes/backup.php +0 -78
  179. tags/1.1.1/includes/download.php +0 -18
  180. tags/1.1.1/includes/functions.php +0 -145
  181. tags/1.1.1/includes/recurse_zip.php +0 -1
  182. tags/1.1.1/js/wp-backitup.js +0 -69
  183. tags/1.1.1/readme.txt +0 -165
  184. tags/1.1.1/screenshots/screenshot-1.png +0 -0
  185. tags/1.1.1/screenshots/screenshot-2.png +0 -0
  186. tags/1.1.1/screenshots/screenshot-3.png +0 -0
  187. tags/1.1.1/wp-backitup.php +0 -138
  188. tags/1.1.2/backups/status.log +0 -1
  189. tags/1.1.2/css/admin-style.css +0 -63
  190. tags/1.1.2/css/wp-backitup.css +0 -63
  191. tags/1.1.2/images/icon.png +0 -0
  192. tags/1.1.2/images/icon32.png +0 -0
  193. tags/1.1.2/images/loader.gif +0 -0
  194. tags/1.1.2/includes/admin_page.php +0 -1
  195. tags/1.1.2/includes/backup.php +0 -78
  196. tags/1.1.2/includes/download.php +0 -18
  197. tags/1.1.2/includes/functions.php +0 -145
  198. tags/1.1.2/includes/recurse_zip.php +0 -1
  199. tags/1.1.2/js/wp-backitup.js +0 -69
  200. tags/1.1.2/readme.txt +0 -165
  201. tags/1.1.2/screenshots/screenshot-1.png +0 -0
  202. tags/1.1.2/screenshots/screenshot-2.png +0 -0
  203. tags/1.1.2/screenshots/screenshot-3.png +0 -0
  204. tags/1.1.2/wp-backitup.php +0 -138
  205. tags/1.1.4/backups/WP Backitup-Export-2013-02-13-0921.zip +0 -0
  206. tags/1.1.4/backups/status.log +0 -1
  207. tags/1.1.4/css/admin.css +0 -59
  208. tags/1.1.4/images/icon.png +0 -0
  209. tags/1.1.4/images/icon32.png +0 -0
  210. tags/1.1.4/images/loader.gif +0 -0
  211. tags/1.1.4/index.php +0 -342
  212. tags/1.1.4/js/admin.js +0 -69
  213. tags/1.1.4/lib/constants.php +0 -21
  214. tags/1.1.4/lib/functions.php +0 -251
  215. tags/1.1.4/lib/includes/backup.php +0 -82
  216. tags/1.1.4/lib/recurse_zip.php +0 -1
  217. tags/1.1.4/license.txt +0 -674
  218. tags/1.1.4/readme.txt +0 -183
  219. tags/1.1.4/screenshots/screenshot-1.png +0 -0
  220. tags/1.1.4/screenshots/screenshot-2.png +0 -0
  221. tags/1.1.4/screenshots/screenshot-3.png +0 -0
  222. tags/1.1.4/views/options.php +0 -47
  223. tags/1.1.6/backups/status.log +0 -1
  224. tags/1.1.6/css/admin.css +0 -59
  225. tags/1.1.6/images/icon.png +0 -0
  226. tags/1.1.6/images/icon32.png +0 -0
  227. tags/1.1.6/images/loader.gif +0 -0
  228. tags/1.1.6/index.php +0 -342
  229. tags/1.1.6/js/admin.js +0 -51
  230. tags/1.1.6/lib/constants.php +0 -21
  231. tags/1.1.6/lib/functions.php +0 -251
  232. tags/1.1.6/lib/includes/backup.php +0 -93
  233. tags/1.1.6/lib/recurse_zip.php +0 -1
  234. tags/1.1.6/license.txt +0 -674
  235. tags/1.1.6/readme.txt +0 -201
  236. tags/1.1.6/screenshots/screenshot-1.png +0 -0
  237. tags/1.1.6/screenshots/screenshot-2.png +0 -0
  238. tags/1.1.6/screenshots/screenshot-3.png +0 -0
  239. tags/1.1.6/views/options.php +0 -46
  240. tags/1.10.0/css/wpbackitup_admin.css +0 -126
  241. tags/1.10.0/images/error.png +0 -0
  242. tags/1.10.0/images/icon.png +0 -0
  243. tags/1.10.0/images/icon32.png +0 -0
  244. tags/1.10.0/images/info.png +0 -0
  245. tags/1.10.0/images/loader.gif +0 -0
  246. tags/1.10.0/images/success.png +0 -0
  247. tags/1.10.0/images/warning.png +0 -0
  248. tags/1.10.0/js/wpbackitup_admin.js +0 -1085
  249. tags/1.10.0/languages/en-GB.mo +0 -0
  250. tags/1.10.0/languages/en-GB.po +0 -333
  251. tags/1.10.0/lib/includes/class-backup.php +0 -724
  252. tags/1.10.0/lib/includes/class-filesystem.php +0 -553
  253. tags/1.10.0/lib/includes/class-job.php +0 -756
  254. tags/1.10.0/lib/includes/class-logger.php +0 -219
  255. tags/1.10.0/lib/includes/class-recursiveFilter_Iterator.php +0 -34
  256. tags/1.10.0/lib/includes/class-restore.php +0 -1085
  257. tags/1.10.0/lib/includes/class-scheduler.php +0 -161
  258. tags/1.10.0/lib/includes/class-sql.php +0 -520
  259. tags/1.10.0/lib/includes/class-utility.php +0 -83
  260. tags/1.10.0/lib/includes/class-wpbackitup-admin.php +0 -1740
  261. tags/1.10.0/lib/includes/class-zip.php +0 -1
  262. tags/1.10.0/lib/includes/handler_download.php +0 -100
  263. tags/1.10.0/lib/includes/handler_upload.php +0 -176
  264. tags/1.10.0/lib/includes/handler_viewlog.php +0 -44
  265. tags/1.10.0/lib/includes/job_backup.php +0 -1032
  266. tags/1.10.0/lib/includes/job_cleanup.php +0 -240
  267. tags/1.10.0/lib/includes/job_restore.php +0 -822
  268. tags/1.10.0/readme.txt +0 -410
  269. tags/1.10.0/views/backup.php +0 -441
  270. tags/1.10.0/views/restore.php +0 -283
  271. tags/1.10.0/views/settings.php +0 -104
  272. tags/1.10.0/views/support.php +0 -85
  273. tags/1.10.0/wp-backitup.php +0 -141
  274. tags/1.10.1/css/wpbackitup_admin.css +0 -126
  275. tags/1.10.1/images/error.png +0 -0
  276. tags/1.10.1/images/icon.png +0 -0
  277. tags/1.10.1/images/icon32.png +0 -0
  278. tags/1.10.1/images/index.html +0 -0
  279. tags/1.10.1/images/info.png +0 -0
  280. tags/1.10.1/images/loader.gif +0 -0
  281. tags/1.10.1/images/success.png +0 -0
  282. tags/1.10.1/images/warning.png +0 -0
  283. tags/1.10.1/index.html +0 -0
  284. tags/1.10.1/js/index.html +0 -0
  285. tags/1.10.1/js/wpbackitup_admin.js +0 -1085
  286. tags/1.10.1/languages/en-GB.mo +0 -0
  287. tags/1.10.1/languages/en-GB.po +0 -333
  288. tags/1.10.1/lib/includes/class-backup.php +0 -724
  289. tags/1.10.1/lib/includes/class-filesystem.php +0 -554
  290. tags/1.10.1/lib/includes/class-job.php +0 -756
  291. tags/1.10.1/lib/includes/class-logger.php +0 -219
  292. tags/1.10.1/lib/includes/class-recursiveFilter_Iterator.php +0 -34
  293. tags/1.10.1/lib/includes/class-restore.php +0 -1085
  294. tags/1.10.1/lib/includes/class-scheduler.php +0 -161
  295. tags/1.10.1/lib/includes/class-sql.php +0 -520
  296. tags/1.10.1/lib/includes/class-utility.php +0 -83
  297. tags/1.10.1/lib/includes/class-wpbackitup-admin.php +0 -581
assets/banner-772x250.jpg DELETED
Binary file
assets/icon-128x128.png DELETED
Binary file
assets/icon-256x256.png DELETED
Binary file
assets/screenshot-1.png DELETED
Binary file
assets/screenshot-2.png DELETED
Binary file
assets/screenshot-3.png DELETED
Binary file
assets/screenshot-4.png DELETED
Binary file
assets/screenshot-5.png DELETED
Binary file
assets/screenshot-6.png DELETED
Binary file
assets/screenshot-7.png DELETED
Binary file
{tags/1.12.1/css → css}/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_flat_75_ffffff_40x100.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_glass_55_fbf9ee_1x400.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_glass_65_ffffff_1x400.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_glass_75_dadada_1x400.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_glass_75_e6e6e6_1x400.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-bg_highlight-soft_75_cccccc_1x100.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-icons_222222_256x240.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-icons_454545_256x240.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-icons_888888_256x240.png RENAMED
File without changes
{tags/1.12.1/css → css}/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
{tags/1.10.0/css → css}/index.html RENAMED
File without changes
{tags/1.12.1/css → css}/jquery-ui.min.css RENAMED
File without changes
{tags/1.15.1/css → css}/keen-ui.min.css RENAMED
File without changes
{tags/1.15.1/css → css}/vue-tabs.min.css RENAMED
File without changes
{tags/1.15.1/css → css}/wp-backitup-admin.min.css RENAMED
File without changes
{tags/1.10.0/images → extensions}/index.html RENAMED
File without changes
{tags/1.14.0/images → images}/active_plugins_1.14.png RENAMED
File without changes
{tags/1.13.2/images → images}/backup_inprogress.png RENAMED
File without changes
{tags/1.13.2/images → images}/backup_retention.png RENAMED
File without changes
{tags/1.13.2/images → images}/backup_scheduler.png RENAMED
File without changes
{tags/1.13.2/images → images}/email_notifications.png RENAMED
File without changes
{tags/1.13.2/images → images}/error.png RENAMED
File without changes
{tags/1.13.2/images → images}/icon.png RENAMED
File without changes
{tags/1.13.2/images → images}/icon32.png RENAMED
File without changes
{tags/1.10.0 → images}/index.html RENAMED
File without changes
{tags/1.13.2/images → images}/info.png RENAMED
File without changes
{tags/1.0.6/images → images}/loader.gif RENAMED
File without changes
{tags/1.13.2/images → images}/restore_success.png RENAMED
File without changes
{tags/1.13.2/images → images}/single-file-download.png RENAMED
File without changes
{tags/1.13.2/images → images}/success.png RENAMED
File without changes
{tags/1.13.2/images → images}/support_page.png RENAMED
File without changes
{tags/1.13.2/images → images}/support_portal.png RENAMED
File without changes
{tags/1.13.2/images → images}/upload_success.png RENAMED
File without changes
{tags/1.13.2/images → images}/warning.png RENAMED
File without changes
{tags/1.13.2/images → images}/wpbackitup-logo-small.png RENAMED
File without changes
{tags/1.13.2/images → images}/wpbackitup-logo.png RENAMED
File without changes
tags/1.10.0/js/index.html → index.html RENAMED
File without changes
{tags/1.10.0/lib/includes → js}/index.html RENAMED
File without changes
{tags/1.15.1/js → js}/keen-ui.min.js RENAMED
File without changes
{tags/1.15.1/js → js}/sweetalert.min.js RENAMED
File without changes
{tags/1.15.1/js → js}/vue.min.js RENAMED
File without changes
{tags/1.15.1/js → js}/wp-backitup-admin.min.js RENAMED
File without changes
{tags/1.14.3/lib → lib}/background-processing/class-async-request.php RENAMED
File without changes
{tags/1.13.5/lib → lib}/background-processing/class-background-process.php RENAMED
File without changes
{tags/1.14.6/lib → lib}/background-processing/class-cleanup-processor.php RENAMED
File without changes
{tags/1.14.5/lib → lib}/background-processing/class-directory-cleanup-processor.php RENAMED
File without changes
{tags/1.14.5/lib → lib}/background-processing/class-file-cleanup-processor.php RENAMED
File without changes
{tags/1.14.5/lib → lib}/background-processing/class-processors.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/background-processing/class-task-processor.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-admin-notice.php RENAMED
File without changes
{trunk/lib → lib}/includes/class-admin-notices.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-api.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-backup.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-cleanup.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-database.php RENAMED
File without changes
{tags/1.14.0/lib → lib}/includes/class-download-log.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-encryption.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-filesystem.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-job-item.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-job-task.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-job.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-license.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-logger.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-loggerV2.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-mutex.php RENAMED
File without changes
{tags/1.12.1/lib → lib}/includes/class-recursivefilteriterator.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-scheduler.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-sql.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-utility.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/class-wpbackitup-admin.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/class-zip.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/handler_download.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/handler_upload.php RENAMED
File without changes
{tags/1.10.9/lib → lib}/includes/handler_viewlog.php RENAMED
File without changes
{tags/1.10.0/lib → lib/includes}/index.html RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/job_backup.php RENAMED
File without changes
{tags/1.15.1/lib → lib}/includes/job_restore.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/update_database.php RENAMED
File without changes
{tags/1.14.3/lib → lib}/includes/update_plugin.php RENAMED
File without changes
{tags/1.10.0/logs → lib}/index.html RENAMED
File without changes
tags/1.10.0/license.txt → license.txt RENAMED
File without changes
{tags/1.10.0/views → logs}/index.html RENAMED
File without changes
trunk/readme.txt → readme.txt RENAMED
@@ -214,7 +214,7 @@ Our online documentation and full list of FAQs can be found at [support.wpbackit
214
 
215
 
216
  == Changelog ==
217
- = 1.15.2 =
218
  *Release Date - November 16, 2017
219
 
220
  * FIX: Fix minor issue with admin notice
214
 
215
 
216
  == Changelog ==
217
+ = 1.15.3 =
218
  *Release Date - November 16, 2017
219
 
220
  * FIX: Fix minor issue with admin notice
tags/1.0.6/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.0.6/css/wp-backitup.css DELETED
@@ -1,52 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- input {padding: 0;}
6
-
7
- h3 {
8
- margin: 0;
9
- padding: 1em 0 0 0;
10
- }
11
-
12
- ul {padding: 1em 0 0 0;}
13
-
14
- iframe {
15
- height: 0;
16
- margin: 0;
17
- padding: 0;
18
- position: absolute;
19
- top: 0;
20
- right: 0;
21
- width: 0;
22
- }
23
-
24
- .wp-backitup-section {clear:both;}
25
-
26
- #backup-button, #restore-form {
27
- float: left;
28
- margin: 0 5px 5px 0;
29
- }
30
-
31
- #backup-button a {
32
- display: block;
33
- padding: 3px 8px;
34
- -webkit-border-radius: 10px;
35
- -moz-border-radius: 10px;
36
- border-radius: 10px;
37
- }
38
-
39
- .status-icon {
40
- display: inline;
41
- height: 16px;
42
- visibility: hidden;
43
- width: 16px;
44
- }
45
-
46
- .status-icon img {margin-top: 3px;}
47
-
48
- #wp-backitup-restore .status-icon img {margin-top: 7px;}
49
-
50
- #restore_form {margin-right: 5px;}
51
-
52
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.6/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- // 5 minutes per image should be PLENTY
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Export file created successfully. You can download your export file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/includes/functions.php DELETED
@@ -1,113 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) { //If $file is a file
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.6/js/wp-backitup.js DELETED
@@ -1,48 +0,0 @@
1
- jQuery(document).ready(function($) {
2
- //define backup variables
3
- var wpBackitupBackup = {
4
- action: 'wpbackitup_backup',
5
- beforeSend: function() {
6
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
7
- $("#wp-backitup-status").empty();
8
- setInterval(logreader, 1000);
9
- }
10
- };
11
-
12
- //define download variables
13
- var wpBackitupDownload = {
14
- action: 'wpbackitup_download'
15
- };
16
-
17
- //define logreader variables
18
- var wpBackitupLogReader = {
19
- action: 'wpbackitup_logreader'
20
- };
21
-
22
- //define logreader function
23
- function logreader() {
24
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
25
- $("#wp-backitup-status").html(response);
26
- });
27
- }
28
-
29
- //define download function
30
- function download() {
31
- $.post(ajaxurl, wpBackitupDownload, function(response) {
32
- $("#wp-backitup-download-status").html(response);
33
- });
34
- }
35
-
36
- //execute download (on page load/refresh)
37
- download();
38
-
39
- //execute backup on button click
40
- $("#wpBackitupBackup").click( function() {
41
- $.post(ajaxurl, wpBackitupBackup, function(response) {
42
- download(); //Build download link
43
- clearInterval(logreader); //Stop checking for status updates
44
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
45
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
46
- });
47
- })
48
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/readme.txt DELETED
@@ -1,119 +0,0 @@
1
- === Plugin Name ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpBackitup.com
4
- Tags: backup, restore, clone, database, wp-content, files
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.0.6
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- WP Backitup allows you to backup your database and wp-content folder. This allows you to quickly clone, backup and restore any of your Wordpress sites.
12
-
13
- == Description ==
14
-
15
- WP Backitup uses nothing but PHP to allow you to backup and restore your Wordpress database, plugins, themes and uploads directories. You can create a
16
- backup of any site and, using WP Backitup, quickly import your files, settings and content into a new site.
17
-
18
- == Installation ==
19
-
20
- Installation of the plugin is straightforward:
21
-
22
- 1. Upload the directory `wp-Backitup` to the `/wp-content/plugins/` directory.
23
- 1. Activate the plugin through the `Plugins` menu in WordPress.
24
- 1. Through the Wordpress dashboard, browse to Tools > WP Backitup.
25
-
26
- == Frequently Asked Questions ==
27
-
28
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
29
- Yes
30
-
31
- = Will WP Backitup work on Windows hosting? =
32
- Yes
33
-
34
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
35
- Not at this time.
36
-
37
- = Can this plugin back to Amazon S3? =
38
- Not at this time.
39
-
40
- = Is there an auto back up schedule feature? =
41
- Not at this time.
42
-
43
- = Will the plugin work with Wordpres version x.x? =
44
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
45
-
46
- = Can this backup one version of WordPress to a different version? =
47
- No. It is absolutely critical that your WordPress versions are exactly the same.
48
-
49
- = Will WP Backitup work on WordPress Multisite? =
50
- It is untested with Wordpress multisite and probably will not work.
51
-
52
- = Does the plugin copy the database details as well? =
53
- Yes, a database dump is created with each backup.
54
-
55
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
56
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
57
-
58
- = Does WP Backitup need to be installed? =
59
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
60
-
61
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
62
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
63
-
64
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
65
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
66
-
67
- = Do you do regularly update this product to match with WP version updates? =
68
- Yes.
69
-
70
- == Screenshots ==
71
- 1. Once activated, the plugin loads a new menu into Tools > WP Backitup.
72
- 2. Simply click 'Export' to generate a backup of your site. The plugin will update you on its progress.
73
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
74
-
75
- == Changelog ==
76
-
77
- = 1.0.6 =
78
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
79
-
80
- = 1.0.5 =
81
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
82
-
83
- = 1.0.4 =
84
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
85
-
86
- = 1.0.3 =
87
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
88
-
89
- = 1.0.2 =
90
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
91
-
92
- = 1.0.1 =
93
- * Increased PHP timeout to 900 seconds (5 minutes).
94
-
95
- = 1.0 =
96
- * Plugin released.
97
-
98
- == Upgrade Notice ==
99
-
100
- = 1.0.6 =
101
- * Non-critical upgrade.
102
-
103
- = 1.0.5 =
104
- * Critical upgrade: More stable, increased flexibility and power.
105
-
106
- = 1.0.4 =
107
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
108
-
109
- = 1.0.3 =
110
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
111
-
112
- = 1.0.2 =
113
- * Critical upgrade: Plugin does not work on most systems without this upgrade
114
-
115
- = 1.0.1 =
116
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
117
-
118
- = 1.0 =
119
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.6/wp-backitup.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.0.6
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John C. Peden ( email : mail@johncpeden.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", WP_PLUGIN_URL ."/wp-backitup/");
19
- define("WPBACKITUP_PLUGIN_PATH", WP_PLUGIN_DIR."/wp-backitup/");
20
- define("WPBACKITUP_DIRNAME", "wp-backitup");
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
22
-
23
- //add plugin options
24
- function wpbackitup_options_init() {
25
- register_setting ('wpbackitup_options', 'wpbackitup', 'wpbackitup_options_validate');
26
- }
27
- add_action('admin_init', 'wpbackitup_options_init' );
28
-
29
- //load admin menu
30
- function wpbackitup_admin_menus() {
31
- $wpbackituppage = add_submenu_page( 'tools.php', 'WP BackItUp', 'WP BackItUp', 'manage_options', 'wp-backitup', 'wpbackitup_admin' );
32
- add_action('admin_print_scripts-'.$wpbackituppage, 'wpbackitup_javascript');
33
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_stylesheet' );
34
- }
35
- add_action('admin_menu', 'wpbackitup_admin_menus');
36
-
37
- //enqueue javascript
38
- function wpbackitup_javascript() {
39
- wp_enqueue_script('wpbackitup-javascript', WPBACKITUP_PLUGIN_URL.'/js/wp-backitup.js');
40
- wp_enqueue_script('ajaxfileupload', WPBACKITUP_PLUGIN_URL.'/js/ajaxfileupload.js');
41
- }
42
-
43
- //enqueue stylesheet
44
- function wpbackitup_stylesheet(){
45
- wp_enqueue_style('wpbackitup-stylesheet', WPBACKITUP_PLUGIN_URL.'/css/wp-backitup.css');
46
- }
47
-
48
- //load plugin functions
49
- include_once 'includes/functions.php';
50
-
51
- //load admin page
52
- function wpbackitup_admin() {
53
- include_once('includes/admin_page.php');
54
- }
55
-
56
- //load backup function
57
- function wpbackitup_backup() {
58
- include 'includes/backup.php';
59
- }
60
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
61
-
62
- //load download function
63
- function wpbackitup_download() {
64
- include 'includes/download.php';
65
- }
66
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
67
-
68
- //load download function
69
- function wpbackitup_logreader() {
70
- if(file_exists(BACKUP_PATH .'/status.log') ) {
71
- readfile(BACKUP_PATH .'/status.log');
72
- }
73
- die();
74
- }
75
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Export file created successfully. You can download your export file using the link above.</li></ul>
 
tags/1.0.7/css/wp-backitup.css DELETED
@@ -1,52 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- input {padding: 0;}
6
-
7
- h3 {
8
- margin: 0;
9
- padding: 1em 0 0 0;
10
- }
11
-
12
- ul {padding: 1em 0 0 0;}
13
-
14
- iframe {
15
- height: 0;
16
- margin: 0;
17
- padding: 0;
18
- position: absolute;
19
- top: 0;
20
- right: 0;
21
- width: 0;
22
- }
23
-
24
- .wp-backitup-section {clear:both;}
25
-
26
- #backup-button, #restore-form {
27
- float: left;
28
- margin: 0 5px 5px 0;
29
- }
30
-
31
- #backup-button a {
32
- display: block;
33
- padding: 3px 8px;
34
- -webkit-border-radius: 10px;
35
- -moz-border-radius: 10px;
36
- border-radius: 10px;
37
- }
38
-
39
- .status-icon {
40
- display: inline;
41
- height: 16px;
42
- visibility: hidden;
43
- width: 16px;
44
- }
45
-
46
- .status-icon img {margin-top: 3px;}
47
-
48
- #wp-backitup-restore .status-icon img {margin-top: 7px;}
49
-
50
- #restore_form {margin-right: 5px;}
51
-
52
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/images/loader.gif DELETED
Binary file
tags/1.0.7/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.7/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- // 5 minutes per image should be PLENTY
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Export file created successfully. You can download your export file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/includes/functions.php DELETED
@@ -1,176 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) { //If $file is a file
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //defube db_import function
116
- if(!function_exists('db_import')) {
117
- function db_import($restoration_dir_path, $import_siteurl, $current_siteurl, $table_prefix, $import_table_prefix, $dbc) {
118
- global $wpdb;
119
- $sql_files = glob($restoration_dir_path . "/*.sql");
120
- foreach($sql_files as $sql_file) {
121
- $templine = ''; // Temporary variable, used to store current query
122
- $lines = file($sql_file); // Read in entire file
123
- foreach ($lines as $line) { // Loop through each line
124
- if (substr($line, 0, 2) == '--' || $line == '') continue; // Skip it if it's a comment
125
- $templine .= $line; // Add this line to the current segment
126
- if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query
127
- //replace imported site url with current site url
128
- if( strstr( trim($templine), trim($import_siteurl) ) == TRUE ) //If import site url is found
129
- $templine = str_replace( trim($import_siteurl), trim($current_siteurl), $templine ); // Replace import site url with current site url
130
- //if the table prefixes are different, replace the imported site prefixes with the current prefixes
131
- if ($table_prefix != $import_table_prefix) {
132
- if( strstr( trim($templine), trim($import_table_prefix) ) == TRUE ) //If import table prefix is found
133
- $templine = str_replace( trim($import_table_prefix), trim($table_prefix), $templine ); // Replace import site table prefix with current site table prefix
134
- }
135
- // Perform the query
136
- if( mysqli_query($dbc, $templine) === FALSE)
137
- print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
138
- $templine = ''; // Reset temp variable to empty
139
- }
140
- }
141
- }
142
- return true;
143
- }
144
- }
145
-
146
- //Define zip function
147
- function zip($source, $destination, $ignore) {
148
- if (is_string($source)) $source_arr = array($source); // convert it to array
149
- if (!extension_loaded('zip')) {
150
- return false;
151
- }
152
- $zip = new ZipArchive();
153
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
154
- return false;
155
- }
156
- foreach ($source_arr as $source) {
157
- if (!file_exists($source)) continue;
158
- $source = str_replace('\\', '/', realpath($source));
159
- if (is_dir($source) === true) {
160
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
161
- foreach ($files as $file) {
162
- if (!preg_match($ignore, $file)) {
163
- $file = str_replace('\\', '/', realpath($file));
164
- if (is_dir($file) === true) {
165
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
166
- } else if (is_file($file) === true) {
167
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
168
- }
169
- }
170
- }
171
- } else if (is_file($source) === true) {
172
- $zip->addFromString(basename($source), file_get_contents($source));
173
- }
174
- }
175
- return $zip->close();
176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.7/includes/restore.php DELETED
@@ -1,312 +0,0 @@
1
- <?php
2
- //define constants
3
- define("WP_BACKITUP_DIRNAME", basename(dirname(dirname(__FILE__))) );
4
- define("BACKUP_PATH", dirname(dirname(__FILE__)) .'/backups/' );
5
- define('WP_CONTENT_PATH', dirname(dirname(dirname(dirname(__FILE__)))));
6
-
7
- //create log file
8
- $log = BACKUP_PATH . "status.log";
9
- $fh = fopen($log, 'w') or die("can't open file");
10
- fwrite($fh, '<ul>');
11
-
12
- //include functions
13
- require('functions.php');
14
-
15
- // 5 minutes per image should be PLENTY
16
- @set_time_limit(900);
17
-
18
-
19
- //Delete any zips in the upload directory first
20
- foreach (glob(BACKUP_PATH .'*.zip') as $file) {
21
- unlink($file);
22
- }
23
-
24
- //Move the uploaded zip to the plugin directory
25
- fwrite($fh, "<li>Uploading restoration file...");
26
- $restore_file_name = basename( $_FILES['wpbackitup-zip']['name']);
27
- $restore_path = BACKUP_PATH . $restore_file_name;
28
- if(move_uploaded_file($_FILES['wpbackitup-zip']['tmp_name'], $restore_path)) {
29
- fwrite($fh, "Done!</li>");
30
- } else {
31
- fwrite($fh, "</li><li class=\"error\">Your file could not be uploaded.</li></ul>");
32
- recursive_delete($restoration_dir_path);
33
- unlink(BACKUP_PATH . $restore_file_name);
34
- fclose($fh);
35
- die();
36
-
37
- }
38
-
39
- //Unzip the uploaded restore file
40
- fwrite($fh, "<li>Unzipping...");
41
- $zip = new ZipArchive;
42
- $res = $zip->open(BACKUP_PATH . $restore_file_name);
43
- if ($res === TRUE) {
44
- $zip->extractTo(BACKUP_PATH);
45
- $zip->close();
46
- fwrite($fh, "Done!</li>");
47
- } else {
48
- fwrite($fh, "</li><li class=\"error\">Your restoration file could not be unzipped.</li></ul>");
49
- recursive_delete($restoration_dir_path);
50
- unlink(BACKUP_PATH . $restore_file_name);
51
- fclose($fh);
52
- die();
53
- }
54
-
55
- //Identify the restoration directory
56
- fwrite($fh, "<li>Validating zip...");
57
- if(count(glob(BACKUP_PATH . "*", GLOB_ONLYDIR)) == 1) { //does this need wilcard?
58
- foreach(glob(BACKUP_PATH . "*", GLOB_ONLYDIR) as $dir) { //does this need wilcard?
59
- $restoration_dir_path = $dir;
60
- }
61
- }
62
- if(glob($restoration_dir_path .'/backupsiteinfo.txt') ){
63
- fwrite($fh, "Done!</li>");
64
- } else {
65
- fwrite($fh, "</li><li class=\"error\">Your zip file does not contain backupsiteinfo.txt. Please choose another file.</li></ul>");
66
- recursive_delete($restoration_dir_path);
67
- unlink(BACKUP_PATH . $restore_file_name);
68
- fclose($fh);
69
- die();
70
- }
71
-
72
- //If themes dir is present, restore it to wp-content
73
- if(glob($restoration_dir_path . "/themes")) {
74
- fwrite($fh, "<li>Restoring themes...");
75
- $themes_dir = WP_CONTENT_PATH .'/themes';
76
- if(!recursive_delete($themes_dir)) {
77
- fwrite($fh, "</li><li class=\"error\">Unable to remove existing themes directory for import. Please check your CHMOD settings in /wp-content/themes.</li></ul>");
78
- recursive_delete($restoration_dir_path);
79
- unlink(BACKUP_PATH . $restore_file_name);
80
- fclose($fh);
81
- die();
82
- }
83
- if(!create_dir($themes_dir)) {
84
- fwrite($fh, "</li><li class=\"error\">Unable to create new themes directory for import. Please check your CHMOD settings in /wp-content/themes.</li></ul>");
85
- recursive_delete($restoration_dir_path);
86
- unlink(BACKUP_PATH . $restore_file_name);
87
- fclose($fh);
88
- die();
89
- }
90
- if(recusive_copy($restoration_dir_path .'/themes', $themes_dir, array( 'cgi-bin', '.', '..','._', $restore_file_name )) ) {
91
- fwrite($fh, "Done!</li>");
92
- } else {
93
- fwrite($fh, "</li><li class=\"error\">Unable to import themes. Please try again.</li></ul>");
94
- recursive_delete($restoration_dir_path);
95
- unlink(BACKUP_PATH . $restore_file_name);
96
- fclose($fh);
97
- die();
98
- }
99
- } else {
100
- fwrite($fh, "<li class=\"error\">Warning: Themes directory not detected in import file.</li>");
101
- }
102
-
103
- //If uploads dir is present, restore it to wp-content
104
- if(glob($restoration_dir_path . "/uploads")) {
105
- fwrite($fh, "<li>Restoring uploads...");
106
- $uploads_dir = WP_CONTENT_PATH .'/uploads';
107
- if(!recursive_delete($uploads_dir) ){
108
- fwrite($fh, "</li><li class=\"error\">Unable to create new uploads directory for import. Please check your CHMOD settings in /wp-content/uploads.</li></ul>");
109
- recursive_delete($restoration_dir_path);
110
- unlink(BACKUP_PATH . $restore_file_name);
111
- fclose($fh);
112
- die();
113
- }
114
- if(!create_dir($uploads_dir) ) {
115
- fwrite($fh, "</li><li class=\"error\">Unable to create new uploads directory for import. Please check your CHMOD settings in /wp-content/uploads.</li></ul>");
116
- recursive_delete($restoration_dir_path);
117
- unlink(BACKUP_PATH . $restore_file_name);
118
- fclose($fh);
119
- die();
120
- }
121
- if (recusive_copy($restoration_dir_path .'/uploads', $uploads_dir, array( 'cgi-bin', '.', '..','._', $restore_file_name )) ) {
122
- fwrite($fh, "Done!</li>");
123
- } else {
124
- fwrite($fh, "</li><li class=\"error\">Unable to import uploads. Please try again.</li></ul>");
125
- recursive_delete($restoration_dir_path);
126
- unlink(BACKUP_PATH . $restore_file_name);
127
- fclose($fh);
128
- die();
129
- }
130
- } else {
131
- fwrite($fh, "<li class=\"error\">Warning: Uploads directory not detected in import file.</li>");
132
- }
133
-
134
- //If plugins dir is present, restore it to wp-content (exclude wp-backitup)
135
- if(glob($restoration_dir_path . "/plugins")) {
136
- fwrite($fh, "<li>Restoring plugins...");
137
- $plugins_dir = WP_CONTENT_PATH .'/plugins';
138
- if(!recursive_delete($plugins_dir, array('cgi-bin','.','..','._', WP_BACKITUP_DIRNAME) ) ) {
139
- fwrite($fh, "</li><li class=\"error\">Unable to create new plugins directory for import. Please check your CHMOD settings in /wp-content/plugins.</li></ul>");
140
- recursive_delete($restoration_dir_path);
141
- unlink(BACKUP_PATH . $restore_file_name);
142
- fclose($fh);
143
- die();
144
- }
145
- if(!create_dir($plugins_dir) ){
146
- fwrite($fh, "</li><li class=\"error\">Unable to create new plugins directory for import. Please check your CHMOD settings in /wp-content/plugins.</li></ul>");
147
- recursive_delete($restoration_dir_path);
148
- unlink(BACKUP_PATH . $restore_file_name);
149
- fclose($fh);
150
- die();
151
- }
152
- if( recusive_copy($restoration_dir_path .'/plugins', $plugins_dir, array( 'cgi-bin', '.', '..','._', $restore_file_name )) ) {
153
- fwrite($fh, "Done!</li>");
154
- } else {
155
- fwrite($fh, "</li><li class=\"error\">Unable to import plugins. Please try again.</li></ul>");
156
- recursive_delete($restoration_dir_path);
157
- unlink(BACKUP_PATH . $restore_file_name);
158
- fclose($fh);
159
- die();
160
- }
161
- } else {
162
- fwrite($fh, "<li class=\"error\">Warning: Plugins directory not detected in import file.</li>");
163
- }
164
-
165
- //if there is a database dump to restore
166
- if(glob($restoration_dir_path . "/*.sql")) {
167
- //collect connection information from form
168
- fwrite($fh, "<li>Restoring database...");
169
- $db_name = $_POST['db_name'];
170
- $db_user = $_POST['db_user'];
171
- $db_pass = $_POST['db_pass'];
172
- $db_host = $_POST['db_host'];
173
- $table_prefix = $_POST['table_prefix'];
174
- $user_id = $_POST['user_id'];
175
- //Connect to DB
176
- $dbc = mysqli_connect($db_host, $db_user, $db_pass, $db_name); //OR die ('Could not connect to your database: ' . );
177
- if ( !$dbc ) {
178
- fwrite($fh, "</li><li class=\"error\">Unable to connect to your current database: " .mysqli_connect_error() ."</li></ul>");
179
- recursive_delete($restoration_dir_path);
180
- unlink(BACKUP_PATH . $restore_file_name);
181
- fclose($fh);
182
- die();
183
- }
184
- //get siteurl
185
- $q1 = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name =\"siteurl\";";
186
- if ($result = mysqli_query($dbc, $q1)) {
187
- while ($row = mysqli_fetch_row($result)) {
188
- $siteurl = $row[0];
189
- }
190
- mysqli_free_result($result);
191
- } else {
192
- fwrite($fh, "</li><li class=\"error\">Unable to get current site URL from database. Please try again.</li></ul>");
193
- recursive_delete($restoration_dir_path);
194
- unlink(BACKUP_PATH . $restore_file_name);
195
- fclose($fh);
196
- die();
197
- }
198
- //get homeurl
199
- $q2 = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name =\"home\";";
200
- if ($result = mysqli_query($dbc, $q2)) {
201
- while ($row = mysqli_fetch_row($result)) {
202
- $homeurl = $row[0];
203
- }
204
- mysqli_free_result($result);
205
- } else {
206
- fwrite($fh, "</li><li class=\"error\">Unable to get current home URL from database. Please try again.</li></ul>");
207
- recursive_delete($restoration_dir_path);
208
- unlink(BACKUP_PATH . $restore_file_name);
209
- fclose($fh);
210
- die();
211
- }
212
- //get user login
213
- $q3 = "SELECT user_login FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
214
- if ($result = mysqli_query($dbc, $q3)) {
215
- while ($row = mysqli_fetch_row($result)) {
216
- $user_login = $row[0];
217
- }
218
- mysqli_free_result($result);
219
- } else {
220
- fwrite($fh, "</li><li class=\"error\">Unable to get current user ID from database. Please try again.</li></ul>");
221
- recursive_delete($restoration_dir_path);
222
- unlink(BACKUP_PATH . $restore_file_name);
223
- fclose($fh);
224
- die();
225
- }
226
- //get user pass
227
- $q4 = "SELECT user_pass FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
228
- if ($result = mysqli_query($dbc, $q4)) {
229
- while ($row = mysqli_fetch_row($result)) {
230
- $user_pass = $row[0];
231
- }
232
- mysqli_free_result($result);
233
- } else {
234
- fwrite($fh, "</li><li class=\"error\">Unable to get current user password from database. Please try again.</li></ul>");
235
- recursive_delete($restoration_dir_path);
236
- unlink(BACKUP_PATH . $restore_file_name);
237
- fclose($fh);
238
- die();
239
- }
240
- //get user email
241
- $q5 = "SELECT user_email FROM ". $table_prefix ."users WHERE ID=" .$user_id ."";
242
- if ($result = mysqli_query($dbc, $q5)) {
243
- while ($row = mysqli_fetch_row($result)) {
244
- $user_email = $row[0];
245
- }
246
- mysqli_free_result($result);
247
- } else {
248
- fwrite($fh, "</li><li class=\"error\">Unable to get current user email from database. Please try again.</li></ul>");
249
- recursive_delete($restoration_dir_path);
250
- unlink(BACKUP_PATH . $restore_file_name);
251
- fclose($fh);
252
- die();
253
- }
254
- //Collect previous backup site url start
255
- $import_siteinfo_lines = file($restoration_dir_path .'/backupsiteinfo.txt');
256
- $import_siteurl = trim($import_siteinfo_lines[0]);
257
- $current_siteurl = trim($siteurl ,'/');
258
- $import_table_prefix = $import_siteinfo_lines[1];
259
- //import the database
260
- if(!db_import($restoration_dir_path, $import_siteurl, $current_siteurl, $table_prefix, $import_table_prefix, $dbc)) {
261
- fwrite($fh, "</li><li class=\"error\">Unable to get import your database. This may require importing the file manually.</li></ul>");
262
- recursive_delete($restoration_dir_path);
263
- unlink(BACKUP_PATH . $restore_file_name);
264
- fclose($fh);
265
- die();
266
- }
267
- //update the database
268
- $q6 = "UPDATE ". $table_prefix ."options SET option_value=\"" .$current_siteurl ."\" WHERE option_name=\"siteurl\"";
269
- $q7 = "UPDATE ". $table_prefix ."options SET option_value=\"" .$homeurl ."\" WHERE option_name=\"home\"";
270
- $q8 = "UPDATE ". $table_prefix ."users SET user_login=\"" .$user_login ."\", user_pass=\"" .$user_pass ."\", user_email=\"" .$user_email ."\" WHERE ID=\"" .$user_id ."\"";
271
- if(!mysqli_query($dbc, $q6) ) {
272
- fwrite($fh, "</li><li class=\"error\">Unable to update your current site URL value. This may require importing the file manually.</li></ul>");
273
- recursive_delete($restoration_dir_path);
274
- unlink(BACKUP_PATH . $restore_file_name);
275
- fclose($fh);
276
- die();
277
- }
278
- if(!mysqli_query($dbc, $q7) ) {
279
- fwrite($fh, "</li><li class=\"error\">Unable to update your current home URL value. This may require importing the file manually.</li></ul>");
280
- recursive_delete($restoration_dir_path);
281
- unlink(BACKUP_PATH . $restore_file_name);
282
- fclose($fh);
283
- die();
284
- }
285
- if(!mysqli_query($dbc, $q8) ) {
286
- fwrite($fh, "</li><li class=\"error\">Unable to update your user information. This may require importing the file manually.</li></ul>");
287
- recursive_delete($restoration_dir_path);
288
- unlink(BACKUP_PATH . $restore_file_name);
289
- fclose($fh);
290
- die();
291
- }
292
- fwrite($fh, "Done!</li>");
293
- } else {
294
- fwrite($fh, "<li class=\"error\">Warning: Database not detected in import file.</li>");
295
- }
296
-
297
- //Disconnect
298
- mysqli_close($dbc);
299
-
300
- //Delete the restoration directory
301
- recursive_delete($restoration_dir_path);
302
-
303
- //Delete zip
304
- unlink(BACKUP_PATH . $restore_file_name);
305
-
306
- //close log file
307
- fwrite($fh, '<li>Restoration complete. Please refresh the page.</li>');
308
- fwrite($fh, '</ul>');
309
- fclose($fh);
310
-
311
- //End backup function
312
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/js/ajaxfileupload.js DELETED
@@ -1,201 +0,0 @@
1
-
2
- jQuery.extend({
3
-
4
-
5
- createUploadIframe: function(id, uri)
6
- {
7
- //create frame
8
- var frameId = 'jUploadFrame' + id;
9
- var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
10
- if(window.ActiveXObject)
11
- {
12
- if(typeof uri== 'boolean'){
13
- iframeHtml += ' src="' + 'javascript:false' + '"';
14
-
15
- }
16
- else if(typeof uri== 'string'){
17
- iframeHtml += ' src="' + uri + '"';
18
-
19
- }
20
- }
21
- iframeHtml += ' />';
22
- jQuery(iframeHtml).appendTo(document.body);
23
-
24
- return jQuery('#' + frameId).get(0);
25
- },
26
- createUploadForm: function(id, fileElementId, data)
27
- {
28
- //create form
29
- var formId = 'jUploadForm' + id;
30
- var fileId = 'jUploadFile' + id;
31
- var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
32
- if(data)
33
- {
34
- for(var i in data)
35
- {
36
- jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
37
- }
38
- }
39
- var oldElement = jQuery('#' + fileElementId);
40
- var newElement = jQuery(oldElement).clone();
41
- jQuery(oldElement).attr('id', fileId);
42
- jQuery(oldElement).before(newElement);
43
- jQuery(oldElement).appendTo(form);
44
-
45
-
46
-
47
- //set attributes
48
- jQuery(form).css('position', 'absolute');
49
- jQuery(form).css('top', '-1200px');
50
- jQuery(form).css('left', '-1200px');
51
- jQuery(form).appendTo('body');
52
- return form;
53
- },
54
-
55
- ajaxFileUpload: function(s) {
56
- // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
57
- s = jQuery.extend({}, jQuery.ajaxSettings, s);
58
- var id = new Date().getTime()
59
- var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
60
- var io = jQuery.createUploadIframe(id, s.secureuri);
61
- var frameId = 'jUploadFrame' + id;
62
- var formId = 'jUploadForm' + id;
63
- // Watch for a new set of requests
64
- if ( s.global && ! jQuery.active++ )
65
- {
66
- jQuery.event.trigger( "ajaxStart" );
67
- }
68
- var requestDone = false;
69
- // Create the request object
70
- var xml = {}
71
- if ( s.global )
72
- jQuery.event.trigger("ajaxSend", [xml, s]);
73
- // Wait for a response to come back
74
- var uploadCallback = function(isTimeout)
75
- {
76
- var io = document.getElementById(frameId);
77
- try
78
- {
79
- if(io.contentWindow)
80
- {
81
- xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
82
- xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
83
-
84
- }else if(io.contentDocument)
85
- {
86
- xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
87
- xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
88
- }
89
- }catch(e)
90
- {
91
- jQuery.handleError(s, xml, null, e);
92
- }
93
- if ( xml || isTimeout == "timeout")
94
- {
95
- requestDone = true;
96
- var status;
97
- try {
98
- status = isTimeout != "timeout" ? "success" : "error";
99
- // Make sure that the request was successful or notmodified
100
- if ( status != "error" )
101
- {
102
- // process the data (runs the xml through httpData regardless of callback)
103
- var data = jQuery.uploadHttpData( xml, s.dataType );
104
- // If a local callback was specified, fire it and pass it the data
105
- if ( s.success )
106
- s.success( data, status );
107
-
108
- // Fire the global callback
109
- if( s.global )
110
- jQuery.event.trigger( "ajaxSuccess", [xml, s] );
111
- } else
112
- jQuery.handleError(s, xml, status);
113
- } catch(e)
114
- {
115
- status = "error";
116
- jQuery.handleError(s, xml, status, e);
117
- }
118
-
119
- // The request was completed
120
- if( s.global )
121
- jQuery.event.trigger( "ajaxComplete", [xml, s] );
122
-
123
- // Handle the global AJAX counter
124
- if ( s.global && ! --jQuery.active )
125
- jQuery.event.trigger( "ajaxStop" );
126
-
127
- // Process result
128
- if ( s.complete )
129
- s.complete(xml, status);
130
-
131
- jQuery(io).unbind()
132
-
133
- setTimeout(function()
134
- { try
135
- {
136
- jQuery(io).remove();
137
- jQuery(form).remove();
138
-
139
- } catch(e)
140
- {
141
- jQuery.handleError(s, xml, null, e);
142
- }
143
-
144
- }, 100)
145
-
146
- xml = null
147
-
148
- }
149
- }
150
- // Timeout checker
151
- if ( s.timeout > 0 )
152
- {
153
- setTimeout(function(){
154
- // Check to see if the request is still happening
155
- if( !requestDone ) uploadCallback( "timeout" );
156
- }, s.timeout);
157
- }
158
- try
159
- {
160
-
161
- var form = jQuery('#' + formId);
162
- jQuery(form).attr('action', s.url);
163
- jQuery(form).attr('method', 'POST');
164
- jQuery(form).attr('target', frameId);
165
- if(form.encoding)
166
- {
167
- jQuery(form).attr('encoding', 'multipart/form-data');
168
- }
169
- else
170
- {
171
- jQuery(form).attr('enctype', 'multipart/form-data');
172
- }
173
- jQuery(form).submit();
174
-
175
- } catch(e)
176
- {
177
- jQuery.handleError(s, xml, null, e);
178
- }
179
-
180
- jQuery('#' + frameId).load(uploadCallback );
181
- return {abort: function () {}};
182
-
183
- },
184
-
185
- uploadHttpData: function( r, type ) {
186
- var data = !type;
187
- data = type == "xml" || data ? r.responseXML : r.responseText;
188
- // If the type is "script", eval it in global context
189
- if ( type == "script" )
190
- jQuery.globalEval( data );
191
- // Get the JavaScript object, if JSON is used.
192
- if ( type == "json" )
193
- eval( "data = " + data );
194
- // evaluate scripts within html
195
- if ( type == "html" )
196
- jQuery("<div>").html(data).evalScripts();
197
-
198
- return data;
199
- }
200
- })
201
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/readme.txt DELETED
@@ -1,120 +0,0 @@
1
- === Plugin Name ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup, restore, clone, database, wp-content, files
5
- Requires at least: 3.4
6
- Tested up to: 3.4.2
7
- Stable tag: 1.0.7
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- WP BackItUp allows you to backup your database and wp-content folder. This allows you to quickly clone, backup and restore any of your Wordpress sites.
12
-
13
- == Description ==
14
-
15
- WP BackItUp uses nothing but PHP to allow you to backup and restore your Wordpress database, plugins, themes and uploads directories. You can create a
16
- backup of any site and, using WP BackItUp, quickly import your files, settings and content into a new site.
17
-
18
- == Installation ==
19
-
20
- Installation of the plugin is straightforward:
21
-
22
- 1. Upload the directory `wp-backitup` to the `/wp-content/plugins/` directory.
23
- 1. Activate the plugin through the `Plugins` menu in WordPress.
24
- 1. Through the Wordpress dashboard, browse to Tools > WP BackItUp.
25
-
26
- == Frequently Asked Questions ==
27
-
28
-
29
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
30
- Yes
31
-
32
- = Will WP Backitup work on Windows hosting? =
33
- Yes
34
-
35
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
36
- Not at this time.
37
-
38
- = Can this plugin back to Amazon S3? =
39
- Not at this time.
40
-
41
- = Is there an auto back up schedule feature? =
42
- Not at this time.
43
-
44
- = Will the plugin work with Wordpres version x.x? =
45
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
46
-
47
- = Can this backup one version of WordPress to a different version? =
48
- No. It is absolutely critical that your WordPress versions are exactly the same.
49
-
50
- = Will WP Backitup work on WordPress Multisite? =
51
- It is untested with Wordpress multisite and probably will not work.
52
-
53
- = Does the plugin copy the database details as well? =
54
- Yes, a database dump is created with each backup.
55
-
56
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
57
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
58
-
59
- = Does WP Backitup need to be installed? =
60
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
61
-
62
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
63
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
64
-
65
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
66
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
67
-
68
- = Do you do regularly update this product to match with WP version updates? =
69
- Yes.
70
-
71
- == Screenshots ==
72
- 1. Once activated, the plugin loads a new menu into Tools > WP Backitup.
73
- 2. Simply click 'Export' to generate a backup of your site. The plugin will update you on its progress.
74
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
75
-
76
- == Changelog ==
77
-
78
- = 1.0.6 =
79
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
80
-
81
- = 1.0.5 =
82
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
83
-
84
- = 1.0.4 =
85
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
86
-
87
- = 1.0.3 =
88
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
89
-
90
- = 1.0.2 =
91
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
92
-
93
- = 1.0.1 =
94
- * Increased PHP timeout to 900 seconds (5 minutes).
95
-
96
- = 1.0 =
97
- * Plugin released.
98
-
99
- == Upgrade Notice ==
100
-
101
- = 1.0.6 =
102
- * Non-critical upgrade.
103
-
104
- = 1.0.5 =
105
- * Critical upgrade: More stable, increased flexibility and power.
106
-
107
- = 1.0.4 =
108
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
109
-
110
- = 1.0.3 =
111
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
112
-
113
- = 1.0.2 =
114
- * Critical upgrade: Plugin does not work on most systems without this upgrade
115
-
116
- = 1.0.1 =
117
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
118
-
119
- = 1.0 =
120
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.7/screenshots/screenshot-1.png DELETED
Binary file
tags/1.0.7/screenshots/screenshot-2.png DELETED
Binary file
tags/1.0.7/screenshots/screenshot-3.png DELETED
Binary file
tags/1.0.7/wp-backitup.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP BackItUp
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.0.7
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John C. Peden ( email : mail@johncpeden.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", WP_PLUGIN_URL ."/wp-backitup/");
19
- define("WPBACKITUP_PLUGIN_PATH", WP_PLUGIN_DIR."/wp-backitup/");
20
- define("WPBACKITUP_DIRNAME", "wp-backitup");
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
22
-
23
- //add plugin options
24
- function wpbackitup_options_init() {
25
- register_setting ('wpbackitup_options', 'wpbackitup', 'wpbackitup_options_validate');
26
- }
27
- add_action('admin_init', 'wpbackitup_options_init' );
28
-
29
- //load admin menu
30
- function wpbackitup_admin_menus() {
31
- $wpbackituppage = add_submenu_page( 'tools.php', 'WP BackItUp', 'WP BackItUp', 'manage_options', 'wp-backitup', 'wpbackitup_admin' );
32
- add_action('admin_print_scripts-'.$wpbackituppage, 'wpbackitup_javascript');
33
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_stylesheet' );
34
- }
35
- add_action('admin_menu', 'wpbackitup_admin_menus');
36
-
37
- //enqueue javascript
38
- function wpbackitup_javascript() {
39
- wp_enqueue_script('wpbackitup-javascript', WPBACKITUP_PLUGIN_URL.'/js/wp-backitup.js');
40
- wp_enqueue_script('ajaxfileupload', WPBACKITUP_PLUGIN_URL.'/js/ajaxfileupload.js');
41
- }
42
-
43
- //enqueue stylesheet
44
- function wpbackitup_stylesheet(){
45
- wp_enqueue_style('wpbackitup-stylesheet', WPBACKITUP_PLUGIN_URL.'/css/wp-backitup.css');
46
- }
47
-
48
- //load plugin functions
49
- include_once 'includes/functions.php';
50
-
51
- //load admin page
52
- function wpbackitup_admin() {
53
- include_once('includes/admin_page.php');
54
- }
55
-
56
- //load backup function
57
- function wpbackitup_backup() {
58
- include 'includes/backup.php';
59
- }
60
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
61
-
62
- //load download function
63
- function wpbackitup_download() {
64
- include 'includes/download.php';
65
- }
66
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
67
-
68
- //load download function
69
- function wpbackitup_logreader() {
70
- if(file_exists(BACKUP_PATH .'/status.log') ) {
71
- readfile(BACKUP_PATH .'/status.log');
72
- }
73
- die();
74
- }
75
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.0.8/css/wp-backitup.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/images/icon.png DELETED
Binary file
tags/1.0.8/images/icon32.png DELETED
Binary file
tags/1.0.8/images/loader.gif DELETED
Binary file
tags/1.0.8/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.8/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- //limite process to 5 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/includes/functions.php DELETED
@@ -1,145 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) {
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //Define zip function
116
- function zip($source, $destination, $ignore) {
117
- if (is_string($source)) $source_arr = array($source); // convert it to array
118
- if (!extension_loaded('zip')) {
119
- return false;
120
- }
121
- $zip = new ZipArchive();
122
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
123
- return false;
124
- }
125
- foreach ($source_arr as $source) {
126
- if (!file_exists($source)) continue;
127
- $source = str_replace('\\', '/', realpath($source));
128
- if (is_dir($source) === true) {
129
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
130
- foreach ($files as $file) {
131
- if (!preg_match($ignore, $file)) {
132
- $file = str_replace('\\', '/', realpath($file));
133
- if (is_dir($file) === true) {
134
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
135
- } else if (is_file($file) === true) {
136
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
137
- }
138
- }
139
- }
140
- } else if (is_file($source) === true) {
141
- $zip->addFromString(basename($source), file_get_contents($source));
142
- }
143
- }
144
- return $zip->close();
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.8/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/readme.txt DELETED
@@ -1,152 +0,0 @@
1
- === WP Backitup ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.0.8
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup creates a backup zip of your site&apos;s content and configuration in just a single click, right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
17
-
18
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
19
-
20
- = Automatically Restore Your Backup Zips =
21
- The optional <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a> can be purchased from the plugin site and allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
22
-
23
- = Manually Restore Your Backup Zips =
24
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
25
-
26
- = Easy To Install and Use =
27
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
28
-
29
- = More questions? =
30
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://wordpress.org/extend/plugins/wp-backitup/faq/" title="WP Backitup FAQ">FAQ page</a>?
31
-
32
- == Installation ==
33
-
34
- Installation of the plugin is straightforward:
35
-
36
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
37
- 1. Activate the plugin.
38
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
39
- 1. Click 'Backup/Restore' to access WP-Backitup
40
-
41
- == Frequently Asked Questions ==
42
-
43
- = Can I manually restore my backup zips? =
44
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
45
-
46
- = Is there an easier way to restore my backup zips? =
47
- Yes, purchase and download the <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
48
-
49
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
50
- It is tested on a wide variety of hosting environments and site configurations. Please use the <a href="http://wordpress.org/support/plugin/wp-backitup">support forum</a> if you are having trouble.
51
-
52
- = Will WP Backitup work on Windows hosting? =
53
- Yes.
54
-
55
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
56
- This will be available in a future release.
57
-
58
- = Can this plugin back to Amazon S3/Dropbox? =
59
- This will be available in a future release.
60
-
61
- = Is there an auto back up schedule feature? =
62
- This will be available in a future release.
63
-
64
- = Will the plugin work with Wordpres version x.x? =
65
- WP Backitup is untested on older versions of Wordpress. Please feel free to try it and use the <a href="http://wordpress.org/support/plugin/wp-backitup">support forum</a> or the voting system on the <a href="http://wordpress.org/support/plugin/wp-backitup">plugin page</a> to tell others.
66
-
67
- = Can this backup one version of WordPress to a different version? =
68
- No. It is absolutely critical that your WordPress versions are exactly the same.
69
-
70
- = Will WP Backitup work on WordPress Multisite? =
71
- The plugin can be network-activated within WPMS but sites must be backed-up individually.
72
-
73
- = Does the plugin copy the database details as well? =
74
- Yes, a database dump is created with each backup.
75
-
76
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
77
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
78
-
79
- = Does WP Backitup need to be installed? =
80
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
81
-
82
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
83
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
84
-
85
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
86
- I`ve tested up to 15 themes, 40 plugins and 350 posts/pages without any issues.
87
-
88
- = Do you do regularly update this product to match with WP version updates? =
89
- Yes.
90
-
91
- == Screenshots ==
92
- 1. Once activated, the plugin loads a new menu into your toolbar.
93
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
94
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
95
-
96
- == Changelog ==
97
-
98
- = 1.0.8 =
99
- * Modified plugin administration and loaded menu tab in main toolbar.
100
-
101
- = 1.0.7 =
102
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
103
-
104
- = 1.0.6 =
105
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
106
-
107
- = 1.0.5 =
108
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
109
-
110
- = 1.0.4 =
111
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
112
-
113
- = 1.0.3 =
114
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
115
-
116
- = 1.0.2 =
117
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
118
-
119
- = 1.0.1 =
120
- * Increased PHP timeout to 900 seconds (5 minutes).
121
-
122
- = 1.0 =
123
- * Plugin released.
124
-
125
- == Upgrade Notice ==
126
-
127
- = 1.0.8 =
128
- * Recommended upgrade. Added links to admin menu.
129
-
130
- = 1.0.7 =
131
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
132
-
133
- = 1.0.6 =
134
- * Non-critical upgrade.
135
-
136
- = 1.0.5 =
137
- * Critical upgrade: More stable, increased flexibility and power.
138
-
139
- = 1.0.4 =
140
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
141
-
142
- = 1.0.3 =
143
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
144
-
145
- = 1.0.2 =
146
- * Critical upgrade: Plugin does not work on most systems without this upgrade
147
-
148
- = 1.0.1 =
149
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
150
-
151
- = 1.0 =
152
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.8/screenshots/screenshot-1.png DELETED
Binary file
tags/1.0.8/screenshots/screenshot-2.png DELETED
Binary file
tags/1.0.8/screenshots/screenshot-3.png DELETED
Binary file
tags/1.0.8/wp-backitup.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup
4
- * Plugin URI: http://wordpress.org/extend/plugins/wp-backitup/
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.0.8
7
- * Author: John Peden
8
- * Author URI: http://www.wpbackitup.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John Peden Ltd ( email : support@wpbackitup.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", WP_PLUGIN_URL ."/wp-backitup/");
19
- define("WPBACKITUP_PLUGIN_PATH", WP_PLUGIN_DIR."/wp-backitup/");
20
- define("WPBACKITUP_DIRNAME", "wp-backitup");
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
22
-
23
- //load admin menu
24
- function wpbackitup_admin_menus() {
25
- $wpbackituppage = add_menu_page( __( 'WP Backitup', 'wpBackitup' ), __( 'Backup/Restore', 'wpBackitup' ), 'manage_options', 'wp-backitup', 'wpbackitup_admin', plugin_dir_url(__FILE__ ) .'images/icon.png', 77);
26
- add_action('admin_print_scripts-'.$wpbackituppage, 'wpbackitup_javascript');
27
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_stylesheet' );
28
- }
29
- add_action('admin_menu', 'wpbackitup_admin_menus');
30
-
31
- //enqueue javascript
32
- function wpbackitup_javascript() {
33
- wp_enqueue_script('wpbackitup-javascript', WPBACKITUP_PLUGIN_URL.'/js/wp-backitup.js');
34
- //this needs moved to addon dir (as above)
35
- wp_enqueue_script('ajaxfileupload', WPBACKITUP_PLUGIN_URL.'/js/ajaxfileupload.js');
36
- }
37
-
38
- //enqueue stylesheet
39
- function wpbackitup_stylesheet(){
40
- wp_enqueue_style('wpbackitup-stylesheet', WPBACKITUP_PLUGIN_URL.'/css/wp-backitup.css');
41
- }
42
-
43
- //load plugin functions
44
- include_once 'includes/functions.php';
45
-
46
- //load admin page
47
- function wpbackitup_admin() {
48
- include_once('includes/admin_page.php');
49
- }
50
-
51
- //load backup function
52
- function wpbackitup_backup() {
53
- include 'includes/backup.php';
54
- }
55
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
56
-
57
- //load download function
58
- function wpbackitup_download() {
59
- include 'includes/download.php';
60
- }
61
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
62
-
63
- //load download function
64
- function wpbackitup_logreader() {
65
- if(file_exists(BACKUP_PATH .'/status.log') ) {
66
- readfile(BACKUP_PATH .'/status.log');
67
- }
68
- die();
69
- }
70
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
71
-
72
- //load addons
73
- if(is_dir(WPBACKITUP_PLUGIN_PATH . "addons")){
74
- foreach(glob(WPBACKITUP_PLUGIN_PATH . "addons/*/") as $addon) {
75
- include_once $addon .'index.php';
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.0.9/css/wp-backitup.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/images/icon.png DELETED
Binary file
tags/1.0.9/images/icon32.png DELETED
Binary file
tags/1.0.9/images/loader.gif DELETED
Binary file
tags/1.0.9/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.9/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- //limite process to 5 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/includes/functions.php DELETED
@@ -1,145 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) {
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //Define zip function
116
- function zip($source, $destination, $ignore) {
117
- if (is_string($source)) $source_arr = array($source); // convert it to array
118
- if (!extension_loaded('zip')) {
119
- return false;
120
- }
121
- $zip = new ZipArchive();
122
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
123
- return false;
124
- }
125
- foreach ($source_arr as $source) {
126
- if (!file_exists($source)) continue;
127
- $source = str_replace('\\', '/', realpath($source));
128
- if (is_dir($source) === true) {
129
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
130
- foreach ($files as $file) {
131
- if (!preg_match($ignore, $file)) {
132
- $file = str_replace('\\', '/', realpath($file));
133
- if (is_dir($file) === true) {
134
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
135
- } else if (is_file($file) === true) {
136
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
137
- }
138
- }
139
- }
140
- } else if (is_file($source) === true) {
141
- $zip->addFromString(basename($source), file_get_contents($source));
142
- }
143
- }
144
- return $zip->close();
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.0.9/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/readme.txt DELETED
@@ -1,158 +0,0 @@
1
- === WP Backitup ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.0.9
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup creates a backup zip of your site&apos;s content and configuration in just a single click, right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
17
-
18
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
19
-
20
- = Automatically Restore Your Backup Zips =
21
- The optional <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a> can be purchased from the plugin site and allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
22
-
23
- = Manually Restore Your Backup Zips =
24
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
25
-
26
- = Easy To Install and Use =
27
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
28
-
29
- = More questions? =
30
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://wordpress.org/extend/plugins/wp-backitup/faq/" title="WP Backitup FAQ">FAQ page</a>?
31
-
32
- == Installation ==
33
-
34
- Installation of the plugin is straightforward:
35
-
36
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
37
- 1. Activate the plugin.
38
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
39
- 1. Click 'Backup/Restore' to access WP-Backitup
40
-
41
- == Frequently Asked Questions ==
42
-
43
- = Can I manually restore my backup zips? =
44
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
45
-
46
- = Is there an easier way to restore my backup zips? =
47
- Yes, purchase and download the <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
48
-
49
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
50
- Yes
51
-
52
- = Will WP Backitup work on Windows hosting? =
53
- Yes
54
-
55
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
56
- Not at this time.
57
-
58
- = Can this plugin back to Amazon S3? =
59
- Not at this time.
60
-
61
- = Is there an auto back up schedule feature? =
62
- Not at this time.
63
-
64
- = Will the plugin work with Wordpres version x.x? =
65
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
66
-
67
- = Can this backup one version of WordPress to a different version? =
68
- No. It is absolutely critical that your WordPress versions are exactly the same.
69
-
70
- = Will WP Backitup work on WordPress Multisite? =
71
- It is untested with Wordpress multisite and probably will not work.
72
-
73
- = Does the plugin copy the database details as well? =
74
- Yes, a database dump is created with each backup.
75
-
76
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
77
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
78
-
79
- = Does WP Backitup need to be installed? =
80
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
81
-
82
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
83
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
84
-
85
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
86
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
87
-
88
- = Do you do regularly update this product to match with WP version updates? =
89
- Yes.
90
-
91
- == Screenshots ==
92
- 1. Once activated, the plugin loads a new menu into your toolbar.
93
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
94
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
95
-
96
- == Changelog ==
97
-
98
- = 1.0.9 =
99
- * Added Presstrends tracking code.
100
-
101
- = 1.0.8 =
102
- * Modified plugin administration and loaded menu tab in main toolbar.
103
-
104
- = 1.0.7 =
105
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
106
-
107
- = 1.0.6 =
108
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
109
-
110
- = 1.0.5 =
111
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
112
-
113
- = 1.0.4 =
114
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
115
-
116
- = 1.0.3 =
117
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
118
-
119
- = 1.0.2 =
120
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
121
-
122
- = 1.0.1 =
123
- * Increased PHP timeout to 900 seconds (5 minutes).
124
-
125
- = 1.0 =
126
- * Plugin released.
127
-
128
- == Upgrade Notice ==
129
-
130
- = 1.0.9 =
131
- * Non-essential upgrade. Added Presstrends code.
132
-
133
- = 1.0.8 =
134
- * Recommended upgrade. Added links to admin menu.
135
-
136
- = 1.0.7 =
137
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
138
-
139
- = 1.0.6 =
140
- * Non-critical upgrade.
141
-
142
- = 1.0.5 =
143
- * Critical upgrade: More stable, increased flexibility and power.
144
-
145
- = 1.0.4 =
146
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
147
-
148
- = 1.0.3 =
149
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
150
-
151
- = 1.0.2 =
152
- * Critical upgrade: Plugin does not work on most systems without this upgrade
153
-
154
- = 1.0.1 =
155
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
156
-
157
- = 1.0 =
158
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.0.9/screenshots/screenshot-1.png DELETED
Binary file
tags/1.0.9/screenshots/screenshot-2.png DELETED
Binary file
tags/1.0.9/screenshots/screenshot-3.png DELETED
Binary file
tags/1.0.9/wp-backitup.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.1.0
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John Peden Ltd ( email : support@wpbackitup.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", WP_PLUGIN_URL ."/wp-backitup/");
19
- define("WPBACKITUP_PLUGIN_PATH", WP_PLUGIN_DIR."/wp-backitup/");
20
- define("WPBACKITUP_DIRNAME", "wp-backitup");
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
22
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
23
-
24
- //load admin menu
25
- function wpbackitup_admin_menus() {
26
- $wpbackituppage = add_menu_page( __( 'WP Backitup', 'wpBackitup' ), __( 'Backup', 'wpBackitup' ), 'manage_options', 'wp-backitup', 'wpbackitup_admin', plugin_dir_url(__FILE__ ) .'images/icon.png', 77);
27
- add_action('admin_print_scripts-'.$wpbackituppage, 'wpbackitup_javascript');
28
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_stylesheet' );
29
- }
30
- add_action('admin_menu', 'wpbackitup_admin_menus');
31
-
32
- //enqueue javascript
33
- function wpbackitup_javascript() {
34
- wp_enqueue_script('wpbackitup-javascript', WPBACKITUP_PLUGIN_URL.'/js/wp-backitup.js');
35
- //this needs moved to addon dir (as above)
36
- wp_enqueue_script('ajaxfileupload', WPBACKITUP_PLUGIN_URL.'/js/ajaxfileupload.js');
37
- }
38
-
39
- //enqueue stylesheet
40
- function wpbackitup_stylesheet(){
41
- wp_enqueue_style('wpbackitup-stylesheet', WPBACKITUP_PLUGIN_URL.'/css/wp-backitup.css');
42
- }
43
-
44
- //load plugin functions
45
- include_once 'includes/functions.php';
46
-
47
- //load admin page
48
- function wpbackitup_admin() {
49
- include_once('includes/admin_page.php');
50
- }
51
-
52
- //load backup function
53
- function wpbackitup_backup() {
54
- include 'includes/backup.php';
55
- }
56
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
57
-
58
- //load download function
59
- function wpbackitup_download() {
60
- include 'includes/download.php';
61
- }
62
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
63
-
64
- //load download function
65
- function wpbackitup_logreader() {
66
- if(file_exists(BACKUP_PATH .'/status.log') ) {
67
- readfile(BACKUP_PATH .'/status.log');
68
- }
69
- die();
70
- }
71
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
72
-
73
- //load addons
74
- function dir_contains_children($dir) {
75
- $result = false;
76
- if($dh = opendir($dir)) {
77
- while(!$result && ($file = readdir($dh)) !== false) {
78
- if($file != ("."||"..") {
79
- include $file;
80
- }
81
- }
82
- closedir($dh);
83
- }
84
-
85
- /**
86
- * PressTrends Plugin API
87
- */
88
- function presstrends_WPBackitup_plugin() {
89
-
90
- // PressTrends Account API Key
91
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
92
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
93
-
94
- // Start of Metrics
95
- global $wpdb;
96
- $data = get_transient( 'presstrends_cache_data' );
97
- if ( !$data || $data == '' ) {
98
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
99
- $url = $api_base . $auth . '/api/' . $api_key . '/';
100
-
101
- $count_posts = wp_count_posts();
102
- $count_pages = wp_count_posts( 'page' );
103
- $comments_count = wp_count_comments();
104
-
105
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
106
- if ( function_exists( 'wp_get_theme' ) ) {
107
- $theme_data = wp_get_theme();
108
- $theme_name = urlencode( $theme_data->Name );
109
- } else {
110
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
111
- $theme_name = $theme_data['Name'];
112
- }
113
-
114
- $plugin_name = '&';
115
- foreach ( get_plugins() as $plugin_info ) {
116
- $plugin_name .= $plugin_info['Name'] . '&';
117
- }
118
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
119
- $plugin_data = get_plugin_data( __FILE__ );
120
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
121
- $data = array(
122
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
123
- 'posts' => $count_posts->publish,
124
- 'pages' => $count_pages->publish,
125
- 'comments' => $comments_count->total_comments,
126
- 'approved' => $comments_count->approved,
127
- 'spam' => $comments_count->spam,
128
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
129
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
130
- 'theme_version' => $plugin_data['Version'],
131
- 'theme_name' => $theme_name,
132
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
133
- 'plugins' => count( get_option( 'active_plugins' ) ),
134
- 'plugin' => urlencode( $plugin_name ),
135
- 'wpversion' => get_bloginfo( 'version' ),
136
- );
137
-
138
- foreach ( $data as $k => $v ) {
139
- $url .= $k . '/' . $v . '/';
140
- }
141
- wp_remote_get( $url );
142
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
143
- }
144
- }
145
-
146
- // PressTrends WordPress Action
147
- add_action('admin_init', 'presstrends_WPBackitup_plugin');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.1.0/css/wp-backitup.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/images/icon.png DELETED
Binary file
tags/1.1.0/images/icon32.png DELETED
Binary file
tags/1.1.0/images/loader.gif DELETED
Binary file
tags/1.1.0/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.0/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- //limite process to 5 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/includes/functions.php DELETED
@@ -1,145 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) {
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //Define zip function
116
- function zip($source, $destination, $ignore) {
117
- if (is_string($source)) $source_arr = array($source); // convert it to array
118
- if (!extension_loaded('zip')) {
119
- return false;
120
- }
121
- $zip = new ZipArchive();
122
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
123
- return false;
124
- }
125
- foreach ($source_arr as $source) {
126
- if (!file_exists($source)) continue;
127
- $source = str_replace('\\', '/', realpath($source));
128
- if (is_dir($source) === true) {
129
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
130
- foreach ($files as $file) {
131
- if (!preg_match($ignore, $file)) {
132
- $file = str_replace('\\', '/', realpath($file));
133
- if (is_dir($file) === true) {
134
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
135
- } else if (is_file($file) === true) {
136
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
137
- }
138
- }
139
- }
140
- } else if (is_file($source) === true) {
141
- $zip->addFromString(basename($source), file_get_contents($source));
142
- }
143
- }
144
- return $zip->close();
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.0/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/readme.txt DELETED
@@ -1,164 +0,0 @@
1
- === WP Backitup ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.1.0
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup creates a backup zip of your site&apos;s content and configuration in just a single click, right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
17
-
18
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
19
-
20
- = Automatically Restore Your Backup Zips =
21
- The optional <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a> can be purchased from the plugin site and allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
22
-
23
- = Manually Restore Your Backup Zips =
24
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
25
-
26
- = Easy To Install and Use =
27
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
28
-
29
- = More questions? =
30
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://wordpress.org/extend/plugins/wp-backitup/faq/" title="WP Backitup FAQ">FAQ page</a>?
31
-
32
- == Installation ==
33
-
34
- Installation of the plugin is straightforward:
35
-
36
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
37
- 1. Activate the plugin.
38
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
39
- 1. Click 'Backup/Restore' to access WP-Backitup
40
-
41
- == Frequently Asked Questions ==
42
-
43
- = Can I manually restore my backup zips? =
44
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
45
-
46
- = Is there an easier way to restore my backup zips? =
47
- Yes, purchase and download the <a href="http://www.wpbackitup.com/addons/" title="WP Backitup Restoration Addon">WP Backitup Restoration Addon</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
48
-
49
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
50
- Yes
51
-
52
- = Will WP Backitup work on Windows hosting? =
53
- Yes
54
-
55
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
56
- Not at this time.
57
-
58
- = Can this plugin back to Amazon S3? =
59
- Not at this time.
60
-
61
- = Is there an auto back up schedule feature? =
62
- Not at this time.
63
-
64
- = Will the plugin work with Wordpres version x.x? =
65
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
66
-
67
- = Can this backup one version of WordPress to a different version? =
68
- No. It is absolutely critical that your WordPress versions are exactly the same.
69
-
70
- = Will WP Backitup work on WordPress Multisite? =
71
- It is untested with Wordpress multisite and probably will not work.
72
-
73
- = Does the plugin copy the database details as well? =
74
- Yes, a database dump is created with each backup.
75
-
76
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
77
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
78
-
79
- = Does WP Backitup need to be installed? =
80
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
81
-
82
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
83
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
84
-
85
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
86
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
87
-
88
- = Do you do regularly update this product to match with WP version updates? =
89
- Yes.
90
-
91
- == Screenshots ==
92
- 1. Once activated, the plugin loads a new menu into your toolbar.
93
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
94
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
95
-
96
- == Changelog ==
97
-
98
- = 1.1.0 =
99
- * Fixed bugs with addons system.
100
-
101
- = 1.0.9 =
102
- * Added Presstrends tracking code.
103
-
104
- = 1.0.8 =
105
- * Modified plugin administration and loaded menu tab in main toolbar.
106
-
107
- = 1.0.7 =
108
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
109
-
110
- = 1.0.6 =
111
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
112
-
113
- = 1.0.5 =
114
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
115
-
116
- = 1.0.4 =
117
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
118
-
119
- = 1.0.3 =
120
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
121
-
122
- = 1.0.2 =
123
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
124
-
125
- = 1.0.1 =
126
- * Increased PHP timeout to 900 seconds (5 minutes).
127
-
128
- = 1.0 =
129
- * Plugin released.
130
-
131
- == Upgrade Notice ==
132
-
133
- = 1.1.0 =
134
- * Non-critical upgrade. Fixed bugs with addons system that caused problems for some users.
135
-
136
- = 1.0.9 =
137
- * Non-essential upgrade. Added Presstrends code.
138
-
139
- = 1.0.8 =
140
- * Recommended upgrade. Added links to admin menu.
141
-
142
- = 1.0.7 =
143
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
144
-
145
- = 1.0.6 =
146
- * Non-critical upgrade.
147
-
148
- = 1.0.5 =
149
- * Critical upgrade: More stable, increased flexibility and power.
150
-
151
- = 1.0.4 =
152
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
153
-
154
- = 1.0.3 =
155
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
156
-
157
- = 1.0.2 =
158
- * Critical upgrade: Plugin does not work on most systems without this upgrade
159
-
160
- = 1.0.1 =
161
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
162
-
163
- = 1.0 =
164
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.0/screenshots/screenshot-1.png DELETED
Binary file
tags/1.1.0/screenshots/screenshot-2.png DELETED
Binary file
tags/1.1.0/screenshots/screenshot-3.png DELETED
Binary file
tags/1.1.0/wp-backitup.php DELETED
@@ -1,135 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.1.0
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John Peden Ltd ( email : support@wpbackitup.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", WP_PLUGIN_URL ."/wp-backitup/");
19
- define("WPBACKITUP_PLUGIN_PATH", WP_PLUGIN_DIR."/wp-backitup/");
20
- define("WPBACKITUP_DIRNAME", "wp-backitup");
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
22
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'backups/');
23
-
24
- //load admin menu
25
- function wpbackitup_admin_menus() {
26
- $wpbackituppage = add_menu_page( __( 'WP Backitup', 'wpBackitup' ), __( 'Backup', 'wpBackitup' ), 'manage_options', 'wp-backitup', 'wpbackitup_admin', plugin_dir_url(__FILE__ ) .'images/icon.png', 77);
27
- add_action('admin_print_scripts-'.$wpbackituppage, 'wpbackitup_javascript');
28
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_stylesheet' );
29
- }
30
- add_action('admin_menu', 'wpbackitup_admin_menus');
31
-
32
- //enqueue javascript
33
- function wpbackitup_javascript() {
34
- wp_enqueue_script('wpbackitup-javascript', WPBACKITUP_PLUGIN_URL.'/js/wp-backitup.js');
35
- //this needs moved to addon dir (as above)
36
- wp_enqueue_script('ajaxfileupload', WPBACKITUP_PLUGIN_URL.'/js/ajaxfileupload.js');
37
- }
38
-
39
- //enqueue stylesheet
40
- function wpbackitup_stylesheet(){
41
- wp_enqueue_style('wpbackitup-stylesheet', WPBACKITUP_PLUGIN_URL.'/css/wp-backitup.css');
42
- }
43
-
44
- //load plugin functions
45
- include_once 'includes/functions.php';
46
-
47
- //load admin page
48
- function wpbackitup_admin() {
49
- include_once('includes/admin_page.php');
50
- }
51
-
52
- //load backup function
53
- function wpbackitup_backup() {
54
- include 'includes/backup.php';
55
- }
56
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
57
-
58
- //load download function
59
- function wpbackitup_download() {
60
- include 'includes/download.php';
61
- }
62
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
63
-
64
- //load download function
65
- function wpbackitup_logreader() {
66
- if(file_exists(BACKUP_PATH .'/status.log') ) {
67
- readfile(BACKUP_PATH .'/status.log');
68
- }
69
- die();
70
- }
71
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
72
-
73
- /**
74
- * PressTrends Plugin API
75
- */
76
- function presstrends_WPBackitup_plugin() {
77
-
78
- // PressTrends Account API Key
79
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
80
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
81
-
82
- // Start of Metrics
83
- global $wpdb;
84
- $data = get_transient( 'presstrends_cache_data' );
85
- if ( !$data || $data == '' ) {
86
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
87
- $url = $api_base . $auth . '/api/' . $api_key . '/';
88
-
89
- $count_posts = wp_count_posts();
90
- $count_pages = wp_count_posts( 'page' );
91
- $comments_count = wp_count_comments();
92
-
93
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
94
- if ( function_exists( 'wp_get_theme' ) ) {
95
- $theme_data = wp_get_theme();
96
- $theme_name = urlencode( $theme_data->Name );
97
- } else {
98
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
99
- $theme_name = $theme_data['Name'];
100
- }
101
-
102
- $plugin_name = '&';
103
- foreach ( get_plugins() as $plugin_info ) {
104
- $plugin_name .= $plugin_info['Name'] . '&';
105
- }
106
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
107
- $plugin_data = get_plugin_data( __FILE__ );
108
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
109
- $data = array(
110
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
111
- 'posts' => $count_posts->publish,
112
- 'pages' => $count_pages->publish,
113
- 'comments' => $comments_count->total_comments,
114
- 'approved' => $comments_count->approved,
115
- 'spam' => $comments_count->spam,
116
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
117
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
118
- 'theme_version' => $plugin_data['Version'],
119
- 'theme_name' => $theme_name,
120
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
121
- 'plugins' => count( get_option( 'active_plugins' ) ),
122
- 'plugin' => urlencode( $plugin_name ),
123
- 'wpversion' => get_bloginfo( 'version' ),
124
- );
125
-
126
- foreach ( $data as $k => $v ) {
127
- $url .= $k . '/' . $v . '/';
128
- }
129
- wp_remote_get( $url );
130
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
131
- }
132
- }
133
-
134
- // PressTrends WordPress Action
135
- add_action('admin_init', 'presstrends_WPBackitup_plugin');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Uploading restoration file...Done!</li><li>Unzipping...Done!</li><li>Validating zip...Done!</li><li>Restoring wp-content directory...Done!</li><li>Restoring database...Done!</li><li>Restoration complete. Please refresh the page.</li></ul>
 
tags/1.1.1/css/admin-style.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/css/wp-backitup.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/images/icon.png DELETED
Binary file
tags/1.1.1/images/icon32.png DELETED
Binary file
tags/1.1.1/images/loader.gif DELETED
Binary file
tags/1.1.1/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.1/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- //limite process to 5 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/includes/functions.php DELETED
@@ -1,145 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) {
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //Define zip function
116
- function zip($source, $destination, $ignore) {
117
- if (is_string($source)) $source_arr = array($source); // convert it to array
118
- if (!extension_loaded('zip')) {
119
- return false;
120
- }
121
- $zip = new ZipArchive();
122
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
123
- return false;
124
- }
125
- foreach ($source_arr as $source) {
126
- if (!file_exists($source)) continue;
127
- $source = str_replace('\\', '/', realpath($source));
128
- if (is_dir($source) === true) {
129
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
130
- foreach ($files as $file) {
131
- if (!preg_match($ignore, $file)) {
132
- $file = str_replace('\\', '/', realpath($file));
133
- if (is_dir($file) === true) {
134
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
135
- } else if (is_file($file) === true) {
136
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
137
- }
138
- }
139
- }
140
- } else if (is_file($source) === true) {
141
- $zip->addFromString(basename($source), file_get_contents($source));
142
- }
143
- }
144
- return $zip->close();
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.1/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/readme.txt DELETED
@@ -1,165 +0,0 @@
1
- === WP Backitup Lite ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.1.1
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup Lite creates a backup zip of your site&apos;s content and configuration in just a single click,
17
- right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
18
-
19
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
20
-
21
- = Automatically Restore Your Backup Zips =
22
- Tired of messing around in PHPMyAdmin and with FTP trying to restore you backups? Why not check out <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>? WP Backitup Pro offers all the features of WP Backitup Lite but allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
23
-
24
- = Manually Restore Your Backup Zips =
25
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
26
-
27
- = Easy To Install and Use =
28
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
29
-
30
- = More questions? =
31
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://www.wpbackitup.com/support/" title="WP Backitup Support Forum">WP Backitup Support Forum</a>, if you need more help?
32
-
33
- == Installation ==
34
-
35
- Installation of the plugin is straightforward:
36
-
37
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
38
- 1. Activate the plugin.
39
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
40
- 1. Click 'Backup/Restore' to access WP-Backitup
41
-
42
- == Frequently Asked Questions ==
43
-
44
- = Can I manually restore my backup zips? =
45
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
46
-
47
- = Is there an easier way to restore my backup zips? =
48
- Yes, purchase and download <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
49
-
50
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
51
- Yes.
52
-
53
- = Will WP Backitup work on Windows hosting? =
54
- Yes.
55
-
56
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
57
- It is likely this will feature in a new version of WP Backitup Pro.
58
-
59
- = Can this plugin back to Amazon S3? =
60
- This will feature in an upcoming version of WP Backitup Pro.
61
-
62
- = Is there an auto back up schedule feature? =
63
- It is likely this will feature in a new version of WP Backitup Pro.
64
-
65
- = Will the plugin work with Wordpres version x.x? =
66
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
67
-
68
- = Can this backup one version of WordPress to a different version? =
69
- No. It is absolutely critical that your WordPress versions are exactly the same.
70
-
71
- = Will WP Backitup work on WordPress Multisite? =
72
- WP Backitup cannot yet backup/restore entire networks but it is compatible with WPMS sites.
73
-
74
- = Does the plugin copy the database details as well? =
75
- Yes, a database dump is created with each backup.
76
-
77
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
78
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
79
-
80
- = Does WP Backitup need to be installed? =
81
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
82
-
83
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
84
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
85
-
86
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
87
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
88
-
89
- = Do you do regularly update this product to match with WP version updates? =
90
- Yes.
91
-
92
- == Screenshots ==
93
- 1. Once activated, the plugin loads a new menu into your toolbar.
94
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
95
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
96
-
97
- == Changelog ==
98
-
99
- = 1.1.0 =
100
- * Fixed bugs with addons system.
101
-
102
- = 1.0.9 =
103
- * Added Presstrends tracking code.
104
-
105
- = 1.0.8 =
106
- * Modified plugin administration and loaded menu tab in main toolbar.
107
-
108
- = 1.0.7 =
109
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
110
-
111
- = 1.0.6 =
112
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
113
-
114
- = 1.0.5 =
115
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
116
-
117
- = 1.0.4 =
118
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
119
-
120
- = 1.0.3 =
121
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
122
-
123
- = 1.0.2 =
124
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
125
-
126
- = 1.0.1 =
127
- * Increased PHP timeout to 900 seconds (5 minutes).
128
-
129
- = 1.0 =
130
- * Plugin released.
131
-
132
- == Upgrade Notice ==
133
-
134
- = 1.1.0 =
135
- * Non-critical upgrade. Fixed bugs with addons system that caused problems for some users.
136
-
137
- = 1.0.9 =
138
- * Non-essential upgrade. Added Presstrends code.
139
-
140
- = 1.0.8 =
141
- * Recommended upgrade. Added links to admin menu.
142
-
143
- = 1.0.7 =
144
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
145
-
146
- = 1.0.6 =
147
- * Non-critical upgrade.
148
-
149
- = 1.0.5 =
150
- * Critical upgrade: More stable, increased flexibility and power.
151
-
152
- = 1.0.4 =
153
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
154
-
155
- = 1.0.3 =
156
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
157
-
158
- = 1.0.2 =
159
- * Critical upgrade: Plugin does not work on most systems without this upgrade
160
-
161
- = 1.0.1 =
162
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
163
-
164
- = 1.0 =
165
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.1/screenshots/screenshot-1.png DELETED
Binary file
tags/1.1.1/screenshots/screenshot-2.png DELETED
Binary file
tags/1.1.1/screenshots/screenshot-3.png DELETED
Binary file
tags/1.1.1/wp-backitup.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup Lite
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.1.1
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John Peden Ltd ( email : support@wpbackitup.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", plugins_url('/', (__FILE__)) );
19
- define("WPBACKITUP_PLUGIN_PATH", plugin_dir_path(__FILE__) );
20
- define("WPBACKITUP_DIRNAME", basename(dirname(__FILE__)) );
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'/backups/' );
22
-
23
- //load admin menu
24
- function wpbackitup_admin_menu() {
25
- $wpbackituppage = add_menu_page( __( 'WP Backitup', 'wpBackitup' ), __( 'Backup/Restore', 'wpBackitup' ), 'manage_options', 'wp-backitup', 'wpbackitup_admin', plugin_dir_url(__FILE__ ) .'images/icon.png', 77);
26
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_admin_stylesheet' );
27
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_admin_javascript' );
28
- }
29
- add_action('admin_menu', 'wpbackitup_admin_menu');
30
-
31
- //enqueue stylesheet
32
- function wpbackitup_admin_stylesheet() {
33
- wp_enqueue_style( 'wpBackitupStylesheet', plugins_url('css/admin-style.css',(__FILE__)) );
34
- }
35
-
36
- //enqueue javascript
37
- function wpbackitup_admin_javascript() {
38
- wp_enqueue_script( 'wpBackitupJavascript', plugins_url('js/wp-backitup.js', (__FILE__)) );
39
- }
40
-
41
- //load plugin functions
42
- include_once 'includes/functions.php';
43
-
44
- //load admin page
45
- function wpbackitup_admin() {
46
- include_once('includes/admin_page.php');
47
- }
48
-
49
- //load backup function
50
- function wpbackitup_backup() {
51
- include 'includes/backup.php';
52
- }
53
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
54
-
55
- //load download function
56
- function wpbackitup_download() {
57
- include 'includes/download.php';
58
- }
59
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
60
-
61
- //load download function
62
- function wpbackitup_logreader() {
63
- if(file_exists(BACKUP_PATH .'/status.log') ) {
64
- readfile(BACKUP_PATH .'/status.log');
65
- }
66
- die();
67
- }
68
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
69
-
70
- //load addons
71
- $dir = WPBACKITUP_PLUGIN_PATH . "addons/restore/";
72
- if(is_dir($dir)){
73
- include_once $dir .'index.php';
74
- }
75
-
76
- /**
77
- * PressTrends Plugin API
78
- */
79
- function presstrends_WPBackitup_plugin() {
80
-
81
- // PressTrends Account API Key
82
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
83
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
84
-
85
- // Start of Metrics
86
- global $wpdb;
87
- $data = get_transient( 'presstrends_cache_data' );
88
- if ( !$data || $data == '' ) {
89
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
90
- $url = $api_base . $auth . '/api/' . $api_key . '/';
91
-
92
- $count_posts = wp_count_posts();
93
- $count_pages = wp_count_posts( 'page' );
94
- $comments_count = wp_count_comments();
95
-
96
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
97
- if ( function_exists( 'wp_get_theme' ) ) {
98
- $theme_data = wp_get_theme();
99
- $theme_name = urlencode( $theme_data->Name );
100
- } else {
101
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
102
- $theme_name = $theme_data['Name'];
103
- }
104
-
105
- $plugin_name = '&';
106
- foreach ( get_plugins() as $plugin_info ) {
107
- $plugin_name .= $plugin_info['Name'] . '&';
108
- }
109
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
110
- $plugin_data = get_plugin_data( __FILE__ );
111
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
112
- $data = array(
113
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
114
- 'posts' => $count_posts->publish,
115
- 'pages' => $count_pages->publish,
116
- 'comments' => $comments_count->total_comments,
117
- 'approved' => $comments_count->approved,
118
- 'spam' => $comments_count->spam,
119
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
120
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
121
- 'theme_version' => $plugin_data['Version'],
122
- 'theme_name' => $theme_name,
123
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
124
- 'plugins' => count( get_option( 'active_plugins' ) ),
125
- 'plugin' => urlencode( $plugin_name ),
126
- 'wpversion' => get_bloginfo( 'version' ),
127
- );
128
-
129
- foreach ( $data as $k => $v ) {
130
- $url .= $k . '/' . $v . '/';
131
- }
132
- wp_remote_get( $url );
133
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
134
- }
135
- }
136
-
137
- // PressTrends WordPress Action
138
- add_action('admin_init', 'presstrends_WPBackitup_plugin');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Uploading restoration file...Done!</li><li>Unzipping...Done!</li><li>Validating zip...Done!</li><li>Restoring wp-content directory...Done!</li><li>Restoring database...Done!</li><li>Restoration complete. Please refresh the page.</li></ul>
 
tags/1.1.2/css/admin-style.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/css/wp-backitup.css DELETED
@@ -1,63 +0,0 @@
1
- /* WP Backitup CSS */
2
-
3
- .error { color: #ff0000;}
4
-
5
- p {
6
- line-height: 1.4em;
7
- }
8
-
9
- #content {
10
- float: left;
11
- width: 65%;
12
- }
13
-
14
- #sidebar {
15
- float: right;
16
- width: 30%;
17
- }
18
-
19
- .widget {
20
- padding: 1em;
21
- }
22
-
23
- input {padding: 0;}
24
-
25
- h3 {
26
- margin: 0;
27
- padding: 1em 0 0 0;
28
- }
29
-
30
- ul {padding: 1em 0 0 0;}
31
-
32
- iframe {
33
- height: 0;
34
- margin: 0;
35
- padding: 0;
36
- position: absolute;
37
- top: 0;
38
- right: 0;
39
- width: 0;
40
- }
41
-
42
- .wp-backitup-section {
43
- border-bottom: 1px solid #ddd;
44
- clear:both;
45
- }
46
-
47
- #backup-button, #restore-form {
48
- float: left;
49
- margin: 0 5px 5px 0;
50
- }
51
-
52
- .status-icon {
53
- display: inline;
54
- height: 16px;
55
- visibility: hidden;
56
- width: 16px;
57
- }
58
-
59
- .status-icon img {margin-top: 3px;}
60
-
61
- #restore_form {margin-right: 5px;}
62
-
63
- #restore-button {margin-top: 22px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/images/icon.png DELETED
Binary file
tags/1.1.2/images/icon32.png DELETED
Binary file
tags/1.1.2/images/loader.gif DELETED
Binary file
tags/1.1.2/includes/admin_page.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.2/includes/backup.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- //limite process to 5 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = BACKUP_PATH .$backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(__FILE__)))) .'/';
9
-
10
- //create log file
11
- $log = BACKUP_PATH . "status.log";
12
- $fh = fopen($log, 'w') or die("can't open file");
13
- fwrite($fh, '<ul>');
14
-
15
- //Check to see if the directory is writeable
16
- fwrite($fh, '<li>Creating backup directory...');
17
- if(!is_writeable(BACKUP_PATH)) {
18
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
19
- die();
20
- } else {
21
- //If the directory is writeable, create the backup folder if it doesn't exist
22
- if( !is_dir($backup_project_path) ) {
23
- @mkdir($backup_project_path, 0755);
24
- fwrite($fh, 'Done!</li>');
25
- }
26
- foreach(glob(BACKUP_PATH . "*.zip") as $zip) {
27
- unlink($zip);
28
- }
29
- }
30
-
31
- //Backup content to project dir
32
- fwrite($fh, '<li>Backing up your files...');
33
- //Backup with copy
34
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
35
- fwrite($fh, 'Done!</li>');
36
- } else {
37
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
38
- die();
39
- }
40
-
41
- //Dump DB to project dir
42
- fwrite($fh, '<li>Backing up your database...');
43
- if( db_backup($backup_project_path) ) {
44
- fwrite($fh, 'Done!</li>');
45
- } else {
46
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
47
- recursive_delete($backup_project_path);
48
- die();
49
- }
50
-
51
- //Create siteinfo in project dir
52
- global $wpdb;
53
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
54
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
55
- recursive_delete($backup_project_path);
56
- die();
57
- }
58
-
59
- //Zip the project dir
60
- fwrite($fh, '<li>Creating backup zip...');
61
- require(WPBACKITUP_PLUGIN_PATH .'includes/recurse_zip.php');
62
- $z = new recurseZip();
63
- $src = rtrim($backup_project_path, '/');
64
- $z->compress($src, BACKUP_PATH);
65
- fwrite($fh, 'Done!</li>');
66
-
67
- //Delete backup dir
68
- if(!recursive_delete($backup_project_path)) {
69
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
70
- }
71
-
72
- //close log file
73
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
74
- fwrite($fh, '</ul>');
75
- fclose($fh);
76
-
77
- //End backup function
78
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/includes/download.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //Define variables
3
- $wp_backitup_path = dirname(dirname(__FILE__));
4
- $wp_content_dirname = basename(dirname(dirname(dirname(dirname(__FILE__)))));
5
- $wp_backitup_dirname = basename($wp_backitup_path);
6
-
7
- //build download link
8
- if(glob($wp_backitup_path . "/backups/*.zip")) {
9
- echo '<ul>';
10
- foreach (glob($wp_backitup_path . "/backups/*.zip") as $file) {
11
- $filename = basename($file);
12
- echo '<li>Download most recent export file: <a href="' .site_url() .'/' .$wp_content_dirname .'/' .'plugins/' .$wp_backitup_dirname. '/backups/' .$filename .'">' .$filename .'</a></li>';
13
- }
14
- echo '</ul>';
15
- } else {
16
- echo '<p>No export file available for download. Please create one.</p>';
17
- }
18
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/includes/functions.php DELETED
@@ -1,145 +0,0 @@
1
- <?php //Define the create_dir function
2
- if(!function_exists('create_dir')) {
3
- function create_dir($dir) {
4
- if( !is_dir($dir) ) {
5
- @mkdir($dir, 0755);
6
- }
7
- return true;
8
- }
9
- }
10
-
11
- //Define recusive_copy function
12
- if(!function_exists('recursive_copy')) {
13
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
14
- if( is_dir($dir) ) { //If the directory exists
15
- if ($dh = opendir($dir) ) {
16
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
17
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
18
- if (!is_dir( $dir.$file ) ) {
19
- //Copy files to destination directory
20
- $fsrc = fopen($dir .$file,'r');
21
- $fdest = fopen($target_path .$file,'w+');
22
- $len = stream_copy_to_stream($fsrc,$fdest);
23
- fclose($fsrc);
24
- fclose($fdest);
25
- } else { //If $file is a directory
26
- $destdir = $target_path .$file; //Modify the destination dir
27
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
28
- @mkdir($destdir, 0755);
29
- }
30
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
31
- }
32
- }
33
- }
34
- closedir($dh);
35
- }
36
- }
37
- return true;
38
- }
39
- }
40
-
41
- //Define DB backup function
42
- if(!function_exists('db_backup')) {
43
- function db_backup($path) {
44
- global $wpdb;
45
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
46
- $tables = array();
47
- foreach($row as $value) {
48
- $tables[] = $value[0];
49
- }
50
- $handle = fopen($path .'db-backup.sql', 'w+');
51
- foreach($tables as $table) {
52
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
53
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
54
- $num_fields=count($testing);
55
- $return = '';
56
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
57
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
58
- $return.= "\n\n".$row2[1].";\n\n";
59
- foreach($result as $row) {
60
- $return.= 'INSERT INTO '.$table.' VALUES(';
61
- for($j=0; $j<$num_fields; $j++) {
62
- $row[$j] = addslashes($row[$j]);
63
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
64
- if (isset($row[$j])) {
65
- $return .= '"' .$row[$j] .'"';
66
- } else {
67
- $return .= '"';
68
- }
69
- if ($j<($num_fields-1)) { $return.= ', '; }
70
- }
71
- $return.= ");\n";
72
- }
73
- $return.="\n\n\n";
74
- fwrite($handle, $return);
75
- }
76
- fclose($handle);
77
- return true;
78
- }
79
- }
80
-
81
- //Define the create_siteinfo function
82
- if(!function_exists('create_siteinfo')) {
83
- function create_siteinfo($path, $table_prefix) {
84
- $siteinfo = $path ."backupsiteinfo.txt";
85
- $handle = fopen($siteinfo, 'w+');
86
- $entry = site_url( '/' ) ."\n$table_prefix";
87
- fwrite($handle, $entry);
88
- fclose($handle);
89
- return true;
90
- }
91
- }
92
-
93
- //Define recursive_delete function
94
- if(!function_exists('recursive_delete')){
95
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
96
- if( is_dir($dir) ){
97
- if($dh = opendir($dir)) {
98
- while( ($file = readdir($dh)) !== false ) {
99
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
100
- if(!is_dir($dir .'/'. $file)) {
101
- unlink($dir .'/'. $file);
102
- } else {
103
- recursive_delete($dir.'/'. $file, $ignore);
104
- }
105
- }
106
- }
107
- }
108
- @rmdir($dir);
109
- closedir($dh);
110
- }
111
- return true;
112
- }
113
- }
114
-
115
- //Define zip function
116
- function zip($source, $destination, $ignore) {
117
- if (is_string($source)) $source_arr = array($source); // convert it to array
118
- if (!extension_loaded('zip')) {
119
- return false;
120
- }
121
- $zip = new ZipArchive();
122
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
123
- return false;
124
- }
125
- foreach ($source_arr as $source) {
126
- if (!file_exists($source)) continue;
127
- $source = str_replace('\\', '/', realpath($source));
128
- if (is_dir($source) === true) {
129
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
130
- foreach ($files as $file) {
131
- if (!preg_match($ignore, $file)) {
132
- $file = str_replace('\\', '/', realpath($file));
133
- if (is_dir($file) === true) {
134
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
135
- } else if (is_file($file) === true) {
136
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
137
- }
138
- }
139
- }
140
- } else if (is_file($source) === true) {
141
- $zip->addFromString(basename($source), file_get_contents($source));
142
- }
143
- }
144
- return $zip->close();
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/includes/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.2/js/wp-backitup.js DELETED
@@ -1,69 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- //define backup variables
4
- var wpBackitupBackup = {
5
- action: 'wpbackitup_backup',
6
- beforeSend: function() {
7
- $('#wp-backitup-backup .status-icon').css('visibility','visible');
8
- $("#wp-backitup-status").empty();
9
- setInterval(logreader, 1000);
10
- }
11
- };
12
-
13
- //define download variables
14
- var wpBackitupDownload = {
15
- action: 'wpbackitup_download'
16
- };
17
-
18
- //define logreader variables
19
- var wpBackitupLogReader = {
20
- action: 'wpbackitup_logreader'
21
- };
22
-
23
- //define logreader function
24
- function logreader() {
25
- $.post(ajaxurl, wpBackitupLogReader, function(response) {
26
- $("#wp-backitup-status").html(response);
27
- });
28
- }
29
-
30
- //define download function
31
- function download() {
32
- $.post(ajaxurl, wpBackitupDownload, function(response) {
33
- $("#wp-backitup-download-status").html(response);
34
- });
35
- }
36
-
37
- //execute download (on page load/refresh)
38
- download();
39
-
40
- //execute backup on button click
41
- $("#wpBackitupBackup").click( function() {
42
- $.post(ajaxurl, wpBackitupBackup, function(response) {
43
- download(); //Build download link
44
- clearInterval(logreader); //Stop checking for status updates
45
- $('#wp-backitup-backup .status-icon').fadeOut(1000); //Fade process indicator
46
- $("#wp-backitup-php").html(response); //Return PHP messages, used for development
47
- });
48
- })
49
-
50
- //execture restore on button click
51
- $("#restore-form").submit(function() {
52
- $('#wp-backitup-restore .status-icon').css('visibility','visible'); //display process icon
53
- $("#wp-backitup-status").empty(); //clear status messages
54
- setInterval(logreader, 1000); //check for status updates every second
55
- $("#restore-form").attr("target","upload_target"); //specify target for form submission
56
- $("#upload_target").load(function (){
57
- importRestore(); //on iframe load, run restore function
58
- });
59
- });
60
-
61
- //define importRestore function
62
- function importRestore() {
63
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
64
- $("#wp-backitup-php").html(ret); //Return PHP messages, used for development
65
- download(); //Create download link
66
- clearInterval(logreader); //Stop checking for status messages
67
- $('#wp-backitup-restore .status-icon').fadeOut(1000); //hide process icon
68
- }
69
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/readme.txt DELETED
@@ -1,165 +0,0 @@
1
- === WP Backitup Lite ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.1.2
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup Lite creates a backup zip of your site&apos;s content and configuration in just a single click,
17
- right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
18
-
19
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
20
-
21
- = Automatically Restore Your Backup Zips =
22
- Tired of messing around in PHPMyAdmin and with FTP trying to restore you backups? Why not check out <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>? WP Backitup Pro offers all the features of WP Backitup Lite but allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
23
-
24
- = Manually Restore Your Backup Zips =
25
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
26
-
27
- = Easy To Install and Use =
28
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
29
-
30
- = More questions? =
31
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://www.wpbackitup.com/support/" title="WP Backitup Support Forum">WP Backitup Support Forum</a>, if you need more help?
32
-
33
- == Installation ==
34
-
35
- Installation of the plugin is straightforward:
36
-
37
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
38
- 1. Activate the plugin.
39
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
40
- 1. Click 'Backup/Restore' to access WP-Backitup
41
-
42
- == Frequently Asked Questions ==
43
-
44
- = Can I manually restore my backup zips? =
45
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
46
-
47
- = Is there an easier way to restore my backup zips? =
48
- Yes, purchase and download <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
49
-
50
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
51
- Yes.
52
-
53
- = Will WP Backitup work on Windows hosting? =
54
- Yes.
55
-
56
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
57
- It is likely this will feature in a new version of WP Backitup Pro.
58
-
59
- = Can this plugin back to Amazon S3? =
60
- This will feature in an upcoming version of WP Backitup Pro.
61
-
62
- = Is there an auto back up schedule feature? =
63
- It is likely this will feature in a new version of WP Backitup Pro.
64
-
65
- = Will the plugin work with Wordpres version x.x? =
66
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
67
-
68
- = Can this backup one version of WordPress to a different version? =
69
- No. It is absolutely critical that your WordPress versions are exactly the same.
70
-
71
- = Will WP Backitup work on WordPress Multisite? =
72
- WP Backitup cannot yet backup/restore entire networks but it is compatible with WPMS sites.
73
-
74
- = Does the plugin copy the database details as well? =
75
- Yes, a database dump is created with each backup.
76
-
77
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
78
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
79
-
80
- = Does WP Backitup need to be installed? =
81
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
82
-
83
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
84
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
85
-
86
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
87
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
88
-
89
- = Do you do regularly update this product to match with WP version updates? =
90
- Yes.
91
-
92
- == Screenshots ==
93
- 1. Once activated, the plugin loads a new menu into your toolbar.
94
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
95
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
96
-
97
- == Changelog ==
98
-
99
- = 1.1.0 =
100
- * Fixed bugs with addons system.
101
-
102
- = 1.0.9 =
103
- * Added Presstrends tracking code.
104
-
105
- = 1.0.8 =
106
- * Modified plugin administration and loaded menu tab in main toolbar.
107
-
108
- = 1.0.7 =
109
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
110
-
111
- = 1.0.6 =
112
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
113
-
114
- = 1.0.5 =
115
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
116
-
117
- = 1.0.4 =
118
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
119
-
120
- = 1.0.3 =
121
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
122
-
123
- = 1.0.2 =
124
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
125
-
126
- = 1.0.1 =
127
- * Increased PHP timeout to 900 seconds (5 minutes).
128
-
129
- = 1.0 =
130
- * Plugin released.
131
-
132
- == Upgrade Notice ==
133
-
134
- = 1.1.0 =
135
- * Non-critical upgrade. Fixed bugs with addons system that caused problems for some users.
136
-
137
- = 1.0.9 =
138
- * Non-essential upgrade. Added Presstrends code.
139
-
140
- = 1.0.8 =
141
- * Recommended upgrade. Added links to admin menu.
142
-
143
- = 1.0.7 =
144
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
145
-
146
- = 1.0.6 =
147
- * Non-critical upgrade.
148
-
149
- = 1.0.5 =
150
- * Critical upgrade: More stable, increased flexibility and power.
151
-
152
- = 1.0.4 =
153
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
154
-
155
- = 1.0.3 =
156
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
157
-
158
- = 1.0.2 =
159
- * Critical upgrade: Plugin does not work on most systems without this upgrade
160
-
161
- = 1.0.1 =
162
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
163
-
164
- = 1.0 =
165
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.2/screenshots/screenshot-1.png DELETED
Binary file
tags/1.1.2/screenshots/screenshot-2.png DELETED
Binary file
tags/1.1.2/screenshots/screenshot-3.png DELETED
Binary file
tags/1.1.2/wp-backitup.php DELETED
@@ -1,138 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: WP Backitup Lite
4
- * Plugin URI: http://www.wpbackitup.com
5
- * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
6
- * Version: 1.1.2
7
- * Author: John Peden
8
- * Author URI: http://www.johncpeden.com
9
- * License: GPLv2 or later
10
- * Text Domain: wp-backitup
11
- */
12
-
13
- /*
14
- Copyright 2012-current John Peden Ltd ( email : support@wpbackitup.com )
15
- */
16
-
17
- //define constants
18
- define("WPBACKITUP_PLUGIN_URL", plugins_url('/', (__FILE__)) );
19
- define("WPBACKITUP_PLUGIN_PATH", plugin_dir_path(__FILE__) );
20
- define("WPBACKITUP_DIRNAME", basename(dirname(__FILE__)) );
21
- define("BACKUP_PATH", WPBACKITUP_PLUGIN_PATH .'/backups/' );
22
-
23
- //load admin menu
24
- function wpbackitup_admin_menu() {
25
- $wpbackituppage = add_menu_page( __( 'WP Backitup', 'wpBackitup' ), __( 'Backup/Restore', 'wpBackitup' ), 'manage_options', 'wp-backitup', 'wpbackitup_admin', plugin_dir_url(__FILE__ ) .'images/icon.png', 77);
26
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_admin_stylesheet' );
27
- add_action('admin_print_styles-' .$wpbackituppage, 'wpbackitup_admin_javascript' );
28
- }
29
- add_action('admin_menu', 'wpbackitup_admin_menu');
30
-
31
- //enqueue stylesheet
32
- function wpbackitup_admin_stylesheet() {
33
- wp_enqueue_style( 'wpBackitupStylesheet', plugins_url('css/admin-style.css',(__FILE__)) );
34
- }
35
-
36
- //enqueue javascript
37
- function wpbackitup_admin_javascript() {
38
- wp_enqueue_script( 'wpBackitupJavascript', plugins_url('js/wp-backitup.js', (__FILE__)) );
39
- }
40
-
41
- //load plugin functions
42
- include_once 'includes/functions.php';
43
-
44
- //load admin page
45
- function wpbackitup_admin() {
46
- include_once('includes/admin_page.php');
47
- }
48
-
49
- //load backup function
50
- function wpbackitup_backup() {
51
- include 'includes/backup.php';
52
- }
53
- add_action('wp_ajax_wpbackitup_backup', 'wpbackitup_backup');
54
-
55
- //load download function
56
- function wpbackitup_download() {
57
- include 'includes/download.php';
58
- }
59
- add_action('wp_ajax_wpbackitup_download', 'wpbackitup_download');
60
-
61
- //load download function
62
- function wpbackitup_logreader() {
63
- if(file_exists(BACKUP_PATH .'/status.log') ) {
64
- readfile(BACKUP_PATH .'/status.log');
65
- }
66
- die();
67
- }
68
- add_action('wp_ajax_wpbackitup_logreader', 'wpbackitup_logreader');
69
-
70
- //load addons
71
- $dir = WPBACKITUP_PLUGIN_PATH . "addons/restore/";
72
- if(is_dir($dir)){
73
- include_once $dir .'index.php';
74
- }
75
-
76
- /**
77
- * PressTrends Plugin API
78
- */
79
- function presstrends_WPBackitup_plugin() {
80
-
81
- // PressTrends Account API Key
82
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
83
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
84
-
85
- // Start of Metrics
86
- global $wpdb;
87
- $data = get_transient( 'presstrends_cache_data' );
88
- if ( !$data || $data == '' ) {
89
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
90
- $url = $api_base . $auth . '/api/' . $api_key . '/';
91
-
92
- $count_posts = wp_count_posts();
93
- $count_pages = wp_count_posts( 'page' );
94
- $comments_count = wp_count_comments();
95
-
96
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
97
- if ( function_exists( 'wp_get_theme' ) ) {
98
- $theme_data = wp_get_theme();
99
- $theme_name = urlencode( $theme_data->Name );
100
- } else {
101
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
102
- $theme_name = $theme_data['Name'];
103
- }
104
-
105
- $plugin_name = '&';
106
- foreach ( get_plugins() as $plugin_info ) {
107
- $plugin_name .= $plugin_info['Name'] . '&';
108
- }
109
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
110
- $plugin_data = get_plugin_data( __FILE__ );
111
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
112
- $data = array(
113
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
114
- 'posts' => $count_posts->publish,
115
- 'pages' => $count_pages->publish,
116
- 'comments' => $comments_count->total_comments,
117
- 'approved' => $comments_count->approved,
118
- 'spam' => $comments_count->spam,
119
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
120
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
121
- 'theme_version' => $plugin_data['Version'],
122
- 'theme_name' => $theme_name,
123
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
124
- 'plugins' => count( get_option( 'active_plugins' ) ),
125
- 'plugin' => urlencode( $plugin_name ),
126
- 'wpversion' => get_bloginfo( 'version' ),
127
- );
128
-
129
- foreach ( $data as $k => $v ) {
130
- $url .= $k . '/' . $v . '/';
131
- }
132
- wp_remote_get( $url );
133
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
134
- }
135
- }
136
-
137
- // PressTrends WordPress Action
138
- add_action('admin_init', 'presstrends_WPBackitup_plugin');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/backups/WP Backitup-Export-2013-02-13-0921.zip DELETED
Binary file
tags/1.1.4/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.1.4/css/admin.css DELETED
@@ -1,59 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel Stylesheets
3
- *
4
- * @version 1.1.4
5
- * @since 1.1.4
6
- */
7
-
8
- /* Global */
9
- .error { color: #ff0000;}
10
-
11
- p {line-height: 1.4em;}
12
-
13
- ul {padding: 1em 0 0 0;}
14
-
15
- h3 {
16
- margin: 0;
17
- padding: 1em 0 0 0;
18
- }
19
-
20
- iframe {
21
- height: 0;
22
- margin: 0;
23
- padding: 0;
24
- position: absolute;
25
- top: 0;
26
- right: 0;
27
- width: 0;
28
- z-index: -10;
29
- }
30
-
31
- .submit {
32
- padding: 0;
33
- }
34
-
35
- /* Content */
36
- #content {
37
- float: left;
38
- width: 65%;
39
- }
40
-
41
- #content input[type="text"], #content input[type="file"] {padding: 0;}
42
-
43
- .status-icon {
44
- display: inline;
45
- height: 16px;
46
- position: relative;
47
- top: 3px;
48
- left: 5px;
49
- visibility: hidden;
50
- width: 16px;
51
- }
52
-
53
- /* Sidebar */
54
- #sidebar {
55
- float: right;
56
- width: 30%;
57
- }
58
-
59
- .widget {padding: 1em;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/images/icon.png DELETED
Binary file
tags/1.1.4/images/icon32.png DELETED
Binary file
tags/1.1.4/images/loader.gif DELETED
Binary file
tags/1.1.4/index.php DELETED
@@ -1,342 +0,0 @@
1
- <?php
2
- /**
3
- * WP Backitup Lite
4
- *
5
- * @package WPBackitup Lite
6
- *
7
- * @global object $wpdb
8
- *
9
- * @author jcpeden
10
- * @version 1.1.4
11
- */
12
- /*
13
- Plugin Name: WP Backitup Lite
14
- Plugin URI: http://www.wpbackitup.com
15
- Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
- Version: 1.1.4
17
- Author: John Peden
18
- Author URI: http://www.johncpeden.com
19
- License: GPL3
20
-
21
- Copyright 2012-2013 John Peden (email : support@wpbackitup.com)
22
-
23
- This program is free software: you can redistribute it and/or modify
24
- it under the terms of the GNU General Public License as published by
25
- the Free Software Foundation, either version 3 of the License, or
26
- (at your option) any later version.
27
-
28
- This program is distributed in the hope that it will be useful,
29
- but WITHOUT ANY WARRANTY; without even the implied warranty of
30
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
- GNU General Public License for more details.
32
-
33
- You should have received a copy of the GNU General Public License
34
- along with this program. If not, see <http://www.gnu.org/licenses/>.
35
- */
36
-
37
- // Include constants file
38
- require_once( dirname( __FILE__ ) . '/lib/constants.php' );
39
-
40
- class WPBackitup {
41
- var $namespace = "wp-backitup-lite";
42
- var $friendly_name = "WP Backitup Lite";
43
- var $version = "1.1.3";
44
-
45
- // Default plugin options
46
- var $defaults = array(
47
- 'presstrends' => "enabled"
48
- );
49
-
50
- /**
51
- * Instantiation construction
52
- *
53
- * @uses add_action()
54
- * @uses WPBackitup::wp_register_scripts()
55
- * @uses WPBackitup::wp_register_styles()
56
- */
57
- function __construct() {
58
- // Name of the option_value to store plugin options in
59
- $this->option_name = '_' . $this->namespace . '--options';
60
-
61
- // Load all library files used by this plugin
62
- $libs = glob( WPBACKITUP_DIRNAME . '/lib/*.php' );
63
- foreach( $libs as $lib ) {
64
- include_once( $lib );
65
- }
66
-
67
- /**
68
- * Make this plugin available for translation.
69
- * Translations can be added to the /languages/ directory.
70
- */
71
- load_theme_textdomain( $this->namespace, WPBACKITUP_DIRNAME . '/languages' );
72
-
73
- // Add all action, filter and shortcode hooks
74
- $this->_add_hooks();
75
- }
76
-
77
- /**
78
- * Add in various hooks
79
- *
80
- * Place all add_action, add_filter, add_shortcode hook-ins here
81
- */
82
- private function _add_hooks() {
83
- // Options page for configuration
84
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
85
- // Route requests for form processing
86
- add_action( 'init', array( &$this, 'route' ) );
87
-
88
- // Add a settings link next to the "Deactivate" link on the plugin listing page
89
- add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
90
-
91
- // Register all JavaScripts for this plugin
92
- add_action( 'init', array( &$this, 'wp_register_scripts' ), 1 );
93
- // Register all Stylesheets for this plugin
94
- add_action( 'init', array( &$this, 'wp_register_styles' ), 1 );
95
- }
96
-
97
- /**
98
- * Process update page form submissions
99
- *
100
- * @uses WPBackitup::sanitize()
101
- * @uses wp_redirect()
102
- * @uses wp_verify_nonce()
103
- */
104
- private function _admin_options_update() {
105
- // Verify submission for processing using wp_nonce
106
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
107
- $data = array();
108
- /**
109
- * Loop through each POSTed value and sanitize it to protect against malicious code. Please
110
- * note that rich text (or full HTML fields) should not be processed by this function and
111
- * dealt with directly.
112
- */
113
- foreach( $_POST['data'] as $key => $val ) {
114
- $data[$key] = $this->_sanitize( $val );
115
- }
116
-
117
- /**
118
- * Place your options processing and storage code here
119
- */
120
-
121
- // Update the options value with the data submitted
122
- update_option( $this->option_name, $data );
123
-
124
- // Redirect back to the options page with the message flag to show the saved message
125
- wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&message=1' );
126
- exit;
127
- }
128
- }
129
-
130
- /**
131
- * Sanitize data
132
- *
133
- * @param mixed $str The data to be sanitized
134
- *
135
- * @uses wp_kses()
136
- *
137
- * @return mixed The sanitized version of the data
138
- */
139
- private function _sanitize( $str ) {
140
- if ( !function_exists( 'wp_kses' ) ) {
141
- require_once( ABSPATH . 'wp-includes/kses.php' );
142
- }
143
- global $allowedposttags;
144
- global $allowedprotocols;
145
-
146
- if ( is_string( $str ) ) {
147
- $str = wp_kses( $str, $allowedposttags, $allowedprotocols );
148
- } elseif( is_array( $str ) ) {
149
- $arr = array();
150
- foreach( (array) $str as $key => $val ) {
151
- $arr[$key] = $this->_sanitize( $val );
152
- }
153
- $str = $arr;
154
- }
155
-
156
- return $str;
157
- }
158
-
159
- /**
160
- * Hook into register_activation_hook action
161
- *
162
- * Put code here that needs to happen when your plugin is first activated (database
163
- * creation, permalink additions, etc.)
164
- */
165
- static function activate() {
166
- // Do activation actions
167
- }
168
-
169
- /**
170
- * Define the admin menu options for this plugin
171
- *
172
- * @uses add_action()
173
- * @uses add_options_page()
174
- */
175
- function admin_menu() {
176
- $page_hook = add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_options_page' ), WPBACKITUP_URLPATH .'/images/icon.png', 77);
177
-
178
- // Add print scripts and styles action based off the option page hook
179
- add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'admin_print_scripts' ) );
180
- add_action( 'admin_print_styles-' . $page_hook, array( &$this, 'admin_print_styles' ) );
181
- }
182
-
183
-
184
- /**
185
- * The admin section options page rendering method
186
- *
187
- * @uses current_user_can()
188
- * @uses wp_die()
189
- */
190
- function admin_options_page() {
191
- if( !current_user_can( 'manage_options' ) ) {
192
- wp_die( 'You do not have sufficient permissions to access this page' );
193
- }
194
-
195
- $page_title = $this->friendly_name . ' Options';
196
- $namespace = $this->namespace;
197
-
198
- include( WPBACKITUP_DIRNAME . "/views/options.php" );
199
- }
200
-
201
- /**
202
- * Load JavaScript for the admin options page
203
- *
204
- * @uses wp_enqueue_script()
205
- */
206
- function admin_print_scripts() {
207
- wp_enqueue_script( "{$this->namespace}-admin" );
208
- }
209
-
210
- /**
211
- * Load Stylesheet for the admin options page
212
- *
213
- * @uses wp_enqueue_style()
214
- */
215
- function admin_print_styles() {
216
- wp_enqueue_style( "{$this->namespace}-admin" );
217
- }
218
-
219
- /**
220
- * Hook into register_deactivation_hook action
221
- *
222
- * Put code here that needs to happen when your plugin is deactivated
223
- */
224
- static function deactivate() {
225
- // Do deactivation actions
226
- }
227
-
228
- /**
229
- * Retrieve the stored plugin option or the default if no user specified value is defined
230
- *
231
- * @param string $option_name The name of the TrialAccount option you wish to retrieve
232
- *
233
- * @uses get_option()
234
- *
235
- * @return mixed Returns the option value or false(boolean) if the option is not found
236
- */
237
- function get_option( $option_name ) {
238
- // Load option values if they haven't been loaded already
239
- if( !isset( $this->options ) || empty( $this->options ) ) {
240
- $this->options = get_option( $this->option_name, $this->defaults );
241
- }
242
-
243
- if( isset( $this->options[$option_name] ) ) {
244
- return $this->options[$option_name]; // Return user's specified option value
245
- } elseif( isset( $this->defaults[$option_name] ) ) {
246
- return $this->defaults[$option_name]; // Return default option value
247
- }
248
- return false;
249
- }
250
-
251
- /**
252
- * Initialization function to hook into the WordPress init action
253
- *
254
- * Instantiates the class on a global variable and sets the class, actions
255
- * etc. up for use.
256
- */
257
- static function instance() {
258
- global $WPBackitup;
259
-
260
- // Only instantiate the Class if it hasn't been already
261
- if( !isset( $WPBackitup ) ) $WPBackitup = new WPBackitup();
262
- }
263
-
264
- /**
265
- * Hook into plugin_action_links filter
266
- *
267
- * Adds a "Settings" link next to the "Deactivate" link in the plugin listing page
268
- * when the plugin is active.
269
- *
270
- * @param object $links An array of the links to show, this will be the modified variable
271
- * @param string $file The name of the file being processed in the filter
272
- */
273
- function plugin_action_links( $links, $file ) {
274
- if( $file == plugin_basename( WPBACKITUP_DIRNAME . '/' . basename( __FILE__ ) ) ) {
275
- $old_links = $links;
276
- $new_links = array(
277
- "settings" => '<a href="options-general.php?page=' . $this->namespace . '">' . __( 'Settings' ) . '</a>'
278
- );
279
- $links = array_merge( $new_links, $old_links );
280
- }
281
-
282
- return $links;
283
- }
284
-
285
- /**
286
- * Route the user based off of environment conditions
287
- *
288
- * This function will handling routing of form submissions to the appropriate
289
- * form processor.
290
- *
291
- * @uses WPBackitup::_admin_options_update()
292
- */
293
- function route() {
294
- $uri = $_SERVER['REQUEST_URI'];
295
- $protocol = isset( $_SERVER['HTTPS'] ) ? 'https' : 'http';
296
- $hostname = $_SERVER['HTTP_HOST'];
297
- $url = "{$protocol}://{$hostname}{$uri}";
298
- $is_post = (bool) ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == "POST" );
299
-
300
- // Check if a nonce was passed in the request
301
- if( isset( $_REQUEST['_wpnonce'] ) ) {
302
- $nonce = $_REQUEST['_wpnonce'];
303
-
304
- // Handle POST requests
305
- if( $is_post ) {
306
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
307
- $this->_admin_options_update();
308
- }
309
- }
310
- // Handle GET requests
311
- else {
312
-
313
- }
314
- }
315
- }
316
-
317
- /**
318
- * Register scripts used by this plugin for enqueuing elsewhere
319
- *
320
- * @uses wp_register_script()
321
- */
322
- function wp_register_scripts() {
323
- // Admin JavaScript
324
- wp_register_script( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/js/admin.js", array( 'jquery' ), $this->version, true );
325
- }
326
-
327
- /**
328
- * Register styles used by this plugin for enqueuing elsewhere
329
- *
330
- * @uses wp_register_style()
331
- */
332
- function wp_register_styles() {
333
- // Admin Stylesheet
334
- wp_register_style( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/css/admin.css", array(), $this->version, 'screen' );
335
- }
336
- }
337
- if( !isset( $WPBackitup ) ) {
338
- WPBackitup::instance();
339
- }
340
-
341
- register_activation_hook( __FILE__, array( 'WPBackitup', 'activate' ) );
342
- register_deactivation_hook( __FILE__, array( 'WPBackitup', 'deactivate' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/js/admin.js DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel JavaScripts
3
- *
4
- * @version 1.1.4
5
- * @since 1.1.4
6
- */
7
-
8
- (function($){
9
- //define backup variables
10
- var backup = {
11
- action: 'backup',
12
- beforeSend: function() {
13
- $('.backup-icon').css('visibility','visible');
14
- $("#status").empty();
15
- setInterval(display_log, 1000);
16
- }
17
- };
18
- //define download variables
19
- var download = {
20
- action: 'download'
21
- };
22
- //define logreader variables
23
- var logreader = {
24
- action: 'logreader'
25
- };
26
- //define logreader function
27
- function display_log() {
28
- $.post(ajaxurl, logreader, function(response) {
29
- $("#status").html(response);
30
- });
31
- }
32
- //define download function
33
- function download_link() {
34
- $.post(ajaxurl, download, function(response) {
35
- $("#download-link").html(response);
36
- });
37
- }
38
-
39
- //execute download (on page load/refresh)
40
- download_link();
41
-
42
- //execute backup on button click
43
- $(".backup-button").click( function() {
44
- $.post(ajaxurl, backup, function(response) {
45
- download_link();
46
- clearInterval(display_log);
47
- $('.backup-icon').fadeOut(1000);
48
- $("#php").html(response); //Return PHP messages, used for development
49
- });
50
- })
51
- //execute restore on button click
52
- $("#restore-form").submit(function() {
53
- $('.restore-icon').css('visibility','visible');
54
- $("#status").empty();
55
- setInterval(display_log, 1000);
56
- $("#restore-form").attr("target","upload_target");
57
- $("#upload_target").load(function (){
58
- importRestore();
59
- });
60
- });
61
-
62
- //define importRestore function
63
- function importRestore() {
64
- var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML; //process upload
65
- $("#php").html(ret); //Return PHP messages, used for development
66
- clearInterval(display_log);
67
- $('.restore-icon').fadeOut(1000);
68
- }
69
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/lib/constants.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /**
3
- * Constants used by this plugin
4
- *
5
- * @package WPBackitup
6
- *
7
- * @author jcpeden
8
- * @version 1.1.4
9
- * @since 1.1.3
10
- */
11
-
12
- // The current version of this plugin
13
- if( !defined( 'WPBACKITUP_VERSION' ) ) define( 'WPBACKITUP_VERSION', '1.1.3' );
14
-
15
- // The directory the plugin resides in
16
- if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
17
-
18
- // The URL path of this plugin
19
- if( !defined( 'WPBACKITUP_URLPATH' ) ) define( 'WPBACKITUP_URLPATH', WP_PLUGIN_URL . "/" . plugin_basename( WPBACKITUP_DIRNAME ) );
20
-
21
- if( !defined( 'IS_AJAX_REQUEST' ) ) define( 'IS_AJAX_REQUEST', ( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/lib/functions.php DELETED
@@ -1,251 +0,0 @@
1
- <?php
2
- /**
3
- * WP Backitup Functions
4
- *
5
- * @package WP Backitup Lite
6
- *
7
- * @author jcpeden
8
- * @version 1.1.4
9
- * @since 1.1.3
10
- */
11
-
12
- //load backup function
13
- function backup() {
14
- include_once 'includes/backup.php';
15
- }
16
- add_action('wp_ajax_backup', 'backup');
17
-
18
- //load download function
19
- function download() {
20
- if(glob(WPBACKITUP_DIRNAME . "/backups/*.zip")) {
21
- echo '<ul>';
22
- foreach (glob(WPBACKITUP_DIRNAME . "/backups/*.zip") as $file) {
23
- $filename = basename($file);
24
- echo '<li>Download most recent export file: <a href="' .WPBACKITUP_URLPATH. '/backups/' .$filename .'">' .$filename .'</a></li>';
25
- }
26
- echo '</ul>';
27
- } else {
28
- echo '<p>No export file available for download. Please create one.</p>';
29
- }
30
- die();
31
- }
32
- add_action('wp_ajax_download', 'download');
33
-
34
- //load logreader function
35
- function logreader() {
36
- $log = WPBACKITUP_DIRNAME .'/backups/status.log';
37
- if(file_exists($log) ) {
38
- readfile($log);
39
- }
40
- die();
41
- }
42
- add_action('wp_ajax_logreader', 'logreader');
43
-
44
- //define create_dir function
45
- if(!function_exists('create_dir')) {
46
- function create_dir($dir) {
47
- if( !is_dir($dir) ) {
48
- @mkdir($dir, 0755);
49
- }
50
- return true;
51
- }
52
- }
53
-
54
- //Define recusive_copy function
55
- if(!function_exists('recursive_copy')) {
56
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
57
- if( is_dir($dir) ) { //If the directory exists
58
- if ($dh = opendir($dir) ) {
59
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
60
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
61
- if (!is_dir( $dir.$file ) ) {
62
- //Copy files to destination directory
63
- $fsrc = fopen($dir .$file,'r');
64
- $fdest = fopen($target_path .$file,'w+');
65
- $len = stream_copy_to_stream($fsrc,$fdest);
66
- fclose($fsrc);
67
- fclose($fdest);
68
- } else { //If $file is a directory
69
- $destdir = $target_path .$file; //Modify the destination dir
70
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
71
- @mkdir($destdir, 0755);
72
- }
73
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
74
- }
75
- }
76
- }
77
- closedir($dh);
78
- }
79
- }
80
- return true;
81
- }
82
- }
83
-
84
- //Define DB backup function
85
- if(!function_exists('db_backup')) {
86
- function db_backup($path) {
87
- global $wpdb;
88
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
89
- $tables = array();
90
- foreach($row as $value) {
91
- $tables[] = $value[0];
92
- }
93
- $handle = fopen($path .'db-backup.sql', 'w+');
94
- foreach($tables as $table) {
95
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
96
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
97
- $num_fields=count($testing);
98
- $return = '';
99
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
100
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
101
- $return.= "\n\n".$row2[1].";\n\n";
102
- foreach($result as $row) {
103
- $return.= 'INSERT INTO '.$table.' VALUES(';
104
- for($j=0; $j<$num_fields; $j++) {
105
- $row[$j] = addslashes($row[$j]);
106
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
107
- if (isset($row[$j])) {
108
- $return .= '"' .$row[$j] .'"';
109
- } else {
110
- $return .= '"';
111
- }
112
- if ($j<($num_fields-1)) { $return.= ', '; }
113
- }
114
- $return.= ");\n";
115
- }
116
- $return.="\n\n\n";
117
- fwrite($handle, $return);
118
- }
119
- fclose($handle);
120
- return true;
121
- }
122
- }
123
-
124
- //Define the create_siteinfo function
125
- if(!function_exists('create_siteinfo')) {
126
- function create_siteinfo($path, $table_prefix) {
127
- $siteinfo = $path ."backupsiteinfo.txt";
128
- $handle = fopen($siteinfo, 'w+');
129
- $entry = site_url( '/' ) ."\n$table_prefix";
130
- fwrite($handle, $entry);
131
- fclose($handle);
132
- return true;
133
- }
134
- }
135
-
136
- //Define recursive_delete function
137
- if(!function_exists('recursive_delete')){
138
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
139
- if( is_dir($dir) ){
140
- if($dh = opendir($dir)) {
141
- while( ($file = readdir($dh)) !== false ) {
142
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
143
- if(!is_dir($dir .'/'. $file)) {
144
- unlink($dir .'/'. $file);
145
- } else {
146
- recursive_delete($dir.'/'. $file, $ignore);
147
- }
148
- }
149
- }
150
- }
151
- @rmdir($dir);
152
- closedir($dh);
153
- }
154
- return true;
155
- }
156
- }
157
-
158
- //Define zip function
159
- function zip($source, $destination, $ignore) {
160
- if (is_string($source)) $source_arr = array($source); // convert it to array
161
- if (!extension_loaded('zip')) {
162
- return false;
163
- }
164
- $zip = new ZipArchive();
165
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
166
- return false;
167
- }
168
- foreach ($source_arr as $source) {
169
- if (!file_exists($source)) continue;
170
- $source = str_replace('\\', '/', realpath($source));
171
- if (is_dir($source) === true) {
172
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
173
- foreach ($files as $file) {
174
- if (!preg_match($ignore, $file)) {
175
- $file = str_replace('\\', '/', realpath($file));
176
- if (is_dir($file) === true) {
177
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
178
- } else if (is_file($file) === true) {
179
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
180
- }
181
- }
182
- }
183
- } else if (is_file($source) === true) {
184
- $zip->addFromString(basename($source), file_get_contents($source));
185
- }
186
- }
187
- return $zip->close();
188
- }
189
-
190
- //load presstrends
191
- function load_presstrends() {
192
- global $WPBackitup;
193
- if($WPBackitup->get_option( 'presstrends' ) == 'enabled') {
194
- // PressTrends Account API Key
195
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
196
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
197
-
198
- // Start of Metrics
199
- global $wpdb;
200
- $data = get_transient( 'presstrends_cache_data' );
201
- if ( !$data || $data == '' ) {
202
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
203
- $url = $api_base . $auth . '/api/' . $api_key . '/';
204
-
205
- $count_posts = wp_count_posts();
206
- $count_pages = wp_count_posts( 'page' );
207
- $comments_count = wp_count_comments();
208
-
209
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
210
- if ( function_exists( 'wp_get_theme' ) ) {
211
- $theme_data = wp_get_theme();
212
- $theme_name = urlencode( $theme_data->Name );
213
- } else {
214
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
215
- $theme_name = $theme_data['Name'];
216
- }
217
-
218
- $plugin_name = '&';
219
- foreach ( get_plugins() as $plugin_info ) {
220
- $plugin_name .= $plugin_info['Name'] . '&';
221
- }
222
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
223
- $plugin_data = get_plugin_data( __FILE__ );
224
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
225
- $data = array(
226
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
227
- 'posts' => $count_posts->publish,
228
- 'pages' => $count_pages->publish,
229
- 'comments' => $comments_count->total_comments,
230
- 'approved' => $comments_count->approved,
231
- 'spam' => $comments_count->spam,
232
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
233
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
234
- 'theme_version' => $plugin_data['Version'],
235
- 'theme_name' => $theme_name,
236
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
237
- 'plugins' => count( get_option( 'active_plugins' ) ),
238
- 'plugin' => urlencode( $plugin_name ),
239
- 'wpversion' => get_bloginfo( 'version' ),
240
- );
241
-
242
- foreach ( $data as $k => $v ) {
243
- $url .= $k . '/' . $v . '/';
244
- }
245
- wp_remote_get( $url );
246
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
247
- }
248
- }
249
- }
250
- // PressTrends WordPress Action
251
- add_action('admin_init', 'load_presstrends');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/lib/includes/backup.php DELETED
@@ -1,82 +0,0 @@
1
- <?php
2
- //limit process to 15 minutes
3
- @set_time_limit(900);
4
-
5
- //Define variables
6
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
7
- $backup_project_path = WPBACKITUP_DIRNAME ."/backups/". $backup_project_dirname .'/';
8
- $wp_content_path = dirname(dirname(dirname(dirname(dirname(__FILE__))))) .'/';
9
-
10
- //create the backup dir
11
- if( !is_dir(WPBACKITUP_DIRNAME ."/backups") ) {
12
- @mkdir(WPBACKITUP_DIRNAME ."/backups", 0775);
13
- }
14
-
15
- //create log file
16
- $log = WPBACKITUP_DIRNAME ."/backups/status.log";
17
- $fh = fopen($log, 'w') or die("can't open file");
18
- fwrite($fh, '<ul>');
19
-
20
- //Check to see if the directory is writeable
21
- fwrite($fh, '<li>Creating backup directory...');
22
- if(!is_writeable(WPBACKITUP_DIRNAME ."/backups/")) {
23
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
24
- die();
25
- } else {
26
- //If the directory is writeable, create the backup folder if it doesn't exist
27
- if( !is_dir($backup_project_path) ) {
28
- @mkdir($backup_project_path, 0775);
29
- fwrite($fh, 'Done!</li>');
30
- }
31
- foreach(glob(WPBACKITUP_DIRNAME ."/backups/*.zip") as $zip) {
32
- unlink($zip);
33
- }
34
- }
35
-
36
- //Backup content to project dir
37
- fwrite($fh, '<li>Backing up your files...');
38
- //Backup with copy
39
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip' ) ) ) {
40
- fwrite($fh, 'Done!</li>');
41
- } else {
42
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
43
- die();
44
- }
45
-
46
- //Dump DB to project dir
47
- fwrite($fh, '<li>Backing up your database...');
48
- if( db_backup($backup_project_path) ) {
49
- fwrite($fh, 'Done!</li>');
50
- } else {
51
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
52
- recursive_delete($backup_project_path);
53
- die();
54
- }
55
-
56
- //Create siteinfo in project dir
57
- global $wpdb;
58
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
59
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
60
- recursive_delete($backup_project_path);
61
- die();
62
- }
63
-
64
- //Zip the project dir
65
- fwrite($fh, '<li>Creating backup zip...');
66
- $z = new recurseZip();
67
- $src = rtrim($backup_project_path, '/');
68
- $z->compress($src, WPBACKITUP_DIRNAME ."/backups/");
69
- fwrite($fh, 'Done!</li>');
70
-
71
- //Delete backup dir
72
- if(!recursive_delete($backup_project_path)) {
73
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
74
- }
75
-
76
- //close log file
77
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
78
- fwrite($fh, '</ul>');
79
- fclose($fh);
80
-
81
- //End backup function
82
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/lib/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
tags/1.1.4/license.txt DELETED
@@ -1,674 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
- Preamble
9
-
10
- The GNU General Public License is a free, copyleft license for
11
- software and other kinds of works.
12
-
13
- The licenses for most software and other practical works are designed
14
- to take away your freedom to share and change the works. By contrast,
15
- the GNU General Public License is intended to guarantee your freedom to
16
- share and change all versions of a program--to make sure it remains free
17
- software for all its users. We, the Free Software Foundation, use the
18
- GNU General Public License for most of our software; it applies also to
19
- any other work released this way by its authors. You can apply it to
20
- your programs, too.
21
-
22
- When we speak of free software, we are referring to freedom, not
23
- price. Our General Public Licenses are designed to make sure that you
24
- have the freedom to distribute copies of free software (and charge for
25
- them if you wish), that you receive source code or can get it if you
26
- want it, that you can change the software or use pieces of it in new
27
- free programs, and that you know you can do these things.
28
-
29
- To protect your rights, we need to prevent others from denying you
30
- these rights or asking you to surrender the rights. Therefore, you have
31
- certain responsibilities if you distribute copies of the software, or if
32
- you modify it: responsibilities to respect the freedom of others.
33
-
34
- For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must pass on to the recipients the same
36
- freedoms that you received. You must make sure that they, too, receive
37
- or can get the source code. And you must show them these terms so they
38
- know their rights.
39
-
40
- Developers that use the GNU GPL protect your rights with two steps:
41
- (1) assert copyright on the software, and (2) offer you this License
42
- giving you legal permission to copy, distribute and/or modify it.
43
-
44
- For the developers' and authors' protection, the GPL clearly explains
45
- that there is no warranty for this free software. For both users' and
46
- authors' sake, the GPL requires that modified versions be marked as
47
- changed, so that their problems will not be attributed erroneously to
48
- authors of previous versions.
49
-
50
- Some devices are designed to deny users access to install or run
51
- modified versions of the software inside them, although the manufacturer
52
- can do so. This is fundamentally incompatible with the aim of
53
- protecting users' freedom to change the software. The systematic
54
- pattern of such abuse occurs in the area of products for individuals to
55
- use, which is precisely where it is most unacceptable. Therefore, we
56
- have designed this version of the GPL to prohibit the practice for those
57
- products. If such problems arise substantially in other domains, we
58
- stand ready to extend this provision to those domains in future versions
59
- of the GPL, as needed to protect the freedom of users.
60
-
61
- Finally, every program is threatened constantly by software patents.
62
- States should not allow patents to restrict development and use of
63
- software on general-purpose computers, but in those that do, we wish to
64
- avoid the special danger that patents applied to a free program could
65
- make it effectively proprietary. To prevent this, the GPL assures that
66
- patents cannot be used to render the program non-free.
67
-
68
- The precise terms and conditions for copying, distribution and
69
- modification follow.
70
-
71
- TERMS AND CONDITIONS
72
-
73
- 0. Definitions.
74
-
75
- "This License" refers to version 3 of the GNU General Public License.
76
-
77
- "Copyright" also means copyright-like laws that apply to other kinds of
78
- works, such as semiconductor masks.
79
-
80
- "The Program" refers to any copyrightable work licensed under this
81
- License. Each licensee is addressed as "you". "Licensees" and
82
- "recipients" may be individuals or organizations.
83
-
84
- To "modify" a work means to copy from or adapt all or part of the work
85
- in a fashion requiring copyright permission, other than the making of an
86
- exact copy. The resulting work is called a "modified version" of the
87
- earlier work or a work "based on" the earlier work.
88
-
89
- A "covered work" means either the unmodified Program or a work based
90
- on the Program.
91
-
92
- To "propagate" a work means to do anything with it that, without
93
- permission, would make you directly or secondarily liable for
94
- infringement under applicable copyright law, except executing it on a
95
- computer or modifying a private copy. Propagation includes copying,
96
- distribution (with or without modification), making available to the
97
- public, and in some countries other activities as well.
98
-
99
- To "convey" a work means any kind of propagation that enables other
100
- parties to make or receive copies. Mere interaction with a user through
101
- a computer network, with no transfer of a copy, is not conveying.
102
-
103
- An interactive user interface displays "Appropriate Legal Notices"
104
- to the extent that it includes a convenient and prominently visible
105
- feature that (1) displays an appropriate copyright notice, and (2)
106
- tells the user that there is no warranty for the work (except to the
107
- extent that warranties are provided), that licensees may convey the
108
- work under this License, and how to view a copy of this License. If
109
- the interface presents a list of user commands or options, such as a
110
- menu, a prominent item in the list meets this criterion.
111
-
112
- 1. Source Code.
113
-
114
- The "source code" for a work means the preferred form of the work
115
- for making modifications to it. "Object code" means any non-source
116
- form of a work.
117
-
118
- A "Standard Interface" means an interface that either is an official
119
- standard defined by a recognized standards body, or, in the case of
120
- interfaces specified for a particular programming language, one that
121
- is widely used among developers working in that language.
122
-
123
- The "System Libraries" of an executable work include anything, other
124
- than the work as a whole, that (a) is included in the normal form of
125
- packaging a Major Component, but which is not part of that Major
126
- Component, and (b) serves only to enable use of the work with that
127
- Major Component, or to implement a Standard Interface for which an
128
- implementation is available to the public in source code form. A
129
- "Major Component", in this context, means a major essential component
130
- (kernel, window system, and so on) of the specific operating system
131
- (if any) on which the executable work runs, or a compiler used to
132
- produce the work, or an object code interpreter used to run it.
133
-
134
- The "Corresponding Source" for a work in object code form means all
135
- the source code needed to generate, install, and (for an executable
136
- work) run the object code and to modify the work, including scripts to
137
- control those activities. However, it does not include the work's
138
- System Libraries, or general-purpose tools or generally available free
139
- programs which are used unmodified in performing those activities but
140
- which are not part of the work. For example, Corresponding Source
141
- includes interface definition files associated with source files for
142
- the work, and the source code for shared libraries and dynamically
143
- linked subprograms that the work is specifically designed to require,
144
- such as by intimate data communication or control flow between those
145
- subprograms and other parts of the work.
146
-
147
- The Corresponding Source need not include anything that users
148
- can regenerate automatically from other parts of the Corresponding
149
- Source.
150
-
151
- The Corresponding Source for a work in source code form is that
152
- same work.
153
-
154
- 2. Basic Permissions.
155
-
156
- All rights granted under this License are granted for the term of
157
- copyright on the Program, and are irrevocable provided the stated
158
- conditions are met. This License explicitly affirms your unlimited
159
- permission to run the unmodified Program. The output from running a
160
- covered work is covered by this License only if the output, given its
161
- content, constitutes a covered work. This License acknowledges your
162
- rights of fair use or other equivalent, as provided by copyright law.
163
-
164
- You may make, run and propagate covered works that you do not
165
- convey, without conditions so long as your license otherwise remains
166
- in force. You may convey covered works to others for the sole purpose
167
- of having them make modifications exclusively for you, or provide you
168
- with facilities for running those works, provided that you comply with
169
- the terms of this License in conveying all material for which you do
170
- not control copyright. Those thus making or running the covered works
171
- for you must do so exclusively on your behalf, under your direction
172
- and control, on terms that prohibit them from making any copies of
173
- your copyrighted material outside their relationship with you.
174
-
175
- Conveying under any other circumstances is permitted solely under
176
- the conditions stated below. Sublicensing is not allowed; section 10
177
- makes it unnecessary.
178
-
179
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
-
181
- No covered work shall be deemed part of an effective technological
182
- measure under any applicable law fulfilling obligations under article
183
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
- similar laws prohibiting or restricting circumvention of such
185
- measures.
186
-
187
- When you convey a covered work, you waive any legal power to forbid
188
- circumvention of technological measures to the extent such circumvention
189
- is effected by exercising rights under this License with respect to
190
- the covered work, and you disclaim any intention to limit operation or
191
- modification of the work as a means of enforcing, against the work's
192
- users, your or third parties' legal rights to forbid circumvention of
193
- technological measures.
194
-
195
- 4. Conveying Verbatim Copies.
196
-
197
- You may convey verbatim copies of the Program's source code as you
198
- receive it, in any medium, provided that you conspicuously and
199
- appropriately publish on each copy an appropriate copyright notice;
200
- keep intact all notices stating that this License and any
201
- non-permissive terms added in accord with section 7 apply to the code;
202
- keep intact all notices of the absence of any warranty; and give all
203
- recipients a copy of this License along with the Program.
204
-
205
- You may charge any price or no price for each copy that you convey,
206
- and you may offer support or warranty protection for a fee.
207
-
208
- 5. Conveying Modified Source Versions.
209
-
210
- You may convey a work based on the Program, or the modifications to
211
- produce it from the Program, in the form of source code under the
212
- terms of section 4, provided that you also meet all of these conditions:
213
-
214
- a) The work must carry prominent notices stating that you modified
215
- it, and giving a relevant date.
216
-
217
- b) The work must carry prominent notices stating that it is
218
- released under this License and any conditions added under section
219
- 7. This requirement modifies the requirement in section 4 to
220
- "keep intact all notices".
221
-
222
- c) You must license the entire work, as a whole, under this
223
- License to anyone who comes into possession of a copy. This
224
- License will therefore apply, along with any applicable section 7
225
- additional terms, to the whole of the work, and all its parts,
226
- regardless of how they are packaged. This License gives no
227
- permission to license the work in any other way, but it does not
228
- invalidate such permission if you have separately received it.
229
-
230
- d) If the work has interactive user interfaces, each must display
231
- Appropriate Legal Notices; however, if the Program has interactive
232
- interfaces that do not display Appropriate Legal Notices, your
233
- work need not make them do so.
234
-
235
- A compilation of a covered work with other separate and independent
236
- works, which are not by their nature extensions of the covered work,
237
- and which are not combined with it such as to form a larger program,
238
- in or on a volume of a storage or distribution medium, is called an
239
- "aggregate" if the compilation and its resulting copyright are not
240
- used to limit the access or legal rights of the compilation's users
241
- beyond what the individual works permit. Inclusion of a covered work
242
- in an aggregate does not cause this License to apply to the other
243
- parts of the aggregate.
244
-
245
- 6. Conveying Non-Source Forms.
246
-
247
- You may convey a covered work in object code form under the terms
248
- of sections 4 and 5, provided that you also convey the
249
- machine-readable Corresponding Source under the terms of this License,
250
- in one of these ways:
251
-
252
- a) Convey the object code in, or embodied in, a physical product
253
- (including a physical distribution medium), accompanied by the
254
- Corresponding Source fixed on a durable physical medium
255
- customarily used for software interchange.
256
-
257
- b) Convey the object code in, or embodied in, a physical product
258
- (including a physical distribution medium), accompanied by a
259
- written offer, valid for at least three years and valid for as
260
- long as you offer spare parts or customer support for that product
261
- model, to give anyone who possesses the object code either (1) a
262
- copy of the Corresponding Source for all the software in the
263
- product that is covered by this License, on a durable physical
264
- medium customarily used for software interchange, for a price no
265
- more than your reasonable cost of physically performing this
266
- conveying of source, or (2) access to copy the
267
- Corresponding Source from a network server at no charge.
268
-
269
- c) Convey individual copies of the object code with a copy of the
270
- written offer to provide the Corresponding Source. This
271
- alternative is allowed only occasionally and noncommercially, and
272
- only if you received the object code with such an offer, in accord
273
- with subsection 6b.
274
-
275
- d) Convey the object code by offering access from a designated
276
- place (gratis or for a charge), and offer equivalent access to the
277
- Corresponding Source in the same way through the same place at no
278
- further charge. You need not require recipients to copy the
279
- Corresponding Source along with the object code. If the place to
280
- copy the object code is a network server, the Corresponding Source
281
- may be on a different server (operated by you or a third party)
282
- that supports equivalent copying facilities, provided you maintain
283
- clear directions next to the object code saying where to find the
284
- Corresponding Source. Regardless of what server hosts the
285
- Corresponding Source, you remain obligated to ensure that it is
286
- available for as long as needed to satisfy these requirements.
287
-
288
- e) Convey the object code using peer-to-peer transmission, provided
289
- you inform other peers where the object code and Corresponding
290
- Source of the work are being offered to the general public at no
291
- charge under subsection 6d.
292
-
293
- A separable portion of the object code, whose source code is excluded
294
- from the Corresponding Source as a System Library, need not be
295
- included in conveying the object code work.
296
-
297
- A "User Product" is either (1) a "consumer product", which means any
298
- tangible personal property which is normally used for personal, family,
299
- or household purposes, or (2) anything designed or sold for incorporation
300
- into a dwelling. In determining whether a product is a consumer product,
301
- doubtful cases shall be resolved in favor of coverage. For a particular
302
- product received by a particular user, "normally used" refers to a
303
- typical or common use of that class of product, regardless of the status
304
- of the particular user or of the way in which the particular user
305
- actually uses, or expects or is expected to use, the product. A product
306
- is a consumer product regardless of whether the product has substantial
307
- commercial, industrial or non-consumer uses, unless such uses represent
308
- the only significant mode of use of the product.
309
-
310
- "Installation Information" for a User Product means any methods,
311
- procedures, authorization keys, or other information required to install
312
- and execute modified versions of a covered work in that User Product from
313
- a modified version of its Corresponding Source. The information must
314
- suffice to ensure that the continued functioning of the modified object
315
- code is in no case prevented or interfered with solely because
316
- modification has been made.
317
-
318
- If you convey an object code work under this section in, or with, or
319
- specifically for use in, a User Product, and the conveying occurs as
320
- part of a transaction in which the right of possession and use of the
321
- User Product is transferred to the recipient in perpetuity or for a
322
- fixed term (regardless of how the transaction is characterized), the
323
- Corresponding Source conveyed under this section must be accompanied
324
- by the Installation Information. But this requirement does not apply
325
- if neither you nor any third party retains the ability to install
326
- modified object code on the User Product (for example, the work has
327
- been installed in ROM).
328
-
329
- The requirement to provide Installation Information does not include a
330
- requirement to continue to provide support service, warranty, or updates
331
- for a work that has been modified or installed by the recipient, or for
332
- the User Product in which it has been modified or installed. Access to a
333
- network may be denied when the modification itself materially and
334
- adversely affects the operation of the network or violates the rules and
335
- protocols for communication across the network.
336
-
337
- Corresponding Source conveyed, and Installation Information provided,
338
- in accord with this section must be in a format that is publicly
339
- documented (and with an implementation available to the public in
340
- source code form), and must require no special password or key for
341
- unpacking, reading or copying.
342
-
343
- 7. Additional Terms.
344
-
345
- "Additional permissions" are terms that supplement the terms of this
346
- License by making exceptions from one or more of its conditions.
347
- Additional permissions that are applicable to the entire Program shall
348
- be treated as though they were included in this License, to the extent
349
- that they are valid under applicable law. If additional permissions
350
- apply only to part of the Program, that part may be used separately
351
- under those permissions, but the entire Program remains governed by
352
- this License without regard to the additional permissions.
353
-
354
- When you convey a copy of a covered work, you may at your option
355
- remove any additional permissions from that copy, or from any part of
356
- it. (Additional permissions may be written to require their own
357
- removal in certain cases when you modify the work.) You may place
358
- additional permissions on material, added by you to a covered work,
359
- for which you have or can give appropriate copyright permission.
360
-
361
- Notwithstanding any other provision of this License, for material you
362
- add to a covered work, you may (if authorized by the copyright holders of
363
- that material) supplement the terms of this License with terms:
364
-
365
- a) Disclaiming warranty or limiting liability differently from the
366
- terms of sections 15 and 16 of this License; or
367
-
368
- b) Requiring preservation of specified reasonable legal notices or
369
- author attributions in that material or in the Appropriate Legal
370
- Notices displayed by works containing it; or
371
-
372
- c) Prohibiting misrepresentation of the origin of that material, or
373
- requiring that modified versions of such material be marked in
374
- reasonable ways as different from the original version; or
375
-
376
- d) Limiting the use for publicity purposes of names of licensors or
377
- authors of the material; or
378
-
379
- e) Declining to grant rights under trademark law for use of some
380
- trade names, trademarks, or service marks; or
381
-
382
- f) Requiring indemnification of licensors and authors of that
383
- material by anyone who conveys the material (or modified versions of
384
- it) with contractual assumptions of liability to the recipient, for
385
- any liability that these contractual assumptions directly impose on
386
- those licensors and authors.
387
-
388
- All other non-permissive additional terms are considered "further
389
- restrictions" within the meaning of section 10. If the Program as you
390
- received it, or any part of it, contains a notice stating that it is
391
- governed by this License along with a term that is a further
392
- restriction, you may remove that term. If a license document contains
393
- a further restriction but permits relicensing or conveying under this
394
- License, you may add to a covered work material governed by the terms
395
- of that license document, provided that the further restriction does
396
- not survive such relicensing or conveying.
397
-
398
- If you add terms to a covered work in accord with this section, you
399
- must place, in the relevant source files, a statement of the
400
- additional terms that apply to those files, or a notice indicating
401
- where to find the applicable terms.
402
-
403
- Additional terms, permissive or non-permissive, may be stated in the
404
- form of a separately written license, or stated as exceptions;
405
- the above requirements apply either way.
406
-
407
- 8. Termination.
408
-
409
- You may not propagate or modify a covered work except as expressly
410
- provided under this License. Any attempt otherwise to propagate or
411
- modify it is void, and will automatically terminate your rights under
412
- this License (including any patent licenses granted under the third
413
- paragraph of section 11).
414
-
415
- However, if you cease all violation of this License, then your
416
- license from a particular copyright holder is reinstated (a)
417
- provisionally, unless and until the copyright holder explicitly and
418
- finally terminates your license, and (b) permanently, if the copyright
419
- holder fails to notify you of the violation by some reasonable means
420
- prior to 60 days after the cessation.
421
-
422
- Moreover, your license from a particular copyright holder is
423
- reinstated permanently if the copyright holder notifies you of the
424
- violation by some reasonable means, this is the first time you have
425
- received notice of violation of this License (for any work) from that
426
- copyright holder, and you cure the violation prior to 30 days after
427
- your receipt of the notice.
428
-
429
- Termination of your rights under this section does not terminate the
430
- licenses of parties who have received copies or rights from you under
431
- this License. If your rights have been terminated and not permanently
432
- reinstated, you do not qualify to receive new licenses for the same
433
- material under section 10.
434
-
435
- 9. Acceptance Not Required for Having Copies.
436
-
437
- You are not required to accept this License in order to receive or
438
- run a copy of the Program. Ancillary propagation of a covered work
439
- occurring solely as a consequence of using peer-to-peer transmission
440
- to receive a copy likewise does not require acceptance. However,
441
- nothing other than this License grants you permission to propagate or
442
- modify any covered work. These actions infringe copyright if you do
443
- not accept this License. Therefore, by modifying or propagating a
444
- covered work, you indicate your acceptance of this License to do so.
445
-
446
- 10. Automatic Licensing of Downstream Recipients.
447
-
448
- Each time you convey a covered work, the recipient automatically
449
- receives a license from the original licensors, to run, modify and
450
- propagate that work, subject to this License. You are not responsible
451
- for enforcing compliance by third parties with this License.
452
-
453
- An "entity transaction" is a transaction transferring control of an
454
- organization, or substantially all assets of one, or subdividing an
455
- organization, or merging organizations. If propagation of a covered
456
- work results from an entity transaction, each party to that
457
- transaction who receives a copy of the work also receives whatever
458
- licenses to the work the party's predecessor in interest had or could
459
- give under the previous paragraph, plus a right to possession of the
460
- Corresponding Source of the work from the predecessor in interest, if
461
- the predecessor has it or can get it with reasonable efforts.
462
-
463
- You may not impose any further restrictions on the exercise of the
464
- rights granted or affirmed under this License. For example, you may
465
- not impose a license fee, royalty, or other charge for exercise of
466
- rights granted under this License, and you may not initiate litigation
467
- (including a cross-claim or counterclaim in a lawsuit) alleging that
468
- any patent claim is infringed by making, using, selling, offering for
469
- sale, or importing the Program or any portion of it.
470
-
471
- 11. Patents.
472
-
473
- A "contributor" is a copyright holder who authorizes use under this
474
- License of the Program or a work on which the Program is based. The
475
- work thus licensed is called the contributor's "contributor version".
476
-
477
- A contributor's "essential patent claims" are all patent claims
478
- owned or controlled by the contributor, whether already acquired or
479
- hereafter acquired, that would be infringed by some manner, permitted
480
- by this License, of making, using, or selling its contributor version,
481
- but do not include claims that would be infringed only as a
482
- consequence of further modification of the contributor version. For
483
- purposes of this definition, "control" includes the right to grant
484
- patent sublicenses in a manner consistent with the requirements of
485
- this License.
486
-
487
- Each contributor grants you a non-exclusive, worldwide, royalty-free
488
- patent license under the contributor's essential patent claims, to
489
- make, use, sell, offer for sale, import and otherwise run, modify and
490
- propagate the contents of its contributor version.
491
-
492
- In the following three paragraphs, a "patent license" is any express
493
- agreement or commitment, however denominated, not to enforce a patent
494
- (such as an express permission to practice a patent or covenant not to
495
- sue for patent infringement). To "grant" such a patent license to a
496
- party means to make such an agreement or commitment not to enforce a
497
- patent against the party.
498
-
499
- If you convey a covered work, knowingly relying on a patent license,
500
- and the Corresponding Source of the work is not available for anyone
501
- to copy, free of charge and under the terms of this License, through a
502
- publicly available network server or other readily accessible means,
503
- then you must either (1) cause the Corresponding Source to be so
504
- available, or (2) arrange to deprive yourself of the benefit of the
505
- patent license for this particular work, or (3) arrange, in a manner
506
- consistent with the requirements of this License, to extend the patent
507
- license to downstream recipients. "Knowingly relying" means you have
508
- actual knowledge that, but for the patent license, your conveying the
509
- covered work in a country, or your recipient's use of the covered work
510
- in a country, would infringe one or more identifiable patents in that
511
- country that you have reason to believe are valid.
512
-
513
- If, pursuant to or in connection with a single transaction or
514
- arrangement, you convey, or propagate by procuring conveyance of, a
515
- covered work, and grant a patent license to some of the parties
516
- receiving the covered work authorizing them to use, propagate, modify
517
- or convey a specific copy of the covered work, then the patent license
518
- you grant is automatically extended to all recipients of the covered
519
- work and works based on it.
520
-
521
- A patent license is "discriminatory" if it does not include within
522
- the scope of its coverage, prohibits the exercise of, or is
523
- conditioned on the non-exercise of one or more of the rights that are
524
- specifically granted under this License. You may not convey a covered
525
- work if you are a party to an arrangement with a third party that is
526
- in the business of distributing software, under which you make payment
527
- to the third party based on the extent of your activity of conveying
528
- the work, and under which the third party grants, to any of the
529
- parties who would receive the covered work from you, a discriminatory
530
- patent license (a) in connection with copies of the covered work
531
- conveyed by you (or copies made from those copies), or (b) primarily
532
- for and in connection with specific products or compilations that
533
- contain the covered work, unless you entered into that arrangement,
534
- or that patent license was granted, prior to 28 March 2007.
535
-
536
- Nothing in this License shall be construed as excluding or limiting
537
- any implied license or other defenses to infringement that may
538
- otherwise be available to you under applicable patent law.
539
-
540
- 12. No Surrender of Others' Freedom.
541
-
542
- If conditions are imposed on you (whether by court order, agreement or
543
- otherwise) that contradict the conditions of this License, they do not
544
- excuse you from the conditions of this License. If you cannot convey a
545
- covered work so as to satisfy simultaneously your obligations under this
546
- License and any other pertinent obligations, then as a consequence you may
547
- not convey it at all. For example, if you agree to terms that obligate you
548
- to collect a royalty for further conveying from those to whom you convey
549
- the Program, the only way you could satisfy both those terms and this
550
- License would be to refrain entirely from conveying the Program.
551
-
552
- 13. Use with the GNU Affero General Public License.
553
-
554
- Notwithstanding any other provision of this License, you have
555
- permission to link or combine any covered work with a work licensed
556
- under version 3 of the GNU Affero General Public License into a single
557
- combined work, and to convey the resulting work. The terms of this
558
- License will continue to apply to the part which is the covered work,
559
- but the special requirements of the GNU Affero General Public License,
560
- section 13, concerning interaction through a network will apply to the
561
- combination as such.
562
-
563
- 14. Revised Versions of this License.
564
-
565
- The Free Software Foundation may publish revised and/or new versions of
566
- the GNU General Public License from time to time. Such new versions will
567
- be similar in spirit to the present version, but may differ in detail to
568
- address new problems or concerns.
569
-
570
- Each version is given a distinguishing version number. If the
571
- Program specifies that a certain numbered version of the GNU General
572
- Public License "or any later version" applies to it, you have the
573
- option of following the terms and conditions either of that numbered
574
- version or of any later version published by the Free Software
575
- Foundation. If the Program does not specify a version number of the
576
- GNU General Public License, you may choose any version ever published
577
- by the Free Software Foundation.
578
-
579
- If the Program specifies that a proxy can decide which future
580
- versions of the GNU General Public License can be used, that proxy's
581
- public statement of acceptance of a version permanently authorizes you
582
- to choose that version for the Program.
583
-
584
- Later license versions may give you additional or different
585
- permissions. However, no additional obligations are imposed on any
586
- author or copyright holder as a result of your choosing to follow a
587
- later version.
588
-
589
- 15. Disclaimer of Warranty.
590
-
591
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
-
600
- 16. Limitation of Liability.
601
-
602
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
- SUCH DAMAGES.
611
-
612
- 17. Interpretation of Sections 15 and 16.
613
-
614
- If the disclaimer of warranty and limitation of liability provided
615
- above cannot be given local legal effect according to their terms,
616
- reviewing courts shall apply local law that most closely approximates
617
- an absolute waiver of all civil liability in connection with the
618
- Program, unless a warranty or assumption of liability accompanies a
619
- copy of the Program in return for a fee.
620
-
621
- END OF TERMS AND CONDITIONS
622
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
628
-
629
- To do so, attach the following notices to the program. It is safest
630
- to attach them to the start of each source file to most effectively
631
- state the exclusion of warranty; and each file should have at least
632
- the "copyright" line and a pointer to where the full notice is found.
633
-
634
- <one line to give the program's name and a brief idea of what it does.>
635
- Copyright (C) <year> <name of author>
636
-
637
- This program is free software: you can redistribute it and/or modify
638
- it under the terms of the GNU General Public License as published by
639
- the Free Software Foundation, either version 3 of the License, or
640
- (at your option) any later version.
641
-
642
- This program is distributed in the hope that it will be useful,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
644
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
- GNU General Public License for more details.
646
-
647
- You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <http://www.gnu.org/licenses/>.
649
-
650
- Also add information on how to contact you by electronic and paper mail.
651
-
652
- If the program does terminal interaction, make it output a short
653
- notice like this when it starts in an interactive mode:
654
-
655
- <program> Copyright (C) <year> <name of author>
656
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
- This is free software, and you are welcome to redistribute it
658
- under certain conditions; type `show c' for details.
659
-
660
- The hypothetical commands `show w' and `show c' should show the appropriate
661
- parts of the General Public License. Of course, your program's commands
662
- might be different; for a GUI interface, you would use an "about box".
663
-
664
- You should also get your employer (if you work as a programmer) or school,
665
- if any, to sign a "copyright disclaimer" for the program, if necessary.
666
- For more information on this, and how to apply and follow the GNU GPL, see
667
- <http://www.gnu.org/licenses/>.
668
-
669
- The GNU General Public License does not permit incorporating your program
670
- into proprietary programs. If your program is a subroutine library, you
671
- may consider it more useful to permit linking proprietary applications with
672
- the library. If this is what you want to do, use the GNU Lesser General
673
- Public License instead of this License. But first, please read
674
- <http://www.gnu.org/philosophy/why-not-lgpl.html>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/readme.txt DELETED
@@ -1,183 +0,0 @@
1
- === WP Backitup Lite ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5
7
- Stable tag: 1.1.4
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup Lite creates a backup zip of your site&apos;s content and configuration in just a single click,
17
- right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
18
-
19
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
20
-
21
- = Automatically Restore Your Backup Zips =
22
- Tired of messing around in PHPMyAdmin and with FTP trying to restore you backups? Why not check out <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>? WP Backitup Pro offers all the features of WP Backitup Lite but allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
23
-
24
- = Manually Restore Your Backup Zips =
25
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
26
-
27
- = Easy To Install and Use =
28
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
29
-
30
- = More questions? =
31
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://www.wpbackitup.com/support/" title="WP Backitup Support Forum">WP Backitup Support Forum</a>, if you need more help?
32
-
33
- == Installation ==
34
-
35
- Installation of the plugin is straightforward:
36
-
37
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
38
- 1. Activate the plugin.
39
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
40
- 1. Click 'Backup/Restore' to access WP-Backitup
41
-
42
- == Frequently Asked Questions ==
43
-
44
- = Can I manually restore my backup zips? =
45
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
46
-
47
- = Is there an easier way to restore my backup zips? =
48
- Yes, purchase and download <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
49
-
50
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
51
- Yes.
52
-
53
- = Will WP Backitup work on Windows hosting? =
54
- Yes.
55
-
56
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
57
- It is likely this will feature in a new version of WP Backitup Pro.
58
-
59
- = Can this plugin back to Amazon S3? =
60
- This will feature in an upcoming version of WP Backitup Pro.
61
-
62
- = Is there an auto back up schedule feature? =
63
- It is likely this will feature in a new version of WP Backitup Pro.
64
-
65
- = Will the plugin work with Wordpres version x.x? =
66
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
67
-
68
- = Can this backup one version of WordPress to a different version? =
69
- No. It is absolutely critical that your WordPress versions are exactly the same.
70
-
71
- = Will WP Backitup work on WordPress Multisite? =
72
- WP Backitup cannot yet backup/restore entire networks but it is compatible with WPMS sites.
73
-
74
- = Does the plugin copy the database details as well? =
75
- Yes, a database dump is created with each backup.
76
-
77
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
78
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
79
-
80
- = Does WP Backitup need to be installed? =
81
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
82
-
83
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
84
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
85
-
86
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
87
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
88
-
89
- = Do you do regularly update this product to match with WP version updates? =
90
- Yes.
91
-
92
- == Screenshots ==
93
- 1. Once activated, the plugin loads a new menu into your toolbar.
94
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
95
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
96
-
97
- == Changelog ==
98
-
99
- = 1.1.3 =
100
- * Re-wrote plugin in OOP, added option to disable Presstrends tracking code.
101
-
102
- = 1.1.2 =
103
- * Fixed issue with stylesheet not being loaded.
104
-
105
- = 1.1.1 =
106
- * Fixed issue with plugin not detecing addons
107
-
108
- = 1.1.0 =
109
- * Fixed bugs with addons system.
110
-
111
- = 1.0.9 =
112
- * Added Presstrends tracking code.
113
-
114
- = 1.0.8 =
115
- * Modified plugin administration and loaded menu tab in main toolbar.
116
-
117
- = 1.0.7 =
118
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
119
-
120
- = 1.0.6 =
121
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
122
-
123
- = 1.0.5 =
124
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
125
-
126
- = 1.0.4 =
127
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
128
-
129
- = 1.0.3 =
130
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
131
-
132
- = 1.0.2 =
133
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
134
-
135
- = 1.0.1 =
136
- * Increased PHP timeout to 900 seconds (5 minutes).
137
-
138
- = 1.0 =
139
- * Plugin released.
140
-
141
- == Upgrade Notice ==
142
-
143
- = 1.1.3 =
144
- * Non-critical upgrade. Re-wrote plugin in object-oriented PHP.
145
-
146
- = 1.1.2 =
147
- * Critical upgrade. Fixed issue with stylesheet.
148
-
149
- = 1.1.1 =
150
- * Critical upgrade. Fixed further bugs with addons system.
151
-
152
- = 1.1.0 =
153
- * Non-critical upgrade. Fixed bugs with addons system that caused problems for some users.
154
-
155
- = 1.0.9 =
156
- * Non-essential upgrade. Added Presstrends code.
157
-
158
- = 1.0.8 =
159
- * Recommended upgrade. Added links to admin menu.
160
-
161
- = 1.0.7 =
162
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
163
-
164
- = 1.0.6 =
165
- * Non-critical upgrade.
166
-
167
- = 1.0.5 =
168
- * Critical upgrade: More stable, increased flexibility and power.
169
-
170
- = 1.0.4 =
171
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
172
-
173
- = 1.0.3 =
174
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
175
-
176
- = 1.0.2 =
177
- * Critical upgrade: Plugin does not work on most systems without this upgrade
178
-
179
- = 1.0.1 =
180
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
181
-
182
- = 1.0 =
183
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.4/screenshots/screenshot-1.png DELETED
Binary file
tags/1.1.4/screenshots/screenshot-2.png DELETED
Binary file
tags/1.1.4/screenshots/screenshot-3.png DELETED
Binary file
tags/1.1.4/views/options.php DELETED
@@ -1,47 +0,0 @@
1
- <script type="text/javascript">var __namespace = '<?php echo $namespace; ?>';</script>
2
- <div class="wrap">
3
- <div id="wp-backitup-icon" class="icon32"><img src="<?php echo plugin_dir_url(dirname(__FILE__) ); ?>images/icon32.png" alt="WP Backitup Icon" height="32" width="32" /></div>
4
- <h2><?php echo $page_title; ?></h2>
5
- <div id="content">
6
- <h3>Backup</h3>
7
- <p>Create a backup file of this site's content and settings.</p>
8
- <p><a href="#" class="backup-button button-primary"><?php _e( "Backup", $namespace ) ?></a><img class="backup-icon status-icon" src="<?php echo WPBACKITUP_URLPATH. "/images/loader.gif"; ?>" height="16" width="16" /></p>
9
- <h3>Download</h3>
10
- <p><div id="download-link"></div></p>
11
- <h3>Status</h3>
12
- <p><div id="status">Nothing to report</div></p>
13
- </div>
14
- <div id="sidebar">
15
- <div class="widget" id="restore-widget">
16
- <h3 class="promo">Restore Your Backups</h3>
17
- <p>You can restore your backup zips by importing them manually or by getting WP Backitup Pro.</p>
18
- <p><a class="button-primary" href="http://www.wpbackitup.com/wp-backitup-pro/">Read more</a></p>
19
- </div>
20
- <div class="widget">
21
- <h3 class="promo">Need support?</h3>
22
- <p>If you are having problems with this plugin please talk about them in the <a href="http://wordpress.org/support/plugin/wp-backitup">support forum</a>.</p>
23
- <p>You can also refer to the <a href="http://www.wpbackitup.com/documentation/">WP Backitup documentation</a>.</p>
24
- </div>
25
- <div class="widget">
26
- <h3 class="promo">Spread the Word!</h3>
27
- <p>Want to help make WP Backitup even better? All donations are used to improve this plugin, so donate $10, $20 or $50 now!</p>
28
- <p><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
29
- <input type="hidden" name="cmd" value="_s-xclick">
30
- <input type="hidden" name="hosted_button_id" value="QSHPK8EDMAW9N">
31
- <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
32
- <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
33
- </form></p>
34
- <p>Or you could <a href="http://wordpress.org/extend/plugins/wp-backitup/">rate the plugin 5&#9733; on Wordpress.org</a>.</p>
35
- </div>
36
- <div class="widget">
37
- <h3 class="promo">Presstrends</h3>
38
- <form action="" method="post" id="<?php echo $namespace; ?>-form">
39
- <?php wp_nonce_field( $namespace . "-update-options" ); ?>
40
- <p><input type="radio" name="data[presstrends]" value="enabled" <?php if($this->get_option( 'presstrends' ) == 'enabled') echo 'checked'; ?>> <label>Enable</label></p>
41
- <p><input type="radio" name="data[presstrends]" value="disabled" <?php if($this->get_option( 'presstrends' ) == 'disabled') echo 'checked'; ?>> <label>Disable</label></p>
42
- <p>Help to improve Easy Webtrends by enabling <a href="http://www.presstrends.io" target="_blank">Presstrends</a>.</p>
43
- <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( "Save", $namespace ) ?>" /></p>
44
- </form>
45
- </div>
46
- </div>
47
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/backups/status.log DELETED
@@ -1 +0,0 @@
1
- <ul><li>Creating backup directory...Done!</li><li>Backing up your files...Done!</li><li>Backing up your database...Done!</li><li>Creating backup zip...Done!</li><li>Backup file created successfully. You can download your backup file using the link above.</li></ul>
 
tags/1.1.6/css/admin.css DELETED
@@ -1,59 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel Stylesheets
3
- *
4
- * @version 1.1.6
5
- * @since 1.1.3
6
- */
7
-
8
- /* Global */
9
- .error { color: #ff0000;}
10
-
11
- p {line-height: 1.4em;}
12
-
13
- ul {padding: 1em 0 0 0;}
14
-
15
- h3 {
16
- margin: 0;
17
- padding: 1em 0 0 0;
18
- }
19
-
20
- iframe {
21
- height: 0;
22
- margin: 0;
23
- padding: 0;
24
- position: absolute;
25
- top: 0;
26
- right: 0;
27
- width: 0;
28
- z-index: -10;
29
- }
30
-
31
- .submit {
32
- padding: 0;
33
- }
34
-
35
- /* Content */
36
- #content {
37
- float: left;
38
- width: 65%;
39
- }
40
-
41
- #content input[type="text"], #content input[type="file"] {padding: 0;}
42
-
43
- .status-icon {
44
- display: inline;
45
- height: 16px;
46
- position: relative;
47
- top: 3px;
48
- left: 5px;
49
- visibility: hidden;
50
- width: 16px;
51
- }
52
-
53
- /* Sidebar */
54
- #sidebar {
55
- float: right;
56
- width: 30%;
57
- }
58
-
59
- .widget {padding: 1em;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/images/icon.png DELETED
Binary file
tags/1.1.6/images/icon32.png DELETED
Binary file
tags/1.1.6/images/loader.gif DELETED
Binary file
tags/1.1.6/index.php DELETED
@@ -1,342 +0,0 @@
1
- <?php
2
- /**
3
- * WP Backitup Lite
4
- *
5
- * @package WPBackitup Lite
6
- *
7
- * @global object $wpdb
8
- *
9
- * @author jcpeden
10
- * @version 1.1.6
11
- */
12
- /*
13
- Plugin Name: WP Backitup Lite
14
- Plugin URI: http://www.wpbackitup.com
15
- Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
16
- Version: 1.1.6
17
- Author: John Peden
18
- Author URI: http://www.johncpeden.com
19
- License: GPL3
20
-
21
- Copyright 2012-2013 John Peden (email : support@wpbackitup.com)
22
-
23
- This program is free software: you can redistribute it and/or modify
24
- it under the terms of the GNU General Public License as published by
25
- the Free Software Foundation, either version 3 of the License, or
26
- (at your option) any later version.
27
-
28
- This program is distributed in the hope that it will be useful,
29
- but WITHOUT ANY WARRANTY; without even the implied warranty of
30
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
- GNU General Public License for more details.
32
-
33
- You should have received a copy of the GNU General Public License
34
- along with this program. If not, see <http://www.gnu.org/licenses/>.
35
- */
36
-
37
- // Include constants file
38
- require_once( dirname( __FILE__ ) . '/lib/constants.php' );
39
-
40
- class WPBackitup {
41
- var $namespace = "wp-backitup-lite";
42
- var $friendly_name = "WP Backitup Lite";
43
- var $version = "1.1.6";
44
-
45
- // Default plugin options
46
- var $defaults = array(
47
- 'presstrends' => "enabled"
48
- );
49
-
50
- /**
51
- * Instantiation construction
52
- *
53
- * @uses add_action()
54
- * @uses WPBackitup::wp_register_scripts()
55
- * @uses WPBackitup::wp_register_styles()
56
- */
57
- function __construct() {
58
- // Name of the option_value to store plugin options in
59
- $this->option_name = '_' . $this->namespace . '--options';
60
-
61
- // Load all library files used by this plugin
62
- $libs = glob( WPBACKITUP_DIRNAME . '/lib/*.php' );
63
- foreach( $libs as $lib ) {
64
- include_once( $lib );
65
- }
66
-
67
- /**
68
- * Make this plugin available for translation.
69
- * Translations can be added to the /languages/ directory.
70
- */
71
- load_theme_textdomain( $this->namespace, WPBACKITUP_DIRNAME . '/languages' );
72
-
73
- // Add all action, filter and shortcode hooks
74
- $this->_add_hooks();
75
- }
76
-
77
- /**
78
- * Add in various hooks
79
- *
80
- * Place all add_action, add_filter, add_shortcode hook-ins here
81
- */
82
- private function _add_hooks() {
83
- // Options page for configuration
84
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
85
- // Route requests for form processing
86
- add_action( 'init', array( &$this, 'route' ) );
87
-
88
- // Add a settings link next to the "Deactivate" link on the plugin listing page
89
- add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
90
-
91
- // Register all JavaScripts for this plugin
92
- add_action( 'init', array( &$this, 'wp_register_scripts' ), 1 );
93
- // Register all Stylesheets for this plugin
94
- add_action( 'init', array( &$this, 'wp_register_styles' ), 1 );
95
- }
96
-
97
- /**
98
- * Process update page form submissions
99
- *
100
- * @uses WPBackitup::sanitize()
101
- * @uses wp_redirect()
102
- * @uses wp_verify_nonce()
103
- */
104
- private function _admin_options_update() {
105
- // Verify submission for processing using wp_nonce
106
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
107
- $data = array();
108
- /**
109
- * Loop through each POSTed value and sanitize it to protect against malicious code. Please
110
- * note that rich text (or full HTML fields) should not be processed by this function and
111
- * dealt with directly.
112
- */
113
- foreach( $_POST['data'] as $key => $val ) {
114
- $data[$key] = $this->_sanitize( $val );
115
- }
116
-
117
- /**
118
- * Place your options processing and storage code here
119
- */
120
-
121
- // Update the options value with the data submitted
122
- update_option( $this->option_name, $data );
123
-
124
- // Redirect back to the options page with the message flag to show the saved message
125
- wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&message=1' );
126
- exit;
127
- }
128
- }
129
-
130
- /**
131
- * Sanitize data
132
- *
133
- * @param mixed $str The data to be sanitized
134
- *
135
- * @uses wp_kses()
136
- *
137
- * @return mixed The sanitized version of the data
138
- */
139
- private function _sanitize( $str ) {
140
- if ( !function_exists( 'wp_kses' ) ) {
141
- require_once( ABSPATH . 'wp-includes/kses.php' );
142
- }
143
- global $allowedposttags;
144
- global $allowedprotocols;
145
-
146
- if ( is_string( $str ) ) {
147
- $str = wp_kses( $str, $allowedposttags, $allowedprotocols );
148
- } elseif( is_array( $str ) ) {
149
- $arr = array();
150
- foreach( (array) $str as $key => $val ) {
151
- $arr[$key] = $this->_sanitize( $val );
152
- }
153
- $str = $arr;
154
- }
155
-
156
- return $str;
157
- }
158
-
159
- /**
160
- * Hook into register_activation_hook action
161
- *
162
- * Put code here that needs to happen when your plugin is first activated (database
163
- * creation, permalink additions, etc.)
164
- */
165
- static function activate() {
166
- // Do activation actions
167
- }
168
-
169
- /**
170
- * Define the admin menu options for this plugin
171
- *
172
- * @uses add_action()
173
- * @uses add_options_page()
174
- */
175
- function admin_menu() {
176
- $page_hook = add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_options_page' ), WPBACKITUP_URLPATH .'/images/icon.png', 77);
177
-
178
- // Add print scripts and styles action based off the option page hook
179
- add_action( 'admin_print_scripts-' . $page_hook, array( &$this, 'admin_print_scripts' ) );
180
- add_action( 'admin_print_styles-' . $page_hook, array( &$this, 'admin_print_styles' ) );
181
- }
182
-
183
-
184
- /**
185
- * The admin section options page rendering method
186
- *
187
- * @uses current_user_can()
188
- * @uses wp_die()
189
- */
190
- function admin_options_page() {
191
- if( !current_user_can( 'manage_options' ) ) {
192
- wp_die( 'You do not have sufficient permissions to access this page' );
193
- }
194
-
195
- $page_title = $this->friendly_name . ' Options';
196
- $namespace = $this->namespace;
197
-
198
- include( WPBACKITUP_DIRNAME . "/views/options.php" );
199
- }
200
-
201
- /**
202
- * Load JavaScript for the admin options page
203
- *
204
- * @uses wp_enqueue_script()
205
- */
206
- function admin_print_scripts() {
207
- wp_enqueue_script( "{$this->namespace}-admin" );
208
- }
209
-
210
- /**
211
- * Load Stylesheet for the admin options page
212
- *
213
- * @uses wp_enqueue_style()
214
- */
215
- function admin_print_styles() {
216
- wp_enqueue_style( "{$this->namespace}-admin" );
217
- }
218
-
219
- /**
220
- * Hook into register_deactivation_hook action
221
- *
222
- * Put code here that needs to happen when your plugin is deactivated
223
- */
224
- static function deactivate() {
225
- // Do deactivation actions
226
- }
227
-
228
- /**
229
- * Retrieve the stored plugin option or the default if no user specified value is defined
230
- *
231
- * @param string $option_name The name of the TrialAccount option you wish to retrieve
232
- *
233
- * @uses get_option()
234
- *
235
- * @return mixed Returns the option value or false(boolean) if the option is not found
236
- */
237
- function get_option( $option_name ) {
238
- // Load option values if they haven't been loaded already
239
- if( !isset( $this->options ) || empty( $this->options ) ) {
240
- $this->options = get_option( $this->option_name, $this->defaults );
241
- }
242
-
243
- if( isset( $this->options[$option_name] ) ) {
244
- return $this->options[$option_name]; // Return user's specified option value
245
- } elseif( isset( $this->defaults[$option_name] ) ) {
246
- return $this->defaults[$option_name]; // Return default option value
247
- }
248
- return false;
249
- }
250
-
251
- /**
252
- * Initialization function to hook into the WordPress init action
253
- *
254
- * Instantiates the class on a global variable and sets the class, actions
255
- * etc. up for use.
256
- */
257
- static function instance() {
258
- global $WPBackitup;
259
-
260
- // Only instantiate the Class if it hasn't been already
261
- if( !isset( $WPBackitup ) ) $WPBackitup = new WPBackitup();
262
- }
263
-
264
- /**
265
- * Hook into plugin_action_links filter
266
- *
267
- * Adds a "Settings" link next to the "Deactivate" link in the plugin listing page
268
- * when the plugin is active.
269
- *
270
- * @param object $links An array of the links to show, this will be the modified variable
271
- * @param string $file The name of the file being processed in the filter
272
- */
273
- function plugin_action_links( $links, $file ) {
274
- if( $file == plugin_basename( WPBACKITUP_DIRNAME . '/' . basename( __FILE__ ) ) ) {
275
- $old_links = $links;
276
- $new_links = array(
277
- "settings" => '<a href="options-general.php?page=' . $this->namespace . '">' . __( 'Settings' ) . '</a>'
278
- );
279
- $links = array_merge( $new_links, $old_links );
280
- }
281
-
282
- return $links;
283
- }
284
-
285
- /**
286
- * Route the user based off of environment conditions
287
- *
288
- * This function will handling routing of form submissions to the appropriate
289
- * form processor.
290
- *
291
- * @uses WPBackitup::_admin_options_update()
292
- */
293
- function route() {
294
- $uri = $_SERVER['REQUEST_URI'];
295
- $protocol = isset( $_SERVER['HTTPS'] ) ? 'https' : 'http';
296
- $hostname = $_SERVER['HTTP_HOST'];
297
- $url = "{$protocol}://{$hostname}{$uri}";
298
- $is_post = (bool) ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == "POST" );
299
-
300
- // Check if a nonce was passed in the request
301
- if( isset( $_REQUEST['_wpnonce'] ) ) {
302
- $nonce = $_REQUEST['_wpnonce'];
303
-
304
- // Handle POST requests
305
- if( $is_post ) {
306
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
307
- $this->_admin_options_update();
308
- }
309
- }
310
- // Handle GET requests
311
- else {
312
-
313
- }
314
- }
315
- }
316
-
317
- /**
318
- * Register scripts used by this plugin for enqueuing elsewhere
319
- *
320
- * @uses wp_register_script()
321
- */
322
- function wp_register_scripts() {
323
- // Admin JavaScript
324
- wp_register_script( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/js/admin.js", array( 'jquery' ), $this->version, true );
325
- }
326
-
327
- /**
328
- * Register styles used by this plugin for enqueuing elsewhere
329
- *
330
- * @uses wp_register_style()
331
- */
332
- function wp_register_styles() {
333
- // Admin Stylesheet
334
- wp_register_style( "{$this->namespace}-admin", WPBACKITUP_URLPATH . "/css/admin.css", array(), $this->version, 'screen' );
335
- }
336
- }
337
- if( !isset( $WPBackitup ) ) {
338
- WPBackitup::instance();
339
- }
340
-
341
- register_activation_hook( __FILE__, array( 'WPBackitup', 'activate' ) );
342
- register_deactivation_hook( __FILE__, array( 'WPBackitup', 'deactivate' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/js/admin.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel JavaScripts
3
- *
4
- * @version 1.1.6
5
- * @since 1.1.3
6
- */
7
-
8
- (function($){
9
- //define backup variables
10
- var backup = {
11
- action: 'backup',
12
- beforeSend: function() {
13
- $('.backup-icon').css('visibility','visible');
14
- $("#status").empty();
15
- setInterval(display_log, 1000);
16
- }
17
- };
18
- //define download variables
19
- var download = {
20
- action: 'download'
21
- };
22
- //define logreader variables
23
- var logreader = {
24
- action: 'logreader'
25
- };
26
- //define logreader function
27
- function display_log() {
28
- $.post(ajaxurl, logreader, function(response) {
29
- $("#status").html(response);
30
- });
31
- }
32
- //define download function
33
- function download_link() {
34
- $.post(ajaxurl, download, function(response) {
35
- $("#download-link").html(response);
36
- });
37
- }
38
-
39
- //execute download (on page load/refresh)
40
- download_link();
41
-
42
- //execute backup on button click
43
- $(".backup-button").click( function() {
44
- $.post(ajaxurl, backup, function(response) {
45
- download_link();
46
- clearInterval(display_log);
47
- $('.backup-icon').fadeOut(1000);
48
- $("#php").html(response); //Return PHP messages, used for development
49
- });
50
- })
51
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/lib/constants.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /**
3
- * Constants used by this plugin
4
- *
5
- * @package WPBackitup
6
- *
7
- * @author jcpeden
8
- * @version 1.1.6
9
- * @since 1.1.3
10
- */
11
-
12
- // The current version of this plugin
13
- if( !defined( 'WPBACKITUP_VERSION' ) ) define( 'WPBACKITUP_VERSION', '1.1.5' );
14
-
15
- // The directory the plugin resides in
16
- if( !defined( 'WPBACKITUP_DIRNAME' ) ) define( 'WPBACKITUP_DIRNAME', dirname( dirname( __FILE__ ) ) );
17
-
18
- // The URL path of this plugin
19
- if( !defined( 'WPBACKITUP_URLPATH' ) ) define( 'WPBACKITUP_URLPATH', WP_PLUGIN_URL . "/" . plugin_basename( WPBACKITUP_DIRNAME ) );
20
-
21
- if( !defined( 'IS_AJAX_REQUEST' ) ) define( 'IS_AJAX_REQUEST', ( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/lib/functions.php DELETED
@@ -1,251 +0,0 @@
1
- <?php
2
- /**
3
- * WP Backitup Functions
4
- *
5
- * @package WP Backitup Lite
6
- *
7
- * @author jcpeden
8
- * @version 1.1.6
9
- * @since 1.1.3
10
- */
11
-
12
- //load backup function
13
- function backup() {
14
- include_once 'includes/backup.php';
15
- }
16
- add_action('wp_ajax_backup', 'backup');
17
-
18
- //load download function
19
- function download() {
20
- if(glob(WPBACKITUP_DIRNAME . "/backups/*.zip")) {
21
- echo '<ul>';
22
- foreach (glob(WPBACKITUP_DIRNAME . "/backups/*.zip") as $file) {
23
- $filename = basename($file);
24
- echo '<li>Download most recent export file: <a href="' .WPBACKITUP_URLPATH. '/backups/' .$filename .'">' .$filename .'</a></li>';
25
- }
26
- echo '</ul>';
27
- } else {
28
- echo '<p>No export file available for download. Please create one.</p>';
29
- }
30
- die();
31
- }
32
- add_action('wp_ajax_download', 'download');
33
-
34
- //load logreader function
35
- function logreader() {
36
- $log = WPBACKITUP_DIRNAME .'/backups/status.log';
37
- if(file_exists($log) ) {
38
- readfile($log);
39
- }
40
- die();
41
- }
42
- add_action('wp_ajax_logreader', 'logreader');
43
-
44
- //define create_dir function
45
- if(!function_exists('create_dir')) {
46
- function create_dir($dir) {
47
- if( !is_dir($dir) ) {
48
- @mkdir($dir, 0755);
49
- }
50
- return true;
51
- }
52
- }
53
-
54
- //Define recusive_copy function
55
- if(!function_exists('recursive_copy')) {
56
- function recursive_copy($dir, $target_path, $ignore = array( 'cgi-bin','..','._' ) ) {
57
- if( is_dir($dir) ) { //If the directory exists
58
- if ($dh = opendir($dir) ) {
59
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
60
- if ( !in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
61
- if (!is_dir( $dir.$file ) ) {
62
- //Copy files to destination directory
63
- $fsrc = fopen($dir .$file,'r');
64
- $fdest = fopen($target_path .$file,'w+');
65
- $len = stream_copy_to_stream($fsrc,$fdest);
66
- fclose($fsrc);
67
- fclose($fdest);
68
- } else { //If $file is a directory
69
- $destdir = $target_path .$file; //Modify the destination dir
70
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
71
- @mkdir($destdir, 0755);
72
- }
73
- recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
74
- }
75
- }
76
- }
77
- closedir($dh);
78
- }
79
- }
80
- return true;
81
- }
82
- }
83
-
84
- //Define DB backup function
85
- if(!function_exists('db_backup')) {
86
- function db_backup($path) {
87
- global $wpdb;
88
- $row = $wpdb->get_results('SHOW TABLES', ARRAY_N);
89
- $tables = array();
90
- foreach($row as $value) {
91
- $tables[] = $value[0];
92
- }
93
- $handle = fopen($path .'db-backup.sql', 'w+');
94
- foreach($tables as $table) {
95
- $result = $wpdb->get_results('SELECT * FROM '.$table,ARRAY_N);
96
- $testing = $wpdb->get_row('SELECT * FROM '.$table,ARRAY_N);
97
- $num_fields=count($testing);
98
- $return = '';
99
- $return.= 'DROP TABLE IF EXISTS '.$table.';';
100
- $row2 = $wpdb->get_row('SHOW CREATE TABLE '.$table,ARRAY_N);
101
- $return.= "\n\n".$row2[1].";\n\n";
102
- foreach($result as $row) {
103
- $return.= 'INSERT INTO '.$table.' VALUES(';
104
- for($j=0; $j<$num_fields; $j++) {
105
- $row[$j] = addslashes($row[$j]);
106
- $row[$j] = ereg_replace("\n", "\\n",$row[$j]);
107
- if (isset($row[$j])) {
108
- $return .= '"' .$row[$j] .'"';
109
- } else {
110
- $return .= '"';
111
- }
112
- if ($j<($num_fields-1)) { $return.= ', '; }
113
- }
114
- $return.= ");\n";
115
- }
116
- $return.="\n\n\n";
117
- fwrite($handle, $return);
118
- }
119
- fclose($handle);
120
- return true;
121
- }
122
- }
123
-
124
- //Define the create_siteinfo function
125
- if(!function_exists('create_siteinfo')) {
126
- function create_siteinfo($path, $table_prefix) {
127
- $siteinfo = $path ."backupsiteinfo.txt";
128
- $handle = fopen($siteinfo, 'w+');
129
- $entry = site_url( '/' ) ."\n$table_prefix";
130
- fwrite($handle, $entry);
131
- fclose($handle);
132
- return true;
133
- }
134
- }
135
-
136
- //Define recursive_delete function
137
- if(!function_exists('recursive_delete')){
138
- function recursive_delete($dir, $ignore = array('cgi-bin','.','..','._') ){
139
- if( is_dir($dir) ){
140
- if($dh = opendir($dir)) {
141
- while( ($file = readdir($dh)) !== false ) {
142
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.') { //Check the file is not in the ignore array
143
- if(!is_dir($dir .'/'. $file)) {
144
- unlink($dir .'/'. $file);
145
- } else {
146
- recursive_delete($dir.'/'. $file, $ignore);
147
- }
148
- }
149
- }
150
- }
151
- @rmdir($dir);
152
- closedir($dh);
153
- }
154
- return true;
155
- }
156
- }
157
-
158
- //Define zip function
159
- function zip($source, $destination, $ignore) {
160
- if (is_string($source)) $source_arr = array($source); // convert it to array
161
- if (!extension_loaded('zip')) {
162
- return false;
163
- }
164
- $zip = new ZipArchive();
165
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
166
- return false;
167
- }
168
- foreach ($source_arr as $source) {
169
- if (!file_exists($source)) continue;
170
- $source = str_replace('\\', '/', realpath($source));
171
- if (is_dir($source) === true) {
172
- $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
173
- foreach ($files as $file) {
174
- if (!preg_match($ignore, $file)) {
175
- $file = str_replace('\\', '/', realpath($file));
176
- if (is_dir($file) === true) {
177
- $zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
178
- } else if (is_file($file) === true) {
179
- $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
180
- }
181
- }
182
- }
183
- } else if (is_file($source) === true) {
184
- $zip->addFromString(basename($source), file_get_contents($source));
185
- }
186
- }
187
- return $zip->close();
188
- }
189
-
190
- //load presstrends
191
- function load_presstrends() {
192
- global $WPBackitup;
193
- if($WPBackitup->get_option( 'presstrends' ) == 'enabled') {
194
- // PressTrends Account API Key
195
- $api_key = 'rwiyhqfp7eioeh62h6t3ulvcghn2q8cr7j5x';
196
- $auth = 'lpa0nvlhyzbyikkwizk4navhtoaqujrbw';
197
-
198
- // Start of Metrics
199
- global $wpdb;
200
- $data = get_transient( 'presstrends_cache_data' );
201
- if ( !$data || $data == '' ) {
202
- $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
203
- $url = $api_base . $auth . '/api/' . $api_key . '/';
204
-
205
- $count_posts = wp_count_posts();
206
- $count_pages = wp_count_posts( 'page' );
207
- $comments_count = wp_count_comments();
208
-
209
- // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
210
- if ( function_exists( 'wp_get_theme' ) ) {
211
- $theme_data = wp_get_theme();
212
- $theme_name = urlencode( $theme_data->Name );
213
- } else {
214
- $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
215
- $theme_name = $theme_data['Name'];
216
- }
217
-
218
- $plugin_name = '&';
219
- foreach ( get_plugins() as $plugin_info ) {
220
- $plugin_name .= $plugin_info['Name'] . '&';
221
- }
222
- // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
223
- $plugin_data = get_plugin_data( __FILE__ );
224
- $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
225
- $data = array(
226
- 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),
227
- 'posts' => $count_posts->publish,
228
- 'pages' => $count_pages->publish,
229
- 'comments' => $comments_count->total_comments,
230
- 'approved' => $comments_count->approved,
231
- 'spam' => $comments_count->spam,
232
- 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
233
- 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
234
- 'theme_version' => $plugin_data['Version'],
235
- 'theme_name' => $theme_name,
236
- 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
237
- 'plugins' => count( get_option( 'active_plugins' ) ),
238
- 'plugin' => urlencode( $plugin_name ),
239
- 'wpversion' => get_bloginfo( 'version' ),
240
- );
241
-
242
- foreach ( $data as $k => $v ) {
243
- $url .= $k . '/' . $v . '/';
244
- }
245
- wp_remote_get( $url );
246
- set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
247
- }
248
- }
249
- }
250
- // PressTrends WordPress Action
251
- add_action('admin_init', 'load_presstrends');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/lib/includes/backup.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Constants used by this plugin
5
- *
6
- * @package WP Backitup Pro
7
- *
8
- * @author jcpeden
9
- * @version 1.1.6
10
- * @since 1.1.3
11
- */
12
-
13
- //limit process to 15 minutes
14
- @set_time_limit(900);
15
-
16
- //Define variables
17
- $backup_project_dirname = get_bloginfo('name') .'-Export-' .date('Y-m-d-Hi');
18
- $backup_project_path = WPBACKITUP_DIRNAME ."/backups/". $backup_project_dirname .'/';
19
- $wp_content_path = dirname(dirname(dirname(dirname(dirname(__FILE__))))) .'/';
20
-
21
- //create the backup dir
22
- if( !is_dir(WPBACKITUP_DIRNAME ."/backups") ) {
23
- @mkdir(WPBACKITUP_DIRNAME ."/backups", 0775);
24
- }
25
-
26
- //create log file
27
- $log = WPBACKITUP_DIRNAME ."/backups/status.log";
28
- $fh = fopen($log, 'w') or die("can't open file");
29
- fwrite($fh, '<ul>');
30
-
31
- //Check to see if the directory is writeable
32
- fwrite($fh, '<li>Creating backup directory...');
33
- if(!is_writeable(WPBACKITUP_DIRNAME ."/backups/")) {
34
- fwrite($fh, '</li><li class="error">Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory.</li></ul>');
35
- die();
36
- } else {
37
- //If the directory is writeable, create the backup folder if it doesn't exist
38
- if( !is_dir($backup_project_path) ) {
39
- @mkdir($backup_project_path, 0775);
40
- fwrite($fh, 'Done!</li>');
41
- }
42
- foreach(glob(WPBACKITUP_DIRNAME ."/backups/*.zip") as $zip) {
43
- unlink($zip);
44
- }
45
- }
46
-
47
- //Backup content to project dir
48
- fwrite($fh, '<li>Backing up your files...');
49
- //Backup with copy
50
- if(recursive_copy($wp_content_path, $backup_project_path, $ignore = array( 'cgi-bin','.','..','._',$backup_project_dirname,'backupbuddy_backups','*.zip','cache' ) ) ) {
51
- fwrite($fh, 'Done!</li>');
52
- } else {
53
- fwrite($fh, '</li><li class="error">Unable to backup your files. Please try again.</li></ul>');
54
- die();
55
- }
56
-
57
- //Dump DB to project dir
58
- fwrite($fh, '<li>Backing up your database...');
59
- if( db_backup($backup_project_path) ) {
60
- fwrite($fh, 'Done!</li>');
61
- } else {
62
- fwrite($fh, '</li><li class="error">Unable to backup your database. Please try again.</li></ul>');
63
- recursive_delete($backup_project_path);
64
- die();
65
- }
66
-
67
- //Create siteinfo in project dir
68
- global $wpdb;
69
- if (!create_siteinfo($backup_project_path, $wpdb->prefix) ) {
70
- fwrite($fh, '<li class="error">Unable to create site information file. Please try again.</li></ul>');
71
- recursive_delete($backup_project_path);
72
- die();
73
- }
74
-
75
- //Zip the project dir
76
- fwrite($fh, '<li>Creating backup zip...');
77
- $z = new recurseZip();
78
- $src = rtrim($backup_project_path, '/');
79
- $z->compress($src, WPBACKITUP_DIRNAME ."/backups/");
80
- fwrite($fh, 'Done!</li>');
81
-
82
- //Delete backup dir
83
- if(!recursive_delete($backup_project_path)) {
84
- fwrite($fh, '<li class="error">Warning: Unable to cleanup your backup directory.</li>');
85
- }
86
-
87
- //close log file
88
- fwrite($fh, '<li>Backup file created successfully. You can download your backup file using the link above.</li>');
89
- fwrite($fh, '</ul>');
90
- fclose($fh);
91
-
92
- //End backup function
93
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/lib/recurse_zip.php DELETED
@@ -1 +0,0 @@
1
- <?php
2
  * Recurse zip function
3
  *
4
  * @package WP Backitup Pro
5
  *
6
  * @author jcpeden
7
  * @version 1.1.6
8
  * @since 1.1.3
9
  */
 
0
  * Recurse zip function
1
  *
2
  * @package WP Backitup Pro
3
  *
4
  * @author jcpeden
5
  * @version 1.1.6
6
  * @since 1.1.3
7
  */
tags/1.1.6/license.txt DELETED
@@ -1,674 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
- Preamble
9
-
10
- The GNU General Public License is a free, copyleft license for
11
- software and other kinds of works.
12
-
13
- The licenses for most software and other practical works are designed
14
- to take away your freedom to share and change the works. By contrast,
15
- the GNU General Public License is intended to guarantee your freedom to
16
- share and change all versions of a program--to make sure it remains free
17
- software for all its users. We, the Free Software Foundation, use the
18
- GNU General Public License for most of our software; it applies also to
19
- any other work released this way by its authors. You can apply it to
20
- your programs, too.
21
-
22
- When we speak of free software, we are referring to freedom, not
23
- price. Our General Public Licenses are designed to make sure that you
24
- have the freedom to distribute copies of free software (and charge for
25
- them if you wish), that you receive source code or can get it if you
26
- want it, that you can change the software or use pieces of it in new
27
- free programs, and that you know you can do these things.
28
-
29
- To protect your rights, we need to prevent others from denying you
30
- these rights or asking you to surrender the rights. Therefore, you have
31
- certain responsibilities if you distribute copies of the software, or if
32
- you modify it: responsibilities to respect the freedom of others.
33
-
34
- For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must pass on to the recipients the same
36
- freedoms that you received. You must make sure that they, too, receive
37
- or can get the source code. And you must show them these terms so they
38
- know their rights.
39
-
40
- Developers that use the GNU GPL protect your rights with two steps:
41
- (1) assert copyright on the software, and (2) offer you this License
42
- giving you legal permission to copy, distribute and/or modify it.
43
-
44
- For the developers' and authors' protection, the GPL clearly explains
45
- that there is no warranty for this free software. For both users' and
46
- authors' sake, the GPL requires that modified versions be marked as
47
- changed, so that their problems will not be attributed erroneously to
48
- authors of previous versions.
49
-
50
- Some devices are designed to deny users access to install or run
51
- modified versions of the software inside them, although the manufacturer
52
- can do so. This is fundamentally incompatible with the aim of
53
- protecting users' freedom to change the software. The systematic
54
- pattern of such abuse occurs in the area of products for individuals to
55
- use, which is precisely where it is most unacceptable. Therefore, we
56
- have designed this version of the GPL to prohibit the practice for those
57
- products. If such problems arise substantially in other domains, we
58
- stand ready to extend this provision to those domains in future versions
59
- of the GPL, as needed to protect the freedom of users.
60
-
61
- Finally, every program is threatened constantly by software patents.
62
- States should not allow patents to restrict development and use of
63
- software on general-purpose computers, but in those that do, we wish to
64
- avoid the special danger that patents applied to a free program could
65
- make it effectively proprietary. To prevent this, the GPL assures that
66
- patents cannot be used to render the program non-free.
67
-
68
- The precise terms and conditions for copying, distribution and
69
- modification follow.
70
-
71
- TERMS AND CONDITIONS
72
-
73
- 0. Definitions.
74
-
75
- "This License" refers to version 3 of the GNU General Public License.
76
-
77
- "Copyright" also means copyright-like laws that apply to other kinds of
78
- works, such as semiconductor masks.
79
-
80
- "The Program" refers to any copyrightable work licensed under this
81
- License. Each licensee is addressed as "you". "Licensees" and
82
- "recipients" may be individuals or organizations.
83
-
84
- To "modify" a work means to copy from or adapt all or part of the work
85
- in a fashion requiring copyright permission, other than the making of an
86
- exact copy. The resulting work is called a "modified version" of the
87
- earlier work or a work "based on" the earlier work.
88
-
89
- A "covered work" means either the unmodified Program or a work based
90
- on the Program.
91
-
92
- To "propagate" a work means to do anything with it that, without
93
- permission, would make you directly or secondarily liable for
94
- infringement under applicable copyright law, except executing it on a
95
- computer or modifying a private copy. Propagation includes copying,
96
- distribution (with or without modification), making available to the
97
- public, and in some countries other activities as well.
98
-
99
- To "convey" a work means any kind of propagation that enables other
100
- parties to make or receive copies. Mere interaction with a user through
101
- a computer network, with no transfer of a copy, is not conveying.
102
-
103
- An interactive user interface displays "Appropriate Legal Notices"
104
- to the extent that it includes a convenient and prominently visible
105
- feature that (1) displays an appropriate copyright notice, and (2)
106
- tells the user that there is no warranty for the work (except to the
107
- extent that warranties are provided), that licensees may convey the
108
- work under this License, and how to view a copy of this License. If
109
- the interface presents a list of user commands or options, such as a
110
- menu, a prominent item in the list meets this criterion.
111
-
112
- 1. Source Code.
113
-
114
- The "source code" for a work means the preferred form of the work
115
- for making modifications to it. "Object code" means any non-source
116
- form of a work.
117
-
118
- A "Standard Interface" means an interface that either is an official
119
- standard defined by a recognized standards body, or, in the case of
120
- interfaces specified for a particular programming language, one that
121
- is widely used among developers working in that language.
122
-
123
- The "System Libraries" of an executable work include anything, other
124
- than the work as a whole, that (a) is included in the normal form of
125
- packaging a Major Component, but which is not part of that Major
126
- Component, and (b) serves only to enable use of the work with that
127
- Major Component, or to implement a Standard Interface for which an
128
- implementation is available to the public in source code form. A
129
- "Major Component", in this context, means a major essential component
130
- (kernel, window system, and so on) of the specific operating system
131
- (if any) on which the executable work runs, or a compiler used to
132
- produce the work, or an object code interpreter used to run it.
133
-
134
- The "Corresponding Source" for a work in object code form means all
135
- the source code needed to generate, install, and (for an executable
136
- work) run the object code and to modify the work, including scripts to
137
- control those activities. However, it does not include the work's
138
- System Libraries, or general-purpose tools or generally available free
139
- programs which are used unmodified in performing those activities but
140
- which are not part of the work. For example, Corresponding Source
141
- includes interface definition files associated with source files for
142
- the work, and the source code for shared libraries and dynamically
143
- linked subprograms that the work is specifically designed to require,
144
- such as by intimate data communication or control flow between those
145
- subprograms and other parts of the work.
146
-
147
- The Corresponding Source need not include anything that users
148
- can regenerate automatically from other parts of the Corresponding
149
- Source.
150
-
151
- The Corresponding Source for a work in source code form is that
152
- same work.
153
-
154
- 2. Basic Permissions.
155
-
156
- All rights granted under this License are granted for the term of
157
- copyright on the Program, and are irrevocable provided the stated
158
- conditions are met. This License explicitly affirms your unlimited
159
- permission to run the unmodified Program. The output from running a
160
- covered work is covered by this License only if the output, given its
161
- content, constitutes a covered work. This License acknowledges your
162
- rights of fair use or other equivalent, as provided by copyright law.
163
-
164
- You may make, run and propagate covered works that you do not
165
- convey, without conditions so long as your license otherwise remains
166
- in force. You may convey covered works to others for the sole purpose
167
- of having them make modifications exclusively for you, or provide you
168
- with facilities for running those works, provided that you comply with
169
- the terms of this License in conveying all material for which you do
170
- not control copyright. Those thus making or running the covered works
171
- for you must do so exclusively on your behalf, under your direction
172
- and control, on terms that prohibit them from making any copies of
173
- your copyrighted material outside their relationship with you.
174
-
175
- Conveying under any other circumstances is permitted solely under
176
- the conditions stated below. Sublicensing is not allowed; section 10
177
- makes it unnecessary.
178
-
179
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
-
181
- No covered work shall be deemed part of an effective technological
182
- measure under any applicable law fulfilling obligations under article
183
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
- similar laws prohibiting or restricting circumvention of such
185
- measures.
186
-
187
- When you convey a covered work, you waive any legal power to forbid
188
- circumvention of technological measures to the extent such circumvention
189
- is effected by exercising rights under this License with respect to
190
- the covered work, and you disclaim any intention to limit operation or
191
- modification of the work as a means of enforcing, against the work's
192
- users, your or third parties' legal rights to forbid circumvention of
193
- technological measures.
194
-
195
- 4. Conveying Verbatim Copies.
196
-
197
- You may convey verbatim copies of the Program's source code as you
198
- receive it, in any medium, provided that you conspicuously and
199
- appropriately publish on each copy an appropriate copyright notice;
200
- keep intact all notices stating that this License and any
201
- non-permissive terms added in accord with section 7 apply to the code;
202
- keep intact all notices of the absence of any warranty; and give all
203
- recipients a copy of this License along with the Program.
204
-
205
- You may charge any price or no price for each copy that you convey,
206
- and you may offer support or warranty protection for a fee.
207
-
208
- 5. Conveying Modified Source Versions.
209
-
210
- You may convey a work based on the Program, or the modifications to
211
- produce it from the Program, in the form of source code under the
212
- terms of section 4, provided that you also meet all of these conditions:
213
-
214
- a) The work must carry prominent notices stating that you modified
215
- it, and giving a relevant date.
216
-
217
- b) The work must carry prominent notices stating that it is
218
- released under this License and any conditions added under section
219
- 7. This requirement modifies the requirement in section 4 to
220
- "keep intact all notices".
221
-
222
- c) You must license the entire work, as a whole, under this
223
- License to anyone who comes into possession of a copy. This
224
- License will therefore apply, along with any applicable section 7
225
- additional terms, to the whole of the work, and all its parts,
226
- regardless of how they are packaged. This License gives no
227
- permission to license the work in any other way, but it does not
228
- invalidate such permission if you have separately received it.
229
-
230
- d) If the work has interactive user interfaces, each must display
231
- Appropriate Legal Notices; however, if the Program has interactive
232
- interfaces that do not display Appropriate Legal Notices, your
233
- work need not make them do so.
234
-
235
- A compilation of a covered work with other separate and independent
236
- works, which are not by their nature extensions of the covered work,
237
- and which are not combined with it such as to form a larger program,
238
- in or on a volume of a storage or distribution medium, is called an
239
- "aggregate" if the compilation and its resulting copyright are not
240
- used to limit the access or legal rights of the compilation's users
241
- beyond what the individual works permit. Inclusion of a covered work
242
- in an aggregate does not cause this License to apply to the other
243
- parts of the aggregate.
244
-
245
- 6. Conveying Non-Source Forms.
246
-
247
- You may convey a covered work in object code form under the terms
248
- of sections 4 and 5, provided that you also convey the
249
- machine-readable Corresponding Source under the terms of this License,
250
- in one of these ways:
251
-
252
- a) Convey the object code in, or embodied in, a physical product
253
- (including a physical distribution medium), accompanied by the
254
- Corresponding Source fixed on a durable physical medium
255
- customarily used for software interchange.
256
-
257
- b) Convey the object code in, or embodied in, a physical product
258
- (including a physical distribution medium), accompanied by a
259
- written offer, valid for at least three years and valid for as
260
- long as you offer spare parts or customer support for that product
261
- model, to give anyone who possesses the object code either (1) a
262
- copy of the Corresponding Source for all the software in the
263
- product that is covered by this License, on a durable physical
264
- medium customarily used for software interchange, for a price no
265
- more than your reasonable cost of physically performing this
266
- conveying of source, or (2) access to copy the
267
- Corresponding Source from a network server at no charge.
268
-
269
- c) Convey individual copies of the object code with a copy of the
270
- written offer to provide the Corresponding Source. This
271
- alternative is allowed only occasionally and noncommercially, and
272
- only if you received the object code with such an offer, in accord
273
- with subsection 6b.
274
-
275
- d) Convey the object code by offering access from a designated
276
- place (gratis or for a charge), and offer equivalent access to the
277
- Corresponding Source in the same way through the same place at no
278
- further charge. You need not require recipients to copy the
279
- Corresponding Source along with the object code. If the place to
280
- copy the object code is a network server, the Corresponding Source
281
- may be on a different server (operated by you or a third party)
282
- that supports equivalent copying facilities, provided you maintain
283
- clear directions next to the object code saying where to find the
284
- Corresponding Source. Regardless of what server hosts the
285
- Corresponding Source, you remain obligated to ensure that it is
286
- available for as long as needed to satisfy these requirements.
287
-
288
- e) Convey the object code using peer-to-peer transmission, provided
289
- you inform other peers where the object code and Corresponding
290
- Source of the work are being offered to the general public at no
291
- charge under subsection 6d.
292
-
293
- A separable portion of the object code, whose source code is excluded
294
- from the Corresponding Source as a System Library, need not be
295
- included in conveying the object code work.
296
-
297
- A "User Product" is either (1) a "consumer product", which means any
298
- tangible personal property which is normally used for personal, family,
299
- or household purposes, or (2) anything designed or sold for incorporation
300
- into a dwelling. In determining whether a product is a consumer product,
301
- doubtful cases shall be resolved in favor of coverage. For a particular
302
- product received by a particular user, "normally used" refers to a
303
- typical or common use of that class of product, regardless of the status
304
- of the particular user or of the way in which the particular user
305
- actually uses, or expects or is expected to use, the product. A product
306
- is a consumer product regardless of whether the product has substantial
307
- commercial, industrial or non-consumer uses, unless such uses represent
308
- the only significant mode of use of the product.
309
-
310
- "Installation Information" for a User Product means any methods,
311
- procedures, authorization keys, or other information required to install
312
- and execute modified versions of a covered work in that User Product from
313
- a modified version of its Corresponding Source. The information must
314
- suffice to ensure that the continued functioning of the modified object
315
- code is in no case prevented or interfered with solely because
316
- modification has been made.
317
-
318
- If you convey an object code work under this section in, or with, or
319
- specifically for use in, a User Product, and the conveying occurs as
320
- part of a transaction in which the right of possession and use of the
321
- User Product is transferred to the recipient in perpetuity or for a
322
- fixed term (regardless of how the transaction is characterized), the
323
- Corresponding Source conveyed under this section must be accompanied
324
- by the Installation Information. But this requirement does not apply
325
- if neither you nor any third party retains the ability to install
326
- modified object code on the User Product (for example, the work has
327
- been installed in ROM).
328
-
329
- The requirement to provide Installation Information does not include a
330
- requirement to continue to provide support service, warranty, or updates
331
- for a work that has been modified or installed by the recipient, or for
332
- the User Product in which it has been modified or installed. Access to a
333
- network may be denied when the modification itself materially and
334
- adversely affects the operation of the network or violates the rules and
335
- protocols for communication across the network.
336
-
337
- Corresponding Source conveyed, and Installation Information provided,
338
- in accord with this section must be in a format that is publicly
339
- documented (and with an implementation available to the public in
340
- source code form), and must require no special password or key for
341
- unpacking, reading or copying.
342
-
343
- 7. Additional Terms.
344
-
345
- "Additional permissions" are terms that supplement the terms of this
346
- License by making exceptions from one or more of its conditions.
347
- Additional permissions that are applicable to the entire Program shall
348
- be treated as though they were included in this License, to the extent
349
- that they are valid under applicable law. If additional permissions
350
- apply only to part of the Program, that part may be used separately
351
- under those permissions, but the entire Program remains governed by
352
- this License without regard to the additional permissions.
353
-
354
- When you convey a copy of a covered work, you may at your option
355
- remove any additional permissions from that copy, or from any part of
356
- it. (Additional permissions may be written to require their own
357
- removal in certain cases when you modify the work.) You may place
358
- additional permissions on material, added by you to a covered work,
359
- for which you have or can give appropriate copyright permission.
360
-
361
- Notwithstanding any other provision of this License, for material you
362
- add to a covered work, you may (if authorized by the copyright holders of
363
- that material) supplement the terms of this License with terms:
364
-
365
- a) Disclaiming warranty or limiting liability differently from the
366
- terms of sections 15 and 16 of this License; or
367
-
368
- b) Requiring preservation of specified reasonable legal notices or
369
- author attributions in that material or in the Appropriate Legal
370
- Notices displayed by works containing it; or
371
-
372
- c) Prohibiting misrepresentation of the origin of that material, or
373
- requiring that modified versions of such material be marked in
374
- reasonable ways as different from the original version; or
375
-
376
- d) Limiting the use for publicity purposes of names of licensors or
377
- authors of the material; or
378
-
379
- e) Declining to grant rights under trademark law for use of some
380
- trade names, trademarks, or service marks; or
381
-
382
- f) Requiring indemnification of licensors and authors of that
383
- material by anyone who conveys the material (or modified versions of
384
- it) with contractual assumptions of liability to the recipient, for
385
- any liability that these contractual assumptions directly impose on
386
- those licensors and authors.
387
-
388
- All other non-permissive additional terms are considered "further
389
- restrictions" within the meaning of section 10. If the Program as you
390
- received it, or any part of it, contains a notice stating that it is
391
- governed by this License along with a term that is a further
392
- restriction, you may remove that term. If a license document contains
393
- a further restriction but permits relicensing or conveying under this
394
- License, you may add to a covered work material governed by the terms
395
- of that license document, provided that the further restriction does
396
- not survive such relicensing or conveying.
397
-
398
- If you add terms to a covered work in accord with this section, you
399
- must place, in the relevant source files, a statement of the
400
- additional terms that apply to those files, or a notice indicating
401
- where to find the applicable terms.
402
-
403
- Additional terms, permissive or non-permissive, may be stated in the
404
- form of a separately written license, or stated as exceptions;
405
- the above requirements apply either way.
406
-
407
- 8. Termination.
408
-
409
- You may not propagate or modify a covered work except as expressly
410
- provided under this License. Any attempt otherwise to propagate or
411
- modify it is void, and will automatically terminate your rights under
412
- this License (including any patent licenses granted under the third
413
- paragraph of section 11).
414
-
415
- However, if you cease all violation of this License, then your
416
- license from a particular copyright holder is reinstated (a)
417
- provisionally, unless and until the copyright holder explicitly and
418
- finally terminates your license, and (b) permanently, if the copyright
419
- holder fails to notify you of the violation by some reasonable means
420
- prior to 60 days after the cessation.
421
-
422
- Moreover, your license from a particular copyright holder is
423
- reinstated permanently if the copyright holder notifies you of the
424
- violation by some reasonable means, this is the first time you have
425
- received notice of violation of this License (for any work) from that
426
- copyright holder, and you cure the violation prior to 30 days after
427
- your receipt of the notice.
428
-
429
- Termination of your rights under this section does not terminate the
430
- licenses of parties who have received copies or rights from you under
431
- this License. If your rights have been terminated and not permanently
432
- reinstated, you do not qualify to receive new licenses for the same
433
- material under section 10.
434
-
435
- 9. Acceptance Not Required for Having Copies.
436
-
437
- You are not required to accept this License in order to receive or
438
- run a copy of the Program. Ancillary propagation of a covered work
439
- occurring solely as a consequence of using peer-to-peer transmission
440
- to receive a copy likewise does not require acceptance. However,
441
- nothing other than this License grants you permission to propagate or
442
- modify any covered work. These actions infringe copyright if you do
443
- not accept this License. Therefore, by modifying or propagating a
444
- covered work, you indicate your acceptance of this License to do so.
445
-
446
- 10. Automatic Licensing of Downstream Recipients.
447
-
448
- Each time you convey a covered work, the recipient automatically
449
- receives a license from the original licensors, to run, modify and
450
- propagate that work, subject to this License. You are not responsible
451
- for enforcing compliance by third parties with this License.
452
-
453
- An "entity transaction" is a transaction transferring control of an
454
- organization, or substantially all assets of one, or subdividing an
455
- organization, or merging organizations. If propagation of a covered
456
- work results from an entity transaction, each party to that
457
- transaction who receives a copy of the work also receives whatever
458
- licenses to the work the party's predecessor in interest had or could
459
- give under the previous paragraph, plus a right to possession of the
460
- Corresponding Source of the work from the predecessor in interest, if
461
- the predecessor has it or can get it with reasonable efforts.
462
-
463
- You may not impose any further restrictions on the exercise of the
464
- rights granted or affirmed under this License. For example, you may
465
- not impose a license fee, royalty, or other charge for exercise of
466
- rights granted under this License, and you may not initiate litigation
467
- (including a cross-claim or counterclaim in a lawsuit) alleging that
468
- any patent claim is infringed by making, using, selling, offering for
469
- sale, or importing the Program or any portion of it.
470
-
471
- 11. Patents.
472
-
473
- A "contributor" is a copyright holder who authorizes use under this
474
- License of the Program or a work on which the Program is based. The
475
- work thus licensed is called the contributor's "contributor version".
476
-
477
- A contributor's "essential patent claims" are all patent claims
478
- owned or controlled by the contributor, whether already acquired or
479
- hereafter acquired, that would be infringed by some manner, permitted
480
- by this License, of making, using, or selling its contributor version,
481
- but do not include claims that would be infringed only as a
482
- consequence of further modification of the contributor version. For
483
- purposes of this definition, "control" includes the right to grant
484
- patent sublicenses in a manner consistent with the requirements of
485
- this License.
486
-
487
- Each contributor grants you a non-exclusive, worldwide, royalty-free
488
- patent license under the contributor's essential patent claims, to
489
- make, use, sell, offer for sale, import and otherwise run, modify and
490
- propagate the contents of its contributor version.
491
-
492
- In the following three paragraphs, a "patent license" is any express
493
- agreement or commitment, however denominated, not to enforce a patent
494
- (such as an express permission to practice a patent or covenant not to
495
- sue for patent infringement). To "grant" such a patent license to a
496
- party means to make such an agreement or commitment not to enforce a
497
- patent against the party.
498
-
499
- If you convey a covered work, knowingly relying on a patent license,
500
- and the Corresponding Source of the work is not available for anyone
501
- to copy, free of charge and under the terms of this License, through a
502
- publicly available network server or other readily accessible means,
503
- then you must either (1) cause the Corresponding Source to be so
504
- available, or (2) arrange to deprive yourself of the benefit of the
505
- patent license for this particular work, or (3) arrange, in a manner
506
- consistent with the requirements of this License, to extend the patent
507
- license to downstream recipients. "Knowingly relying" means you have
508
- actual knowledge that, but for the patent license, your conveying the
509
- covered work in a country, or your recipient's use of the covered work
510
- in a country, would infringe one or more identifiable patents in that
511
- country that you have reason to believe are valid.
512
-
513
- If, pursuant to or in connection with a single transaction or
514
- arrangement, you convey, or propagate by procuring conveyance of, a
515
- covered work, and grant a patent license to some of the parties
516
- receiving the covered work authorizing them to use, propagate, modify
517
- or convey a specific copy of the covered work, then the patent license
518
- you grant is automatically extended to all recipients of the covered
519
- work and works based on it.
520
-
521
- A patent license is "discriminatory" if it does not include within
522
- the scope of its coverage, prohibits the exercise of, or is
523
- conditioned on the non-exercise of one or more of the rights that are
524
- specifically granted under this License. You may not convey a covered
525
- work if you are a party to an arrangement with a third party that is
526
- in the business of distributing software, under which you make payment
527
- to the third party based on the extent of your activity of conveying
528
- the work, and under which the third party grants, to any of the
529
- parties who would receive the covered work from you, a discriminatory
530
- patent license (a) in connection with copies of the covered work
531
- conveyed by you (or copies made from those copies), or (b) primarily
532
- for and in connection with specific products or compilations that
533
- contain the covered work, unless you entered into that arrangement,
534
- or that patent license was granted, prior to 28 March 2007.
535
-
536
- Nothing in this License shall be construed as excluding or limiting
537
- any implied license or other defenses to infringement that may
538
- otherwise be available to you under applicable patent law.
539
-
540
- 12. No Surrender of Others' Freedom.
541
-
542
- If conditions are imposed on you (whether by court order, agreement or
543
- otherwise) that contradict the conditions of this License, they do not
544
- excuse you from the conditions of this License. If you cannot convey a
545
- covered work so as to satisfy simultaneously your obligations under this
546
- License and any other pertinent obligations, then as a consequence you may
547
- not convey it at all. For example, if you agree to terms that obligate you
548
- to collect a royalty for further conveying from those to whom you convey
549
- the Program, the only way you could satisfy both those terms and this
550
- License would be to refrain entirely from conveying the Program.
551
-
552
- 13. Use with the GNU Affero General Public License.
553
-
554
- Notwithstanding any other provision of this License, you have
555
- permission to link or combine any covered work with a work licensed
556
- under version 3 of the GNU Affero General Public License into a single
557
- combined work, and to convey the resulting work. The terms of this
558
- License will continue to apply to the part which is the covered work,
559
- but the special requirements of the GNU Affero General Public License,
560
- section 13, concerning interaction through a network will apply to the
561
- combination as such.
562
-
563
- 14. Revised Versions of this License.
564
-
565
- The Free Software Foundation may publish revised and/or new versions of
566
- the GNU General Public License from time to time. Such new versions will
567
- be similar in spirit to the present version, but may differ in detail to
568
- address new problems or concerns.
569
-
570
- Each version is given a distinguishing version number. If the
571
- Program specifies that a certain numbered version of the GNU General
572
- Public License "or any later version" applies to it, you have the
573
- option of following the terms and conditions either of that numbered
574
- version or of any later version published by the Free Software
575
- Foundation. If the Program does not specify a version number of the
576
- GNU General Public License, you may choose any version ever published
577
- by the Free Software Foundation.
578
-
579
- If the Program specifies that a proxy can decide which future
580
- versions of the GNU General Public License can be used, that proxy's
581
- public statement of acceptance of a version permanently authorizes you
582
- to choose that version for the Program.
583
-
584
- Later license versions may give you additional or different
585
- permissions. However, no additional obligations are imposed on any
586
- author or copyright holder as a result of your choosing to follow a
587
- later version.
588
-
589
- 15. Disclaimer of Warranty.
590
-
591
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
-
600
- 16. Limitation of Liability.
601
-
602
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
- SUCH DAMAGES.
611
-
612
- 17. Interpretation of Sections 15 and 16.
613
-
614
- If the disclaimer of warranty and limitation of liability provided
615
- above cannot be given local legal effect according to their terms,
616
- reviewing courts shall apply local law that most closely approximates
617
- an absolute waiver of all civil liability in connection with the
618
- Program, unless a warranty or assumption of liability accompanies a
619
- copy of the Program in return for a fee.
620
-
621
- END OF TERMS AND CONDITIONS
622
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
628
-
629
- To do so, attach the following notices to the program. It is safest
630
- to attach them to the start of each source file to most effectively
631
- state the exclusion of warranty; and each file should have at least
632
- the "copyright" line and a pointer to where the full notice is found.
633
-
634
- <one line to give the program's name and a brief idea of what it does.>
635
- Copyright (C) <year> <name of author>
636
-
637
- This program is free software: you can redistribute it and/or modify
638
- it under the terms of the GNU General Public License as published by
639
- the Free Software Foundation, either version 3 of the License, or
640
- (at your option) any later version.
641
-
642
- This program is distributed in the hope that it will be useful,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
644
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
- GNU General Public License for more details.
646
-
647
- You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <http://www.gnu.org/licenses/>.
649
-
650
- Also add information on how to contact you by electronic and paper mail.
651
-
652
- If the program does terminal interaction, make it output a short
653
- notice like this when it starts in an interactive mode:
654
-
655
- <program> Copyright (C) <year> <name of author>
656
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
- This is free software, and you are welcome to redistribute it
658
- under certain conditions; type `show c' for details.
659
-
660
- The hypothetical commands `show w' and `show c' should show the appropriate
661
- parts of the General Public License. Of course, your program's commands
662
- might be different; for a GUI interface, you would use an "about box".
663
-
664
- You should also get your employer (if you work as a programmer) or school,
665
- if any, to sign a "copyright disclaimer" for the program, if necessary.
666
- For more information on this, and how to apply and follow the GNU GPL, see
667
- <http://www.gnu.org/licenses/>.
668
-
669
- The GNU General Public License does not permit incorporating your program
670
- into proprietary programs. If your program is a subroutine library, you
671
- may consider it more useful to permit linking proprietary applications with
672
- the library. If this is what you want to do, use the GNU Lesser General
673
- Public License instead of this License. But first, please read
674
- <http://www.gnu.org/philosophy/why-not-lgpl.html>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/readme.txt DELETED
@@ -1,201 +0,0 @@
1
- === WP Backitup Lite ===
2
- Contributors: jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup wordpress, database backup, backup database, download database, backup and restore, restoring wordpress, restore wordpress, restore wordpress backup,
5
- Requires at least: 3.4
6
- Tested up to: 3.5.1
7
- Stable tag: 1.1.6
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Create a backup zip of your content and settings with a single click that can be used to restore your site quickly and easily.
12
-
13
- == Description ==
14
-
15
- = The Simple Way to Backup Your Site =
16
- WP Backitup Lite creates a backup zip of your site&apos;s content and configuration in just a single click,
17
- right from your Wordpress dashboard. There is no need to FTP into your site and no knowledge of MySQL or PHPMyAdmin is required.
18
-
19
- You can use your backup zip to restore your site or to clone a site&apos;s content and settings when setting up a new one.
20
-
21
- = Automatically Restore Your Backup Zips =
22
- Tired of messing around in PHPMyAdmin and with FTP trying to restore you backups? Why not check out <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>? WP Backitup Pro offers all the features of WP Backitup Lite but allows you to import your backup zips in seconds, right from the Wordpress Dashboard (<a href="http://wordpress.org/extend/plugins/wp-backitup/screenshots/" title="WP Backitup Screenshots">screenshots</a>).
23
-
24
- = Manually Restore Your Backup Zips =
25
- WP Backitup generates a zip file containing a copy of your wp-content directory and a database dump. You can unzip it and <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">import your database</a> and files manually but this requires knowledge of FTP and MySQL.
26
-
27
- = Easy To Install and Use =
28
- Simply install the plugin directly to Wordpress and browse to the new menu 'Backup/Restore'. From there, just follow the on-screen instructions and watch as WP Backitup creates a backup of you site's plugins, themes and uploads as well as you content and settings (including all custom widgets and settings for any additional plugins).
29
-
30
- = More questions? =
31
- Why not head over to the <a href="http://www.wpbackitup.com/" title="WP Backitup">WP Backitup site</a> or take a look at the <a href="http://www.wpbackitup.com/support/" title="WP Backitup Support Forum">WP Backitup Support Forum</a>, if you need more help?
32
-
33
- == Installation ==
34
-
35
- Installation of the plugin is straightforward:
36
-
37
- 1. Upload the plugin to your plugins directory via FTP or through the Wordpress dashboard.
38
- 1. Activate the plugin.
39
- 1. A new menu called 'Backup/Restore' will be added to your toolbar.
40
- 1. Click 'Backup/Restore' to access WP-Backitup
41
-
42
- == Frequently Asked Questions ==
43
-
44
- = Can I manually restore my backup zips? =
45
- Sure! The backup zips generated by WP Backitup contain a database dump and a copy of your wp-content directory. Simply upload your files and import your database.
46
-
47
- = Is there an easier way to restore my backup zips? =
48
- Yes, purchase and download <a href="http://www.wpbackitup.com/wp-backitup-pro/" title="WP Backitup Pro">WP Backitup Pro</a>. Once installed, you'll be able to restore you backup zips without FTP or MySQL.
49
-
50
- = Will the plugin work on shared hosting/sub domains/webhost xxx? =
51
- Yes.
52
-
53
- = Will WP Backitup work on Windows hosting? =
54
- Yes.
55
-
56
- = Are you going to be making progress bars both for backing up and restoring with this plugin? =
57
- It is likely this will feature in a new version of WP Backitup Pro.
58
-
59
- = Can this plugin back to Amazon S3? =
60
- This will feature in an upcoming version of WP Backitup Pro.
61
-
62
- = Is there an auto back up schedule feature? =
63
- It is likely this will feature in a new version of WP Backitup Pro.
64
-
65
- = Will the plugin work with Wordpres version x.x? =
66
- The plugin works on the latest release of WordPress and is updated to function with all new releases.
67
-
68
- = Can this backup one version of WordPress to a different version? =
69
- No. It is absolutely critical that your WordPress versions are exactly the same.
70
-
71
- = Will WP Backitup work on WordPress Multisite? =
72
- WP Backitup cannot yet backup/restore entire networks but it is compatible with WPMS sites.
73
-
74
- = Does the plugin copy the database details as well? =
75
- Yes, a database dump is created with each backup.
76
-
77
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and load in a basic themplate? =
78
- Yes. WP Backitup can be used to create a good starting point for any and all sites you work on.
79
-
80
- = Does WP Backitup need to be installed? =
81
- Yes. You must install the WP Backitup plugin on the site you wish to backup and the site you wish to restore to. Its just a simple plugin.
82
-
83
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
84
- WP Backitup creates a database dump and a backup of all your themes, plugins and uploads.
85
-
86
- = Do you have any ideas about how large a blog is too big for WP Backitup to handle? =
87
- I`ve tested up to 5 themes, 20 plugins and 100 posts/pages without any issues.
88
-
89
- = Do you do regularly update this product to match with WP version updates? =
90
- Yes.
91
-
92
- == Screenshots ==
93
- 1. Once activated, the plugin loads a new menu into your toolbar.
94
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
95
- 3. When the backup has been created, click the download link to access a zipped backup of your site.
96
-
97
- == Changelog ==
98
-
99
- = 1.1.6 =
100
- * Forced backup process to ignore cache files
101
-
102
- = 1.1.5 =
103
- * Fixed minor bugs in the code.
104
-
105
- = 1.1.4 =
106
- * Fixed minor bugs in tracking code and options.
107
-
108
- = 1.1.3 =
109
- * Re-wrote plugin in OOP, added option to disable Presstrends tracking code.
110
-
111
- = 1.1.2 =
112
- * Fixed issue with stylesheet not being loaded.
113
-
114
- = 1.1.1 =
115
- * Fixed issue with plugin not detecing addons
116
-
117
- = 1.1.0 =
118
- * Fixed bugs with addons system.
119
-
120
- = 1.0.9 =
121
- * Added Presstrends tracking code.
122
-
123
- = 1.0.8 =
124
- * Modified plugin administration and loaded menu tab in main toolbar.
125
-
126
- = 1.0.7 =
127
- * Added hooks to plugin to allow addons to be built and loaded into the free version of the theme, distributed through the Wordpress plugin repository. Backups were also limited to 20MB to ensure that the processes actually complete.
128
-
129
- = 1.0.6 =
130
- * Initial free version of the plugin distributed on Wordpress. This version can only backup.
131
-
132
- = 1.0.5 =
133
- * Modified backup to use AJAX and restore to use AJAX-like functionality. Added read-write for options so they are saved to DB on exit.
134
-
135
- = 1.0.4 =
136
- * Reduced the size of the plugin by re-using code. Added support for multiple table prefixes and media library import.
137
-
138
- = 1.0.3 =
139
- * Removed redundant code, allowed plugin to work with multiple table prefixes and user IDs other than 1.
140
-
141
- = 1.0.2 =
142
- * Fixed backup/restore function of database, plugins and themes dir. Removed PHP error notices if options are not set on admin page
143
-
144
- = 1.0.1 =
145
- * Increased PHP timeout to 900 seconds (5 minutes).
146
-
147
- = 1.0 =
148
- * Plugin released.
149
-
150
- == Upgrade Notice ==
151
-
152
- = 1.1.6 =
153
- * Recommended upgrade. Backup process faster and more stable.
154
-
155
- = 1.1.5 =
156
- * Non-critical upgrade. Fixed minor bugs in code.
157
-
158
- = 1.1.4 =
159
- * Non-critical upgrade. Fixed bugs in code.
160
-
161
- = 1.1.3 =
162
- * Non-critical upgrade. Re-wrote plugin in object-oriented PHP.
163
-
164
- = 1.1.2 =
165
- * Critical upgrade. Fixed issue with stylesheet.
166
-
167
- = 1.1.1 =
168
- * Critical upgrade. Fixed further bugs with addons system.
169
-
170
- = 1.1.0 =
171
- * Non-critical upgrade. Fixed bugs with addons system that caused problems for some users.
172
-
173
- = 1.0.9 =
174
- * Non-essential upgrade. Added Presstrends code.
175
-
176
- = 1.0.8 =
177
- * Recommended upgrade. Added links to admin menu.
178
-
179
- = 1.0.7 =
180
- * Critical upgrade. Totally overhauled the plugin's construction, stability and features.
181
-
182
- = 1.0.6 =
183
- * Non-critical upgrade.
184
-
185
- = 1.0.5 =
186
- * Critical upgrade: More stable, increased flexibility and power.
187
-
188
- = 1.0.4 =
189
- * Critical upgrade: Many people have had trouble prior to this release. Flexibility has been increased and the plugin is now more stable and lightweight.
190
-
191
- = 1.0.3 =
192
- * Recommended upgrade: The plugin is more flexible and offers more helpful status and error messages.
193
-
194
- = 1.0.2 =
195
- * Critical upgrade: Plugin does not work on most systems without this upgrade
196
-
197
- = 1.0.1 =
198
- * This version increases PHP timeout if possible (upgrade if you are having timeout errors).
199
-
200
- = 1.0 =
201
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.1.6/screenshots/screenshot-1.png DELETED
Binary file
tags/1.1.6/screenshots/screenshot-2.png DELETED
Binary file
tags/1.1.6/screenshots/screenshot-3.png DELETED
Binary file
tags/1.1.6/views/options.php DELETED
@@ -1,46 +0,0 @@
1
- <div class="wrap">
2
- <div id="wp-backitup-icon" class="icon32"><img src="<?php echo plugin_dir_url(dirname(__FILE__) ); ?>images/icon32.png" alt="WP Backitup Icon" height="32" width="32" /></div>
3
- <h2><?php echo $page_title; ?></h2>
4
- <div id="content">
5
- <h3><?php _e('Backup', $this->namespace ); ?></h3>
6
- <p><?php _e('Create a backup file of this site\'s content and settings.', $this->namespace ); ?></p>
7
- <p><a href="#" class="backup-button button-primary"><?php _e( "Backup", $this->namespace ); ?> ) ?></a><img class="backup-icon status-icon" src="<?php echo WPBACKITUP_URLPATH. "/images/loader.gif"; ?>" height="16" width="16" /></p>
8
- <h3>Download</h3>
9
- <p><div id="download-link"></div></p>
10
- <h3>Status</h3>
11
- <p><div id="status">Nothing to report</div></p>
12
- </div>
13
- <div id="sidebar">
14
- <div class="widget" id="restore-widget">
15
- <h3 class="promo">Restore Your Backups</h3>
16
- <p>You can restore your backup zips by importing them manually or by getting WP Backitup Pro.</p>
17
- <p><a class="button-primary" href="http://www.wpbackitup.com/wp-backitup-pro/">Read more</a></p>
18
- </div>
19
- <div class="widget">
20
- <h3 class="promo">Need support?</h3>
21
- <p>If you are having problems with this plugin please talk about them in the <a href="http://wordpress.org/support/plugin/wp-backitup">support forum</a>.</p>
22
- <p>You can also refer to the <a href="http://www.wpbackitup.com/documentation/">WP Backitup documentation</a>.</p>
23
- </div>
24
- <div class="widget">
25
- <h3 class="promo">Spread the Word!</h3>
26
- <p>Want to help make WP Backitup even better? All donations are used to improve this plugin, so donate $10, $20 or $50 now!</p>
27
- <p><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
28
- <input type="hidden" name="cmd" value="_s-xclick">
29
- <input type="hidden" name="hosted_button_id" value="QSHPK8EDMAW9N">
30
- <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
31
- <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
32
- </form></p>
33
- <p>Or you could <a href="http://wordpress.org/extend/plugins/wp-backitup/">rate the plugin 5&#9733; on Wordpress.org</a>.</p>
34
- </div>
35
- <div class="widget">
36
- <h3 class="promo">Presstrends</h3>
37
- <form action="" method="post" id="<?php echo $namespace; ?>-form">
38
- <?php wp_nonce_field( $namespace . "-update-options" ); ?>
39
- <p><input type="radio" name="data[presstrends]" value="enabled" <?php if($this->get_option( 'presstrends' ) == 'enabled') echo 'checked'; ?>> <label>Enable</label></p>
40
- <p><input type="radio" name="data[presstrends]" value="disabled" <?php if($this->get_option( 'presstrends' ) == 'disabled') echo 'checked'; ?>> <label>Disable</label></p>
41
- <p>Help to improve Easy Webtrends by enabling <a href="http://www.presstrends.io" target="_blank">Presstrends</a>.</p>
42
- <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( "Save", $namespace ) ?>" /></p>
43
- </form>
44
- </div>
45
- </div>
46
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/css/wpbackitup_admin.css DELETED
@@ -1,126 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel Stylesheets
3
- *
4
- * @version 1.4.0
5
- * @since 1.0.1
6
- */
7
-
8
- /* Global */
9
-
10
- .error { color: #ff0000;}
11
- .warning { color: #FEEFB3;}
12
- .wpbackitup-warning { color: #FF8000;}
13
-
14
- .isa_info, .isa_success, .isa_warning, .isa_error {
15
- border: 1px solid;
16
- margin: 10px 0px;
17
- padding:15px 10px 15px 50px;
18
- background-repeat: no-repeat;
19
- background-position: 10px center;-moz-border-radius:.5em;
20
- -webkit-border-radius:.5em;
21
- border-radius:.5em;
22
-
23
- }
24
- .isa_info {
25
- color: #00529B;
26
- background-color: #BDE5F8;
27
- background-image: url('../images/info.png');
28
- }
29
- .isa_success {
30
- color: #4F8A10;
31
- background-color: #DFF2BF;
32
- background-image:url('../images/success.png');
33
- }
34
- .isa_warning {
35
- color: #9F6000;
36
- background-color: #FEEFB3;
37
- background-image: url('../images/warning.png');
38
- }
39
- .isa_error {
40
- color: #D8000C;
41
- background-color: #FFBABA;
42
- background-image: url('../images/error.png');
43
- }
44
-
45
- p {line-height: 1.4em;}
46
-
47
- td {padding: 0;}
48
-
49
- h3 {
50
- margin: 0;
51
- padding: 0 0 0 0;
52
- border-bottom: 1px solid #eee;
53
- }
54
-
55
- .wp-backitup-iframe {
56
- height: 0;
57
- margin: 0;
58
- padding: 0;
59
- position: absolute;
60
- top: 0;
61
- right: 0;
62
- width: 0;
63
- z-index: -1;
64
- }
65
-
66
- .submit { padding: 0; }
67
-
68
-
69
- /* Content */
70
- #content {
71
- float: left;
72
- width: 65%;
73
- }
74
-
75
- #content input[type="text"], #content input[type="file"] {padding: 0;}
76
-
77
- .status-icon {
78
- display: inline;
79
- height: 16px;
80
- position: relative;
81
- top: 3px;
82
- left: 5px;
83
- visibility: hidden;
84
- width: 16px;
85
- }
86
-
87
- /** Status Reporting **/
88
- .backup-status,
89
- .backup-status span,
90
-
91
- .backup-errors,
92
- .backup-errors div,
93
- .backup-error,
94
-
95
- .backup-warning,
96
- .backup-warning div,
97
-
98
- .backup-success,
99
- .backup-success div,
100
-
101
- .restore-status,
102
- .restore-status span,
103
-
104
- .restore-errors,
105
- .restore-errors div,
106
-
107
- .restore-success,
108
- .restore-success div,
109
-
110
- .upload-status,
111
- .upload-status span
112
- {
113
- display: none;
114
- }
115
-
116
- /* Sidebar */
117
- #sidebar {
118
- float: right;
119
- width: 30%;
120
- }
121
-
122
- .widget {
123
- padding: 1em;
124
- background-color: white;
125
- margin: 20px;
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/images/error.png DELETED
Binary file
tags/1.10.0/images/icon.png DELETED
Binary file
tags/1.10.0/images/icon32.png DELETED
Binary file
tags/1.10.0/images/info.png DELETED
Binary file
tags/1.10.0/images/loader.gif DELETED
Binary file
tags/1.10.0/images/success.png DELETED
Binary file
tags/1.10.0/images/warning.png DELETED
Binary file
tags/1.10.0/js/wpbackitup_admin.js DELETED
@@ -1,1085 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel JavaScripts
3
- *
4
- * @version 1.4.0
5
- * @since 1.0.1
6
- */
7
-
8
- (function($){
9
- var namespace = 'wp-backitup';
10
-
11
- //Add View Log Click event to backup page
12
- wpbackitup_add_viewlog_onclick();
13
-
14
- //Add download backup Click event to backup page
15
- wpbackitup_add_downloadbackup_onclick();
16
-
17
- /* define logreader variables */
18
- var wpbackitup_restore_status_reader = {
19
- action: wpbackitup_get_action_name('restore_status_reader')
20
- };
21
-
22
- var wpbackitup_backup_status_reader = {
23
- action: wpbackitup_get_action_name('backup_status_reader')
24
- };
25
-
26
- //UPLOADS
27
- try {
28
- plupload_init(wpbackitup_plupload_config);
29
- } catch (err) {
30
- console.log(err);
31
- }
32
-
33
- $( "#scheduled-backups-accordian" ).click(function() {
34
-
35
- scheduled_backups=$("#scheduled-backups");
36
- scheduled_backups_button = $( "#scheduled-backups-accordian");
37
-
38
- if ($(this).is(".fa-angle-double-down")){
39
- scheduled_backups.fadeIn( "slow" )
40
- scheduled_backups_button.toggleClass( "fa-angle-double-down", false);
41
- scheduled_backups_button.toggleClass( "fa-angle-double-up", true);
42
- } else{
43
- scheduled_backups_button.toggleClass( "fa-angle-double-down", true);
44
- scheduled_backups_button.toggleClass( "fa-angle-double-up", false);
45
- scheduled_backups.fadeOut( "slow" )
46
- }
47
-
48
- });
49
-
50
- $( "#upload-backups-accordian" ).click(function() {
51
-
52
- upload_backups=$("#wpbackitup-plupload-modal");
53
- upload_backups_button = $( "#upload-backups-accordian");
54
-
55
- if ($(this).is(".fa-angle-double-down")){
56
- upload_backups.fadeIn( "slow" )
57
- upload_backups_button.toggleClass( "fa-angle-double-down", false);
58
- upload_backups_button.toggleClass( "fa-angle-double-up", true);
59
- } else{
60
- upload_backups_button.toggleClass( "fa-angle-double-down", true);
61
- upload_backups_button.toggleClass( "fa-angle-double-up", false);
62
- upload_backups.fadeOut( "slow" )
63
- }
64
-
65
- });
66
-
67
- //binds to onchange event of the upload file input field
68
- $('#wpbackitup-zip').bind('change', function() {
69
-
70
- //this.files[0].size gets the size of your file.
71
- var upload_file_size = this.files[0].size;
72
- var max_file_size = $('#maxfilesize').val();
73
-
74
- //IF Not supported by browser just check on server
75
- if (upload_file_size == 'undefined' ||
76
- max_file_size == 'undefined' ||
77
- upload_file_size == '' ||
78
- max_file_size =='')
79
- {
80
- return;
81
- }
82
-
83
- if (upload_file_size > max_file_size){
84
- alert('The backup you have selected exceeds what your host allows you to upload.');
85
- $("#wpbackitup-zip").val("");
86
- }
87
- });
88
-
89
-
90
-
91
- function wpbackitup_add_viewlog_onclick(){
92
- $(".viewloglink").click(function(){
93
- var href = $(this).attr("href");
94
- $("#backup_name").val(href);
95
- $("#viewlog").submit();
96
- return false;
97
- });
98
- }
99
-
100
- function wpbackitup_add_downloadbackup_onclick(){
101
- $(".downloadbackuplink").click(function(){
102
- var href = $(this).attr("href");
103
- $("#backup_file").val(href);
104
- $("#download_backup").submit();
105
- return false;
106
- });
107
- }
108
-
109
- /* get restore status */
110
- function wpbackitup_get_restore_status() {
111
- $.post(ajaxurl, wpbackitup_restore_status_reader, function(response) {
112
- /* Get response from log reader */
113
- var xmlObj = $(response);
114
-
115
- /* For each response */
116
- xmlObj.each(function() {
117
-
118
- /* Select correct status */
119
- var attributename = "." + $(this).attr('class');
120
- var icon_attributename = "." + $(this).attr('class') + '-icon';
121
-
122
- //Hide all
123
- if ( $(this).html() == 0 ) {
124
-
125
- $(attributename).find(".status").hide();
126
- $(attributename).find(".status-icon").hide();
127
-
128
- }
129
-
130
- //Processing
131
- if ( $(this).html() == 1 ) {
132
-
133
- $(icon_attributename).css('visibility', 'visible');
134
- $(attributename).find(".status").fadeOut(200);
135
- $(attributename).find(".status-icon").fadeIn(1500);
136
-
137
- }
138
-
139
- //Done
140
- if ( $(this).html() == 2 ) {
141
-
142
- /* If status returns 1, display 'Done' or show detailed message */
143
- $(attributename).find(".status-icon").fadeOut(200);
144
- $(attributename).find(".status").fadeIn(1500);
145
-
146
- }
147
-
148
- //Fatal Error
149
- if ( $(this).html() == -1 ) {
150
-
151
- $(attributename).find(".status-icon").fadeOut(200);
152
- $(attributename).find(".fail").fadeIn(1500);
153
- $(attributename).find(".isa_error").fadeIn(1500);
154
-
155
- /* Stop status reader */
156
- clearInterval(window.intervalDefine);
157
-
158
- }
159
-
160
- //Warning
161
- if ( $(this).html() == -2 ) {
162
-
163
- $(attributename).find(".isa_warning").fadeIn(1500);
164
-
165
- }
166
-
167
- //success
168
- if ( $(this).html() == 99 ) {
169
-
170
- $(attributename).find(".isa_success").fadeIn(1500);
171
-
172
- /* Stop statusreader */
173
- clearInterval(window.intervalDefine);
174
-
175
- }
176
-
177
- });
178
- });
179
- }
180
-
181
- /* get backup status */
182
- function wpbackitup_get_backup_status() {
183
- $.post(ajaxurl, wpbackitup_backup_status_reader, function(response) {
184
- /* Get response from log reader */
185
- var xmlObj = $(response);
186
-
187
- /* For each response */
188
- xmlObj.each(function() {
189
-
190
- /* Select correct status */
191
- var attributename = "." + $(this).attr('class');
192
- var icon_attributename = "." + $(this).attr('class') + '-icon';
193
-
194
- //Hide all
195
- if ( $(this).html() == 0 ) {
196
-
197
- $(attributename).find(".status").hide();
198
- $(attributename).find(".status-icon").hide();
199
-
200
- }
201
-
202
- //Processing
203
- if ( $(this).html() == 1 ) {
204
-
205
- $(icon_attributename).css('visibility', 'visible');
206
- $(attributename).find(".status").fadeOut(200);
207
- $(attributename).find(".status-icon").fadeIn(1500);
208
-
209
- }
210
-
211
- //Done
212
- if ( $(this).html() == 2 ) {
213
-
214
- $(attributename).find(".status-icon").fadeOut(200);
215
- $(attributename).find(".status").fadeIn(1500);
216
-
217
- }
218
-
219
- //Fatal Error
220
- if ( $(this).html() == -1 ) {
221
-
222
- $(attributename).find(".status-icon").fadeOut(200);
223
- $(attributename).find(".fail").fadeIn(1500);
224
-
225
-
226
- /* Stop status reader */
227
- clearInterval(window.intervalDefine);
228
-
229
- //Show error status
230
- wpbackitup_get_backup_response();
231
- }
232
-
233
- //Warning
234
- if ( $(this).html() == -2 ) {
235
-
236
- $(attributename).find(".status-icon").fadeOut(200);
237
- $(attributename).find(".wpbackitup-warning").fadeIn(1500);
238
-
239
- }
240
-
241
- //success
242
- if ( $(this).html() == 99 ) {
243
-
244
- /* If status returns 1, display 'Done' or show detailed message */
245
- $(attributename).find(".status-icon").fadeOut(200);
246
- $(attributename).find(".status").fadeIn(1500);
247
-
248
- /* Stop statusreader */
249
- clearInterval(window.intervalDefine);
250
-
251
- //Show error status
252
- wpbackitup_get_backup_response();
253
-
254
- }
255
-
256
- });
257
- });
258
- }
259
-
260
- /* define backup response_reader function */
261
- function wpbackitup_get_backup_response() {
262
- //This function is required because of 504 gateway timeouts
263
-
264
- var jqxhr = $.ajax({
265
- url: ajaxurl,
266
- type: 'POST',
267
- data: {action: wpbackitup_get_action_name('backup_response_reader')},
268
- dataType: "json"
269
- });
270
-
271
- jqxhr.always(function(jsonData, textStatus, errorThrown) {
272
- console.log("Backup Response:" + JSON.stringify(jsonData));
273
-
274
- if (typeof jsonData.backupStatus !== 'undefined' && typeof jsonData.backupMessage !== 'undefined')
275
- {
276
- console.log("JSON Backup Status:" + jsonData.backupStatus);
277
- console.log("JSON Backup Message:" + jsonData.backupMessage);
278
-
279
- switch (jsonData.backupStatus) {
280
- case 'success':
281
- console.log("JSON success response received.");
282
- //fade out all of the spinners
283
- $('.status-icon').fadeOut(200);
284
- $("#backup-button").removeAttr("disabled"); //enable button
285
-
286
- $('.isa_success').show;
287
- $('.backup-success').fadeIn(1500);
288
-
289
- wpbackitup_processRow_backup(jsonData);
290
-
291
- //Are there any warnings?
292
- if (typeof jsonData.backupWarnings !== 'undefined'){
293
- var warning = $('.backup-warning');
294
-
295
- var $warningMessages = jsonData.backupWarnings;
296
- $warningMessages.forEach(function(obj) {
297
- var warningMessage = obj.warningMessage;
298
- warning.append('<li class="isa_warning">Warning: '+ warningMessage + '</li>');
299
- });
300
-
301
- warning.fadeIn(1500);
302
- }
303
-
304
- break;
305
-
306
- case 'error':
307
- console.log("JSON error response received.");
308
-
309
- var msg="(JS997) Unexpected error";
310
- if (typeof jsonData.backupMessage !== 'undefined'){
311
- msg= jsonData.backupMessage;
312
- }
313
- var status_message='Error: &nbsp;' + msg;
314
-
315
- var backup_error= $('.backup-error');
316
- backup_error.html(status_message);
317
- backup_error.addClass("isa_error");
318
- backup_error.fadeIn(1500);
319
-
320
- //fade out all of the spinners
321
- $('.status-icon').fadeOut(200);
322
- $("#backup-button").removeAttr("disabled"); //enable button
323
-
324
- break;
325
-
326
- default:
327
- console.log("Unexpected JSON response status received.");
328
-
329
- var msg="(JS998) Unexpected error";
330
- if (typeof jsonData.backupMessage !== 'undefined'){
331
- msg= jsonData.backupMessage;
332
- }
333
- var status_message='Error(JS998) : &nbsp;' + msg;
334
-
335
- var unexpected_error= $('.backup-error');
336
- unexpected_error.html(status_message);
337
- unexpected_error.addClass("isa_error");
338
- unexpected_error.fadeIn(1500);
339
-
340
- //fade out all of the spinners
341
- $('.status-icon').fadeOut(200);
342
- $("#backup-button").removeAttr("disabled"); //enable button
343
-
344
- break;
345
-
346
- }
347
-
348
- } else { //Didnt get any json back
349
- console.log("NON JSON response received.");
350
- console.log("Backup Response:" + errorThrown);
351
- status_message='(JS999) An unexpected error has occurred: &nbsp;';
352
- status_message+='</br>Response: &nbsp;' + JSON.stringify(jsonData);
353
- status_message+='</br>Status: &nbsp;' + textStatus;
354
- status_message+='</br>Error: &nbsp;' + JSON.stringify(errorThrown);
355
-
356
- $('.backup-status').hide();
357
-
358
- var unexpected_error= $('.backup-error');
359
- unexpected_error.html(status_message);
360
- unexpected_error.addClass("isa_error");
361
- unexpected_error.show();
362
-
363
- $('.status-icon').fadeOut(200);
364
- }
365
- });
366
- }
367
-
368
- //Save Schedule CLICK
369
- $("#wp-backitup-notification-close").click(function() {
370
- wpbackitup_dismiss_message();
371
- });
372
-
373
-
374
- //Save Schedule CLICK
375
- $("#wp-backitup-save_schedule_form").submit(function() {
376
-
377
- var formData = new FormData();
378
- formData.append('action', wpbackitup_get_action_name('update-schedule'));
379
- formData.append('_wpnonce', $('#wp-backitup_nonce-update-schedule').val());
380
- formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
381
-
382
- var days_selected = [];
383
- $.each($("input[name='dow']:checked"), function(){
384
- days_selected.push($(this).val());
385
- });
386
-
387
- formData.append('days_selected', days_selected);
388
-
389
- jQuery.ajax({
390
- url: ajaxurl,
391
- type: 'POST',
392
- cache: false,
393
- contentType: false,
394
- processData: false,
395
- dataType: "json",
396
- data: formData,
397
-
398
- success: function(data, textStatus, jqXHR){
399
- response=data.message;
400
- console.log("Success:" + response);
401
-
402
- //Turn on the notification bar
403
- switch (response)
404
- {
405
- case 'success':
406
- wpbackitup_show_success_message("Scheduled has been saved.");
407
- break;
408
- case 'error':
409
- wpbackitup_show_error_message("Scheduled was not saved.");
410
- break;
411
- default:
412
-
413
- }
414
-
415
- },
416
- error: function(jqXHR, textStatus, errorThrown){
417
- console.log("Error." + textStatus +':' +errorThrown);
418
- },
419
- complete: function(jqXHR, textStatus){
420
- console.log("Complete");
421
- }
422
- });
423
-
424
- return false;
425
-
426
- });
427
-
428
- // BACKUP button click
429
- $(".backup-button").click(function(e) {
430
- e.preventDefault();
431
-
432
- $("#backup-button").attr('disabled', 'disabled'); //Disable button
433
-
434
- var jqxhr = $.ajax({
435
- url: ajaxurl,
436
- type: 'POST',
437
- data: {action: wpbackitup_get_action_name('backup')},
438
- cache: false,
439
- dataType: "json",
440
-
441
- beforeSend: function(jqXHR, settings) {
442
- console.log("BeforeSend:Nothing to report.");
443
- wpbackitup_show_backup();
444
- }
445
- });
446
-
447
- //Fetch the JSON response file if it exists
448
- jqxhr.always(function(data, textStatus, errorThrown) {
449
- console.log("Backup Button Click - Always");
450
- console.log(data.message);//backup queued?
451
- });
452
- });
453
-
454
- function wpbackitup_show_backup(){
455
- /* display processing icon */
456
- $('.backup-icon').css('visibility', 'visible');
457
- $('.backup-icon').show();
458
-
459
- /* hide default message */
460
- $('.backup-success').hide();
461
- $('.default-status').hide();
462
- $('.backup-error').hide();
463
-
464
- /* hide the status just incase this is the second run */
465
- $("ul.backup-status").children().children().hide();
466
- $(".backup-errors").children().children().hide();
467
- $(".backup-success").children().children().hide();
468
-
469
- /* show backup status, backup errors */
470
- $('.backup-status').show();
471
- window.intervalDefine = setInterval(wpbackitup_get_backup_status, 5000);
472
- }
473
-
474
-
475
- //RESTORE button click
476
- $('#datatable').on('click', 'a.restoreRow', function(e) {
477
- e.preventDefault();
478
-
479
- if (confirm('Are you sure you want to restore your site?'))
480
- {
481
- var filename = this.title;
482
- var row = this.id.replace('restoreRow', 'row');
483
- userid = $('input[name=user_id]').val();
484
-
485
- var jqxhr = $.ajax({
486
- url: ajaxurl,
487
- type: 'post',
488
- data: {action: wpbackitup_get_action_name('restore'), selected_file: filename,user_id: userid},
489
- cache: false,
490
- dataType: "json",
491
-
492
- //success: function(response) {
493
- // /* Return PHP messages, used for development */
494
- // $("#php").html(response);
495
- //
496
- // //clearInterval(window.intervalDefine);
497
- // var data = $.parseJSON(response);
498
- //
499
- //},
500
- beforeSend: function () {
501
- console.log("BeforeSend:Nothing to report.");
502
- wpbackitup_show_restore();
503
- }
504
- });
505
-
506
- //Fetch the JSON response file if it exists
507
- jqxhr.always(function(data, textStatus, errorThrown) {
508
- console.log("Restore Button Click - Always");
509
- //console.log("Response:" + data);
510
- });
511
- }
512
- });
513
-
514
-
515
- function wpbackitup_show_restore(){
516
- /* display processing icon */
517
- $('.restore-icon').css('visibility', 'visible');
518
-
519
- /* hide default message, backup status and backup errors */
520
- $('.default-status, .upload-status').hide();
521
-
522
- $("ul.restore-status").children().children().hide();
523
- $(".restore-errors").children().children().hide();
524
- $(".restore-success").children().children().hide();
525
-
526
- /* show restore status messages */
527
- $('.restore-status, .restore-errors, .restore-success').show();
528
- $('.preparing-icon').css('visibility', 'visible');
529
- $('.preparing').find(".status-icon").fadeIn(1500);
530
-
531
- window.intervalDefine = setInterval(wpbackitup_get_restore_status, 5000);
532
- }
533
-
534
- /*Upload form button*/
535
- //$("#upload-form").submit(function(e) {
536
- //
537
- // e.preventDefault();
538
- //
539
- // //CHECK ERRORS ON USER SIDE, IF TRUE, END OPERATIONS.
540
- // if (wpbackitup_upload_errors()){
541
- // return false;
542
- // }
543
- //
544
- // var formData = new FormData();
545
- // formData.append('action', wpbackitup_get_action_name('upload'));
546
- // formData.append('_wpnonce', $('#_wpnonce').val());
547
- // formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
548
- // formData.append('upload_ids',$('#upload_ids').val());
549
- //
550
- // jQuery.ajax({
551
- // url: ajaxurl,
552
- // type: 'POST',
553
- // cache: false,
554
- // contentType: false,
555
- // processData: false,
556
- // dataType: "json",
557
- //
558
- // //MODIFIED - From ajaxData to formData
559
- // data: formData,
560
- //
561
- // beforeSend: function(jqXHR, settings){
562
- // //console.log("Haven't entered server side yet.");
563
- // /* display processing icon */
564
- // $('.upload-icon').css('visibility', 'visible');
565
- //
566
- // /* hide default message, backup status and backup errors */
567
- // $('.default-status, .restore-status, .restore-errors').hide();
568
- // $("ul.restore-status").children().children().hide();
569
- // $(".restore-errors").children().children().hide();
570
- // $(".restore-success").children().children().hide();
571
- //
572
- // /* show restore status messages */
573
- // $('.upload-status').toggle();
574
- //
575
- // $("#wpbackitup-zip").attr("disabled", "disabled"); //Disable upload
576
- // $("#upload-button").attr("disabled", "disabled"); //Disable upload
577
- //
578
- // },
579
- // dataFilter: function(data, type){
580
- // //Check the response before sending to success
581
- // //Possible that is isnt json so just forward it to success in a json object
582
- // try {
583
- // $("#php").html(data);
584
- // var response = $.parseJSON(data);
585
- // console.log("JSON string echoed back from server side:" + response);
586
- // return data;
587
- // } catch (e) {
588
- // console.log("NON JSON string echoed back from server side:" + type + ':' + data);
589
- // var rtnData = new Object();
590
- // rtnData.success = "";
591
- // rtnData.error = data;
592
- // return JSON.stringify(rtnData)
593
- // }
594
- //
595
- //
596
- // },
597
- // success: function(data, textStatus, jqXHR){
598
- // console.log("Back from server-side:" + data);
599
- // //Checking errors that may have been caught on the server side that
600
- // // normally wouldn't display in the error Ajax function.
601
- //
602
- // if (data.msg == 'success')
603
- // {
604
- // status_message=data.file + ' file was uploaded successfully...';
605
- // wpbackitup_processRow_restore(data);
606
- // $('.upload-status').addClass("isa_success");
607
- // }else{
608
- // status_message='Error: &nbsp;' + data.error;
609
- // $('.upload-status').addClass("isa_error");
610
- // }
611
- //
612
- // $('.upload-icon').fadeOut(1000);
613
- // $('.upload-status').show();
614
- // $('.upload-status').html(status_message);
615
- //
616
- // },
617
- // error: function(jqXHR, textStatus, errorThrown){
618
- // console.log("A JS error has occurred." + textStatus +':' +errorThrown);
619
- // },
620
- // complete: function(jqXHR, textStatus){
621
- // console.log("Ajax is finished.");
622
- // }
623
- // });
624
- //
625
- // return false;
626
- //});
627
- //
628
- //function wpbackitup_upload_errors()
629
- //{
630
- // var selected_files = $('#upload_ids').val();
631
- // if (selected_files == '')
632
- // {
633
- // alert('No file(s) selected. Please choose a backup file.');
634
- // return true;
635
- // }
636
- //
637
- // //if ($('#upload_files').val() != '')
638
- // //{
639
- // // var ext = $('#upload_files').val().split('.').pop().toLowerCase();
640
- // // if($.inArray(ext, ['zip']) == -1)
641
- // // {
642
- // // alert('Invalid file type. Please choose a ZIP file to upload.');
643
- // // return true;
644
- // // }
645
- // //}
646
- // return false;
647
- //}
648
- //
649
- ///*Upload form button*/
650
- //$("#upload-form_OLD").submit(function() {
651
- //
652
- // //e.preventDefault();
653
- //
654
- // //CHECK ERRORS ON USER SIDE, IF TRUE, END OPERATIONS.
655
- // if (wpbackitup_upload_errors()){
656
- // return false;
657
- // }
658
- //
659
- // var formData = new FormData();
660
- // jQuery.each($('#wpbackitup-zip')[0].files, function(i, file) {
661
- // formData.append('uploadFile-'+i, file);
662
- // });
663
- // formData.append('action', wpbackitup_get_action_name('upload'));
664
- // formData.append('_wpnonce', $('#_wpnonce').val());
665
- // formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
666
- //
667
- // jQuery.ajax({
668
- // url: ajaxurl,
669
- // type: 'POST',
670
- // cache: false,
671
- // contentType: false,
672
- // processData: false,
673
- // dataType: "json",
674
- //
675
- // //MODIFIED - From ajaxData to formData
676
- // data: formData,
677
- //
678
- // beforeSend: function(jqXHR, settings){
679
- // //console.log("Haven't entered server side yet.");
680
- // /* display processing icon */
681
- // $('.upload-icon').css('visibility', 'visible');
682
- //
683
- // /* hide default message, backup status and backup errors */
684
- // $('.default-status, .restore-status, .restore-errors').hide();
685
- // $("ul.restore-status").children().children().hide();
686
- // $(".restore-errors").children().children().hide();
687
- // $(".restore-success").children().children().hide();
688
- //
689
- // /* show restore status messages */
690
- // $('.upload-status').toggle();
691
- //
692
- // $("#wpbackitup-zip").attr("disabled", "disabled"); //Disable upload
693
- // $("#upload-button").attr("disabled", "disabled"); //Disable upload
694
- //
695
- // },
696
- // dataFilter: function(data, type){
697
- // //Check the response before sending to success
698
- // //Possible that is isnt json so just forward it to success in a json object
699
- // try {
700
- // $("#php").html(data);
701
- // var response = $.parseJSON(data);
702
- // console.log("JSON string echoed back from server side:" + response);
703
- // return data;
704
- // } catch (e) {
705
- // console.log("NON JSON string echoed back from server side:" + type + ':' + data);
706
- // var rtnData = new Object();
707
- // rtnData.success = "";
708
- // rtnData.error = data;
709
- // return JSON.stringify(rtnData)
710
- // }
711
- //
712
- //
713
- // },
714
- // success: function(data, textStatus, jqXHR){
715
- // console.log("Back from server-side:" + data);
716
- // //Checking errors that may have been caught on the server side that
717
- // // normally wouldn't display in the error Ajax function.
718
- //
719
- // if (data.msg == 'success')
720
- // {
721
- // status_message=data.file + ' file was uploaded successfully...';
722
- // wpbackitup_processRow_restore(data);
723
- // $('.upload-status').addClass("isa_success");
724
- // }else{
725
- // status_message='Error: &nbsp;' + data.error;
726
- // $('.upload-status').addClass("isa_error");
727
- // }
728
- //
729
- // $('.upload-icon').fadeOut(1000);
730
- // $('.upload-status').show();
731
- // $('.upload-status').html(status_message);
732
- //
733
- // },
734
- // error: function(jqXHR, textStatus, errorThrown){
735
- // console.log("A JS error has occurred." + textStatus +':' +errorThrown);
736
- // },
737
- // complete: function(jqXHR, textStatus){
738
- // console.log("Ajax is finished.");
739
- // }
740
- // });
741
- //
742
- // return false;
743
- //});
744
-
745
- // DELETE file action
746
- $('#datatable').on('click', 'a.deleteRow', function(e) {
747
-
748
- e.preventDefault();
749
- if (confirm('Are you sure ?'))
750
- {
751
- var filename = this.title;
752
- var row = this.id.replace('deleteRow', 'row');
753
- $.ajax({
754
- url: ajaxurl,
755
- type: 'post',
756
- data: {action: wpbackitup_get_action_name('delete_file'), filed: filename},
757
- success: function(data) {
758
- if (data === 'deleted')
759
- {
760
- $('#' + row).remove();
761
- }
762
- else
763
- {
764
- alert('This file cannot be delete!');
765
- }
766
- }
767
- });
768
- }
769
- else
770
- {
771
- return;
772
- }
773
- });
774
-
775
- //UPLOADS
776
- //http://www.plupload.com/example_events.php
777
- function plupload_init(plupload_config) {
778
-
779
- var uploader = new plupload.Uploader(plupload_config);
780
- uploader.init();
781
-
782
- //File Added event
783
- uploader.bind('FilesAdded', function(up, files){
784
- plupload.each(files, function(file){
785
- //add some file name validation here?
786
- $('#filelist').append(
787
- '<div id="media-item-' + file.id + '" class="media-item child-of-0">' +
788
- '<img class="pinkynail" alt="" src="' + site_url + '/wp-includes/images/media/archive.png">' +
789
- '<div class="filename new" id="' + file.id + '">' +
790
- file.name + ' (<span>' + plupload.formatSize(0) + '</span> of ' + plupload.formatSize(file.size) + ') ' +
791
- '<div class="progress" style="width: 0%;"></div></div></div>');
792
- });
793
-
794
- up.refresh();
795
- up.start();
796
- });
797
-
798
- //File Progress Event
799
- uploader.bind('UploadProgress', function(up, file) {
800
- $('#' + file.id + " .progress").width((file.percent *.15 )+ "%");
801
- $('#' + file.id + " span").html(plupload.formatSize(parseInt(file.size * file.percent / 100)));
802
- });
803
-
804
- //Chunked upload
805
- uploader.bind(' ChunkUploaded', function(up, file,info) {
806
- console.log('Chunk Uploaded:');
807
- console.log(info);
808
-
809
- if (is_plupload_error(info,up,file)){
810
- console.log('chunk error');
811
- }
812
-
813
- });
814
-
815
- //Error Event
816
- uploader.bind('Error', function(up, error) {
817
- console.log('PlUpload Error:');
818
- console.log(error);
819
-
820
- var error_div = "error-item-"+ error.file.id;
821
-
822
- //If error div NOT exists then add it
823
- //Chunk and file uploaded both will call this routine
824
- if (! $('#'+ error_div).length){
825
- $('#filelist').append(
826
- '<div class="error-div error" id="' + error_div + '" >' +
827
- '<strong>' + error.file.name + ' has failed to upload due to error:&nbsp;</strong> <span>' + error.message + '</span> ' +
828
- '</div>'
829
- );
830
- }
831
-
832
-
833
- });
834
-
835
-
836
- // a file was uploaded
837
- uploader.bind('FileUploaded', function(up, file, response) {
838
- console.log('File Uploaded');
839
- console.log(response);
840
-
841
-
842
- if (is_plupload_error(response,up,file)){
843
- console.log('uploaded error')
844
- }else{
845
- console.log('uploaded success')
846
- $('#' + file.id + " .progress").css("background-color", "green");
847
- }
848
-
849
- });
850
- }
851
-
852
- function is_plupload_error(response,uploader,file){
853
- if (response.status == '200') {
854
- try {
855
- response_json = jQuery.parseJSON(response.response);
856
-
857
- if (response_json.error) {
858
- plupload_error (uploader,file, 100, response_json.error)
859
- return true;
860
- }
861
-
862
- //success
863
- return false;
864
-
865
-
866
- } catch (err) {
867
- console.log('Unexpected JSON Error' + err);
868
- plupload_error (uploader,file, 998, response.response)
869
- return true;
870
- }
871
-
872
- } else {
873
- alert('Unknown server response status: '+response.code);
874
- console.log(response);
875
- plupload_error (uploader,file, 999, response.response)
876
- return true;
877
- }
878
-
879
- }
880
- function plupload_error (uploader,file, code, error_message){
881
-
882
- file.status = plupload.FAILED;
883
- uploader.trigger("Error", {
884
- code: code,
885
- message: error_message,
886
- file: file
887
- });
888
-
889
- //remove upload from list
890
- $('#media-item-' + file.id).hide();
891
- }
892
-
893
- function wpbackitup_processRow_backup(data)
894
- {
895
- // decide class of row to be inserted dynamically
896
- var css_class;
897
- css_class = '';
898
-
899
- if (!$('#datatable tr').first().hasClass('alternate'))
900
- css_class = 'class="alternate"';
901
- // decided class of row to be inserted dynamically
902
-
903
- // build id of the row to be inserted dynamically
904
- var cur_row = ($('#datatable tr:last')[0].id.replace('row', ''));
905
- cur_row++;
906
-
907
- // built id of the row to be inserted dynamically
908
- if (typeof data !== 'undefined')
909
- {
910
- //var restoreColumn = '<td><a href="#" title="' + data.backupFile + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n';
911
-
912
- var viewColumn = '<td>&nbsp;</td>\n';
913
- if (typeof data.logFileExists !== 'undefined' && data.logFileExists==true) {
914
- viewColumn = '<td><a class="viewloglink" href="' + data.backupName + '">View Log</a></td>\n';
915
- }
916
-
917
- var newRow =
918
- '<tr ' + css_class + ' id="row' + cur_row + '">\n\
919
- <td>New Backup!</td>\n\
920
- <td><a href="#TB_inline?width=600&height=550&inlineId=new_backup" class="thickbox" title="' + data.backupName + '">Download</a></td>\n';
921
- newRow +=viewColumn;
922
- newRow +='<td><a href="#" title="' + data.backupName + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n';
923
- newRow +='</tr>';
924
-
925
- if ($('#nofiles'))
926
- $('#nofiles').remove();
927
-
928
- var total_rows = $('#datatable tr').length;
929
- $('#datatable').prepend(newRow);
930
- $('#datatable tr:first').hide().show('slow'); // just an animation to show newly added row
931
-
932
- if(total_rows >= data.backupRetained)
933
- $('#datatable tr:last').hide();
934
-
935
- wpbackitup_add_viewlog_onclick();
936
-
937
- wpbackitup_add_downloadbackup_onclick();
938
-
939
- }
940
- }
941
-
942
- function wpbackitup_processRow_restore(data)
943
- {
944
- // decide class of row to be inserted dynamically
945
- var css_class;
946
- css_class = '';
947
-
948
- if (!$('#datatable tr').first().hasClass('alternate'))
949
- css_class = 'class="alternate"';
950
- // decided class of row to be inserted dynamically
951
-
952
- // build id of the row to be inserted dynamically
953
- var cur_row = ($('#datatable tr:last')[0].id.replace('row', ''));
954
- cur_row++;
955
-
956
- // built id of the row to be inserted dynamically
957
- if (data != undefined)
958
- {
959
- var restoreColumn = '<td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n';
960
- var newRow =
961
- '<tr ' + css_class + ' id="row' + cur_row + '">\n\
962
- <td>Uploaded Backup<i class="fa fa-long-arrow-right"></i>' + data.file +'</td>\n\
963
- <td><a href="' + data.zip_link + '">Download</a></td>\n\
964
- <td><a href="#" title="' + data.file + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n\
965
- <td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n\
966
- </tr>';
967
-
968
- if ($('#nofiles'))
969
- $('#nofiles').remove();
970
-
971
- var total_rows = $('#datatable tr').length;
972
- $('#datatable').prepend(newRow);
973
- $('#datatable tr:first').hide().show('slow'); // just an animation to show newly added row
974
-
975
- if(total_rows >= data.retained)
976
- $('#datatable tr:last').hide();
977
- }
978
- }
979
-
980
-
981
- function wpbackitup_get_action_name(action) {
982
- return namespace + '_' + action;
983
- }
984
-
985
- function wpbackitup_dismiss_message(){
986
- notification_bar = $( "#wp-backitup-notification-parent");
987
- notification_bar.fadeOut( "slow" )
988
- }
989
-
990
- function wpbackitup_show_success_message(message){
991
- notification_bar_message = $( "#wp-backitup-notification-message");
992
- notification_bar_message.html("<p>" + message + "</p>");
993
-
994
- notification_bar = $( "#wp-backitup-notification-parent");
995
- notification_bar.toggleClass("error",false);
996
- notification_bar.toggleClass("updated",true);
997
-
998
- notification_bar.show();
999
- $('html, body').animate({ scrollTop: 0 }, 'slow');
1000
- }
1001
-
1002
- function wpbackitup_show_error_message(message){
1003
- notification_bar_message = $( "#wp-backitup-notification-message");
1004
- notification_bar_message.html("<p>" + message + "</p>");
1005
-
1006
- notification_bar = $( "#wp-backitup-notification-parent");
1007
- notification_bar.toggleClass("updated",false);
1008
- notification_bar.toggleClass("error",true);
1009
-
1010
- notification_bar.show();
1011
- $('html, body').animate({ scrollTop: 0 }, 'slow');
1012
- }
1013
-
1014
-
1015
-
1016
-
1017
- // Uploading files
1018
- //jQuery(document).ready(function($){
1019
- // var custom_uploader;
1020
- // $('#upload_backup_button').click(function(e) {
1021
- //
1022
- // e.preventDefault();
1023
- //
1024
- // //If the uploader object has already been created, reopen the dialog
1025
- // if (custom_uploader) {
1026
- // custom_uploader.open();
1027
- // return;
1028
- // }
1029
- //
1030
- // //Extend the wp.media object (wp-includes/js/media-views.js)
1031
- // custom_uploader = wp.media.frames.file_frame = wp.media({
1032
- // //id:'wpbackitup-library',
1033
- // library: {
1034
- // type: "application/zip"
1035
- // },
1036
- // title: 'Select Backup Files',
1037
- // button: {
1038
- // text: 'Select Backup Files'
1039
- // },
1040
- // //searchable:false,
1041
- // //editing:false,
1042
- // //frame: 'post',
1043
- // multiple: true
1044
- // });
1045
- //
1046
- // //When a file is selected, grab the URL and set it as the text field's value
1047
- // custom_uploader.on('select', function() {
1048
- //
1049
- // //attachment = custom_uploader.state().get('selection').first().toJSON();
1050
- // //$('#upload_backup').val(attachment.filename);
1051
- //
1052
- // var attachments_string='';
1053
- // var selected_file_ids=[];
1054
- // var selection = custom_uploader.state().get('selection');
1055
- // selection.map( function( attachment ) {
1056
- // attachment = attachment.toJSON();
1057
- //
1058
- // //Probably need to add this to a hidden form field
1059
- // selected_file_ids.push(attachment.id);
1060
- // attachments_string+=attachment.filename +",";
1061
- // // Do something with attachment.id and/or attachment.url here
1062
- // });
1063
- //
1064
- // var ids_json = JSON.stringify(selected_file_ids);
1065
- // $('#upload_ids').val(ids_json);
1066
- // $('#upload_files').val(attachments_string);
1067
- // $('#upload_backup').val(attachments_string);
1068
- //
1069
- // });
1070
- //
1071
- //
1072
- // //Open the uploader dialog
1073
- // custom_uploader.open();
1074
- //
1075
- // });
1076
- //
1077
- //
1078
- //});
1079
-
1080
- //**TEST METHODS**//
1081
-
1082
- //wpbackitup_show_restore();
1083
- //wpbackitup_show_backup();
1084
-
1085
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/languages/en-GB.mo DELETED
Binary file
tags/1.10.0/languages/en-GB.po DELETED
@@ -1,333 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: WP Backitup\n"
4
- "POT-Creation-Date: 2013-09-07 19:24-0000\n"
5
- "PO-Revision-Date: 2013-09-07 19:24-0000\n"
6
- "Last-Translator: John Peden <john.peden@britishcouncil.org>\n"
7
- "Language-Team: John Peden Ltd <mail@johncpeden.com>\n"
8
- "Language: English\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.5.4\n"
13
- "X-Poedit-KeywordsList: _e;__\n"
14
- "X-Poedit-Basepath: .\n"
15
- "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-SearchPath-0: .\n"
17
- "X-Poedit-SearchPath-1: ..\n"
18
-
19
- #: ../index.php:312
20
- msgid "Manage"
21
- msgstr ""
22
-
23
- #: ../views/options.php:6 ../views/options.php:8
24
- msgid "Backup"
25
- msgstr ""
26
-
27
- #: ../views/options.php:7
28
- msgid "Create a backup file of this site's content and settings"
29
- msgstr ""
30
-
31
- #: ../views/options.php:9
32
- msgid "Download"
33
- msgstr ""
34
-
35
- #: ../views/options.php:15 ../views/options.php:30
36
- msgid "Restore"
37
- msgstr ""
38
-
39
- #: ../views/options.php:17
40
- msgid ""
41
- "Restore a WP Backitup zip file and overwrite this site's content, themes, "
42
- "plugins, uploads and settings"
43
- msgstr ""
44
-
45
- #: ../views/options.php:22
46
- msgid "The maximum filesize you can upload is "
47
- msgstr ""
48
-
49
- #: ../views/options.php:35
50
- msgid "Status"
51
- msgstr ""
52
-
53
- #: ../views/options.php:40
54
- msgid "Nothing to report"
55
- msgstr ""
56
-
57
- #: ../views/options.php:45
58
- msgid "Preparing to backup"
59
- msgstr ""
60
-
61
- #: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
62
- #: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
63
- #: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
64
- #: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
65
- #: ../views/options.php:73
66
- msgid "Done"
67
- msgstr ""
68
-
69
- #: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
70
- #: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
71
- #: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
72
- #: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
73
- #: ../views/options.php:73
74
- msgid "Failed"
75
- msgstr ""
76
-
77
- #: ../views/options.php:46
78
- msgid "Backing-up database"
79
- msgstr ""
80
-
81
- #: ../views/options.php:47
82
- msgid "Backing-up /wp-content/"
83
- msgstr ""
84
-
85
- #: ../views/options.php:48
86
- msgid "Creating backup information file"
87
- msgstr ""
88
-
89
- #: ../views/options.php:49
90
- msgid "Zipping backup directory"
91
- msgstr ""
92
-
93
- #: ../views/options.php:50 ../views/options.php:73
94
- msgid "Cleaning up"
95
- msgstr ""
96
-
97
- #: ../views/options.php:51
98
- msgid ""
99
- "Backup file created successfully. You can download your backup file using "
100
- "the link above"
101
- msgstr ""
102
-
103
- #: ../views/options.php:56
104
- msgid ""
105
- "Error: Unable to create new directory for backup. Please check your CHMOD "
106
- "settings of your wp-backitup plugin directory"
107
- msgstr ""
108
-
109
- #: ../views/options.php:57
110
- msgid ""
111
- "Error: Cannot create backup directory. Please check the CHMOD settings of "
112
- "your wp-backitup plugin directory"
113
- msgstr ""
114
-
115
- #: ../views/options.php:58
116
- msgid "Error: Unable to backup your files. Please try again"
117
- msgstr ""
118
-
119
- #: ../views/options.php:59
120
- msgid "Error: Unable to backup your database. Please try again"
121
- msgstr ""
122
-
123
- #: ../views/options.php:60
124
- msgid ""
125
- "Error: Your database was accesible but a dump could not be created. Please "
126
- "contact support by clicking the link on the right, stating your web host "
127
- "when you submit the form."
128
- msgstr ""
129
-
130
- #: ../views/options.php:61
131
- msgid "Error: Unable to create site information file. Please try again"
132
- msgstr ""
133
-
134
- #: ../views/options.php:62
135
- msgid "Warning: Unable to cleanup your backup directory"
136
- msgstr ""
137
-
138
- #: ../views/options.php:67
139
- msgid "Uploading restoration zip"
140
- msgstr ""
141
-
142
- #: ../views/options.php:68
143
- msgid "Unzipping"
144
- msgstr ""
145
-
146
- #: ../views/options.php:69
147
- msgid "Validating restoration zip"
148
- msgstr ""
149
-
150
- #: ../views/options.php:70
151
- msgid "Setting checkpoint"
152
- msgstr ""
153
-
154
- #: ../views/options.php:71
155
- msgid "Importing database"
156
- msgstr ""
157
-
158
- #: ../views/options.php:72
159
- msgid "Importing /wp-content/ directory"
160
- msgstr ""
161
-
162
- #: ../views/options.php:74
163
- msgid ""
164
- "Restoration completed successfully. Please refresh the page and login to the "
165
- "site again (with your current username and password)"
166
- msgstr ""
167
-
168
- #: ../views/options.php:79
169
- msgid "Error: No file selected"
170
- msgstr ""
171
-
172
- #: ../views/options.php:80
173
- msgid "Error: Your file could not be uploaded"
174
- msgstr ""
175
-
176
- #: ../views/options.php:81
177
- msgid "Error: Your restoration file could not be unzipped"
178
- msgstr ""
179
-
180
- #: ../views/options.php:82
181
- msgid ""
182
- "Error: Your zip file appears to be invalid. Please ensure you chose the "
183
- "correct zip file"
184
- msgstr ""
185
-
186
- #: ../views/options.php:83
187
- msgid "Error: Cannot create restore point"
188
- msgstr ""
189
-
190
- #: ../views/options.php:84
191
- msgid "Error: Unable to connect to your database"
192
- msgstr ""
193
-
194
- #: ../views/options.php:85
195
- msgid "Error: Unable to get current site URL from database. Please try again"
196
- msgstr ""
197
-
198
- #: ../views/options.php:86
199
- msgid "Error: Unable to get current home URL from database. Please try again"
200
- msgstr ""
201
-
202
- #: ../views/options.php:87
203
- msgid "Error: Unable to get current user ID from database. Please try again"
204
- msgstr ""
205
-
206
- #: ../views/options.php:88
207
- msgid ""
208
- "Error: Unable to get current user password from database. Please try again"
209
- msgstr ""
210
-
211
- #: ../views/options.php:89
212
- msgid "Error: Unable to get current user email from database. Please try again"
213
- msgstr ""
214
-
215
- #: ../views/options.php:90
216
- msgid ""
217
- "Error: Unable to get import your database. This may require importing the "
218
- "file manually"
219
- msgstr ""
220
-
221
- #: ../views/options.php:91
222
- msgid ""
223
- "Error: Unable to update your current site URL value. This may require "
224
- "importing the file manually"
225
- msgstr ""
226
-
227
- #: ../views/options.php:92
228
- msgid ""
229
- "Error: Unable to update your current home URL value. This may require "
230
- "importing the file manually"
231
- msgstr ""
232
-
233
- #: ../views/options.php:93
234
- msgid ""
235
- "Error: Unable to update your user information. This may require importing "
236
- "the file manually"
237
- msgstr ""
238
-
239
- #: ../views/options.php:94
240
- msgid "Error: Warning: Database not detected in import file"
241
- msgstr ""
242
-
243
- #: ../views/options.php:95
244
- msgid ""
245
- "Error: Unable to remove existing wp-content directory for import. Please "
246
- "check your CHMOD settings in /wp-content/"
247
- msgstr ""
248
-
249
- #: ../views/options.php:96
250
- msgid ""
251
- "Error: Unable to create new wp-content directory for import. Please check "
252
- "your CHMOD settings in /wp-content/"
253
- msgstr ""
254
-
255
- #: ../views/options.php:97
256
- msgid "Error: Unable to import wp-content. Please try again"
257
- msgstr ""
258
-
259
- #: ../views/options.php:98
260
- msgid "Warning: Unable to cleanup import directory"
261
- msgstr ""
262
-
263
- #: ../views/options.php:109
264
- msgid "License Key"
265
- msgstr ""
266
-
267
- #: ../views/options.php:113
268
- msgid "Pro features and auto-updates enabled"
269
- msgstr ""
270
-
271
- #: ../views/options.php:115
272
- msgid "Activate auto-restore and auto-updates by entering your license key"
273
- msgstr ""
274
-
275
- #: ../views/options.php:120
276
- msgid "Active"
277
- msgstr ""
278
-
279
- #: ../views/options.php:121
280
- msgid "Update"
281
- msgstr ""
282
-
283
- #: ../views/options.php:123
284
- msgid "Inactive"
285
- msgstr ""
286
-
287
- #: ../views/options.php:124
288
- msgid "Activate"
289
- msgstr ""
290
-
291
- #: ../views/options.php:125
292
- msgid "Purchase a license key"
293
- msgstr ""
294
-
295
- #: ../views/options.php:132
296
- msgid "WP Backitup support system"
297
- msgstr ""
298
-
299
- #: ../views/options.php:135
300
- msgid "support system"
301
- msgstr ""
302
-
303
- #: ../views/options.php:138
304
- msgid "Need Help?"
305
- msgstr ""
306
-
307
- #: ../views/options.php:139
308
- msgid "Access the"
309
- msgstr ""
310
-
311
- #: ../views/options.php:143
312
- msgid "Spread the Word"
313
- msgstr ""
314
-
315
- #: ../views/options.php:144
316
- msgid "Rate WP Backitup"
317
- msgstr ""
318
-
319
- #: ../views/options.php:149
320
- msgid "Enable"
321
- msgstr ""
322
-
323
- #: ../views/options.php:150
324
- msgid "Disable"
325
- msgstr ""
326
-
327
- #: ../views/options.php:151
328
- msgid "Help to improve Easy Webtrends by enabling"
329
- msgstr ""
330
-
331
- #: ../views/options.php:152
332
- msgid "Save"
333
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-backup.php DELETED
@@ -1,724 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Backup Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
- /*** Includes ***/
12
- // include file system class
13
- if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
14
- include_once 'class-filesystem.php';
15
- }
16
-
17
-
18
-
19
- class WPBackItUp_Backup {
20
-
21
- private $logger;
22
-
23
- //Public Properties
24
- public $backup_name;
25
- public $backup_filename;
26
- public $backup_project_path;
27
- public $backup_folder_root;
28
- public $restore_folder_root;
29
- public $backup_retained_number;
30
- public $backup_retained_days;
31
- public $backup_batch_size;
32
-
33
- //scheduled,manual,none
34
- public $backup_type;
35
-
36
- private static $lockFileName;
37
- private static $lockFile;
38
-
39
-
40
- //-------------STATIC FUNCTIONS-------------------//
41
-
42
-
43
-
44
- //-------------END STATIC FUNCTIONS-------------------//
45
-
46
- function __construct($logger,$backup_name, $backup_type) {
47
- global $WPBackitup;
48
- try {
49
- $this->logger = $logger;
50
-
51
- $this->backup_type=$backup_type;
52
-
53
- $this->backup_batch_size=1; //manual backups
54
- if ('scheduled'==$this->backup_type){
55
- $this->backup_batch_size=$WPBackitup->backup_batch_size(); //Scheduled
56
- }
57
- $this->backup_name=$backup_name;
58
- $this->backup_filename=$backup_name . '.tmp';
59
-
60
- $backup_project_path = WPBACKITUP__BACKUP_PATH .'/TMP_'. $backup_name .'/';
61
-
62
- $backup_folder_root =WPBACKITUP__BACKUP_PATH .'/';
63
- $restore_folder_root = WPBACKITUP__RESTORE_FOLDER;
64
-
65
- $this->backup_project_path=$backup_project_path;
66
- $this->backup_folder_root=$backup_folder_root;
67
- $this->restore_folder_root=$restore_folder_root;
68
-
69
- $this->backup_retained_number = $WPBackitup->backup_retained_number();
70
- $this->backup_retained_days = WPBACKITUP__BACKUP_RETAINED_DAYS; //Prob need to move this to main propery
71
-
72
- } catch(Exception $e) {
73
- $this->logger->log_error(__METHOD__,'Constructor Exception: ' .$e);
74
- throw $e;
75
- }
76
- }
77
-
78
- function __destruct() {
79
- //Call end just in case
80
- $this->end();
81
- }
82
-
83
-
84
- /**
85
- * Begin backup process - Only one may be running at a time
86
- * @return bool
87
- */
88
- public static function start (){
89
- $logger = new WPBackItUp_Logger(false,null,'debug_lock');
90
- try {
91
- self::$lockFileName = WPBACKITUP__PLUGIN_PATH .'logs/wpbackitup_lock.lock';
92
- $logger->log_info(__METHOD__,'Begin - Lock File:' . self::$lockFileName);
93
-
94
- self::$lockFile = fopen(self::$lockFileName ,"w"); // open it for WRITING ("w")
95
- if (flock( self::$lockFile, LOCK_EX | LOCK_NB)) {
96
- $logger->log_info(__METHOD__,'Process LOCK acquired');
97
- return true;
98
- } else {
99
- $logger->log_info(__METHOD__,'Process LOCK failed');
100
- return false;
101
- }
102
-
103
- } catch(Exception $e) {
104
- $logger->log_info(__METHOD__,'Process Lock error: ' .$e);
105
- return false;
106
- }
107
- }
108
-
109
- /**
110
- * End Backup Process
111
- * @return bool
112
- */
113
- public static function end (){
114
- //$this->logger->log_info(__METHOD__,'Begin - Unlock File:' . $this->lockFileName);
115
-
116
- try{
117
- //$this->logger->log_info(__METHOD__,'LOCK released - backup ending');
118
- flock( self::$lockFile, LOCK_UN); // unlock the file
119
- return true;
120
-
121
- }catch(Exception $e) {
122
- //$this->logger->log_error(__METHOD__,'Cant unlock file: ' .$e);
123
- return false;
124
- }
125
- }
126
-
127
- /**
128
- * Check lock status
129
- * @return bool
130
- */
131
- public function check_lock_status (){
132
- //Check for 5 minutes then give up
133
- for ($i = 1; $i <= 100; $i++) {
134
- if ($this->start()){
135
- $this->end();
136
- return true;
137
- }
138
- else{
139
- sleep(3); //sleep for 3 seconds
140
- }
141
- }
142
- return false;
143
- }
144
-
145
- public function isScheduled(){
146
-
147
- return true;
148
- }
149
-
150
- public function cleanup_backups_by_prefix($prefix) {
151
- $this->logger->log_info( __METHOD__, 'Begin' );
152
- $backup_root_path=$this->backup_folder_root;
153
-
154
- //get a list of all the temps
155
- $work_folder_list = glob($backup_root_path. $prefix .'*', GLOB_ONLYDIR);
156
- $file_system = new WPBackItUp_FileSystem($this->logger);
157
- foreach($work_folder_list as $folder) {
158
- $file_system->recursive_delete($folder);
159
- }
160
-
161
- $this->logger->log_info( __METHOD__, 'End' );
162
- }
163
-
164
- public function cleanup_old_backups() {
165
- $this->logger->log_info( __METHOD__, 'Begin' );
166
-
167
- // --PURGE BACKUP FOLDER
168
- //Purge logs in backup older than N days
169
- $backup_root_path=$this->backup_folder_root;
170
- $file_system = new WPBackItUp_FileSystem($this->logger);
171
-
172
- //check retention limits
173
- $file_system->purge_folders($backup_root_path,'*',$this->backup_retained_number);
174
-
175
- $this->logger->log_info( __METHOD__, 'End' );
176
- }
177
-
178
-
179
- public function cleanup_unfinished_backups_OLD(){
180
- $dir=$this->backup_folder_root;
181
- $this->logger->log_info(__METHOD__,'Begin:'.$dir);
182
- $ignore = array('cgi-bin','.','..','._');
183
- if( is_dir($dir) ){
184
- if($dh = opendir($dir)) {
185
- while( ($file = readdir($dh)) !== false ) {
186
- $ext = pathinfo($file, PATHINFO_EXTENSION);
187
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.' && $ext!="zip" && $ext!="log") { //Check the file is not in the ignore array
188
- if(!is_dir($dir .'/'. $file)) {
189
- unlink($dir .'/'. $file);
190
- } else {
191
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
192
- $fileSystem->recursive_delete($dir.'/'. $file, $ignore);
193
- }
194
- }
195
- }
196
- }
197
- closedir($dh);
198
- }
199
- $this->logger->log_info(__METHOD__,'End');
200
- return true;
201
- }
202
-
203
- public function cleanup_current_backup(){
204
- $path = $this->backup_project_path;
205
- $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
206
-
207
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
208
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
209
-
210
- if(!$fileSystem ->delete_files($work_files)) {
211
- $this->logger->log_error(__METHOD__,'Work files could not be deleted');
212
- return false;
213
- }
214
-
215
- $this->logger->log_info(__METHOD__,'End - Work Files Deleted');
216
- return true;
217
- }
218
-
219
- public function delete_site_data_files(){
220
- $path = $this->backup_project_path;
221
- $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
222
-
223
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
224
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
225
-
226
- if(!$fileSystem ->delete_files($work_files)) {
227
- $this->logger->log_error(__METHOD__,'Work files could not be deleted');
228
- return false;
229
- }
230
-
231
- $this->logger->log_info(__METHOD__,'End - Work Files Deleted');
232
- return true;
233
- }
234
-
235
-
236
- public function purge_old_files(){
237
- $this->logger->log_info(__METHOD__,'Begin');
238
- $fileSystem = new WPBackItUp_FileSystem( $this->logger);
239
-
240
- //Check the retention
241
- $fileSystem->purge_FilesByDate($this->backup_retained_number,$this->backup_folder_root);
242
-
243
- // --PURGE BACKUP FOLDER
244
- //Purge logs in backup older than N days
245
- $backup_path = WPBACKITUP__BACKUP_PATH .'/';
246
- $fileSystem->purge_files($backup_path,'*.log',$this->backup_retained_days);
247
-
248
- //Purge restore DB checkpoints older than 5 days
249
- $fileSystem->purge_files($backup_path,'db*.cur',$this->backup_retained_days);
250
-
251
- // --PURGE LOGS FOLDER
252
- $logs_path = WPBACKITUP__PLUGIN_PATH .'/logs/';
253
-
254
- //Purge logs in logs older than 5 days
255
- $fileSystem->purge_files($logs_path,'*.log',$this->backup_retained_days);
256
-
257
- //Purge Zipped logs in logs older than 5 days
258
- $fileSystem->purge_files($logs_path,'*.zip',$this->backup_retained_days);
259
-
260
- //Purge logs in logs older than 5 days
261
- // $fileSystem->purge_files($logs_path,'Backup_*.log',$this->backup_retained_days);
262
-
263
- // //Purge debug logs in logs older than 5 days
264
- // $fileSystem->purge_files($logs_path,'*debug*.log',$this->backup_retained_days);
265
- //
266
- // //Purge upload logs in logs older than 5 days
267
- // $fileSystem->purge_files($logs_path,'*upload*.log',$this->backup_retained_days);
268
- //
269
- // //Purge cleanup logs in logs older than 5 days
270
- // $fileSystem->purge_files($logs_path,'*cleanup*.log',$this->backup_retained_days);
271
- //
272
- // //Purge Zipped logs in logs older than 5 days
273
- // $fileSystem->purge_files($logs_path,'logs_*.zip',$this->backup_retained_days);
274
- //
275
- // //Purge restore logs in logs older than 5 days
276
- // $fileSystem->purge_files($logs_path,'*restore*.log',$this->backup_retained_days);
277
-
278
- $this->logger->log_info(__METHOD__,'End');
279
-
280
- }
281
-
282
- //Make sure the root backup folder wpbackitup_backups exists
283
- public function backup_root_folder_exists(){
284
- $this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_folder_root);
285
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
286
- if(!$fileSystem->create_dir($this->backup_folder_root)) {
287
- $this->logger->log_error(__METHOD__,' Cant create backup folder :'. $this->backup_folder_root);
288
- return false;
289
- }
290
-
291
- $fileSystem->secure_folder($this->backup_folder_root);
292
-
293
- //Make sure logs folder is secured
294
- $logs_dir = WPBACKITUP__PLUGIN_PATH .'/logs/';
295
- $fileSystem->secure_folder( $logs_dir);
296
-
297
-
298
- $this->logger->log_info(__METHOD__,'End');
299
- return true;
300
- }
301
-
302
- //Create the root folder for the current backup
303
- public function create_current_backup_folder(){
304
- $this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_project_path);
305
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
306
- if(!$fileSystem->create_dir($this->backup_project_path)) {
307
- $this->logger->log_error(__METHOD__,'Cant create backup folder :'. $this->backup_project_path);
308
- return false;
309
- }
310
-
311
- $this->logger->log_info(__METHOD__,'End');
312
- return true;
313
- }
314
-
315
- //Check to see if the directory exists and is writeable
316
- public function backup_folder_exists(){
317
- $path=$this->backup_project_path;
318
- $this->logger->log_info(__METHOD__,'Is folder writeable: ' .$path);
319
- if(is_writeable($path)) {
320
- $this->logger->log_info(__METHOD__,'Folder IS writeable');
321
- return true;
322
- }
323
-
324
- $this->logger->log_error(__METHOD__,'Folder NOT writeable');
325
- return false;
326
- }
327
-
328
- //Export the SQL database
329
- public function export_database(){
330
- $sql_file_name=$this->backup_project_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
331
- $sqlUtil = new WPBackItUp_SQL($this->logger);
332
- $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$sql_file_name);
333
-
334
- //Try SQLDump First
335
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
336
- if(!$sqlUtil->mysqldump_export($sql_file_name) ) {
337
-
338
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP/PATH');
339
- if(!$sqlUtil->mysqldump_export($sql_file_name,true) ) {
340
-
341
- $this->logger->log_info(__METHOD__,'Export DB with Manual SQL EXPORT');
342
- if(!$sqlUtil->manual_export($sql_file_name) ) {
343
- $this->logger->log_error(__METHOD__,'SQL EXPORT FAILED');
344
- return false;
345
- }
346
- }
347
- }
348
- $this->logger->log_info(__METHOD__,'Database Exported successfully');
349
-
350
- // Uncomment when encryption is added
351
- // backup wp.config
352
- // $from_path = get_home_path() .'/wp-config.php';
353
- // $to_path = $this->backup_project_path .'/wp-config.bak';
354
- // $file_system = new WPBackItUp_FileSystem($this->logger);
355
- // $file_system->copy_file($from_path,$to_path);
356
-
357
- return true;
358
- }
359
-
360
- //Create siteinfo in project dir
361
- public function create_siteinfo_file(){
362
- global $table_prefix; //from wp-config
363
- $path=$this->backup_project_path;
364
- $siteinfo = $path ."backupsiteinfo.txt";
365
-
366
- $this->logger->log_info(__METHOD__,'Create Site Info File:'.$siteinfo);
367
- try {
368
- $handle = fopen($siteinfo, 'w+');
369
- if (false===$handle){
370
- $this->logger->log_error(__METHOD__,'Cant open file.');
371
- return false;
372
- }
373
-
374
- //Probably should change to json format
375
-
376
- //Write Site URL
377
- $entry = site_url( '/' ) ."\n";
378
- fwrite($handle, $entry);
379
-
380
- //Write Table Prefix
381
- $entry = $table_prefix ."\n" ;
382
- fwrite($handle, $entry);
383
-
384
- //write WP version
385
- $entry =get_bloginfo( 'version')."\n" ;
386
- fwrite($handle, $entry);
387
-
388
- //write WP BackItUp
389
- $entry =WPBACKITUP__VERSION."\n" ;
390
- fwrite($handle, $entry);
391
-
392
- fclose($handle);
393
-
394
-
395
- if (file_exists($siteinfo)){
396
- $this->logger->log_info(__METHOD__,'File created successfully.');
397
- return true;
398
- }
399
-
400
- }catch(Exception $e) {
401
- $this->this->logger->log_error(__METHOD__,' Exception: ' .$e);
402
- }
403
-
404
- $this->logger->log_error(__METHOD__,'Site Info File NOT Created.');
405
- return false;
406
- }
407
-
408
- public function get_plugins_file_list() {
409
- $this->logger->log_info( __METHOD__, 'Begin' );
410
-
411
- $file_system = new WPBackItUp_FileSystem($this->logger);
412
- $plugins_file_list = $file_system->get_recursive_file_list(WPBACKITUP__PLUGINS_ROOT_PATH. '/*' );
413
- $this->logger->log_info( __METHOD__, 'Plugin File Count: ' .count($plugins_file_list));
414
-
415
- return $plugins_file_list;
416
- }
417
-
418
- public function get_themes_file_list() {
419
- $this->logger->log_info( __METHOD__, 'Begin' );
420
-
421
- $file_system = new WPBackItUp_FileSystem($this->logger);
422
- $themes_root_path = WPBACKITUP__THEMES_ROOT_PATH;
423
- $themes_file_list = $file_system->get_recursive_file_list($themes_root_path. '/*' );
424
- $this->logger->log_info( __METHOD__, 'Themes File Count: ' .count($themes_file_list));
425
-
426
- return $themes_file_list;
427
- }
428
-
429
- public function get_uploads_file_list() {
430
- $this->logger->log_info( __METHOD__, 'Begin' );
431
-
432
- $upload_array = wp_upload_dir();
433
- $uploads_root_path = $upload_array['basedir'];
434
-
435
- //ignore these folders under uploads
436
- $ignore = explode(',',WPBACKITUP__BACKUP_IGNORE_LIST);
437
-
438
- $uploads_folderlist = glob($uploads_root_path. '/*',GLOB_ONLYDIR|GLOB_NOSORT);
439
- $uploads_file_list=array();
440
-
441
- $file_system = new WPBackItUp_FileSystem($this->logger);
442
- foreach ( $uploads_folderlist as $folder ) {
443
- if (! $this->strposa(basename($folder), $ignore)){
444
- array_push($uploads_file_list,$folder);
445
- $file_list = $file_system->get_recursive_file_list($folder. '/*' );
446
- $uploads_file_list = array_merge($uploads_file_list,$file_list);
447
- }
448
- }
449
-
450
- //Need to grab the files in the root also
451
- $files_only = array_filter(glob($uploads_root_path. '/*'), 'is_file');
452
- if (count($files_only)>0){
453
- $uploads_file_list = array_merge($uploads_file_list,$files_only);
454
- }
455
-
456
- $this->logger->log_info( __METHOD__, 'Themes File Count: ' .count($uploads_file_list));
457
-
458
- return $uploads_file_list;
459
- }
460
-
461
- public function get_other_file_list() {
462
- $this->logger->log_info( __METHOD__, 'Begin' );
463
-
464
- $wpcontent_path = WPBACKITUP__CONTENT_PATH;
465
-
466
- $upload_array = wp_upload_dir();
467
- $uploads_folder = basename ($upload_array['basedir']);
468
- $themes_folder = basename (WPBACKITUP__THEMES_ROOT_PATH);
469
- $plugins_folder = basename (WPBACKITUP__PLUGINS_ROOT_PATH);
470
-
471
- //ignore these folders
472
- $wpback_ignore = explode(',',WPBACKITUP__BACKUP_IGNORE_LIST);
473
- $wpcontent_ignore=array($uploads_folder, $themes_folder, $plugins_folder);
474
- $ignore = array_merge($wpback_ignore,$wpcontent_ignore);
475
-
476
- $wpcontent_folderlist = glob($wpcontent_path. '/*',GLOB_ONLYDIR|GLOB_NOSORT);
477
-
478
- $other_file_list=array();
479
- $file_system = new WPBackItUp_FileSystem($this->logger);
480
- foreach ( $wpcontent_folderlist as $folder ) {
481
- if (!$this->strposa(basename($folder), $ignore)){
482
- array_push($other_file_list,$folder);
483
- $file_list = $file_system->get_recursive_file_list($folder. '/*' );
484
- $other_file_list = array_merge($other_file_list,$file_list);
485
- }
486
- }
487
-
488
- //Need to grab the files in the root also
489
- $files_only = array_filter(glob($wpcontent_path. '/*'), 'is_file');
490
- if (count($files_only)>0){
491
-
492
- //Get rid of the debug.log file - dont want to restore it
493
- $debug_log_index = $this->search_array('debug.log', $files_only);
494
- if (false!==$debug_log_index) {
495
- unset($files_only[$debug_log_index]);
496
- }
497
-
498
- $other_file_list = array_merge($other_file_list,$files_only);
499
- }
500
-
501
- $this->logger->log_info( __METHOD__, 'Other File Count: ' .count($other_file_list));
502
-
503
- return $other_file_list;
504
- }
505
-
506
-
507
- //BackUp
508
- public function backup_file_list($source_root,$target_root,$suffix,$file_list,$batch_size,$ignore=''){
509
- $this->logger->log_info(__METHOD__,'Begin - Item Count: '. count($file_list));
510
-
511
- $zip_file_path = $this->backup_project_path . $this->backup_name .'-'.$suffix .'.tmp';
512
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
513
-
514
- foreach($file_list as $item) {
515
-
516
- //skip it if in ignore
517
- if ( !empty($ignore) && false!== strpos($item,$ignore)) {
518
- $this->logger->log_info( __METHOD__, 'Skip File:' . $item );
519
- array_shift($file_list); //remove from list
520
- continue;
521
- }
522
-
523
- //skip it if folder
524
- if ( is_dir( $item ) ) {
525
- $this->logger->log_info( __METHOD__, 'Skip folder:' . $item );
526
- array_shift( $file_list ); //remove from list
527
- continue;
528
- }
529
-
530
-
531
- //replace the source path with the target
532
- $target_item_path = str_replace(rtrim($source_root, '/'),rtrim($target_root,'/'),$item);
533
- if ( $zip->add_file($item,$target_item_path)) {
534
- array_shift($file_list);
535
- $this->logger->log_info( __METHOD__, 'File Added:' . $target_item_path );
536
- $this->logger->log_info( __METHOD__, 'Zip file count:' . $zip->get_zip_file_count() . '>=' . $batch_size);
537
-
538
- //If we have added X# of files or hit the size limit then lets close the zip and finish on the next pass
539
- if( $zip->get_zip_file_count()>=$batch_size){
540
-
541
- $zip->close();//close the zip
542
-
543
- //check the compressed file size
544
- $compressed_zip_file_size = $zip->get_zip_actual_size();
545
- $this->logger->log_info( __METHOD__, 'Zip Actual Size after close:' . $zip->get_zip_actual_size());
546
-
547
- //if the zip is too big we need to rename it
548
- $threshold = $zip->get_max_zip_size(.8);
549
- if ($compressed_zip_file_size >= $threshold) {
550
- $this->logger->log_info(__METHOD__,'Zip hit max size threshold:'.$compressed_zip_file_size .'>' .$threshold );
551
- if (! $this->add_zip_suffix($zip_file_path)){
552
- return 'error';
553
- }
554
- }
555
-
556
- $this->logger->log_info(__METHOD__,'End - Item Count:' . count($file_list));
557
- return $file_list;
558
- }
559
- } else {
560
- $this->logger->log_error( __METHOD__, 'File NOT added:' . $target_item_path );
561
- return 'error';
562
- }
563
- }
564
-
565
-
566
- //if we get here then close the zip
567
- $zip->close();//close the zip
568
-
569
- //if there are no more files to add then rename the zip
570
- //Check to see if the file exists, it is possible that it does not if only empty folders were contained
571
- if(count($file_list)==0 && file_exists($zip_file_path) ){
572
- $this->logger->log_info( __METHOD__, 'Zip Actual Size after close:' . $zip->get_zip_actual_size());
573
- if (! $this->add_zip_suffix($zip_file_path)){
574
- return 'error';
575
- }
576
- }
577
-
578
- $this->logger->log_info(__METHOD__,'End - Item Count:' . count($file_list));
579
- return $file_list;
580
- }
581
-
582
-
583
- private function strposa($haystack, $needle) {
584
- if(!is_array($needle)) $needle = array($needle);
585
-
586
- foreach($needle as $query) {
587
- //If wildcard on end then compare
588
- if ('*' == substr($query, -1) && strpos( $haystack, rtrim($query,"*")) !== false) {
589
- return true;
590
- } else {
591
- if ( $haystack==$query ) {
592
- return true;
593
- }
594
- }
595
- }
596
- return false;
597
- }
598
-
599
- private function add_zip_suffix($zip_file_path){
600
- $this->logger->log_info(__METHOD__,'Begin');
601
-
602
- $file_extension = pathinfo($zip_file_path, PATHINFO_EXTENSION);
603
- $this->logger->log_info(__METHOD__,'File Extension:'.$file_extension);
604
- if ($file_extension!='zip'){
605
- $file_system = new WPBackItUp_FileSystem($this->logger);
606
- $new_zip_name = str_replace('.' . $file_extension,'-'.time() .'.zip',$zip_file_path);
607
- if ( !$file_system->rename_file($zip_file_path,$new_zip_name)){
608
- $this->logger->log_error(__METHOD__,'Zip could not be renamed.');
609
- return false;
610
- }
611
- }
612
-
613
- //if we get here the file was renamed or was .zip already
614
- return true;
615
- }
616
-
617
- public function finalize_zip_file() {
618
- $this->logger->log_info(__METHOD__,'Begin - Finalize the zip.');
619
-
620
- $zip_file_path = $this->backup_folder_root . $this->backup_filename;
621
- $new_zip_name = str_replace('.tmp','.zip',$zip_file_path);
622
-
623
- $file_system = new WPBackItUp_FileSystem($this->logger);
624
- if (! $file_system->rename_file($zip_file_path,$new_zip_name)){
625
- $this->logger->log_error(__METHOD__,'Zip could not be finalized.');
626
- return false;
627
- }
628
-
629
- //Change the file name property moving forward
630
- $this->set_zip_extension();
631
-
632
- $this->logger->log_info(__METHOD__,'End - Zip Finalized successfully.');
633
- return true;
634
- }
635
-
636
- //Set zip extension to zip
637
- public function set_zip_extension() {
638
- $this->logger->log_info(__METHOD__,'Begin - change zip extension to zip');
639
-
640
- $this->backup_filename = substr_replace($this->backup_filename, '.zip', -4);
641
- //$this->backup_filename=str_replace('.tmp','.zip',$this->backup_filename);
642
-
643
- $this->logger->log_info(__METHOD__,'End - Zip extension changed:' . $this->backup_filename);
644
-
645
- }
646
-
647
- //Create manifest file
648
- public function create_backup_manifest(){
649
- $this->logger->log_info(__METHOD__,'Begin');
650
-
651
- //get a list of all the zips
652
- $backup_files_path = array_filter(glob($this->backup_project_path. '*.zip'), 'is_file');
653
- if (count($backup_files_path)>0){
654
- //get rid of the path.
655
- $backup_files = str_replace($this->backup_project_path,'',$backup_files_path);
656
- $manifest_file=$this->backup_project_path . 'backupmanifest.txt';
657
- file_put_contents($manifest_file,json_encode($backup_files));
658
-
659
- //Find the main zip in the array to get the path
660
- $main_zip_index = $this->search_array('-main-', $backup_files_path);
661
-
662
- //add it to the main zip file
663
- if ($main_zip_index!==false){
664
- $zip_file_path = $backup_files_path[$main_zip_index];
665
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
666
- $target_item_path = str_replace(rtrim($this->backup_project_path, '/'),rtrim('site-data','/'),$manifest_file);
667
- if ( $zip->add_file($manifest_file,$target_item_path)) {
668
- $zip->close();//close the zip
669
- $this->logger->log_info(__METHOD__,'End - Manifest created.');
670
- return true;
671
- }
672
- }
673
- }
674
-
675
- $this->logger->log_error(__METHOD__,'End - Manifest not created.');
676
- return false;
677
- }
678
-
679
- private function search_array($search, $array)
680
- {
681
- foreach($array as $key => $value)
682
- {
683
- if (stristr($value, $search))
684
- {
685
- return $key;
686
- }
687
- }
688
- return false;
689
- }
690
-
691
-
692
- public function rename_backup_folder() {
693
- $this->logger->log_info(__METHOD__,'Begin');
694
-
695
- $backup_project_path = $this->backup_project_path;
696
- //remove the 4 character prefix
697
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
698
-
699
- $file_system = new WPBackItUp_FileSystem($this->logger);
700
- if (! $file_system->rename_file($backup_project_path,$new_backup_path)){
701
- $this->logger->log_error(__METHOD__,'Folder could not be renamed');
702
- return false;
703
- }
704
-
705
- $this->set_final_backup_path();
706
-
707
- $this->logger->log_info(__METHOD__,'End');
708
- return true;
709
- }
710
-
711
- //this is needed because it is set to TMP until finalization then needed a way to know where the current path is
712
- public function set_final_backup_path(){
713
- $this->logger->log_info(__METHOD__,'Begin');
714
-
715
- $backup_project_path = $this->backup_project_path;
716
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
717
-
718
- //set the path to the new path
719
- $this->backup_project_path=$new_backup_path;
720
-
721
- $this->logger->log_info(__METHOD__,'End');
722
- }
723
-
724
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-filesystem.php DELETED
@@ -1,553 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup Utility Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
- /*** Includes ***/
12
- // include backup class
13
- if( !class_exists( 'WPBackItUp_RecursiveFilter_Iterator' ) ) {
14
- include_once 'class-recursiveFilter_Iterator.php';
15
- }
16
-
17
- class WPBackItUp_FileSystem {
18
-
19
- private $logger;
20
-
21
- function __construct($logger=null) {
22
- try {
23
- if (null==$logger){
24
- $this->logger = new WPBackItUp_Logger(true,null,'debug_filesystem');
25
- } else{
26
- $this->logger = $logger;
27
- }
28
- } catch(Exception $e) {
29
- //Dont do anything
30
- print $e;
31
- }
32
- }
33
-
34
- function __destruct() {
35
-
36
- }
37
-
38
- public function create_dir($dir) {
39
- $this->logger->log('(FileSytem.create_dir) Create Directory: ' .$dir);
40
- if( !is_dir($dir) ) {
41
- @mkdir($dir, 0755);
42
- }
43
- $this->logger->log('(FileSytem.create_dir) Directory created: ' .$dir);
44
- return true;
45
- }
46
-
47
- public function recursive_delete($dir, $ignore = array('') ){
48
- $this->logger->log('(FileSystem.recursive_delete) Recursively Delete: ' .$dir);
49
-
50
- $this->logger->log('(FileSystem.recursive_delete) Ignore:');
51
- $this->logger->log($ignore);
52
-
53
- if( is_dir($dir) ){
54
- //Make sure the folder is not in the ignore array
55
- if (!$this->delete_ignore($dir,$ignore)){
56
- if($dh = opendir($dir)) {
57
- while( ($file = readdir($dh)) !== false ) {
58
- if (!$this->delete_ignore($file,$ignore)) { //Check the file is not in the ignore array
59
- if(!is_dir($dir .'/'. $file)) {
60
- unlink($dir .'/'. $file); //delete the file
61
- $this->logger->log('(FileSytem.recursive_delete) File Deleted:' .$dir .'/'. $file);
62
- } else {
63
- //This is a dir so delete the files first
64
- $this->recursive_delete($dir.'/'. $file, $ignore);
65
- }
66
- }
67
- }
68
- }
69
- //Remove the directory
70
- @rmdir($dir);
71
- $this->logger->log('(FileSystem.recursive_delete) Folder Deleted:' .$dir);
72
- closedir($dh);
73
- }
74
- }
75
- $this->logger->log('(FileSystem.recursive_delete) Recursive Delete Completed.');
76
- return true;
77
- }
78
-
79
- public function recursive_copy($dir, $target_path, $ignore = array('') ) {
80
- $this->logger->log('(FileSystem.recursive_copy) Recursive copy FROM: ' .$dir);
81
- $this->logger->log('(FileSystem.recursive_copy) Recursive Copy TO: '.$target_path);
82
- $this->logger->log('(FileSystem.recursive_copy) IGNORE:');
83
- $this->logger->log($ignore);
84
-
85
- if( is_dir($dir) ) { //If the directory exists
86
- //Exclude all the OTHER backup folders under wp-content
87
- //Will create the folders but NOT the contents
88
- if (!$this->ignore($dir,$ignore) && !$this->is_backup_folder($dir) ){
89
- if ($dh = opendir($dir) ) {
90
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
91
- if (!$this->ignore($file,$ignore)) { //Check the file is not in the ignore array
92
- if (!is_dir( $dir.$file ) ) {
93
- try {
94
- $fsrc = fopen($dir .$file,'r');
95
- $fdest = fopen($target_path .$file,'w+');
96
- stream_copy_to_stream($fsrc,$fdest);
97
- fclose($fsrc);
98
- fclose($fdest);
99
- } catch(Exception $e) {
100
- $this->logger->log('(FileSystem.recursive_copy) File Copy Exception: ' .$e);
101
- return false;
102
- }
103
- } else { //If $file is a directory
104
- $destdir = $target_path .$file; //Modify the destination dir
105
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
106
- $this->logger->log('(FileSytem.recursive_copy) Create Folder: ' .$destdir);
107
- try {
108
- @mkdir($destdir, 0755);
109
- } catch(Exception $e) {
110
- $this->logger->log('(FileSystem.recursive_copy)Create Folder Exception: ' .$e);
111
- return false;
112
- }
113
- }
114
- $this->recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
115
- }
116
- }
117
- }
118
- closedir($dh);
119
- }
120
- }
121
- }
122
-
123
- $this->logger->log('(FileSystem.recursive_copy) Completed');
124
- return true;
125
- }
126
-
127
- public function recursive_validate($source_path, $target_path, $ignore = array('') ) {
128
- // $this->logger->log('(FileSystem.recursive_validate) Recursive validate FROM: ' .$source_path);
129
- // $this->logger->log('(FileSystem.recursive_validate) Recursive validate TO: '.$target_path);
130
- // $this->logger->log('(FileSystem.recursive_validate) IGNORE:');
131
- // $this->logger->log($ignore);
132
-
133
- $rtnVal=true;
134
- if( is_dir($source_path) ) { //If the directory exists
135
- if (!$this->ignore($source_path,$ignore)){
136
- if ($dh = opendir($source_path) ) {
137
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
138
- if ( !$this->ignore($file,$ignore)) { //Check the file is not in the ignore array
139
- if (!is_dir( $source_path.$file ) ) {
140
- try {
141
- $source_file = $source_path .$file;
142
- $target_file = $target_path .$file;
143
-
144
- if (!file_exists($target_file)) {
145
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF - Target file doesnt exist:' . $target_file);
146
- $rtnVal=false;
147
- continue;
148
- }
149
-
150
- $source_file_size = filesize ($source_file);
151
- $target_file_size = filesize ($target_file);
152
-
153
- if ($source_file_size != $target_file_size){
154
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Source:' . $source_file);
155
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Target:' . $target_file);
156
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Size:' . $source_file_size .':' . $target_file_size);
157
- $rtnVal=false;
158
- continue;
159
- }
160
-
161
- } catch(Exception $e) {
162
- $this->logger->log('(FileSystem.recursive_validate) Exception: ' .$e);
163
- return false;
164
- }
165
- } else { //If $file is a directory
166
- $destdir = $target_path .$file; //Modify the destination dir
167
- if(!is_dir($destdir)) {
168
- $this->logger->log('(FileSytem.recursive_validate) DIFF Folder doesnt exist: ' .$destdir);
169
- $rtnVal= false;
170
- }else{
171
- $dir_rtnVal=$this->recursive_validate($source_path .$file .'/', $target_path .$file .'/', $ignore);
172
- //Don't want to set to true as its the default on all calls
173
- if (!$dir_rtnVal) $rtnVal = false;
174
- }
175
- }
176
- }
177
- }
178
- closedir($dh);
179
- }
180
- }
181
- }
182
-
183
- //$this->logger->log('(FileSystem.recursive_validate) Completed:' . ($rtnVal ? 'true' : 'false'));
184
- return $rtnVal;
185
- }
186
-
187
- private function ignore($file, $ignoreList){
188
-
189
- //Exclude these files and folders from the delete
190
- if (in_array(basename($file), $ignoreList) ||
191
- substr($file, 0, 1) == '.' ||
192
- ($file == "." ) ||
193
- ($file == ".." ) ||
194
- ($file == "._" ) ||
195
- ($file == "cgi-bin" )) {
196
-
197
- //$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
198
- return true;
199
- }
200
-
201
- return false;
202
- }
203
-
204
- private function delete_ignore($file, $ignoreList){
205
-
206
- //Exclude these files and folders from the delete
207
- if (in_array(basename($file), $ignoreList) ||
208
- //substr($file, 0, 1) == '.' ||
209
- ($file == "." ) ||
210
- ($file == ".." ))
211
- //($file == "._" )
212
- //($file == "cgi-bin" ))
213
- {
214
- //$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
215
- return true;
216
- }
217
-
218
- return false;
219
- }
220
-
221
- //Check for backup folders
222
- private function is_backup_folder($dir){
223
- if (
224
- strpos(strtolower($dir),'/wp-content/backup')!== false ||
225
- strpos(strtolower($dir),'/wp-content/updraft')!== false ||
226
- strpos(strtolower($dir),'/wp-content/wp-clone')!== false ||
227
- strpos(strtolower($dir),'/wp-content/uploads/backwpup')!== false ||
228
- strpos(strtolower($dir),'/wp-content/uploads/backupwordpress')!== false
229
- ){
230
-
231
- $this->logger->log('(FileSystem.is_backup_folder) SKIP Backup Folder: ' .$dir);
232
- return true;
233
-
234
- }else{
235
- return false;
236
- }
237
-
238
- }
239
-
240
-
241
- // function delete_children_recursive($path, $ignore = array('cgi-bin','._'))
242
- // { //The filters are not working on this method
243
- // return false;
244
- // if (is_dir($path))
245
- // {
246
- // $this->logger->log('(FileSystem_delete_children_recursive) Ignore:');
247
- // $this->logger->log($ignore);
248
- //
249
- // $iterator = new RecursiveDirectoryIterator($path);
250
- // $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
251
- // $filter = new WPBackItUp_RecursiveFilter_Iterator($iterator);
252
- // $filter->set_filter($ignore);
253
- //
254
- // $all_files = new RecursiveIteratorIterator($filter,RecursiveIteratorIterator::CHILD_FIRST);
255
- //
256
- // foreach ($all_files as $file)
257
- // {
258
- // if ($file->isDir())
259
- // {
260
- // $this->logger->log('(delete_recursive_new) delete folder:'.$file);
261
- // rmdir($file->getPathname());
262
- // }
263
- // else
264
- // {
265
- // $this->logger->log('(delete_recursive_new) delete file:'.$file);
266
- // unlink($file->getPathname());
267
- //
268
- // }
269
- //
270
- // $this->logger->log('(FileSystem_delete_children_recursive) Deleted:' . $file);
271
- // }
272
- // }
273
- // return true;
274
- // }
275
-
276
-
277
- public function purge_FilesByDate($number_Files_Allowed,$path)
278
- {
279
- $this->logger->log('(FileSytem.purge_FilesByDate) Purge files by date:' .$number_Files_Allowed .':'.$path);
280
-
281
- if (is_numeric($number_Files_Allowed) && $number_Files_Allowed> 0){
282
- $FileList = glob($path . "*.zip");
283
-
284
- //Sort by Date Time
285
- usort($FileList, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
286
-
287
- $i = 1;
288
- foreach ($FileList as $key => $val)
289
- {
290
- $this->logger->log_info(__METHOD__,' File:'.$val);
291
- $this->logger->log_info(__METHOD__,' File Date Time:'.filemtime($val));
292
-
293
- if($i <= $number_Files_Allowed)
294
- {
295
- $i++;
296
- continue;
297
- }
298
- else{
299
- $log_file_path = str_replace('.zip','.log',$val);
300
- if (file_exists($val)) unlink($val);
301
- if (file_exists($log_file_path)) unlink($log_file_path);
302
- $this->logger->log('(FileSytem.purge_FilesByDate) Delete File:)' .$val);
303
-
304
- }
305
- }
306
- }
307
- $this->logger->log('(FileSytem.purge_FilesByDate) Completed.');
308
- }
309
-
310
- public function purge_files($path, $file_pattern, $days)
311
- {
312
- $this->logger->log('(FileSytem.purge_files) Purge files days:' . $days);
313
- $this->logger->log('(FileSytem.purge_files) Purge files path:' . $path);
314
- $this->logger->log('(FileSytem.purge_files) Purge files extension:' . $file_pattern);
315
-
316
- //Check Parms
317
- if (empty($path) || empty($file_pattern) || !is_numeric($days)){
318
- $this->logger->log('(FileSytem.purge_files) Invalid Parm values');
319
- return false;
320
- }
321
-
322
- $FileList = glob($path . $file_pattern);
323
-
324
- //Sort by Date Time oldest first so can break when all old files are deleted
325
- usort($FileList, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
326
-
327
- foreach ($FileList as $key => $file)
328
- {
329
- $this->logger->log_info(__METHOD__,' File:'.$file);
330
- $this->logger->log_info(__METHOD__,' File Date Time:'.filemtime($file));
331
-
332
- $current_date = new DateTime('now');
333
- $file_mod_date = new DateTime(date('Y-m-d',filemtime($file)));
334
-
335
- //PHP 5.3 only
336
- //$date_diff = $current_date->diff($file_mod_date);
337
- //$date_diff_days = $date_diff->days;
338
-
339
- $util = new WPBackItUp_Utility( $this->logger);
340
- $date_diff_days=$util->date_diff_days($file_mod_date,$current_date);
341
-
342
- if($date_diff_days>=$days){
343
- if (file_exists($file)) unlink($file);
344
- $this->logger->log('Delete:' . $file);
345
- }
346
- else{
347
- break; //Exit for
348
- }
349
- }
350
- $this->logger->log('(FileSytem.purge_files) Completed.');
351
- return true;
352
- }
353
-
354
-
355
- /**
356
- * Purge the backups that exceed the retained number setting
357
- *
358
- * @param $path
359
- * @param $pattern
360
- * @param $retention_limit
361
- *
362
- * @return bool
363
- */
364
- public function purge_folders($path, $pattern, $retention_limit)
365
- {
366
- $this->logger->log_info(__METHOD__,' Purge folders retained number:' . $retention_limit);
367
- $this->logger->log_info(__METHOD__,' Purge folder path:' . $path);
368
- $this->logger->log_info(__METHOD__,' Purge pattern:' . $pattern);
369
-
370
- //Check Parms
371
- if (empty($path) || empty($pattern) || !is_numeric($retention_limit)){
372
- $this->logger->log_error(__METHOD__,' Invalid Parm values');
373
- return false;
374
- }
375
-
376
- $folder_list = glob($path . $pattern, GLOB_ONLYDIR);
377
- //Sort by Date Time so oldest is deleted first
378
- usort($folder_list, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
379
-
380
- $backup_count=0;
381
- foreach ($folder_list as $key => $folder)
382
- {
383
- $this->logger->log_info(__METHOD__,' Folder:'.$folder);
384
- $this->logger->log_info(__METHOD__,' Folder Date Time:'.filemtime($folder));
385
-
386
- ++$backup_count;
387
- if($backup_count>$retention_limit){
388
- if (file_exists($folder)) {
389
- $this->recursive_delete($folder);
390
- }
391
- }
392
- }
393
- $this->logger->log_info(__METHOD__,'End');
394
- return true;
395
- }
396
-
397
- public function delete_files($file_list)
398
- {
399
- $this->logger->log_info(__METHOD__,'Begin');
400
-
401
- foreach ($file_list as $key => $file)
402
- {
403
- if (file_exists($file)){
404
- unlink($file);
405
- $this->logger->log('Deleted:' . $file);
406
- }
407
- }
408
- $this->logger->log_info(__METHOD__,'End');
409
- return true;
410
- }
411
-
412
-
413
- function get_file_handle($path,$newFile=false) {
414
- $this->logger->log('(FileSytem.get_file_handle) Path:' . $path);
415
-
416
- try {
417
-
418
- if ($newFile && file_exists($path)){
419
- if (unlink($path)){
420
- $this->logger->log('(FileSytem.get_file_handle) Deleted:' . $path);
421
- }
422
- else{
423
- $this->logger->log('(FileSytem.get_file_handle) File could not be deleted:');
424
- $this->logger->log(error_get_last());
425
- }
426
- }
427
-
428
- $fh= fopen($path, 'w');
429
- if (false===$fh){
430
- $this->logger->log('(FileSytem.get_file_handle) File could not be opened:');
431
- $this->logger->log(error_get_last());
432
- return false;
433
- }
434
-
435
- return $fh;
436
-
437
- } catch(Exception $e) {
438
- $this->logger->log('(FileSytem.get_file_handle) Exception:' . $e);
439
- return false;
440
- }
441
- }
442
-
443
- /**
444
- * Copy single file
445
- * @param $from_file
446
- * @param $to_file
447
- *
448
- * @return bool
449
- */
450
- function copy_file($from_file,$to_file) {
451
- $this->logger->log('(FileSystem.copy_file) FROM Path:' . $from_file);
452
- $this->logger->log('(FileSystem.copy_file) TO Path:' . $to_file);
453
-
454
- try {
455
- if (file_exists($from_file)){
456
- if (copy($from_file,$to_file)){
457
- $this->logger->log('(FileSystem.copy_file) File copied successfully.');
458
- return true;
459
- }
460
- else{
461
- $this->logger->log('(FileSystem.copy_file) File could not be copied:');
462
- $this->logger->log(error_get_last());
463
- return false;
464
- }
465
- }
466
- else{
467
- $this->logger->log('(FileSystem.copy_file) FROM File doesnt exist');
468
- return false;
469
- }
470
-
471
- } catch(Exception $e) {
472
- $this->logger->log('(FileSystem.copy_file) Exception:' . $e);
473
- return false;
474
- }
475
- }
476
-
477
- /**
478
- * Rename single file
479
- * @param $from_file
480
- * @param $to_file_name
481
- *
482
- * @return bool
483
- */
484
- function rename_file($from_file,$to_file_name) {
485
- $this->logger->log_info(__METHOD__,' FROM Path:' . $from_file);
486
- $this->logger->log_info(__METHOD__,' TO Path:' . $to_file_name);
487
-
488
- try {
489
- if (file_exists($from_file)){
490
- if (rename($from_file,$to_file_name)){
491
- $this->logger->log_info(__METHOD__,'File renamed successfully.');
492
- return true;
493
- }
494
- else{
495
- $this->logger->log_error(__METHOD__,'File could not be renamed:');
496
- $this->logger->log(error_get_last());
497
- return false;
498
- }
499
- }
500
- else{
501
- $this->logger->log_error(__METHOD__,'FROM File doesnt exist');
502
- return false;
503
- }
504
-
505
- } catch(Exception $e) {
506
- $this->logger->log_error(__METHOD__,' Exception:' . $e);
507
- return false;
508
- }
509
- }
510
-
511
- /**
512
- * Make sure that htaccess/web.config files exist in folder
513
- * If folder doesnt exist then create it.
514
- * @param $path
515
- */
516
- function secure_folder($path){
517
- $this->logger->log_info(__METHOD__,'Begin');
518
-
519
- $path = rtrim($path,"/");
520
-
521
- if( !is_dir($path) ) {
522
- @mkdir($path, 0755);
523
- $this->logger->log_info(__METHOD__,'Folder Created:' .$path);
524
- }
525
-
526
- if (!is_file($path.'/index.html')) @file_put_contents($path.'/index.html',"<html><body><a href=\"http://www.wpbackitup.com\">WP BackItUp - The simplest way to backup WordPress</a></body></html>");
527
- if (!is_file($path.'/.htaccess')) @file_put_contents($path.'/.htaccess','deny from all');
528
- if (!is_file($path.'/web.config')) @file_put_contents($path.'/web.config', "<configuration>\n<system.webServer>\n<authorization>\n<deny users=\"*\" />\n</authorization>\n</system.webServer>\n</configuration>\n");
529
- $this->logger->log_info(__METHOD__,'Secure files exist or were created.');
530
-
531
-
532
- $this->logger->log_info(__METHOD__,'End');
533
- }
534
-
535
-
536
- public function get_recursive_file_list($pattern) {
537
- $this->logger->log_info( __METHOD__, 'Begin: ' .$pattern );
538
-
539
- return $this->glob_recursive($pattern);
540
- }
541
-
542
- private function glob_recursive($pattern, $flags = 0)
543
- {
544
- //The order here is important because the folders must be in the list before the files.
545
- $files = glob($pattern, $flags);
546
- foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR) as $dir)
547
- {
548
- $files = array_merge($files, $this->glob_recursive($dir.'/'.basename($pattern), $flags));
549
- }
550
-
551
- return $files;
552
- }
553
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-job.php DELETED
@@ -1,756 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
-
4
-
5
- class WPBackItUp_Job {
6
-
7
- const JOB_TITLE='wpbackitup_job';
8
-
9
- private $logger;
10
- private $job_id;
11
- private $allocated_task;
12
-
13
- public $job_status;
14
- public $backup_id;
15
-
16
- private $job_start_time;
17
- private $job_end_time;
18
-
19
- static private $backup_tasks = array(
20
- 1=>'task_preparing',
21
- 2=>'task_backup_db' ,
22
- 3=>'task_backup_siteinfo',
23
- 4=>'task_backup_themes',
24
- 5=>'task_backup_plugins',
25
- 6=>'task_backup_uploads',
26
- 7=>'task_backup_other',
27
- 8=>'task_validate_backup',
28
- 9=>'task_finalize_backup',
29
- );
30
-
31
- static private $restore_tasks = array(
32
- 1=>'task_preparing',
33
- 2=>'task_unzip_backup_set',
34
- 3=>'task_validate_backup',
35
- 4=>'task_create_checkpoint',
36
- 5=>'task_stage_wpcontent',
37
- 6=>'task_restore_wpcontent',
38
- 8=>'task_restore_database',
39
- );
40
-
41
- static private $cleanup_tasks = array(
42
- 1=>'task_scheduled_cleanup'
43
- );
44
-
45
- function __construct($job) {
46
- try {
47
- $this->logger = new WPBackItUp_Logger(false,null,'debug_job');
48
-
49
- //Load of the class properties from the post object(see wp_post)
50
- $this->job_id=$job->ID;
51
- $this->job_status=$job->post_status;
52
- $this->backup_id=$job->post_name;
53
-
54
- //Deserialize content
55
- $content = $job->post_content;
56
- if (!empty($content)){
57
- $job_info =maybe_unserialize($content);
58
- if (is_array($job_info)){
59
- $this->job_start_time=$job_info['start_time'];
60
- }
61
- }
62
-
63
- } catch(Exception $e) {
64
- error_log($e); //Log to debug
65
- }
66
- }
67
-
68
- function __destruct() {
69
-
70
- }
71
-
72
- public function is_job_complete() {
73
- $this->logger->log_info( __METHOD__, 'Begin' );
74
-
75
- $tasks = get_post_meta( $this->job_id);
76
- foreach($tasks as $key=>$value) {
77
- //Is this a task of job meta data
78
- if (substr($key, 0, 4)!='task') continue;
79
-
80
- $task = get_post_meta($this->job_id,$key);
81
-
82
- //Get Task Properties
83
- $task_id = $task[0]['task_id'];
84
- $task_status = $task[0]['task_status'];
85
- $task_allocated_id = $task[0]['task_allocated_id'];
86
- $task_last_updated = $task[0]['task_last_updated'];
87
-
88
- if ('queued'==$task_status || 'active'==$task_status){
89
- $this->logger->log_info( __METHOD__, 'Active or Queued Task found:' . $key );
90
- return false;
91
- }
92
- }
93
-
94
- //No active or queued tasks were found
95
- $this->logger->log_info( __METHOD__, 'End - No Active or Queued Tasks found' );
96
- return true;
97
-
98
- }
99
- //What is the next task in the stack
100
- public function get_next_task(){
101
- $this->logger->log_info(__METHOD__,'Begin');
102
-
103
- $this->allocated_task=null; //Set the current task to null;
104
-
105
- //Get the tasks -- DO I NEED TO SORT?
106
- $tasks = get_post_meta($this->job_id);
107
-
108
- //Enumerate the tasks
109
- foreach ($tasks as $key => $value) {
110
-
111
- //Is this a task of job meta data
112
- if (substr($key, 0, 4)!='task') continue;
113
-
114
- $task = get_post_meta($this->job_id,$key);
115
-
116
- //Get Task Properties
117
- $task_id = $task[0]['task_id'];
118
- $task_status = $task[0]['task_status'];
119
- $task_allocated_id = $task[0]['task_allocated_id'];
120
- $task_last_updated = $task[0]['task_last_updated'];
121
-
122
- //if next task in stack is queued then its time to get to work
123
- switch ($task_status) {
124
- case "queued":
125
- //Try allocate task
126
- $queued_task = $this->allocate_task($this->job_id, $key,$task_id);
127
- return $queued_task[0]['task_id'];
128
-
129
- case "active":
130
- //Error if >= 3 minutes since the last update
131
- if (time()>=$task_last_updated+WPBACKITUP__TASK_TIMEOUT_SECONDS){
132
- $this->update_task_status($this->job_id, $key,$task_id,'error');
133
-
134
- //Update job to error also
135
- $this->set_job_status_error();
136
- return 'error_' . $task_id ;
137
-
138
- }else {
139
-
140
- $this->logger->log_info( __METHOD__, 'Job:' . $key . ' is still active' );
141
- //if its been less than 3 minutes then wait
142
- return false;
143
- }
144
-
145
- case "complete":
146
- //Do nothing - get the next task
147
- break;
148
-
149
- case "error":
150
- //Job should already be error but update if not
151
- //Update job to error also
152
- $this->set_job_status_error();
153
- return 'error_' . $task_id ;
154
- }
155
- }
156
-
157
- //If no more tasks then job must be done
158
- $this->set_job_status_complete();
159
-
160
- $this->logger->log_info(__METHOD__,'End - no tasks to allocate');
161
- return false; //no tasks to allocate
162
- }
163
-
164
- /**
165
- * Allocate the task to this job - will set task status to active
166
- *
167
- * @param $job_id
168
- * @param $key
169
- * @param $task_id
170
- *
171
- * @return bool
172
- */
173
- private function allocate_task($job_id, $key,$task_id){
174
- $this->logger->log_info(__METHOD__,'Begin');
175
-
176
- //Allocate the task to this process
177
- $process_uid = uniqid();
178
- $this->update_task_status($job_id, $key,$task_id,'active',$process_uid);
179
-
180
- //Get updated task and make sure uid is good
181
- $updated_task = get_post_meta( $this->job_id, $key);
182
- $updated_task_allocated_id = $updated_task[0]['task_allocated_id'];
183
- if ($process_uid==$updated_task_allocated_id) {
184
- $this->allocated_task=$updated_task; // set the jobs allocated task
185
-
186
- $this->logger->log_info(__METHOD__,'End - Task allocated');
187
- return $updated_task;
188
- }else{
189
- $this->allocated_task=null;
190
- $this->logger->log_info(__METHOD__,'End - Task was not allocated');
191
- return false;
192
- }
193
- }
194
-
195
-
196
- /**
197
- * Set the allocated task status to queued
198
- */
199
- public function set_task_queued(){
200
- $this->logger->log_info(__METHOD__,'Begin');
201
-
202
- $this->logger->log_info(__METHOD__, 'Task Info:');
203
- $this->logger->log($this->allocated_task);
204
-
205
- //Get allocated task Properties
206
- $task_id = $this->allocated_task[0]['task_id'];
207
- $this->update_task_status($this->job_id, $task_id,$task_id,'queued');
208
-
209
- $this->logger->log_info(__METHOD__,'End');
210
- }
211
-
212
- /**
213
- * Set the allocated task status to complete
214
- */
215
- public function set_task_complete(){
216
- $this->logger->log_info(__METHOD__,'Begin');
217
-
218
- $this->logger->log_info(__METHOD__, 'Task Info:');
219
- $this->logger->log($this->allocated_task);
220
-
221
- //Get allocated task Properties
222
- $task_id = $this->allocated_task[0]['task_id'];
223
- $this->update_task_status($this->job_id, $task_id,$task_id,'complete');
224
-
225
-
226
- //Check if this was the last task
227
- if ($this->is_job_complete()){
228
- $this->set_job_status_complete();
229
- }
230
-
231
- $this->logger->log_info(__METHOD__,'End');
232
- }
233
-
234
- /**
235
- * Set the allocated task status to error
236
- */
237
- public function set_task_error($error_code){
238
- $this->logger->log_info(__METHOD__,'Begin');
239
-
240
- $this->logger->log_info(__METHOD__, 'Task Info:');
241
- $this->logger->log($this->allocated_task);
242
-
243
- //Get allocated task Properties
244
- $task_id = $this->allocated_task[0]['task_id'];
245
- $this->update_task_status($this->job_id, $task_id,$task_id,'error','',$error_code);
246
-
247
- $this->set_job_status_error();
248
-
249
- $this->logger->log_info(__METHOD__,'End');
250
- }
251
-
252
-
253
- private function update_task_status($job_id,$task_name,$task_id, $task_status, $task_allocated_id='', $task_error_code=''){
254
- $this->logger->log_info(__METHOD__,'Begin');
255
-
256
- $meta_value = array(
257
- 'task_id' => $task_id,
258
- 'task_status' => $task_status,
259
- 'task_allocated_id' => $task_allocated_id,
260
- 'task_error_code' => $task_error_code,
261
- 'task_last_updated' => time()
262
- );
263
-
264
- $this->logger->log_info(__METHOD__,'End - Task Updated:' .$job_id .'-'. $task_name .'-'. $task_status);
265
- return update_post_meta( $job_id, $task_name, $meta_value );
266
- }
267
-
268
-
269
- public function update_job_meta($meta_name,$meta_value){
270
- $this->logger->log_info(__METHOD__,'Begin - Update job meta:' .$this->job_id .'-'. $meta_name);
271
-
272
- return update_post_meta( $this->job_id, $meta_name, $meta_value );
273
- }
274
-
275
- // public function update_task_file_list($task_name,$file_list){
276
- // $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $task_name);
277
- //
278
- // return update_post_meta( $this->job_id, $task_name, wp_slash($file_list) );
279
- // }
280
-
281
- // public function get_task_file_list($task_name){
282
- // $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $task_name);
283
- //
284
- // $file_list = get_post_meta($this->job_id,$task_name,true);
285
- //
286
- // return $file_list;
287
- // }
288
-
289
- public function get_job_meta($meta_name){
290
- $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $meta_name);
291
-
292
- return get_post_meta($this->job_id,$meta_name,true);
293
-
294
- }
295
-
296
- /**
297
- * Set job status to active
298
- */
299
- public function set_job_status_active( ) {
300
- $status='active';
301
- if ($this->update_job_status($status)){
302
- $this->job_status = $status;
303
- }
304
-
305
- //Set job end Time
306
- $this->set_job_start_time();
307
- }
308
-
309
- /**
310
- * Set job status to error
311
- */
312
- public function set_job_status_error( ) {
313
- $status='error';
314
- if ($this->update_job_status($status)){
315
- $this->job_status = $status;
316
- }
317
-
318
- //Set job end Time
319
- $this->set_job_end_time();
320
- }
321
-
322
- /**
323
- * Set job status to complete
324
- */
325
- public function set_job_status_complete( ) {
326
- $status='complete';
327
-
328
- if ($this->update_job_status($status)){
329
- $this->job_status = $status;
330
- }
331
-
332
- //Set job end Time
333
- $this->set_job_end_time();
334
- }
335
-
336
- /**
337
- * Set job status to cancelled
338
- */
339
- public function set_job_status_cancelled( ) {
340
- $status='cancelled';
341
-
342
- if ($this->update_job_status($status)){
343
- $this->job_status = $status;
344
- }
345
-
346
- //Set job end Time
347
- $this->set_job_end_time();
348
- }
349
-
350
-
351
- /**
352
- * Update job status
353
- *
354
- * @param $status
355
- *
356
- * @return bool
357
- */
358
- private function update_job_status($status) {
359
- $this->logger->log_info(__METHOD__,'Begin');
360
-
361
- $job = array(
362
- 'ID' => $this->job_id,
363
- 'post_status' => $status
364
- );
365
-
366
- // update the job
367
- $job_id = wp_update_post($job );
368
-
369
- if (0!=$job_id) {
370
- $this->logger->log_info(__METHOD__,'End - Backup Job status set to:' .$job_id .'-' . $status );
371
- return true;
372
- } else{
373
- $this->logger->log_error(__METHOD__,'End - Backup Job status NOT set.');
374
- return false;
375
- }
376
-
377
- }
378
-
379
- /**
380
- * Set job start time
381
- *
382
- * @return bool
383
- */
384
- private function set_job_start_time() {
385
- $this->logger->log_info(__METHOD__,'Begin');
386
-
387
- $this->job_start_time= time();
388
- $job_info = array(
389
- 'start_time' => $this->job_start_time,
390
- );
391
-
392
- $job = array(
393
- 'ID' => $this->job_id,
394
- 'post_content' => serialize($job_info)
395
- );
396
-
397
- // update the job info
398
- $job_id = wp_update_post($job );
399
-
400
- if (0!=$job_id) {
401
- $this->logger->log_info(__METHOD__,'End - Backup Job start time set');
402
- return true;
403
- } else{
404
- $this->logger->log_error(__METHOD__,'End - Backup Job start time NOT set.');
405
- return false;
406
- }
407
-
408
- }
409
-
410
- /**
411
- * Set job end time
412
- *
413
- * @return bool
414
- */
415
- private function set_job_end_time() {
416
- $this->logger->log_info(__METHOD__,'Begin');
417
-
418
- $this->job_end_time=time();
419
- $job_info = array(
420
- 'start_time' => $this->job_start_time,
421
- 'end_time' => $this->job_end_time,
422
- );
423
-
424
- $job = array(
425
- 'ID' => $this->job_id,
426
- 'post_content' => serialize($job_info)
427
- );
428
-
429
- // update the job info
430
- $job_id = wp_update_post($job );
431
-
432
- if (0!=$job_id) {
433
- $this->logger->log_info(__METHOD__,'End - Backup Job end time set');
434
- return true;
435
- } else{
436
- $this->logger->log_error(__METHOD__,'End - Backup Job end time NOT set.');
437
- return false;
438
- }
439
-
440
- }
441
-
442
- /**---------STATICS---------***/
443
-
444
- /**
445
- * Is there at least 1 job queued or active?
446
- *
447
- * @param $job_name
448
- *
449
- * @return bool
450
- */
451
- public static function is_job_queued($job_name) {
452
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
453
- $logger->log_info(__METHOD__,'Begin - Check Job Queue:' . $job_name);
454
-
455
- //Get top 1
456
- $args = array(
457
- 'posts_per_page' => 1,
458
- 'post_type' => $job_name,
459
- 'post_status' => array('queued','active'),
460
- 'orderby' => 'post_date',
461
- 'order' => 'ASC',
462
- 'suppress_filters' => true
463
- );
464
- $jobs = get_posts( $args );
465
- $logger->log($jobs);
466
-
467
- if (is_array($jobs) && count($jobs)>0) {
468
- $logger->log_info(__METHOD__,'Jobs found:' . count($jobs) );
469
- return true;
470
- }
471
-
472
- $logger->log_info(__METHOD__,'No jobs found:' . $job_name);
473
- $logger->log_info(__METHOD__,'End');
474
- return false;
475
- }
476
-
477
- /**
478
- * Cancel all queued or active jobs
479
- *
480
- * @return bool
481
- */
482
- public static function cancel_all_jobs() {
483
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
484
- $logger->log_info(__METHOD__,'Begin - Cancel all jobs.');
485
-
486
-
487
- while (self::is_job_queued('backup')){
488
- $backup_job = self::get_job('backup');
489
- if (false!== $backup_job) {
490
- $backup_job->set_job_status_cancelled();
491
- $logger->log_info(__METHOD__,'Backup job Cancelled:' . $backup_job->job_id);
492
- }
493
- }
494
-
495
- while (self::is_job_queued('cleanup')){
496
- $cleanup_job = self::get_job('cleanup');
497
- if (false!== $cleanup_job) {
498
- $cleanup_job->set_job_status_cancelled();
499
- $logger->log_info(__METHOD__,'Cleanup job Cancelled:' . $cleanup_job->job_id);
500
- }
501
- }
502
-
503
- $logger->log_info(__METHOD__,'End - All jobs cancelled');
504
- }
505
-
506
- /**
507
- * Gets the queued or active job on top of the stack
508
- *
509
- * @param $job_name
510
- *
511
- * @return bool|WPBackItUp_Job
512
- */
513
- public static function get_job($job_name) {
514
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
515
- $logger->log_info(__METHOD__,'Begin - Job Name: ' .$job_name);
516
-
517
- //Get backup on top
518
- $args = array(
519
- 'posts_per_page' => 1,
520
- 'post_type' => $job_name,
521
- 'post_status' => array('queued','active'),
522
- 'orderby' => 'post_date',
523
- 'order' => 'ASC',
524
- );
525
- $jobs = get_posts( $args );
526
- $logger->log($jobs);
527
-
528
- if (is_array($jobs) && count($jobs)>0) {
529
- $logger->log_info(__METHOD__,'Job found:' . count($jobs));
530
-
531
- $backup_job = new WPBackItUp_Job($jobs[0]);
532
- if ('queued'==$backup_job->job_status){
533
- $backup_job->set_job_status_active();
534
- }
535
- return $backup_job;
536
- }
537
-
538
- $logger->log_info(__METHOD__,'No jobs found.');
539
- $logger->log_info(__METHOD__,'End');
540
- return false;
541
- }
542
-
543
- /**
544
- * Gets a job by id
545
- *
546
- * @param $id
547
- *
548
- * @return bool|WPBackItUp_Job
549
- */
550
- public static function get_job_by_id($id) {
551
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
552
- $logger->log_info(__METHOD__,'Begin');
553
-
554
- $job = get_post( $id, 'OBJECT');
555
- $logger->log($job);
556
-
557
- if (null!=$job) {
558
- $logger->log_info(__METHOD__,'Job found:' .$id);
559
- return new WPBackItUp_Job($job);
560
- }
561
-
562
- $logger->log_info(__METHOD__,'No job found with id.' . $id);
563
- $logger->log_info(__METHOD__,'End');
564
- return false;
565
- }
566
-
567
- /**
568
- * Queue a job
569
- *
570
- * @param $job_name
571
- *
572
- * @return bool|WPBackItUp_Job
573
- */
574
- public static function queue_job($job_name){
575
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
576
- $logger->log_info(__METHOD__,'Begin - Job:'. $job_name);
577
-
578
- $new_job = array(
579
- 'post_title' => self::JOB_TITLE,
580
- 'post_name' => time(),
581
- 'post_status' => 'queued',
582
- 'post_type' => $job_name
583
- );
584
-
585
- // Insert the post into the database
586
- $job_id = wp_insert_post($new_job );
587
- $logger->log_info(__METHOD__,'Job Created:' .$job_id);
588
-
589
- switch ($job_name) {
590
- case "restore":
591
- //add the tasks
592
- if ( false === self::create_tasks( $job_id,self::$restore_tasks ) ) {
593
- $logger->log_info( __METHOD__, 'Restore tasks not Created - deleting job:' . $job_id );
594
- wp_delete_post( $job_id, true );
595
- return false;
596
- }
597
-
598
- break;
599
-
600
- case "backup":
601
- //add the tasks
602
- if ( false === self::create_tasks( $job_id,self::$backup_tasks ) ) {
603
- $logger->log_info( __METHOD__, 'Backup tasks not Created - deleting job:' . $job_id );
604
- wp_delete_post( $job_id, true );
605
- return false;
606
- }
607
-
608
- break;
609
-
610
- case "cleanup":
611
- //add the tasks
612
- if ( false === self::create_tasks( $job_id,self::$cleanup_tasks ) ) {
613
- $logger->log_info( __METHOD__, 'Cleanup tasks not Created - deleting job:' . $job_id );
614
- wp_delete_post( $job_id, true );
615
- return false;
616
- }
617
- break;
618
-
619
- default://Job type not defined
620
- $logger->log_info( __METHOD__, 'Job type not defined - deleting job:' . $job_name );
621
- wp_delete_post( $job_id, true );
622
- return false;
623
- }
624
-
625
- $logger->log_info(__METHOD__,'End');
626
- return self::get_job_by_id($job_id);
627
- }
628
-
629
- /**
630
- * Create all the tasks for a job
631
- *
632
- * @param $job_id
633
- *
634
- * @param $tasks
635
- *
636
- * @return bool
637
- */
638
- private static function create_tasks($job_id, $tasks){
639
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
640
- $logger->log_info(__METHOD__,'Begin');
641
-
642
- //Create the job tasks
643
- $last_updated_time=time();
644
- foreach ($tasks as $key => $value){
645
- $task_name = $value;
646
- $task_data = array(
647
- 'task_id' => $task_name,
648
- 'task_status' => 'queued',
649
- 'task_allocated_id'=>'',
650
- 'task_last_updated'=>$last_updated_time
651
- );
652
- $task_created = update_post_meta( $job_id, $task_name, $task_data );
653
-
654
- if (false===$task_created){
655
- $logger->log_error( __METHOD__, 'Tasks NOT created');
656
- return false;
657
- }
658
- $logger->log_info( __METHOD__, 'task created:' . $task_created .':'. $task_name);
659
- }
660
-
661
- $logger->log_info(__METHOD__,'End');
662
- return true;
663
-
664
- }
665
-
666
- // /**
667
- // * Create all the tasks for a job
668
- // * @param $job_id
669
- // *
670
- // * @return bool
671
- // */
672
- // private static function create_backup_tasks($job_id){
673
- // $logger = new WPBackItUp_Logger(false,null,'debug_job');
674
- // $logger->log_info(__METHOD__,'Begin');
675
- //
676
- // //Create the job tasks
677
- // $last_updated_time=time();
678
- // foreach (self::$backup_tasks as $key => $value){
679
- // $task_name = $value;
680
- // $task_data = array(
681
- // 'task_id' => $task_name,
682
- // 'task_status' => 'queued',
683
- // 'task_allocated_id'=>'',
684
- // 'task_last_updated'=>$last_updated_time
685
- // );
686
- // $task_created = update_post_meta( $job_id, $task_name, $task_data );
687
- //
688
- // if (false===$task_created){
689
- // $logger->log_error( __METHOD__, 'Tasks NOT created');
690
- // return false;
691
- // }
692
- // $logger->log_info( __METHOD__, 'task created:' . $task_created .':'. $task_name);
693
- // }
694
- //
695
- // $logger->log_info(__METHOD__,'End');
696
- // return true;
697
- //
698
- // }
699
-
700
- // /**
701
- // * Create all the tasks for a job
702
- // * @param $job_id
703
- // *
704
- // * @return bool
705
- // */
706
- // private static function create_cleanup_tasks($job_id){
707
- // $logger = new WPBackItUp_Logger(false,null,'debug_job');
708
- // $logger->log_info(__METHOD__,'Begin');
709
- //
710
- // //Create the job tasks
711
- // $last_updated_time=time();
712
- // foreach (self::$cleanup_tasks as $key => $value){
713
- // $task_name = $value;
714
- // $task_data = array(
715
- // 'task_id' => $task_name,
716
- // 'task_status' => 'queued',
717
- // 'task_allocated_id'=>'',
718
- // 'task_last_updated'=>$last_updated_time
719
- // );
720
- // $task_created = update_post_meta( $job_id, $task_name, $task_data );
721
- //
722
- // if (false===$task_created){
723
- // $logger->log_error( __METHOD__, 'Tasks NOT created');
724
- // return false;
725
- // }
726
- // $logger->log_info( __METHOD__, 'task created:' . $task_created );
727
- // }
728
- //
729
- // $logger->log_info(__METHOD__,'End');
730
- // return true;
731
- //
732
- // }
733
-
734
- /**
735
- * @return mixed
736
- */
737
- public function get_job_start_time() {
738
- return $this->job_start_time;
739
- }
740
-
741
- /**
742
- * @return mixed
743
- */
744
- public function get_job_end_time() {
745
- return $this->job_end_time;
746
- }
747
-
748
- /**
749
- * Get Job status
750
- * @return mixed
751
- */
752
- public function get_job_status() {
753
- return $this->job_status;
754
- }
755
- }
756
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-logger.php DELETED
@@ -1,219 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (logger)');
2
-
3
- /**
4
- * WP Backitup Logging Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
-
12
- class WPBackItUp_Logger {
13
-
14
- private $dfh;
15
- private $logging;
16
-
17
- public $logFileName;
18
- public $logFilePath;
19
-
20
- public function __construct($delete_log, $path=null, $file_name=null, $debugOverride=false) {
21
- global $WPBackitup;
22
-
23
- $this->logging = $WPBackitup->logging();
24
-
25
- //If override debug flag then turn logging on.
26
- if (true===$debugOverride) $this->logging=true;
27
-
28
- //check for optional parms
29
- if (!is_string($path)){
30
- $path = WPBACKITUP__PLUGIN_PATH .'/logs';
31
- }
32
-
33
- if (!is_string($file_name)){
34
- $file_name='debug';
35
- }
36
-
37
-
38
- $this->logFileName=$file_name .'.log';
39
- $this->logFilePath= $path .'/'. $this->logFileName;
40
-
41
- try {
42
- //If debug then open the file handle
43
- if (true===$this->logging){
44
-
45
- //Delete log first
46
- if ($delete_log && file_exists($this->logFilePath)) {
47
- unlink($this->logFilePath);
48
- }
49
-
50
- $this->dfh = fopen($this->logFilePath, 'a');
51
- fwrite($this->dfh, "** Open LOG File ** ". PHP_EOL);
52
- }
53
- } catch(Exception $e) {
54
- //Dont do anything
55
- print $e;
56
- }
57
- }
58
-
59
- function __destruct() {
60
- $this->close_file();
61
- }
62
-
63
- public function close_file() {
64
- try {
65
- if (!is_null($this->dfh) && is_resource($this->dfh)){
66
- fwrite($this->dfh, "** Close LOG File ** ". PHP_EOL);
67
- fclose($this->dfh);
68
- }
69
- } catch(Exception $e) {
70
- //Dont do anything
71
- print $e;
72
- }
73
-
74
- $this->dfh=null;
75
- }
76
-
77
- function log($message) {
78
- try{
79
- if (true===$this->logging){
80
- if (!is_null($this->dfh) && is_resource($this->dfh)){
81
- $date = date_i18n('Y-m-d H:i:s',current_time( 'timestamp' ));
82
- if( is_array( $message ) || is_object( $message ) ){
83
- fwrite($this->dfh, $date ." " .print_r( $message, true ) . PHP_EOL);
84
- } else {
85
- fwrite($this->dfh, $date ." " .$message . PHP_EOL);
86
- }
87
- }
88
- }
89
- } catch(Exception $e) {
90
- //Dont do anything
91
- print $e;
92
- }
93
- }
94
-
95
- //Log Errors
96
- public function log_info($function,$message, $additional_message=null) {
97
- $function='(' . $function . ') INFO: ' . $additional_message;
98
- if( is_array( $message ) || is_object( $message ) ){
99
- $this->log($function);
100
- $this->log($message);
101
- } else {
102
- $this->log($function . $message);
103
- }
104
- }
105
-
106
- //Log Errors
107
- public function log_error($function,$message,$additional_message=null) {
108
- $function='(' . $function . ') ERROR: ' . $additional_message;
109
- if( is_array( $message ) || is_object( $message ) ){
110
- $this->log($function);
111
- $this->log($message);
112
- } else {
113
- $this->log($function .$message);
114
- }
115
- }
116
-
117
- //Log warning
118
- public function log_warning($function,$message,$additional_message=null) {
119
- $function='(' . $function . ') WARNING: ' . $additional_message;
120
- if( is_array( $message ) || is_object( $message ) ){
121
- $this->log($function);
122
- $this->log($message);
123
- } else {
124
- $this->log($function .$message);
125
- }
126
- }
127
-
128
- function log_sysinfo() {
129
- global $wpdb,$WPBackitup;
130
- try{
131
- if (true===$this->logging){
132
-
133
- $this->log("**SYSTEM INFO**");
134
-
135
- $this->log("\n--Site Info--");
136
- $this->log('Site URL:' . site_url());
137
- $this->log('Home URL:' . home_url());
138
- $this->log('Multisite:' . ( is_multisite() ? 'Yes' : 'No' )) ;
139
-
140
- $this->log("\n--Wordpress Info--");
141
- $this->log("Wordpress Version:" . get_bloginfo( 'version'));
142
- $this->log('Language:' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ));
143
- $this->log('Table Prefix:' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ));
144
- $this->log('WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ));
145
- $this->log('Memory Limit:' . WP_MEMORY_LIMIT );
146
-
147
-
148
- $this->log("\n--WordPress Active Plugins--");
149
- // Check if get_plugins() function exists. This is required on the front end of the
150
- // site, since it is in a file that is normally only loaded in the admin.
151
- if ( ! function_exists( 'get_plugins' ) ) {
152
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
153
- }
154
-
155
- $plugins = get_plugins();
156
- $active_plugins = get_option( 'active_plugins', array() );
157
- foreach( $plugins as $plugin_path => $plugin ) {
158
- if( !in_array( $plugin_path, $active_plugins ) ) continue;
159
-
160
- $this->log( $plugin['Name'] . ': ' . $plugin['Version']);
161
- }
162
-
163
- // WordPress inactive plugins
164
- $this->log("\n" . '--WordPress Inactive Plugins--');
165
-
166
- foreach( $plugins as $plugin_path => $plugin ) {
167
- if( in_array( $plugin_path, $active_plugins ) )
168
- continue;
169
-
170
- $this->log($plugin['Name'] . ': ' . $plugin['Version']);
171
- }
172
-
173
- $this->log("\n--Server Info--");
174
- $this->log('PHP Version:' . PHP_VERSION);
175
- $this->log('Webserver Info:' . $_SERVER['SERVER_SOFTWARE']);
176
- $this->log('MySQL Version:' . $wpdb->db_version());
177
-
178
-
179
- $this->log("\n--PHP Info--");
180
- $this->log("PHP Info:" . phpversion());
181
- $this->log("Operating System:" . php_uname());
182
-
183
- if ( @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on' ){
184
- $this->log("PHP Safe Mode: On");
185
- } else{
186
- $this->log("PHP Safe Mode: Off");
187
- }
188
-
189
- if ( @ini_get('sql.safe_mode') || strtolower(@ini_get('sql.safe_mode')) == 'on' ){
190
- $this->log("SQL Safe Mode: On");
191
- } else{
192
- $this->log("SQL Safe Mode: Off");
193
- }
194
- $this->log("Script Max Execution Time:" . ini_get('max_execution_time'));
195
- $this->log('Memory Limit:' . ini_get( 'memory_limit' ));
196
- $this->log('Upload Max Size:' . ini_get( 'upload_max_filesize' ));
197
- $this->log('Post Max Size:' . ini_get( 'post_max_size' ));
198
- $this->log('Upload Max Filesize:' . ini_get( 'upload_max_filesize' ));
199
- $this->log('Max Input Vars:' . ini_get( 'max_input_vars' ));
200
- $this->log('Display Errors:' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ));
201
-
202
-
203
- $this->log("\n--WP BackItUp Info--");
204
- $this->log("WPBACKITUP License Active: " . ($WPBackitup->license_active() ? 'true' : 'false'));
205
- $prefix='WPBACKITUP';
206
- foreach (get_defined_constants() as $key=>$value)
207
- {
208
- if (substr($key,0,strlen($prefix))==$prefix) {
209
- $this->log($key . ':' . $value);
210
- }
211
- }
212
- $this->log("**END SYSTEM INFO**");
213
- }
214
- } catch(Exception $e) {
215
- //Dont do anything
216
- print $e;
217
- }
218
- }
219
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-recursiveFilter_Iterator.php DELETED
@@ -1,34 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup Recurse Iterator
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
-
12
-
13
- class WPBackItUp_RecursiveFilter_Iterator extends RecursiveFilterIterator {
14
-
15
- private $filters=array();
16
- private $logger;
17
-
18
- //Set the ignore list
19
- function set_filter ($ignore) {
20
- $this->filters = $ignore;
21
- }
22
-
23
- public function accept() {
24
- $logger = new WPBackItUp_Logger(false);
25
- $accept = !in_array(
26
- $this->current()->getFilename(),
27
- $this->filters,
28
- true);
29
-
30
- $logger->log('(WPBackItUp_RecursiveFilter_Iterator) accept:' . $this->current()->getFilename() . ":" .$accept);
31
- return $accept;
32
- }
33
-
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-restore.php DELETED
@@ -1,1085 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Backup Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
- class WPBackItUp_Restore {
11
-
12
- private $logger;
13
-
14
- //Public Properties
15
- private $backup_id;
16
- private $backup_name;
17
- private $backup_folder_path;
18
- private $restore_root_folder_path;
19
- private $restore_staging_suffix;
20
-
21
- const SITEDATAPATH = 'site-data';
22
- const PLUGINSPATH = 'wp-content-plugins';
23
- const THEMESPATH = 'wp-content-themes';
24
- const OTHERPATH = 'wp-content-other';
25
- const UPLOADPATH = 'wp-content-uploads';
26
-
27
- function __construct($logger, $backup_name, $backup_id) {
28
- //global $WPBackitup;
29
-
30
- try {
31
- $this->logger = $logger;
32
-
33
- $this->backup_name=$backup_name;
34
- $this->backup_folder_path = WPBACKITUP__BACKUP_PATH .'/' .$backup_name;
35
-
36
- $this->restore_root_folder_path = WPBACKITUP__RESTORE_PATH;
37
-
38
- $this->backup_id=$backup_id;
39
- $this->restore_staging_suffix = '_' .$backup_id;
40
-
41
-
42
- } catch(Exception $e) {
43
- $this->logger->log($e);
44
- print $e;
45
- }
46
- }
47
-
48
- function __destruct() {
49
-
50
- }
51
-
52
- public function delete_restore_folder() {
53
- $this->logger->log_info( __METHOD__, 'Begin delete restore folders.' );
54
-
55
- //get a list of all the folders
56
- $item_list = glob($this->restore_root_folder_path .'/*');
57
- return $this->delete_folders($item_list);
58
- }
59
-
60
- public function delete_staged_folders() {
61
- $this->logger->log_info( __METHOD__, 'Begin delete staged folders.' );
62
-
63
- //get a list of all the staged folders
64
- $item_list = glob(WPBACKITUP__CONTENT_PATH .'/*'.$this->restore_staging_suffix .'*');
65
- return $this->delete_folders($item_list);
66
-
67
- }
68
-
69
- private function delete_folders($item_list) {
70
- $this->logger->log_info( __METHOD__, 'Begin' );
71
-
72
- $this->logger->log_info( __METHOD__, 'Folders to be deleted:' );
73
- $this->logger->log($item_list);
74
-
75
- $file_system = new WPBackItUp_FileSystem($this->logger);
76
- foreach($item_list as $item) {
77
- if (is_dir($item)) {
78
- if (! $file_system->recursive_delete( $item )){
79
- $this->logger->log_error( __METHOD__, 'Folder could NOT be deleted:' . $item);
80
- return false;
81
- }
82
- }else{
83
- if (! unlink($item)){
84
- $this->logger->log_error( __METHOD__, 'File could NOT be deleted:' . $item);
85
- return false;
86
- }
87
- }
88
- }
89
-
90
- $this->logger->log_info( __METHOD__, 'End' );
91
- return true;
92
- }
93
-
94
-
95
- //Create an empty restore folder
96
- public function create_restore_root_folder() {
97
- $this->logger->log_info(__METHOD__,'Create restore folder.' . $this->restore_root_folder_path);
98
-
99
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
100
- if( $fileSystem->create_dir($this->restore_root_folder_path)) {
101
- //Secure restore folder
102
- $fileSystem->secure_folder( $this->restore_root_folder_path);
103
- return true;
104
-
105
- } else{
106
- return false;
107
- }
108
-
109
- }
110
-
111
- //Unzip the backup to the restore folder
112
- function unzip_archive_file($backup_set_list){
113
- $this->logger->log_info(__METHOD__,'Begin');
114
-
115
- if (count($backup_set_list)<=0) return false;
116
-
117
- $backup_file_path = $backup_set_list[0];
118
- $this->logger->log_info(__METHOD__,'Begin - Unzip Backup File:' .$backup_file_path);
119
- try {
120
- $zip = new ZipArchive;
121
- $res = $zip->open($backup_file_path);
122
- if ($res === TRUE) {
123
- if (true===$zip->extractTo($this->restore_root_folder_path)){
124
- $zip->close();
125
- } else {
126
- $zip->close();
127
- $this->logger->log_error(__METHOD__,'Cant unzip backup:'.$backup_file_path);
128
- return false;
129
- }
130
- } else {
131
- $this->logger->log_error(__METHOD__,'Cant open backup archive:'.$backup_file_path);
132
- return false;
133
- }
134
-
135
- $this->logger->log_info(__METHOD__,'Backup file unzipped: ' .$backup_file_path);
136
-
137
- } catch(Exception $e) {
138
- $this->logger->log_error(__METHOD__,'An Unexpected Error has happened: ' .$e);
139
- return false;
140
- }
141
-
142
- return true;
143
- }
144
-
145
- //Validate the restore folder
146
- function validate_restore_folder(){
147
- $this->logger->log_info(__METHOD__,'Begin');
148
-
149
- $restore_folder_root=$this->restore_root_folder_path . '/';
150
- $this->logger->log_info(__METHOD__,'Validate restore folder : ' .$restore_folder_root);
151
-
152
-
153
- //Do we have at least 4 folders - other may sometimes not be there
154
- if ( count( glob( $restore_folder_root.'*', GLOB_ONLYDIR ) ) < 4 ) {
155
- $this->logger->log_error(__METHOD__,'Restore directory INVALID: ' .$restore_folder_root);
156
- return false;
157
- }
158
-
159
-
160
- $site_data_folder = $restore_folder_root .self::SITEDATAPATH;
161
- if(!is_dir($site_data_folder) ){
162
- $this->logger->log_error(__METHOD__,'site-data missing from restore folder:' .$site_data_folder);
163
- return false;
164
- }
165
-
166
- $plugins_folder = $restore_folder_root .self::PLUGINSPATH;
167
- if(!is_dir($plugins_folder) ){
168
- $this->logger->log_error(__METHOD__,'wp-content-plugins missing from restore folder:' .$plugins_folder);
169
- return false;
170
- }
171
-
172
- $themes_folder = $restore_folder_root .self::THEMESPATH;
173
- if(!is_dir($themes_folder) ){
174
- $this->logger->log_error(__METHOD__,'wp-content-themes missing from restore folder:' .$themes_folder);
175
- return false;
176
- }
177
-
178
- //Not an error
179
- $other_folder = $restore_folder_root .self::OTHERPATH;
180
- if(!is_dir($other_folder) ){
181
- $this->logger->log_info(__METHOD__,'wp-content-other missing from restore folder:' .$other_folder);
182
- }
183
-
184
- $uploads_folder = $restore_folder_root .self::UPLOADPATH;
185
- if(!is_dir($uploads_folder) ){
186
- $this->logger->log_error(__METHOD__,'wp-content-uploads missing from restore folder:' .$uploads_folder);
187
- return false;
188
- }
189
-
190
- $this->logger->log_info(__METHOD__,'End - Restoration directory validated: ' .$restore_folder_root);
191
- return true;
192
- }
193
-
194
- //Validate the restore folder
195
- function validate_siteinfo_file(){
196
- $this->logger->log_info(__METHOD__,'Begin');
197
-
198
- $site_info_path = $this->restore_root_folder_path . '/' .self::SITEDATAPATH .'/backupsiteinfo.txt';
199
- $this->logger->log_info(__METHOD__,'Validate Site info file: ' . $site_info_path);
200
- if(! file_exists($site_info_path) || empty($site_info_path)) {
201
- $this->logger->log_error(__METHOD__,'backupsiteinfo.txt missing or empty ' .$site_info_path);
202
- return false;
203
- }
204
-
205
-
206
- //Get file values
207
- $this->logger->log_info(__METHOD__, 'GET Site Info data' );
208
- $import_siteinfo_lines = file( $site_info_path);
209
- if (count($import_siteinfo_lines)<3){
210
- $this->logger->log_error(__METHOD__,'Site Data file NOT valid.' );
211
- return false;
212
- } else {
213
- $restore_siteurl = str_replace( "\n", '', trim( $import_siteinfo_lines[0] ) );
214
- $restore_table_prefix = str_replace( "\n", '', $import_siteinfo_lines[1] );
215
- $restore_wp_version = str_replace( "\n", '', $import_siteinfo_lines[2] );
216
- $restore_wpbackitup_version = str_replace( "\n", '', $import_siteinfo_lines[3] );
217
-
218
- $site_data = array (
219
- 'restore_siteurl'=>$restore_siteurl,
220
- 'restore_table_prefix'=>$restore_table_prefix,
221
- 'restore_wp_version'=>$restore_wp_version,
222
- 'restore_wpbackitup_version'=>$restore_wpbackitup_version,
223
- );
224
-
225
- $this->logger->log_info(__METHOD__,'Site Data:' );
226
- $this->logger->log($site_data);
227
- return $site_data;
228
- }
229
-
230
- }
231
-
232
- //Validate the manifest
233
- function validate_manifest_file($backup_set_list, &$error_code){
234
- $this->logger->log_info(__METHOD__,'Begin');
235
-
236
- $manifest_file_path = $this->restore_root_folder_path . '/' .self::SITEDATAPATH .'/backupmanifest.txt';
237
- $this->logger->log_info(__METHOD__,'Validate backup manifest: ' . $manifest_file_path);
238
-
239
- if(! file_exists($manifest_file_path) || empty($manifest_file_path)) {
240
- $this->logger->log_info(__METHOD__,'No manifest found.');
241
- return true; //Old backups will not have a manifest - OK
242
- }
243
-
244
- $manifest_data_string = file_get_contents($manifest_file_path);
245
- if (false===$manifest_data_string || empty($manifest_data_string)){
246
- $this->logger->log_error(__METHOD__,'Manifest empty.');
247
- $error_code=1;
248
- return false;
249
- }
250
-
251
- // make sure all the files in the manifest are part of the set
252
- $manifest_data_array = json_decode($manifest_data_string,true);
253
- foreach($manifest_data_array as $zip_file)
254
- {
255
- //does this file exist in the set
256
- if (false===$this->search_array($zip_file, $backup_set_list)){
257
- $this->logger->log_error(__METHOD__,'Zip File Missing:' .$zip_file);
258
- $error_code=2;
259
- return false;
260
- }
261
- }
262
-
263
- // Do we have any extra zip files
264
- foreach($backup_set_list as $zip_file)
265
- {
266
- //does this file exist in the manifest
267
- if (false===$this->search_array(basename($zip_file), $manifest_data_array)){
268
- $this->logger->log_error(__METHOD__,'Zip File Not in manifest:' .$zip_file);
269
- $error_code=3;
270
- return false;
271
- }
272
- }
273
-
274
- $this->logger->log_info(__METHOD__,'End' );
275
- return true;
276
-
277
- }
278
-
279
- private function search_array($search, $array)
280
- {
281
- foreach($array as $key => $value)
282
- {
283
- if (stristr($value, $search))
284
- {
285
- return $key;
286
- }
287
- }
288
- return false;
289
- }
290
-
291
- //Make sure there IS a backup to restore
292
- function validate_SQL_exists(){
293
- $this->logger->log_info(__METHOD__,'Begin');
294
-
295
- $backup_sql_file = $this->restore_root_folder_path . '/' .self::SITEDATAPATH . '/' . WPBACKITUP__SQL_DBBACKUP_FILENAME;
296
- $this->logger->log_info(__METHOD__,'Check for database backup file' . $backup_sql_file);
297
- if(!file_exists($backup_sql_file) || empty($backup_sql_file)) {
298
- $this->logger->log_error(__METHOD__,'Database backup file NOT FOUND.');
299
- return false;
300
- }
301
-
302
- $this->logger->log_info(__METHOD__,'Database backup file exists');
303
- return true;
304
- }
305
-
306
- public function export_database(){
307
- $this->logger->log_info(__METHOD__,'Begin');
308
-
309
- $date = date_i18n('Y-m-d-Hi',current_time( 'timestamp' ));
310
- $backup_file = $this->backup_folder_path .'/'. 'db-backup-' . $date .'.cur';
311
-
312
- $sqlUtil = new WPBackItUp_SQL($this->logger);
313
- $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$backup_file);
314
-
315
- //Try SQLDump First
316
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
317
- if(!$sqlUtil->mysqldump_export($backup_file) ) {
318
-
319
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP/PATH');
320
- if(!$sqlUtil->mysqldump_export($backup_file,true) ) {
321
-
322
- $this->logger->log_info(__METHOD__,'Export DB with Manual SQL EXPORT');
323
- if(!$sqlUtil->manual_export($backup_file) ) {
324
- $this->logger->log_error(__METHOD__,'SQL EXPORT FAILED');
325
- return false;
326
- }
327
- }
328
- }
329
- $this->logger->log_info(__METHOD__,'Database Exported successfully');
330
-
331
- return true;
332
- }
333
-
334
-
335
- public function rename_folder($from_folder_name,$to_folder_name){
336
- $this->logger->log_info(__METHOD__,'Begin');
337
- $this->logger->log_info(__METHOD__,'Rename from folder name:' . $from_folder_name);
338
- $this->logger->log_info(__METHOD__,'Rename to folder name: '. $to_folder_name);
339
-
340
- $file_system = new WPBackItUp_FileSystem($this->logger);
341
- if ( !$file_system->rename_file($from_folder_name,$to_folder_name)) {
342
- $this->logger->log_error(__METHOD__,'Folder could not be renamed');
343
- return false;
344
- }
345
-
346
- $this->logger->log_info(__METHOD__,'End');
347
-
348
- return true;
349
- }
350
-
351
- // Restore everything but plugins
352
- public function restore_wpcontent(){
353
- $this->logger->log_info(__METHOD__,'Begin');
354
- $error_folders = array();
355
- $error_files = array();
356
-
357
- //Create the archive folder
358
- $archive_folder = $this->restore_root_folder_path .'/Archive'.$this->restore_staging_suffix;
359
- if (! is_dir($archive_folder)){
360
- mkdir($archive_folder);
361
- }
362
-
363
- //Get all staged directories and rename them
364
- //Plugins, backup & restore folders wereent staged
365
- $wpcontent_folder_list = glob(WPBACKITUP__CONTENT_PATH .'/*'.$this->restore_staging_suffix ,GLOB_ONLYDIR);
366
- foreach ( $wpcontent_folder_list as $from_folder_name ) {
367
-
368
- $folder_name_only = basename( $from_folder_name );
369
- $this->logger->log_info(__METHOD__,'Folder name:' . $folder_name_only);
370
-
371
- $to_folder_name = WPBACKITUP__CONTENT_PATH . '/' . str_replace( $this->restore_staging_suffix, '', $folder_name_only );
372
-
373
- //rename the existing folder to OLD if exists
374
- $archive_success=true;
375
- if (is_dir($to_folder_name)){
376
- //try to rename it 5 times
377
- $archive_folder_name = $archive_folder .'/' .str_replace( $this->restore_staging_suffix, '', $folder_name_only );
378
- for ($i = 1; $i <= 5; $i++) {
379
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
380
- if ( $this->rename_folder($to_folder_name,$archive_folder_name)) {
381
- $archive_success=true;
382
- break; // break out if rename successful
383
- }else{
384
- $archive_success=false;
385
- sleep(1); //give it a second
386
- }
387
- }
388
- }
389
-
390
- $rename_success=false;
391
- //Rename the staged folder
392
- if ($archive_success) {
393
- for ($i = 1; $i <= 5; $i++) {
394
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
395
- if ( $this->rename_folder( $from_folder_name, $to_folder_name ) ) {
396
- $rename_success=true;
397
- break; // break out if rename successful
398
- }else{
399
- $rename_success=false;
400
- sleep(1); //give it a second
401
- }
402
- }
403
- }
404
-
405
- //keep going on failure
406
- if (! $rename_success){
407
- array_push($error_folders,$from_folder_name);
408
- $this->logger->log_error(__METHOD__, 'Cant restore folder.' .$from_folder_name );
409
- }
410
- }
411
-
412
-
413
- if (count($error_folders)>0){
414
- $this->logger->log_error(__METHOD__,'End - Error Folders:');
415
- $this->logger->log($error_folders);
416
- return $error_folders;
417
- }
418
-
419
- $this->logger->log_info(__METHOD__,'End Restont WPContent Folders- No errors');
420
-
421
- //NOW restore the files
422
- $wpcontent_files_only = array_filter(glob($this->restore_root_folder_path .'/' .self::OTHERPATH .'/*'), 'is_file');
423
- foreach ( $wpcontent_files_only as $from_file_name ) {
424
- $file_name_only = basename( $from_file_name );
425
-
426
- $this->logger->log_info(__METHOD__,'WPContent File name:' . $file_name_only);
427
-
428
- //Archive the old file
429
- $to_file_name = WPBACKITUP__CONTENT_PATH .'/' . $file_name_only;
430
- $archive_success=true;
431
- if (file_exists($to_file_name)){
432
-
433
- //try to rename it 5 times
434
- $archive_file_name = $archive_folder .'/' . $file_name_only;
435
- for ($i = 1; $i <= 5; $i++) {
436
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
437
- if ( $this->rename_folder($to_file_name,$archive_file_name)) {
438
- $archive_success=true;
439
- break; // break out if rename successful
440
- }else{
441
- $archive_success=false;
442
- sleep(1); //give it a second
443
- }
444
- }
445
- }
446
-
447
- $rename_success=false;
448
- if ($archive_success){
449
- //Restore the file
450
- for ($i = 1; $i <= 5; $i++) {
451
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
452
- if ( $this->rename_folder( $from_file_name, $to_file_name ) ) {
453
- $rename_success=true;
454
- break; // break out if rename successful
455
- }else{
456
- $rename_success=false;
457
- sleep(1); //give it a second
458
- }
459
- }
460
-
461
- }
462
-
463
- //keep going on failure but add file to list
464
- if (!$rename_success){
465
- array_push($error_files,$from_folder_name);
466
- $this->logger->log_error(__METHOD__, 'Cant restore file.' .$from_file_name );
467
-
468
- }
469
- }
470
-
471
-
472
- if (count($error_files)>0) {
473
- $this->logger->log_error(__METHOD__,'End - Error Files:');
474
- $this->logger->log($error_files);
475
- return $error_folders;
476
- } else{
477
- $this->logger->log_info(__METHOD__,'End Restore WPContent - No errors');
478
- return true;
479
- }
480
-
481
- }
482
-
483
- public function restore_plugins(){
484
- $this->logger->log_info(__METHOD__,'Begin');
485
- $error_folders = array();
486
- $error_files = array();
487
-
488
- //Create the archive folder if it doesnt exist
489
- $archive_folder = $this->restore_root_folder_path .'/Archive'.$this->restore_staging_suffix;
490
- if (! is_dir($archive_folder)){
491
- mkdir($archive_folder);
492
- }
493
-
494
- //Create the plugins archive
495
- $plugin_archive_folder = $archive_folder .'/' . basename(WPBACKITUP__PLUGINS_ROOT_PATH);
496
- if (! is_dir($plugin_archive_folder)){
497
- mkdir($plugin_archive_folder);
498
- }
499
-
500
-
501
- //Move the folders ONLY
502
- $plugins_folder_list = glob($this->restore_root_folder_path .'/' .self::PLUGINSPATH .'/*' ,GLOB_ONLYDIR);
503
- foreach ( $plugins_folder_list as $from_folder_name ) {
504
- $folder_name_only = basename( $from_folder_name );
505
-
506
- //Dont restore wp backitup plugin
507
- $this->logger->log_info(__METHOD__,'Plugin Folder name:' . $folder_name_only);
508
- if ( $folder_name_only != WPBACKITUP__PLUGIN_FOLDER) {
509
-
510
- //Archive the old plugin
511
- $to_folder_name = WPBACKITUP__PLUGINS_ROOT_PATH .'/' . $folder_name_only;
512
- $archive_success=true;
513
- if (is_dir($to_folder_name)){
514
-
515
- //try to rename it 5 times
516
- $archive_folder_name = $plugin_archive_folder .'/' . $folder_name_only;
517
- for ($i = 1; $i <= 5; $i++) {
518
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
519
- if ( $this->rename_folder($to_folder_name,$archive_folder_name)) {
520
- $archive_success=true;
521
- break; // break out if rename successful
522
- }else{
523
- $archive_success=false;
524
- sleep(1); //give it a second
525
- }
526
- }
527
- }
528
-
529
- $rename_success=false;
530
- if ($archive_success){
531
- //Restore the plugin
532
- for ($i = 1; $i <= 5; $i++) {
533
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
534
- if ( $this->rename_folder( $from_folder_name, $to_folder_name ) ) {
535
- $rename_success=true;
536
- break; // break out if rename successful
537
- }else{
538
- $rename_success=false;
539
- sleep(1); //give it a second
540
- }
541
- }
542
-
543
- }
544
-
545
- //keep going on failure but add folder to list
546
- if (!$rename_success){
547
- array_push($error_folders,$from_folder_name);
548
- $this->logger->log_error(__METHOD__, 'Cant restore plugin folder.' .$from_folder_name );
549
- }
550
- }
551
- }
552
-
553
-
554
- //If error on folders then return
555
- if (count($error_folders)>0){
556
- $this->logger->log_error(__METHOD__,'End - Error Folders:');
557
- $this->logger->log($error_folders);
558
- return $error_folders;
559
- }
560
- $this->logger->log_info(__METHOD__, 'End restore plugin folders.');
561
-
562
-
563
- //NOW move the files
564
- $plugins_files_only = array_filter(glob($this->restore_root_folder_path .'/' .self::PLUGINSPATH .'/*'), 'is_file');
565
- foreach ( $plugins_files_only as $from_file_name ) {
566
- $file_name_only = basename( $from_file_name );
567
-
568
- $this->logger->log_info(__METHOD__,'Plugin File name:' . $file_name_only);
569
-
570
- //Archive the old file
571
- $to_file_name = WPBACKITUP__PLUGINS_ROOT_PATH .'/' . $file_name_only;
572
- $archive_success=true;
573
- if (file_exists($to_file_name)){
574
-
575
- //try to rename it 5 times
576
- $archive_file_name = $plugin_archive_folder .'/' . $file_name_only;
577
- for ($i = 1; $i <= 5; $i++) {
578
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
579
- if ( $this->rename_folder($to_file_name,$archive_file_name)) {
580
- $archive_success=true;
581
- break; // break out if rename successful
582
- }else{
583
- $archive_success=false;
584
- sleep(1); //give it a second
585
- }
586
- }
587
- }
588
-
589
- $rename_success=false;
590
- if ($archive_success){
591
- //Restore the plugin
592
- for ($i = 1; $i <= 5; $i++) {
593
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
594
- if ( $this->rename_folder( $from_file_name, $to_file_name ) ) {
595
- $rename_success=true;
596
- break; // break out if rename successful
597
- }else{
598
- $rename_success=false;
599
- sleep(1); //give it a second
600
- }
601
- }
602
-
603
- }
604
-
605
- //keep going on failure but add file to list
606
- if (!$rename_success){
607
- array_push($error_files,$from_folder_name);
608
- $this->logger->log_error(__METHOD__, 'Cant restore plugin file.' .$from_file_name );
609
-
610
- }
611
- }
612
-
613
-
614
- if (count($error_files)>0) {
615
- $this->logger->log_error(__METHOD__,'End - Error Files:');
616
- $this->logger->log($error_files);
617
- return $error_folders;
618
- } else{
619
- $this->logger->log_info(__METHOD__,'End Restore Plugins - No errors');
620
- return true;
621
- }
622
-
623
-
624
- }
625
-
626
- public function restore_database(){
627
- $this->logger->log_info(__METHOD__,'Begin - restore database.');
628
-
629
- $backup_sql_file = $this->restore_root_folder_path . '/' .self::SITEDATAPATH . '/' . WPBACKITUP__SQL_DBBACKUP_FILENAME;
630
- return $this->run_sql_from_file($backup_sql_file);
631
-
632
- }
633
-
634
- private function run_sql_from_file($sql_file_path){
635
- $this->logger->log_info(__METHOD__,'Begin - SQL: '. $sql_file_path);
636
-
637
-
638
- $dbc = new WPBackItUp_SQL($this->logger);
639
- if(!$dbc->run_sql_exec($sql_file_path)) {
640
- //try with sql path on this time
641
- if(!$dbc->run_sql_exec($sql_file_path,true)) {
642
- //Try manually
643
- if ( ! $dbc->run_sql_manual( $sql_file_path ) ) {
644
- $this->logger->log_error( __METHOD__, 'Database import error.' );
645
- return false;
646
- }
647
- }
648
- }
649
-
650
- $this->logger->log_info(__METHOD__,'End');
651
- return true;
652
- }
653
-
654
- public function activate_plugins(){
655
- $this->logger->log_info(__METHOD__,'Begin');
656
-
657
- $plugins = get_plugins();
658
- foreach ( $plugins as $plugin => $value ) {
659
- //Activate plugin if NOT already active
660
- if (! is_plugin_active($plugin) ) {
661
- $result = activate_plugin($plugin);
662
- if ( is_wp_error( $result ) ) {
663
- $this->logger->log_error(__METHOD__,'Plugin could NOT be activated:' .$plugin);
664
- } else{
665
- $this->logger->log_info(__METHOD__,'Plugin activated:' .$plugin);
666
- }
667
- }
668
- }
669
-
670
- $this->logger->log_info(__METHOD__,'End');
671
- return true;
672
- }
673
-
674
- public function deactivate_plugins(){
675
- $this->logger->log_info(__METHOD__,'Begin');
676
-
677
- $plugins = get_option('active_plugins');
678
- foreach ($plugins as $plugin) {
679
- //dont deactivate wp-backitup
680
- if ('wp-backitup/wp-backitup.php' != $plugin){
681
- deactivate_plugins($plugin);
682
- $this->logger->log_info(__METHOD__,'Plugin Deactivated:' . $plugin);
683
- }
684
- }
685
-
686
- $this->logger->log_info(__METHOD__,'End');
687
- }
688
-
689
- //get siteurl
690
- public function get_siteurl(){
691
- global $table_prefix;
692
- $this->logger->log_info(__METHOD__,'Begin');
693
-
694
- $sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='siteurl';";
695
- $dbc = new WPBackItUp_SQL($this->logger);
696
- $siteurl = $dbc->get_sql_scalar($sql);
697
- if (empty($siteurl)) {
698
- $this->logger->log_error(__METHOD__,'Siteurl not found');
699
- return false;
700
- }
701
-
702
- $this->logger->log_info(__METHOD__,'End - Siteurl found:' .$siteurl);
703
- return $siteurl;
704
- }
705
-
706
- //get homeurl
707
- function get_homeurl(){
708
- global $table_prefix;
709
- $this->logger->log_info(__METHOD__,'Begin');
710
-
711
- $sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='home';";
712
- $dbc = new WPBackItUp_SQL($this->logger);
713
- $homeurl = $dbc->get_sql_scalar($sql);
714
- if (empty($homeurl)) {
715
- $this->logger->log_error(__METHOD__,' Homeurl not found.');
716
- return false;
717
- }
718
- $this->logger->log_info(__METHOD__,'End - homeurl found:' . $homeurl);
719
- return $homeurl;
720
- }
721
-
722
- //get user login
723
- function get_user_login($user_id){
724
- global $table_prefix;
725
- $this->logger->log_info(__METHOD__,'Begin');
726
-
727
- $sql = "SELECT user_login FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
728
-
729
- $dbc = new WPBackItUp_SQL($this->logger);
730
- $user_login = $dbc->get_sql_scalar($sql);
731
- if (empty($user_login)) {
732
- $this->logger->log_error(__METHOD__,'User_login not found.');
733
- return false;
734
- }
735
-
736
- $this->logger->log_info(__METHOD__,'End - User_login found.');
737
- return $user_login;
738
- }
739
-
740
- //get user pass
741
- function get_user_pass($user_id){
742
- global $table_prefix;
743
- $this->logger->log_info(__METHOD__,'Begin');
744
-
745
- $sql = "SELECT user_pass FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
746
-
747
- $dbc = new WPBackItUp_SQL($this->logger);
748
- $user_pass = $dbc->get_sql_scalar($sql);
749
- if (empty($user_pass)) {
750
- $this->logger->log_error(__METHOD__,'User_pass not found.');
751
- return false;
752
- }
753
- $this->logger->log_info(__METHOD__,'End - User_pass found.');
754
- return $user_pass;
755
- }
756
-
757
- //get user email
758
- function get_user_email($user_id){
759
- global $table_prefix;
760
- $this->logger->log_info(__METHOD__,'Begin');
761
-
762
- $sql = "SELECT user_email FROM ". $table_prefix ."users WHERE ID=" .$user_id ."";
763
- $dbc = new WPBackItUp_SQL($this->logger);
764
- $user_email = $dbc->get_sql_scalar($sql);
765
- if (empty($user_email)) {
766
- $this->logger->log_error(__METHOD__,'User_email not found.');
767
- return false;
768
- }
769
- $this->logger->log_info(__METHOD__,'End - User_email found.');
770
- return $user_email;
771
- }
772
-
773
-
774
- //Update user credentials
775
- function update_user_credentials($user_id, $user_login, $user_pass_hash, $user_email,$table_prefix){
776
- $this->logger->log_info(__METHOD__,'Begin');
777
-
778
- //prefer SQL update because password hash is safer than plain text update
779
- $sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass_hash ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
780
- $dbc = new WPBackItUp_SQL($this->logger);
781
- if (!$dbc->run_sql_command($sql)){
782
- $this->logger->log_error(__METHOD__,'User Credential database update failed.');
783
- return false;
784
- }
785
- $this->logger->log_info(__METHOD__,'End - User Credential updated in database.');
786
- return true;
787
- }
788
-
789
- //Create user
790
- function create_user_XXX($current_user){
791
- $this->logger->log_info(__METHOD__,'Begin');
792
-
793
- $user_id = wp_insert_user( $current_user ) ;
794
- if( is_wp_error($user_id) ) {
795
- $this->logger->log_error(__METHOD__,'User was not created:' .$user_id->get_error_message());
796
- return false;
797
- }
798
-
799
- $this->logger->log_info(__METHOD__,'End - New user created:' . $user_id);
800
- return true;
801
- }
802
-
803
-
804
- //update credentials
805
- function update_credentials($user_id, $user_full_name, $user_login, $user_pass_hash, $user_email,$table_prefix){
806
- $this->logger->log_info(__METHOD__,'Begin');
807
-
808
- //prefer SQL update because password hash is safer than plain text update
809
-
810
- $dbc = new WPBackItUp_SQL($this->logger);
811
-
812
- //Fetch the user
813
- $sql = "SELECT id from " . $table_prefix ."users where user_login = '" .$user_login ."'";
814
- $query_result = $dbc->get_sql_scalar($sql);
815
- $this->logger->log_info(__METHOD__,'Fetch user by login:' .$query_result);
816
-
817
- if (!empty($query_result)) {
818
- $this->logger->log_info(__METHOD__,'Update User Credentials.');
819
- //update the user
820
- $sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass_hash ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
821
- $dbc = new WPBackItUp_SQL($this->logger);
822
- if (!$dbc->run_sql_command($sql)){
823
- $this->logger->log_error(__METHOD__,'User Credential database update failed.');
824
- return false;
825
- }
826
- $this->logger->log_info(__METHOD__,'End - User Credential updated in database.');
827
- return true;
828
-
829
-
830
- } else {
831
- $this->logger->log_info(__METHOD__,'Create User Credentials.');
832
- //Create the user
833
- $sql = "INSERT INTO ". $table_prefix ."users (user_login, user_nicename, display_name, user_pass, user_email, user_registered, user_status) values('" .$user_login ."','" .$user_full_name ."','" .$user_full_name ."','" .$user_pass_hash ."','" .$user_email ."', NOW() ,'0')";
834
- if (!$dbc->run_sql_command($sql)){
835
- $this->logger->log_error(__METHOD__,'User insert failed.');
836
- return false;
837
- }else{
838
- $this->logger->log_info(__METHOD__,'User inserted in database successfully.');
839
- }
840
-
841
- //Get the new user ID
842
- $sql = "SELECT id from " . $table_prefix ."users where user_login = '" .$user_login ."'";
843
- $user_id = $dbc->get_sql_scalar($sql);
844
- $this->logger->log_info(__METHOD__,'Fetch user by id:' .$user_id);
845
-
846
- $sql = "INSERT INTO ". $table_prefix ."usermeta (user_id, meta_key, meta_value) values(" .$user_id .",'wp_capabilities', 'a:1:{s:13:\"administrator\";s:1:\"1\";}')";
847
- if (!$dbc->run_sql_command($sql)){
848
- $this->logger->log_error(__METHOD__,'user capabilities insert failed.');
849
- return false;
850
- }else {
851
- $this->logger->log_info(__METHOD__,'User capabilities inserted successfully.');
852
- }
853
-
854
- $sql = "INSERT INTO ". $table_prefix ."usermeta (user_id, meta_key, meta_value) values(" .$user_id .",'wp_user_level', '10')";
855
- if (!$dbc->run_sql_command($sql)){
856
- $this->logger->log_error(__METHOD__,'User level insert failed');
857
- return false;
858
- }else{
859
- $this->logger->log_info(__METHOD__,'User level inserted successfully.');
860
- }
861
-
862
- $this->logger->log_info(__METHOD__,'End - User created in database successfully.');
863
- return true;
864
- }
865
-
866
- }
867
-
868
- //update the site URL in the restored database
869
- function update_siteurl($table_prefix, $current_siteurl){
870
- $this->logger->log_info(__METHOD__,'Begin');
871
-
872
- $sql = "UPDATE ". $table_prefix ."options SET option_value='" .$current_siteurl ."' WHERE option_name='siteurl'";
873
- $dbc = new WPBackItUp_SQL($this->logger);
874
- if (!$dbc->run_sql_command($sql)){
875
- $this->logger->log('Error: SiteURL updated failed.');
876
- return false;
877
- }
878
- $this->logger->log_info(__METHOD__,'End - SiteURL updated in database:' .$current_siteurl);
879
- return true;
880
- }
881
-
882
- //Update homeURL
883
- function update_homeurl($table_prefix, $homeurl){
884
- $this->logger->log_info(__METHOD__,'Begin');
885
-
886
- $sql = "UPDATE ". $table_prefix ."options SET option_value='" .$homeurl ."' WHERE option_name='home'";
887
- $dbc = new WPBackItUp_SQL($this->logger);
888
- if (!$dbc->run_sql_command($sql)){
889
- $this->logger->log(__METHOD__,'HomeURL database update failed..');
890
- return false;
891
- }
892
- $this->logger->log_info(__METHOD__,'End - HomeURL updated in database:'.$homeurl);
893
- return true;
894
- }
895
-
896
- function update_permalinks(){
897
- global $wp_rewrite;
898
- $this->logger->log_info(__METHOD__,'Begin');
899
-
900
- try {
901
- $wp_rewrite->flush_rules( true );//Update permalinks - hard flush
902
-
903
- }catch(Exception $e) {
904
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
905
- return false;
906
- }
907
- $this->logger->log_info(__METHOD__,'End - Permalinks updated.');
908
- return true;
909
- }
910
-
911
- public function zip_logs(){
912
- $this->logger->log_info(__METHOD__,'Begin');
913
-
914
- //Zip up all the logs in the log folder
915
- $logs_path = WPBACKITUP__PLUGIN_PATH .'logs';
916
- $zip_file_path = $logs_path .'/Restore_Logs_' .$this->backup_id . '.zip';
917
-
918
- //copy/replace WP debug file
919
- $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
920
- $this->logger->log_info(__METHOD__,"Copy WP Debug: " .$wpdebug_file_path);
921
- if (file_exists($wpdebug_file_path)) {
922
- copy( $wpdebug_file_path, $logs_path .'/wpdebug.log' );
923
- }
924
-
925
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
926
- $zip->zip_files_in_folder($logs_path,$this->backup_id,'*.log');
927
- $zip->close();
928
-
929
- $this->logger->log_info(__METHOD__,'End');
930
-
931
- return $zip_file_path;
932
-
933
- }
934
-
935
- function send_notification_email($err, $success,$logs=array(),$notification_email) {
936
- global $logger,$status_array,$backup_job;
937
- $logger->log_info(__METHOD__,"Begin");
938
-
939
- $utility = new WPBackItUp_Utility($logger);
940
-
941
- if($success)
942
- {
943
- //Don't send logs on success unless debug is on.
944
- if (WPBACKITUP__DEBUG!==true){
945
- $logs=array();
946
- }
947
-
948
- $subject = get_bloginfo() . ' - Restore completed successfully.';
949
- $message = '<b>Your site was restored successfully.</b><br/><br/>';
950
-
951
- } else {
952
- $subject = get_bloginfo() .' - Backup did not complete successfully.';
953
- $message = '<b>Your restore did not complete successfully.</b><br/><br/>';
954
- }
955
-
956
- $local_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',current_time( 'timestamp' )));
957
- $message .= 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
958
- $message .= 'Restore date: ' . $local_datetime . '<br/>';
959
-
960
- //$message .= 'Completion Code: ' . $backup_job->backup_id .'-'. $processing_minutes .'-' .$processing_seconds .'<br/>';
961
- $message .= 'WP BackItUp Version: ' . WPBACKITUP__VERSION . '<br/>';
962
- $message .= '<br/>';
963
-
964
-
965
- //Add the completed steps on success
966
- // if($success) {
967
- // $message .='<b>Steps Completed</b><br/>';
968
- //
969
- // //Add the completed statuses
970
- // foreach ($status_array as $status_key => $status_value) {
971
- // if ($status_value==2) {
972
- // foreach ($status_description as $msg_key => $msg_value) {
973
- // if ($status_key==$msg_key) {
974
- // $message .= $msg_value . '<br/>';
975
- // break;
976
- // }
977
- // }
978
- // }
979
- // }
980
- // } else {
981
- // //Error occurred
982
- // $message .= '<br/>';
983
- // $message .= 'Errors:<br/>' . get_error_message($err);
984
- // }
985
-
986
- // $term='success';
987
- // if(!$success)$term='error';
988
- // $message .='<br/><br/>Checkout '. $WPBackitup->get_anchor_with_utm('www.wpbackitup.com', '', 'notification+email', $term) .' for info about WP BackItUp and our other products.<br/>';
989
-
990
-
991
- if($notification_email)
992
- $utility->send_email($notification_email,$subject,$message,$logs);
993
-
994
- $logger->log_info(__METHOD__,"End");
995
- }
996
-
997
- function save_process_status($process,$status){
998
- $this->logger->log_info(__METHOD__,"Begin");
999
-
1000
- //Write status to JSON file - cant use database because it will e restored
1001
- $local_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',current_time( 'timestamp' )));
1002
- $process_status = array(
1003
- 'status' => $status,
1004
- 'start_time'=>$local_datetime,
1005
- 'end_time' =>''
1006
- );
1007
-
1008
- $log_file_path = WPBACKITUP__PLUGIN_PATH .'logs/restore_' .$this->backup_id .'.log';
1009
- $restore_status_string=false;
1010
- if (file_exists($log_file_path)){
1011
- $restore_status_string = file_get_contents($log_file_path);
1012
- }
1013
-
1014
- if (false===$restore_status_string || empty($restore_status_string)){
1015
- $restore_status_array=array($process=>$process_status);
1016
- } else{
1017
- $restore_status_array = json_decode($restore_status_string,true);
1018
-
1019
- //Does the process already exist
1020
- if (! array_key_exists ($process,$restore_status_array)){
1021
- //Add to existing array
1022
- $restore_status_array[$process]=$process_status;
1023
- }else{
1024
- //update the end time
1025
- $restore_status_array[$process]['end_time'] = $local_datetime;
1026
- $restore_status_array[$process]['status'] = $status;
1027
- }
1028
-
1029
- }
1030
-
1031
- $restore_status_string = json_encode($restore_status_array);
1032
- file_put_contents($log_file_path, $restore_status_string);
1033
-
1034
- $this->logger->log_info(__METHOD__,"End");
1035
- }
1036
-
1037
-
1038
-
1039
-
1040
-
1041
- /** GETTERS */
1042
-
1043
- /**
1044
- * @return string
1045
- */
1046
- public function get_backup_folder_path() {
1047
- return $this->backup_folder_path;
1048
- }
1049
-
1050
- /**
1051
- * @return string
1052
- */
1053
- public function get_restore_root_folder_path() {
1054
- return $this->restore_root_folder_path;
1055
- }
1056
-
1057
- /**
1058
- * @return string
1059
- */
1060
- // public function get_restore_folder_path() {
1061
- // return $this->restore_folder_path;
1062
- // }
1063
-
1064
- /**
1065
- * @return mixed
1066
- */
1067
- public function get_backup_name() {
1068
- return $this->backup_name;
1069
- }
1070
-
1071
- /**
1072
- * @return string
1073
- */
1074
- public function get_restore_staging_suffix() {
1075
- return $this->restore_staging_suffix;
1076
- }
1077
-
1078
- /**
1079
- * @return mixed
1080
- */
1081
- public function get_backup_id() {
1082
- return $this->backup_id;
1083
- }
1084
-
1085
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-scheduler.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /**
3
- * WP BackItUp Scheduler Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
- class WPBackItUp_Scheduler {
12
-
13
-
14
- private $logger;
15
-
16
- /**
17
- * Constructor
18
- */
19
- function __construct() {
20
-
21
- $this->logger = new WPBackItUp_Logger(false,null,'debug_scheduler');
22
-
23
- }
24
-
25
- /**
26
- * Destructor
27
- */
28
- function __destruct() {
29
- $this->logger->close_file();
30
- }
31
-
32
-
33
- /**
34
- * Check to see if task is ready to run
35
- *
36
- * @param $task
37
- * @return bool
38
- */
39
- public function isTaskScheduled($task){
40
- $this->logger->log('Check schedule for task: ' . $task);
41
- switch ($task) {
42
- case "backup":
43
- return $this->check_backup_schedule();
44
- break;
45
- case "cleanup":
46
- return $this->check_cleanup_schedule();
47
- break;
48
- }
49
-
50
- $this->logger->log('Task not found:' . $task);
51
- return false;
52
- }
53
-
54
- /**
55
- * Check the backup schedule to determine if the backup
56
- * task should be run today.
57
- *
58
- * @return bool
59
- */
60
- private function check_backup_schedule(){
61
- global $WPBackitup;
62
- $this->logger->log('**Check Backup Schedule**');
63
-
64
- try {
65
-
66
- ///ONLY active premium get this feature
67
- if (!$WPBackitup->license_active() || 'expired'== $WPBackitup->license_status()){
68
- $this->logger->log('License is not active');
69
- return false;
70
- }
71
-
72
- //Get days scheduled to run on.
73
- $scheduled_dow = $WPBackitup->backup_schedule();
74
- $this->logger->log('Scheduled Days of week: ' .$scheduled_dow); //1=monday, 2=tuesday..
75
-
76
- //What is the current day of the week
77
- $current_datetime = current_time( 'timestamp' );
78
- $current_date = date("Ymd",$current_datetime);
79
- $current_dow = date("N",$current_datetime); //1=monday
80
-
81
- $this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
82
- $this->logger->log('Current Day of Week:' . $current_dow );
83
-
84
- //Get Last RUN date
85
- $lastrun_datetime = $WPBackitup->backup_lastrun_date();
86
-
87
- $lastrun_date = date("Ymd",$lastrun_datetime);
88
- $lastrun_dow =0;//0=none
89
- if ($lastrun_datetime!=-2147483648){// 1901-12-13:never run
90
- $lastrun_dow = date("N",$lastrun_datetime);
91
- }
92
-
93
- $this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
94
- $this->logger->log('Last Run Day of Week:' . $lastrun_dow);
95
-
96
- //Did backup already run today
97
- if ($current_date==$lastrun_date){
98
- $this->logger->log('Backup already ran today');
99
- return false;
100
- }
101
-
102
- //Should it run on this day of the week
103
- if (false===strpos($scheduled_dow,$current_dow)){
104
- $this->logger->log('Not scheduled for: ' .$current_dow);
105
- return false;
106
- }
107
-
108
- $this->logger->log('Backup should be run now.');
109
- return true;
110
-
111
- }catch(Exception $e) {
112
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
113
- return false;
114
- }
115
-
116
- }
117
-
118
- /**
119
- * Check the cleanup schedule to determine if the task should be run today.
120
- * Cleanup will be run once per day
121
- *
122
- * @return bool
123
- */
124
- private function check_cleanup_schedule(){
125
- global $WPBackitup;
126
- $this->logger->log('**Check Cleanup Schedule**');
127
- try {
128
-
129
- //What is the current day of the week
130
- $current_datetime = current_time( 'timestamp' );
131
- $current_date = date("Ymd",$current_datetime);
132
-
133
- $this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
134
-
135
- //Get Last RUN date
136
- $lastrun_datetime = $WPBackitup->cleanup_lastrun_date();
137
-
138
- $lastrun_date = date("Ymd",$lastrun_datetime);
139
- $this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
140
-
141
- //Has it been at least an hour since the last cleanup?
142
-
143
- $next_run_datetime=$lastrun_datetime+3600; //1 hour
144
- $this->logger->log('Next Run Date Time:' . date( 'Y-m-d H:i:s',$next_run_datetime));
145
-
146
- $this->logger->log('TimeToRun:' . $current_datetime . ':'.$next_run_datetime );
147
- if ($current_datetime>=$next_run_datetime){
148
- $this->logger->log('Cleanup should be run now.');
149
- return true;
150
- }
151
-
152
- $this->logger->log('Not yet time to run Cleanup.');
153
- return false;
154
-
155
- }catch(Exception $e) {
156
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
157
- return false;
158
- }
159
-
160
- }
161
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-sql.php DELETED
@@ -1,520 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup SQL Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
- class WPBackItUp_SQL {
12
-
13
- private $logger;
14
- private $connection;
15
-
16
- function __construct($logger) {
17
- try {
18
- $this->logger = $logger;
19
- $this->connection = $this->get_sqlconnection();
20
-
21
- } catch(Exception $e) {
22
- //Dont do anything
23
- print $e;
24
- }
25
- }
26
-
27
- function __destruct() {
28
- // Close the connection
29
- $this->connection->close() ;
30
- }
31
-
32
- public function mysqldump_export($sql_file_path,$with_mysqlpath=false) {
33
-
34
- $this->logger->log('(SQL.mysqldump_export) Export Database to: ' .$sql_file_path);
35
-
36
- $db_name = DB_NAME;
37
- $db_user = DB_USER;
38
- $db_pass = DB_PASSWORD;
39
- $db_host = $this->get_hostonly(DB_HOST);
40
- $db_port = $this->get_portonly(DB_HOST);
41
-
42
- //This is to ensure that exec() is enabled on the server
43
- if(exec('echo EXEC') == 'EXEC') {
44
- try {
45
- $mysql_path='';
46
- if ($with_mysqlpath) {
47
- $mysql_path = $this->get_mysql_path();
48
- if ($mysql_path===false) return false;
49
- }
50
-
51
- $process = $mysql_path .'mysqldump';
52
- $command = $process
53
- . ' --host=' . $db_host;
54
-
55
- //Check for port
56
- if (false!==$db_port){
57
- $command .=' --port=' . $db_port;
58
- }
59
-
60
- $command .=
61
- ' --user=' . $db_user
62
- . ' --password=' . $db_pass
63
- .=' ' . $db_name
64
- . ' > "' . $sql_file_path .'"';
65
-
66
- if (WPBACKITUP__DEBUG) {
67
- $this->logger->log('(SQL.db_SQLDump)Execute command:' . $command);
68
- }
69
-
70
- exec($command,$output,$rtn_var);
71
- $this->logger->log('(SQL.mysqldump_export)Execute output:');
72
- $this->logger->log($output);
73
- $this->logger->log('Return Value:' .$rtn_var);
74
-
75
- //0 is success
76
- if ($rtn_var>0){
77
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED return Value:' .$rtn_var);
78
- return false;
79
- }
80
-
81
- //Did the export work
82
- clearstatcache();
83
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
84
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED: Dump was empty or missing.');
85
- return false;
86
- }
87
- } catch(Exception $e) {
88
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exception: ' .$e);
89
- return false;
90
- }
91
- }
92
- else
93
- {
94
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exec() disabled.');
95
- return false;
96
- }
97
-
98
- $this->logger->log('(SQL.mysqldump_export) SQL Dump SUCCESS.');
99
- return true;
100
- }
101
-
102
-
103
- public function manual_export($sql_file_path) {
104
- $this->logger->log('(SQL.manual_export)Manually Create SQL Backup File:'.$sql_file_path);
105
-
106
- $mysqli = $this->connection;
107
- $mysqli->set_charset('utf8');
108
-
109
- if (false===$mysqli) {
110
- return false;
111
- }
112
-
113
- // Script Header Information
114
- $return = '';
115
- $return .= "-- ------------------------------------------------------\n";
116
- $return .= "-- ------------------------------------------------------\n";
117
- $return .= "--\n";
118
- $return .= "-- WP BackItUp Manual Database Backup \n";
119
- $return .= "--\n";
120
- $return .= '-- Created: ' . date("Y/m/d") . ' on ' . date("h:i") . "\n";
121
- $return .= "--\n";
122
- $return .= "-- Database : " . DB_NAME . "\n";
123
- $return .= "--\n";
124
- $return .= "-- ------------------------------------------------------\n";
125
- $return .= "-- ------------------------------------------------------\n";
126
- $return .= 'SET AUTOCOMMIT = 0 ;' ."\n" ;
127
- $return .= 'SET FOREIGN_KEY_CHECKS=0 ;' ."\n" ;
128
- $return .= "\n";
129
- $return .= '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' ."\n" ;
130
- $return .= '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;' ."\n" ;
131
- $return .= '/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;' ."\n" ;
132
- $return .= '/*!40101 SET NAMES utf8 */;' ."\n" ;
133
-
134
- $tables = array() ;
135
-
136
- // Exploring what tables this database has
137
- $result = $mysqli->query('SHOW TABLES' ) ;
138
-
139
- // Cycle through "$result" and put content into an array
140
- while ($row = $result->fetch_row()) {
141
- $tables[] = $row[0] ;
142
- }
143
-
144
- // Cycle through each table
145
- foreach($tables as $table) {
146
- // Get content of each table
147
- $result = $mysqli->query('SELECT * FROM '. $table) ;
148
-
149
- // Get number of fields (columns) of each table
150
- $num_fields = $mysqli->field_count ;
151
-
152
- // Add table information
153
- $return .= "--\n" ;
154
- $return .= '-- Table structure for table `' . $table . '`' . "\n" ;
155
- $return .= "--\n" ;
156
- $return.= 'DROP TABLE IF EXISTS `'.$table.'`;' . "\n" ;
157
-
158
- // Get the table-shema
159
- $shema = $mysqli->query('SHOW CREATE TABLE '.$table) ;
160
-
161
- // Extract table shema
162
- $tableshema = $shema->fetch_row() ;
163
-
164
- // Append table-shema into code
165
- $return.= $tableshema[1].";" . "\n\n" ;
166
-
167
- // Cycle through each table-row
168
- while($rowdata = $result->fetch_row()) {
169
-
170
- $return.= 'INSERT INTO '.$table.' VALUES(';
171
- for($j=0; $j<$num_fields; $j++){
172
- $rowdata[$j] = addslashes($rowdata[$j]);
173
- $rowdata[$j] = str_replace("\n","\\n",$rowdata[$j]);
174
-
175
- if (isset($rowdata[$j])) {
176
- $return.= '"'.$rowdata[$j].'"' ;
177
- } else {
178
- if (is_null($rowdata[$j])) {
179
- $return.= 'NULL';//Dont think this is working but not causing issues
180
- } else {
181
- $return.= '""';
182
- }
183
- }
184
-
185
- if ($j<($num_fields-1)) { $return.= ','; }
186
- }
187
- $return.= ");\n";
188
- }
189
- $return .= "\n\n" ;
190
- }
191
-
192
- $return .= 'SET FOREIGN_KEY_CHECKS = 1 ; ' . "\n" ;
193
- $return .= 'COMMIT ; ' . "\n" ;
194
- $return .= 'SET AUTOCOMMIT = 1 ; ' . "\n" ;
195
-
196
- //save file
197
- $handle = fopen($sql_file_path,'w+');
198
- fwrite($handle,$return);
199
- fclose($handle);
200
- clearstatcache();
201
-
202
- //Did the export work
203
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
204
- $this->logger->log('(SQL.manual_export) Failure: SQL Export file was empty or didnt exist.');
205
- return false;
206
- }
207
-
208
- $this->logger->log('(SQL.manual_export)SQL Backup File Created:'.$sql_file_path);
209
- return true;
210
- }
211
-
212
- public function run_sql_exec($sql_file,$with_mysqlpath=false) {
213
- $this->logger->log('(SQL.run_sql_exec)SQL Execute:' .$sql_file);
214
-
215
- //Is the backup sql file empty
216
- if (!file_exists($sql_file) || filesize($sql_file)<=0) {
217
- $this->logger->log('(SQL.run_sql_exec) Failure: SQL File was empty:' .$sql_file);
218
- return false;
219
- }
220
-
221
- //This is to ensure that exec() is enabled on the server
222
- if(exec('echo EXEC') != 'EXEC') {
223
- $this->logger->log('(SQL.run_sql_exec) Failure: Exec() disabled.');
224
- return false;
225
- }
226
-
227
- try {
228
-
229
- $mysql_path='';
230
- if ($with_mysqlpath) {
231
- $mysql_path = $this->get_mysql_path();
232
- if ($mysql_path===false) return false;
233
- }
234
-
235
- $db_name = DB_NAME;
236
- $db_user = DB_USER;
237
- $db_pass = DB_PASSWORD;
238
- $db_host = $this->get_hostonly(DB_HOST);
239
- $db_port = $this->get_portonly(DB_HOST);
240
-
241
- $process = $mysql_path .'mysql';
242
- $command = $process
243
- . ' --host=' . $db_host;
244
-
245
- //Check for port
246
- if (false!==$db_port){
247
- $command .=' --port=' . $db_port;
248
- }
249
-
250
- $command .=
251
- ' --user=' . $db_user
252
- . ' --password=' . $db_pass
253
- . ' --database=' . $db_name
254
- . ' --execute="SOURCE ' . $sql_file .'"';
255
-
256
- if (WPBACKITUP__DEBUG) {
257
- $this->logger->log( '(SQL.db_run_sql)Execute command:' . $command );
258
- }
259
-
260
- //$output = shell_exec($command);
261
- exec($command,$output,$rtn_var);
262
- $this->logger->log('(SQL.run_sql_exec)Execute output:');
263
- $this->logger->log($output);
264
- $this->logger->log('Return Value:' .$rtn_var);
265
-
266
- //0 is success
267
- if ($rtn_var!=0){
268
- $this->logger->log('(SQL.run_sql_exec) An Error has occurred RTNVAL: ' .$rtn_var);
269
- return false;
270
- }
271
-
272
- }catch(Exception $e) {
273
- $this->logger->log('(SQL.run_sql_exec) Exception: ' .$e);
274
- return false;
275
- }
276
-
277
- //Success
278
- $this->logger->log('(SQL.run_sql_exec)SQL Executed successfully');
279
- return true;
280
- }
281
-
282
- public function run_sql_manual_OLD($sql_file) {
283
- $this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file);
284
-
285
- //Is the backup sql file empty
286
- if (!file_exists($sql_file) || filesize($sql_file)<=0) {
287
- $this->logger->log('(SQL.run_sql_manual) Failure: SQL File was empty:' .$sql_file);
288
- return false;
289
- }
290
-
291
- $query = file_get_contents($sql_file);
292
- if (empty($query)) return false;
293
-
294
- try {
295
-
296
- $mysqli = $this->get_sqlconnection();
297
- $mysqli->set_charset('utf8');
298
-
299
- if (false===$mysqli) {
300
- return false;
301
- }
302
-
303
- $ctr=1;
304
- $this->logger->log('(SQL.run_sql_manual) 0: here ');
305
- if($mysqli->multi_query($query))
306
- {
307
- do {
308
-
309
- $this->logger->log('(SQL.run_sql_manual) 1: ' .$ctr++);
310
- /* store first result set */
311
- if($resultSet = $mysqli->store_result())
312
- {
313
- $this->logger->log('(SQL.run_sql_manual) 2: ');
314
-
315
- while($row = $resultSet->fetch_row())
316
- {
317
- $this->logger->log('(SQL.run_sql_manual) 3: ');
318
- }
319
- $resultSet->free();
320
- }
321
-
322
- if (!$mysqli->more_results()) break; //All done
323
-
324
- } while ($mysqli->next_result());
325
-
326
- $this->logger->log('(SQL.run_sql_manual) 4: ');
327
- $mysqli->close();
328
- }
329
-
330
- }catch(Exception $e) {
331
- $this->logger->log('(SQL.run_sql_manual) Exception: ' .$e);
332
- return false;
333
- }
334
-
335
- //Success
336
- $this->logger->log('(SQL.run_sql_manual)SQL Executed successfully:' .$sql_file);
337
- return true;
338
- }
339
-
340
- function run_sql_manual($sql_file_path, $delimiter = ';')
341
- {
342
- $this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file_path);
343
- set_time_limit(0);
344
-
345
- //Is the backup sql file empty
346
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
347
- $this->logger->log('(SQL.run_sql_manual) Failure: SQL File was empty:' .$sql_file_path);
348
- return false;
349
- }
350
-
351
- try {
352
- if (is_file($sql_file_path) === true)
353
- {
354
- $sql_handle = fopen($sql_file_path, 'r');
355
-
356
- if (is_resource($sql_handle) === true)
357
- {
358
- $query = array();
359
-
360
- $mysqli = $this->get_sqlconnection();
361
- $mysqli->set_charset('utf8');
362
- // $mysqli->autocommit(FALSE);
363
- // $mysqli->begin_transaction();
364
-
365
- if (false===$mysqli) {
366
- return false;
367
- }
368
-
369
- $error_count=0;
370
- $total_query=0;
371
- while (feof($sql_handle) === false)
372
- {
373
- $query[] = fgets($sql_handle);
374
-
375
- if (preg_match('~' . preg_quote($delimiter, '~') . '\s*$~iS', end($query)) === 1)
376
- {
377
- $query = trim(implode('', $query));
378
-
379
- //Execute SQL statement
380
- $total_query++;
381
- if ($mysqli->query($query) === false) {
382
- $error_count++;
383
-
384
- $this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
385
- $this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
386
-
387
- $this->logger->log('(SQL.run_sql_manual) SQL ERROR: ' . $query);
388
-
389
- //$mysqli->rollback();
390
- $mysqli->close();
391
-
392
- fclose($sql_handle);
393
- return false;
394
- }
395
- // else {
396
- // $this->logger->log('(SQL.run_sql_manual) SUCCESS: ' . $query);
397
- // }
398
-
399
- while (ob_get_level() > 0)
400
- {
401
- ob_end_flush();
402
- }
403
-
404
- flush();
405
- }
406
-
407
- if (is_string($query) === true)
408
- {
409
- $query = array();
410
- }
411
- }
412
-
413
- //$mysqli->commit();
414
- $mysqli->close();
415
-
416
- $this->logger->log('(SQL.run_sql_manual)SQL Executed successfully:' .$sql_file_path);
417
- $this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
418
- $this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
419
- return fclose($sql_handle);
420
- }
421
- }
422
-
423
- }catch(Exception $e) {
424
- $this->logger->log('(SQL.run_sql_manual) Exception: ' .$e);
425
- return false;
426
- }
427
-
428
- $this->logger->log('(SQL.run_sql_manual)SQL File could not be opened:' .$sql_file_path);
429
- return false;
430
- }
431
-
432
- private function get_sqlconnection() {
433
- $this->logger->log('(SQL.get_sqlconnection)Get SQL connection to database.');
434
- $db_name = DB_NAME;
435
- $db_user = DB_USER;
436
- $db_pass = DB_PASSWORD;
437
- $db_host = $this->get_hostonly(DB_HOST);
438
- $db_port = $this->get_portonly(DB_HOST);
439
-
440
- $this->logger->log('(SQL.get_sqlconnection)Host:' . $db_host);
441
- $this->logger->log('(SQL.get_sqlconnection)Port:' . $db_port);
442
-
443
- if (false===$db_port){
444
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name);
445
- }
446
- else {
447
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name,$db_port);
448
- }
449
-
450
- if ($mysqli->connect_errno) {
451
- $this->logger->log('(SQL.get_sqlconnection)Cannot connect to database.' . $mysqli->connect_error);
452
- return false;
453
- }
454
- return $mysqli;
455
- }
456
-
457
- private function get_hostonly($db_host) {
458
- //Check for port
459
- $host_array = explode(':',$db_host);
460
- if (is_array($host_array)){
461
- return $host_array[0];
462
- }
463
- return $db_host;
464
- }
465
-
466
- private function get_portonly($db_host) {
467
- //Check for port
468
- $host_array = explode(':',$db_host);
469
- if (is_array($host_array) && count($host_array)>1){
470
- return $host_array[1];
471
- }
472
-
473
- return false;
474
- }
475
-
476
- //Get SQL scalar value
477
- public function get_sql_scalar($sql){
478
- $value='';
479
- if ($result = mysqli_query($this->connection, $sql)) {
480
- while ($row = mysqli_fetch_row($result)) {
481
- $value = $row[0];
482
- }
483
- mysqli_free_result($result);
484
- }
485
- return $value;
486
- }
487
-
488
- //Run SQL command
489
- public function run_sql_command($sql){
490
- if(!mysqli_query($this->connection, $sql) ) {
491
- $this->logger->log('Error:SQL Command Failed:' .$sql);
492
- return false;
493
- }
494
- return true;
495
- }
496
-
497
- //Get path to MQSQL Bin
498
- private function get_mysql_path(){
499
- $base_directory = $this->get_sql_scalar('select @@basedir');
500
- if (!empty($base_directory)){
501
- $base_directory.='/bin/';
502
- $this->logger->log('MySQL install path found:' .$base_directory);
503
- return $base_directory;
504
- }
505
- $this->logger->log('MySQL install path NOT found');
506
- return false;
507
- }
508
-
509
- //This function is untested
510
- // function get_database_size($dbname) {
511
- // mysqli_select_db($dbname);
512
- // $result = mysqli_query("SHOW TABLE STATUS");
513
- // $dbsize = 0;
514
- // while($row = mysqli_fetch_array($result)) {
515
- // $dbsize += $row["Data_length"] + $row["Index_length"];
516
- // }
517
- // return $dbsize;
518
- // }
519
-
520
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-utility.php DELETED
@@ -1,83 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Utility Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
- class WPBackItUp_Utility {
11
-
12
- private $logger;
13
-
14
- function __construct($logger) {
15
- try {
16
- $this->logger = $logger;
17
- } catch(Exception $e) {
18
- //Dont do anything
19
- print $e;
20
- }
21
- }
22
-
23
- function __destruct() {
24
-
25
- }
26
-
27
-
28
- function send_email($to,$subject,$message,$attachments=array(),$reply_email=null)
29
- {
30
- try {
31
- //global $WPBackitup;
32
- if($to) {
33
-
34
- $from_email = get_bloginfo( 'admin_email' );
35
- $headers[] = 'Content-type: text/html';
36
- $headers[] = 'From: WP BackItUp <'. $from_email .'>';
37
-
38
- if (null!=$reply_email) {
39
- $headers[] = 'Reply-To: <'. $reply_email .'>';
40
- }
41
-
42
- wp_mail($to, $subject, nl2br($message), $headers,$attachments);
43
- $this->logger->log('(send_email)EMail Sent from:' .$from_email);
44
- $this->logger->log('(send_email)EMail Sent to:' .$to);
45
- }
46
-
47
- } catch(Exception $e) {
48
- //Dont do anything
49
- $this->logger->log('(send_email)Send Email Exception:'.$e);
50
- }
51
-
52
- }
53
-
54
- //Function for PHP version 5.2
55
- //Diff Approximation only
56
- function date_diff_days($date1,$date2 ){
57
-
58
- $date_diff_seconds = $this->date_diff_seconds($date1,$date2 );
59
- $days = round($date_diff_seconds/86400);
60
- return $days;
61
- }
62
-
63
- //Function for PHP version 5.2
64
- //Diff Approximation only
65
- function date_diff_seconds($date1,$date2 ){
66
- // the necessary way using PHP 5.2
67
- $date1_string = $date1->format('U');
68
- $date2_string = $date2->format('U');
69
-
70
- // get a difference represented as an int, number of seconds
71
- $date_diff_seconds = abs($date1_string - $date2_string);
72
-
73
- return $date_diff_seconds;
74
- }
75
-
76
- function timestamp_diff_seconds($timestamp1,$timestamp2 ){
77
- // get a difference represented as an int, number of seconds
78
- $timestamp_diff_seconds = abs($timestamp1 - $timestamp2);
79
-
80
- return $timestamp_diff_seconds;
81
- }
82
- }
83
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-wpbackitup-admin.php DELETED
@@ -1,1740 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Admin Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
-
12
- class WPBackitup_Admin {
13
-
14
- public $namespace = WPBACKITUP__NAMESPACE;
15
- public $friendly_name = WPBACKITUP__FRIENDLY_NAME;
16
- public $version = WPBACKITUP__VERSION;
17
-
18
- private static $instance = false;
19
-
20
- //Use Getters
21
- private $license_key;//Loaded in getter
22
- private $license_type; //Loaded in getter
23
- private $license_expires;
24
-
25
- private $license_active;//Loaded in getter
26
- private $license_status;//Loaded in getter
27
- private $license_status_message;//Loaded in getter
28
- private $license_type_description; //Getter will load
29
-
30
- private $backup_retained_number; //Getter will load
31
- private $notification_email;//Getter will load
32
- private $logging;//Getter will load
33
-
34
- private $backup_count; //getter will load
35
- private $successful_backup_count;
36
-
37
- public $backup_type;
38
-
39
-
40
- // Default plugin options
41
- public $defaults = array(
42
- 'logging' => false,
43
- 'license_key' => "lite",
44
- 'license_last_check_date'=> "1970-01-01 00:00:00",
45
- 'license_status' => "",
46
- 'license_status_message'=> "",
47
- 'license_type' => "0",
48
- 'license_expires'=> "1970-01-01 00:00:00",
49
- 'license_limit'=> "1",
50
- 'license_sitecount'=> "",
51
- 'notification_email' => "",
52
- 'backup_retained_number' => "3",
53
- 'lite_backup_retained_number' => "1",
54
- 'lite_registration_email' => "",
55
- 'lite_registration_first_name' => "",
56
- 'backup_count'=>0,
57
- 'successful_backup_count'=>0,
58
- 'stats_last_check_date'=> "1970-01-01 00:00:00",
59
- 'backup_schedule'=>"",
60
- 'backup_lastrun_date'=>"-2147483648",
61
- 'cleanup_lastrun_date'=>"-2147483648",
62
- 'backup_batch_size'=>"500",
63
- 'support_email' => "",
64
- );
65
-
66
-
67
- /**
68
- * Retrieve the current WP backItUp instance.
69
- */
70
- public static function get_instance() {
71
- if ( ! self::$instance ) {
72
- self::$instance = new self();
73
- }
74
-
75
- return self::$instance;
76
- }
77
-
78
- /**
79
- * Instantiation construction
80
- *
81
- */
82
- private function __construct() {
83
- /**
84
- * Make this plugin available for translation.
85
- * Translations can be added to the /languages/ directory.
86
- */
87
-
88
- //TODO: Add multi Language Support back
89
- //load_theme_textdomain( $this->namespace, WPBACKITUP__PLUGIN_DIR . '/languages' );
90
-
91
- // Add all action, filter and shortcode hooks
92
- $this->_add_hooks();
93
- }
94
-
95
- /**
96
- * Add in various hooks
97
- */
98
- private function _add_hooks() {
99
-
100
- // Options page for configuration
101
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
102
-
103
- // Route requests for form processing
104
- add_action( 'admin_init', array( &$this, 'route' ) );
105
-
106
- // Add a settings link next to the "Deactivate" link on the plugin listing page
107
- add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
108
-
109
- //Load all the resources
110
- add_action( 'admin_enqueue_scripts', array( &$this, 'load_resources' ) );
111
-
112
- //Load the backup action
113
- add_action('wp_ajax_wp-backitup_backup', array( &$this, 'ajax_queue_backup' ));
114
-
115
- //Load the restore action
116
- add_action('wp_ajax_wp-backitup_restore', array( &$this, 'ajax_queue_restore' ));
117
-
118
- //Load the upload action
119
- add_action('wp_ajax_wp-backitup_plupload_action', array($this,'plupload_action'));
120
-
121
- //Status reader for UI
122
- add_action('wp_ajax_wp-backitup_restore_status_reader', array( &$this,'ajax_get_restore_status'));
123
-
124
- add_action('wp_ajax_wp-backitup_backup_status_reader', array( &$this,'ajax_get_backup_status'));
125
-
126
- add_action('wp_ajax_wp-backitup_backup_response_reader', array( &$this,'ajax_backup_response_reader'));
127
-
128
- //Delete File Action
129
- add_action('wp_ajax_wp-backitup_delete_file', array( &$this,'ajax_delete_backup'));
130
-
131
- //View Log Action
132
- add_action('admin_post_viewlog', array( &$this,'admin_viewlog'));
133
-
134
- //Download Backup
135
- add_action('admin_post_download_backup', array( &$this,'admin_download_backup'));
136
-
137
- //Create Daily backup action
138
- add_action( 'wpbackitup_queue_scheduled_jobs', array( &$this,'wpbackitup_queue_scheduled_jobs'));
139
-
140
- add_action( 'wpbackitup_run_backup_tasks', array( &$this,'wpbackitup_run_backup_tasks'));
141
-
142
- add_action( 'wpbackitup_run_cleanup_tasks', array( &$this,'wpbackitup_run_cleanup_tasks'));
143
-
144
- }
145
-
146
- /**
147
- *
148
- * Define the admin menu options for this plugin
149
- *
150
- */
151
- public function admin_menu() {
152
-
153
- // add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
154
- add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_backup_page' ), WPBACKITUP__PLUGIN_URL .'/images/icon.png', 77);
155
-
156
- //Add Backup Menu Nav
157
- add_submenu_page( $this->namespace, 'Backup', 'Backup', 'administrator', $this->namespace.'-backup', array( &$this, 'admin_backup_page' ) );
158
-
159
- //Add Restore Menu Nav IF licensed
160
- if ($this->license_type()!=0) {
161
- add_submenu_page( $this->namespace, 'Restore', 'Restore', 'administrator', $this->namespace.'-restore', array( &$this, 'admin_restore_page' ) );
162
- }
163
-
164
- //Add Support Menu Nav
165
- add_submenu_page( $this->namespace, 'Support', 'Support', 'administrator', $this->namespace.'-support', array( &$this, 'admin_support_page' ) );
166
-
167
- //Add Settings Menu Nav
168
- add_submenu_page( $this->namespace, 'Settings', 'Settings', 'administrator', $this->namespace.'-settings', array( &$this, 'admin_settings_page' ) );
169
-
170
-
171
- if (WPBACKITUP__DEBUG===true){
172
- add_submenu_page( $this->namespace, 'Test', 'Test', 'administrator', $this->namespace.'-test', array( &$this, 'admin_test_page' ) );
173
- }
174
- // remove duplicate submenu page. wp limitations //
175
- // http://wordpress.stackexchange.com/questions/16401/remove-duplicate-main-submenu-in-admin
176
- remove_submenu_page($this->namespace,$this->namespace);
177
-
178
- }
179
-
180
- public function load_resources() {
181
-
182
- //Only load the JS and CSS when plugin is active
183
- if( !empty($_REQUEST['page']) && substr($_REQUEST['page'], 0, 11) === 'wp-backitup') {
184
-
185
- // Admin JavaScript
186
- wp_register_script( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "js/wpbackitup_admin.js", array( 'jquery' ), $this->version, true );
187
- wp_enqueue_script( "{$this->namespace}-admin" );
188
-
189
- // Admin Stylesheet
190
- wp_register_style( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "css/wpbackitup_admin.css", array(), $this->version, 'screen' );
191
- wp_enqueue_style( "{$this->namespace}-admin" );
192
-
193
- //Admin fonts
194
- wp_register_style( 'google-fonts', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
195
- wp_enqueue_style( 'google-fonts' );
196
-
197
- //UPLOADS only
198
- if ($_REQUEST['page']=='wp-backitup-restore') {
199
- wp_enqueue_media();
200
- }
201
- }
202
- }
203
-
204
- /**
205
- * The admin section backup page rendering method
206
- *
207
- */
208
- public function admin_backup_page()
209
- {
210
- if( !current_user_can( 'manage_options' ) ) {
211
- wp_die( 'You do not have sufficient permissions to access this page' );
212
- }
213
-
214
- include WPBACKITUP__PLUGIN_PATH . "/views/backup.php";
215
- }
216
-
217
- /**
218
- * The admin section restore page rendering method
219
- *
220
- */
221
- public function admin_restore_page()
222
- {
223
- if( !current_user_can( 'manage_options' ) ) {
224
- wp_die( 'You do not have sufficient permissions to access this page.' );
225
- }
226
-
227
- include WPBACKITUP__PLUGIN_PATH . "/views/restore.php";
228
- }
229
-
230
- /**
231
- * The admin section settings page rendering method
232
- *
233
- */
234
- public function admin_settings_page()
235
- {
236
-
237
- if( !current_user_can( 'manage_options' ) ) {
238
- wp_die( 'You do not have sufficient permissions to access this page.' );
239
- }
240
-
241
- include WPBACKITUP__PLUGIN_PATH . "/views/settings.php";
242
- }
243
-
244
- /**
245
- * The admin section support page rendering method
246
- *
247
- */
248
- public function admin_support_page()
249
- {
250
- include WPBACKITUP__PLUGIN_PATH . "/views/support.php";
251
- }
252
-
253
- /**
254
- * The admin section backup page rendering method
255
- *
256
- */
257
- public function admin_test_page()
258
- {
259
- if( !current_user_can( 'manage_options' ) ) {
260
- wp_die( 'You do not have sufficient permissions to access this page' );
261
- }
262
-
263
- include WPBACKITUP__PLUGIN_PATH . "/views/test.php";
264
- }
265
-
266
- /**
267
- * Route the user based off of environment conditions
268
- *
269
- * @uses WPBackitup::_admin_options_update()
270
- */
271
- public function route() {
272
- $uri = $_SERVER['REQUEST_URI'];
273
- $protocol = isset( $_SERVER['HTTPS'] ) ? 'https' : 'http';
274
- $hostname = $_SERVER['HTTP_HOST'];
275
- $url = "{$protocol}://{$hostname}{$uri}";
276
- $is_post = (bool) ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == "POST" );
277
-
278
- // Check if a nonce was passed in the request
279
- if( isset( $_REQUEST['_wpnonce'] ) ) {
280
- $nonce = $_REQUEST['_wpnonce'];
281
-
282
- $logger = new WPBackItUp_Logger(false);
283
- //$logger->log('NONCE:' .$nonce);
284
-
285
- // Handle POST requests
286
- if( $is_post ) {
287
-
288
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
289
- $logger->log('Update Options Form Post');
290
- $this->_admin_options_update();
291
- }
292
-
293
- if( wp_verify_nonce( $nonce, "{$this->namespace}-register-lite" ) ) {
294
- $logger->log('Register Lite Form Post');
295
- $this->_admin_register_lite();
296
- }
297
-
298
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-schedule" ) ) {
299
- $logger->log('Update Schedule Form Post');
300
-
301
- $jsonResponse = new stdClass();
302
- if ($this->_admin_save_schedule()){
303
- $jsonResponse->message = 'success';
304
- }else{
305
- $jsonResponse->message = 'error';
306
- }
307
-
308
- exit(json_encode($jsonResponse));
309
-
310
- }
311
-
312
- if( wp_verify_nonce( $nonce, "{$this->namespace}-support-form" ) ) {
313
- $logger->log('Support Form Post');
314
- $this->_admin_send_support_request();
315
- }
316
-
317
- }
318
- // Handle GET requests
319
- else {
320
-
321
- }
322
- }
323
- }
324
-
325
- public function initialize(){
326
- $this->check_license();
327
- }
328
-
329
- public function wpbackitup_queue_scheduled_jobs(){
330
-
331
- // Check permissions
332
- if (! self::is_authorized()) exit('Access denied.');
333
-
334
- //Include Scheduler Class
335
- if( !class_exists( 'WPBackItUp_Scheduler' ) ) {
336
- include_once 'class-scheduler.php';
337
- }
338
-
339
- //Include Job class
340
- if( !class_exists( 'WPBackItUp_Job' ) ) {
341
- include_once 'class-job.php';
342
- }
343
-
344
-
345
- //If any jobs are queued or active then just exit
346
- if (WPBackItUp_Job::is_job_queued('backup') ||
347
- WPBackItUp_Job::is_job_queued('restore') ||
348
- WPBackItUp_Job::is_job_queued('cleanup')) {
349
- exit;
350
- }
351
-
352
-
353
- //Is it time for a backup?
354
- //Check scheduler and queue tasks that need to be run
355
- $scheduler = new WPBackItUp_Scheduler();
356
- if ( $scheduler->isTaskScheduled( 'backup' ) ) {
357
-
358
- $backup_job = WPBackItUp_Job::queue_job( 'backup' );
359
-
360
- //Setup the job run event
361
- wp_schedule_single_event( time(), 'wpbackitup_run_backup_tasks' );
362
-
363
- exit( 0 ); //success - don't schedule anything else
364
- }
365
-
366
- //Is it time for a cleanup
367
- //Check scheduler and queue tasks that need to be run
368
- if ( $scheduler->isTaskScheduled( 'cleanup' ) && !WPBackItUp_Job::is_job_queued('backup') ) {
369
-
370
- $cleanup_job = WPBackItUp_Job::queue_job( 'cleanup' );
371
-
372
- //Setup the job run event
373
- wp_schedule_single_event( time(), 'wpbackitup_run_cleanup_tasks' );
374
-
375
- exit( 0 ); //success - don't schedule anything else
376
- }
377
-
378
-
379
- exit(0); //success nothing to schedule
380
- }
381
-
382
- //Run queue manual backup
383
- public function ajax_queue_backup() {
384
- // Check permissions
385
- if (! self::is_authorized()) exit('Access denied.');
386
-
387
- $logger = new WPBackItUp_Logger(false,null,'debug_events');
388
- $logger->log_info(__METHOD__,'Begin');
389
-
390
- //Include Job class
391
- if( !class_exists( 'WPBackItUp_Job' ) ) {
392
- include_once 'class-job.php';
393
- }
394
-
395
- $rtnData = new stdClass();
396
- //If no backup queued already then queue one
397
- if (!WPBackItUp_Job::is_job_queued('backup')){
398
- if (WPBackItUp_Job::queue_job('backup')){
399
- $rtnData->message = 'Backup Queued';
400
- }else {
401
- $rtnData->message = 'Backup could not be queued';
402
- }
403
- }else{
404
- $rtnData->message = 'Backup already in queue';
405
- }
406
-
407
- $logger->log_info(__METHOD__,$rtnData->message);
408
- $logger->log_info(__METHOD__,'End');
409
- echo json_encode($rtnData);
410
- exit;
411
- }
412
-
413
- //Run queue manual restore
414
- public function ajax_queue_restore() {
415
- $rtnData = new stdClass();
416
-
417
- // Check permissions
418
- if (! self::is_authorized()) exit('Access denied.');
419
-
420
- $logger = new WPBackItUp_Logger(false,null,'debug_events');
421
- $logger->log_info(__METHOD__,'Begin');
422
-
423
- //Include Job class
424
- if( !class_exists( 'WPBackItUp_Job' ) ) {
425
- include_once 'class-job.php';
426
- }
427
-
428
- $validation_error=false;
429
- //Get posted values
430
- $backup_file_name = $_POST['selected_file'];//Get the backup file name
431
- if( empty($backup_file_name)) {
432
- $rtnData->message = 'No backup file selected.';
433
- $validation_error=true;
434
- }
435
-
436
- //Get user ID - GET ThIS FROM POST ID
437
- $user_id = $_POST['user_id'];
438
- if( empty($user_id)) {
439
- $rtnData->message = 'No user id found.';
440
- $validation_error=true;
441
- }
442
-
443
- //If no job queued already then queue one
444
- if (! $validation_error){
445
- if (! WPBackItUp_Job::is_job_queued('restore')){
446
- $job=WPBackItUp_Job::queue_job('restore');
447
- if ($job!== false){
448
- $job->update_job_meta('backup_name',$backup_file_name);
449
- $job->update_job_meta('user_id',$user_id);
450
- $rtnData->message = 'Restore Queued';
451
- }else {
452
- $rtnData->message = 'Restore could not be queued';
453
- }
454
- }else{
455
- $rtnData->message = 'Restore already in queue';
456
- }
457
- }
458
-
459
- $logger->log_info(__METHOD__,$rtnData->message);
460
- $logger->log_info(__METHOD__,'End');
461
- echo json_encode($rtnData);
462
- exit;
463
- }
464
-
465
- //Run scheduled backup tasks
466
- function wpbackitup_run_backup_tasks(){
467
-
468
- // Check permissions
469
- if (! self::is_authorized()) exit('Access denied.');
470
-
471
- $process_id = uniqid();
472
-
473
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
474
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
475
-
476
- //Try Run Next Backup Tasks
477
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run Backup Task');
478
-
479
- $this->backup_type='scheduled';
480
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_backup.php' );
481
-
482
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run Backup Task');
483
-
484
- exit(0);
485
- }
486
-
487
- //Run scheduled backup tasks
488
- function wpbackitup_run_cleanup_tasks(){
489
- // Check permissions
490
- if (! self::is_authorized()) exit('Access denied.');
491
-
492
- $process_id = uniqid();
493
-
494
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
495
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
496
-
497
- //Try Run Next Backup Tasks
498
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run cleanup Task');
499
-
500
- $this->backup_type='scheduled';
501
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_cleanup.php' );
502
-
503
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run cleanup Task');
504
-
505
- exit;
506
- }
507
-
508
-
509
- // public function ajax_get_restore_status() {
510
- // // Check permissions
511
- // if (! self::is_authorized()) exit('Access denied.');
512
- //
513
- // $log = WPBACKITUP__PLUGIN_PATH .'/logs/restore_status.log';
514
- // if(file_exists($log) ) {
515
- // readfile($log);
516
- // }
517
- // exit;
518
- // }
519
-
520
-
521
- /**
522
- * Return the backup status and try run tasks
523
- */
524
- public function ajax_get_backup_status() {
525
- // Check permissions
526
- if (! self::is_authorized()) exit('Access denied.');
527
-
528
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
529
-
530
- $event_logger->log_info(__METHOD__ ,'User Permissions: ' .current_user_can( 'manage_options' ));
531
-
532
- //Check permissions
533
- if ( current_user_can( 'manage_options' ) ) {
534
- //echo('RUNNING BACKUP');
535
-
536
- $process_id = uniqid();
537
-
538
-
539
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
540
-
541
- //Try Run Next Backup Tasks
542
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run Backup Task');
543
-
544
- $this->backup_type='manual';
545
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_backup.php' );
546
-
547
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run Backup Task');
548
-
549
- //return status
550
- $log = WPBACKITUP__PLUGIN_PATH .'/logs/backup_status.log';
551
- if(file_exists($log) ) {
552
- //Probably should use the database instead now.
553
- readfile($log);
554
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Status sent to browser.');
555
- }
556
- }
557
-
558
- exit;
559
- }
560
-
561
- /**
562
- * Return the restore status and try run tasks
563
- */
564
- public function ajax_get_restore_status() {
565
- // Check permissions
566
- if (! self::is_authorized()) exit('Access denied.');
567
-
568
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
569
-
570
- $event_logger->log_info(__METHOD__ ,'User Permissions: ' .current_user_can( 'manage_options' ));
571
-
572
- //Check permissions
573
- if ( current_user_can( 'manage_options' ) ) {
574
- //echo('RUNNING BACKUP');
575
-
576
- $process_id = uniqid();
577
-
578
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
579
-
580
- //Try Run Next Backup Tasks
581
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run restore task');
582
-
583
- $this->backup_type='manual';
584
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_restore.php' );
585
-
586
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run Backup Task');
587
-
588
- //return status
589
- $log = WPBACKITUP__PLUGIN_PATH .'/logs/restore_status.log';
590
- if(file_exists($log) ) {
591
- //Probably should use the database instead now.
592
- readfile($log);
593
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Status sent to browser.');
594
- }
595
- }
596
-
597
- exit;
598
- }
599
-
600
- public function plupload_action() {
601
- // Check permissions
602
- if (! self::is_authorized()) exit('Access denied.');
603
-
604
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/handler_upload.php' );
605
- }
606
-
607
- public function upload_dir($uploads) {
608
- $upload_path = WPBACKITUP__UPLOAD_PATH;
609
- if (is_writable($upload_path)) $uploads['path'] = $upload_path;
610
- return $uploads;
611
- }
612
-
613
- public function unique_filename_callback($dir, $name, $ext) {
614
- return $name.$ext;
615
- }
616
-
617
-
618
- public function sanitize_file_name($filename) {
619
- return $filename;
620
- }
621
-
622
-
623
- public function ajax_backup_response_reader() {
624
- // Check permissions
625
- if (! self::is_authorized()) exit('Access denied.');
626
-
627
- $log = WPBACKITUP__PLUGIN_PATH .'/logs/backup_response.log';
628
- if(file_exists($log) ) {
629
- readfile($log);
630
- }else{
631
- $rtnData = new stdClass();
632
- $rtnData->message = 'No response log found.';
633
- echo json_encode($rtnData);
634
- }
635
- exit;
636
- }
637
-
638
- public function ajax_delete_backup()
639
- {
640
- // Check permissions
641
- if (! self::is_authorized()) exit('Access denied.');
642
-
643
- $logger = new WPBackItUp_Logger(true,null,'debug_delete');
644
-
645
- $backup_folder_name = str_replace('deleteRow', '', $_POST['filed']);
646
-
647
- $backup_folder_path = WPBACKITUP__BACKUP_PATH .'/' . $backup_folder_name;
648
- $DLT_backup_folder_path = WPBACKITUP__BACKUP_PATH .'/DLT_' . $backup_folder_name .'_' . current_time( 'timestamp' );;
649
-
650
- $logger->log_info(__METHOD__,'From:'.$backup_folder_path );
651
- $logger->log_info(__METHOD__,'To:'.$DLT_backup_folder_path );
652
-
653
- //Mark the folder deleted so cleanup will handle
654
- if (file_exists ($backup_folder_path)){
655
-
656
- if( !class_exists( 'WPBackItUp_FileSystem' ) ) {
657
- include_once 'class-filesystem.php';
658
- }
659
-
660
- $file_system = new WPBackItUp_FileSystem($logger);
661
- if (! $file_system->rename_file($backup_folder_path,$DLT_backup_folder_path)){
662
- $logger->log_error(__METHOD__,'Folder was not renamed');
663
- exit('Backup NOT deleted');
664
- }
665
- }else{
666
- $logger->log_error(__METHOD__,'Folder not found:'. $backup_folder_path);
667
- }
668
-
669
- exit('deleted');
670
- }
671
-
672
- function admin_viewlog(){
673
- if (! self::is_authorized()) exit('Access denied.');
674
-
675
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/handler_viewlog.php' );
676
- }
677
-
678
- function admin_download_backup(){
679
- if (! self::is_authorized()) exit('Access denied.');
680
-
681
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/handler_download.php' );
682
- }
683
-
684
- /**
685
- * Process update page form submissions and validate license key
686
- *
687
- */
688
- public function _admin_options_update() {
689
- // Verify submission for processing using wp_nonce
690
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
691
-
692
- /**
693
- * Loop through each POSTed value and sanitize it to protect against malicious code. Please
694
- * note that rich text (or full HTML fields) should not be processed by this function and
695
- * dealt with directly.
696
- */
697
-
698
- $logger = new WPBackItUp_Logger(false);
699
- $logger->log("Posted Fields");
700
- $logger->log($_POST['data']); //License will not be in this array
701
-
702
- foreach( $_POST['data'] as $key => $val ) {
703
- $posted_value = $this->_sanitize($val);
704
- //If license updated then validate
705
- if (!empty($key) && $key=='license_key') {
706
- $logger->log('License Posted:' .$posted_value);
707
- $this->update_license_options($posted_value);
708
- }
709
- else {
710
- $data[$key] =$posted_value;
711
- }
712
- }
713
-
714
- $license_description = $this->license_type_description();
715
-
716
- //Could have just been a license update
717
- if(!empty($data)) {
718
-
719
-
720
- //** VALIDATE backup_retained_number **//
721
- //Set back to original settings if value not changed
722
- if(!empty($data['backup_retained_number']) && !is_numeric($data['backup_retained_number']))
723
- {
724
- $data['backup_retained_number'] = $this->defaults['backup_retained_number'];
725
- set_transient('settings-error-number', __('Please enter a number', $this->namespace), 60);
726
-
727
- }
728
- else{ //Empty OR not NUMERIC
729
-
730
- //Empty
731
- if ( empty($data['backup_retained_number']) ){
732
- $data['backup_retained_number'] = $this->defaults['backup_retained_number'];
733
- set_transient('settings-error-number', __('Please enter a number', $this->namespace), 60);
734
- }
735
-
736
- //exceeds lite threshold
737
- if ( !empty($data['backup_retained_number']) && ($this->license_type()==0) && ($data['backup_retained_number'] > 1) ){
738
- $data['backup_retained_number'] = $this->defaults['lite_backup_retained_number'];
739
- set_transient('settings-license-error', __(ucfirst($license_description) .' license holders may only save 1 backup archive.', $this->namespace), 60);
740
- }
741
-
742
- //exceeds pro threshold
743
- if (!empty($data['backup_retained_number']) && ($this->license_type()==1) && ($data['backup_retained_number'] > 3)){
744
- $data['backup_retained_number'] = $this->defaults['backup_retained_number'];
745
- set_transient('settings-license-error', __(ucfirst($license_description) .' license holders may only save up to 3 backup archives.', $this->namespace), 60);
746
- }
747
-
748
- }
749
-
750
- //** VALIDATE notification_email **//
751
- if(!empty($data['notification_email']) && !is_email($data['notification_email']))
752
- {
753
- $data['notification_email'] = $this->defaults['notification_email'];
754
- set_transient('settings-error-email', __('Please enter a a valid email', $this->namespace), 60);
755
- }
756
-
757
-
758
- //** VALIDATE backup_batch_size **//
759
- if(empty($data['backup_batch_size']) || !is_numeric($data['backup_batch_size']))
760
- {
761
- $data['backup_batch_size'] = $this->defaults['backup_batch_size'];
762
- set_transient('batch_size_settings-error-number', __('Please enter a number', $this->namespace), 60);
763
- }
764
-
765
-
766
- // Update the options value with the data submitted
767
- foreach( $data as $key => $val ) {
768
- $this->set_option($key, $val);
769
- $logger->log('Updated Option: ' .$key .':' .$val);
770
- }
771
- }
772
-
773
- // Redirect back to the options page with the message flag to show the saved message
774
- wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
775
- exit;
776
- }
777
- }
778
-
779
- /**
780
- * Save Schedule
781
- *
782
- */
783
- public function _admin_save_schedule() {
784
- // Verify submission for processing using wp_nonce
785
- $logger = new WPBackItUp_Logger(false);
786
-
787
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-schedule" ) ) {
788
-
789
- $logger->log("Save Schedule");
790
- $logger->log($_POST);
791
-
792
- $val = $_POST['days_selected'];
793
- $days_selected = $this->_sanitize($val);
794
- $logger->log('Days Selected:' . $days_selected);
795
-
796
- //save option to DB even if empty
797
- $this->set_backup_schedule($days_selected);
798
-
799
- //Add backup scheduled if doesnt exist
800
- if(!wp_next_scheduled( 'wpbackitup_queue_scheduled_jobs' ) ){
801
- wp_schedule_event( time()+3600, 'hourly', 'wpbackitup_queue_scheduled_jobs');
802
- }
803
-
804
- return true;
805
- }
806
-
807
- return false;
808
- }
809
-
810
- /**
811
- * Send support request Schedule
812
- *
813
- */
814
- public function _admin_send_support_request() {
815
- // Verify submission for processing using wp_nonce
816
-
817
- $url= str_replace('&s=1','',$_REQUEST['_wp_http_referer']);
818
- $logger = new WPBackItUp_Logger(true,null,'debug_support');
819
- $logger->log_sysinfo();
820
- $logger->log_info(__METHOD__,'Send Support Request');
821
-
822
- $error=false;
823
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-support-form" ) ) {
824
-
825
- $logger->log_info(__METHOD__,"Send support request");
826
- $logger->log_info(__METHOD__,$_POST);
827
-
828
- //save the email in place of transient
829
- $this->set_support_email($_POST['support_email']);
830
-
831
- // save the transients in case of error
832
- foreach( $_POST as $key => $val ){
833
- set_transient($key, __($val, $this->namespace), 60);
834
- }
835
-
836
- //validate form fields
837
- if(empty($_POST['support_email']) || !is_email($_POST['support_email']))
838
- {
839
- $error=true;
840
- set_transient('error-support-email', __('Please enter a valid email', $this->namespace), 60);
841
- }
842
-
843
- if(empty($_POST['support_subject']))
844
- {
845
- $error=true;
846
- set_transient('error-support-subject', __('Please enter a short description of your problem', $this->namespace), 60);
847
- }
848
-
849
- if(empty($_POST['support_body']))
850
- {
851
- $error=true;
852
- set_transient('error-support-body', __('Please enter your problem description', $this->namespace), 60);
853
- }
854
-
855
- $include_logs=false;
856
- if(!empty($_POST['support_include_logs']))
857
- {
858
- $include_logs=true;
859
- }
860
-
861
- //Send if no errors
862
- if (!$error){
863
-
864
- if( !class_exists( 'WPBackItUp_Zip' ) ) {
865
- include_once 'class-zip.php';
866
- }
867
-
868
- if( !class_exists( 'WPBackItUp_Utility' ) ) {
869
- include_once 'class-utility.php';
870
- }
871
-
872
- $support_request_id=time();
873
- $logs_attachment = array(); //default to no logs
874
- if ($include_logs){
875
- $logs_path = WPBACKITUP__PLUGIN_PATH .'logs';
876
-
877
- //copy/replace WP debug file
878
- $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
879
- $logger->log_info(__METHOD__,"Copy WP Debug: " .$wpdebug_file_path);
880
- if (file_exists($wpdebug_file_path)) {
881
- copy( $wpdebug_file_path, $logs_path .'/wpdebug.log' );
882
- }
883
-
884
-
885
- $zip_file_path = $logs_path . '/logs_' . $support_request_id . '.zip';
886
- $zip = new WPBackItUp_Zip($logger,$zip_file_path);
887
- $zip->zip_files_in_folder($logs_path,$support_request_id,'*.log');
888
- $zip->close();
889
-
890
- $logs_attachment = array( $zip_file_path );
891
-
892
- }
893
-
894
- $utility = new WPBackItUp_Utility($logger);
895
- $support_to_address = WPBACKITUP__SUPPORT_EMAIL;
896
- $support_from_email=$_POST['support_email'];
897
- $support_subject = 'Support Request (' .$support_request_id .'): ' .$_POST['support_subject'];
898
-
899
-
900
- $site_info = 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
901
- $site_info .="WP BackItUp License Type: " . $this->license_type_description() .' <br />';
902
-
903
- $support_body=$site_info . '<br/><br/>' . $_POST['support_body'];
904
-
905
-
906
- $utility->send_email($support_to_address,$support_subject,$support_body,$logs_attachment,$support_from_email);
907
-
908
- // get rid of the transients
909
- foreach( $_POST as $key => $val ){
910
- delete_transient($key);
911
- }
912
-
913
- wp_safe_redirect($url . '&s=1');
914
- exit;
915
- }
916
- }
917
-
918
- wp_safe_redirect($url);
919
- exit;
920
-
921
- }
922
-
923
- /**
924
- * Process registration page form submissions
925
- *
926
- */
927
- public function _admin_register_lite() {
928
- // Verify submission for processing using wp_nonce
929
- if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-register-lite" ) ) {
930
-
931
- /**
932
- * Loop through each POSTed value and sanitize it to protect against malicious code. Please
933
- * note that rich text (or full HTML fields) should not be processed by this function and
934
- * dealt with directly.
935
- */
936
-
937
- $logger = new WPBackItUp_Logger(false,null,'debug_lite_registration');
938
- $logger->log("Register WP BackItUp Lite");
939
- $logger->log($_POST);
940
-
941
- $val = $_POST['email'];
942
- $email = $this->_sanitize($val);
943
- if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)){
944
- $urlparts = parse_url(site_url());
945
- $domain = $urlparts['host'];
946
-
947
- $first_name=$_POST['first_name'];
948
-
949
- //save options to DB
950
- $this->set_option('lite_registration_email', $email);
951
- if(!empty($first_name)){
952
- $this->set_option('lite_registration_first_name', $first_name);
953
- }
954
-
955
- $form_data = array(
956
- 'email' => $email,
957
- 'site' => $domain,
958
- 'first_name' => $first_name,
959
- 'time_zone'=> get_option('timezone_string'),
960
- );
961
-
962
- $url = WPBACKITUP__SECURESITE_URL; //PRD
963
- $post_url=$url . '/api/wpbackitup/register_lite';
964
-
965
- $logger->log('Lite User Registration Post URL: ' .$post_url);
966
- $logger->log('Lite User Registration Post Form Data: ' );
967
- $logger->log($form_data);
968
-
969
- $response = wp_remote_post( $post_url, array(
970
- 'method' => 'POST',
971
- 'timeout' => 45,
972
- 'blocking' => true,
973
- 'headers' => array(),
974
- 'body' => $form_data,
975
- 'cookies' => array()
976
- )
977
- );
978
-
979
- if ( is_wp_error( $response ) ) {
980
- $error_message = $response->get_error_message();
981
- $logger->log('Lite User Registration Error: ' .$error_message);
982
- } else {
983
- $logger->log('Lite User Registered Successfully:');
984
- $logger->log($response);
985
- }
986
-
987
- }
988
-
989
- // Redirect back to the options page with the message flag to show the saved message
990
- wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
991
- exit;
992
- }
993
- }
994
-
995
- /**
996
- * Hook into plugin_action_links filter
997
- *
998
- * @param object $links An array of the links to show, this will be the modified variable
999
- * @param string $file The name of the file being processed in the filter
1000
- *
1001
- */
1002
- public function plugin_action_links( $links, $file ) {
1003
-
1004
- // Add links to plugin
1005
- if ( $file == plugin_basename( WPBACKITUP__PLUGIN_PATH . '/wp-backitup.php' ) ) {
1006
- $settings_link = '<a href="' . esc_url( self::get_settings_page_url() ) . '">'.esc_html__( 'Settings' , 'wp-backitup').'</a>';
1007
- array_unshift($links, $settings_link);
1008
- }
1009
-
1010
- return $links;
1011
- }
1012
-
1013
- /**
1014
- *
1015
- * GETTERS
1016
- *
1017
- **/
1018
-
1019
- /**
1020
- * Generic Getter
1021
- */
1022
- public function get($property) {
1023
-
1024
- if (empty($this->$property)) {
1025
- $this->$property = $this->get_option($property);
1026
-
1027
- //If not set then use the defaults
1028
- if (empty($this->$property)) {
1029
- $this->$property=$this->defaults[$property];
1030
- }
1031
- }
1032
-
1033
- return $this->$property;
1034
-
1035
- }
1036
-
1037
-
1038
- /**
1039
- * Getter - license key
1040
- */
1041
- public function license_key(){
1042
- return $this->get('license_key');
1043
- }
1044
-
1045
- /**
1046
- * Getter - license status message
1047
- */
1048
- public function license_status_message(){
1049
- return $this->get('license_status_message');
1050
- }
1051
-
1052
- /**
1053
- * Getter - license expires
1054
- */
1055
- public function license_expires(){
1056
- return $this->get('license_expires');
1057
- }
1058
-
1059
- /**
1060
- * Getter - notification email
1061
- */
1062
- public function notification_email(){
1063
- return $this->get('notification_email');
1064
- }
1065
-
1066
- /**
1067
- * Getter - logging
1068
- */
1069
- public function logging(){
1070
- $logging = $this->get('logging');
1071
- return $logging === 'true'? true: false;
1072
- }
1073
-
1074
- public function backup_schedule(){
1075
- return $this->get('backup_schedule');
1076
- }
1077
-
1078
- public function backup_lastrun_date(){
1079
- return $this->get('backup_lastrun_date');
1080
- }
1081
-
1082
- public function cleanup_lastrun_date(){
1083
- return $this->get('cleanup_lastrun_date');
1084
- }
1085
-
1086
- public function backup_batch_size(){
1087
- return $this->get('backup_batch_size');
1088
- }
1089
-
1090
-
1091
-
1092
- /**
1093
- * Getter - license active - derived property
1094
- */
1095
- public function license_active(){
1096
- //echo('</br>license Active Value1:' .$this->license_active);
1097
-
1098
- if (empty($this->license_active)) {
1099
- //echo('</br>SET PROP');
1100
-
1101
- $this->license_active = false;//default
1102
-
1103
- $license_key = $this->license_key();
1104
- $license_status = $this->license_status();
1105
-
1106
- //Allow expired licenses to be active for now
1107
- if(false !== $license_key && false !== $license_status) {
1108
- if ('valid'== $license_status || 'expired'== $license_status) {
1109
- $this->license_active= true;
1110
- }
1111
- }
1112
- }
1113
-
1114
- //echo('</br>license Active Value2:' .$this->license_active);
1115
- return $this->license_active;
1116
- }
1117
-
1118
- /**
1119
- * Getter - license status
1120
- */
1121
- public function license_status(){
1122
- return $this->get('license_status');
1123
- }
1124
-
1125
-
1126
- /**
1127
- * Getter: Get license type or default
1128
- */
1129
- public function license_type(){
1130
- return $this->get('license_type');
1131
- }
1132
-
1133
- /**
1134
- * Getter - license type description - derived property
1135
- */
1136
- public function license_type_description(){
1137
-
1138
- if (empty($this->license_type_description)) {
1139
-
1140
- switch ($this->license_type()) {
1141
- case 0:
1142
- $this->license_type_description = 'lite';
1143
- break;
1144
- case 1:
1145
- $this->license_type_description = 'personal';
1146
- break;
1147
-
1148
- case 2:
1149
- $this->license_type_description = 'business';
1150
- break;
1151
-
1152
- case 3:
1153
- $this->license_type_description = 'professional';
1154
- break;
1155
- }
1156
- }
1157
-
1158
- return $this->license_type_description;
1159
- }
1160
-
1161
- /**
1162
- * Getter - backup retained number - derived property
1163
- */
1164
- public function backup_retained_number(){
1165
- if (empty($this->backup_retained_number)) {
1166
- $this->backup_retained_number = $this->get_option('backup_retained_number');
1167
-
1168
- //If not set then use the defaults
1169
- if (empty($this->backup_retained_number)) {
1170
-
1171
- switch ($this->license_type()) {
1172
- case 0: //Lite
1173
- $this->backup_retained_number=1;
1174
- break;
1175
- case 1: //Personal
1176
- $this->backup_retained_number=3;
1177
- break;
1178
-
1179
- case 2: //Business
1180
- $this->backup_retained_number=3;
1181
- break;
1182
-
1183
- case 3: //Pro
1184
- $this->backup_retained_number=3;
1185
- break;
1186
- }
1187
-
1188
- $this->set_option('backup_retained_number',$this->backup_retained_number);
1189
- }
1190
-
1191
- }
1192
-
1193
- return $this->backup_retained_number;
1194
-
1195
- }
1196
-
1197
- function backup_count(){
1198
- return $this->get('backup_count');
1199
- }
1200
-
1201
- function successful_backup_count(){
1202
- return $this->get('successful_backup_count');
1203
- }
1204
-
1205
- function lite_registration_email(){
1206
- return $this->get('lite_registration_email');
1207
- }
1208
-
1209
- function lite_registration_first_name(){
1210
- return $this->get('lite_registration_first_name');
1211
- }
1212
-
1213
- function is_lite_registered(){
1214
- $lite_email_registration= $this->lite_registration_email();
1215
- if (!empty($lite_email_registration)) {
1216
- return true;
1217
- } else {
1218
- return false;
1219
- }
1220
-
1221
- }
1222
-
1223
- public function support_email(){
1224
- return $this->get('support_email');
1225
- }
1226
-
1227
- public function get_backup_list(){
1228
-
1229
- // get retention number set
1230
- $number_retained_archives = $this->backup_retained_number();
1231
-
1232
- //Make sure backup folder exists
1233
- $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
1234
-
1235
- //Create the backup list
1236
- $folder_list = glob($backup_dir . "/*",GLOB_ONLYDIR);
1237
- $backup_list=array();
1238
- $i=0;
1239
- if (count($folder_list)>0) {
1240
- foreach($folder_list as $folder) {
1241
- $backup_name = basename($folder);
1242
- $backup_prefix = substr($backup_name,0,4);
1243
-
1244
- //Dont include incomplete backups or deleted folders
1245
- if ( $backup_prefix!='TMP_' &&
1246
- $backup_prefix!='DLT_' ) {
1247
-
1248
- $i++;
1249
- if( $number_retained_archives && $i> $number_retained_archives ) break;
1250
-
1251
- $logs = glob($folder . "/*.log");
1252
- $log_exists=false;
1253
- if (count($logs)>0){
1254
- $log_exists=true;
1255
- }
1256
-
1257
- //Only get the files with the backup prefix.
1258
- $zip_files = glob($folder . "/" .$backup_name ."*.zip");
1259
-
1260
- array_push($backup_list,
1261
- array(
1262
- "backup_name" => $backup_name,
1263
- "log_exists"=>$log_exists,
1264
- "date_time" => filectime($folder),
1265
- "zip_files"=>$zip_files,
1266
- ));
1267
-
1268
- // $backup_list[] = [
1269
- // "backup_name" => $backup_name,
1270
- // "log_exists"=>$log_exists,
1271
- // "date_time" => filectime($folder),
1272
- // "zip_files"=>$zip_files,
1273
- // ];
1274
- }
1275
- }
1276
- //sort the list by date
1277
- usort($backup_list, create_function('$a,$b', 'return $b["date_time"] - $a["date_time"];'));
1278
-
1279
- return $backup_list;
1280
- }
1281
-
1282
- return false;
1283
- }
1284
-
1285
- /**---------- END GETTERS --------------- **/
1286
-
1287
- /**---------- SETTERS --------------- **/
1288
-
1289
- /**
1290
- * Generic Setter
1291
- */
1292
- private function set($property,$value) {
1293
-
1294
- $this->set_option($property, $value);
1295
- $this->$property = $value;
1296
-
1297
- //If not set then use the defaults
1298
- if (empty($this->$property)) {
1299
- $this->$property=$this->defaults[$property];
1300
- }
1301
-
1302
- }
1303
-
1304
- function set_backup_count($value){
1305
- $this->set('backup_count', $value);
1306
- }
1307
-
1308
- function set_successful_backup_count($value){
1309
- $this->set('successful_backup_count', $value);
1310
- }
1311
-
1312
- public function set_backup_schedule($value){
1313
- $this->set('backup_schedule', $value);
1314
- }
1315
-
1316
- public function set_backup_lastrun_date($value){
1317
- $this->set('backup_lastrun_date', $value);
1318
- }
1319
-
1320
- public function set_cleanup_lastrun_date($value){
1321
- $this->set('cleanup_lastrun_date', $value);
1322
- }
1323
-
1324
- public function set_backup_batch_size($value){
1325
- $this->set('backup_batch_size', $value);
1326
- }
1327
-
1328
- function set_support_email($value){
1329
- $this->set('support_email', $value);
1330
- }
1331
- /**---------- END SETTERS --------------- **/
1332
-
1333
-
1334
- /**-------------- LICENSE FUNCTIONS ---------------**/
1335
-
1336
- /**
1337
- * Validate License Info Once per day
1338
- */
1339
- public function check_license(){
1340
- $license_key=$this->license_key();
1341
- //echo "</br>License Key:" .$license_key;
1342
-
1343
- $license_last_check_date=$this->get_option('license_last_check_date');
1344
-
1345
- //Validate License once per day
1346
- $license_last_check_date = new DateTime($license_last_check_date);
1347
- //echo($license_last_check_date->format('Y-m-d H:i:s') .'</br>');
1348
-
1349
- $now = new DateTime('now');//Get NOW
1350
- $yesterday = $now->modify('-1 day');//subtract a day
1351
- //$yesterday = $now->sub(new DateInterval('P1D'));//subtract a day PHP 3.0 only
1352
- //echo($yesterday->format('Y-m-d H:i:s') .'</br>');
1353
-
1354
- //Validate License
1355
- if ($license_last_check_date<$yesterday)
1356
- {
1357
- //echo "Validate License";
1358
- $this->update_license_options($license_key);
1359
- //$this->update_stats($license_key);
1360
- }
1361
- }
1362
-
1363
- /**
1364
- * Update ALL the license options
1365
- */
1366
- private function update_license_options($license)
1367
- {
1368
- $logger = new WPBackItUp_Logger(false);
1369
- $logger->log('Update License Options:' .$license);
1370
-
1371
- $license=trim($license);
1372
-
1373
- //Load the defaults
1374
- $data['license_key'] = $this->defaults['license_key'];
1375
- $dt = new DateTime('now');
1376
- $data['license_last_check_date'] = $dt->format('Y-m-d H:i:s');
1377
-
1378
- $data['license_status'] = $this->defaults['license_status'];
1379
- $data['license_status_message']= $this->defaults['license_status_message'];
1380
- $data['license_expires']= $this->defaults['license_expires'];
1381
- $data['license_limit']= $this->defaults['license_limit'];
1382
- $data['license_sitecount']= $this->defaults['license_sitecount'];
1383
- $data['license_type']= $this->defaults['license_type'];
1384
-
1385
- //If no value then default to lite
1386
- if (empty($license) || 'lite'== $license ){
1387
- $data['license_status'] = 'free';
1388
- $data['license_expires']= $this->defaults['license_expires'];
1389
- $data['license_limit']= 1;
1390
- $data['license_sitecount']= 1;
1391
- $data['license_type']= 0;
1392
- } else {
1393
- //CALL EDD_ACTIVATE_LICENSE to get activation information
1394
- $api_params = array(
1395
- 'edd_action'=> 'activate_license',
1396
- 'license' => $license,
1397
- 'item_name' => urlencode( WPBACKITUP__ITEM_NAME ), // the name of product in EDD
1398
- //'url' => home_url()
1399
- );
1400
-
1401
- $logger->log('Activate License Request Info:');
1402
- $logger->log($api_params);
1403
-
1404
- $response = wp_remote_get(
1405
- add_query_arg( $api_params, WPBACKITUP__SECURESITE_URL ),
1406
- array(
1407
- 'timeout' => 15,
1408
- 'sslverify' => false
1409
- )
1410
- );
1411
- $logger->log('Validation Response:');
1412
- $logger->log($response);
1413
-
1414
- if ( is_wp_error( $response ) ){
1415
- $logger->log_error(__METHOD__,$response->get_error_message());
1416
- return false; //Exit and don't update
1417
- }else{
1418
- $logger->log_info(__METHOD__,'No request errors.');
1419
- }
1420
-
1421
- $license_data = json_decode( wp_remote_retrieve_body( $response ) );
1422
- $logger->log('License Object Info');
1423
- $logger->log($license_data);
1424
-
1425
- $data['license_key'] = $license;
1426
- $data['license_status'] = $license_data->license;
1427
- $data['license_limit'] = $license_data->license_limit;
1428
- $data['license_sitecount'] = $license_data->site_count;
1429
- $data['license_expires'] = $license_data->expires;
1430
-
1431
- //This is how we determine the type of license because
1432
- //there is no difference in EDD
1433
- if (is_numeric($license_data->license_limit)){
1434
-
1435
- //Personal
1436
- if ($license_data->license_limit<5) {
1437
- $data['license_type'] = 1;
1438
- }
1439
-
1440
- //Business
1441
- if ($license_data->license_limit>=5 && $license_data->license_limit<20) {
1442
- $data['license_type'] = 2;
1443
- }
1444
-
1445
- //Professional
1446
- if ($license_data->license_limit>=20) {
1447
- $data['license_type'] = 3;
1448
- }
1449
-
1450
- //EDD sends back expired in the error
1451
- if (($license_data->license=='invalid') && ($license_data->error=='expired')){
1452
-
1453
- //Default to valid for now
1454
- $data['license_status'] ='valid';
1455
- $data['license_status_message'] ='';
1456
-
1457
- //Only expire license in current month
1458
- $license_expire_date = $license_data->expires;
1459
- $expire_date_array = date_parse($license_expire_date);
1460
- $logger->log('Expire Date Array');
1461
- $logger->log($expire_date_array);
1462
- $logger->log('Expire Month: ' .$expire_date_array[month]);
1463
- $logger->log('Current Month: ' .date('m'));
1464
-
1465
- //only EXPIRE current month
1466
- //if ($expire_date_array[month]==date('m')) {
1467
- $data['license_status'] ='expired';
1468
- $data['license_status_message'] ='License has expired.';
1469
- $logger->log('Expire License.');
1470
- //}
1471
- }
1472
-
1473
- if (($license_data->license=='invalid') && ($license_data->error=='no_activations_left')){
1474
- $data['license_status_message'] ='Activation limit has been reached.';
1475
- }
1476
- }
1477
- }
1478
-
1479
- $logger->log('Updating License Options');
1480
- foreach($data as $key => $val ) {
1481
- $this->set_option($key, $val);
1482
- $logger->log('Updated Option: ' .$key .':' .$val);
1483
- }
1484
- return true;
1485
- }
1486
-
1487
- /**-------------- END LICENSE FUNCTIONS ---------------**/
1488
-
1489
- /**
1490
- * Retrieve the stored plugin option or the default if no user specified value is defined
1491
- *
1492
- * @param string $option_name
1493
- *
1494
- * @uses get_option()
1495
- *
1496
- * @return mixed Returns the option value or false(boolean) if the option is not found
1497
- */
1498
- public function get_option( $option_name ) {
1499
- // Load option values if they haven't been loaded already
1500
- $wp_option_name = $this->namespace .'_' .$option_name;
1501
-
1502
- //Use this after migration
1503
- //$option_value = get_option($wp_option_name,$this->defaults[$option_name]);
1504
-
1505
- $option_value = get_option($wp_option_name);
1506
-
1507
- //return the value
1508
- if(isset( $option_value ) && !empty( $option_value )) return $option_value;
1509
-
1510
- //Should only happen once
1511
- //Can take this out in next release
1512
- //If looking for license then migrate the old settings
1513
- if ('license_key'==$option_name) {
1514
- $options = get_option('_' . $this->namespace . '--options');
1515
- $license = $options[$option_name];
1516
- if( isset( $license ) || !empty( $license ) ) {
1517
- //migrate to new option setting
1518
- $this->set_option($option_name, $license);
1519
- $this->update_license_options($license);
1520
-
1521
- //Delete the old options
1522
- delete_option('_' . $this->namespace . '--options');
1523
-
1524
- return $license;
1525
- }
1526
-
1527
- }
1528
- //Return the default
1529
- return $this->defaults[$option_name];
1530
- }
1531
-
1532
- //Prefix options with namespace & save
1533
- public function set_option($option_name, $value) {
1534
- $option_name = $this->namespace .'_' .$option_name;
1535
- update_option($option_name,$value);
1536
-
1537
- //Check class variables
1538
- if($option_name=='license_type')
1539
- $this->license_type= $value;
1540
- }
1541
-
1542
- public function increment_backup_count(){
1543
- $backup_count = $this->backup_count();
1544
- $backup_count=$backup_count+1;
1545
- $this->set_backup_count($backup_count);
1546
- }
1547
-
1548
- public function increment_successful_backup_count(){
1549
- $successful_backup_count = $this->successful_backup_count();
1550
- $successful_backup_count=$successful_backup_count+1;
1551
- $this->set_successful_backup_count($successful_backup_count);
1552
- }
1553
-
1554
- /**
1555
- * Sanitize data
1556
- *
1557
- * @param mixed $str The data to be sanitized
1558
- *
1559
- * @uses wp_kses()
1560
- *
1561
- * @return mixed The sanitized version of the data
1562
- */
1563
- private function _sanitize( $str ) {
1564
- if ( !function_exists( 'wp_kses' ) ) {
1565
- include_once ABSPATH . 'wp-includes/kses.php';
1566
- }
1567
- global $allowedposttags;
1568
- global $allowedprotocols;
1569
-
1570
- if ( is_string( $str ) ) {
1571
- $str = wp_kses( $str, $allowedposttags, $allowedprotocols );
1572
- } elseif( is_array( $str ) ) {
1573
- $arr = array();
1574
- foreach( (array) $str as $key => $val ) {
1575
- $arr[$key] = $this->_sanitize( $val );
1576
- }
1577
- $str = $arr;
1578
- }
1579
-
1580
- return $str;
1581
- }
1582
-
1583
- /**STATIC FUNCTIONS**/
1584
-
1585
- public static function is_authorized(){
1586
-
1587
- $permission_logger = new WPBackItUp_Logger(false,null,'debug_permissions');
1588
- $permission_logger->log_info(__METHOD__ ,'Begin');
1589
-
1590
- $permission_logger->log_info(__METHOD__ ,'User Permissions: ' .current_user_can( 'manage_options' ));
1591
-
1592
- if (defined('DOING_CRON')) {
1593
- $permission_logger->log_info( __METHOD__, 'Doing CRON Constant: ' . DOING_CRON );
1594
- } else {
1595
- $permission_logger->log_info(__METHOD__ ,'DOING_CRON - NOT defined');
1596
- }
1597
-
1598
- if (defined('XMLRPC_REQUEST')) {
1599
- $permission_logger->log_info(__METHOD__ ,'XMLRPC_REQUEST Constant: ' .XMLRPC_REQUEST );
1600
- } else {
1601
- $permission_logger->log_info(__METHOD__ ,'XMLRPC_REQUEST - NOT defined ');
1602
- }
1603
-
1604
- //Check User Permissions or CRON
1605
- if (!current_user_can( 'manage_options' )
1606
- && (!defined('DOING_CRON') || !DOING_CRON)){
1607
- $permission_logger->log_info(__METHOD__ ,'End - NOT AUTHORIZED');
1608
- return false;
1609
- }
1610
-
1611
- $permission_logger->log_info(__METHOD__ ,'End - SUCCESS');
1612
- return true;
1613
- }
1614
-
1615
- private static function get_settings_page_url( $page = 'config' ) {
1616
-
1617
- $args = array( 'page' => 'wp-backitup-settings' );
1618
- $url = add_query_arg( $args, admin_url( 'admin.php' ));
1619
-
1620
- return $url;
1621
- }
1622
-
1623
-
1624
- /**
1625
- * Activation action
1626
- */
1627
- public static function activate() {
1628
- try{
1629
- //Get rid of old job
1630
- wp_clear_scheduled_hook('wpbackitup_check_scheduled_tasks');
1631
-
1632
- //add cron task for once per hour starting in 1 hour
1633
- if(!wp_next_scheduled( 'wpbackitup_queue_scheduled_jobs' ) ){
1634
- wp_schedule_event( time()+3600, 'hourly', 'wpbackitup_queue_scheduled_jobs');
1635
- }
1636
-
1637
- require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-filesystem.php' );
1638
- $file_system = new WPBackItUp_FileSystem();
1639
-
1640
- //Check backup folder folders
1641
- $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
1642
- $file_system->secure_folder( $backup_dir);
1643
-
1644
-
1645
- //--Check restore folder folders
1646
- $restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER;
1647
- $file_system->secure_folder( $restore_dir);
1648
-
1649
- $logs_dir = WPBACKITUP__PLUGIN_PATH .'/logs/';
1650
- $file_system->secure_folder( $logs_dir);
1651
-
1652
- //Make sure they exist now
1653
- if( !is_dir($backup_dir) || !is_dir($restore_dir)) {
1654
- exit ('WP BackItUp was not able to create the required backup and restore folders.');
1655
- }
1656
-
1657
- //Need to reset the batch size for this release
1658
- $batch_size = get_option('wp-backitup_backup_batch_size');
1659
- if ($batch_size<100){
1660
- delete_option('wp-backitup_backup_batch_size');
1661
- }
1662
-
1663
- } catch (Exception $e) {
1664
- exit ('WP BackItUp encountered an error during activation.</br>' .$e->getMessage());
1665
- }
1666
- }
1667
-
1668
- /**
1669
- * Deactivation action
1670
- */
1671
- public static function deactivate() {
1672
- // Do deactivation actions
1673
-
1674
- wp_clear_scheduled_hook( 'wpbackitup_queue_scheduled_jobs');
1675
- }
1676
-
1677
- /* --------------------- PRIVATES -----------------------------------------*/
1678
-
1679
- /**
1680
- * Update statistics
1681
- */
1682
- private function update_stats($license)
1683
- {
1684
- $logger = new WPBackItUp_Logger(true);
1685
- $logger->log('Update Stats:' .$license);
1686
-
1687
- $license=trim($license);
1688
-
1689
- //Get stats here
1690
-
1691
- //Setup API call
1692
- $api_params = array(
1693
- 'wpb_action'=> 'update_stats',
1694
- 'license' => $license
1695
- );
1696
-
1697
- $url = WPBACKITUP__SECURESITE_URL .'/stats-update-test';
1698
- $response = wp_remote_get( add_query_arg( $api_params, $url ), array( 'timeout' => 15, 'sslverify' => true ) );
1699
- $logger->log('Stats Response:');
1700
- $logger->log($response);
1701
-
1702
- if ( is_wp_error( $response ) )
1703
- return false; //Exit and don't update
1704
-
1705
- //$license_data = json_decode( wp_remote_retrieve_body( $response ) );
1706
-
1707
- return true;
1708
- }
1709
-
1710
- //Pretty= Pretty version of anchor
1711
- //Page = page to link to
1712
- //content = Widget Name(where)
1713
- //term = pinpoint where in widget
1714
- function get_anchor_with_utm($pretty, $page, $content = null, $term = null){
1715
-
1716
- $medium='plugin'; //Campaign Medium
1717
- $source=$this->namespace; //plugin name
1718
-
1719
- $campaign='lite';
1720
- if ($this->license_active()) $campaign='premium';
1721
-
1722
- $utm_url = WPBACKITUP__SITE_URL .'/' .$page .'/?utm_medium=' .$medium . '&utm_source=' .$source .'&utm_campaign=' .$campaign;
1723
-
1724
- if (!empty($content)){
1725
- $utm_url .= '&utm_content=' .$content;
1726
- }
1727
-
1728
- if (!empty($term)){
1729
- $utm_url .= '&utm_term=' .$term;
1730
- }
1731
-
1732
- $anchor = '<a href="'.$utm_url .'" target="_blank">' .$pretty .'</a>';
1733
- return $anchor;
1734
-
1735
- }
1736
-
1737
- /* --------------------- END PRIVATES -----------------------------------------*/
1738
-
1739
-
1740
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/class-zip.php DELETED
@@ -1 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
  * WP Backitup Zip Function
3
  *
4
  * @package WP Backitup
5
  *
6
  * @author cssimmon
7
  *
8
  */
9
  private $zip_file_count;
10
  $this->zip_file_count=0;
11
  }
 
0
  * WP Backitup Zip Function
1
  *
2
  * @package WP Backitup
3
  *
4
  * @author cssimmon
5
  *
6
  */
7
  private $zip_file_count;
8
  $this->zip_file_count=0;
9
  }
tags/1.10.0/lib/includes/handler_download.php DELETED
@@ -1,100 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (viewlog)');
2
- @set_time_limit(WPBACKITUP__SCRIPT_TIMEOUT_SECONDS);
3
-
4
- // required for IE, otherwise Content-disposition is ignored
5
- //@apache_setenv('no-gzip', 1); Causes failure on siteground...research
6
- @ini_set('zlib.output_compression', 'Off');
7
-
8
- global $logger;
9
- $logger = new WPBackItUp_Logger(true,null,'debug_download');
10
-
11
- $logger->log_info(__METHOD__,$_REQUEST);
12
-
13
- if ( isset($_REQUEST['_wpnonce']) && !empty($_REQUEST['_wpnonce'])
14
- && isset($_REQUEST['backup_file']) && !empty($_REQUEST['backup_file']) ) {
15
-
16
- if ( wp_verify_nonce( $_REQUEST['_wpnonce'], WPBACKITUP__NAMESPACE . '-download_backup' ) ) {
17
- $logger->log_info( __METHOD__, 'nonce verified' );
18
-
19
- //strip off the suffix IF one exists
20
- $folder_name = rtrim( $_REQUEST['backup_file'], '.zip' );;
21
- if ( ( $str_pos = strpos( $folder_name, '-main-' ) ) !== false ) {
22
- $suffix = substr( $folder_name, $str_pos );
23
- $folder_name = str_replace( $suffix, '', $folder_name );
24
- }
25
-
26
- if ( ( $str_pos = strpos( $folder_name, '-others-' ) ) !== false ) {
27
- $suffix = substr( $folder_name, $str_pos );
28
- $folder_name = str_replace( $suffix, '', $folder_name );
29
- }
30
-
31
- if ( ( $str_pos = strpos( $folder_name, '-plugins-' ) ) !== false ) {
32
- $suffix = substr( $folder_name, $str_pos );
33
- $folder_name = str_replace( $suffix, '', $folder_name );
34
- }
35
-
36
- if ( ( $str_pos = strpos( $folder_name, '-themes-' ) ) !== false ) {
37
- $suffix = substr( $folder_name, $str_pos );
38
- $folder_name = str_replace( $suffix, '', $folder_name );
39
- }
40
-
41
- if ( ( $str_pos = strpos( $folder_name, '-uploads-' ) ) !== false ) {
42
- $suffix = substr( $folder_name, $str_pos );
43
- $folder_name = str_replace( $suffix, '', $folder_name );
44
- }
45
-
46
- $backup_filename = $_REQUEST['backup_file'];
47
- $backup_path = WPBACKITUP__BACKUP_PATH . '/' . $folder_name . '/' . $backup_filename;
48
- $logger->log_info( __METHOD__, 'Backup file path:' . $backup_path );
49
-
50
- if ( !empty($backup_filename) && file_exists( $backup_path ) ) {
51
- $file_size = filesize($backup_path);
52
- $chunksize = 1*(1024*1024); // how many bytes per chunk
53
- $buffer = '';
54
- $cnt =0;
55
- $handle = fopen($backup_path, 'rb');
56
- if ($handle !== false) {
57
- //Output Headers
58
- header("Content-Disposition: attachment; filename=\"" . basename( $backup_path ) . "\";" );
59
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
60
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT" );
61
- header("Content-type: application/zip");
62
- header("Content-Transfer-Encoding: binary");
63
- header("Content-Length: ".$file_size);
64
-
65
- while (!feof($handle)) {
66
- $buffer = fread($handle, $chunksize);
67
- echo $buffer;
68
- ob_flush();
69
- flush();
70
- }
71
-
72
- fclose($handle);
73
- $logger->log_info( __METHOD__, 'Download complete' );
74
- exit();
75
-
76
- } else {
77
- $logger->log_error( __METHOD__, 'File Not found' );
78
- }
79
- } else {
80
- $logger->log_error( __METHOD__, 'Backup file doesnt exist:' . $backup_path );
81
- }
82
- } else {
83
- $logger->log_error( __METHOD__, 'Bad Nonce');
84
- }
85
- } else {
86
- $logger->log_error( __METHOD__, 'Form data missing');
87
- }
88
-
89
- //Return empty file
90
- header ('Content-type: octet/stream');
91
- header("Content-Disposition: attachment; filename=empty.log");
92
- header("Content-Length: 100");
93
- ob_get_clean();
94
- echo('No backup file found.'. PHP_EOL);
95
- if (ob_get_level()>1) ob_end_flush();
96
-
97
-
98
-
99
-
100
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/handler_upload.php DELETED
@@ -1,176 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (upload)');
2
- /**
3
- * WP BackItUp File Upload Handler
4
- *
5
- * @package WP BackItUp
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
- /*** Includes ***/
12
-
13
-
14
- /*** Globals ***/
15
- global $logger;
16
- $logger = new WPBackItUp_Logger(false,null,'debug_upload');
17
- $backup_folder_root = WPBACKITUP__BACKUP_PATH .'/';
18
-
19
- //*****************//
20
- //*** MAIN CODE ***//
21
- //*****************//
22
- $logger->log('***BEGIN UPLOAD***');
23
- $logger->log($_POST);
24
-
25
-
26
- //verify nonce
27
- if ( !wp_verify_nonce($_REQUEST['_wpnonce'],WPBACKITUP__NAMESPACE .'-upload')) {
28
- $logger->log_error(__METHOD__,'Invalid Nonce');
29
- echo json_encode( array( 'error' => sprintf( __( 'Invalid Nonce',WPBACKITUP__NAMESPACE ) ) ) );
30
- exit;
31
-
32
- }
33
-
34
- //Check upload folder
35
- $upload_path = WPBACKITUP__UPLOAD_PATH;
36
- if ( !is_dir( $upload_path ) ){
37
- if ( ! mkdir( $upload_path, 0755 )){
38
- $logger->log_error(__METHOD__,'Upload directory is not writable, or does not exist.');
39
- echo json_encode( array( 'error' => sprintf( __( "Upload directory is not writable, or does not exist.", WPBACKITUP__NAMESPACE ) ) ) );
40
- exit;
41
- }
42
- }
43
-
44
- add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
45
- add_filter( 'sanitize_file_name', array( $this, 'sanitize_file_name' ) );
46
-
47
- $farray = array( 'test_form' => true, 'action' => WPBACKITUP__NAMESPACE . '_plupload_action' );
48
-
49
- $farray['test_type'] = false;
50
- $farray['ext'] = 'x-gzip';
51
- $farray['type'] = 'application/octet-stream';
52
-
53
- if ( ! isset( $_POST['chunks'] ) ) {
54
- $farray['unique_filename_callback'] = array( $this, 'unique_filename_callback' );
55
- }
56
-
57
- $status = wp_handle_upload(
58
- $_FILES['async-upload'],
59
- $farray
60
- );
61
-
62
- //remove filters
63
- remove_filter( 'upload_dir', array( $this, 'upload_dir' ) );
64
- remove_filter( 'sanitize_file_name', array( $this, 'sanitize_file_name' ) );
65
-
66
- if ( isset( $status['error'] ) ) {
67
- $logger->log_error(__METHOD__,$status['error']);
68
- echo json_encode( array( 'error' => $status['error'] ) );
69
- exit;
70
- }
71
-
72
- if ( isset( $_POST['chunks'] ) && isset( $_POST['chunk'] ) ) {
73
- $chunk_id = $_POST['chunk'];
74
- $zip_file_name = basename( $_POST['name'] );
75
- $from_file_path = $status['file'];
76
- $to_file_path = $upload_path . '/' . $zip_file_name . '_' . $chunk_id . '.zip.tmp';
77
- if ( ! rename( $from_file_path, $to_file_path ) ) {
78
- @unlink( $from_file_path );
79
- $logger->log_error(__METHOD__,'Cant rename file.');
80
- echo json_encode( array( 'error' => sprintf( __( 'Error: %s', 'wpbackitup' ), __( 'File could not be uploaded', 'wpbackitup' ) ) ) );
81
- exit;
82
- }
83
-
84
- // Combine all chunks when done
85
- if ( $_POST['chunk'] == $_POST['chunks'] - 1 ) {
86
- $zip_file_path = $upload_path . '/' . $zip_file_name;
87
- if ( $zip_file_handle = fopen( $zip_file_path, 'wb' ) ) {
88
- //fetch chunks in order
89
- for ( $i = 0; $i < $_POST['chunks']; $i ++ ) {
90
- $chunk_file = $upload_path . '/' . $zip_file_name . '_' . $i . '.zip.tmp';
91
- if ( $rh = fopen( $chunk_file, 'rb' ) ) {
92
- while ( $line = fread( $rh, 32768 ) ) {
93
- fwrite( $zip_file_handle, $line );
94
- }
95
- fclose( $rh );
96
- @unlink( $chunk_file );
97
- }
98
- }
99
- fclose( $zip_file_handle );
100
-
101
- $status['file'] = $zip_file_path;
102
-
103
- //File is finished uploading now move to backup project folder
104
-
105
- //remove the suffix
106
- $file_name = substr( basename( $zip_file_path ), 0, - 4 );
107
-
108
- //strip off the suffix
109
- $prefix = substr( $file_name, 0, 6 );
110
- $suffix = '';
111
- $folder_name = '';
112
-
113
- if ( ( $str_pos = strpos( $file_name, '-main-' ) ) !== false ) {
114
- $suffix = substr( $file_name, $str_pos );
115
- $folder_name = str_replace( $suffix, '', $file_name );
116
- }
117
-
118
- if ( ( $str_pos = strpos( $file_name, '-others-' ) ) !== false ) {
119
- $suffix = substr( $file_name, $str_pos );
120
- $folder_name = str_replace( $suffix, '', $file_name );
121
- }
122
-
123
- if ( ( $str_pos = strpos( $file_name, '-plugins-' ) ) !== false ) {
124
- $suffix = substr( $file_name, $str_pos );
125
- $folder_name = str_replace( $suffix, '', $file_name );
126
- }
127
-
128
- if ( ( $str_pos = strpos( $file_name, '-themes-' ) ) !== false ) {
129
- $suffix = substr( $file_name, $str_pos );
130
- $folder_name = str_replace( $suffix, '', $file_name );
131
- }
132
-
133
- if ( ( $str_pos = strpos( $file_name, '-uploads-' ) ) !== false ) {
134
- $suffix = substr( $file_name, $str_pos );
135
- $folder_name = str_replace( $suffix, '', $file_name );
136
- }
137
-
138
- //Is this a BackItUp archive
139
- if ( empty( $folder_name ) || empty( $suffix ) || 'Backup' != $prefix ) {
140
- $logger->log_error(__METHOD__,'Upload does not appear to be a WP BackItUp backup archive');
141
- echo json_encode( array( 'error' => sprintf( __( "Upload does not appear to be a WP BackItUp backup archive file.",WPBACKITUP__NAMESPACE ) ) ) );
142
- unlink( $zip_file_path );//get rid of it
143
- exit;
144
- }
145
-
146
- //Does folder exist
147
- $backup_archive_folder = WPBACKITUP__BACKUP_PATH . '/' . $folder_name;
148
- if ( ! is_dir( $backup_archive_folder ) ) {
149
- if ( ! mkdir( $backup_archive_folder, 0755 ) ) {
150
- $logger->log_error(__METHOD__,'Upload directory is not writable');
151
- echo json_encode( array( 'error' => sprintf( __( "Upload directory is not writable, or does not exist.", WPBACKITUP__NAMESPACE ) ) ) );
152
- exit;
153
- }
154
- }
155
-
156
- //move the file to the archive folder
157
- //will overwrite if exists
158
- $target_file = $backup_archive_folder . "/" . basename( $zip_file_path );
159
- if ( ! rename( $zip_file_path, $target_file ) ) {
160
- $logger->log_error(__METHOD__,'Cant move zip file to backup folder');
161
- echo json_encode( array( 'error' => sprintf( __( "Could not import file into WP BackItUp backup set.",WPBACKITUP__NAMESPACE ) ) ) );
162
- exit;
163
- }
164
- }
165
- }
166
- }
167
-
168
- // send the uploaded file url in response
169
- $response['success'] = $status['url'];
170
- echo json_encode( $response );
171
- exit;
172
-
173
-
174
- /******************/
175
- /*** Functions ***/
176
- /******************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/handler_viewlog.php DELETED
@@ -1,44 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (viewlog)');
2
- @set_time_limit(WPBACKITUP__SCRIPT_TIMEOUT_SECONDS);
3
-
4
-
5
- if ( isset($_REQUEST['_wpnonce']) && !empty($_REQUEST['_wpnonce'])
6
- && isset($_REQUEST['backup_name']) && !empty($_REQUEST['backup_name']) ){
7
-
8
- if ( wp_verify_nonce($_REQUEST['_wpnonce'],WPBACKITUP__NAMESPACE .'-viewlog')) {
9
-
10
- $backup_folder = $_REQUEST['backup_name'];
11
- $log_filename = $_REQUEST['backup_name']. '.log';
12
- $log_path = WPBACKITUP__BACKUP_PATH .'/' .$backup_folder .'/' .$log_filename ;
13
-
14
- if(file_exists($log_path) ) {
15
-
16
- header("Content-Disposition: attachment; filename=\"" . basename( $log_path ) . "\";" );
17
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
18
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT" );
19
- header("Content-type: octet/stream");
20
- header("Content-Length: ".filesize($log_path));
21
-
22
- ob_get_clean();
23
- readfile($log_path);
24
- if (ob_get_level()>1) ob_end_flush();
25
- exit();
26
- }
27
- }
28
- }
29
-
30
- //Return empty file
31
- header ('Content-type: octet/stream');
32
- header("Content-Disposition: attachment; filename=empty.log");
33
- header("Content-Length: 100");
34
- ob_get_clean();
35
- echo('No log file found.'. PHP_EOL);
36
- if (ob_get_level()>1) ob_end_flush();
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/job_backup.php DELETED
@@ -1,1032 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- @set_time_limit(WPBACKITUP__SCRIPT_TIMEOUT_SECONDS);
3
-
4
- /**
5
- * WP Backitup Backup
6
- *
7
- * @package WP Backitup
8
- *
9
- * @author cssimmon
10
- *
11
- */
12
-
13
- /*** Includes ***/
14
-
15
- if( !class_exists( 'WPBackItUp_Logger' ) ) {
16
- include_once 'class-logger.php';
17
- }
18
-
19
- if( !class_exists( 'WPBackItUp_Utility' ) ) {
20
- include_once 'class-utility.php';
21
- }
22
-
23
-
24
- if( !class_exists( 'WPBackItUp_SQL' ) ) {
25
- include_once 'class-sql.php';
26
- }
27
-
28
- if( !class_exists( 'WPBackItUp_Backup' ) ) {
29
- include_once 'class-backup.php';
30
- }
31
-
32
- if( !class_exists( 'WPBackItUp_Zip' ) ) {
33
- include_once 'class-zip.php';
34
- }
35
-
36
-
37
- if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
38
- include_once 'class-filesystem.php';
39
- }
40
-
41
-
42
- if( !class_exists( 'WPBackItUp_Job' ) ) {
43
- include_once 'class-job.php';
44
- }
45
-
46
- /*** Globals ***/
47
- global $WPBackitup;
48
-
49
- global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
50
- $inactive=0;
51
- $active=1;
52
- $complete=2;
53
- $failure=-1;
54
- $warning=-2;
55
- $success=99;
56
-
57
- //setup the status array
58
- global $status_array;
59
- $status_array = array(
60
- 'preparing' =>$inactive,
61
- 'backupdb' =>$inactive ,
62
- 'infofile'=>$inactive,
63
- 'backup_themes'=>$inactive,
64
- 'backup_plugins'=>$inactive,
65
- 'backup_uploads'=>$inactive,
66
- 'backup_other'=>$inactive,
67
- 'validate_backup'=>$inactive,
68
- 'finalize_backup'=>$inactive,
69
- );
70
-
71
-
72
- //**************************//
73
- // SINGLE THREAD BACKUPS //
74
- //**************************//
75
-
76
- $logger_tasks = new WPBackItUp_Logger(false,null,'debug_tasks');
77
- $backup_process_id = uniqid();
78
-
79
- //Make sure backup is NOT already running before you run the current task
80
-
81
- //Scheduled the next check
82
- if ('scheduled'==$this->backup_type){
83
- wp_schedule_single_event( time()+30, 'wpbackitup_run_backup_tasks');
84
- }
85
-
86
- if (!WPBackItUp_Backup::start()) {
87
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Backup job cant acquire job lock.');
88
- return; //nothing to do
89
- }else{
90
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Backup job lock acquired.');
91
- }
92
- //**************************//
93
-
94
-
95
- //**************************//
96
- // Task Handling //
97
- //**************************//
98
- global $backup_job;
99
- $backup_job=null;
100
- $current_task= null;
101
-
102
- $backup_error=false;
103
- $backup_job = WPBackItUp_Job::get_job('backup');
104
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Check for available backup job');
105
- if ($backup_job){
106
-
107
- //Get the next task in the stack
108
- $next_task = $backup_job->get_next_task();
109
- if (false!==$next_task){
110
- $backup_id=$backup_job->backup_id;
111
- $current_task=$next_task;
112
-
113
- //If task contains error then timeout has occurred
114
- if (strpos($current_task,'error') !== false){
115
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Backup Error Found:' .$current_task);
116
- $backup_error=true;
117
- }
118
-
119
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Available Task Found:' . $current_task);
120
-
121
- }else{
122
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','No available tasks found.');
123
- WPBackItUp_Backup::end(); //release lock
124
- return;
125
- }
126
- }else {
127
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','No backup job available.');
128
-
129
- wp_clear_scheduled_hook( 'wpbackitup_run_backup_tasks');
130
- WPBackItUp_Backup::end(); //release lock
131
- return;
132
- }
133
-
134
- //Should only get here when there is a task to run
135
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Run Backup task:' .$current_task);
136
-
137
- //*************************//
138
- //*** MAIN BACKUP CODE ***//
139
- //*************************//
140
-
141
- //Get the backup ID
142
- $backup_name = get_backup_name($backup_job->backup_id);
143
-
144
- global $logger;
145
- $logger = new WPBackItUp_Logger(false,null,$backup_name);
146
-
147
- global $wp_backup;
148
- $wp_backup = new WPBackItUp_Backup($logger,$backup_name,$WPBackitup->backup_type);
149
-
150
-
151
- //*************************//
152
- //*** BACKUP TASKS ***//
153
- //*************************//
154
-
155
- //An error has occurred on the previous tasks
156
- if ($backup_error) {
157
- $error_task = substr($current_task,6);
158
- $logger->log('Fatal error on previous task:'. $error_task);
159
-
160
- //Check for error type
161
- switch ($error_task) {
162
- case "task_preparing":
163
- set_status('preparing',$active,true);
164
- write_fatal_error_status('2101');
165
- end_backup(2101, false);
166
- break;
167
-
168
- case "task_backup_db":
169
- set_status( 'backupdb', $active, true );
170
- write_fatal_error_status( '2104' );
171
- end_backup( 2104, false );
172
- break;
173
-
174
- case "task_backup_siteinfo":
175
- set_status( 'infofile', $active, true );
176
- write_fatal_error_status( '2105' );
177
- end_backup( 2105, false );
178
- break;
179
-
180
- case "task_backup_themes":
181
- set_status( 'backup_themes', $active, true );
182
- write_fatal_error_status( '2120' );
183
- end_backup( 2120, false );
184
- break;
185
-
186
- case "task_backup_plugins":
187
- set_status( 'backup_plugins', $active, true );
188
- write_fatal_error_status( '2121' );
189
- end_backup( 2121, false );
190
- break;
191
-
192
- case "task_backup_uploads":
193
- set_status( 'backup_uploads', $active, true );
194
- write_fatal_error_status( '2122' );
195
- end_backup( 2122, false );
196
- break;
197
-
198
- case "task_backup_other":
199
- set_status( 'backup_other', $active, true );
200
- write_fatal_error_status( '2123' );
201
- end_backup( 2123, false );
202
- break;
203
-
204
- case "task_validate_backup":
205
- set_status( 'validate_backup', $active, true );
206
- write_fatal_error_status( '2126' );
207
- end_backup( 2126, false );
208
- break;
209
-
210
- case "task_finalize_backup":
211
- set_status( 'finalize_backup', $active, true );
212
- write_fatal_error_status( '2109' );
213
- end_backup( 2109, false );
214
- break;
215
-
216
-
217
-
218
- // case "task_cleanup_current": //Dont end backup on this error
219
- // set_status( 'cleanup', $active, true );
220
- // write_warning_status( '2106' );
221
- // break;
222
-
223
- default:
224
- write_warning_status( '2999' );
225
- end_backup( 2999, false );
226
- break;
227
- }
228
-
229
- }
230
-
231
- //Cleanup Task
232
- if ('task_preparing'==$current_task) {
233
-
234
- //Init
235
- $logger->log('***BEGIN BACKUP***');
236
- $logger->log_sysinfo();
237
- $logger->log('BACKUP TYPE:' .$wp_backup->backup_type);
238
- $logger->log('BACKUP BATCH SIZE:' .$wp_backup->backup_batch_size);
239
- $logger->log('BACKUP ID:' .$backup_job->backup_id);
240
-
241
- $WPBackitup->increment_backup_count();
242
- //End Init
243
-
244
- $logger->log('**BEGIN CLEANUP**');
245
-
246
- //Cleanup & Validate the backup folded is ready
247
- write_response_processing("preparing for backup");
248
- set_status('preparing',$active,true);
249
-
250
- write_response_processing("Cleanup before backup");
251
-
252
- //*** Check Dependencies ***
253
- if (!WPBackItUp_Zip::zip_utility_exists()) {
254
- $logger->log_error(__METHOD__, 'Zip Util does not exist.' );
255
- $backup_job->set_task_error('125');
256
- write_fatal_error_status( '125' );
257
- end_backup( 125, false );
258
- }
259
-
260
- //*** END Check Dependencies ***
261
-
262
-
263
- //This is handled in the cleanup jobs now
264
- //Cleanup any backups that didnt finish normally
265
- //$wp_backup->cleanup_unfinished_backups();
266
-
267
- //Make sure wpbackitup_backups exists
268
- if (! $wp_backup->backup_root_folder_exists() ){
269
- $backup_job->set_task_error('101');
270
-
271
- write_fatal_error_status('101');
272
- end_backup(101, false);
273
- }
274
-
275
- //Create the root folder for the current backup
276
- if (! $wp_backup->create_current_backup_folder()){
277
- $backup_job->set_task_error('101');
278
-
279
- write_fatal_error_status('101');
280
- end_backup(101, false);
281
- }
282
-
283
- //Check to see if the directory exists and is writeable
284
- if (! $wp_backup->backup_folder_exists()){
285
- $backup_job->set_task_error('102');
286
-
287
- write_fatal_error_status('102');
288
- end_backup(102,false);
289
- }
290
-
291
- //Generate the list of files to be backed up and update the tasks info
292
-
293
- $plugins_file_list = $wp_backup->get_plugins_file_list();
294
- $backup_job->update_job_meta('backup_plugins_filelist',wp_slash($plugins_file_list));
295
- $backup_job->update_job_meta('backup_plugins_filelist_remaining',wp_slash($plugins_file_list));
296
-
297
- $themes_file_list = $wp_backup->get_themes_file_list();
298
- $backup_job->update_job_meta('backup_themes_filelist',wp_slash($themes_file_list));
299
- $backup_job->update_job_meta('backup_themes_filelist_remaining',wp_slash($themes_file_list));
300
-
301
- //some folders excluded
302
- $uploads_file_list = $wp_backup->get_uploads_file_list();
303
- $backup_job->update_job_meta('backup_uploads_filelist',wp_slash($uploads_file_list));
304
- $backup_job->update_job_meta('backup_uploads_filelist_remaining',wp_slash($uploads_file_list));
305
-
306
- //some folders excluded
307
- $others_file_list = $wp_backup->get_other_file_list();
308
- $backup_job->update_job_meta('backup_others_filelist',wp_slash($others_file_list));
309
- $backup_job->update_job_meta('backup_others_filelist_remaining',wp_slash($others_file_list));
310
-
311
-
312
- set_status('preparing',$complete,false);
313
- $backup_job->set_task_complete();
314
-
315
- $logger->log('**END CLEANUP**');
316
- return;
317
- }
318
-
319
-
320
- //Backup the database
321
- if ('task_backup_db'==$current_task) {
322
- $logger->log( '**BEGIN SQL EXPORT**' );
323
- write_response_processing( "Create database export" );
324
- set_status( 'backupdb', $active, true );
325
-
326
- if ( ! $wp_backup->export_database() ) {
327
- $backup_job->set_task_error('104');
328
-
329
- write_fatal_error_status( '104' );
330
- //cleanup_on_failure( $wp_backup->backup_project_path );
331
- end_backup( 104, false );
332
- }
333
-
334
- set_status('backupdb',$complete,false);
335
- $backup_job->set_task_complete();
336
-
337
- $logger->log('**END SQL EXPORT**');
338
- return;
339
-
340
- }
341
-
342
- //Extract the site info
343
- if ('task_backup_siteinfo'==$current_task) {
344
- $logger->log( '**SITE INFO**' );
345
- write_response_processing( "Retrieve Site Info" );
346
- set_status( 'infofile', $active, true );
347
-
348
- if ( $wp_backup->create_siteinfo_file() ) {
349
-
350
- //Add site Info and SQL data to main zip
351
- $site_data_suffix='main';
352
- $source_site_data_root = $wp_backup->backup_project_path;
353
- $target_site_data_root = 'site-data';
354
-
355
- $site_data_files = array_filter(glob($wp_backup->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
356
- $site_data_complete = $wp_backup->backup_file_list( $source_site_data_root, $target_site_data_root, $site_data_suffix, $site_data_files, WPBACKITUP__PLUGINS_BATCH_SIZE );
357
- if ( $site_data_complete == 'error' ) {
358
- $backup_job->set_task_error('105');
359
-
360
- write_fatal_error_status( '105' );
361
- //cleanup_on_failure( $wp_backup->backup_project_path );
362
- end_backup( 105, false );
363
- }
364
- } else {
365
- //Site data could be extracted
366
- $backup_job->set_task_error('105');
367
-
368
- write_fatal_error_status( '105' );
369
- //cleanup_on_failure( $wp_backup->backup_project_path );
370
- end_backup( 105, false );
371
- }
372
-
373
- //get rid of the SQL and sitedata file - will check again at end in cleanup
374
- $wp_backup->delete_site_data_files();
375
-
376
- set_status( 'infofile', $complete, false );
377
- $backup_job->set_task_complete();
378
-
379
- $logger->log( '**END SITE INFO**' );
380
- return;
381
-
382
- }
383
-
384
- //Backup the themes
385
- if ('task_backup_themes'==$current_task) {
386
- $logger->log('**BACKUP THEMES TASK**' );
387
- write_response_processing( "Backup themes " );
388
- set_status( 'backup_themes', $active, true );
389
-
390
- $source_themes_root = WPBACKITUP__THEMES_ROOT_PATH;
391
- $target_theme_root = 'wp-content-themes';
392
- $themes_suffix='themes';
393
- $themes_file_list = $backup_job->get_job_meta('backup_themes_filelist_remaining');
394
- $themes_file_list_count= count($themes_file_list);
395
-
396
- $themes_remaining_files = $wp_backup->backup_file_list($source_themes_root,$target_theme_root,$themes_suffix,$themes_file_list,WPBACKITUP__THEMES_BATCH_SIZE);
397
- if ($themes_remaining_files=='error') {
398
- //ERROR
399
- $logger->log_error(__METHOD__,'Error backing up themes.');
400
- $backup_job->set_task_error('120');
401
- write_fatal_error_status( '120' );
402
- //cleanup_on_failure( $wp_backup->backup_project_path );
403
- end_backup( 120, false );
404
- }else{
405
- //update the file list with remaining files
406
- $backup_job->update_job_meta('backup_themes_filelist_remaining',wp_slash($themes_remaining_files));
407
-
408
- $themes_remaining_files_count= count($themes_remaining_files);
409
- $themes_batch_count = $themes_file_list_count-$themes_remaining_files_count;
410
- $logger->log('Backed up in this batch:' .$themes_batch_count);
411
-
412
- $logger->log('Themes remaining:' .$themes_remaining_files_count);
413
- if ($themes_remaining_files_count>0){
414
- //CONTINUE
415
- $logger->log_info(__METHOD__,'Continue backing up themes.');
416
- $backup_job->set_task_queued();
417
- }else{
418
- //COMPLETE
419
- $logger->log_info(__METHOD__,'Complete - All themes backed up.');
420
-
421
- set_status( 'backup_themes', $complete, false );
422
- $backup_job->set_task_complete();
423
- $logger->log('**END BACKUP THEMES TASK**');
424
- }
425
- }
426
-
427
- return;
428
- }
429
-
430
- //Backup the plugins
431
- if ('task_backup_plugins'==$current_task) {
432
- $logger->log( '**BACKUP PLUGINS TASK**' );
433
- write_response_processing( "Backup plugins " );
434
- set_status( 'backup_plugins', $active, true );
435
-
436
- $source_plugins_root = WPBACKITUP__PLUGINS_ROOT_PATH;
437
- $target_plugins_root = 'wp-content-plugins';
438
- $plugins_suffix='plugins';
439
- $plugins_file_list = $backup_job->get_job_meta('backup_plugins_filelist_remaining');
440
- $plugins_file_list_count= count($plugins_file_list);
441
-
442
- $plugins_remaining_files = $wp_backup->backup_file_list($source_plugins_root,$target_plugins_root,$plugins_suffix,$plugins_file_list,WPBACKITUP__PLUGINS_BATCH_SIZE);
443
- if ($plugins_remaining_files=='error') {
444
- //ERROR
445
- $logger->log('Error backing up plugins.');
446
-
447
- $backup_job->set_task_error('121');
448
- write_fatal_error_status( '121' );
449
- //cleanup_on_failure( $wp_backup->backup_project_path );
450
- end_backup( 121, false );
451
- } else {
452
- //update the file list with remaining files
453
- $backup_job->update_job_meta('backup_plugins_filelist_remaining',wp_slash($plugins_remaining_files));
454
-
455
- $plugins_remaining_files_count= count($plugins_remaining_files);
456
- $plugins_batch_count = $plugins_file_list_count-$plugins_remaining_files_count;
457
- $logger->log('Backed up in this batch:' .$plugins_batch_count);
458
-
459
- $logger->log('Plugins remaining:' .$plugins_remaining_files_count);
460
- if ($plugins_remaining_files_count>0){
461
- //CONTINUE
462
- $logger->log('Continue backing up plugins.');
463
- $backup_job->set_task_queued();
464
- } else{
465
- //COMPLETE
466
- $logger->log('Complete - All plugins backed up.');
467
- set_status( 'backup_plugins', $complete, false );
468
- $backup_job->set_task_complete();
469
- $logger->log('**END BACKUP PLUGINS TASK**');
470
- }
471
- }
472
-
473
- return;
474
- }
475
-
476
-
477
- //Backup the uploads
478
- if ('task_backup_uploads'==$current_task) {
479
- $logger->log( '**BACKUP UPLOADS TASK**' );
480
- write_response_processing( "Backup uploads " );
481
- set_status( 'backup_uploads', $active, true );
482
-
483
- $upload_array = wp_upload_dir();
484
- $source_uploads_root = $upload_array['basedir'];
485
- $target_uploads_root = 'wp-content-uploads';
486
- $uploads_suffix = 'uploads';
487
-
488
- $uploads_file_list = $backup_job->get_job_meta( 'backup_uploads_filelist_remaining' );
489
- $uploads_file_list_count = count( $uploads_file_list );
490
-
491
- $batch_size = $WPBackitup->backup_batch_size();
492
-
493
- //exclude zip files from backup
494
- $uploads_remaining_files = $wp_backup->backup_file_list( $source_uploads_root, $target_uploads_root, $uploads_suffix, $uploads_file_list,$batch_size,'.zip' );
495
- if ( $uploads_remaining_files == 'error' ) {
496
- //ERROR
497
- $logger->log( 'Error backing up uploads.' );
498
- $backup_job->set_task_error( '122' );
499
- write_fatal_error_status( '122' );
500
- //cleanup_on_failure( $wp_backup->backup_project_path );
501
- end_backup( 122, false );
502
- } else {
503
- //update the file list with remaining files
504
- $backup_job->update_job_meta( 'backup_uploads_filelist_remaining', wp_slash($uploads_remaining_files) );
505
-
506
- $uploads_remaining_files_count = count( $uploads_remaining_files );
507
- $uploads_batch_count = $uploads_file_list_count - $uploads_remaining_files_count;
508
- $logger->log( 'Backed up in this batch:' . $uploads_batch_count );
509
- $logger->log( 'Remaining Uploads:' . $uploads_remaining_files_count );
510
- if ( $uploads_remaining_files_count > 0 ) {
511
- //CONTINUE
512
- $logger->log( 'Continue backing up uploads.' );
513
- $backup_job->set_task_queued();
514
-
515
- } else {
516
- //COMPLETE
517
- $logger->log( 'All uploads backed up.' );
518
- set_status( 'backup_uploads', $complete, false );
519
- $backup_job->set_task_complete();
520
- $logger->log( '**END BACKUP UPLOADS TASK**' );
521
- }
522
- }
523
-
524
- return;
525
- }
526
-
527
- //Backup all the other content in the wp-content root
528
- if ('task_backup_other'==$current_task) {
529
- $logger->log( '**BACKUP OTHER TASK**' );
530
- write_response_processing( "Backup other files " );
531
- set_status( 'backup_other', $active, true );
532
-
533
- $source_others_root = WPBACKITUP__CONTENT_PATH;
534
- $target_others_root = 'wp-content-other';
535
- $others_suffix = 'others';
536
-
537
- $others_file_list = $backup_job->get_job_meta( 'backup_others_filelist_remaining' );
538
- $others_file_list_count = count( $others_file_list );
539
-
540
- $batch_size = $WPBackitup->backup_batch_size();
541
-
542
- //exclude zip files from backup
543
- $others_remaining_files = $wp_backup->backup_file_list( $source_others_root, $target_others_root, $others_suffix, $others_file_list, $batch_size,'.zip' );
544
- if ( $others_remaining_files == 'error' ) {
545
- //ERROR
546
- $logger->log( 'Error backing up others.' );
547
- $backup_job->set_task_error( '123' );
548
-
549
- write_fatal_error_status( '123' );
550
- //cleanup_on_failure( $wp_backup->backup_project_path );
551
- end_backup( 123, false );
552
- } else {
553
- //update the file list with remaining files
554
- $backup_job->update_job_meta( 'backup_others_filelist_remaining', wp_slash($others_remaining_files) );
555
-
556
- $others_remaining_files_count = count( $others_remaining_files );
557
- $others_batch_count = $others_file_list_count - $others_remaining_files_count;
558
- $logger->log( 'Backed up in this batch:' . $others_batch_count );
559
- $logger->log( 'Remaining Others:' . $others_remaining_files_count );
560
- if ( $others_remaining_files_count > 0 ) {
561
- //CONTINUE
562
- $logger->log( 'Continue backing up others.' );
563
- $backup_job->set_task_queued();
564
- } else {
565
- //COMPLETE
566
- $logger->log( 'All others backed up.' );
567
-
568
- set_status( 'backup_other', $complete, false );
569
- $backup_job->set_task_complete();
570
- $logger->log( '**END BACKUP OTHER TASK**' );
571
- }
572
-
573
- }
574
-
575
- return;
576
- }
577
-
578
- //ENCRYPT CONTENT TASK
579
- //wp-config.php
580
- //db backup
581
-
582
- //Validate the backup IF logging is turned on - reporting only
583
- if ('task_validate_backup'==$current_task) {
584
- //Validate the content if logging is on
585
- $logger->log('**VALIDATE CONTENT**');
586
-
587
- write_response_processing( "Validating Backup " );
588
- set_status( 'validate_backup', $active, true );
589
-
590
- if ($WPBackitup->logging()){
591
- //$wp_backup->validate_backup(); --HOW DO I DO THIS
592
- }
593
-
594
- sleep(5);//temp UI only
595
-
596
- set_status( 'validate_backup', $complete, false );
597
- $backup_job->set_task_complete();
598
- $logger->log('**END VALIDATE CONTENT**');
599
-
600
- return;
601
- }
602
-
603
- //Zip up the backup folder
604
- if ('task_finalize_backup'==$current_task) {
605
- $logger->log( '**FINALIZE BACKUP**' );
606
- write_response_processing( "Compress Backup " );
607
- set_status( 'finalize_backup', $active, true );
608
-
609
- //Generate manifest
610
- if ( ! $wp_backup->create_backup_manifest()) {
611
- $backup_job->set_task_error('109');
612
-
613
- write_fatal_error_status( '109' );
614
- //cleanup_on_failure( $wp_backup->backup_project_path );
615
- end_backup( 109, false );
616
- }
617
-
618
- if ( ! $wp_backup->cleanup_current_backup() ) {
619
- //Warning - no need to error job
620
- write_warning_status( '106' );
621
- }
622
-
623
- //Rename backup folder
624
- if ( ! $wp_backup->rename_backup_folder()) {
625
- $backup_job->set_task_error('109');
626
-
627
- write_fatal_error_status( '109' );
628
- //cleanup_on_failure( $wp_backup->backup_project_path );
629
- end_backup( 109, false );
630
- }
631
-
632
- set_status( 'finalize_backup', $complete, false );
633
- $backup_job->set_task_complete();
634
-
635
- $logger->log( '**END FINALIZE BACKUP**' );
636
-
637
- }
638
-
639
- //If we get this far we have a finalized backup so change the path
640
- $wp_backup->set_final_backup_path();
641
-
642
- //Cleanup work folders - handled in cleanup jobs now
643
- //if ('task_cleanup_current'==$current_task) {
644
- // $logger->log( '**CLEANUP**' );
645
- //
646
- // write_response_processing( "Cleanup after Backup " );
647
- // set_status( 'cleanup', $active, true );
648
- //
649
- // //Check retention limits and cleanup
650
- // $wp_backup->purge_old_files();
651
- //
652
- // set_status( 'cleanup', $complete, false );
653
- // $backup_job->set_task_complete();
654
- //
655
- // $logger->log( '**END CLEANUP**' );
656
- //}
657
-
658
- if ($backup_job->get_job_status()=='complete') {
659
- //SUCCESS- End Job!
660
- set_status_success();
661
- write_response_file_success();
662
- $WPBackitup->increment_successful_backup_count();
663
- end_backup( null, true );
664
- }
665
-
666
- exit();
667
- /******************/
668
- /*** Functions ***/
669
- /******************/
670
- function get_backup_name($timestamp){
671
-
672
- $url = home_url();
673
- $url = str_replace('http://','',$url);
674
- $url = str_replace('https://','',$url);
675
- $url = str_replace('/','-',$url);
676
- $fileUTCDateTime=$timestamp;//current_time( 'timestamp' );
677
- $localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
678
- $backup_name = 'Backup_' . $url .'_' .$localDateTime;
679
-
680
- return $backup_name;
681
-
682
- }
683
- function end_backup($err=null, $success=null){
684
- global $WPBackitup,$wp_backup, $logger, $backup_job;
685
- $logger->log_info(__METHOD__,"Begin");
686
-
687
- $logger->log('Zip up all the logs.');
688
- //Zip up all the logs in the log folder
689
- $logs_path = WPBACKITUP__PLUGIN_PATH .'logs';
690
- $zip_file_path = $wp_backup->backup_project_path .'logs_' .$backup_job->backup_id . '.zip';
691
-
692
- //copy/replace WP debug file
693
- $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
694
- $logger->log_info(__METHOD__,"Copy WP Debug: " .$wpdebug_file_path);
695
- if (file_exists($wpdebug_file_path)) {
696
- copy( $wpdebug_file_path, $logs_path .'/wpdebug.log' );
697
- }
698
-
699
- $zip = new WPBackItUp_Zip($logger,$zip_file_path);
700
- $zip->zip_files_in_folder($logs_path,$backup_job->backup_id,'*.log');
701
- $zip->close();
702
-
703
- WPBackItUp_Backup::end(); //Release the lock
704
- $current_datetime = current_time( 'timestamp' );
705
- $WPBackitup->set_backup_lastrun_date($current_datetime);
706
-
707
- $util = new WPBackItUp_Utility($logger);
708
- $seconds = $util->timestamp_diff_seconds($backup_job->get_job_start_time(),$backup_job->get_job_end_time());
709
-
710
- $processing_minutes = round($seconds / 60);
711
- $processing_seconds = $seconds % 60;
712
-
713
- $logger->log('Script Processing Time:' .$processing_minutes .' Minutes ' .$processing_seconds .' Seconds');
714
-
715
- if (true===$success) $logger->log("Backup completed: SUCCESS");
716
- if (false===$success) $logger->log("Backup completed: ERROR");
717
-
718
- $logger->log("*** END BACKUP ***");
719
-
720
- //Send Notification email
721
- $logger->log('Send Email notification');
722
- $logs_attachment = array( $zip_file_path );
723
- send_backup_notification_email($err, $success,$logs_attachment);
724
-
725
- $logFileName = $logger->logFileName;
726
- $logFilePath = $logger->logFilePath;
727
- $logger->close_file();
728
-
729
- //Move the log if it exists
730
- $newlogFilePath = $wp_backup->backup_project_path .$logFileName;
731
- if (null!=$success && file_exists($logFilePath)){
732
- rename($logFilePath,$newlogFilePath);
733
- }
734
-
735
- echo('Backup has completed');
736
- exit(0);
737
- }
738
-
739
- function send_backup_notification_email($err, $success,$logs=array()) {
740
- global $WPBackitup, $wp_backup, $logger,$status_array,$backup_job;
741
- $logger->log_info(__METHOD__,"Begin");
742
-
743
- $start_timestamp = $backup_job->get_job_start_time();
744
- $end_timestamp = $backup_job->get_job_end_time();
745
- $utility = new WPBackItUp_Utility($logger);
746
- $seconds = $utility->timestamp_diff_seconds($start_timestamp,$end_timestamp);
747
-
748
- $processing_minutes = round($seconds / 60);
749
- $processing_seconds = $seconds % 60;
750
-
751
- $status_description = array(
752
- 'preparing'=>'Preparing for backup...Done',
753
- 'backupdb'=>'Backing up database...Done',
754
- 'infofile'=>'Creating backup information file...Done',
755
- 'backup_themes'=>'Backing up themes...Done',
756
- 'backup_plugins'=>'Backing up plugins...Done',
757
- 'backup_uploads'=>'Backing up uploads...Done',
758
- 'backup_other'=>'Backing up miscellaneous files...Done',
759
- 'finalize_backup'=>'Finalizing backup...Done',
760
- 'validate_backup'=>'Validating backup...Done',
761
- 'cleanup'=>'Cleaning up...Done'
762
- );
763
-
764
- if($success)
765
- {
766
- //Don't send logs on success unless debug is on.
767
- if (WPBACKITUP__DEBUG!==true){
768
- $logs=array();
769
- }
770
-
771
- $subject = get_bloginfo() . ' - Backup completed successfully.';
772
- $message = '<b>Your backup completed successfully.</b><br/><br/>';
773
-
774
- } else {
775
- $subject = get_bloginfo() .' - Backup did not complete successfully.';
776
- $message = '<b>Your backup did not complete successfully.</b><br/><br/>';
777
- }
778
-
779
- $local_start_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',$start_timestamp));
780
- $local_end_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',$end_timestamp));
781
- $message .= 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
782
- $message .= 'Backup date: ' . $local_start_datetime . '<br/>';
783
- $message .= 'Number of backups completed with WP BackItUp: ' . $WPBackitup->backup_count() . '<br/>';
784
-
785
- $message .= 'Completion Code: ' . $backup_job->backup_id .'-'. $processing_minutes .'-' .$processing_seconds .'<br/>';
786
- $message .= 'WP BackItUp Version: ' . WPBACKITUP__VERSION . '<br/>';
787
- $message .= '<br/>';
788
-
789
-
790
- //Add the completed steps on success
791
- if($success) {
792
- $message .='<b>Steps Completed</b><br/>';
793
-
794
- //Add the completed statuses
795
- foreach ($status_array as $status_key => $status_value) {
796
- if ($status_value==2) {
797
- foreach ($status_description as $msg_key => $msg_value) {
798
- if ($status_key==$msg_key) {
799
- $message .= $msg_value . '<br/>';
800
- break;
801
- }
802
- }
803
- }
804
- }
805
- } else {
806
- //Error occurred
807
- $message .= '<br/>';
808
- $message .= 'Errors:<br/>' . get_error_message($err);
809
- }
810
-
811
- $term='success';
812
- if(!$success)$term='error';
813
- $message .='<br/><br/>Checkout '. $WPBackitup->get_anchor_with_utm('www.wpbackitup.com', '', 'notification+email', $term) .' for info about WP BackItUp and our other products.<br/>';
814
-
815
-
816
- $notification_email = $WPBackitup->get_option('notification_email');
817
- if($notification_email)
818
- $utility->send_email($notification_email,$subject,$message,$logs);
819
-
820
- $logger->log_info(__function__,"End");
821
- }
822
-
823
- function cleanup_on_failure($path){
824
- global $logger;
825
- global $wp_backup;
826
-
827
- if (WPBACKITUP__DEBUG===true){
828
- $logger->log('Cleanup On Fail suspended: debug on.');
829
- }
830
- else{
831
- $wp_backup->cleanup_backups_by_prefix('TMP_');
832
- }
833
- }
834
-
835
- function write_fatal_error_status($status_code) {
836
- global $status_array,$active,$failure;
837
-
838
- //Find the active status and set to failure
839
- foreach ($status_array as $key => $value) {
840
- if ($value==$active){
841
- $status_array[$key]=$failure;
842
- }
843
- }
844
-
845
- write_status();
846
- write_response_file_error($status_code);
847
- }
848
-
849
- function write_warning_status($status_code) {
850
- global $status_array,$active,$warning;
851
-
852
- //Find the active status and set to failure
853
- foreach ($status_array as $key => $value) {
854
- if ($value==$active){
855
- $status_array[$key]=$warning;
856
- }
857
- }
858
-
859
- write_status();
860
- }
861
-
862
- //function write_warning_status($status_code) {
863
- // global $status_array,$warning;
864
- //
865
- // //Add warning to array
866
- // $status_array[$status_code]=$warning;
867
- // write_status();
868
- //}
869
-
870
- function write_status() {
871
- global $status_array;
872
- $fh=getStatusLog();
873
-
874
- foreach ($status_array as $key => $value) {
875
- fwrite($fh, '<div class="' . $key . '">' . $value .'</div>');
876
- }
877
-
878
- fclose($fh);
879
- }
880
-
881
- function set_status($process,$status,$flush){
882
- global $status_array,$complete;
883
-
884
- $status_array[$process]=$status;
885
-
886
- //Mark all the others complete and flush
887
- foreach ($status_array as $key => $value) {
888
- if ($process==$key) {
889
- break;
890
- }else{
891
- $status_array[$key]=$complete;
892
- }
893
- }
894
-
895
- if ($flush) write_status();
896
- }
897
-
898
- function set_status_success(){
899
- global $status_array,$complete,$success;
900
-
901
- //Mark all the others complete and flush
902
- foreach ($status_array as $key => $value) {
903
- $status_array[$key]=$complete;
904
- }
905
-
906
- $status_array['finalinfo']=$success;
907
- write_status();
908
- }
909
-
910
- //Get Status Log
911
- function getStatusLog(){
912
- global $logger;
913
-
914
- $status_file_path = WPBACKITUP__PLUGIN_PATH .'/logs/backup_status.log';
915
- $filesystem = new WPBackItUp_FileSystem($logger);
916
- return $filesystem->get_file_handle($status_file_path);
917
-
918
- }
919
-
920
- //write Response Log
921
- function write_response_processing($message) {
922
-
923
- $jsonResponse = new stdClass();
924
- $jsonResponse->backupStatus = 'processing';
925
- $jsonResponse->backupMessage = $message;
926
-
927
- write_response_file($jsonResponse);
928
- }
929
-
930
-
931
- //write Response Log
932
- function write_response_file_error($error) {
933
-
934
- $jsonResponse = new stdClass();
935
- $jsonResponse->backupStatus = 'error';
936
- $jsonResponse->backupMessage = get_error_message($error);
937
-
938
- write_response_file($jsonResponse);
939
- }
940
-
941
- //write Response Log
942
- function write_response_file_success() {
943
- global $WPBackitup,$wp_backup,$logger;
944
-
945
- $jsonResponse = new stdClass();
946
- $jsonResponse->backupStatus = 'success';
947
- $jsonResponse->backupMessage = 'success';
948
- $jsonResponse->backupName = $wp_backup->backup_name;
949
- $jsonResponse->backupLicense = $WPBackitup->license_active();
950
- $jsonResponse->backupRetained = $wp_backup->backup_retained_number;
951
-
952
- $jsonResponse->logFileExists = file_exists($logger->logFilePath);
953
-
954
- write_response_file($jsonResponse);
955
- }
956
-
957
- //write Response Log
958
- function write_response_file($JSON_Response) {
959
- global $logger;
960
-
961
- $json_response = json_encode($JSON_Response);
962
- $logger->log('Write response file:' . $json_response);
963
-
964
- $fh=get_response_file();
965
- fwrite($fh, $json_response);
966
- fclose($fh);
967
- }
968
-
969
- //Get Response Log
970
- function get_response_file() {
971
- global $logger;
972
- $response_file_path = WPBACKITUP__PLUGIN_PATH .'logs/backup_response.log';
973
- $filesytem = new WPBackItUp_FileSystem($logger);
974
- return $filesytem->get_file_handle($response_file_path,false);
975
- }
976
-
977
-
978
- /**
979
- * Get error message
980
- *
981
- * @param $error_code
982
- *
983
- * @return string
984
- */
985
- function get_error_message($error_code){
986
-
987
- $error_message_array = array(
988
- '101' =>'(101) Unable to create a new directory for backup. Please check your CHMOD settings of your wp-backitup backup directory',
989
- '102'=> '(102) Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory',
990
- '103'=> '(103) Unable to backup your files. Please try again',
991
- '104'=> '(104) Unable to export your database. Please try again',
992
- '105'=> '(105) Unable to export site information file. Please try again',
993
- '106'=> '(106) Unable to cleanup your backup directory',
994
- '107'=> '(107) Unable to compress(zip) your backup. Please try again',
995
- '108'=> '(108) Unable to backup your site data files. Please try again',
996
- '109'=> '(109) Unable to finalize backup. Please try again',
997
- '114'=> '(114) Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request',
998
- '120'=> '(120) Unable to backup your themes. Please try again',
999
- '121'=> '(121) Unable to backup your plugins. Please try again',
1000
- '122'=> '(122) Unable to backup your uploads. Please try again',
1001
- '123'=> '(123) Unable to backup your miscellaneous files. Please try again',
1002
- '125'=> '(125) Unable to compress your backup because there is no zip utility available. Please contact support',
1003
- '126'=> '(126) Unable to validate your backup. Please try again',
1004
-
1005
- '2101' =>'(2101) Unable to create a new directory for backup. Please check your CHMOD settings of your wp-backitup backup directory',
1006
- '2102'=> '(2102) Cannot create backup directory. Please check the CHMOD settings of your wp-backitup plugin directory',
1007
- '2103'=> '(2103) Unable to backup your files. Please try again',
1008
- '2104'=> '(2104) Unable to export your database. Please try again',
1009
- '2105'=> '(2105) Unable to export site information file. Please try again',
1010
- '2106'=> '(2106) Unable to cleanup your backup directory',
1011
- '2107'=> '(2107) Unable to compress(zip) your backup. Please try again',
1012
- '2108'=> '(2108) Unable to backup your site data files. Please try again',
1013
- '2109'=> '(2109) Unable to finalize backup. Please try again',
1014
- '2114'=> '(2114) Your database was accessible but an export could not be created. Please contact support by clicking the get support link on the right. Please let us know who your host is when you submit the request',
1015
- '2120'=> '(2120) Unable to backup your themes. Please try again',
1016
- '2121'=> '(2121) Unable to backup your plugins. Please try again',
1017
- '2122'=> '(2122) Unable to backup your uploads. Please try again',
1018
- '2123'=> '(2123) Unable to backup your miscellaneous files. Please try again',
1019
- '2125'=> '(2125) Unable to compress your backup because there is no zip utility available. Please contact support',
1020
- '2126'=> '(2126) Unable to validate your backup. Please try again',
1021
- );
1022
-
1023
- $error_message = '(999) Unexpected error';
1024
- if (array_key_exists($error_code,$error_message_array)) {
1025
- $error_message = $error_message_array[ $error_code ];
1026
- }
1027
-
1028
- return $error_message;
1029
- }
1030
-
1031
-
1032
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/job_cleanup.php DELETED
@@ -1,240 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- @set_time_limit(WPBACKITUP__SCRIPT_TIMEOUT_SECONDS);
3
-
4
- /**
5
- * WP Backitup Backup
6
- *
7
- * @package WP Backitup
8
- *
9
- * @author cssimmon
10
- *
11
- */
12
-
13
- /*** Includes ***/
14
-
15
- if( !class_exists( 'WPBackItUp_Logger' ) ) {
16
- include_once 'class-logger.php';
17
- }
18
-
19
- if( !class_exists( 'WPBackItUp_Utility' ) ) {
20
- include_once 'class-utility.php';
21
- }
22
-
23
-
24
- if( !class_exists( 'WPBackItUp_SQL' ) ) {
25
- include_once 'class-sql.php';
26
- }
27
-
28
- // include backup class
29
- if( !class_exists( 'WPBackItUp_Backup' ) ) {
30
- include_once 'class-backup.php';
31
- }
32
-
33
- if( !class_exists( 'WPBackItUp_Restore' ) ) {
34
- include_once 'class-restore.php';
35
- }
36
-
37
- // include logger class
38
- if( !class_exists( 'WPBackItUp_Zip' ) ) {
39
- include_once 'class-zip.php';
40
- }
41
-
42
- // include file system class
43
- if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
44
- include_once 'class-filesystem.php';
45
- }
46
-
47
- // include job class
48
- if( !class_exists( 'WPBackItUp_Job' ) ) {
49
- include_once 'class-job.php';
50
- }
51
-
52
- /*** Globals ***/
53
- global $WPBackitup;
54
-
55
- global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
56
- $inactive=0;
57
- $active=1;
58
- $complete=2;
59
- $failure=-1;
60
- $warning=-2;
61
- $success=99;
62
-
63
-
64
- //**************************//
65
- // SINGLE THREAD BACKUPS //
66
- //**************************//
67
- $logger_tasks = new WPBackItUp_Logger(false,null,'debug_tasks');
68
- $backup_process_id = uniqid();
69
-
70
-
71
- //If there is a queued or active job then add a resume check
72
- if ('scheduled'==$this->backup_type){
73
- wp_schedule_single_event( time()+30, 'wpbackitup_run_cleanup_tasks');
74
- }
75
-
76
- //Make sure backup is NOT already running before you run the current task
77
- if (!WPBackItUp_Backup::start()) {
78
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Cleanup job cant acquire job lock.');
79
- return; //nothing to do
80
- }else{
81
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Cleanup job lock acquired.');
82
- }
83
- //**************************//
84
-
85
- //**************************//
86
- // Task Handling //
87
- //**************************//
88
- global $cleanup_job;
89
- $cleanup_job=null;
90
- $current_task= null;
91
-
92
- $backup_error=false;
93
-
94
-
95
- $cleanup_job = WPBackItUp_Job::get_job('cleanup');
96
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Check for available job');
97
- if ($cleanup_job){
98
-
99
- //Get the next task in the stack
100
- $next_task = $cleanup_job->get_next_task();
101
- if (false!==$next_task){
102
- $backup_id=$cleanup_job->backup_id;
103
- $current_task=$next_task;
104
-
105
- //If task contains error then timeout has occurred
106
- if (strpos($current_task,'error') !== false){
107
- $backup_error=true;
108
- }
109
-
110
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Available Task Found:' . $current_task);
111
-
112
- }else{
113
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','No available tasks found.');
114
- WPBackItUp_Backup::end(); //release lock
115
- return;
116
- }
117
- }else {
118
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','No backup job available.');
119
- wp_clear_scheduled_hook( 'wpbackitup_run_cleanup_tasks');
120
- WPBackItUp_Backup::end(); //release lock
121
- return;
122
- }
123
-
124
-
125
- //Should only get here when there is a task to run
126
- $logger_tasks->log_info(__METHOD__.'(' .$backup_process_id .')','Run Backup task:' .$current_task);
127
-
128
- //*************************//
129
- //*** MAIN BACKUP CODE ***//
130
- //*************************//
131
-
132
- //Get the backup ID
133
- $job_name = get_job_name($cleanup_job->backup_id);
134
-
135
- global $logger;
136
- $logger = new WPBackItUp_Logger(false,null,$job_name);
137
-
138
- global $wp_backup;
139
- $wp_backup = new WPBackItUp_Backup($logger,$job_name,$WPBackitup->backup_type);
140
-
141
-
142
- //*** SCHEDULED TASKS ***//
143
-
144
- //Run cleanup task
145
- if ('task_scheduled_cleanup'==$current_task) {
146
-
147
- //Init
148
- $logger->log('***BEGIN JOB***');
149
- $logger->log_sysinfo();
150
-
151
- $logger->log('Scheduled Cleanup requested');
152
-
153
- $logger->log( '**CLEAN UNFINISHED BACKUPS**' );
154
- //cleanup any folders that have the TMP_ prefix
155
- $wp_backup->cleanup_backups_by_prefix('TMP_');
156
- $logger->log( '**END CLEAN UNFINISHED BACKUPS**' );
157
-
158
- $logger->log( '**CLEAN DELETED BACKUPS**' );
159
- //cleanup any folders that have the DLT_ prefix
160
- $wp_backup->cleanup_backups_by_prefix('DLT_');
161
- $logger->log( '**END CLEAN DELETED BACKUPS**' );
162
-
163
- $logger->log( '**CLEAN OLD BACKUPS**' );
164
- //Cleanup any folders that exceed retention limit
165
- $wp_backup->cleanup_old_backups();
166
- $logger->log( '**END CLEAN OLD BACKUPS**' );
167
-
168
- $logger->log( '**CLEAN OLD RESTORES**' );
169
- //Cleanup any folders that exceed retention limit
170
- $wp_restore = new WPBackItUp_Restore($logger,$job_name,null);
171
- $wp_restore->delete_restore_folder();
172
- $logger->log( '**END CLEAN OLD RESTORES**' );
173
-
174
- $logger->log( '**PURGE OLD FILES**' );
175
- $wp_backup->purge_old_files();
176
- $logger->log( '**END PURGE OLD FILES**' );
177
-
178
- $logger->log( '**SECURE FOLDERS**' );
179
- //Make sure backup folder is secured
180
- $file_system = new WPBackItUp_FileSystem();
181
-
182
- //Make sure backup folder is secured
183
- $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
184
- $file_system->secure_folder( $backup_dir);
185
-
186
- //--Check restore folder folders
187
- $restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER;
188
- $file_system->secure_folder( $restore_dir);
189
-
190
- //Make sure logs folder is secured
191
- $logs_dir = WPBACKITUP__PLUGIN_PATH .'/logs/';
192
- $file_system->secure_folder( $logs_dir);
193
- $logger->log( '**END SECURE FOLDERS**' );
194
-
195
- $cleanup_job->set_task_complete();
196
-
197
- }
198
-
199
- end_job(null,true);
200
-
201
- //*** END SCHEDULED TASKS ***//
202
-
203
- /******************/
204
- /*** Functions ***/
205
- /******************/
206
- function get_job_name($timestamp){
207
-
208
- $fileUTCDateTime=$timestamp;//current_time( 'timestamp' );
209
- $localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
210
- $job_name = 'cleanup_' .$localDateTime;
211
-
212
- return $job_name;
213
-
214
- }
215
-
216
- function end_job($err=null, $success=null){
217
- global $WPBackitup, $logger, $cleanup_job;
218
- $logger->log_info(__METHOD__,"Begin");
219
-
220
- WPBackItUp_Backup::end(); //Release the lock
221
- $current_datetime = current_time( 'timestamp' );
222
- $WPBackitup->set_cleanup_lastrun_date($current_datetime);
223
-
224
- $util = new WPBackItUp_Utility($logger);
225
- $seconds = $util->timestamp_diff_seconds($cleanup_job->get_job_start_time(),$cleanup_job->get_job_end_time());
226
-
227
- $processing_minutes = round($seconds / 60);
228
- $processing_seconds = $seconds % 60;
229
-
230
- $logger->log('Script Processing Time:' .$processing_minutes .' Minutes ' .$processing_seconds .' Seconds');
231
-
232
- if (true===$success) $logger->log("Cleanup completed: SUCCESS");
233
- if (false===$success) $logger->log("Cleanup completed: ERROR");
234
- $logger->log("*** END JOB ***");
235
- $logger->close_file();
236
-
237
- echo('cleanup has completed');
238
- exit(0);
239
- }
240
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/lib/includes/job_restore.php DELETED
@@ -1,822 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (restore)');
2
- @set_time_limit(WPBACKITUP__SCRIPT_TIMEOUT_SECONDS);
3
-
4
- /**
5
- * WP Backitup Restore Functions
6
- *
7
- * @package WP Backitup Pro
8
- *
9
- * @author cssimmon
10
- *
11
- */
12
-
13
- /*** Includes ***/
14
-
15
- if( !class_exists( 'WPBackItUp_Backup' ) ) {
16
- include_once 'class-backup.php';
17
- }
18
-
19
- if( !class_exists( 'WPBackItUp_Restore' ) ) {
20
- include_once 'class-restore.php';
21
- }
22
-
23
- if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
24
- include_once 'class-filesystem.php';
25
- }
26
-
27
- if( !class_exists( 'WPBackItUp_Zip' ) ) {
28
- include_once 'class-zip.php';
29
- }
30
-
31
- if( !class_exists( 'WPBackItUp_Utility' ) ) {
32
- include_once 'class-utility.php';
33
- }
34
-
35
- if( !class_exists( 'WPBackItUp_SQL' ) ) {
36
- include_once 'class-sql.php';
37
- }
38
-
39
- if( !class_exists( 'WPBackItUp_Job' ) ) {
40
- include_once 'class-job.php';
41
- }
42
-
43
-
44
- /*** Globals ***/
45
- global $WPBackitup;
46
- global $table_prefix; //this is from wp-config
47
-
48
- global $backup_name; //name of the backup file
49
- global $RestorePoint_SQL; //path to restore point
50
- global $logger;
51
-
52
- global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
53
- $inactive=0;
54
- $active=1;
55
- $complete=2;
56
- $failure=-1;
57
- $warning=-2;
58
- $success=99;
59
-
60
- //setup the status array
61
- global $status_array;
62
- $status_array = array(
63
- 'preparing' =>$inactive ,
64
- 'unzipping' =>$inactive ,
65
- 'validation'=>$inactive,
66
- 'deactivate_plugins' =>$inactive ,
67
- 'restore_point'=>$inactive,
68
- 'stage_wpcontent'=>$inactive,
69
- 'restore_wpcontent'=>$inactive,
70
- 'restore_database'=>$inactive,
71
- 'update_user'=>$inactive,
72
- 'update_site_info'=>$inactive,
73
- 'activate_plugins'=>$inactive,
74
- 'update_permalinks'=>$inactive,
75
- );
76
-
77
- //**************************//
78
- // SINGLE THREAD RESTORE //
79
- //**************************//
80
-
81
- $logger_tasks = new WPBackItUp_Logger(false,null,'debug_restore_tasks');
82
- $process_id = uniqid();
83
-
84
- //Is restore running
85
- if ( ! WPBackItUp_Backup::start()) {
86
- $logger_tasks->log_info(__METHOD__,'Restore job cant acquire job lock.');
87
- return; // do nothing.
88
- }else{
89
- $logger_tasks->log_info(__METHOD__,'Restore job lock acquired.');
90
- }
91
-
92
-
93
- //**************************//
94
- // Task Handling //
95
- //**************************//
96
- global $restore_job;
97
- $restore_job=null;
98
- $current_task= null;
99
-
100
- $restore_error=false;
101
- $restore_job = WPBackItUp_Job::get_job('restore');
102
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','Check for available job');
103
- if ($restore_job){
104
-
105
- //Get the next task in the stack
106
- $next_task = $restore_job->get_next_task();
107
- if (false!==$next_task){
108
- $restore_id=$restore_job->backup_id;
109
- $current_task=$next_task;
110
-
111
- //If task contains error then timeout has occurred
112
- if (strpos($current_task,'error') !== false){
113
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','Restore Error Found:' .$current_task);
114
- $restore_error=true;
115
- }
116
-
117
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','Available Task Found:' . $current_task);
118
-
119
- }else{
120
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','No available tasks found.');
121
- WPBackItUp_Backup::end(); //release lock
122
- return;
123
- }
124
- }else {
125
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','No job available.');
126
-
127
- //wp_clear_scheduled_hook( 'wpbackitup_run_restore_tasks');
128
- WPBackItUp_Backup::end(); //release lock
129
- return;
130
- }
131
-
132
- //Should only get here when there is a task to run
133
- $logger_tasks->log_info(__METHOD__.'(' .$process_id .')','Run Restore task:' .$current_task);
134
-
135
-
136
- //*****************//
137
- //*** MAIN CODE ***//
138
- //*****************//
139
-
140
- //Get the job name
141
- $job_log_name = get_job_log_name($restore_job->backup_id);
142
-
143
- global $logger;
144
- $logger = new WPBackItUp_Logger(false,null,$job_log_name,true);
145
-
146
- $backup_name = $restore_job->get_job_meta('backup_name');
147
- if( empty($backup_name)) {
148
- $logger->log_error(__METHOD__,'Backup name not found in job meta.');
149
- write_fatal_error_status('error201');
150
- end_restore();
151
- }
152
-
153
- //Get user ID
154
- $user_id = $restore_job->get_job_meta('user_id');
155
- if( empty($user_id)) {
156
- $logger->log_error(__METHOD__,'User Id not found in job meta.');
157
- write_fatal_error_status('error201');
158
- end_restore();
159
- }
160
-
161
- global $wp_restore; //Eventually everything will be migrated to this class
162
- $wp_restore = new WPBackItUp_Restore($logger,$backup_name,$restore_job->backup_id);
163
-
164
- //*************************//
165
- //*** RESTORE TASKS ***//
166
- //*************************//
167
- //An error has occurred on the previous tasks
168
- if ($restore_error) {
169
- $error_task = substr( $current_task, 6 );
170
-
171
- //Check for error type
172
- switch ( $error_task ) {
173
- case "task_preparing":
174
- fatal_error( 'preparing', '2001', 'Task ended in error:'.$error_task );
175
- break;
176
-
177
- case "task_unzip_backup_set":
178
- fatal_error( 'unzipping', '2002', 'Task ended in error:'.$error_task );
179
- break;
180
-
181
- case "task_validate_backup":
182
- fatal_error( 'validation', '2003', 'Task ended in error:'.$error_task );
183
- break;
184
-
185
- case "task_create_checkpoint":
186
- fatal_error( 'restore_point', '2004', 'Task ended in error:'.$error_task );
187
- break;
188
-
189
- case "task_stage_wpcontent":
190
- fatal_error( 'stage_wpcontent', '2005', 'Task ended in error:'.$error_task );
191
- break;
192
-
193
- case "task_restore_wpcontent":
194
- fatal_error( 'restore_wpcontent', '2006', 'Task ended in error:'.$error_task );
195
- break;
196
-
197
- case "task_restore_database":
198
- fatal_error( 'restore_database', '2007', 'Task ended in error:'.$error_task );
199
- break;
200
-
201
- default:
202
- fatal_error( 'unknown', '2999', 'Task ended in error:'.$error_task );
203
- break;
204
- }
205
- }
206
-
207
- //Cleanup Task
208
- if ('task_preparing'==$current_task) {
209
- $logger->log('***BEGIN RESTORE***');
210
- $logger->log_sysinfo();
211
-
212
- $task = 'preparing';
213
- start_status($task);
214
-
215
- $logger->log('**PREPARING FOR RESTORE**');
216
-
217
- if (! $this->license_active()){
218
- fatal_error($task,'225','Restore is not available because license is not active.');
219
- }
220
-
221
- //PREPARE TASK
222
- if (! class_exists('ZipArchive')){
223
- fatal_error($task,'235','Zip Archive Class is not available.');
224
- }
225
-
226
- $logger->log('*DELETE RESTORE FOLDER*');
227
- if ( ! $wp_restore->delete_restore_folder()){
228
- fatal_error($task,'222','Restore folder could not be deleted.');
229
- }
230
- $logger->log('*END DELETE RESTORE FOLDER*');
231
-
232
- $logger->log('*CREATE ROOT RESTORE FOLDER*');
233
- if ( ! $wp_restore->create_restore_root_folder()){
234
- fatal_error($task,'222','Root Restore folder could not be created.');
235
- }
236
- $logger->log('*END CREATE RESTORE FOLDER*');
237
-
238
- $logger->log('*DELETE STAGED FOLDER*');
239
- if ( ! $wp_restore->delete_staged_folders()){
240
- fatal_error($task, '222','Staged folders could not be deleted.');
241
- }
242
- $logger->log('*END DELETE STAGED FOLDER*');
243
-
244
- $logger->log('*UPDATE ZIP JOB META*');
245
- //Get the zip list
246
- $backup_path_pattern = $wp_restore->get_backup_folder_path() . '/' .$wp_restore->get_backup_name() . '*.zip' ;
247
- $logger->log_info(__METHOD__,'Fetch backups pattern:' .$backup_path_pattern);
248
- $backup_set = glob( $backup_path_pattern);
249
- if ( count($backup_set)>0){
250
- $restore_job->update_job_meta('backup_set',wp_slash($backup_set));
251
- $restore_job->update_job_meta('backup_set_remaining',wp_slash($backup_set));
252
- }else{
253
- fatal_error($task,'222','No zip files found (pattern):' . $backup_path_pattern);
254
- }
255
- $logger->log('*END UPDATE ZIP JOB META*');
256
-
257
-
258
- $logger->log( '*UPDATE SITE VALUES META*' );
259
- $siteurl = $wp_restore->get_siteurl();
260
- if (false===$siteurl){
261
- fatal_error($task,'207','Unable to fetch site url.');
262
- }else {
263
- $restore_job->update_job_meta('current_siteurl',$siteurl);
264
- }
265
-
266
- $homeurl = $wp_restore->get_homeurl();
267
- if (false===$homeurl){
268
- fatal_error($task, '208','Unable to fetch home url.');
269
- }else{
270
- $restore_job->update_job_meta('current_homeurl',$homeurl);
271
- }
272
-
273
- $user_login = $wp_restore->get_user_login( $user_id );
274
- if (false===$user_login) {
275
- fatal_error($task,'209','Unable to fetch user login.');
276
- }else{
277
- $restore_job->update_job_meta('current_user_login',$user_login);
278
- }
279
-
280
- $user_pass = $wp_restore->get_user_pass( $user_id );
281
- if (false===$user_pass){
282
- fatal_error($task,'210','Unable to fetch user password.');
283
- }else{
284
- $restore_job->update_job_meta('current_user_pass_hash',$user_pass);
285
- }
286
-
287
- $user_email = $wp_restore->get_user_email( $user_id );
288
- if (false===$user_email){
289
- fatal_error($task,'211','Unable to fetch user email.');
290
- } else{
291
- $restore_job->update_job_meta('current_user_email',$user_email);
292
- }
293
-
294
- $logger->log( '*END UPDATE SITE VALUES META*' );
295
-
296
- end_status($task);
297
- $restore_job->set_task_complete();
298
- $logger->log('**END PREPARING FOR RESTORE**');
299
-
300
- return;
301
- }
302
-
303
- if ('task_unzip_backup_set'==$current_task) {
304
-
305
- $logger->log( '**UNZIP BACKUP**' );
306
-
307
- $task = 'unzipping';
308
- start_status($task );
309
-
310
- //get the list of plugins zips in folder
311
- $backup_set_list=$restore_job->get_job_meta('backup_set_remaining');
312
- $logger->log_info(__METHOD__,'Begin - Backup set list:');
313
- $logger->log($backup_set_list);
314
- if ( ! $wp_restore->unzip_archive_file( $backup_set_list) ) {
315
- fatal_error($task,'203','Unable to unzip archive.');
316
- } else {
317
-
318
- array_shift( $backup_set_list ); //remove from list
319
- $restore_job->update_job_meta('backup_set_remaining',wp_slash($backup_set_list));
320
-
321
- if (count($backup_set_list)>0){
322
- //CONTINUE
323
- $logger->log('Continue unzipping backup set.');
324
- $restore_job->set_task_queued();
325
- } else{
326
- //COMPLETE
327
- $logger->log('Complete - All archives restored.');
328
- end_status( $task);
329
- $restore_job->set_task_complete();
330
- $logger->log( '**END UNZIP BACKUP**' );
331
- }
332
-
333
- }
334
-
335
- return;
336
-
337
- }
338
-
339
- //Validate the backup folder
340
- if ('task_validate_backup'==$current_task) {
341
- $logger->log_info(__METHOD__, '**VALIDATE BACKUP**' );
342
-
343
- $task = 'validation';
344
- start_status($task);
345
-
346
- //Validate the restore folder
347
-
348
- if ( ! $wp_restore->validate_restore_folder( )){
349
- fatal_error($task,'204','Restore directory INVALID.');
350
- }
351
-
352
- $logger->log( '*VALIDATE MANIFEST*' );
353
- $backup_set_list=$restore_job->get_job_meta('backup_set');
354
- if ( $wp_restore->validate_manifest_file($backup_set_list,$error_code)===false){
355
- if ($error_code==1){
356
- fatal_error($task,'251','Empty manifest.');
357
- }
358
-
359
- if ($error_code==2){
360
- fatal_error($task,'252','Missing zip file.');
361
- }
362
-
363
- if ($error_code==3){
364
- fatal_error($task,'253','Zip file not in manifest.');
365
- }
366
-
367
- //shouldnt get here
368
- fatal_error($task,'999','Unexpected error code:' . $error_code);
369
-
370
- }
371
- $logger->log( '*END VALIDATE MANIFEST*' );
372
-
373
- $logger->log( '*VALIDATE SITEDATA FILE*' );
374
- //validate the site data file
375
- $site_info = $wp_restore->validate_siteinfo_file();
376
- if ( $site_info===false){
377
- fatal_error($task,'204','Site Data file INVALID.');
378
- }else{
379
- //save restore info to meta
380
- $restore_job->update_job_meta('restore_site_info',$site_info);
381
- }
382
-
383
- //Check table prefix values FATAL - need to add link to article
384
- if ( $table_prefix != $site_info['restore_table_prefix'] ) {
385
- fatal_error($task,'221','Table prefix different from restore.');
386
- }
387
-
388
- //Check wordpress version
389
- if ( get_bloginfo( 'version') != $site_info['restore_wp_version'] ) {
390
- fatal_error($task,'226','Backup was created using different version of wordpress');
391
- }
392
-
393
-
394
- //Check wpbackitup version
395
- //Only major versions differences should fail
396
- //1.9.2.8 and 1.9.2.9 are ok
397
- //1.9.2 and 1.10 are NOT
398
- //Even minor numbers are final releases
399
- //Odd minor numbers are pre-releases
400
- $restore_wpbackitup_version = $site_info['restore_wpbackitup_version'];
401
- $restore_wpbackitup_version = explode('.', $restore_wpbackitup_version);
402
- $current_wpbackitup_version = explode('.', WPBACKITUP__VERSION);
403
-
404
- $logger->log_info(__METHOD__,'Backup Created with WP BackItUp Version :');
405
- $logger->log($restore_wpbackitup_version);
406
-
407
- //Check version if not 1.9
408
- if ("1" != $restore_wpbackitup_version[0] || "9" !=$restore_wpbackitup_version[1]){
409
- //If major version is different
410
- if ($restore_wpbackitup_version[0] != $current_wpbackitup_version[0] ||
411
- $restore_wpbackitup_version[1] != $current_wpbackitup_version[1] ) {
412
- fatal_error($task,'227','Backup was created using different version of WP BackItUp');
413
- }
414
- }
415
- $logger->log( '*END VALIDATE SITEDATA FILE*' );
416
-
417
-
418
- $logger->log( '*VALIDATE SQL FILE EXISTS*' );
419
- if ( ! $wp_restore->validate_SQL_exists( )){
420
- fatal_error($task,'216','NO Database backups in backup.');
421
- }
422
- $logger->log( '*END VALIDATE SQL FILE EXISTS*' );
423
- end_status($task);
424
-
425
- $logger->log('*DEACTIVATE ACTIVE PLUGINS*');
426
- $task='deactivate_plugins';
427
- start_status($task);
428
- $wp_restore->deactivate_plugins();
429
- end_status($task);
430
- $logger->log('*END DEACTIVATE ACTIVE PLUGINS*');
431
-
432
- $restore_job->set_task_complete();
433
- $logger->log( '**END VALIDATE BACKUP**' );
434
-
435
- return;
436
- }
437
-
438
-
439
- //Create the DB restore point
440
- if ('task_create_checkpoint'==$current_task) {
441
-
442
- $logger->log('**CREATE RESTORE POINT**');
443
- $task = 'restore_point';
444
- start_status($task);
445
-
446
- if ( ! $wp_restore->export_database()){
447
- fatal_error($task,'205','Cant backup database.');
448
- }
449
-
450
- $restore_job->set_task_complete();
451
- end_status($task);
452
- $logger->log('**END CREATE RESTORE POINT**');
453
-
454
- return;
455
- }
456
-
457
-
458
- //Stage WP content folders
459
- if ('task_stage_wpcontent'==$current_task) {
460
-
461
- $logger->log('*STAGE WP-CONTENT*');
462
- $task = 'stage_wpcontent';
463
-
464
- start_status($task);
465
-
466
- $folder_stage_suffix = $wp_restore->get_restore_staging_suffix();
467
-
468
- //Stage all but plugins
469
-
470
- $logger->log('*STAGE THEMES*');
471
- $from_folder_name = $wp_restore->get_restore_root_folder_path() .'/' .$wp_restore::THEMESPATH;
472
- $to_folder_name = WPBACKITUP__THEMES_ROOT_PATH . $folder_stage_suffix;
473
- if (! $wp_restore->rename_folder($from_folder_name,$to_folder_name)){
474
- fatal_error($task,'219','Cant stage themes.',false);
475
- $wp_restore->delete_staged_folders();
476
- end_restore();
477
- }
478
- $logger->log('*END STAGE THEMES*');
479
-
480
- $logger->log('*STAGE UPLOADS*');
481
- $from_folder_name = $wp_restore->get_restore_root_folder_path() .'/' .$wp_restore::UPLOADPATH;
482
- $upload_array = wp_upload_dir();
483
- $uploads_root_path = $upload_array['basedir'];
484
- $to_folder_name = $uploads_root_path . $folder_stage_suffix;
485
- if (! $wp_restore->rename_folder($from_folder_name,$to_folder_name)){
486
- fatal_error($task,'219','Cant stage uploads.',false);
487
- $wp_restore->delete_staged_folders();
488
- end_restore();
489
- }
490
- $logger->log('*END STAGE UPLOADS*');
491
-
492
- $logger->log('*STAGE OTHER FOLDERS*');
493
- $other_list = glob($wp_restore->get_restore_root_folder_path() .'/' .$wp_restore::OTHERPATH .'/*',GLOB_ONLYDIR|GLOB_NOSORT);
494
- foreach ( $other_list as $from_folder_name ) {
495
- $to_folder_name = WPBACKITUP__CONTENT_PATH .'/' .basename($from_folder_name) . $folder_stage_suffix;
496
- if (! $wp_restore->rename_folder($from_folder_name,$to_folder_name)) {
497
- fatal_error($task,'219','Cant stage other.',false);
498
- $wp_restore->delete_staged_folders();
499
- end_restore();
500
- }
501
- }
502
- $logger->log('*END STAGE OTHER FOLDERS*');
503
- end_status($task);
504
-
505
- $restore_job->set_task_complete();
506
-
507
- $logger->log('**END STAGE WP-CONTENT**');
508
-
509
- return;
510
- }
511
-
512
-
513
- //Rename the staged folders to current
514
- if ('task_restore_wpcontent'==$current_task) {
515
-
516
- $logger->log('**RESTORE WPCONTENT**');
517
- $task ='restore_wpcontent';
518
- start_status($task);
519
-
520
- $logger->log('*RESTORE MAIN WPCONTENT*');
521
- $wpcontent_restore =$wp_restore->restore_wpcontent();
522
- if (! $wpcontent_restore===true) {
523
- //array with failed list returned
524
- //If any of them fail call it done.
525
- warning('300','Cant restore all WP content.');
526
- }
527
- $logger->log('*END RESTORE MAIN WPCONTENT*');
528
-
529
- $logger->log('*RESTORE PLUGINS*');
530
- $plugin_restore = $wp_restore->restore_plugins();
531
- if (! $plugin_restore ===true) {
532
- //array with fail list returned
533
- warning('305', 'Couldnt restore all plugins.');
534
- }
535
-
536
- $logger->log('*END RESTORE PLUGINS*');
537
-
538
- $restore_job->set_task_complete();
539
- end_status($task);
540
- $logger->log('**END RESTORE WPCONTENT**');
541
-
542
- return;
543
- }
544
-
545
- //restore the DB
546
- if ('task_restore_database'==$current_task) {
547
-
548
- $logger->log('**RESTORE DATABASE**');
549
- $task ='restore_database';
550
- start_status($task);
551
-
552
- $current_siteurl= $restore_job->get_job_meta('current_siteurl');
553
- $current_homeurl= $restore_job->get_job_meta('current_homeurl');
554
-
555
- $current_user_id=$restore_job->get_job_meta('user_id');
556
- $current_user_login=$restore_job->get_job_meta('current_user_login');
557
- $current_user_pass_hash= $restore_job->get_job_meta('current_user_pass_hash');
558
- $current_user_email=$restore_job->get_job_meta('current_user_email');
559
-
560
- $user_full_name='';
561
- $current_user = get_user_by('id',$current_user_id);
562
- if (false!==$current_user){
563
- $user_full_name = $current_user->first_name . ' ' .$current_user->last_name;
564
- }
565
-
566
- //Not going to use the restore Point SQL because IF the import failed then DB may be intact
567
- if ( ! $wp_restore->restore_database()) {
568
- fatal_error($task,'212','Database NOT restored.');
569
- //Do we want to recover the DB ?
570
- }
571
-
572
- end_status($task);
573
- $logger->log('**END RESTORE DATABASE**');
574
-
575
- $logger->log('*UPDATE DATABASE VALUES*');
576
-
577
- //update the session cookie
578
- wp_set_auth_cookie( $user_id, true);
579
-
580
- WPBackItUp_Job::cancel_all_jobs(); //Cancel any jobs that were in the restored DB
581
-
582
- start_status('update_user');
583
- //Restored DB so current user may not be there.
584
- //If current user id doesnt exist then create it
585
- //if exists update to current properties
586
- if ( ! $wp_restore->update_credentials($user_id, $user_full_name, $current_user_login, $current_user_pass_hash, $current_user_email,$table_prefix)){
587
- warning('215', 'Cant update user credentials.');
588
- }
589
- end_status('update_user');
590
-
591
- start_status('update_site_info');
592
- if ( ! $wp_restore->update_siteurl($table_prefix,$current_siteurl)){
593
- warning('213', 'Cant update site url.');
594
- }
595
-
596
- if ( ! $wp_restore->update_homeurl($table_prefix, $current_homeurl)){
597
- warning('214', 'Cant update home url.');
598
- }
599
- end_status('update_site_info');
600
-
601
- //DONT NEED TO UPDATE TASKS - DB RESTORED
602
-
603
- $logger->log('*ACTIVATE PLUGINS*');
604
- start_status('activate_plugins');
605
- $wp_restore->activate_plugins();
606
- end_status('activate_plugins');
607
- $logger->log('*END ACTIVATE PLUGINS*');
608
-
609
-
610
- start_status('update_permalinks');
611
- if (! $wp_restore->update_permalinks()){
612
- //dont do anything
613
- }
614
- end_status('update_permalinks');
615
- $logger->log('*END UPDATE DATABASE VALUES*');
616
- }
617
-
618
- //**************************************************************
619
- // After the database is restored all the job data will be gone
620
- //
621
- // NO MORE TASKS OR JOB DATA AFTER THIS POINT
622
- //
623
- //**************************************************************
624
-
625
-
626
- //schedule a cleanup? with job id? for staged folder
627
- set_status_success();
628
- $logger->log('Restore completed successfully');
629
- $logger->log('***END RESTORE***');
630
-
631
- echo('Restore has completed successfully.');
632
- end_restore(null,true);
633
-
634
- exit;
635
-
636
- /******************/
637
- /*** Functions ***/
638
- /******************/
639
- function fatal_error($process,$error_code,$error_message, $end=true){
640
- global $restore_job, $failure, $logger;
641
-
642
- $logger->log_error(__METHOD__,$error_message);
643
- $restore_job->set_task_error($error_code);
644
- write_response_file_error($error_code,$error_message);
645
-
646
- set_status($process,$failure,true);
647
- write_fatal_error_status('error' .$error_code);
648
-
649
- if ($end) {
650
- end_restore();
651
- }
652
- }
653
-
654
- function warning($error_code,$warning_message) {
655
- global $logger, $status_array,$warning;
656
-
657
- $logger->log_warning(__METHOD__, $warning_message);
658
-
659
- //Add warning to array
660
- $status_array['warning' .$error_code]=$warning;
661
- write_restore_status();
662
- }
663
-
664
- function set_status($process,$status,$flush){
665
- global $wp_restore,$logger;
666
- global $status_array,$complete;
667
-
668
- $status_array[$process]=$status;
669
-
670
- //Mark all the others complete and flush
671
- foreach ($status_array as $key => $value) {
672
- if ($process==$key) {
673
- break;
674
- }else{
675
- $status_array[$key]=$complete;
676
- }
677
- }
678
-
679
- if ($flush) write_restore_status();
680
-
681
- }
682
-
683
- //write Response Log
684
- function write_response_file_error($error_code,$error_message) {
685
-
686
- $jsonResponse = new stdClass();
687
- $jsonResponse->restoreStatus = 'error';
688
- $jsonResponse->errorCode = $error_code;
689
- $jsonResponse->restoreMessage = $error_message;
690
-
691
- write_response_file($jsonResponse);
692
- }
693
-
694
- //write Response Log
695
- function write_response_file_success() {
696
-
697
- $jsonResponse = new stdClass();
698
- $jsonResponse->backupStatus = 'success';
699
- $jsonResponse->backupMessage = 'success';
700
-
701
- write_response_file($jsonResponse);
702
- }
703
-
704
-
705
- //write Response Log
706
- function write_response_file($JSON_Response) {
707
- global $logger;
708
-
709
- $json_response = json_encode($JSON_Response);
710
- $logger->log('Write response file:' . $json_response);
711
-
712
- $fh=get_response_file();
713
- fwrite($fh, $json_response);
714
- fclose($fh);
715
- }
716
-
717
- //Get Response Log
718
- function get_response_file() {
719
- global $logger;
720
- $response_file_path = WPBACKITUP__PLUGIN_PATH .'logs/restore_response.log';
721
- $filesytem = new WPBackItUp_FileSystem($logger);
722
- return $filesytem->get_file_handle($response_file_path,false);
723
- }
724
-
725
- function get_job_log_name($timestamp){
726
-
727
- $url = home_url();
728
- $url = str_replace('http://','',$url);
729
- $url = str_replace('https://','',$url);
730
- $url = str_replace('/','-',$url);
731
- $fileUTCDateTime=$timestamp;//current_time( 'timestamp' );
732
- $localDateTime = date_i18n('Y-m-d-His',$fileUTCDateTime);
733
- $job_log_name = 'Restore_' . $url .'_' .$localDateTime;
734
-
735
- return $job_log_name;
736
- }
737
-
738
- //Get Status Log
739
- function get_restore_Log() {
740
- global $logger;
741
-
742
- $status_file_path = WPBACKITUP__PLUGIN_PATH .'/logs/restore_status.log';
743
- $filesystem = new WPBackItUp_FileSystem($logger);
744
- return $filesystem->get_file_handle($status_file_path);
745
-
746
- }
747
-
748
- function write_fatal_error_status($status_code) {
749
- global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
750
-
751
- //Find the active status and set to failure
752
- foreach ($status_array as $key => $value) {
753
- if ($value==$active){
754
- $status_array[$key]=$failure;
755
- }
756
- }
757
-
758
- //Add failure to array
759
- $status_array[$status_code]=$failure;
760
- write_restore_status();
761
- }
762
-
763
-
764
-
765
- function write_restore_status() {
766
- global $status_array;
767
- $fh=get_restore_Log();
768
-
769
- foreach ($status_array as $key => $value) {
770
- fwrite($fh, '<div class="' . $key . '">' . $value .'</div>');
771
- }
772
- fclose($fh);
773
- }
774
-
775
- function start_status($process){
776
- global $wp_restore,$active;
777
-
778
- set_status($process,$active,true);
779
- $wp_restore->save_process_status($process,'started');
780
- }
781
-
782
- function end_status($process){
783
- global $wp_restore,$complete;
784
-
785
- set_status($process,$complete,false);
786
- $wp_restore->save_process_status($process,'completed');
787
- }
788
-
789
-
790
- function set_status_success(){
791
- global $status_array,$inactive,$active,$complete,$failure,$warning,$success;
792
- global $active;
793
-
794
- $status_array['finalinfo']=$success;
795
- write_restore_status();
796
- }
797
-
798
- function end_restore($err=null, $success=null){
799
- global $WPBackitup, $wp_restore, $logger;
800
-
801
- if (true===$success) $logger->log("Backup completed: SUCCESS");
802
- if (false===$success) $logger->log("Backup completed: ERROR");
803
-
804
- $logger->log("*** END BACKUP ***");
805
-
806
- //Zip up all the logs
807
- // $zip_file_path =$wp_restore->zip_logs();
808
-
809
- //Email the log
810
- // $notification_email = $WPBackitup->get_option('notification_email');
811
- // $logs_attachment = array( $zip_file_path );
812
- // $wp_restore->send_notification_email($err, $success,$logs_attachment,$notification_email);
813
-
814
- //Release the lock
815
- WPBackItUp_Backup::end();
816
-
817
- //Close the logger
818
- $logger->close_file();
819
-
820
- echo('Backup has completed');
821
- exit(0);
822
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/readme.txt DELETED
@@ -1,410 +0,0 @@
1
- === WP Backitup ===
2
- Contributors: cssimmon,jcpeden
3
- Donate link: http://www.wpbackitup.com
4
- Tags: backup, back up, backups, backup wordpress, backup database, backup plugin, backup and restore, database, database backup, database restore, db, db backup, db restore, download database, full backup, mysql backup, restore, restore database,restore wordpress, restore wordpress backup,restoring wordpress, website backup, wordpress backup, wordpress restore, plugin, backup buddy
5
- Requires at least: 3.8.0
6
- Tested up to: 4.0.1
7
- Stable tag: 1.9.2
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Simple & complete backups of your WordPress website with this easy to use plugin.
12
-
13
- == Description ==
14
-
15
- = The Simplest Way to Backup Your WordPress Site =
16
- Backing up your WordPress website is easy with WP BackItUp. Simply install WP BackItUp and within minutes you will have a complete backup of your entire site. No complex configuration to deal with. No advanced knowledge of WordPress required. No FTP, cPanel, MySQL or PHPMyAdmin involved. If you can press a button then you can backup your WordPress site with WP BackItUp.
17
-
18
- WP BackItUp creates a backup archive (zip) of your entire website (database, plugins, themes, uploads, content) with a single click. Backup archives can be quickly and easily downloaded so that they can be stored securely and separately from your hosted WordPress site.
19
-
20
- Here are just a few of our incredible features.
21
-
22
- **Features**
23
- ------------
24
- * **Easy to use**, just one click and your site is backed up
25
- * **Easy to setup** because there is no setup required
26
- * **Simple** & easy to understand interface
27
- * **Fast** backups
28
- * Automated backups allow you to **schedule** your backups to run whenever you need them to (premium only)
29
- * Support if you run into any trouble
30
- * Backup status notifications by email
31
- * Works in low memory & shared hosting environments
32
- * Works on all WordPress platforms (Linux, Windows and even Azure)
33
- * **Complete backup**, which includes database, plugins, themes, uploads, everything
34
- * Compresses(zip) your backups to **save** you **space**
35
- * Stores backups to a folder on your server
36
- * Download backup archives right from your WordPress dashboard
37
- * Cleans up all work files to save space
38
- * Simple **restore** right from your WordPress dashboard(premium only)
39
- * Debug mode that provides full logging of the backup
40
- * Tested and supported on all current PHP versions (5.2, 5.3, 5.4, 5.5)
41
- * Premium version and priority support available
42
-
43
- = Don't Risk Losing Your Website =
44
- Does the thought of losing your website keep you up at night? All the time, effort and money you've invested, gone in an instant. WordPress is an incredible product but there are many things that can cause you to lose your website. You could get hacked, your hosting company could go out of business, you could install a bad plugin or theme, the list is endless and without good backups, you could lose everything. If this isn't one of the things keeping you up at night, then it really should be. It was keeping us up at night so we decided to do something about it.
45
-
46
- In 2012 we created the WP BackItUp plugin and made it freely available to the WordPress community so that we can all sleep better at night knowing our content is safe. Since 2012 we have added many incredible features and even created a premium version, but our fundamental goal is still the same. We want to make WordPress backups as **simple**, **effective** and **easy** as possible because we don’t want anything to stop you from backing up your WordPress site regularly. We offer this plugin to you for free so that you will **BackItUp** and sleep better at night.
47
-
48
- = Automatically Restore/Clone/Migrate your Website? =
49
- Need to restore, clone or migrate your website to another host, we make that easy too. The premium version of WP BackItUp will allow you to restore your site from backup with a single click. All you need to do is select the backup you want to restore and click restore, right from your WordPress dashboard. That’s it, your site is back up and running in minutes.
50
-
51
- = Free Support =
52
- We offer free support via the WordPress [support forum](http://wordpress.org/support/plugin/wp-backitup) for this plugin but before posting a question please make sure you are running the current version of WP BackItUp. We make frequent releases to add features and fix issues so please make sure you are up to date before posting an issue. We also ask that you review the [online documentation](http://www.wpbackitup.com/documentation/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+doc) and [FAQ's](https://www.wpbackitup.com/documentation/faqs/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+faq) sections of [www.wpbackitup.com](http://www.wpbackitup.com/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=free+support+a) before posting your questions.
53
-
54
- = Professional Support =
55
- WP BackItUp is supported by a team of professional developers. If you are using WP BackItUp to secure your business website then professional support is available to our premium customers. Please see [www.wpbackitup.com](http://www.wpbackitup.com/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=professional+support+a) for details.
56
-
57
- = Premium Plugin Available =
58
- WP BackItUp premium allows you to restore your backups from the WordPress dashboard in minutes or get a full money-back refund. You can purchase a [no-risk WP Backitup license](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=description&utm_term=premium+plugin+no+risk) anytime from the WP Backitup site.
59
-
60
- = More questions? =
61
- Please review our [FAQ’s](http://wordpress.org/plugins/wp-backitup/faq/) or ask them in the [support forum](http://wordpress.org/support/plugin/wp-backitup).
62
-
63
- == Installation ==
64
-
65
- Installing WP-BackItUp is very easy and straightforward.
66
-
67
- 1. Search for 'WP BackItUp' in the WordPress.org plugin directory and click install. Or, upload the files to your wp-content/wp-backitup/ folder.
68
- 1. Activate the plugin.
69
- 1. A new menu called 'WP Backitup' will be added to the left side navigation of your WordPress dashboard.
70
- 1. Click 'WP Backitup' to access the backup interface.
71
- 1. Enter your sites license key for premium features. You may purchase a license key at [www.wpbackitup.com](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=installation&utm_term=install+license)
72
-
73
- You can find more detailed instructions at [www.wpbackitup.com](http://wpbackitup.com/documentation/faqs/install/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=installation&utm_term=install+instructions)
74
-
75
- == Frequently Asked Questions ==
76
-
77
- = Is WP BackItUp really free? =
78
- Yes, we have provided WP BackItUp free to the WordPress community since 2012. We do this because we don't want there to be any reason **you** aren't backing up your WordPress site, it's that important.
79
-
80
- The free version is made possible by our generous premium customers. Please use WP BackItUp free for as long as needed but if you are able, consider supporting our community by becoming a premium customer. See [www.wpbackitup.com/premium](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=free+pricing) for details.
81
-
82
- = Can I manually restore my WP BackItUp archive(zip)? =
83
- Sure! The backup archive generated by WP BackItUp contains everything you need to restore your WordPress site. We even created a guide to help you. Please see [www.wpbackitup.com/manual-restore](https://www.wpbackitup.com/documentation/restore/how-to-manually-restore-your-wordpress-database/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=manual+restore) for details.
84
-
85
- = Is there an easier way to restore my backup zips? =
86
- Yes, the premium version of WP BackItUp provides a one click restore option. If you can click a button then you can restore your site. Please see [www.wpbackitup.com](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=easy+restore+pricing) for pricing info and our [no-risk offer](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=easy+restore+no+risk).
87
-
88
- = How long do backups take? =
89
- WP BackItUp is really fast. Unless your site is extremely large(many gigabytes) it should only take a few minutes for your backup to complete. If your back up has been running for longer than 15 minutes then there may be an issue. Before contacting support please close your browser and try the backup again. If it continues happening, contact support.
90
-
91
- = Will the plugin work on shared hosts, sub domains or my host? =
92
- Yes, WP BackItUp has been around since 2012 and has over 30,000 installs all over the world. WP BackItUp can be used safely and easily on most hosts and set-ups.
93
-
94
- = Will WP BackItUp work on Windows hosting? =
95
- Yes. WP BackItUp works on both Windows and Linux hosts. WP BackItUp even works with WordPress sites hosted on Windows Azure.
96
-
97
- = Does this plugin backup to Amazon S3, dropbox or google drive? =
98
- Not yet but this feature will be available in an upcoming version of WP BackItUp. We listen to requests so if this is an important feature to you then please let us know by submitting a [feature request](https://www.wpbackitup.com/feature-request/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=dropbox+feature+request).
99
-
100
- = Is there an auto back up schedule feature? =
101
- Not yet but this feature will be available in an upcoming version of WP BackItUp. We listen to requests so if this is an important feature to you then please let us know by submitting a [feature request](https://www.wpbackitup.com/feature-request/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=dropbox+feature+request).
102
-
103
- = Will WP BackItUp work with WordPress version x.x? =
104
- WP BackItUp works on the current release of WordPress and is updated to function with all new releases.
105
-
106
- = Can my backup be used to restore to a different version of WordPress? =
107
- This is a tough one. In many cases the backups created by WP BackItUp can be used to restore to a different version of WordPress but this is **not recommended**. It is very important that you keep all your WordPress versions the same but if you find yourself in this situation then all may not be lost. Please contact support [www.wpbackitup.com/support](https://www.wpbackitup.com/support/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=different+version+support) before attempting this on your own.
108
-
109
- = Will WP Backitup work on WordPress Multisite? =
110
- WP Backitup cannot yet backup/restore entire networks but it is compatible with WordPress MultiSite (WPMS) installs.
111
-
112
- = Does WP BackItUp backup the WordPress database? =
113
- Yes it does. Your entire database will be exported into a SQL file and saved in the backup archive created by WP BackItUp. This file is used by WP BackItUp premium to restore your site and may be also be used for manual restores.
114
- Please see [www.wpbackitup.com](https://www.wpbackitup.com/pricing-purchase/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=database+pricing) for information about WP BackItUp premium or for [manual-restore instructions](https://www.wpbackitup.com/documentation/restore/how-to-manually-restore-your-wordpress-database/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=database+manual+restore)
115
-
116
- = Does the plugin backup the database details as well? =
117
- Yes, the database export contains everything related to the database.
118
-
119
- = Can I make a basic WordPress site, with all my desired plugins and settings, make a few pages, setup permalinks, remove all the default junk and then use it as a template for all my new WordPress sites? =
120
- Yes. WP BackItUp is used by many professional designers & developers just this way. Once you have your WordPress site setup the way you want, just BackItUp and use that backup archive as a starting point for all your new sites.
121
-
122
- = Does WP BackItUp need to be installed? =
123
- Yes, WP BackItUp is just like any other WordPress plugin. You must install it on any site that you wish to perform a backup or restore.
124
-
125
- = Does WP Backitup backup plugins settings or just the plugins themselves? =
126
- WP Backitup creates a backup of **everything**. This includes plugins, plugin settings, themes, theme settings, pages, posts, users, uploads, everything.
127
-
128
- = Do you have any idea when a WordPress site becomes too large for WP BackItUp to handle? =
129
- WP BackItUp can be used to backup very large sites. We`ve tested up to 5 themes, 20 plugins and more than 100 posts/pages without any issues.
130
-
131
- = Do you do regularly update this product to match with WP version updates? =
132
- Yes. We continually improve WP BackItUp and test it with every new version ow WordPress.
133
-
134
- = I am not running the most recent version of WP BackItUp. Should I upgrade? =
135
- Yes, please make sure you are always running the current version of WP BackItUp.
136
-
137
- = Further Support & Feedback =
138
- General support questions should be posted in the WordPress support forums. If you are WP BackItup premium customer then support requests may be submitted to [www.wpbackitup.com/support](https://www.wpbackitup.com/support/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=further+support+support)
139
-
140
- Our online documentation and full list of FAQs can be found at [www.wpbackitup.com/help](https://www.wpbackitup.com/documentation/?utm_medium=partner&utm_source=wordpress.org&utm_campaign=plugin+directory&utm_content=faq&utm_term=further+support+help)
141
-
142
-
143
- == Screenshots ==
144
- 1. Once activated, the plugin loads a new menu into your WordPress dashboard.
145
- 2. Simply click 'Backup' to generate a backup of your site. The plugin will update you on its progress.
146
- 3. When the backup is complete it will appear in the available backups section where you can download it to store somewhere safe .
147
- 4. Automated backups may be scheduled for any day of the week. (Premium Only)
148
- 5. Restore your site from any backup with the one click restore feature. (Premium Only)
149
- 6. Backups may be uploaded via the upload option.
150
- 7. Email notifications, backup retention and logging settings are available in settings.
151
-
152
-
153
- == Changelog ==
154
- = 1.10.0 =
155
- * New Feature: Add support request to plugin
156
- * New Feature: Add large backup support
157
- * New Feature: Add drag and drop uploads
158
- * New Feature: Split backup into separate archives(database,plugins,themes,uploads)
159
- * New Feature: Add download popup to allow user to selectively download backup archives
160
- * Updates: Security Enhancements
161
- * Updates: Miscellaneous User Experience Improvements
162
- * Updates: Significant Performance Improvements
163
-
164
- = 1.9.2 =
165
- * New Features: Added WordPress 4.0.1 support
166
- * New Features: Major Security Enhancements
167
- * New Features: Added log attachment to backup notification email
168
- * Update: Moved zip threshold to constant.
169
- * Update: Added additional logging to archive process
170
-
171
- = 1.9.1 =
172
- * New Features: Long running backups are now supported.
173
- * Update: Extensive Performance improvements
174
- * Update: User experience improvements to backup.
175
- * Update: Extensive updates to error handling and messaging
176
- * Update: Enhancements to backup email notification.
177
- * Update: Logging enhancements.
178
- * Update: Automated cleanup uses file retention limits for all logs.
179
- * Update: Security enhancements to prevent unwanted access to backup, restore and log folders.
180
- * Fix: IFrame css definition changed to use wp-backitup namespace.
181
-
182
- = 1.9 =
183
- * New Features: Scheduled backups are now available.
184
- * New Feature: Allow only a single backup to be run at a time.
185
- * New feature: Automated cleanup feature will perform work file and log cleanup once per day.
186
- * Update: User experience improvements to backup.
187
- * Update: Logging enhancements.
188
- * Fix: Add support for windows MySql database exports. Windows backups always worked but did not take advantage of MySql export tools like other platforms.
189
-
190
-
191
- = 1.8 =
192
- * Updates: WordPress 4.0 support
193
- * Feature: Add support for large database restore.
194
- * Feature: Add database checkpoint recovery for database restore failures
195
- * Feature: Add restore logging on all restores
196
- * Fix: Correct bug on restore when table prefix doesn't match.
197
-
198
- = 1.7.5.1 =
199
- * This is a minor release with some small UI fixes.
200
- * Feature: Add lite registration
201
- * Fix: correct license expiration month
202
- * Fix: added namespace prefix to all ajax actions
203
-
204
- = 1.7.5 =
205
- * Feature: Add exclusion of non-WP Backitup backups to increase performance
206
- * Fix: correct date issue for php 5.2 users
207
- * Fix: correct issue with backup log listing in backup view
208
- * Fix: correct issue with delete file when no log exists
209
-
210
- = 1.7.4 =
211
- * Fix to backup folder create & checks
212
- * Security Enhancements
213
- * Add logging to filesystem create folder
214
-
215
- = 1.7.3 =
216
- * Fix 1.7.2 deployment issue
217
-
218
- = 1.7.2 =
219
- * User Interface improvements
220
- * Add backup and restore folder check
221
- * Add log viewer
222
- * Add utm enhancements
223
-
224
- = 1.7.1 =
225
- * Fix to log file cleanup error
226
-
227
- = 1.7.0 =
228
- * Security enhancements
229
- * Major user interface improvements
230
- * Improvements to upload functionality
231
- * Add Feature: Backup Email Notifications
232
- * Add Feature: Backup Retention
233
- * Bug fix: Create Backup & Restore folders on activation
234
- * Updates to license activation
235
-
236
- = 1.6.7 =
237
- * WordPress 3.9.1 support
238
- * Unicode fix to support utf8 content
239
-
240
- = 1.6.6 =
241
- * WordPress 3.9 support
242
-
243
- = 1.6.5 =
244
- * Correct issue with subversion tags
245
-
246
- = 1.6.4 =
247
- * Correct issue with subversion tags
248
-
249
- = 1.6.3 =
250
- * Fixed issue with svn
251
-
252
- = 1.6.2 =
253
- * Fixed issue with version 1.6.1 update.
254
-
255
- = 1.6.1 =
256
- * This release is mostly cosmetic changes and minor fixes to v1.6.0
257
- * Corrected path issue occurring on unix platform
258
- * Updated backup zip to remove blanks in file name
259
- * Changed backup suffix to backup instead of export
260
- * Corrected backup.sql export file size check
261
- * Fix license check for restore option
262
- * Update usage tracking default to off
263
- * Correct issue with manual data export that contain non-ascii characters
264
- * Add Date Time stamp on SQL restore export
265
-
266
- = 1.6.0 =
267
- * Significant performance improvements.
268
- * Many improvements to user interface.
269
- * Support for multiple backups.
270
- * Added interface for large file uploads via FTP.
271
- * Added restore point and database recovery when fatal errors are encountered.
272
- * Added configurable debug logging.
273
- * Added logging option to options page.
274
-
275
- = 1.5.4 =
276
- Enabled plugin to work with version 3.8
277
-
278
- = 1.5.3 =
279
- Enabled plugin to work with version 3.7.1
280
-
281
- = 1.5.2 =
282
- Modified admin interface.
283
-
284
- = 1.5.1 =
285
- Removed redundant code.
286
-
287
- = 1.5.0 =
288
- Changed DB Export and import method to work on all hosting.
289
-
290
- = 1.4.2 =
291
- Changed DB backup method to work on shared hosting.
292
-
293
- = 1.4.1 =
294
- Setup alert if DB is 0 bytes.
295
-
296
- = 1.4.0 =
297
- Fixed status reporting for backup/restore process and built-in localization.
298
-
299
- = 1.3.0 =
300
- Recommended upgrade: Amalgameted lite and pro versions of the plugin.
301
-
302
- = 1.2.2 =
303
- Major updates to improve plugin performance and stability.
304
-
305
- = 1.2.1 =
306
- Minor updates to plugin functionality.
307
-
308
- = 1.2.0 =
309
- Brought versioning inline with WP Backitup Lite. Fixed incorrecy message on restore interface. Fixed restorationcess.
310
-
311
- = 1.1.0 =
312
- Backup from mysqldump, restore from mysql command line, restore functionality from uploaded files, file size limit check according to server before uploads, setInterval termination after operation, status update as the task completes using XML.
313
-
314
- = 1.0.9 =
315
- Introduced mysqldump for backup and shell exec for copy/delete operations.
316
-
317
- = 1.0.8 =
318
- Added ability to restore from server.
319
-
320
- = 1.0.7 =
321
- Improved auto-update facility and plugin stability.
322
-
323
- = 1.0.6 =
324
- Fixed critical issues the auto-upgradecess.
325
-
326
- = 1.0.5 =
327
- Fixed critical issues the auto-upgradecess.
328
-
329
- = 1.0.4 =
330
- Fixed issues with the restorationcess.
331
-
332
- = 1.0.3 =
333
- Fixed the auto-update engine and license key activation system.
334
-
335
- = 1.0.2 =
336
- Minor bugs patched for auto-update engine.
337
-
338
- = 1.0.1 =
339
- WP Backitup integrated with licensing and auto-update engine.
340
-
341
- = 1.0.0 =
342
- Initial version of the plugin released.
343
-
344
- == Upgrade Notice ==
345
-
346
- = 1.5.3 =
347
- Optional upgrade: No functionality changes.
348
-
349
- = 1.5.2 =
350
- Optional upgrade: No functionality changes.
351
-
352
- = 1.5.1 =
353
- Optional upgrade: Redundant code was removed from plugin.
354
-
355
- = 1.5.0 =
356
- Critical upgrade: Fixes to backup and import processes to work on a wider range of hosts.
357
-
358
- = 1.4.2 =
359
- Recommended upgrade: Many people on shared hosting will now be able to backup their database.
360
-
361
- = 1.4.1 =
362
- Recommended upgrade: Backitup will now alert and halt if your database is 0 bytes on backup.
363
-
364
- = 1.4.0 =
365
- Recommended upgrade: Fixed status reporting for backup/restore process and built-in localization.
366
-
367
- = 1.3.0 =
368
- Recommended upgrade: Amalgameted lite and pro versions of the plugin
369
-
370
- = 1.2.2 =
371
- Critical upgrade: Major overhaul of plugin structure
372
-
373
- = 1.2.1 =
374
- Recommended upgrade: Minor update to plugin structure.
375
-
376
- = 1.2.0 =
377
- Recommended upgrade: Minor update to plugin structure.
378
-
379
- = 1.1.0 =
380
- Critical upgrade: Improved plugin performance.
381
-
382
- = 1.0.9 =
383
- Recommended upgrade: Improved reliability and performance.
384
-
385
- = 1.0.8 =
386
- Recommended upgrade: Improved functionality
387
-
388
- = 1.0.7 =
389
- Critical upgrade: Fixed major bugs with auto-upgradecess.
390
-
391
- = 1.0.6 =
392
- Critical upgrade: Fixed major bugs with auto-upgradecess.
393
-
394
- = 1.0.5 =
395
- Critical upgrade: Fixed major bugs with auto-upgradecess.
396
-
397
- = 1.0.4 =
398
- Critical upgrade: Fixed major bugs with restorationcess.
399
-
400
- = 1.0.3 =
401
- Critical upgrade: Patched auto-update engine.
402
-
403
- = 1.0.2 =
404
- Non-critical upgrade: Patched auto-update engine.
405
-
406
- = 1.0.1 =
407
- Recommended upgrade: Added the licensing and auto-update engine.
408
-
409
- = 1.0.0 =
410
- Initial version of the plugin.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/views/backup.php DELETED
@@ -1,441 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- $page_title = $this->friendly_name . ' Dashboard';
4
- $namespace = $this->namespace;
5
-
6
- //Path Variables
7
- $backup_folder_root = WPBACKITUP__BACKUP_PATH;
8
- $logs_folder_root = WPBACKITUP__PLUGIN_PATH .'/logs';
9
-
10
- //Get license info
11
- $version = $this->version;
12
- $license_key = $this->license_key();
13
- $license_active = $this->license_active();
14
-
15
- $license_type = $this->license_type();
16
- $license_type_description = $this->license_type_description();
17
- if (!empty($license_type_description)){
18
- $license_type_description = ucfirst($license_type_description);
19
- }
20
-
21
- $license_status = $this->license_status();
22
- $license_status_message = $this->license_status_message();
23
-
24
- $license_Expires = $this->license_expires();
25
- $formatted_expired_date = date('F j, Y',strtotime($license_Expires));
26
-
27
- // get retention number set
28
- $number_retained_archives = $this->backup_retained_number();
29
-
30
- $lite_registration_first_name = $this->lite_registration_first_name();
31
- $lite_registration_email = $this->lite_registration_email();
32
- $is_lite_registered = $this->is_lite_registered();
33
-
34
- $backup_schedule=$this->backup_schedule();
35
-
36
- $schedule_style_disabled='';
37
- if (!$license_active || 'expired'== $license_status){
38
- $schedule_style_disabled='disabled';
39
- }
40
-
41
-
42
- //Make sure backup folder exists
43
- $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
44
- $backup_folder_exists=false;
45
- if( !is_dir($backup_dir) ) {
46
- if (@mkdir($backup_dir, 0755)){
47
- $backup_folder_exists=true;
48
- }
49
- }else{
50
- $backup_folder_exists=true;
51
- }
52
-
53
- //Cleanup old backups - this can be removed in a few months.
54
- //Get Zip File List
55
- $file_list = glob($backup_folder_root . "/*.{zip,log}",GLOB_BRACE);
56
- //If there are zip files then move them into their own folders
57
- foreach($file_list as $file) {
58
-
59
- //remove the suffix
60
- $file_name = substr(basename($file),0,-4);
61
-
62
- //strip off the suffix IF one exists
63
- $folder_name = $file_name;
64
- if ( ( $str_pos = strpos( $folder_name, '-main-' ) ) !== false ) {
65
- $suffix = substr( $folder_name, $str_pos );
66
- $folder_name = str_replace( $suffix, '', $folder_name );
67
- }
68
-
69
- if ( ( $str_pos = strpos( $folder_name, '-others-' ) ) !== false ) {
70
- $suffix = substr( $folder_name, $str_pos );
71
- $folder_name = str_replace( $suffix, '', $folder_name );
72
- }
73
-
74
- if ( ( $str_pos = strpos( $folder_name, '-plugins-' ) ) !== false ) {
75
- $suffix = substr( $folder_name, $str_pos );
76
- $folder_name = str_replace( $suffix, '', $folder_name );
77
- }
78
-
79
- if ( ( $str_pos = strpos( $folder_name, '-themes-' ) ) !== false ) {
80
- $suffix = substr( $folder_name, $str_pos );
81
- $folder_name = str_replace( $suffix, '', $folder_name );
82
- }
83
-
84
- if ( ( $str_pos = strpos( $folder_name, '-uploads-' ) ) !== false ) {
85
- $suffix = substr( $folder_name, $str_pos );
86
- $folder_name = str_replace( $suffix, '', $folder_name );
87
- }
88
-
89
- //Does folder exist
90
- $backup_archive_folder = $backup_dir . '/' . $folder_name;
91
- if ( ! is_dir( $backup_archive_folder ) ) {
92
- if (mkdir( $backup_archive_folder, 0755 )){
93
- //print_r( "Folder Create.." );
94
- }else{
95
- //print_r( "Create Failed.." );
96
- }
97
- }
98
-
99
- //make sure it exists before you move it
100
- if ( is_dir( $backup_archive_folder ) ) {
101
- //move the file to the archive folder
102
- $target_file = $backup_archive_folder ."/" . basename($file);
103
- if (rename ($file,$target_file)){
104
- //print_r( "File Moved.." );
105
- } else{
106
- //print_r( "Move Failed.." );
107
- }
108
-
109
- } else {
110
- //print_r( "NO FOLDER" );
111
- }
112
-
113
- }
114
-
115
- $backup_list = $this->get_backup_list();
116
-
117
- ?>
118
-
119
- <?php //Add Notification to UI
120
- if (!$backup_folder_exists) {
121
- echo(
122
- '<div style="overflow: hidden;" class="error" id="wp-backitup-notification-parent" class="updated">
123
- <div style="float:left;" id="wp-backitup-notification-message" ><p><strong>Error:</strong> Backup folder does not exist. Please contact ');
124
-
125
- echo($this->get_anchor_with_utm('support','support','backup+error','no+backup+folder'));
126
- echo(' for assistance.</p></div>');
127
-
128
- echo('<div style="float:right;"><p><a id="wp-backitup-notification-close"><i style="float:right" class="fa fa-close"> Close</i></a></p></div>
129
- </div>');
130
- } else{
131
- echo(
132
- '<div style="overflow: hidden; display:none" id="wp-backitup-notification-parent" class="updated">
133
- <div style="float:left;" id="wp-backitup-notification-message" ></div>
134
- <div style="float:right;"><p><a id="wp-backitup-notification-close"><i style="float:right" class="fa fa-close"> Close</i></a></p></div>
135
- </div>'
136
- );
137
- }
138
- ?>
139
-
140
- <script type="text/javascript">var __namespace = "<?php echo($namespace); ?>";</script>
141
- <div class="wrap">
142
- <h2><?php echo $page_title; ?></h2>
143
-
144
- <div id="content">
145
-
146
- <!--Manual Backups-->
147
- <!--Manual Backups-->
148
- <div class="widget">
149
- <h3><i class="fa fa-cogs"></i> <?php _e('Backup', $namespace); ?></h3>
150
- <p><b>Click the backup button to create a zipped backup file of this site's database, plugins, themes and settings.</b></p>
151
- <p>Once your backup file has been created it will appear in the available backups section below. This file may remain on your hosting providers server but we recommend that you download and save it somewhere safe.</p>
152
- <p> WP BackItUp premium customers can use these backup files to perform an automated restore of their site.</p>
153
- <p>
154
- <?php if ($backup_folder_exists) :?>
155
- <input type="submit" id="backup-button" class="backup-button button-primary" value="<?php _e("Backup", $namespace) ?>"/><img class="backup-icon status-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></p>
156
- <?php endif; ?>
157
- <?php
158
- //Display a note for lite customers
159
- if (!$license_active)
160
- echo '<p> * WP BackItUp lite customers may use these backup files to manually restore their site. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','documentation/restore/how-to-manually-restore-your-wordpress-database','backup','manual+restore') .' for manual restore instructions.</p>';
161
- ?>
162
- </div>
163
-
164
-
165
- <!--Scheduled Backups-->
166
- <div class="widget">
167
- <h3><i class="fa fa-clock-o"></i> <?php _e('Backup Schedule', $namespace); ?>
168
- <i id="scheduled-backups-accordian" style="float:right" class="fa fa-angle-double-down"></i></h3>
169
- <p><b>Select the days of the week you would like your backup to run.</b></p>
170
- <div id="scheduled-backups" style="display: none;">
171
- <p>Backup your site once per week or every day, it's up to you. If you have email notifications turned on we'll even send you an email when it's done.
172
- Once your backup file has been created it will appear in the available backups section below. This file may remain on your hosting providers server but we recommend that you download and save it somewhere safe.</p>
173
- <p>
174
- <b>Please make sure to schedule your backup for at least once per week.</b>
175
- <form action="admin-post.php" method="post" id="<?php echo $namespace; ?>-save_schedule_form">
176
- <?php wp_nonce_field($namespace . '-update-schedule',$namespace . '_nonce-update-schedule'); ?>
177
-
178
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'1'))? _e('checked') :_e(''); ?> value="1">Monday<br>
179
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'2'))? _e('checked') :_e(''); ?> value="2">Tuesday<br>
180
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'3'))? _e('checked') :_e(''); ?> value="3">Wednesday<br>
181
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'4'))? _e('checked') :_e(''); ?> value="4">Thursday<br>
182
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'5'))? _e('checked') :_e(''); ?> value="5">Friday<br>
183
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'6'))? _e('checked') :_e(''); ?> value="6">Saturday<br>
184
- <input <?php _e($schedule_style_disabled); ?> type="checkbox" name="dow" <?php (false!==strpos($backup_schedule,'7'))? _e('checked') :_e(''); ?> value="7">Sunday<br>
185
-
186
- <br/>
187
- <input <?php _e($schedule_style_disabled); ?> type="submit" id="schedule-button" class="schedule-button button-primary" value="<?php _e("Save Schedule", $namespace) ?>"/>
188
- </form>
189
- <?php
190
- //Display restore note for lite customers
191
- if (!$license_active || 'expired'== $license_status)
192
- echo '<p>* Scheduled backups are only available to WP BackItUp premium customers. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','pricing-purchase','scheduled+backups','risk+free') . ' to get WP BackItUp risk free for 30 days.</p>';
193
- ?>
194
- </div>
195
- </div>
196
-
197
- <!--Available Backups section-->
198
- <div class="widget">
199
- <h3><i class="fa fa-cloud-download"></i> <?php _e('Available Backups', $namespace); ?></h3>
200
-
201
- <!--View Log Form-->
202
- <form id = "viewlog" name = "viewlog" action="admin-post.php" method="post">
203
- <input type="hidden" name="action" value="viewlog">
204
- <input type="hidden" id="backup_name" name="backup_name" value="">
205
- <?php wp_nonce_field($this->namespace . "-viewlog"); ?>
206
- </form>
207
-
208
- <form id = "download_backup" name = "download_backup" action="admin-post.php" method="post">
209
- <input type="hidden" name="action" value="download_backup">
210
- <input type="hidden" id="backup_file" name="backup_file" value="">
211
- <?php wp_nonce_field($this->namespace . "-download_backup"); ?>
212
- </form>
213
-
214
- <table class="widefat" id="datatable">
215
- <?php
216
-
217
- if ($backup_list!=false)
218
- {
219
- $i = 0;
220
- foreach ($backup_list as $file)
221
- {
222
-
223
- $backup_name = $file["backup_name"];
224
- $file_datetime = get_date_from_gmt(date('Y-m-d H:i:s', $file["date_time"]), 'Y-m-d g:i a');
225
- $log_exists = $file["log_exists"];
226
-
227
- $class = $i % 2 == 0 ? 'class="alternate"' : '';
228
- ?>
229
-
230
- <tr <?php echo $class ?> id="row<?php echo $i; ?>">
231
- <td><?php echo $file_datetime ?></td>
232
-
233
- <!--Download Link-->
234
- <td>
235
- <a href="#TB_inline?width=600&height=550&inlineId=<?php echo preg_replace('/[^A-Za-z0-9\-]/', '', $backup_name) ?>" class="thickbox" title="<?php echo $backup_name ?>">Download</a>
236
- </td>
237
-
238
- <?php if (($log_exists)):?>
239
- <td><a class='viewloglink' href="<?php echo $backup_name ?>">View Log</a></td>
240
- <?php else: ?>
241
- <td>&nbsp;</td>
242
- <?php endif; ?>
243
-
244
- <td><a href="#" title="<?php echo $backup_name; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
245
- </tr>
246
-
247
- <?php
248
- $i++;
249
- }
250
- }
251
- else
252
- {
253
- echo '<tr id="nofiles"><td colspan="3">No backup archives found.</td></tr>';
254
- }
255
- ?>
256
- </table>
257
-
258
- <?php
259
- //Display restore note for lite customers
260
- if (!$license_active)
261
- echo '<p>* The automated restore feature is only available to WP BackItUp premium customers. Please visit ' .$this->get_anchor_with_utm('www.wpbackitup.com','pricing-purchase','available+backups','risk+free') . ' to get WP BackItUp risk free for 30 days.</p>';
262
- ?>
263
- </div>
264
-
265
- <div id="status" class="widget">
266
- <h3><i class="fa fa-check-square-o"></i> <?php _e('Status', $namespace); ?></h3>
267
-
268
- <!--default status message-->
269
- <ul class="default-status">
270
- <li><?php _e('Nothing to report', $namespace); ?></li>
271
- </ul>
272
-
273
- <!--backup status messages-->
274
- <ul class="backup-status">
275
- <li class="preparing"><?php _e('Preparing for backup', $namespace); ?>...<span class='status-icon'><img class="preparing-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
276
- <li class='backupdb'><?php _e('Backing up database', $namespace); ?>...<span class='status-icon'><img class="backupdb-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
277
- <li class='infofile'><?php _e('Creating backup information file', $namespace); ?>...<span class='status-icon'><img class="infofile-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
278
- <li class='backup_themes'><?php _e('Backing up themes', $namespace); ?>...<span class='status-icon'><img class="backup_themes-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
279
- <li class='backup_plugins'><?php _e('Backing up plugins', $namespace); ?>...<span class='status-icon'><img class="backup_plugins-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
280
- <li class='backup_uploads'><?php _e('Backing up uploads', $namespace); ?>...<span class='status-icon'><img class="backup_uploads-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
281
- <li class='backup_other'><?php _e('Backing up everything else', $namespace); ?>...<span class='status-icon'><img class="backup_other-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
282
- <li class='validate_backup'><?php _e('Validating backup', $namespace); ?>...<span class='status-icon'><img class="validate_backup-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
283
- <li class='finalize_backup'><?php _e('Finalizing backup', $namespace); ?>...<span class='status-icon'><img class="finalize_backup-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span><span class='wpbackitup-warning'><?php _e('Warning', $namespace); ?></span></li>
284
- </ul>
285
-
286
- <!--Error status messages-->
287
- <ul class="backup-error">
288
- <!--Warning PlaceHolder-->
289
- </ul>
290
-
291
- <!--success messages-->
292
- <ul class="backup-success">
293
- <li class='isa_success'><?php _e('Backup completed successfully. ', $namespace); ?></li>
294
- </ul>
295
-
296
- <ul class="backup-warning">
297
- <!--Warning PlaceHolder-->
298
- </ul>
299
-
300
- </div>
301
-
302
- </div> <!--content-->
303
-
304
- <div id="sidebar">
305
-
306
- <!-- Display opt-in form if the user is unregistered -->
307
- <?php if (!$license_active) : ?>
308
- <?php if (!$is_lite_registered) : ?>
309
- <div class="widget">
310
- <h3 class="promo"><?php _e('Register WP BackItUp Lite', $namespace); ?></h3>
311
- <form action="" method="post" id="<?php echo $namespace; ?>-form">
312
- <?php wp_nonce_field($namespace . "-register-lite"); ?>
313
- <p><?php _e('Enter your email address to register WP BackItUp Lite. Registered users will receive <b>special offers</b> and access to our world class <b>support</b> team. <br /> <br />Premium customers only need to enter their license key in the section below. Registration is not required.', $namespace); ?></p>
314
- <input type="text" name="first_name" id="first_name" placeholder="first name" value="<?php echo($lite_registration_first_name) ?>" /><br/>
315
- <input type="text" name="email" id="email" placeholder="email address" value="<?php echo($lite_registration_email) ?>" />
316
- <div class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e("Register", $namespace) ?>" /></div>
317
- </form>
318
- </div>
319
- <?php else : ?>
320
- <div class="widget">
321
- <h3 class="promo"><?php _e('Get a license', $namespace); ?></h3>
322
- <p><?php _e('Tired of messing with FTP, MySQL and PHPMyAdmin? Restore your backups from this page in minutes or your money back', $namespace); ?>.</p>
323
- <?php echo($this->get_anchor_with_utm('Purchase a license for WP BackItUp','pricing-purchase','get+license','purchase')) ?>
324
- </div>
325
- <?php endif ?>
326
- <?php endif; ?>
327
-
328
- <!-- Display license key widget -->
329
- <div class="widget">
330
- <h3 class="promo"><?php _e('License v ' . $version, $namespace); ?></h3>
331
- <form action="" method="post" id="<?php echo $namespace; ?>-form">
332
- <?php wp_nonce_field($namespace . "-update-options"); ?>
333
- <?php
334
-
335
- $fontColor='green';
336
- if ($license_status=='valid')
337
- $fontColor='green';
338
-
339
- if ($license_status=='invalid')
340
- $fontColor='red';
341
-
342
- if ($license_status=='expired')
343
- $fontColor='orange';
344
-
345
- $license_message='';
346
- if (!empty($license_status)) {
347
- $license_message=' License Status: ' . $license_status;
348
- }
349
-
350
- if($license_active)
351
- echo '<p>' . $license_type_description .' License Key</p>';
352
- else
353
- echo '<p>Enter your license key to activate features.</p>';
354
- ?>
355
-
356
- <input type="text" name="data[license_key]" id="license_key" value="<?php _e($license_key, $namespace); ?>" />
357
- <div style="color:<?php _e($fontColor); ?>"><?php _e($license_message, $namespace); ?></div>
358
- <div style="color:<?php _e($fontColor); ?>"><?php _e($license_status_message, $namespace); ?></div>
359
-
360
- <?php if ($license_status=='expired'): ?>
361
- <div>License expired:&nbsp;<span style="color:red"><?php _e($formatted_expired_date, $namespace); ?></span></div>
362
- <?php endif; ?>
363
-
364
- <?php if ($license_active) : ?>
365
- <div class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e("Update", $namespace) ?>" /></div>
366
- <?php endif; ?>
367
-
368
- <?php if (!$license_active) : ?>
369
- <p class="submit"><input type="submit" name="Submit" class="button-secondary" value="<?php _e("Activate", $namespace) ?>" /></p>
370
- <?php endif; ?>
371
-
372
- <?php if ($license_status=='invalid' || $license_status==''): ?>
373
- <p>Purchase a <?php echo($this->get_anchor_with_utm('no-risk','pricing-purchase','license','no+risk'))?> license using the purchase link above.</p>
374
- <?php endif; ?>
375
-
376
- <?php if ($license_status=='expired'): ?>
377
- <div>License expired? <?php echo($this->get_anchor_with_utm('Renew Now ','documentation/faqs/expired-license','license','license+expired'))?> and save 20%.</div>
378
- <div>* Offer valid for a limited time!</div>
379
- <?php endif; ?>
380
- </form>
381
- </div>
382
-
383
- <!-- Display links widget -->
384
- <div class="widget">
385
- <h3 class="promo"><?php _e('Useful Links', $namespace); ?></h3>
386
- <ul>
387
- <?php if ($license_active) : ?>
388
- <li><?php echo($this->get_anchor_with_utm('Your account','your-account','useful+links','your+account'))?></li>
389
- <li><?php echo($this->get_anchor_with_utm('Upgrade your license','pricing-purchase','useful+links','upgrade+license'))?></li>
390
- <?php endif; ?>
391
- <li><?php echo($this->get_anchor_with_utm('Documentation','documentation','useful+links','help'))?></li>
392
-
393
- <?php if ($license_active || $is_lite_registered) : ?>
394
- <li><?php echo($this->get_anchor_with_utm('Get support','support' ,'useful+links','get+support'))?></li>
395
- <?php endif; ?>
396
-
397
- <li><?php echo($this->get_anchor_with_utm('Feature request','feature-request' ,'useful+links','feature+request'))?></li>
398
- <li>Have a suggestion? Why not submit a feature request.</li>
399
- </ul>
400
- </div>
401
-
402
- </div><!--Sidebar-->
403
-
404
- </div> <!--wrap-->
405
-
406
- <!--File download lists-->
407
- <span class="hidden">
408
- <?php add_thickbox(); ?>
409
- <!--File download lists-->
410
- <?php if ($backup_list!=false) : ?>
411
- <?php foreach ($backup_list as $folder) :
412
- $backup_name = $folder["backup_name"];
413
- $zip_files = $folder["zip_files"];
414
- $count=0;
415
- ?>
416
- <div id="<?php echo preg_replace('/[^A-Za-z0-9\-]/', '', $backup_name) ?>" style="display:none;">
417
- <h2>WP BackItUp Backup Set</h2>
418
- <p>Below are the archive files included in this backup set. Click the link to download.</p>
419
- <table id="datatable" class="widefat">
420
- <tbody>
421
- <?php foreach ($zip_files as $file) :
422
- ++$count;
423
- $class = $count % 2 == 0 ? '' : 'alternate';
424
- $row_id="row".$count;
425
- $zip_file = basename($file);
426
- ?>
427
- <tr id="<?php echo $row_id ?>" class="<?php echo $class ?>">
428
- <td><a href="<?php echo $zip_file ?>" class="downloadbackuplink"><?php echo $zip_file ?></a></td>
429
- </tr>
430
- <?php endforeach; ?>
431
- </tbody>
432
- </table>
433
- <?php endforeach; ?>
434
- </div>
435
- <?php endif; ?>
436
- <div id="new_backup" style="display:none;">
437
- <h2>WP BackItUp Backup Set</h2>
438
- <p>Please refresh this page to download your new backup files.</p>
439
- </div>
440
- </span>
441
- <!--End File download lists-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/views/restore.php DELETED
@@ -1,283 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- $page_title = $this->friendly_name . ' Restore';
4
- $namespace = $this->namespace;
5
-
6
- //Path Variables
7
- $backup_folder_root = WPBACKITUP__BACKUP_PATH .'/';
8
-
9
- $license_active = $this->license_active();
10
-
11
- //Make sure backup folder exists
12
- $backup_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER;
13
- $backup_folder_exists=false;
14
- if( !is_dir($backup_dir) ) {
15
- if (@mkdir($backup_dir, 0755)){
16
- $backup_folder_exists=true;
17
- }
18
- }else{
19
- $backup_folder_exists=true;
20
- }
21
-
22
- //Check restore folder folders
23
- $restore_dir = WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER;
24
- $restore_folder_exists=false;
25
- if( !is_dir($restore_dir) ) {
26
- if (@mkdir($restore_dir, 0755)){
27
- $restore_folder_exists=true;
28
- }
29
- }else{
30
- $restore_folder_exists=true;
31
- }
32
-
33
- $backup_list = $this->get_backup_list();
34
-
35
-
36
- $chunk_size = min(wp_max_upload_size()-1024, 1024*1024*2);
37
- $plupload_config = array(
38
- 'runtimes' => 'html5,flash,silverlight,html4',
39
- 'browse_button' => 'plupload-browse-button',
40
- 'container' => 'plupload-upload-ui',
41
- 'drop_element' => 'drag-drop-area',
42
- 'file_data_name' => 'async-upload',
43
- 'multiple_queues' => true,
44
- 'max_file_size' => '100Gb',
45
- 'chunk_size' => $chunk_size.'b',
46
- 'url' => admin_url('admin-ajax.php'),
47
- 'filters' => array(array('title' => __('Zip Files'), 'extensions' => 'zip')),
48
- 'multipart' => true,
49
- 'multi_selection' => true,
50
- 'urlstream_upload' => true,
51
- 'multipart_params' => array(
52
- '_wpnonce' => wp_create_nonce($namespace . '-upload'),
53
- 'action' => 'wp-backitup_plupload_action')
54
- );
55
-
56
- ?>
57
-
58
- <?php
59
- //Fatal Error - no backup folder
60
- if (!$backup_folder_exists) {
61
- echo '<div class="error"><p><strong>Error: Backup folder does not exist. Please contact ';
62
- echo($this->get_anchor_with_utm('support','support' ,'restore+error','no+backup+folder'));
63
- echo ' for assistance.</strong></p></div>';
64
- }
65
-
66
- //Fatal Error - no restore folder
67
- if (!$restore_folder_exists) {
68
- echo '<div class="error"><p><strong>Error: Restore folder does not exist. Please contact ';
69
- echo($this->get_anchor_with_utm('support','support' ,'restore+error','no+restore+folder'));
70
- echo ' for assistance.</strong></p></div>';
71
- }
72
- ?>
73
-
74
- <script type="text/javascript">var __namespace = '<?php echo $namespace; ?>';</script>
75
- <div class="wrap">
76
- <div id="wp-backitup-icon" class="icon32"><img src="<?php echo plugin_dir_url(dirname(__FILE__)); ?>images/icon32.png" alt="WP Backitup Icon" height="32" width="32" /></div>
77
- <h2><?php echo $page_title; ?></h2>
78
- <div id="content">
79
-
80
- <!--Available Backups section-->
81
- <div class="widget">
82
- <h3><i class="fa fa-cloud-download"></i> <?php _e('Available Backups', $namespace); ?></h3>
83
- <table class="widefat" id="datatable">
84
- <?php
85
-
86
- if ($backup_list!=false)
87
- {
88
- $i = 0;
89
- foreach ($backup_list as $file)
90
- {
91
- $backup_name = $file["backup_name"];
92
- $backup_datetime = get_date_from_gmt(date('Y-m-d H:i:s', $file["date_time"]), 'Y-m-d g:i a'); //Local Date Time
93
- $log_exists = $file["log_exists"];
94
- $class = $i % 2 == 0 ? 'class="alternate"' : '';
95
- ?>
96
- <tr <?php echo $class ?> id="row<?php echo $i; ?>">
97
- <td><?php echo $backup_name ?></td>
98
- <td>&nbsp;</td>
99
- <td><a href="#" title="<?php echo $backup_name; ?>" class="deleteRow" id="deleteRow<?php echo $i; ?>">Delete</a></td>
100
- <?php
101
- if ($this->license_active())
102
- {
103
- echo '<td><a href="#" title="' . $backup_name . '" class="restoreRow" id="restoreRow' . $i . '">Restore</a></td>';
104
- }
105
- ?>
106
- </tr>
107
- <?php
108
- $i++;
109
- }
110
- }
111
- else
112
- {
113
- echo '<tr id="nofiles"><td colspan="3">No backup archives found.</td></tr>';
114
- }
115
- ?>
116
- </table>
117
-
118
- <form id="restore-form" method="post" action="admin-post.php">
119
- <?php global $current_user; ?>
120
- <input type="hidden" name="user_id" value="<?php echo $current_user->ID; ?>" />
121
- <input type="hidden" name="is_selected" id="is_selected" value="0" />
122
- <input type="hidden" name="selected_file" id="selected_file" value="" />
123
- </form>
124
-
125
- <?php
126
- //Display restore note for lite customers
127
- if (!$this->license_active())
128
- {
129
- echo '<p>* The automated restore feature is only available to licensed customers. Please visit <a href="' . WPBACKITUP__SITE_URL .'" target="_blank">'. WPBACKITUP__SITE_URL .'</a> to get license WP BackItUp risk free for 30 days.</p>';
130
- }
131
- ?>
132
- </div>
133
-
134
- <!--Disable upload form if the user has not activated-->
135
- <?php
136
- if ($this->license_active())
137
- {
138
- ?>
139
- <div class="widget">
140
- <h3>
141
- <i class="fa fa-upload"></i> <?php _e('Upload', $namespace); ?>
142
- <i id="upload-backups-accordian" style="float:right" class="fa fa-angle-double-down"></i>
143
- </h3>
144
- <p><b><?php _e('Upload WP BackItUp archive(zip) files to add to your list of available backups.', $namespace); ?></b></p>
145
- <?php
146
- $max_upload = (int) (ini_get('upload_max_filesize'));
147
- $max_post = (int) (ini_get('post_max_size'));
148
- $memory_limit = (int) (ini_get('memory_limit'));
149
- $upload_mb = min($max_upload, $max_post, $memory_limit);
150
- $upload_bytes = $upload_mb * 1048576;
151
- ?>
152
- <p>
153
-
154
- </p>
155
-
156
- <script type="text/javascript">
157
- var wpbackitup_plupload_config=<?php echo json_encode($plupload_config); ?>;
158
- var site_url="<?php echo get_site_url(); ?>";
159
- </script>
160
-
161
- <div id="wpbackitup-plupload-modal" title="<?php _e('WP BackItUp - Upload backup files',$namespace); ?>" style="width: 75%; margin: 16px; display:none; margin-left: 100px;">
162
- <p style="max-width: 610px;"><em><?php _e("Backup files may be uploaded into WP BackItUp with this form." ,$namespace);?> <?php echo htmlspecialchars(__('They may also be uploaded manually into the WP BackItUp directory (wp-content/wpbackitup_backups) using FTP. When done uploading all backup files refresh this page.',$namespace));?></em></p>
163
- <?php
164
- global $wp_version;
165
- if (version_compare($wp_version, '3.3', '<')) {
166
- echo '<em>'.sprintf(__('This feature requires %s version %s or later', $namespace), 'WordPress', '3.3').'</em>';
167
- } else {
168
- ?>
169
- <div id="plupload-upload-ui" class ="drag-drop" style="width: 100%;">
170
- <div id="drag-drop-area">
171
- <div class="drag-drop-inside">
172
- <p class="drag-drop-info"><?php _e('Drop backup files here', $namespace); ?></p>
173
- <p><?php _ex('or', 'Uploader: Drop backup files here - or - Select Files'); ?></p>
174
- <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p>
175
- </div>
176
- </div>
177
- </div>
178
- <p style="max-width: 100%;"><em><?php _e("* Reload this page when done uploading to see new backups appear in the Available Backups section above. " ,$namespace);?> </em></p>
179
-
180
- <div id="filelist" class="media-item" style="width: 100%;"></div>
181
-
182
- <?php } ?>
183
-
184
- </div>
185
-
186
-
187
- </div>
188
- <?php } ?>
189
- <!--End of Upload form-->
190
-
191
-
192
- <div id="status" class="widget">
193
- <h3><i class="fa fa-check-square-o"></i> <?php _e('Status', $namespace); ?></h3>
194
-
195
- <!--default status message-->
196
- <ul class="default-status">
197
- <li><?php _e('Nothing to report', $namespace); ?></li>
198
- </ul>
199
-
200
- <!--Upload status messages-->
201
- <ul class="upload-status">
202
- <li><span class='upload-status'></span></li>
203
- </ul>
204
-
205
- <!--restore status messages-->
206
- <ul class="restore-status">
207
- <li class="preparing"><?php _e('Preparing for restore', $namespace); ?>...<span class='status-icon'><img class="preparing-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
208
- <li class="unzipping"><?php _e('Unzipping backup set', $namespace); ?>...<span class='status-icon'><img class="unzipping-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
209
- <li class="validation"><?php _e('Validating backup file', $namespace); ?>...<span class='status-icon'><img class="validation-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
210
- <li class="deactivate_plugins"><?php _e('Deactivating plugins', $namespace); ?>...<span class='status-icon'><img class="deactivate_plugins-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
211
- <li class="restore_point"><?php _e('Creating database restore point', $namespace); ?>...<span class='status-icon'><img class="restore_point-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
212
- <li class="stage_wpcontent"><?php _e('Staging content files', $namespace); ?>...<span class='status-icon'><img class="stage_wpcontent-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
213
- <li class="restore_wpcontent"><?php _e('Restoring content files', $namespace); ?>...<span class='status-icon'><img class="stage_wpcontent-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
214
- <li class="restore_database"><?php _e('Restoring database', $namespace); ?>...<span class='status-icon'><img class="restore_database-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
215
- <li class="update_user"><?php _e('Updating current user info', $namespace); ?>...<span class='status-icon'><img class="update_user-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
216
- <li class="update_site_info"><?php _e('Updating site URL', $namespace); ?>...<span class='status-icon'><img class="update_site_info-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
217
- <li class="activate_plugins"><?php _e('Activating plugins', $namespace); ?>...<span class='status-icon'><img class="activate_plugins-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
218
- <li class="update_permalinks"><?php _e('Updating permalinks', $namespace); ?>...<span class='status-icon'><img class="update_permalinks-icon" src="<?php echo WPBACKITUP__PLUGIN_URL . "/images/loader.gif"; ?>" height="16" width="16" /></span><span class='status'><?php _e('Done', $namespace); ?></span><span class='fail error'><?php _e('Failed', $namespace); ?></span></li>
219
- </ul>
220
- <p>
221
-
222
- <!--restore error messages-->
223
- <div class="restore-errors">
224
- <span class="error201"><div class='isa_error'><?php _e('Error 201: No file selected', $namespace); ?>.</div></span>
225
- <span class="error202"><div class='isa_error'><?php _e('Error 202: Your file could not be uploaded', $namespace); ?>.</div></span>
226
- <span class="error203"><div class='isa_error'><?php _e('Error 203: Your backup could not be unzipped', $namespace); ?>.</div></span>
227
- <span class="error204"><div class='isa_error'><?php _e('Error 204: Your backup appears to be invalid. Please ensure you selected a valid backup', $namespace); ?>.</div></span>
228
- <span class="error205"><div class='isa_error'><?php _e('Error 205: Cannot create restore point', $namespace); ?>.</div></span>
229
- <span class="error206"><div class='isa_error'><?php _e('Error 206: Unable to connect to your database', $namespace); ?>.</div></span>
230
- <span class="error207"><div class='isa_error'><?php _e('Error 207: Unable to get current site URL from database. Please try again', $namespace); ?>.</div></span>
231
- <span class="error208"><div class='isa_error'><?php _e('Error 208: Unable to get current home URL from database. Please try again', $namespace); ?>.</div></span>
232
- <span class="error209"><div class='isa_error'><?php _e('Error 209: Unable to get current user ID from database. Please try again', $namespace); ?>.</div></span>
233
- <span class="error210"><div class='isa_error'><?php _e('Error 210: Unable to get current user password from database. Please try again', $namespace); ?>.</div></span>
234
- <span class="error211"><div class='isa_error'><?php _e('Error 211: Unable to get current user email from database. Please try again', $namespace); ?>.</div></span>
235
- <span class="error212"><div class='isa_error'><?php _e('Error 212: Unable to import your database. This may require importing the file manually', $namespace); ?>.</div></span>
236
- <span class="warning213"><div class='isa_warning'><?php _e('Warning 213: Unable to update your site URL value. Please check your Wordpress general settings to make sure your Site and Wordpress URLs are correct', $namespace); ?>.</div></span>
237
- <span class="warning214"><div class='isa_warning'><?php _e('Warning 214: Unable to update your home URL value. Please check your Wordpress general settings to make sure your Site and Wordpress URLs are correct', $namespace); ?>.</div></span>
238
- <span class="warning215"><div class='isa_warning'><?php _e('Warning 215: Unable to update your user information. This may require you to login with the admin username and password that was used when the backup was created', $namespace); ?>.</div></span>
239
- <span class="error216"><div class='isa_error'><?php _e('Error 216: Database not found in backup', $namespace); ?>.</div></span>
240
- <span class="warning217"><div class='isa_warning'><?php _e('Warning 217: Unable to remove existing wp-content directory', $namespace); ?>.</div></span>
241
- <span class="error218"><div class='isa_error'><?php _e('Error 218: Unable to create new wp-content directory. Please check your CHMOD settings in /wp-content/', $namespace); ?>.</div></span>
242
- <span class="error219"><div class='isa_error'><?php _e('Error 219: Unable to import wp-content. Please try again', $namespace); ?>.</div></span>
243
- <span class="warning220"><div class='isa_warning'><?php _e('Warning 220: Unable to cleanup import directory. No action is required', $namespace); ?>.</div></span>
244
- <span class="error221"><div class='isa_error'><?php _e('Error 221: Table prefix value in wp-config.php is different from backup. This MUST be changed in your wp-config.php file before you will be able to restore your site. See www.wpbackitup.com <a href ="http://www.wpbackitup.com/documentation/faqs/wordpress-table-prefix" target="_blank" > FAQs</a> for more info.', $namespace); ?>.</div></span>
245
- <span class='error222'><div class='isa_error'><?php _e('Error 222: Unable to create restore folder', $namespace); ?>.</div></span>
246
- <span class='error223'><div class='isa_error'><?php _e('Error 223: An error occurred during the restore. WP BackItUp attempted to restore the database to its previous state but were unsuccessful. Please contact WP BackItUp customer support and do not attempt to perform any further restores', $namespace); ?>.</div></span>
247
- <span class='error224'><div class='isa_error'><?php _e('Error 224: An error occurred during the restore, however, we have successfully restored your database to the previous state', $namespace); ?>.</div></span>
248
- <span class='error225'><div class='isa_error'><?php _e('Error 225: Restore option is only available to licensed WP BackItUp users', $namespace); ?>.</div></span>
249
- <span class='error226'><div class='isa_error'><?php _e('Error 226: Restore cannot proceed because your backup was created using a different version of Wordpress', $namespace); ?>.</div></span>
250
- <span class='error227'><div class='isa_error'><?php _e('Error 227: Restore cannot proceed because your backup was created using a different version of WP BackItUp. Please contact WP BackItUp support to help convert this backup to the current version', $namespace); ?>.</div></span>
251
- <span class="error230"><div class='isa_error'><?php _e('Error 230: WP BackItUp ran into unexpected errors during the database restore. However, we were able to successfully revert the database back to its original state . This error may require importing the database manually', $namespace); ?>.</div></span>
252
- <span class="error235"><div class='isa_error'><?php _e('Error 235: WP BackItUp is not able to proceed because there is no zip utility available. Please contact support', $namespace); ?>.</div></span>
253
- <span class="error250"><div class='isa_error'><?php _e('Error 250: WP BackItUp is unable to begin the restore because a backup is running. Please wait for the backup to complete and then try again', $namespace); ?>.</div></span>
254
-
255
- <span class="error251"><div class='isa_error'><?php _e('Error 251: WP BackItUp is unable to begin the restore because the backup manifest is empty', $namespace); ?>.</div></span>
256
- <span class="error252"><div class='isa_error'><?php _e('Error 252: At least one zip file is missing from your backup set. Please make sure to upload all zip files that were part of this backup', $namespace); ?>.</div></span>
257
- <span class="error253"><div class='isa_error'><?php _e('Error 253: Backup set contains a zip file that is not in the manifest. Please make sure to upload only zip files that were part of this backup', $namespace); ?>.</div></span>
258
-
259
- <span class="warning300"><div class='isa_warning'><?php _e('Warning 300: Unable to restore all Wordpress content. Please review your restore logs to see what WP BackItUp was unable to restore', $namespace); ?>.</div></span>
260
- <span class="warning305"><div class='isa_warning'><?php _e('Warning 305: Unable to restore all plugins. Please review your restore logs to see what WP BackItUp was unable to restore', $namespace); ?>.</div></span>
261
-
262
- <span class="error2001"><div class='isa_error'><?php _e('Error 2001: Unable to prepare site for restore', $namespace); ?>.</div></span>
263
- <span class="error2002"><div class='isa_error'><?php _e('Error 2002: Unable to unzip backup', $namespace); ?>.</div></span>
264
- <span class="error2003"><div class='isa_error'><?php _e('Error 2003: Unable to validate backup', $namespace); ?>.</div></span>
265
- <span class="error2004"><div class='isa_error'><?php _e('Error 2004: Unable to create restore point', $namespace); ?>.</div></span>
266
- <span class="error2005"><div class='isa_error'><?php _e('Error 2005: Unable to stage wp-content', $namespace); ?>.</div></span>
267
- <span class="error2006"><div class='isa_error'><?php _e('Error 2006: Unable to restore content files', $namespace); ?>.</div></span>
268
- <span class="error2007"><div class='isa_error'><?php _e('Error 2007: Unable to restore database', $namespace); ?>.</div></span>
269
- <span class="error2999"><div class='isa_error'><?php _e('Error 2999: Unexpected error encountered', $namespace); ?>.</div></span>
270
-
271
-
272
- </div>
273
-
274
- <!--restore success messages-->
275
- <div class="restore-success">
276
- <span class='finalinfo'><div class='isa_success'><?php _e('Restore completed successfully. If you are prompted to login please do so with your current username and password', $namespace); ?>.</div></span>
277
- </div>
278
-
279
- </div>
280
-
281
- </div>
282
-
283
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/views/settings.php DELETED
@@ -1,104 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- $page_title = $this->friendly_name . ' Settings';
4
- $namespace = $this->namespace;
5
-
6
- $license_active = $this->license_active();
7
- $is_lite_registered = $this->is_lite_registered();
8
-
9
- $backup_batch_size=$this->backup_batch_size();
10
-
11
- //Hold off on this for a bit
12
- $disabled='';
13
- // if (!$license_active && !$is_lite_registered){
14
- // $disabled='disabled';
15
- // }
16
-
17
- ?>
18
-
19
- <div class="wrap">
20
- <h2><?php echo $page_title; ?></h2>
21
- <div id="content">
22
-
23
-
24
- <!-- Display Settings widget -->
25
- <form action="admin-post.php" method="post" id="<?php echo $namespace; ?>-form">
26
- <?php wp_nonce_field($namespace . "-update-options"); ?>
27
- <div class="widget">
28
- <h3 class="promo"><i class="fa fa-envelope"></i> Email Notifications</h3>
29
- <p><b>Please enter your email address if you would like to receive backup email notifications.</b></p>
30
- <p><?php _e('Backup email notifications will be sent for every backup and will contain status information related to the backup.', $namespace); ?></p>
31
- <p><input type="text" name="data[notification_email]" value="<?php echo $this->notification_email(); ?>" size="30"></p>
32
- <div class="submit"><input <?php echo($disabled) ; ?> type="submit" name="Save_Email" class="button-primary" value="<?php _e("Save", $namespace) ?>" />
33
- <!-- --><?php //if (!$license_active && !$is_lite_registered) : ?>
34
- <!-- * Please register WP BackItUp to use this feature.-->
35
- <!-- --><?php //endif; ?>
36
- </div>
37
- <?php
38
- if ( false !== ( $msg = get_transient('settings-error-email') ) && $msg)
39
- {
40
- echo '<p class="error">'.$msg.'</p>';
41
- delete_transient('settings-error-email');
42
- }
43
- ?>
44
- </div>
45
-
46
-
47
- <div class="widget">
48
- <h3 class="promo"><i class="fa fa-trash-o"></i> Backup Retention</h3>
49
- <p><b>Enter the number of backup archives that you would like to remain on the server.</b></p>
50
- <p>Many hosts limit the amount of space that you can take up on their servers. This option tells
51
- WP BackItUp the maximum number of backup archives that should remain on your hosts server. Don't worry, we will
52
- always remove the oldest backup archives first.</p>
53
- <p><input type="text" name="data[backup_retained_number]" value="<?php echo $this->backup_retained_number(); ?>" size="4"></p>
54
- <div class="submit"><input type="submit" name="Save_Retention" class="button-primary" value="<?php _e("Save", $namespace) ?>" /></div>
55
- <?php
56
- if ( false !== ( $msg = get_transient('settings-error-number') ) && $msg)
57
- {
58
- echo '<p class="error">'.$msg.'</p>';
59
- delete_transient('settings-error-number');
60
- }
61
-
62
- if ( false !== ( $msg = get_transient('settings-license-error') ) && $msg)
63
- {
64
- echo '<p class="error">'.$msg.'</p>';
65
- delete_transient('settings-license-error');
66
- }
67
- ?>
68
- </div>
69
-
70
- <div class="widget">
71
- <h3 class="promo"><i class="fa fa-file-text-o"></i> Turn on logging?</h3>
72
- <p><input type="radio" name="data[logging]" value="true" <?php if ($this->logging()) echo 'checked'; ?>> <label><?php _e('Yes', $namespace); ?></label></p>
73
- <p><input type="radio" name="data[logging]" value="false" <?php if (!$this->logging()) echo 'checked'; ?>> <label><?php _e('No', $namespace); ?></label></p>
74
- <p><?php _e('This option should only be turned on when troubleshooting issues with WPBackItUp support.', $namespace); ?></p>
75
- <p class="submit"><input type="submit" name="Save_Logging" class="button-primary" value="<?php _e("Save", $namespace) ?>" /></p>
76
- </div>
77
-
78
- <div class="widget">
79
- <h3 class="promo"><i class="fa fa-wrench"></i> Advanced Settings</h3>
80
- <p><b>These options should only be changed when working with WP BackItUp support.</b></p>
81
- <input name="data[backup_batch_size]" id="wpbackitup_batch_size" type="text" size="2" value="<?php echo $backup_batch_size; ?>"/>
82
- <label> Backup batch size</label>
83
- <p class="submit"><input type="submit" name="Save_AdvancedSettings" class="button-primary" value="<?php _e("Save", $namespace) ?>" />
84
- <?php
85
- if ( false !== ( $msg = get_transient('batch_size_settings-error-number') ) && $msg)
86
- {
87
- echo '<p class="error">'.$msg.'</p>';
88
- delete_transient('batch_size_settings-error-number');
89
- }
90
- ?>
91
- </p>
92
- </div>
93
-
94
- <!--Debug Widget-->
95
- <?php if (WP_DEBUG===true) :?>
96
- <div class="widget">
97
- <h3><i class="fa fa-wrench"></i> <?php _e('Debug', $namespace); ?></h3>
98
- <div id="php"><p>Debugging is turned on in your wp-config.php file and should only be used when troubleshooting issues on your site.</p></div>
99
- </div>
100
- <?php endif; ?>
101
-
102
- </form>
103
- </div>
104
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/views/support.php DELETED
@@ -1,85 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- $page_title = $this->friendly_name . ' Support';
4
- $namespace = $this->namespace;
5
-
6
- $license_active = $this->license_active();
7
- $is_lite_registered = $this->is_lite_registered();
8
-
9
- $support_email =$this->support_email();
10
-
11
- $disabled='';
12
- // if (!$license_active && !$is_lite_registered){
13
- // $disabled='disabled';
14
- // }
15
-
16
- ?>
17
- <?php if (!empty($_GET["s"]) && '1' == $_GET["s"]) : ?>
18
- <div class="updated">
19
- <p><?php _e( 'Support email sent successfully!', $namespace ); ?></p>
20
- </div>
21
- <?php endif; ?>
22
-
23
- <div class="wrap">
24
- <h2><?php echo $page_title; ?></h2>
25
- <div id="content">
26
-
27
-
28
- <!-- Display Settings widget -->
29
- <form action="admin-post.php" method="post" id="<?php echo $namespace; ?>-support-form">
30
- <?php wp_nonce_field($namespace . "-support-form"); ?>
31
- <div class="widget">
32
- <h3 class="promo"><i class="fa fa-envelope"></i> Email Logs to Support</h3>
33
- <p><b>Please use this form to send your log files to support. You may also use this form to open a support ticket.</b></p>
34
- <p><?php _e('We will respond to this request via email using the email address you enter below.', $namespace); ?></p>
35
- <p><input <?php echo($disabled) ; ?> type="text" name="support_email" value="<?php echo $support_email; ?>" size="30" placeholder="your email address">
36
- <?php
37
- if ( false !== ( $msg = get_transient('error-support-email') ) && $msg)
38
- {
39
- echo '<span class="error">'.$msg.'</span>';
40
- delete_transient('error-support-email');
41
- }
42
- ?>
43
- </p>
44
-
45
- <p><input <?php echo($disabled) ; ?> type="text" name="support_subject" value="<?php echo get_transient('support_subject'); ?>" size="30" placeholder="problem subject">
46
- <?php
47
- if ( false !== ( $msg = get_transient('error-support-subject') ) && $msg)
48
- {
49
- echo '<span class="error">'.$msg.'</span>';
50
- delete_transient('error-support-subject');
51
- }
52
- ?>
53
-
54
- </p>
55
-
56
- <p><textarea <?php echo($disabled) ; ?> name="support_body" rows="4" cols="50" style="width:450px;height:150px;" placeholder="problem description"><?php echo get_transient('support_body'); ?></textarea>
57
- <?php
58
- if ( false !== ( $msg = get_transient('error-support-body') ) && $msg)
59
- {
60
- echo '<span class="error">'.$msg.'</span>';
61
- delete_transient('error-support-body');
62
- }
63
- ?>
64
-
65
- </p>
66
- <input <?php echo($disabled) ; ?> type="checkbox" name="support_include_logs" id="support_include_logs" value="1" checked> <label for="support_include_logs">send logs</label><br>
67
-
68
- <div class="submit"><input <?php echo($disabled) ; ?> type="submit" name="send_ticket" class="button-primary" value="<?php _e("Send", $namespace) ?>" />
69
- <?php if (!$license_active) : ?>
70
- * Premium customers receive priority support.
71
- <?php endif; ?>
72
- </div>
73
-
74
- <?php
75
- if ( false !== ( $msg = get_transient('settings-error-email') ) && $msg)
76
- {
77
- echo '<p class="error">'.$msg.'</p>';
78
- delete_transient('settings-error-email');
79
- }
80
- ?>
81
- </div>
82
-
83
- </form>
84
- </div>
85
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.0/wp-backitup.php DELETED
@@ -1,141 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
- /*
12
- Plugin Name: WP Backitup
13
- Plugin URI: http://www.wpbackitup.com
14
- Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
15
- Version: 1.10.0
16
- Author: Chris Simmons
17
- Author URI: http://www.wpbackitup.com
18
- License: GPL3
19
-
20
- Copyright 2012-2014 WPBackItUp (email : support@wpbackitup.com)
21
-
22
- This program is free software: you can redistribute it and/or modify
23
- it under the terms of the GNU General Public License as published by
24
- the Free Software Foundation, either version 3 of the License, or
25
- (at your option) any later version.
26
-
27
- This program is distributed in the hope that it will be useful,
28
- but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- GNU General Public License for more details.
31
-
32
- You should have received a copy of the GNU General Public License
33
- along with this program. If not, see <http://www.gnu.org/licenses/>.
34
- */
35
-
36
- define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
37
- define( 'WPBACKITUP__VERSION', '1.10.0');
38
- define( 'WPBACKITUP__DEBUG', false );
39
- define( 'WPBACKITUP__MINIMUM_WP_VERSION', '3.0' );
40
- define( 'WPBACKITUP__ITEM_NAME', 'WP Backitup' );
41
- define( 'WPBACKITUP__FRIENDLY_NAME', 'WP BackItUp' );
42
-
43
- define( 'WPBACKITUP__CONTENT_PATH', WP_CONTENT_DIR );
44
-
45
- define( 'WPBACKITUP__SITE_URL', 'http://www.wpbackitup.com');
46
- define( 'WPBACKITUP__SECURESITE_URL', 'https://www.wpbackitup.com' );
47
-
48
- define( 'WPBACKITUP__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
49
- define( 'WPBACKITUP__PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
50
- define( 'WPBACKITUP__PLUGIN_FOLDER',basename(dirname(__FILE__)));
51
-
52
- define( 'WPBACKITUP__BACKUP_FOLDER', 'wpbackitup_backups' );
53
- define( 'WPBACKITUP__BACKUP_URL', content_url() . "/" .WPBACKITUP__BACKUP_FOLDER);
54
- define( 'WPBACKITUP__BACKUP_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__BACKUP_FOLDER);
55
- define( 'WPBACKITUP__UPLOAD_FOLDER','TMP_Uploads');
56
- define( 'WPBACKITUP__UPLOAD_PATH',WPBACKITUP__BACKUP_PATH . '/' .WPBACKITUP__UPLOAD_FOLDER);
57
-
58
- define( 'WPBACKITUP__RESTORE_FOLDER', 'wpbackitup_restore' );
59
- define( 'WPBACKITUP__RESTORE_PATH',WPBACKITUP__CONTENT_PATH . '/' . WPBACKITUP__RESTORE_FOLDER);
60
-
61
- define( 'WPBACKITUP__PLUGINS_ROOT_PATH',WP_PLUGIN_DIR );
62
- define( 'WPBACKITUP__THEMES_ROOT_PATH',get_theme_root() );
63
- define( 'WPBACKITUP__THEMES_FOLDER',basename(get_theme_root()));
64
-
65
- define( 'WPBACKITUP__SQL_DBBACKUP_FILENAME', 'db-backup.sql');
66
-
67
- define( 'WPBACKITUP__BACKUP_IGNORE_LIST', WPBACKITUP__BACKUP_FOLDER .',' .WPBACKITUP__RESTORE_FOLDER .',updraft*,wp-clone*,backwpup*,backupwordpress*,cache,backupcreator*,backupbuddy*');
68
- define( 'WPBACKITUP__TASK_TIMEOUT_SECONDS', 300);//300 = 5 minutes
69
- define( 'WPBACKITUP__SCRIPT_TIMEOUT_SECONDS', 900);//900 = 15 minutes
70
-
71
- define( 'WPBACKITUP__BACKUP_RETAINED_DAYS', 5);//5 days
72
- define( 'WPBACKITUP__SUPPORT_EMAIL', 'support@wpbackitup.com');
73
-
74
- define( 'WPBACKITUP__ZIP_MAX_FILE_SIZE', 524288000); //524288000; # 500Mb
75
- define( 'WPBACKITUP__THEMES_BATCH_SIZE', 5000); //~100kb each = 5000*100 = 500000 kb = 500 mb
76
- define( 'WPBACKITUP__PLUGINS_BATCH_SIZE', 5000); //~100kb each = 5000*100 = 500000 kb = 500 mb
77
- define( 'WPBACKITUP__OTHERS_BATCH_SIZE', 500); //~100kb each = 5000*100 = 500000 kb = 500 mb
78
- define( 'WPBACKITUP__UPLOADS_BATCH_SIZE', 500); //anyones guess here
79
-
80
- register_activation_hook( __FILE__, array( 'WPBackitup_Admin', 'activate' ) );
81
- register_deactivation_hook( __FILE__, array( 'WPBackitup_Admin', 'deactivate' ) );
82
-
83
-
84
- function wpbackitup_modify_cron_schedules($schedules) {
85
- $schedules['weekly'] = array('interval' => 604800, 'display' => 'Once Weekly');
86
- $schedules['monthly'] = array('interval' => 2592000, 'display' => 'Once Monthly');
87
- $schedules['every4hours'] = array('interval' => 14400, 'display' => sprintf(__('Every %s hours', 'wpbackitup'), 4));
88
- $schedules['every8hours'] = array('interval' => 28800, 'display' => sprintf(__('Every %s hours', 'wpbackitup'), 8));
89
- return $schedules;
90
- }
91
-
92
- add_filter('cron_schedules', 'wpbackitup_modify_cron_schedules', 30);
93
-
94
- function wpbackitup_custom_post_status(){
95
- register_post_status( 'queued', array(
96
- 'public' => false,
97
- 'exclude_from_search' => false,
98
- 'show_in_admin_all_list' => false,
99
- 'show_in_admin_status_list' => true,
100
- ));
101
-
102
- register_post_status( 'active', array(
103
- 'public' => false,
104
- 'exclude_from_search' => false,
105
- 'show_in_admin_all_list' => false,
106
- 'show_in_admin_status_list' => true,
107
- ));
108
-
109
- register_post_status( 'error', array(
110
- 'public' => false,
111
- 'exclude_from_search' => false,
112
- 'show_in_admin_all_list' => false,
113
- 'show_in_admin_status_list' => true,
114
- ));
115
-
116
- register_post_status( 'complete', array(
117
- 'public' => false,
118
- 'exclude_from_search' => false,
119
- 'show_in_admin_all_list' => false,
120
- 'show_in_admin_status_list' => true,
121
- ));
122
-
123
- }
124
- add_action( 'init', 'wpbackitup_custom_post_status' );
125
-
126
- // Admin class will not be instantiate if any of these conditions are met
127
- if (!is_admin()
128
- && (!defined('DOING_CRON') || !DOING_CRON)
129
- && (!defined('XMLRPC_REQUEST') || !XMLRPC_REQUEST)
130
- && empty($_SERVER['SHELL'])
131
- && empty($_SERVER['USER'])) {
132
-
133
- return; //END HERE
134
- }
135
-
136
- require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-wpbackitup-admin.php' );
137
- require_once( WPBACKITUP__PLUGIN_PATH .'/lib/includes/class-logger.php' );
138
-
139
- global $WPBackitup;
140
- $WPBackitup = WPBackitup_Admin::get_instance();
141
- $WPBackitup->initialize();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/css/wpbackitup_admin.css DELETED
@@ -1,126 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel Stylesheets
3
- *
4
- * @version 1.4.0
5
- * @since 1.0.1
6
- */
7
-
8
- /* Global */
9
-
10
- .error { color: #ff0000;}
11
- .warning { color: #FEEFB3;}
12
- .wpbackitup-warning { color: #FF8000;}
13
-
14
- .isa_info, .isa_success, .isa_warning, .isa_error {
15
- border: 1px solid;
16
- margin: 10px 0px;
17
- padding:15px 10px 15px 50px;
18
- background-repeat: no-repeat;
19
- background-position: 10px center;-moz-border-radius:.5em;
20
- -webkit-border-radius:.5em;
21
- border-radius:.5em;
22
-
23
- }
24
- .isa_info {
25
- color: #00529B;
26
- background-color: #BDE5F8;
27
- background-image: url('../images/info.png');
28
- }
29
- .isa_success {
30
- color: #4F8A10;
31
- background-color: #DFF2BF;
32
- background-image:url('../images/success.png');
33
- }
34
- .isa_warning {
35
- color: #9F6000;
36
- background-color: #FEEFB3;
37
- background-image: url('../images/warning.png');
38
- }
39
- .isa_error {
40
- color: #D8000C;
41
- background-color: #FFBABA;
42
- background-image: url('../images/error.png');
43
- }
44
-
45
- p {line-height: 1.4em;}
46
-
47
- td {padding: 0;}
48
-
49
- h3 {
50
- margin: 0;
51
- padding: 0 0 0 0;
52
- border-bottom: 1px solid #eee;
53
- }
54
-
55
- .wp-backitup-iframe {
56
- height: 0;
57
- margin: 0;
58
- padding: 0;
59
- position: absolute;
60
- top: 0;
61
- right: 0;
62
- width: 0;
63
- z-index: -1;
64
- }
65
-
66
- .submit { padding: 0; }
67
-
68
-
69
- /* Content */
70
- #content {
71
- float: left;
72
- width: 65%;
73
- }
74
-
75
- #content input[type="text"], #content input[type="file"] {padding: 0;}
76
-
77
- .status-icon {
78
- display: inline;
79
- height: 16px;
80
- position: relative;
81
- top: 3px;
82
- left: 5px;
83
- visibility: hidden;
84
- width: 16px;
85
- }
86
-
87
- /** Status Reporting **/
88
- .backup-status,
89
- .backup-status span,
90
-
91
- .backup-errors,
92
- .backup-errors div,
93
- .backup-error,
94
-
95
- .backup-warning,
96
- .backup-warning div,
97
-
98
- .backup-success,
99
- .backup-success div,
100
-
101
- .restore-status,
102
- .restore-status span,
103
-
104
- .restore-errors,
105
- .restore-errors div,
106
-
107
- .restore-success,
108
- .restore-success div,
109
-
110
- .upload-status,
111
- .upload-status span
112
- {
113
- display: none;
114
- }
115
-
116
- /* Sidebar */
117
- #sidebar {
118
- float: right;
119
- width: 30%;
120
- }
121
-
122
- .widget {
123
- padding: 1em;
124
- background-color: white;
125
- margin: 20px;
126
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/images/error.png DELETED
Binary file
tags/1.10.1/images/icon.png DELETED
Binary file
tags/1.10.1/images/icon32.png DELETED
Binary file
tags/1.10.1/images/index.html DELETED
File without changes
tags/1.10.1/images/info.png DELETED
Binary file
tags/1.10.1/images/loader.gif DELETED
Binary file
tags/1.10.1/images/success.png DELETED
Binary file
tags/1.10.1/images/warning.png DELETED
Binary file
tags/1.10.1/index.html DELETED
File without changes
tags/1.10.1/js/index.html DELETED
File without changes
tags/1.10.1/js/wpbackitup_admin.js DELETED
@@ -1,1085 +0,0 @@
1
- /**
2
- * WP Backitup Admin Control Panel JavaScripts
3
- *
4
- * @version 1.4.0
5
- * @since 1.0.1
6
- */
7
-
8
- (function($){
9
- var namespace = 'wp-backitup';
10
-
11
- //Add View Log Click event to backup page
12
- wpbackitup_add_viewlog_onclick();
13
-
14
- //Add download backup Click event to backup page
15
- wpbackitup_add_downloadbackup_onclick();
16
-
17
- /* define logreader variables */
18
- var wpbackitup_restore_status_reader = {
19
- action: wpbackitup_get_action_name('restore_status_reader')
20
- };
21
-
22
- var wpbackitup_backup_status_reader = {
23
- action: wpbackitup_get_action_name('backup_status_reader')
24
- };
25
-
26
- //UPLOADS
27
- try {
28
- plupload_init(wpbackitup_plupload_config);
29
- } catch (err) {
30
- console.log(err);
31
- }
32
-
33
- $( "#scheduled-backups-accordian" ).click(function() {
34
-
35
- scheduled_backups=$("#scheduled-backups");
36
- scheduled_backups_button = $( "#scheduled-backups-accordian");
37
-
38
- if ($(this).is(".fa-angle-double-down")){
39
- scheduled_backups.fadeIn( "slow" )
40
- scheduled_backups_button.toggleClass( "fa-angle-double-down", false);
41
- scheduled_backups_button.toggleClass( "fa-angle-double-up", true);
42
- } else{
43
- scheduled_backups_button.toggleClass( "fa-angle-double-down", true);
44
- scheduled_backups_button.toggleClass( "fa-angle-double-up", false);
45
- scheduled_backups.fadeOut( "slow" )
46
- }
47
-
48
- });
49
-
50
- $( "#upload-backups-accordian" ).click(function() {
51
-
52
- upload_backups=$("#wpbackitup-plupload-modal");
53
- upload_backups_button = $( "#upload-backups-accordian");
54
-
55
- if ($(this).is(".fa-angle-double-down")){
56
- upload_backups.fadeIn( "slow" )
57
- upload_backups_button.toggleClass( "fa-angle-double-down", false);
58
- upload_backups_button.toggleClass( "fa-angle-double-up", true);
59
- } else{
60
- upload_backups_button.toggleClass( "fa-angle-double-down", true);
61
- upload_backups_button.toggleClass( "fa-angle-double-up", false);
62
- upload_backups.fadeOut( "slow" )
63
- }
64
-
65
- });
66
-
67
- //binds to onchange event of the upload file input field
68
- $('#wpbackitup-zip').bind('change', function() {
69
-
70
- //this.files[0].size gets the size of your file.
71
- var upload_file_size = this.files[0].size;
72
- var max_file_size = $('#maxfilesize').val();
73
-
74
- //IF Not supported by browser just check on server
75
- if (upload_file_size == 'undefined' ||
76
- max_file_size == 'undefined' ||
77
- upload_file_size == '' ||
78
- max_file_size =='')
79
- {
80
- return;
81
- }
82
-
83
- if (upload_file_size > max_file_size){
84
- alert('The backup you have selected exceeds what your host allows you to upload.');
85
- $("#wpbackitup-zip").val("");
86
- }
87
- });
88
-
89
-
90
-
91
- function wpbackitup_add_viewlog_onclick(){
92
- $(".viewloglink").click(function(){
93
- var href = $(this).attr("href");
94
- $("#backup_name").val(href);
95
- $("#viewlog").submit();
96
- return false;
97
- });
98
- }
99
-
100
- function wpbackitup_add_downloadbackup_onclick(){
101
- $(".downloadbackuplink").click(function(){
102
- var href = $(this).attr("href");
103
- $("#backup_file").val(href);
104
- $("#download_backup").submit();
105
- return false;
106
- });
107
- }
108
-
109
- /* get restore status */
110
- function wpbackitup_get_restore_status() {
111
- $.post(ajaxurl, wpbackitup_restore_status_reader, function(response) {
112
- /* Get response from log reader */
113
- var xmlObj = $(response);
114
-
115
- /* For each response */
116
- xmlObj.each(function() {
117
-
118
- /* Select correct status */
119
- var attributename = "." + $(this).attr('class');
120
- var icon_attributename = "." + $(this).attr('class') + '-icon';
121
-
122
- //Hide all
123
- if ( $(this).html() == 0 ) {
124
-
125
- $(attributename).find(".status").hide();
126
- $(attributename).find(".status-icon").hide();
127
-
128
- }
129
-
130
- //Processing
131
- if ( $(this).html() == 1 ) {
132
-
133
- $(icon_attributename).css('visibility', 'visible');
134
- $(attributename).find(".status").fadeOut(200);
135
- $(attributename).find(".status-icon").fadeIn(1500);
136
-
137
- }
138
-
139
- //Done
140
- if ( $(this).html() == 2 ) {
141
-
142
- /* If status returns 1, display 'Done' or show detailed message */
143
- $(attributename).find(".status-icon").fadeOut(200);
144
- $(attributename).find(".status").fadeIn(1500);
145
-
146
- }
147
-
148
- //Fatal Error
149
- if ( $(this).html() == -1 ) {
150
-
151
- $(attributename).find(".status-icon").fadeOut(200);
152
- $(attributename).find(".fail").fadeIn(1500);
153
- $(attributename).find(".isa_error").fadeIn(1500);
154
-
155
- /* Stop status reader */
156
- clearInterval(window.intervalDefine);
157
-
158
- }
159
-
160
- //Warning
161
- if ( $(this).html() == -2 ) {
162
-
163
- $(attributename).find(".isa_warning").fadeIn(1500);
164
-
165
- }
166
-
167
- //success
168
- if ( $(this).html() == 99 ) {
169
-
170
- $(attributename).find(".isa_success").fadeIn(1500);
171
-
172
- /* Stop statusreader */
173
- clearInterval(window.intervalDefine);
174
-
175
- }
176
-
177
- });
178
- });
179
- }
180
-
181
- /* get backup status */
182
- function wpbackitup_get_backup_status() {
183
- $.post(ajaxurl, wpbackitup_backup_status_reader, function(response) {
184
- /* Get response from log reader */
185
- var xmlObj = $(response);
186
-
187
- /* For each response */
188
- xmlObj.each(function() {
189
-
190
- /* Select correct status */
191
- var attributename = "." + $(this).attr('class');
192
- var icon_attributename = "." + $(this).attr('class') + '-icon';
193
-
194
- //Hide all
195
- if ( $(this).html() == 0 ) {
196
-
197
- $(attributename).find(".status").hide();
198
- $(attributename).find(".status-icon").hide();
199
-
200
- }
201
-
202
- //Processing
203
- if ( $(this).html() == 1 ) {
204
-
205
- $(icon_attributename).css('visibility', 'visible');
206
- $(attributename).find(".status").fadeOut(200);
207
- $(attributename).find(".status-icon").fadeIn(1500);
208
-
209
- }
210
-
211
- //Done
212
- if ( $(this).html() == 2 ) {
213
-
214
- $(attributename).find(".status-icon").fadeOut(200);
215
- $(attributename).find(".status").fadeIn(1500);
216
-
217
- }
218
-
219
- //Fatal Error
220
- if ( $(this).html() == -1 ) {
221
-
222
- $(attributename).find(".status-icon").fadeOut(200);
223
- $(attributename).find(".fail").fadeIn(1500);
224
-
225
-
226
- /* Stop status reader */
227
- clearInterval(window.intervalDefine);
228
-
229
- //Show error status
230
- wpbackitup_get_backup_response();
231
- }
232
-
233
- //Warning
234
- if ( $(this).html() == -2 ) {
235
-
236
- $(attributename).find(".status-icon").fadeOut(200);
237
- $(attributename).find(".wpbackitup-warning").fadeIn(1500);
238
-
239
- }
240
-
241
- //success
242
- if ( $(this).html() == 99 ) {
243
-
244
- /* If status returns 1, display 'Done' or show detailed message */
245
- $(attributename).find(".status-icon").fadeOut(200);
246
- $(attributename).find(".status").fadeIn(1500);
247
-
248
- /* Stop statusreader */
249
- clearInterval(window.intervalDefine);
250
-
251
- //Show error status
252
- wpbackitup_get_backup_response();
253
-
254
- }
255
-
256
- });
257
- });
258
- }
259
-
260
- /* define backup response_reader function */
261
- function wpbackitup_get_backup_response() {
262
- //This function is required because of 504 gateway timeouts
263
-
264
- var jqxhr = $.ajax({
265
- url: ajaxurl,
266
- type: 'POST',
267
- data: {action: wpbackitup_get_action_name('backup_response_reader')},
268
- dataType: "json"
269
- });
270
-
271
- jqxhr.always(function(jsonData, textStatus, errorThrown) {
272
- console.log("Backup Response:" + JSON.stringify(jsonData));
273
-
274
- if (typeof jsonData.backupStatus !== 'undefined' && typeof jsonData.backupMessage !== 'undefined')
275
- {
276
- console.log("JSON Backup Status:" + jsonData.backupStatus);
277
- console.log("JSON Backup Message:" + jsonData.backupMessage);
278
-
279
- switch (jsonData.backupStatus) {
280
- case 'success':
281
- console.log("JSON success response received.");
282
- //fade out all of the spinners
283
- $('.status-icon').fadeOut(200);
284
- $("#backup-button").removeAttr("disabled"); //enable button
285
-
286
- $('.isa_success').show;
287
- $('.backup-success').fadeIn(1500);
288
-
289
- wpbackitup_processRow_backup(jsonData);
290
-
291
- //Are there any warnings?
292
- if (typeof jsonData.backupWarnings !== 'undefined'){
293
- var warning = $('.backup-warning');
294
-
295
- var $warningMessages = jsonData.backupWarnings;
296
- $warningMessages.forEach(function(obj) {
297
- var warningMessage = obj.warningMessage;
298
- warning.append('<li class="isa_warning">Warning: '+ warningMessage + '</li>');
299
- });
300
-
301
- warning.fadeIn(1500);
302
- }
303
-
304
- break;
305
-
306
- case 'error':
307
- console.log("JSON error response received.");
308
-
309
- var msg="(JS997) Unexpected error";
310
- if (typeof jsonData.backupMessage !== 'undefined'){
311
- msg= jsonData.backupMessage;
312
- }
313
- var status_message='Error: &nbsp;' + msg;
314
-
315
- var backup_error= $('.backup-error');
316
- backup_error.html(status_message);
317
- backup_error.addClass("isa_error");
318
- backup_error.fadeIn(1500);
319
-
320
- //fade out all of the spinners
321
- $('.status-icon').fadeOut(200);
322
- $("#backup-button").removeAttr("disabled"); //enable button
323
-
324
- break;
325
-
326
- default:
327
- console.log("Unexpected JSON response status received.");
328
-
329
- var msg="(JS998) Unexpected error";
330
- if (typeof jsonData.backupMessage !== 'undefined'){
331
- msg= jsonData.backupMessage;
332
- }
333
- var status_message='Error(JS998) : &nbsp;' + msg;
334
-
335
- var unexpected_error= $('.backup-error');
336
- unexpected_error.html(status_message);
337
- unexpected_error.addClass("isa_error");
338
- unexpected_error.fadeIn(1500);
339
-
340
- //fade out all of the spinners
341
- $('.status-icon').fadeOut(200);
342
- $("#backup-button").removeAttr("disabled"); //enable button
343
-
344
- break;
345
-
346
- }
347
-
348
- } else { //Didnt get any json back
349
- console.log("NON JSON response received.");
350
- console.log("Backup Response:" + errorThrown);
351
- status_message='(JS999) An unexpected error has occurred: &nbsp;';
352
- status_message+='</br>Response: &nbsp;' + JSON.stringify(jsonData);
353
- status_message+='</br>Status: &nbsp;' + textStatus;
354
- status_message+='</br>Error: &nbsp;' + JSON.stringify(errorThrown);
355
-
356
- $('.backup-status').hide();
357
-
358
- var unexpected_error= $('.backup-error');
359
- unexpected_error.html(status_message);
360
- unexpected_error.addClass("isa_error");
361
- unexpected_error.show();
362
-
363
- $('.status-icon').fadeOut(200);
364
- }
365
- });
366
- }
367
-
368
- //Save Schedule CLICK
369
- $("#wp-backitup-notification-close").click(function() {
370
- wpbackitup_dismiss_message();
371
- });
372
-
373
-
374
- //Save Schedule CLICK
375
- $("#wp-backitup-save_schedule_form").submit(function() {
376
-
377
- var formData = new FormData();
378
- formData.append('action', wpbackitup_get_action_name('update-schedule'));
379
- formData.append('_wpnonce', $('#wp-backitup_nonce-update-schedule').val());
380
- formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
381
-
382
- var days_selected = [];
383
- $.each($("input[name='dow']:checked"), function(){
384
- days_selected.push($(this).val());
385
- });
386
-
387
- formData.append('days_selected', days_selected);
388
-
389
- jQuery.ajax({
390
- url: ajaxurl,
391
- type: 'POST',
392
- cache: false,
393
- contentType: false,
394
- processData: false,
395
- dataType: "json",
396
- data: formData,
397
-
398
- success: function(data, textStatus, jqXHR){
399
- response=data.message;
400
- console.log("Success:" + response);
401
-
402
- //Turn on the notification bar
403
- switch (response)
404
- {
405
- case 'success':
406
- wpbackitup_show_success_message("Scheduled has been saved.");
407
- break;
408
- case 'error':
409
- wpbackitup_show_error_message("Scheduled was not saved.");
410
- break;
411
- default:
412
-
413
- }
414
-
415
- },
416
- error: function(jqXHR, textStatus, errorThrown){
417
- console.log("Error." + textStatus +':' +errorThrown);
418
- },
419
- complete: function(jqXHR, textStatus){
420
- console.log("Complete");
421
- }
422
- });
423
-
424
- return false;
425
-
426
- });
427
-
428
- // BACKUP button click
429
- $(".backup-button").click(function(e) {
430
- e.preventDefault();
431
-
432
- $("#backup-button").attr('disabled', 'disabled'); //Disable button
433
-
434
- var jqxhr = $.ajax({
435
- url: ajaxurl,
436
- type: 'POST',
437
- data: {action: wpbackitup_get_action_name('backup')},
438
- cache: false,
439
- dataType: "json",
440
-
441
- beforeSend: function(jqXHR, settings) {
442
- console.log("BeforeSend:Nothing to report.");
443
- wpbackitup_show_backup();
444
- }
445
- });
446
-
447
- //Fetch the JSON response file if it exists
448
- jqxhr.always(function(data, textStatus, errorThrown) {
449
- console.log("Backup Button Click - Always");
450
- console.log(data.message);//backup queued?
451
- });
452
- });
453
-
454
- function wpbackitup_show_backup(){
455
- /* display processing icon */
456
- $('.backup-icon').css('visibility', 'visible');
457
- $('.backup-icon').show();
458
-
459
- /* hide default message */
460
- $('.backup-success').hide();
461
- $('.default-status').hide();
462
- $('.backup-error').hide();
463
-
464
- /* hide the status just incase this is the second run */
465
- $("ul.backup-status").children().children().hide();
466
- $(".backup-errors").children().children().hide();
467
- $(".backup-success").children().children().hide();
468
-
469
- /* show backup status, backup errors */
470
- $('.backup-status').show();
471
- window.intervalDefine = setInterval(wpbackitup_get_backup_status, 5000);
472
- }
473
-
474
-
475
- //RESTORE button click
476
- $('#datatable').on('click', 'a.restoreRow', function(e) {
477
- e.preventDefault();
478
-
479
- if (confirm('Are you sure you want to restore your site?'))
480
- {
481
- var filename = this.title;
482
- var row = this.id.replace('restoreRow', 'row');
483
- userid = $('input[name=user_id]').val();
484
-
485
- var jqxhr = $.ajax({
486
- url: ajaxurl,
487
- type: 'post',
488
- data: {action: wpbackitup_get_action_name('restore'), selected_file: filename,user_id: userid},
489
- cache: false,
490
- dataType: "json",
491
-
492
- //success: function(response) {
493
- // /* Return PHP messages, used for development */
494
- // $("#php").html(response);
495
- //
496
- // //clearInterval(window.intervalDefine);
497
- // var data = $.parseJSON(response);
498
- //
499
- //},
500
- beforeSend: function () {
501
- console.log("BeforeSend:Nothing to report.");
502
- wpbackitup_show_restore();
503
- }
504
- });
505
-
506
- //Fetch the JSON response file if it exists
507
- jqxhr.always(function(data, textStatus, errorThrown) {
508
- console.log("Restore Button Click - Always");
509
- //console.log("Response:" + data);
510
- });
511
- }
512
- });
513
-
514
-
515
- function wpbackitup_show_restore(){
516
- /* display processing icon */
517
- $('.restore-icon').css('visibility', 'visible');
518
-
519
- /* hide default message, backup status and backup errors */
520
- $('.default-status, .upload-status').hide();
521
-
522
- $("ul.restore-status").children().children().hide();
523
- $(".restore-errors").children().children().hide();
524
- $(".restore-success").children().children().hide();
525
-
526
- /* show restore status messages */
527
- $('.restore-status, .restore-errors, .restore-success').show();
528
- $('.preparing-icon').css('visibility', 'visible');
529
- $('.preparing').find(".status-icon").fadeIn(1500);
530
-
531
- window.intervalDefine = setInterval(wpbackitup_get_restore_status, 5000);
532
- }
533
-
534
- /*Upload form button*/
535
- //$("#upload-form").submit(function(e) {
536
- //
537
- // e.preventDefault();
538
- //
539
- // //CHECK ERRORS ON USER SIDE, IF TRUE, END OPERATIONS.
540
- // if (wpbackitup_upload_errors()){
541
- // return false;
542
- // }
543
- //
544
- // var formData = new FormData();
545
- // formData.append('action', wpbackitup_get_action_name('upload'));
546
- // formData.append('_wpnonce', $('#_wpnonce').val());
547
- // formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
548
- // formData.append('upload_ids',$('#upload_ids').val());
549
- //
550
- // jQuery.ajax({
551
- // url: ajaxurl,
552
- // type: 'POST',
553
- // cache: false,
554
- // contentType: false,
555
- // processData: false,
556
- // dataType: "json",
557
- //
558
- // //MODIFIED - From ajaxData to formData
559
- // data: formData,
560
- //
561
- // beforeSend: function(jqXHR, settings){
562
- // //console.log("Haven't entered server side yet.");
563
- // /* display processing icon */
564
- // $('.upload-icon').css('visibility', 'visible');
565
- //
566
- // /* hide default message, backup status and backup errors */
567
- // $('.default-status, .restore-status, .restore-errors').hide();
568
- // $("ul.restore-status").children().children().hide();
569
- // $(".restore-errors").children().children().hide();
570
- // $(".restore-success").children().children().hide();
571
- //
572
- // /* show restore status messages */
573
- // $('.upload-status').toggle();
574
- //
575
- // $("#wpbackitup-zip").attr("disabled", "disabled"); //Disable upload
576
- // $("#upload-button").attr("disabled", "disabled"); //Disable upload
577
- //
578
- // },
579
- // dataFilter: function(data, type){
580
- // //Check the response before sending to success
581
- // //Possible that is isnt json so just forward it to success in a json object
582
- // try {
583
- // $("#php").html(data);
584
- // var response = $.parseJSON(data);
585
- // console.log("JSON string echoed back from server side:" + response);
586
- // return data;
587
- // } catch (e) {
588
- // console.log("NON JSON string echoed back from server side:" + type + ':' + data);
589
- // var rtnData = new Object();
590
- // rtnData.success = "";
591
- // rtnData.error = data;
592
- // return JSON.stringify(rtnData)
593
- // }
594
- //
595
- //
596
- // },
597
- // success: function(data, textStatus, jqXHR){
598
- // console.log("Back from server-side:" + data);
599
- // //Checking errors that may have been caught on the server side that
600
- // // normally wouldn't display in the error Ajax function.
601
- //
602
- // if (data.msg == 'success')
603
- // {
604
- // status_message=data.file + ' file was uploaded successfully...';
605
- // wpbackitup_processRow_restore(data);
606
- // $('.upload-status').addClass("isa_success");
607
- // }else{
608
- // status_message='Error: &nbsp;' + data.error;
609
- // $('.upload-status').addClass("isa_error");
610
- // }
611
- //
612
- // $('.upload-icon').fadeOut(1000);
613
- // $('.upload-status').show();
614
- // $('.upload-status').html(status_message);
615
- //
616
- // },
617
- // error: function(jqXHR, textStatus, errorThrown){
618
- // console.log("A JS error has occurred." + textStatus +':' +errorThrown);
619
- // },
620
- // complete: function(jqXHR, textStatus){
621
- // console.log("Ajax is finished.");
622
- // }
623
- // });
624
- //
625
- // return false;
626
- //});
627
- //
628
- //function wpbackitup_upload_errors()
629
- //{
630
- // var selected_files = $('#upload_ids').val();
631
- // if (selected_files == '')
632
- // {
633
- // alert('No file(s) selected. Please choose a backup file.');
634
- // return true;
635
- // }
636
- //
637
- // //if ($('#upload_files').val() != '')
638
- // //{
639
- // // var ext = $('#upload_files').val().split('.').pop().toLowerCase();
640
- // // if($.inArray(ext, ['zip']) == -1)
641
- // // {
642
- // // alert('Invalid file type. Please choose a ZIP file to upload.');
643
- // // return true;
644
- // // }
645
- // //}
646
- // return false;
647
- //}
648
- //
649
- ///*Upload form button*/
650
- //$("#upload-form_OLD").submit(function() {
651
- //
652
- // //e.preventDefault();
653
- //
654
- // //CHECK ERRORS ON USER SIDE, IF TRUE, END OPERATIONS.
655
- // if (wpbackitup_upload_errors()){
656
- // return false;
657
- // }
658
- //
659
- // var formData = new FormData();
660
- // jQuery.each($('#wpbackitup-zip')[0].files, function(i, file) {
661
- // formData.append('uploadFile-'+i, file);
662
- // });
663
- // formData.append('action', wpbackitup_get_action_name('upload'));
664
- // formData.append('_wpnonce', $('#_wpnonce').val());
665
- // formData.append('_wp_http_referer',$("[name='_wp_http_referer']").val());
666
- //
667
- // jQuery.ajax({
668
- // url: ajaxurl,
669
- // type: 'POST',
670
- // cache: false,
671
- // contentType: false,
672
- // processData: false,
673
- // dataType: "json",
674
- //
675
- // //MODIFIED - From ajaxData to formData
676
- // data: formData,
677
- //
678
- // beforeSend: function(jqXHR, settings){
679
- // //console.log("Haven't entered server side yet.");
680
- // /* display processing icon */
681
- // $('.upload-icon').css('visibility', 'visible');
682
- //
683
- // /* hide default message, backup status and backup errors */
684
- // $('.default-status, .restore-status, .restore-errors').hide();
685
- // $("ul.restore-status").children().children().hide();
686
- // $(".restore-errors").children().children().hide();
687
- // $(".restore-success").children().children().hide();
688
- //
689
- // /* show restore status messages */
690
- // $('.upload-status').toggle();
691
- //
692
- // $("#wpbackitup-zip").attr("disabled", "disabled"); //Disable upload
693
- // $("#upload-button").attr("disabled", "disabled"); //Disable upload
694
- //
695
- // },
696
- // dataFilter: function(data, type){
697
- // //Check the response before sending to success
698
- // //Possible that is isnt json so just forward it to success in a json object
699
- // try {
700
- // $("#php").html(data);
701
- // var response = $.parseJSON(data);
702
- // console.log("JSON string echoed back from server side:" + response);
703
- // return data;
704
- // } catch (e) {
705
- // console.log("NON JSON string echoed back from server side:" + type + ':' + data);
706
- // var rtnData = new Object();
707
- // rtnData.success = "";
708
- // rtnData.error = data;
709
- // return JSON.stringify(rtnData)
710
- // }
711
- //
712
- //
713
- // },
714
- // success: function(data, textStatus, jqXHR){
715
- // console.log("Back from server-side:" + data);
716
- // //Checking errors that may have been caught on the server side that
717
- // // normally wouldn't display in the error Ajax function.
718
- //
719
- // if (data.msg == 'success')
720
- // {
721
- // status_message=data.file + ' file was uploaded successfully...';
722
- // wpbackitup_processRow_restore(data);
723
- // $('.upload-status').addClass("isa_success");
724
- // }else{
725
- // status_message='Error: &nbsp;' + data.error;
726
- // $('.upload-status').addClass("isa_error");
727
- // }
728
- //
729
- // $('.upload-icon').fadeOut(1000);
730
- // $('.upload-status').show();
731
- // $('.upload-status').html(status_message);
732
- //
733
- // },
734
- // error: function(jqXHR, textStatus, errorThrown){
735
- // console.log("A JS error has occurred." + textStatus +':' +errorThrown);
736
- // },
737
- // complete: function(jqXHR, textStatus){
738
- // console.log("Ajax is finished.");
739
- // }
740
- // });
741
- //
742
- // return false;
743
- //});
744
-
745
- // DELETE file action
746
- $('#datatable').on('click', 'a.deleteRow', function(e) {
747
-
748
- e.preventDefault();
749
- if (confirm('Are you sure ?'))
750
- {
751
- var filename = this.title;
752
- var row = this.id.replace('deleteRow', 'row');
753
- $.ajax({
754
- url: ajaxurl,
755
- type: 'post',
756
- data: {action: wpbackitup_get_action_name('delete_file'), filed: filename},
757
- success: function(data) {
758
- if (data === 'deleted')
759
- {
760
- $('#' + row).remove();
761
- }
762
- else
763
- {
764
- alert('This file cannot be delete!');
765
- }
766
- }
767
- });
768
- }
769
- else
770
- {
771
- return;
772
- }
773
- });
774
-
775
- //UPLOADS
776
- //http://www.plupload.com/example_events.php
777
- function plupload_init(plupload_config) {
778
-
779
- var uploader = new plupload.Uploader(plupload_config);
780
- uploader.init();
781
-
782
- //File Added event
783
- uploader.bind('FilesAdded', function(up, files){
784
- plupload.each(files, function(file){
785
- //add some file name validation here?
786
- $('#filelist').append(
787
- '<div id="media-item-' + file.id + '" class="media-item child-of-0">' +
788
- '<img class="pinkynail" alt="" src="' + site_url + '/wp-includes/images/media/archive.png">' +
789
- '<div class="filename new" id="' + file.id + '">' +
790
- file.name + ' (<span>' + plupload.formatSize(0) + '</span> of ' + plupload.formatSize(file.size) + ') ' +
791
- '<div class="progress" style="width: 0%;"></div></div></div>');
792
- });
793
-
794
- up.refresh();
795
- up.start();
796
- });
797
-
798
- //File Progress Event
799
- uploader.bind('UploadProgress', function(up, file) {
800
- $('#' + file.id + " .progress").width((file.percent *.15 )+ "%");
801
- $('#' + file.id + " span").html(plupload.formatSize(parseInt(file.size * file.percent / 100)));
802
- });
803
-
804
- //Chunked upload
805
- uploader.bind(' ChunkUploaded', function(up, file,info) {
806
- console.log('Chunk Uploaded:');
807
- console.log(info);
808
-
809
- if (is_plupload_error(info,up,file)){
810
- console.log('chunk error');
811
- }
812
-
813
- });
814
-
815
- //Error Event
816
- uploader.bind('Error', function(up, error) {
817
- console.log('PlUpload Error:');
818
- console.log(error);
819
-
820
- var error_div = "error-item-"+ error.file.id;
821
-
822
- //If error div NOT exists then add it
823
- //Chunk and file uploaded both will call this routine
824
- if (! $('#'+ error_div).length){
825
- $('#filelist').append(
826
- '<div class="error-div error" id="' + error_div + '" >' +
827
- '<strong>' + error.file.name + ' has failed to upload due to error:&nbsp;</strong> <span>' + error.message + '</span> ' +
828
- '</div>'
829
- );
830
- }
831
-
832
-
833
- });
834
-
835
-
836
- // a file was uploaded
837
- uploader.bind('FileUploaded', function(up, file, response) {
838
- console.log('File Uploaded');
839
- console.log(response);
840
-
841
-
842
- if (is_plupload_error(response,up,file)){
843
- console.log('uploaded error')
844
- }else{
845
- console.log('uploaded success')
846
- $('#' + file.id + " .progress").css("background-color", "green");
847
- }
848
-
849
- });
850
- }
851
-
852
- function is_plupload_error(response,uploader,file){
853
- if (response.status == '200') {
854
- try {
855
- response_json = jQuery.parseJSON(response.response);
856
-
857
- if (response_json.error) {
858
- plupload_error (uploader,file, 100, response_json.error)
859
- return true;
860
- }
861
-
862
- //success
863
- return false;
864
-
865
-
866
- } catch (err) {
867
- console.log('Unexpected JSON Error' + err);
868
- plupload_error (uploader,file, 998, response.response)
869
- return true;
870
- }
871
-
872
- } else {
873
- alert('Unknown server response status: '+response.code);
874
- console.log(response);
875
- plupload_error (uploader,file, 999, response.response)
876
- return true;
877
- }
878
-
879
- }
880
- function plupload_error (uploader,file, code, error_message){
881
-
882
- file.status = plupload.FAILED;
883
- uploader.trigger("Error", {
884
- code: code,
885
- message: error_message,
886
- file: file
887
- });
888
-
889
- //remove upload from list
890
- $('#media-item-' + file.id).hide();
891
- }
892
-
893
- function wpbackitup_processRow_backup(data)
894
- {
895
- // decide class of row to be inserted dynamically
896
- var css_class;
897
- css_class = '';
898
-
899
- if (!$('#datatable tr').first().hasClass('alternate'))
900
- css_class = 'class="alternate"';
901
- // decided class of row to be inserted dynamically
902
-
903
- // build id of the row to be inserted dynamically
904
- var cur_row = ($('#datatable tr:last')[0].id.replace('row', ''));
905
- cur_row++;
906
-
907
- // built id of the row to be inserted dynamically
908
- if (typeof data !== 'undefined')
909
- {
910
- //var restoreColumn = '<td><a href="#" title="' + data.backupFile + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n';
911
-
912
- var viewColumn = '<td>&nbsp;</td>\n';
913
- if (typeof data.logFileExists !== 'undefined' && data.logFileExists==true) {
914
- viewColumn = '<td><a class="viewloglink" href="' + data.backupName + '">View Log</a></td>\n';
915
- }
916
-
917
- var newRow =
918
- '<tr ' + css_class + ' id="row' + cur_row + '">\n\
919
- <td>New Backup!</td>\n\
920
- <td><a href="#TB_inline?width=600&height=550&inlineId=new_backup" class="thickbox" title="' + data.backupName + '">Download</a></td>\n';
921
- newRow +=viewColumn;
922
- newRow +='<td><a href="#" title="' + data.backupName + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n';
923
- newRow +='</tr>';
924
-
925
- if ($('#nofiles'))
926
- $('#nofiles').remove();
927
-
928
- var total_rows = $('#datatable tr').length;
929
- $('#datatable').prepend(newRow);
930
- $('#datatable tr:first').hide().show('slow'); // just an animation to show newly added row
931
-
932
- if(total_rows >= data.backupRetained)
933
- $('#datatable tr:last').hide();
934
-
935
- wpbackitup_add_viewlog_onclick();
936
-
937
- wpbackitup_add_downloadbackup_onclick();
938
-
939
- }
940
- }
941
-
942
- function wpbackitup_processRow_restore(data)
943
- {
944
- // decide class of row to be inserted dynamically
945
- var css_class;
946
- css_class = '';
947
-
948
- if (!$('#datatable tr').first().hasClass('alternate'))
949
- css_class = 'class="alternate"';
950
- // decided class of row to be inserted dynamically
951
-
952
- // build id of the row to be inserted dynamically
953
- var cur_row = ($('#datatable tr:last')[0].id.replace('row', ''));
954
- cur_row++;
955
-
956
- // built id of the row to be inserted dynamically
957
- if (data != undefined)
958
- {
959
- var restoreColumn = '<td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n';
960
- var newRow =
961
- '<tr ' + css_class + ' id="row' + cur_row + '">\n\
962
- <td>Uploaded Backup<i class="fa fa-long-arrow-right"></i>' + data.file +'</td>\n\
963
- <td><a href="' + data.zip_link + '">Download</a></td>\n\
964
- <td><a href="#" title="' + data.file + '" class="deleteRow" id="deleteRow' + cur_row + '">Delete</a></td>\n\
965
- <td><a href="#" title="' + data.file + '" class="restoreRow" id="restoreRow' + cur_row + '">Restore</a></td>\n\
966
- </tr>';
967
-
968
- if ($('#nofiles'))
969
- $('#nofiles').remove();
970
-
971
- var total_rows = $('#datatable tr').length;
972
- $('#datatable').prepend(newRow);
973
- $('#datatable tr:first').hide().show('slow'); // just an animation to show newly added row
974
-
975
- if(total_rows >= data.retained)
976
- $('#datatable tr:last').hide();
977
- }
978
- }
979
-
980
-
981
- function wpbackitup_get_action_name(action) {
982
- return namespace + '_' + action;
983
- }
984
-
985
- function wpbackitup_dismiss_message(){
986
- notification_bar = $( "#wp-backitup-notification-parent");
987
- notification_bar.fadeOut( "slow" )
988
- }
989
-
990
- function wpbackitup_show_success_message(message){
991
- notification_bar_message = $( "#wp-backitup-notification-message");
992
- notification_bar_message.html("<p>" + message + "</p>");
993
-
994
- notification_bar = $( "#wp-backitup-notification-parent");
995
- notification_bar.toggleClass("error",false);
996
- notification_bar.toggleClass("updated",true);
997
-
998
- notification_bar.show();
999
- $('html, body').animate({ scrollTop: 0 }, 'slow');
1000
- }
1001
-
1002
- function wpbackitup_show_error_message(message){
1003
- notification_bar_message = $( "#wp-backitup-notification-message");
1004
- notification_bar_message.html("<p>" + message + "</p>");
1005
-
1006
- notification_bar = $( "#wp-backitup-notification-parent");
1007
- notification_bar.toggleClass("updated",false);
1008
- notification_bar.toggleClass("error",true);
1009
-
1010
- notification_bar.show();
1011
- $('html, body').animate({ scrollTop: 0 }, 'slow');
1012
- }
1013
-
1014
-
1015
-
1016
-
1017
- // Uploading files
1018
- //jQuery(document).ready(function($){
1019
- // var custom_uploader;
1020
- // $('#upload_backup_button').click(function(e) {
1021
- //
1022
- // e.preventDefault();
1023
- //
1024
- // //If the uploader object has already been created, reopen the dialog
1025
- // if (custom_uploader) {
1026
- // custom_uploader.open();
1027
- // return;
1028
- // }
1029
- //
1030
- // //Extend the wp.media object (wp-includes/js/media-views.js)
1031
- // custom_uploader = wp.media.frames.file_frame = wp.media({
1032
- // //id:'wpbackitup-library',
1033
- // library: {
1034
- // type: "application/zip"
1035
- // },
1036
- // title: 'Select Backup Files',
1037
- // button: {
1038
- // text: 'Select Backup Files'
1039
- // },
1040
- // //searchable:false,
1041
- // //editing:false,
1042
- // //frame: 'post',
1043
- // multiple: true
1044
- // });
1045
- //
1046
- // //When a file is selected, grab the URL and set it as the text field's value
1047
- // custom_uploader.on('select', function() {
1048
- //
1049
- // //attachment = custom_uploader.state().get('selection').first().toJSON();
1050
- // //$('#upload_backup').val(attachment.filename);
1051
- //
1052
- // var attachments_string='';
1053
- // var selected_file_ids=[];
1054
- // var selection = custom_uploader.state().get('selection');
1055
- // selection.map( function( attachment ) {
1056
- // attachment = attachment.toJSON();
1057
- //
1058
- // //Probably need to add this to a hidden form field
1059
- // selected_file_ids.push(attachment.id);
1060
- // attachments_string+=attachment.filename +",";
1061
- // // Do something with attachment.id and/or attachment.url here
1062
- // });
1063
- //
1064
- // var ids_json = JSON.stringify(selected_file_ids);
1065
- // $('#upload_ids').val(ids_json);
1066
- // $('#upload_files').val(attachments_string);
1067
- // $('#upload_backup').val(attachments_string);
1068
- //
1069
- // });
1070
- //
1071
- //
1072
- // //Open the uploader dialog
1073
- // custom_uploader.open();
1074
- //
1075
- // });
1076
- //
1077
- //
1078
- //});
1079
-
1080
- //**TEST METHODS**//
1081
-
1082
- //wpbackitup_show_restore();
1083
- //wpbackitup_show_backup();
1084
-
1085
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/languages/en-GB.mo DELETED
Binary file
tags/1.10.1/languages/en-GB.po DELETED
@@ -1,333 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: WP Backitup\n"
4
- "POT-Creation-Date: 2013-09-07 19:24-0000\n"
5
- "PO-Revision-Date: 2013-09-07 19:24-0000\n"
6
- "Last-Translator: John Peden <john.peden@britishcouncil.org>\n"
7
- "Language-Team: John Peden Ltd <mail@johncpeden.com>\n"
8
- "Language: English\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.5.4\n"
13
- "X-Poedit-KeywordsList: _e;__\n"
14
- "X-Poedit-Basepath: .\n"
15
- "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-SearchPath-0: .\n"
17
- "X-Poedit-SearchPath-1: ..\n"
18
-
19
- #: ../index.php:312
20
- msgid "Manage"
21
- msgstr ""
22
-
23
- #: ../views/options.php:6 ../views/options.php:8
24
- msgid "Backup"
25
- msgstr ""
26
-
27
- #: ../views/options.php:7
28
- msgid "Create a backup file of this site's content and settings"
29
- msgstr ""
30
-
31
- #: ../views/options.php:9
32
- msgid "Download"
33
- msgstr ""
34
-
35
- #: ../views/options.php:15 ../views/options.php:30
36
- msgid "Restore"
37
- msgstr ""
38
-
39
- #: ../views/options.php:17
40
- msgid ""
41
- "Restore a WP Backitup zip file and overwrite this site's content, themes, "
42
- "plugins, uploads and settings"
43
- msgstr ""
44
-
45
- #: ../views/options.php:22
46
- msgid "The maximum filesize you can upload is "
47
- msgstr ""
48
-
49
- #: ../views/options.php:35
50
- msgid "Status"
51
- msgstr ""
52
-
53
- #: ../views/options.php:40
54
- msgid "Nothing to report"
55
- msgstr ""
56
-
57
- #: ../views/options.php:45
58
- msgid "Preparing to backup"
59
- msgstr ""
60
-
61
- #: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
62
- #: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
63
- #: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
64
- #: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
65
- #: ../views/options.php:73
66
- msgid "Done"
67
- msgstr ""
68
-
69
- #: ../views/options.php:45 ../views/options.php:46 ../views/options.php:47
70
- #: ../views/options.php:48 ../views/options.php:49 ../views/options.php:50
71
- #: ../views/options.php:67 ../views/options.php:68 ../views/options.php:69
72
- #: ../views/options.php:70 ../views/options.php:71 ../views/options.php:72
73
- #: ../views/options.php:73
74
- msgid "Failed"
75
- msgstr ""
76
-
77
- #: ../views/options.php:46
78
- msgid "Backing-up database"
79
- msgstr ""
80
-
81
- #: ../views/options.php:47
82
- msgid "Backing-up /wp-content/"
83
- msgstr ""
84
-
85
- #: ../views/options.php:48
86
- msgid "Creating backup information file"
87
- msgstr ""
88
-
89
- #: ../views/options.php:49
90
- msgid "Zipping backup directory"
91
- msgstr ""
92
-
93
- #: ../views/options.php:50 ../views/options.php:73
94
- msgid "Cleaning up"
95
- msgstr ""
96
-
97
- #: ../views/options.php:51
98
- msgid ""
99
- "Backup file created successfully. You can download your backup file using "
100
- "the link above"
101
- msgstr ""
102
-
103
- #: ../views/options.php:56
104
- msgid ""
105
- "Error: Unable to create new directory for backup. Please check your CHMOD "
106
- "settings of your wp-backitup plugin directory"
107
- msgstr ""
108
-
109
- #: ../views/options.php:57
110
- msgid ""
111
- "Error: Cannot create backup directory. Please check the CHMOD settings of "
112
- "your wp-backitup plugin directory"
113
- msgstr ""
114
-
115
- #: ../views/options.php:58
116
- msgid "Error: Unable to backup your files. Please try again"
117
- msgstr ""
118
-
119
- #: ../views/options.php:59
120
- msgid "Error: Unable to backup your database. Please try again"
121
- msgstr ""
122
-
123
- #: ../views/options.php:60
124
- msgid ""
125
- "Error: Your database was accesible but a dump could not be created. Please "
126
- "contact support by clicking the link on the right, stating your web host "
127
- "when you submit the form."
128
- msgstr ""
129
-
130
- #: ../views/options.php:61
131
- msgid "Error: Unable to create site information file. Please try again"
132
- msgstr ""
133
-
134
- #: ../views/options.php:62
135
- msgid "Warning: Unable to cleanup your backup directory"
136
- msgstr ""
137
-
138
- #: ../views/options.php:67
139
- msgid "Uploading restoration zip"
140
- msgstr ""
141
-
142
- #: ../views/options.php:68
143
- msgid "Unzipping"
144
- msgstr ""
145
-
146
- #: ../views/options.php:69
147
- msgid "Validating restoration zip"
148
- msgstr ""
149
-
150
- #: ../views/options.php:70
151
- msgid "Setting checkpoint"
152
- msgstr ""
153
-
154
- #: ../views/options.php:71
155
- msgid "Importing database"
156
- msgstr ""
157
-
158
- #: ../views/options.php:72
159
- msgid "Importing /wp-content/ directory"
160
- msgstr ""
161
-
162
- #: ../views/options.php:74
163
- msgid ""
164
- "Restoration completed successfully. Please refresh the page and login to the "
165
- "site again (with your current username and password)"
166
- msgstr ""
167
-
168
- #: ../views/options.php:79
169
- msgid "Error: No file selected"
170
- msgstr ""
171
-
172
- #: ../views/options.php:80
173
- msgid "Error: Your file could not be uploaded"
174
- msgstr ""
175
-
176
- #: ../views/options.php:81
177
- msgid "Error: Your restoration file could not be unzipped"
178
- msgstr ""
179
-
180
- #: ../views/options.php:82
181
- msgid ""
182
- "Error: Your zip file appears to be invalid. Please ensure you chose the "
183
- "correct zip file"
184
- msgstr ""
185
-
186
- #: ../views/options.php:83
187
- msgid "Error: Cannot create restore point"
188
- msgstr ""
189
-
190
- #: ../views/options.php:84
191
- msgid "Error: Unable to connect to your database"
192
- msgstr ""
193
-
194
- #: ../views/options.php:85
195
- msgid "Error: Unable to get current site URL from database. Please try again"
196
- msgstr ""
197
-
198
- #: ../views/options.php:86
199
- msgid "Error: Unable to get current home URL from database. Please try again"
200
- msgstr ""
201
-
202
- #: ../views/options.php:87
203
- msgid "Error: Unable to get current user ID from database. Please try again"
204
- msgstr ""
205
-
206
- #: ../views/options.php:88
207
- msgid ""
208
- "Error: Unable to get current user password from database. Please try again"
209
- msgstr ""
210
-
211
- #: ../views/options.php:89
212
- msgid "Error: Unable to get current user email from database. Please try again"
213
- msgstr ""
214
-
215
- #: ../views/options.php:90
216
- msgid ""
217
- "Error: Unable to get import your database. This may require importing the "
218
- "file manually"
219
- msgstr ""
220
-
221
- #: ../views/options.php:91
222
- msgid ""
223
- "Error: Unable to update your current site URL value. This may require "
224
- "importing the file manually"
225
- msgstr ""
226
-
227
- #: ../views/options.php:92
228
- msgid ""
229
- "Error: Unable to update your current home URL value. This may require "
230
- "importing the file manually"
231
- msgstr ""
232
-
233
- #: ../views/options.php:93
234
- msgid ""
235
- "Error: Unable to update your user information. This may require importing "
236
- "the file manually"
237
- msgstr ""
238
-
239
- #: ../views/options.php:94
240
- msgid "Error: Warning: Database not detected in import file"
241
- msgstr ""
242
-
243
- #: ../views/options.php:95
244
- msgid ""
245
- "Error: Unable to remove existing wp-content directory for import. Please "
246
- "check your CHMOD settings in /wp-content/"
247
- msgstr ""
248
-
249
- #: ../views/options.php:96
250
- msgid ""
251
- "Error: Unable to create new wp-content directory for import. Please check "
252
- "your CHMOD settings in /wp-content/"
253
- msgstr ""
254
-
255
- #: ../views/options.php:97
256
- msgid "Error: Unable to import wp-content. Please try again"
257
- msgstr ""
258
-
259
- #: ../views/options.php:98
260
- msgid "Warning: Unable to cleanup import directory"
261
- msgstr ""
262
-
263
- #: ../views/options.php:109
264
- msgid "License Key"
265
- msgstr ""
266
-
267
- #: ../views/options.php:113
268
- msgid "Pro features and auto-updates enabled"
269
- msgstr ""
270
-
271
- #: ../views/options.php:115
272
- msgid "Activate auto-restore and auto-updates by entering your license key"
273
- msgstr ""
274
-
275
- #: ../views/options.php:120
276
- msgid "Active"
277
- msgstr ""
278
-
279
- #: ../views/options.php:121
280
- msgid "Update"
281
- msgstr ""
282
-
283
- #: ../views/options.php:123
284
- msgid "Inactive"
285
- msgstr ""
286
-
287
- #: ../views/options.php:124
288
- msgid "Activate"
289
- msgstr ""
290
-
291
- #: ../views/options.php:125
292
- msgid "Purchase a license key"
293
- msgstr ""
294
-
295
- #: ../views/options.php:132
296
- msgid "WP Backitup support system"
297
- msgstr ""
298
-
299
- #: ../views/options.php:135
300
- msgid "support system"
301
- msgstr ""
302
-
303
- #: ../views/options.php:138
304
- msgid "Need Help?"
305
- msgstr ""
306
-
307
- #: ../views/options.php:139
308
- msgid "Access the"
309
- msgstr ""
310
-
311
- #: ../views/options.php:143
312
- msgid "Spread the Word"
313
- msgstr ""
314
-
315
- #: ../views/options.php:144
316
- msgid "Rate WP Backitup"
317
- msgstr ""
318
-
319
- #: ../views/options.php:149
320
- msgid "Enable"
321
- msgstr ""
322
-
323
- #: ../views/options.php:150
324
- msgid "Disable"
325
- msgstr ""
326
-
327
- #: ../views/options.php:151
328
- msgid "Help to improve Easy Webtrends by enabling"
329
- msgstr ""
330
-
331
- #: ../views/options.php:152
332
- msgid "Save"
333
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-backup.php DELETED
@@ -1,724 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Backup Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
- /*** Includes ***/
12
- // include file system class
13
- if( !class_exists( 'WPBackItUp_Filesystem' ) ) {
14
- include_once 'class-filesystem.php';
15
- }
16
-
17
-
18
-
19
- class WPBackItUp_Backup {
20
-
21
- private $logger;
22
-
23
- //Public Properties
24
- public $backup_name;
25
- public $backup_filename;
26
- public $backup_project_path;
27
- public $backup_folder_root;
28
- public $restore_folder_root;
29
- public $backup_retained_number;
30
- public $backup_retained_days;
31
- public $backup_batch_size;
32
-
33
- //scheduled,manual,none
34
- public $backup_type;
35
-
36
- private static $lockFileName;
37
- private static $lockFile;
38
-
39
-
40
- //-------------STATIC FUNCTIONS-------------------//
41
-
42
-
43
-
44
- //-------------END STATIC FUNCTIONS-------------------//
45
-
46
- function __construct($logger,$backup_name, $backup_type) {
47
- global $WPBackitup;
48
- try {
49
- $this->logger = $logger;
50
-
51
- $this->backup_type=$backup_type;
52
-
53
- $this->backup_batch_size=1; //manual backups
54
- if ('scheduled'==$this->backup_type){
55
- $this->backup_batch_size=$WPBackitup->backup_batch_size(); //Scheduled
56
- }
57
- $this->backup_name=$backup_name;
58
- $this->backup_filename=$backup_name . '.tmp';
59
-
60
- $backup_project_path = WPBACKITUP__BACKUP_PATH .'/TMP_'. $backup_name .'/';
61
-
62
- $backup_folder_root =WPBACKITUP__BACKUP_PATH .'/';
63
- $restore_folder_root = WPBACKITUP__RESTORE_FOLDER;
64
-
65
- $this->backup_project_path=$backup_project_path;
66
- $this->backup_folder_root=$backup_folder_root;
67
- $this->restore_folder_root=$restore_folder_root;
68
-
69
- $this->backup_retained_number = $WPBackitup->backup_retained_number();
70
- $this->backup_retained_days = WPBACKITUP__BACKUP_RETAINED_DAYS; //Prob need to move this to main propery
71
-
72
- } catch(Exception $e) {
73
- $this->logger->log_error(__METHOD__,'Constructor Exception: ' .$e);
74
- throw $e;
75
- }
76
- }
77
-
78
- function __destruct() {
79
- //Call end just in case
80
- $this->end();
81
- }
82
-
83
-
84
- /**
85
- * Begin backup process - Only one may be running at a time
86
- * @return bool
87
- */
88
- public static function start (){
89
- $logger = new WPBackItUp_Logger(false,null,'debug_lock');
90
- try {
91
- self::$lockFileName = WPBACKITUP__PLUGIN_PATH .'logs/wpbackitup_lock.lock';
92
- $logger->log_info(__METHOD__,'Begin - Lock File:' . self::$lockFileName);
93
-
94
- self::$lockFile = fopen(self::$lockFileName ,"w"); // open it for WRITING ("w")
95
- if (flock( self::$lockFile, LOCK_EX | LOCK_NB)) {
96
- $logger->log_info(__METHOD__,'Process LOCK acquired');
97
- return true;
98
- } else {
99
- $logger->log_info(__METHOD__,'Process LOCK failed');
100
- return false;
101
- }
102
-
103
- } catch(Exception $e) {
104
- $logger->log_info(__METHOD__,'Process Lock error: ' .$e);
105
- return false;
106
- }
107
- }
108
-
109
- /**
110
- * End Backup Process
111
- * @return bool
112
- */
113
- public static function end (){
114
- //$this->logger->log_info(__METHOD__,'Begin - Unlock File:' . $this->lockFileName);
115
-
116
- try{
117
- //$this->logger->log_info(__METHOD__,'LOCK released - backup ending');
118
- flock( self::$lockFile, LOCK_UN); // unlock the file
119
- return true;
120
-
121
- }catch(Exception $e) {
122
- //$this->logger->log_error(__METHOD__,'Cant unlock file: ' .$e);
123
- return false;
124
- }
125
- }
126
-
127
- /**
128
- * Check lock status
129
- * @return bool
130
- */
131
- public function check_lock_status (){
132
- //Check for 5 minutes then give up
133
- for ($i = 1; $i <= 100; $i++) {
134
- if ($this->start()){
135
- $this->end();
136
- return true;
137
- }
138
- else{
139
- sleep(3); //sleep for 3 seconds
140
- }
141
- }
142
- return false;
143
- }
144
-
145
- public function isScheduled(){
146
-
147
- return true;
148
- }
149
-
150
- public function cleanup_backups_by_prefix($prefix) {
151
- $this->logger->log_info( __METHOD__, 'Begin' );
152
- $backup_root_path=$this->backup_folder_root;
153
-
154
- //get a list of all the temps
155
- $work_folder_list = glob($backup_root_path. $prefix .'*', GLOB_ONLYDIR);
156
- $file_system = new WPBackItUp_FileSystem($this->logger);
157
- foreach($work_folder_list as $folder) {
158
- $file_system->recursive_delete($folder);
159
- }
160
-
161
- $this->logger->log_info( __METHOD__, 'End' );
162
- }
163
-
164
- public function cleanup_old_backups() {
165
- $this->logger->log_info( __METHOD__, 'Begin' );
166
-
167
- // --PURGE BACKUP FOLDER
168
- //Purge logs in backup older than N days
169
- $backup_root_path=$this->backup_folder_root;
170
- $file_system = new WPBackItUp_FileSystem($this->logger);
171
-
172
- //check retention limits
173
- $file_system->purge_folders($backup_root_path,'*',$this->backup_retained_number);
174
-
175
- $this->logger->log_info( __METHOD__, 'End' );
176
- }
177
-
178
-
179
- public function cleanup_unfinished_backups_OLD(){
180
- $dir=$this->backup_folder_root;
181
- $this->logger->log_info(__METHOD__,'Begin:'.$dir);
182
- $ignore = array('cgi-bin','.','..','._');
183
- if( is_dir($dir) ){
184
- if($dh = opendir($dir)) {
185
- while( ($file = readdir($dh)) !== false ) {
186
- $ext = pathinfo($file, PATHINFO_EXTENSION);
187
- if (!in_array($file, $ignore) && substr($file, 0, 1) != '.' && $ext!="zip" && $ext!="log") { //Check the file is not in the ignore array
188
- if(!is_dir($dir .'/'. $file)) {
189
- unlink($dir .'/'. $file);
190
- } else {
191
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
192
- $fileSystem->recursive_delete($dir.'/'. $file, $ignore);
193
- }
194
- }
195
- }
196
- }
197
- closedir($dh);
198
- }
199
- $this->logger->log_info(__METHOD__,'End');
200
- return true;
201
- }
202
-
203
- public function cleanup_current_backup(){
204
- $path = $this->backup_project_path;
205
- $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
206
-
207
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
208
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
209
-
210
- if(!$fileSystem ->delete_files($work_files)) {
211
- $this->logger->log_error(__METHOD__,'Work files could not be deleted');
212
- return false;
213
- }
214
-
215
- $this->logger->log_info(__METHOD__,'End - Work Files Deleted');
216
- return true;
217
- }
218
-
219
- public function delete_site_data_files(){
220
- $path = $this->backup_project_path;
221
- $this->logger->log_info(__METHOD__, 'Begin - Cleanup Backup Folder:' . $path);
222
-
223
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
224
- $work_files = array_filter(glob($this->backup_project_path. '*.{txt,sql}',GLOB_BRACE), 'is_file');
225
-
226
- if(!$fileSystem ->delete_files($work_files)) {
227
- $this->logger->log_error(__METHOD__,'Work files could not be deleted');
228
- return false;
229
- }
230
-
231
- $this->logger->log_info(__METHOD__,'End - Work Files Deleted');
232
- return true;
233
- }
234
-
235
-
236
- public function purge_old_files(){
237
- $this->logger->log_info(__METHOD__,'Begin');
238
- $fileSystem = new WPBackItUp_FileSystem( $this->logger);
239
-
240
- //Check the retention
241
- $fileSystem->purge_FilesByDate($this->backup_retained_number,$this->backup_folder_root);
242
-
243
- // --PURGE BACKUP FOLDER
244
- //Purge logs in backup older than N days
245
- $backup_path = WPBACKITUP__BACKUP_PATH .'/';
246
- $fileSystem->purge_files($backup_path,'*.log',$this->backup_retained_days);
247
-
248
- //Purge restore DB checkpoints older than 5 days
249
- $fileSystem->purge_files($backup_path,'db*.cur',$this->backup_retained_days);
250
-
251
- // --PURGE LOGS FOLDER
252
- $logs_path = WPBACKITUP__PLUGIN_PATH .'/logs/';
253
-
254
- //Purge logs in logs older than 5 days
255
- $fileSystem->purge_files($logs_path,'*.log',$this->backup_retained_days);
256
-
257
- //Purge Zipped logs in logs older than 5 days
258
- $fileSystem->purge_files($logs_path,'*.zip',$this->backup_retained_days);
259
-
260
- //Purge logs in logs older than 5 days
261
- // $fileSystem->purge_files($logs_path,'Backup_*.log',$this->backup_retained_days);
262
-
263
- // //Purge debug logs in logs older than 5 days
264
- // $fileSystem->purge_files($logs_path,'*debug*.log',$this->backup_retained_days);
265
- //
266
- // //Purge upload logs in logs older than 5 days
267
- // $fileSystem->purge_files($logs_path,'*upload*.log',$this->backup_retained_days);
268
- //
269
- // //Purge cleanup logs in logs older than 5 days
270
- // $fileSystem->purge_files($logs_path,'*cleanup*.log',$this->backup_retained_days);
271
- //
272
- // //Purge Zipped logs in logs older than 5 days
273
- // $fileSystem->purge_files($logs_path,'logs_*.zip',$this->backup_retained_days);
274
- //
275
- // //Purge restore logs in logs older than 5 days
276
- // $fileSystem->purge_files($logs_path,'*restore*.log',$this->backup_retained_days);
277
-
278
- $this->logger->log_info(__METHOD__,'End');
279
-
280
- }
281
-
282
- //Make sure the root backup folder wpbackitup_backups exists
283
- public function backup_root_folder_exists(){
284
- $this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_folder_root);
285
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
286
- if(!$fileSystem->create_dir($this->backup_folder_root)) {
287
- $this->logger->log_error(__METHOD__,' Cant create backup folder :'. $this->backup_folder_root);
288
- return false;
289
- }
290
-
291
- $fileSystem->secure_folder($this->backup_folder_root);
292
-
293
- //Make sure logs folder is secured
294
- $logs_dir = WPBACKITUP__PLUGIN_PATH .'/logs/';
295
- $fileSystem->secure_folder( $logs_dir);
296
-
297
-
298
- $this->logger->log_info(__METHOD__,'End');
299
- return true;
300
- }
301
-
302
- //Create the root folder for the current backup
303
- public function create_current_backup_folder(){
304
- $this->logger->log_info(__METHOD__,'Begin: ' .$this->backup_project_path);
305
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
306
- if(!$fileSystem->create_dir($this->backup_project_path)) {
307
- $this->logger->log_error(__METHOD__,'Cant create backup folder :'. $this->backup_project_path);
308
- return false;
309
- }
310
-
311
- $this->logger->log_info(__METHOD__,'End');
312
- return true;
313
- }
314
-
315
- //Check to see if the directory exists and is writeable
316
- public function backup_folder_exists(){
317
- $path=$this->backup_project_path;
318
- $this->logger->log_info(__METHOD__,'Is folder writeable: ' .$path);
319
- if(is_writeable($path)) {
320
- $this->logger->log_info(__METHOD__,'Folder IS writeable');
321
- return true;
322
- }
323
-
324
- $this->logger->log_error(__METHOD__,'Folder NOT writeable');
325
- return false;
326
- }
327
-
328
- //Export the SQL database
329
- public function export_database(){
330
- $sql_file_name=$this->backup_project_path . WPBACKITUP__SQL_DBBACKUP_FILENAME;
331
- $sqlUtil = new WPBackItUp_SQL($this->logger);
332
- $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$sql_file_name);
333
-
334
- //Try SQLDump First
335
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
336
- if(!$sqlUtil->mysqldump_export($sql_file_name) ) {
337
-
338
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP/PATH');
339
- if(!$sqlUtil->mysqldump_export($sql_file_name,true) ) {
340
-
341
- $this->logger->log_info(__METHOD__,'Export DB with Manual SQL EXPORT');
342
- if(!$sqlUtil->manual_export($sql_file_name) ) {
343
- $this->logger->log_error(__METHOD__,'SQL EXPORT FAILED');
344
- return false;
345
- }
346
- }
347
- }
348
- $this->logger->log_info(__METHOD__,'Database Exported successfully');
349
-
350
- // Uncomment when encryption is added
351
- // backup wp.config
352
- // $from_path = get_home_path() .'/wp-config.php';
353
- // $to_path = $this->backup_project_path .'/wp-config.bak';
354
- // $file_system = new WPBackItUp_FileSystem($this->logger);
355
- // $file_system->copy_file($from_path,$to_path);
356
-
357
- return true;
358
- }
359
-
360
- //Create siteinfo in project dir
361
- public function create_siteinfo_file(){
362
- global $table_prefix; //from wp-config
363
- $path=$this->backup_project_path;
364
- $siteinfo = $path ."backupsiteinfo.txt";
365
-
366
- $this->logger->log_info(__METHOD__,'Create Site Info File:'.$siteinfo);
367
- try {
368
- $handle = fopen($siteinfo, 'w+');
369
- if (false===$handle){
370
- $this->logger->log_error(__METHOD__,'Cant open file.');
371
- return false;
372
- }
373
-
374
- //Probably should change to json format
375
-
376
- //Write Site URL
377
- $entry = site_url( '/' ) ."\n";
378
- fwrite($handle, $entry);
379
-
380
- //Write Table Prefix
381
- $entry = $table_prefix ."\n" ;
382
- fwrite($handle, $entry);
383
-
384
- //write WP version
385
- $entry =get_bloginfo( 'version')."\n" ;
386
- fwrite($handle, $entry);
387
-
388
- //write WP BackItUp
389
- $entry =WPBACKITUP__VERSION."\n" ;
390
- fwrite($handle, $entry);
391
-
392
- fclose($handle);
393
-
394
-
395
- if (file_exists($siteinfo)){
396
- $this->logger->log_info(__METHOD__,'File created successfully.');
397
- return true;
398
- }
399
-
400
- }catch(Exception $e) {
401
- $this->this->logger->log_error(__METHOD__,' Exception: ' .$e);
402
- }
403
-
404
- $this->logger->log_error(__METHOD__,'Site Info File NOT Created.');
405
- return false;
406
- }
407
-
408
- public function get_plugins_file_list() {
409
- $this->logger->log_info( __METHOD__, 'Begin' );
410
-
411
- $file_system = new WPBackItUp_FileSystem($this->logger);
412
- $plugins_file_list = $file_system->get_recursive_file_list(WPBACKITUP__PLUGINS_ROOT_PATH. '/*' );
413
- $this->logger->log_info( __METHOD__, 'Plugin File Count: ' .count($plugins_file_list));
414
-
415
- return $plugins_file_list;
416
- }
417
-
418
- public function get_themes_file_list() {
419
- $this->logger->log_info( __METHOD__, 'Begin' );
420
-
421
- $file_system = new WPBackItUp_FileSystem($this->logger);
422
- $themes_root_path = WPBACKITUP__THEMES_ROOT_PATH;
423
- $themes_file_list = $file_system->get_recursive_file_list($themes_root_path. '/*' );
424
- $this->logger->log_info( __METHOD__, 'Themes File Count: ' .count($themes_file_list));
425
-
426
- return $themes_file_list;
427
- }
428
-
429
- public function get_uploads_file_list() {
430
- $this->logger->log_info( __METHOD__, 'Begin' );
431
-
432
- $upload_array = wp_upload_dir();
433
- $uploads_root_path = $upload_array['basedir'];
434
-
435
- //ignore these folders under uploads
436
- $ignore = explode(',',WPBACKITUP__BACKUP_IGNORE_LIST);
437
-
438
- $uploads_folderlist = glob($uploads_root_path. '/*',GLOB_ONLYDIR|GLOB_NOSORT);
439
- $uploads_file_list=array();
440
-
441
- $file_system = new WPBackItUp_FileSystem($this->logger);
442
- foreach ( $uploads_folderlist as $folder ) {
443
- if (! $this->strposa(basename($folder), $ignore)){
444
- array_push($uploads_file_list,$folder);
445
- $file_list = $file_system->get_recursive_file_list($folder. '/*' );
446
- $uploads_file_list = array_merge($uploads_file_list,$file_list);
447
- }
448
- }
449
-
450
- //Need to grab the files in the root also
451
- $files_only = array_filter(glob($uploads_root_path. '/*'), 'is_file');
452
- if (count($files_only)>0){
453
- $uploads_file_list = array_merge($uploads_file_list,$files_only);
454
- }
455
-
456
- $this->logger->log_info( __METHOD__, 'Themes File Count: ' .count($uploads_file_list));
457
-
458
- return $uploads_file_list;
459
- }
460
-
461
- public function get_other_file_list() {
462
- $this->logger->log_info( __METHOD__, 'Begin' );
463
-
464
- $wpcontent_path = WPBACKITUP__CONTENT_PATH;
465
-
466
- $upload_array = wp_upload_dir();
467
- $uploads_folder = basename ($upload_array['basedir']);
468
- $themes_folder = basename (WPBACKITUP__THEMES_ROOT_PATH);
469
- $plugins_folder = basename (WPBACKITUP__PLUGINS_ROOT_PATH);
470
-
471
- //ignore these folders
472
- $wpback_ignore = explode(',',WPBACKITUP__BACKUP_IGNORE_LIST);
473
- $wpcontent_ignore=array($uploads_folder, $themes_folder, $plugins_folder);
474
- $ignore = array_merge($wpback_ignore,$wpcontent_ignore);
475
-
476
- $wpcontent_folderlist = glob($wpcontent_path. '/*',GLOB_ONLYDIR|GLOB_NOSORT);
477
-
478
- $other_file_list=array();
479
- $file_system = new WPBackItUp_FileSystem($this->logger);
480
- foreach ( $wpcontent_folderlist as $folder ) {
481
- if (!$this->strposa(basename($folder), $ignore)){
482
- array_push($other_file_list,$folder);
483
- $file_list = $file_system->get_recursive_file_list($folder. '/*' );
484
- $other_file_list = array_merge($other_file_list,$file_list);
485
- }
486
- }
487
-
488
- //Need to grab the files in the root also
489
- $files_only = array_filter(glob($wpcontent_path. '/*'), 'is_file');
490
- if (count($files_only)>0){
491
-
492
- //Get rid of the debug.log file - dont want to restore it
493
- $debug_log_index = $this->search_array('debug.log', $files_only);
494
- if (false!==$debug_log_index) {
495
- unset($files_only[$debug_log_index]);
496
- }
497
-
498
- $other_file_list = array_merge($other_file_list,$files_only);
499
- }
500
-
501
- $this->logger->log_info( __METHOD__, 'Other File Count: ' .count($other_file_list));
502
-
503
- return $other_file_list;
504
- }
505
-
506
-
507
- //BackUp
508
- public function backup_file_list($source_root,$target_root,$suffix,$file_list,$batch_size,$ignore=''){
509
- $this->logger->log_info(__METHOD__,'Begin - Item Count: '. count($file_list));
510
-
511
- $zip_file_path = $this->backup_project_path . $this->backup_name .'-'.$suffix .'.tmp';
512
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
513
-
514
- foreach($file_list as $item) {
515
-
516
- //skip it if in ignore
517
- if ( !empty($ignore) && false!== strpos($item,$ignore)) {
518
- $this->logger->log_info( __METHOD__, 'Skip File:' . $item );
519
- array_shift($file_list); //remove from list
520
- continue;
521
- }
522
-
523
- //skip it if folder
524
- if ( is_dir( $item ) ) {
525
- $this->logger->log_info( __METHOD__, 'Skip folder:' . $item );
526
- array_shift( $file_list ); //remove from list
527
- continue;
528
- }
529
-
530
-
531
- //replace the source path with the target
532
- $target_item_path = str_replace(rtrim($source_root, '/'),rtrim($target_root,'/'),$item);
533
- if ( $zip->add_file($item,$target_item_path)) {
534
- array_shift($file_list);
535
- $this->logger->log_info( __METHOD__, 'File Added:' . $target_item_path );
536
- $this->logger->log_info( __METHOD__, 'Zip file count:' . $zip->get_zip_file_count() . '>=' . $batch_size);
537
-
538
- //If we have added X# of files or hit the size limit then lets close the zip and finish on the next pass
539
- if( $zip->get_zip_file_count()>=$batch_size){
540
-
541
- $zip->close();//close the zip
542
-
543
- //check the compressed file size
544
- $compressed_zip_file_size = $zip->get_zip_actual_size();
545
- $this->logger->log_info( __METHOD__, 'Zip Actual Size after close:' . $zip->get_zip_actual_size());
546
-
547
- //if the zip is too big we need to rename it
548
- $threshold = $zip->get_max_zip_size(.8);
549
- if ($compressed_zip_file_size >= $threshold) {
550
- $this->logger->log_info(__METHOD__,'Zip hit max size threshold:'.$compressed_zip_file_size .'>' .$threshold );
551
- if (! $this->add_zip_suffix($zip_file_path)){
552
- return 'error';
553
- }
554
- }
555
-
556
- $this->logger->log_info(__METHOD__,'End - Item Count:' . count($file_list));
557
- return $file_list;
558
- }
559
- } else {
560
- $this->logger->log_error( __METHOD__, 'File NOT added:' . $target_item_path );
561
- return 'error';
562
- }
563
- }
564
-
565
-
566
- //if we get here then close the zip
567
- $zip->close();//close the zip
568
-
569
- //if there are no more files to add then rename the zip
570
- //Check to see if the file exists, it is possible that it does not if only empty folders were contained
571
- if(count($file_list)==0 && file_exists($zip_file_path) ){
572
- $this->logger->log_info( __METHOD__, 'Zip Actual Size after close:' . $zip->get_zip_actual_size());
573
- if (! $this->add_zip_suffix($zip_file_path)){
574
- return 'error';
575
- }
576
- }
577
-
578
- $this->logger->log_info(__METHOD__,'End - Item Count:' . count($file_list));
579
- return $file_list;
580
- }
581
-
582
-
583
- private function strposa($haystack, $needle) {
584
- if(!is_array($needle)) $needle = array($needle);
585
-
586
- foreach($needle as $query) {
587
- //If wildcard on end then compare
588
- if ('*' == substr($query, -1) && strpos( $haystack, rtrim($query,"*")) !== false) {
589
- return true;
590
- } else {
591
- if ( $haystack==$query ) {
592
- return true;
593
- }
594
- }
595
- }
596
- return false;
597
- }
598
-
599
- private function add_zip_suffix($zip_file_path){
600
- $this->logger->log_info(__METHOD__,'Begin');
601
-
602
- $file_extension = pathinfo($zip_file_path, PATHINFO_EXTENSION);
603
- $this->logger->log_info(__METHOD__,'File Extension:'.$file_extension);
604
- if ($file_extension!='zip'){
605
- $file_system = new WPBackItUp_FileSystem($this->logger);
606
- $new_zip_name = str_replace('.' . $file_extension,'-'.time() .'.zip',$zip_file_path);
607
- if ( !$file_system->rename_file($zip_file_path,$new_zip_name)){
608
- $this->logger->log_error(__METHOD__,'Zip could not be renamed.');
609
- return false;
610
- }
611
- }
612
-
613
- //if we get here the file was renamed or was .zip already
614
- return true;
615
- }
616
-
617
- public function finalize_zip_file() {
618
- $this->logger->log_info(__METHOD__,'Begin - Finalize the zip.');
619
-
620
- $zip_file_path = $this->backup_folder_root . $this->backup_filename;
621
- $new_zip_name = str_replace('.tmp','.zip',$zip_file_path);
622
-
623
- $file_system = new WPBackItUp_FileSystem($this->logger);
624
- if (! $file_system->rename_file($zip_file_path,$new_zip_name)){
625
- $this->logger->log_error(__METHOD__,'Zip could not be finalized.');
626
- return false;
627
- }
628
-
629
- //Change the file name property moving forward
630
- $this->set_zip_extension();
631
-
632
- $this->logger->log_info(__METHOD__,'End - Zip Finalized successfully.');
633
- return true;
634
- }
635
-
636
- //Set zip extension to zip
637
- public function set_zip_extension() {
638
- $this->logger->log_info(__METHOD__,'Begin - change zip extension to zip');
639
-
640
- $this->backup_filename = substr_replace($this->backup_filename, '.zip', -4);
641
- //$this->backup_filename=str_replace('.tmp','.zip',$this->backup_filename);
642
-
643
- $this->logger->log_info(__METHOD__,'End - Zip extension changed:' . $this->backup_filename);
644
-
645
- }
646
-
647
- //Create manifest file
648
- public function create_backup_manifest(){
649
- $this->logger->log_info(__METHOD__,'Begin');
650
-
651
- //get a list of all the zips
652
- $backup_files_path = array_filter(glob($this->backup_project_path. '*.zip'), 'is_file');
653
- if (count($backup_files_path)>0){
654
- //get rid of the path.
655
- $backup_files = str_replace($this->backup_project_path,'',$backup_files_path);
656
- $manifest_file=$this->backup_project_path . 'backupmanifest.txt';
657
- file_put_contents($manifest_file,json_encode($backup_files));
658
-
659
- //Find the main zip in the array to get the path
660
- $main_zip_index = $this->search_array('-main-', $backup_files_path);
661
-
662
- //add it to the main zip file
663
- if ($main_zip_index!==false){
664
- $zip_file_path = $backup_files_path[$main_zip_index];
665
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
666
- $target_item_path = str_replace(rtrim($this->backup_project_path, '/'),rtrim('site-data','/'),$manifest_file);
667
- if ( $zip->add_file($manifest_file,$target_item_path)) {
668
- $zip->close();//close the zip
669
- $this->logger->log_info(__METHOD__,'End - Manifest created.');
670
- return true;
671
- }
672
- }
673
- }
674
-
675
- $this->logger->log_error(__METHOD__,'End - Manifest not created.');
676
- return false;
677
- }
678
-
679
- private function search_array($search, $array)
680
- {
681
- foreach($array as $key => $value)
682
- {
683
- if (stristr($value, $search))
684
- {
685
- return $key;
686
- }
687
- }
688
- return false;
689
- }
690
-
691
-
692
- public function rename_backup_folder() {
693
- $this->logger->log_info(__METHOD__,'Begin');
694
-
695
- $backup_project_path = $this->backup_project_path;
696
- //remove the 4 character prefix
697
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
698
-
699
- $file_system = new WPBackItUp_FileSystem($this->logger);
700
- if (! $file_system->rename_file($backup_project_path,$new_backup_path)){
701
- $this->logger->log_error(__METHOD__,'Folder could not be renamed');
702
- return false;
703
- }
704
-
705
- $this->set_final_backup_path();
706
-
707
- $this->logger->log_info(__METHOD__,'End');
708
- return true;
709
- }
710
-
711
- //this is needed because it is set to TMP until finalization then needed a way to know where the current path is
712
- public function set_final_backup_path(){
713
- $this->logger->log_info(__METHOD__,'Begin');
714
-
715
- $backup_project_path = $this->backup_project_path;
716
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
717
-
718
- //set the path to the new path
719
- $this->backup_project_path=$new_backup_path;
720
-
721
- $this->logger->log_info(__METHOD__,'End');
722
- }
723
-
724
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-filesystem.php DELETED
@@ -1,554 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup Utility Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
- /*** Includes ***/
12
- // include backup class
13
- if( !class_exists( 'WPBackItUp_RecursiveFilter_Iterator' ) ) {
14
- include_once 'class-recursiveFilter_Iterator.php';
15
- }
16
-
17
- class WPBackItUp_FileSystem {
18
-
19
- private $logger;
20
-
21
- function __construct($logger=null) {
22
- try {
23
- if (null==$logger){
24
- $this->logger = new WPBackItUp_Logger(true,null,'debug_filesystem');
25
- } else{
26
- $this->logger = $logger;
27
- }
28
- } catch(Exception $e) {
29
- //Dont do anything
30
- print $e;
31
- }
32
- }
33
-
34
- function __destruct() {
35
-
36
- }
37
-
38
- public function create_dir($dir) {
39
- $this->logger->log('(FileSytem.create_dir) Create Directory: ' .$dir);
40
- if( !is_dir($dir) ) {
41
- @mkdir($dir, 0755);
42
- }
43
- $this->logger->log('(FileSytem.create_dir) Directory created: ' .$dir);
44
- return true;
45
- }
46
-
47
- public function recursive_delete($dir, $ignore = array('') ){
48
- $this->logger->log('(FileSystem.recursive_delete) Recursively Delete: ' .$dir);
49
-
50
- $this->logger->log('(FileSystem.recursive_delete) Ignore:');
51
- $this->logger->log($ignore);
52
-
53
- if( is_dir($dir) ){
54
- //Make sure the folder is not in the ignore array
55
- if (!$this->delete_ignore($dir,$ignore)){
56
- if($dh = opendir($dir)) {
57
- while( ($file = readdir($dh)) !== false ) {
58
- if (!$this->delete_ignore($file,$ignore)) { //Check the file is not in the ignore array
59
- if(!is_dir($dir .'/'. $file)) {
60
- unlink($dir .'/'. $file); //delete the file
61
- $this->logger->log('(FileSytem.recursive_delete) File Deleted:' .$dir .'/'. $file);
62
- } else {
63
- //This is a dir so delete the files first
64
- $this->recursive_delete($dir.'/'. $file, $ignore);
65
- }
66
- }
67
- }
68
- }
69
- //Remove the directory
70
- @rmdir($dir);
71
- $this->logger->log('(FileSystem.recursive_delete) Folder Deleted:' .$dir);
72
- closedir($dh);
73
- }
74
- }
75
- $this->logger->log('(FileSystem.recursive_delete) Recursive Delete Completed.');
76
- return true;
77
- }
78
-
79
- public function recursive_copy($dir, $target_path, $ignore = array('') ) {
80
- $this->logger->log('(FileSystem.recursive_copy) Recursive copy FROM: ' .$dir);
81
- $this->logger->log('(FileSystem.recursive_copy) Recursive Copy TO: '.$target_path);
82
- $this->logger->log('(FileSystem.recursive_copy) IGNORE:');
83
- $this->logger->log($ignore);
84
-
85
- if( is_dir($dir) ) { //If the directory exists
86
- //Exclude all the OTHER backup folders under wp-content
87
- //Will create the folders but NOT the contents
88
- if (!$this->ignore($dir,$ignore) && !$this->is_backup_folder($dir) ){
89
- if ($dh = opendir($dir) ) {
90
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
91
- if (!$this->ignore($file,$ignore)) { //Check the file is not in the ignore array
92
- if (!is_dir( $dir.$file ) ) {
93
- try {
94
- $fsrc = fopen($dir .$file,'r');
95
- $fdest = fopen($target_path .$file,'w+');
96
- stream_copy_to_stream($fsrc,$fdest);
97
- fclose($fsrc);
98
- fclose($fdest);
99
- } catch(Exception $e) {
100
- $this->logger->log('(FileSystem.recursive_copy) File Copy Exception: ' .$e);
101
- return false;
102
- }
103
- } else { //If $file is a directory
104
- $destdir = $target_path .$file; //Modify the destination dir
105
- if(!is_dir($destdir)) { //Create the destdir if it doesn't exist
106
- $this->logger->log('(FileSytem.recursive_copy) Create Folder: ' .$destdir);
107
- try {
108
- @mkdir($destdir, 0755);
109
- } catch(Exception $e) {
110
- $this->logger->log('(FileSystem.recursive_copy)Create Folder Exception: ' .$e);
111
- return false;
112
- }
113
- }
114
- $this->recursive_copy($dir .$file .'/', $target_path .$file .'/', $ignore);
115
- }
116
- }
117
- }
118
- closedir($dh);
119
- }
120
- }
121
- }
122
-
123
- $this->logger->log('(FileSystem.recursive_copy) Completed');
124
- return true;
125
- }
126
-
127
- public function recursive_validate($source_path, $target_path, $ignore = array('') ) {
128
- // $this->logger->log('(FileSystem.recursive_validate) Recursive validate FROM: ' .$source_path);
129
- // $this->logger->log('(FileSystem.recursive_validate) Recursive validate TO: '.$target_path);
130
- // $this->logger->log('(FileSystem.recursive_validate) IGNORE:');
131
- // $this->logger->log($ignore);
132
-
133
- $rtnVal=true;
134
- if( is_dir($source_path) ) { //If the directory exists
135
- if (!$this->ignore($source_path,$ignore)){
136
- if ($dh = opendir($source_path) ) {
137
- while(($file = readdir($dh)) !== false) { //While there are files in the directory
138
- if ( !$this->ignore($file,$ignore)) { //Check the file is not in the ignore array
139
- if (!is_dir( $source_path.$file ) ) {
140
- try {
141
- $source_file = $source_path .$file;
142
- $target_file = $target_path .$file;
143
-
144
- if (!file_exists($target_file)) {
145
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF - Target file doesnt exist:' . $target_file);
146
- $rtnVal=false;
147
- continue;
148
- }
149
-
150
- $source_file_size = filesize ($source_file);
151
- $target_file_size = filesize ($target_file);
152
-
153
- if ($source_file_size != $target_file_size){
154
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Source:' . $source_file);
155
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Target:' . $target_file);
156
- $this->logger->log('(FileSystem.recursive_validate) Files DIFF Size:' . $source_file_size .':' . $target_file_size);
157
- $rtnVal=false;
158
- continue;
159
- }
160
-
161
- } catch(Exception $e) {
162
- $this->logger->log('(FileSystem.recursive_validate) Exception: ' .$e);
163
- return false;
164
- }
165
- } else { //If $file is a directory
166
- $destdir = $target_path .$file; //Modify the destination dir
167
- if(!is_dir($destdir)) {
168
- $this->logger->log('(FileSytem.recursive_validate) DIFF Folder doesnt exist: ' .$destdir);
169
- $rtnVal= false;
170
- }else{
171
- $dir_rtnVal=$this->recursive_validate($source_path .$file .'/', $target_path .$file .'/', $ignore);
172
- //Don't want to set to true as its the default on all calls
173
- if (!$dir_rtnVal) $rtnVal = false;
174
- }
175
- }
176
- }
177
- }
178
- closedir($dh);
179
- }
180
- }
181
- }
182
-
183
- //$this->logger->log('(FileSystem.recursive_validate) Completed:' . ($rtnVal ? 'true' : 'false'));
184
- return $rtnVal;
185
- }
186
-
187
- private function ignore($file, $ignoreList){
188
-
189
- //Exclude these files and folders from the delete
190
- if (in_array(basename($file), $ignoreList) ||
191
- substr($file, 0, 1) == '.' ||
192
- ($file == "." ) ||
193
- ($file == ".." ) ||
194
- ($file == "._" ) ||
195
- ($file == "cgi-bin" )) {
196
-
197
- //$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
198
- return true;
199
- }
200
-
201
- return false;
202
- }
203
-
204
- private function delete_ignore($file, $ignoreList){
205
-
206
- //Exclude these files and folders from the delete
207
- if (in_array(basename($file), $ignoreList) ||
208
- //substr($file, 0, 1) == '.' ||
209
- ($file == "." ) ||
210
- ($file == ".." ))
211
- //($file == "._" )
212
- //($file == "cgi-bin" ))
213
- {
214
- //$this->logger->log('(FileSystem.ignore) IGNORE:'.$file);
215
- return true;
216
- }
217
-
218
- return false;
219
- }
220
-
221
- //Check for backup folders
222
- private function is_backup_folder($dir){
223
- if (
224
- strpos(strtolower($dir),'/wp-content/backup')!== false ||
225
- strpos(strtolower($dir),'/wp-content/updraft')!== false ||
226
- strpos(strtolower($dir),'/wp-content/wp-clone')!== false ||
227
- strpos(strtolower($dir),'/wp-content/uploads/backwpup')!== false ||
228
- strpos(strtolower($dir),'/wp-content/uploads/backupwordpress')!== false
229
- ){
230
-
231
- $this->logger->log('(FileSystem.is_backup_folder) SKIP Backup Folder: ' .$dir);
232
- return true;
233
-
234
- }else{
235
- return false;
236
- }
237
-
238
- }
239
-
240
-
241
- // function delete_children_recursive($path, $ignore = array('cgi-bin','._'))
242
- // { //The filters are not working on this method
243
- // return false;
244
- // if (is_dir($path))
245
- // {
246
- // $this->logger->log('(FileSystem_delete_children_recursive) Ignore:');
247
- // $this->logger->log($ignore);
248
- //
249
- // $iterator = new RecursiveDirectoryIterator($path);
250
- // $iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
251
- // $filter = new WPBackItUp_RecursiveFilter_Iterator($iterator);
252
- // $filter->set_filter($ignore);
253
- //
254
- // $all_files = new RecursiveIteratorIterator($filter,RecursiveIteratorIterator::CHILD_FIRST);
255
- //
256
- // foreach ($all_files as $file)
257
- // {
258
- // if ($file->isDir())
259
- // {
260
- // $this->logger->log('(delete_recursive_new) delete folder:'.$file);
261
- // rmdir($file->getPathname());
262
- // }
263
- // else
264
- // {
265
- // $this->logger->log('(delete_recursive_new) delete file:'.$file);
266
- // unlink($file->getPathname());
267
- //
268
- // }
269
- //
270
- // $this->logger->log('(FileSystem_delete_children_recursive) Deleted:' . $file);
271
- // }
272
- // }
273
- // return true;
274
- // }
275
-
276
-
277
- public function purge_FilesByDate($number_Files_Allowed,$path)
278
- {
279
- $this->logger->log('(FileSytem.purge_FilesByDate) Purge files by date:' .$number_Files_Allowed .':'.$path);
280
-
281
- if (is_numeric($number_Files_Allowed) && $number_Files_Allowed> 0){
282
- $FileList = glob($path . "*.zip");
283
-
284
- //Sort by Date Time
285
- usort($FileList, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
286
-
287
- $i = 1;
288
- foreach ($FileList as $key => $val)
289
- {
290
- $this->logger->log_info(__METHOD__,' File:'.$val);
291
- $this->logger->log_info(__METHOD__,' File Date Time:'.filemtime($val));
292
-
293
- if($i <= $number_Files_Allowed)
294
- {
295
- $i++;
296
- continue;
297
- }
298
- else{
299
- $log_file_path = str_replace('.zip','.log',$val);
300
- if (file_exists($val)) unlink($val);
301
- if (file_exists($log_file_path)) unlink($log_file_path);
302
- $this->logger->log('(FileSytem.purge_FilesByDate) Delete File:)' .$val);
303
-
304
- }
305
- }
306
- }
307
- $this->logger->log('(FileSytem.purge_FilesByDate) Completed.');
308
- }
309
-
310
- public function purge_files($path, $file_pattern, $days)
311
- {
312
- $this->logger->log('(FileSytem.purge_files) Purge files days:' . $days);
313
- $this->logger->log('(FileSytem.purge_files) Purge files path:' . $path);
314
- $this->logger->log('(FileSytem.purge_files) Purge files extension:' . $file_pattern);
315
-
316
- //Check Parms
317
- if (empty($path) || empty($file_pattern) || !is_numeric($days)){
318
- $this->logger->log('(FileSytem.purge_files) Invalid Parm values');
319
- return false;
320
- }
321
-
322
- $FileList = glob($path . $file_pattern);
323
-
324
- //Sort by Date Time oldest first so can break when all old files are deleted
325
- usort($FileList, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
326
-
327
- foreach ($FileList as $key => $file)
328
- {
329
- $this->logger->log_info(__METHOD__,' File:'.$file);
330
- $this->logger->log_info(__METHOD__,' File Date Time:'.filemtime($file));
331
-
332
- $current_date = new DateTime('now');
333
- $file_mod_date = new DateTime(date('Y-m-d',filemtime($file)));
334
-
335
- //PHP 5.3 only
336
- //$date_diff = $current_date->diff($file_mod_date);
337
- //$date_diff_days = $date_diff->days;
338
-
339
- $util = new WPBackItUp_Utility( $this->logger);
340
- $date_diff_days=$util->date_diff_days($file_mod_date,$current_date);
341
-
342
- if($date_diff_days>=$days){
343
- if (file_exists($file)) unlink($file);
344
- $this->logger->log('Delete:' . $file);
345
- }
346
- else{
347
- break; //Exit for
348
- }
349
- }
350
- $this->logger->log('(FileSytem.purge_files) Completed.');
351
- return true;
352
- }
353
-
354
-
355
- /**
356
- * Purge the backups that exceed the retained number setting
357
- *
358
- * @param $path
359
- * @param $pattern
360
- * @param $retention_limit
361
- *
362
- * @return bool
363
- */
364
- public function purge_folders($path, $pattern, $retention_limit)
365
- {
366
- $this->logger->log_info(__METHOD__,' Purge folders retained number:' . $retention_limit);
367
- $this->logger->log_info(__METHOD__,' Purge folder path:' . $path);
368
- $this->logger->log_info(__METHOD__,' Purge pattern:' . $pattern);
369
-
370
- //Check Parms
371
- if (empty($path) || empty($pattern) || !is_numeric($retention_limit)){
372
- $this->logger->log_error(__METHOD__,' Invalid Parm values');
373
- return false;
374
- }
375
-
376
- $folder_list = glob($path . $pattern, GLOB_ONLYDIR);
377
-
378
- //Sort by Date Time so oldest is deleted first
379
- //usort($folder_list, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
380
-
381
- $backup_count=0;
382
- foreach (array_reverse($folder_list) as $key => $folder)
383
- {
384
- $this->logger->log_info(__METHOD__,' Folder:'.$folder);
385
- $this->logger->log_info(__METHOD__,' Folder Date Time:'.filemtime($folder));
386
-
387
- ++$backup_count;
388
- if($backup_count>$retention_limit){
389
- if (file_exists($folder)) {
390
- $this->recursive_delete($folder);
391
- }
392
- }
393
- }
394
- $this->logger->log_info(__METHOD__,'End');
395
- return true;
396
- }
397
-
398
- public function delete_files($file_list)
399
- {
400
- $this->logger->log_info(__METHOD__,'Begin');
401
-
402
- foreach ($file_list as $key => $file)
403
- {
404
- if (file_exists($file)){
405
- unlink($file);
406
- $this->logger->log('Deleted:' . $file);
407
- }
408
- }
409
- $this->logger->log_info(__METHOD__,'End');
410
- return true;
411
- }
412
-
413
-
414
- function get_file_handle($path,$newFile=false) {
415
- $this->logger->log('(FileSytem.get_file_handle) Path:' . $path);
416
-
417
- try {
418
-
419
- if ($newFile && file_exists($path)){
420
- if (unlink($path)){
421
- $this->logger->log('(FileSytem.get_file_handle) Deleted:' . $path);
422
- }
423
- else{
424
- $this->logger->log('(FileSytem.get_file_handle) File could not be deleted:');
425
- $this->logger->log(error_get_last());
426
- }
427
- }
428
-
429
- $fh= fopen($path, 'w');
430
- if (false===$fh){
431
- $this->logger->log('(FileSytem.get_file_handle) File could not be opened:');
432
- $this->logger->log(error_get_last());
433
- return false;
434
- }
435
-
436
- return $fh;
437
-
438
- } catch(Exception $e) {
439
- $this->logger->log('(FileSytem.get_file_handle) Exception:' . $e);
440
- return false;
441
- }
442
- }
443
-
444
- /**
445
- * Copy single file
446
- * @param $from_file
447
- * @param $to_file
448
- *
449
- * @return bool
450
- */
451
- function copy_file($from_file,$to_file) {
452
- $this->logger->log('(FileSystem.copy_file) FROM Path:' . $from_file);
453
- $this->logger->log('(FileSystem.copy_file) TO Path:' . $to_file);
454
-
455
- try {
456
- if (file_exists($from_file)){
457
- if (copy($from_file,$to_file)){
458
- $this->logger->log('(FileSystem.copy_file) File copied successfully.');
459
- return true;
460
- }
461
- else{
462
- $this->logger->log('(FileSystem.copy_file) File could not be copied:');
463
- $this->logger->log(error_get_last());
464
- return false;
465
- }
466
- }
467
- else{
468
- $this->logger->log('(FileSystem.copy_file) FROM File doesnt exist');
469
- return false;
470
- }
471
-
472
- } catch(Exception $e) {
473
- $this->logger->log('(FileSystem.copy_file) Exception:' . $e);
474
- return false;
475
- }
476
- }
477
-
478
- /**
479
- * Rename single file
480
- * @param $from_file
481
- * @param $to_file_name
482
- *
483
- * @return bool
484
- */
485
- function rename_file($from_file,$to_file_name) {
486
- $this->logger->log_info(__METHOD__,' FROM Path:' . $from_file);
487
- $this->logger->log_info(__METHOD__,' TO Path:' . $to_file_name);
488
-
489
- try {
490
- if (file_exists($from_file)){
491
- if (rename($from_file,$to_file_name)){
492
- $this->logger->log_info(__METHOD__,'File renamed successfully.');
493
- return true;
494
- }
495
- else{
496
- $this->logger->log_error(__METHOD__,'File could not be renamed:');
497
- $this->logger->log(error_get_last());
498
- return false;
499
- }
500
- }
501
- else{
502
- $this->logger->log_error(__METHOD__,'FROM File doesnt exist');
503
- return false;
504
- }
505
-
506
- } catch(Exception $e) {
507
- $this->logger->log_error(__METHOD__,' Exception:' . $e);
508
- return false;
509
- }
510
- }
511
-
512
- /**
513
- * Make sure that htaccess/web.config files exist in folder
514
- * If folder doesnt exist then create it.
515
- * @param $path
516
- */
517
- function secure_folder($path){
518
- $this->logger->log_info(__METHOD__,'Begin');
519
-
520
- $path = rtrim($path,"/");
521
-
522
- if( !is_dir($path) ) {
523
- @mkdir($path, 0755);
524
- $this->logger->log_info(__METHOD__,'Folder Created:' .$path);
525
- }
526
-
527
- if (!is_file($path.'/index.html')) @file_put_contents($path.'/index.html',"<html><body><a href=\"http://www.wpbackitup.com\">WP BackItUp - The simplest way to backup WordPress</a></body></html>");
528
- if (!is_file($path.'/.htaccess')) @file_put_contents($path.'/.htaccess','deny from all');
529
- if (!is_file($path.'/web.config')) @file_put_contents($path.'/web.config', "<configuration>\n<system.webServer>\n<authorization>\n<deny users=\"*\" />\n</authorization>\n</system.webServer>\n</configuration>\n");
530
- $this->logger->log_info(__METHOD__,'Secure files exist or were created.');
531
-
532
-
533
- $this->logger->log_info(__METHOD__,'End');
534
- }
535
-
536
-
537
- public function get_recursive_file_list($pattern) {
538
- $this->logger->log_info( __METHOD__, 'Begin: ' .$pattern );
539
-
540
- return $this->glob_recursive($pattern);
541
- }
542
-
543
- private function glob_recursive($pattern, $flags = 0)
544
- {
545
- //The order here is important because the folders must be in the list before the files.
546
- $files = glob($pattern, $flags);
547
- foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR) as $dir)
548
- {
549
- $files = array_merge($files, $this->glob_recursive($dir.'/'.basename($pattern), $flags));
550
- }
551
-
552
- return $files;
553
- }
554
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-job.php DELETED
@@ -1,756 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
-
4
-
5
- class WPBackItUp_Job {
6
-
7
- const JOB_TITLE='wpbackitup_job';
8
-
9
- private $logger;
10
- private $job_id;
11
- private $allocated_task;
12
-
13
- public $job_status;
14
- public $backup_id;
15
-
16
- private $job_start_time;
17
- private $job_end_time;
18
-
19
- static private $backup_tasks = array(
20
- 1=>'task_preparing',
21
- 2=>'task_backup_db' ,
22
- 3=>'task_backup_siteinfo',
23
- 4=>'task_backup_themes',
24
- 5=>'task_backup_plugins',
25
- 6=>'task_backup_uploads',
26
- 7=>'task_backup_other',
27
- 8=>'task_validate_backup',
28
- 9=>'task_finalize_backup',
29
- );
30
-
31
- static private $restore_tasks = array(
32
- 1=>'task_preparing',
33
- 2=>'task_unzip_backup_set',
34
- 3=>'task_validate_backup',
35
- 4=>'task_create_checkpoint',
36
- 5=>'task_stage_wpcontent',
37
- 6=>'task_restore_wpcontent',
38
- 8=>'task_restore_database',
39
- );
40
-
41
- static private $cleanup_tasks = array(
42
- 1=>'task_scheduled_cleanup'
43
- );
44
-
45
- function __construct($job) {
46
- try {
47
- $this->logger = new WPBackItUp_Logger(false,null,'debug_job');
48
-
49
- //Load of the class properties from the post object(see wp_post)
50
- $this->job_id=$job->ID;
51
- $this->job_status=$job->post_status;
52
- $this->backup_id=$job->post_name;
53
-
54
- //Deserialize content
55
- $content = $job->post_content;
56
- if (!empty($content)){
57
- $job_info =maybe_unserialize($content);
58
- if (is_array($job_info)){
59
- $this->job_start_time=$job_info['start_time'];
60
- }
61
- }
62
-
63
- } catch(Exception $e) {
64
- error_log($e); //Log to debug
65
- }
66
- }
67
-
68
- function __destruct() {
69
-
70
- }
71
-
72
- public function is_job_complete() {
73
- $this->logger->log_info( __METHOD__, 'Begin' );
74
-
75
- $tasks = get_post_meta( $this->job_id);
76
- foreach($tasks as $key=>$value) {
77
- //Is this a task of job meta data
78
- if (substr($key, 0, 4)!='task') continue;
79
-
80
- $task = get_post_meta($this->job_id,$key);
81
-
82
- //Get Task Properties
83
- $task_id = $task[0]['task_id'];
84
- $task_status = $task[0]['task_status'];
85
- $task_allocated_id = $task[0]['task_allocated_id'];
86
- $task_last_updated = $task[0]['task_last_updated'];
87
-
88
- if ('queued'==$task_status || 'active'==$task_status){
89
- $this->logger->log_info( __METHOD__, 'Active or Queued Task found:' . $key );
90
- return false;
91
- }
92
- }
93
-
94
- //No active or queued tasks were found
95
- $this->logger->log_info( __METHOD__, 'End - No Active or Queued Tasks found' );
96
- return true;
97
-
98
- }
99
- //What is the next task in the stack
100
- public function get_next_task(){
101
- $this->logger->log_info(__METHOD__,'Begin');
102
-
103
- $this->allocated_task=null; //Set the current task to null;
104
-
105
- //Get the tasks -- DO I NEED TO SORT?
106
- $tasks = get_post_meta($this->job_id);
107
-
108
- //Enumerate the tasks
109
- foreach ($tasks as $key => $value) {
110
-
111
- //Is this a task of job meta data
112
- if (substr($key, 0, 4)!='task') continue;
113
-
114
- $task = get_post_meta($this->job_id,$key);
115
-
116
- //Get Task Properties
117
- $task_id = $task[0]['task_id'];
118
- $task_status = $task[0]['task_status'];
119
- $task_allocated_id = $task[0]['task_allocated_id'];
120
- $task_last_updated = $task[0]['task_last_updated'];
121
-
122
- //if next task in stack is queued then its time to get to work
123
- switch ($task_status) {
124
- case "queued":
125
- //Try allocate task
126
- $queued_task = $this->allocate_task($this->job_id, $key,$task_id);
127
- return $queued_task[0]['task_id'];
128
-
129
- case "active":
130
- //Error if >= 3 minutes since the last update
131
- if (time()>=$task_last_updated+WPBACKITUP__TASK_TIMEOUT_SECONDS){
132
- $this->update_task_status($this->job_id, $key,$task_id,'error');
133
-
134
- //Update job to error also
135
- $this->set_job_status_error();
136
- return 'error_' . $task_id ;
137
-
138
- }else {
139
-
140
- $this->logger->log_info( __METHOD__, 'Job:' . $key . ' is still active' );
141
- //if its been less than 3 minutes then wait
142
- return false;
143
- }
144
-
145
- case "complete":
146
- //Do nothing - get the next task
147
- break;
148
-
149
- case "error":
150
- //Job should already be error but update if not
151
- //Update job to error also
152
- $this->set_job_status_error();
153
- return 'error_' . $task_id ;
154
- }
155
- }
156
-
157
- //If no more tasks then job must be done
158
- $this->set_job_status_complete();
159
-
160
- $this->logger->log_info(__METHOD__,'End - no tasks to allocate');
161
- return false; //no tasks to allocate
162
- }
163
-
164
- /**
165
- * Allocate the task to this job - will set task status to active
166
- *
167
- * @param $job_id
168
- * @param $key
169
- * @param $task_id
170
- *
171
- * @return bool
172
- */
173
- private function allocate_task($job_id, $key,$task_id){
174
- $this->logger->log_info(__METHOD__,'Begin');
175
-
176
- //Allocate the task to this process
177
- $process_uid = uniqid();
178
- $this->update_task_status($job_id, $key,$task_id,'active',$process_uid);
179
-
180
- //Get updated task and make sure uid is good
181
- $updated_task = get_post_meta( $this->job_id, $key);
182
- $updated_task_allocated_id = $updated_task[0]['task_allocated_id'];
183
- if ($process_uid==$updated_task_allocated_id) {
184
- $this->allocated_task=$updated_task; // set the jobs allocated task
185
-
186
- $this->logger->log_info(__METHOD__,'End - Task allocated');
187
- return $updated_task;
188
- }else{
189
- $this->allocated_task=null;
190
- $this->logger->log_info(__METHOD__,'End - Task was not allocated');
191
- return false;
192
- }
193
- }
194
-
195
-
196
- /**
197
- * Set the allocated task status to queued
198
- */
199
- public function set_task_queued(){
200
- $this->logger->log_info(__METHOD__,'Begin');
201
-
202
- $this->logger->log_info(__METHOD__, 'Task Info:');
203
- $this->logger->log($this->allocated_task);
204
-
205
- //Get allocated task Properties
206
- $task_id = $this->allocated_task[0]['task_id'];
207
- $this->update_task_status($this->job_id, $task_id,$task_id,'queued');
208
-
209
- $this->logger->log_info(__METHOD__,'End');
210
- }
211
-
212
- /**
213
- * Set the allocated task status to complete
214
- */
215
- public function set_task_complete(){
216
- $this->logger->log_info(__METHOD__,'Begin');
217
-
218
- $this->logger->log_info(__METHOD__, 'Task Info:');
219
- $this->logger->log($this->allocated_task);
220
-
221
- //Get allocated task Properties
222
- $task_id = $this->allocated_task[0]['task_id'];
223
- $this->update_task_status($this->job_id, $task_id,$task_id,'complete');
224
-
225
-
226
- //Check if this was the last task
227
- if ($this->is_job_complete()){
228
- $this->set_job_status_complete();
229
- }
230
-
231
- $this->logger->log_info(__METHOD__,'End');
232
- }
233
-
234
- /**
235
- * Set the allocated task status to error
236
- */
237
- public function set_task_error($error_code){
238
- $this->logger->log_info(__METHOD__,'Begin');
239
-
240
- $this->logger->log_info(__METHOD__, 'Task Info:');
241
- $this->logger->log($this->allocated_task);
242
-
243
- //Get allocated task Properties
244
- $task_id = $this->allocated_task[0]['task_id'];
245
- $this->update_task_status($this->job_id, $task_id,$task_id,'error','',$error_code);
246
-
247
- $this->set_job_status_error();
248
-
249
- $this->logger->log_info(__METHOD__,'End');
250
- }
251
-
252
-
253
- private function update_task_status($job_id,$task_name,$task_id, $task_status, $task_allocated_id='', $task_error_code=''){
254
- $this->logger->log_info(__METHOD__,'Begin');
255
-
256
- $meta_value = array(
257
- 'task_id' => $task_id,
258
- 'task_status' => $task_status,
259
- 'task_allocated_id' => $task_allocated_id,
260
- 'task_error_code' => $task_error_code,
261
- 'task_last_updated' => time()
262
- );
263
-
264
- $this->logger->log_info(__METHOD__,'End - Task Updated:' .$job_id .'-'. $task_name .'-'. $task_status);
265
- return update_post_meta( $job_id, $task_name, $meta_value );
266
- }
267
-
268
-
269
- public function update_job_meta($meta_name,$meta_value){
270
- $this->logger->log_info(__METHOD__,'Begin - Update job meta:' .$this->job_id .'-'. $meta_name);
271
-
272
- return update_post_meta( $this->job_id, $meta_name, $meta_value );
273
- }
274
-
275
- // public function update_task_file_list($task_name,$file_list){
276
- // $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $task_name);
277
- //
278
- // return update_post_meta( $this->job_id, $task_name, wp_slash($file_list) );
279
- // }
280
-
281
- // public function get_task_file_list($task_name){
282
- // $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $task_name);
283
- //
284
- // $file_list = get_post_meta($this->job_id,$task_name,true);
285
- //
286
- // return $file_list;
287
- // }
288
-
289
- public function get_job_meta($meta_name){
290
- $this->logger->log_info(__METHOD__,'Begin - Update file list:' .$this->job_id .'-'. $meta_name);
291
-
292
- return get_post_meta($this->job_id,$meta_name,true);
293
-
294
- }
295
-
296
- /**
297
- * Set job status to active
298
- */
299
- public function set_job_status_active( ) {
300
- $status='active';
301
- if ($this->update_job_status($status)){
302
- $this->job_status = $status;
303
- }
304
-
305
- //Set job end Time
306
- $this->set_job_start_time();
307
- }
308
-
309
- /**
310
- * Set job status to error
311
- */
312
- public function set_job_status_error( ) {
313
- $status='error';
314
- if ($this->update_job_status($status)){
315
- $this->job_status = $status;
316
- }
317
-
318
- //Set job end Time
319
- $this->set_job_end_time();
320
- }
321
-
322
- /**
323
- * Set job status to complete
324
- */
325
- public function set_job_status_complete( ) {
326
- $status='complete';
327
-
328
- if ($this->update_job_status($status)){
329
- $this->job_status = $status;
330
- }
331
-
332
- //Set job end Time
333
- $this->set_job_end_time();
334
- }
335
-
336
- /**
337
- * Set job status to cancelled
338
- */
339
- public function set_job_status_cancelled( ) {
340
- $status='cancelled';
341
-
342
- if ($this->update_job_status($status)){
343
- $this->job_status = $status;
344
- }
345
-
346
- //Set job end Time
347
- $this->set_job_end_time();
348
- }
349
-
350
-
351
- /**
352
- * Update job status
353
- *
354
- * @param $status
355
- *
356
- * @return bool
357
- */
358
- private function update_job_status($status) {
359
- $this->logger->log_info(__METHOD__,'Begin');
360
-
361
- $job = array(
362
- 'ID' => $this->job_id,
363
- 'post_status' => $status
364
- );
365
-
366
- // update the job
367
- $job_id = wp_update_post($job );
368
-
369
- if (0!=$job_id) {
370
- $this->logger->log_info(__METHOD__,'End - Backup Job status set to:' .$job_id .'-' . $status );
371
- return true;
372
- } else{
373
- $this->logger->log_error(__METHOD__,'End - Backup Job status NOT set.');
374
- return false;
375
- }
376
-
377
- }
378
-
379
- /**
380
- * Set job start time
381
- *
382
- * @return bool
383
- */
384
- private function set_job_start_time() {
385
- $this->logger->log_info(__METHOD__,'Begin');
386
-
387
- $this->job_start_time= time();
388
- $job_info = array(
389
- 'start_time' => $this->job_start_time,
390
- );
391
-
392
- $job = array(
393
- 'ID' => $this->job_id,
394
- 'post_content' => serialize($job_info)
395
- );
396
-
397
- // update the job info
398
- $job_id = wp_update_post($job );
399
-
400
- if (0!=$job_id) {
401
- $this->logger->log_info(__METHOD__,'End - Backup Job start time set');
402
- return true;
403
- } else{
404
- $this->logger->log_error(__METHOD__,'End - Backup Job start time NOT set.');
405
- return false;
406
- }
407
-
408
- }
409
-
410
- /**
411
- * Set job end time
412
- *
413
- * @return bool
414
- */
415
- private function set_job_end_time() {
416
- $this->logger->log_info(__METHOD__,'Begin');
417
-
418
- $this->job_end_time=time();
419
- $job_info = array(
420
- 'start_time' => $this->job_start_time,
421
- 'end_time' => $this->job_end_time,
422
- );
423
-
424
- $job = array(
425
- 'ID' => $this->job_id,
426
- 'post_content' => serialize($job_info)
427
- );
428
-
429
- // update the job info
430
- $job_id = wp_update_post($job );
431
-
432
- if (0!=$job_id) {
433
- $this->logger->log_info(__METHOD__,'End - Backup Job end time set');
434
- return true;
435
- } else{
436
- $this->logger->log_error(__METHOD__,'End - Backup Job end time NOT set.');
437
- return false;
438
- }
439
-
440
- }
441
-
442
- /**---------STATICS---------***/
443
-
444
- /**
445
- * Is there at least 1 job queued or active?
446
- *
447
- * @param $job_name
448
- *
449
- * @return bool
450
- */
451
- public static function is_job_queued($job_name) {
452
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
453
- $logger->log_info(__METHOD__,'Begin - Check Job Queue:' . $job_name);
454
-
455
- //Get top 1
456
- $args = array(
457
- 'posts_per_page' => 1,
458
- 'post_type' => $job_name,
459
- 'post_status' => array('queued','active'),
460
- 'orderby' => 'post_date',
461
- 'order' => 'ASC',
462
- 'suppress_filters' => true
463
- );
464
- $jobs = get_posts( $args );
465
- $logger->log($jobs);
466
-
467
- if (is_array($jobs) && count($jobs)>0) {
468
- $logger->log_info(__METHOD__,'Jobs found:' . count($jobs) );
469
- return true;
470
- }
471
-
472
- $logger->log_info(__METHOD__,'No jobs found:' . $job_name);
473
- $logger->log_info(__METHOD__,'End');
474
- return false;
475
- }
476
-
477
- /**
478
- * Cancel all queued or active jobs
479
- *
480
- * @return bool
481
- */
482
- public static function cancel_all_jobs() {
483
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
484
- $logger->log_info(__METHOD__,'Begin - Cancel all jobs.');
485
-
486
-
487
- while (self::is_job_queued('backup')){
488
- $backup_job = self::get_job('backup');
489
- if (false!== $backup_job) {
490
- $backup_job->set_job_status_cancelled();
491
- $logger->log_info(__METHOD__,'Backup job Cancelled:' . $backup_job->job_id);
492
- }
493
- }
494
-
495
- while (self::is_job_queued('cleanup')){
496
- $cleanup_job = self::get_job('cleanup');
497
- if (false!== $cleanup_job) {
498
- $cleanup_job->set_job_status_cancelled();
499
- $logger->log_info(__METHOD__,'Cleanup job Cancelled:' . $cleanup_job->job_id);
500
- }
501
- }
502
-
503
- $logger->log_info(__METHOD__,'End - All jobs cancelled');
504
- }
505
-
506
- /**
507
- * Gets the queued or active job on top of the stack
508
- *
509
- * @param $job_name
510
- *
511
- * @return bool|WPBackItUp_Job
512
- */
513
- public static function get_job($job_name) {
514
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
515
- $logger->log_info(__METHOD__,'Begin - Job Name: ' .$job_name);
516
-
517
- //Get backup on top
518
- $args = array(
519
- 'posts_per_page' => 1,
520
- 'post_type' => $job_name,
521
- 'post_status' => array('queued','active'),
522
- 'orderby' => 'post_date',
523
- 'order' => 'ASC',
524
- );
525
- $jobs = get_posts( $args );
526
- $logger->log($jobs);
527
-
528
- if (is_array($jobs) && count($jobs)>0) {
529
- $logger->log_info(__METHOD__,'Job found:' . count($jobs));
530
-
531
- $backup_job = new WPBackItUp_Job($jobs[0]);
532
- if ('queued'==$backup_job->job_status){
533
- $backup_job->set_job_status_active();
534
- }
535
- return $backup_job;
536
- }
537
-
538
- $logger->log_info(__METHOD__,'No jobs found.');
539
- $logger->log_info(__METHOD__,'End');
540
- return false;
541
- }
542
-
543
- /**
544
- * Gets a job by id
545
- *
546
- * @param $id
547
- *
548
- * @return bool|WPBackItUp_Job
549
- */
550
- public static function get_job_by_id($id) {
551
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
552
- $logger->log_info(__METHOD__,'Begin');
553
-
554
- $job = get_post( $id, 'OBJECT');
555
- $logger->log($job);
556
-
557
- if (null!=$job) {
558
- $logger->log_info(__METHOD__,'Job found:' .$id);
559
- return new WPBackItUp_Job($job);
560
- }
561
-
562
- $logger->log_info(__METHOD__,'No job found with id.' . $id);
563
- $logger->log_info(__METHOD__,'End');
564
- return false;
565
- }
566
-
567
- /**
568
- * Queue a job
569
- *
570
- * @param $job_name
571
- *
572
- * @return bool|WPBackItUp_Job
573
- */
574
- public static function queue_job($job_name){
575
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
576
- $logger->log_info(__METHOD__,'Begin - Job:'. $job_name);
577
-
578
- $new_job = array(
579
- 'post_title' => self::JOB_TITLE,
580
- 'post_name' => time(),
581
- 'post_status' => 'queued',
582
- 'post_type' => $job_name
583
- );
584
-
585
- // Insert the post into the database
586
- $job_id = wp_insert_post($new_job );
587
- $logger->log_info(__METHOD__,'Job Created:' .$job_id);
588
-
589
- switch ($job_name) {
590
- case "restore":
591
- //add the tasks
592
- if ( false === self::create_tasks( $job_id,self::$restore_tasks ) ) {
593
- $logger->log_info( __METHOD__, 'Restore tasks not Created - deleting job:' . $job_id );
594
- wp_delete_post( $job_id, true );
595
- return false;
596
- }
597
-
598
- break;
599
-
600
- case "backup":
601
- //add the tasks
602
- if ( false === self::create_tasks( $job_id,self::$backup_tasks ) ) {
603
- $logger->log_info( __METHOD__, 'Backup tasks not Created - deleting job:' . $job_id );
604
- wp_delete_post( $job_id, true );
605
- return false;
606
- }
607
-
608
- break;
609
-
610
- case "cleanup":
611
- //add the tasks
612
- if ( false === self::create_tasks( $job_id,self::$cleanup_tasks ) ) {
613
- $logger->log_info( __METHOD__, 'Cleanup tasks not Created - deleting job:' . $job_id );
614
- wp_delete_post( $job_id, true );
615
- return false;
616
- }
617
- break;
618
-
619
- default://Job type not defined
620
- $logger->log_info( __METHOD__, 'Job type not defined - deleting job:' . $job_name );
621
- wp_delete_post( $job_id, true );
622
- return false;
623
- }
624
-
625
- $logger->log_info(__METHOD__,'End');
626
- return self::get_job_by_id($job_id);
627
- }
628
-
629
- /**
630
- * Create all the tasks for a job
631
- *
632
- * @param $job_id
633
- *
634
- * @param $tasks
635
- *
636
- * @return bool
637
- */
638
- private static function create_tasks($job_id, $tasks){
639
- $logger = new WPBackItUp_Logger(false,null,'debug_job');
640
- $logger->log_info(__METHOD__,'Begin');
641
-
642
- //Create the job tasks
643
- $last_updated_time=time();
644
- foreach ($tasks as $key => $value){
645
- $task_name = $value;
646
- $task_data = array(
647
- 'task_id' => $task_name,
648
- 'task_status' => 'queued',
649
- 'task_allocated_id'=>'',
650
- 'task_last_updated'=>$last_updated_time
651
- );
652
- $task_created = update_post_meta( $job_id, $task_name, $task_data );
653
-
654
- if (false===$task_created){
655
- $logger->log_error( __METHOD__, 'Tasks NOT created');
656
- return false;
657
- }
658
- $logger->log_info( __METHOD__, 'task created:' . $task_created .':'. $task_name);
659
- }
660
-
661
- $logger->log_info(__METHOD__,'End');
662
- return true;
663
-
664
- }
665
-
666
- // /**
667
- // * Create all the tasks for a job
668
- // * @param $job_id
669
- // *
670
- // * @return bool
671
- // */
672
- // private static function create_backup_tasks($job_id){
673
- // $logger = new WPBackItUp_Logger(false,null,'debug_job');
674
- // $logger->log_info(__METHOD__,'Begin');
675
- //
676
- // //Create the job tasks
677
- // $last_updated_time=time();
678
- // foreach (self::$backup_tasks as $key => $value){
679
- // $task_name = $value;
680
- // $task_data = array(
681
- // 'task_id' => $task_name,
682
- // 'task_status' => 'queued',
683
- // 'task_allocated_id'=>'',
684
- // 'task_last_updated'=>$last_updated_time
685
- // );
686
- // $task_created = update_post_meta( $job_id, $task_name, $task_data );
687
- //
688
- // if (false===$task_created){
689
- // $logger->log_error( __METHOD__, 'Tasks NOT created');
690
- // return false;
691
- // }
692
- // $logger->log_info( __METHOD__, 'task created:' . $task_created .':'. $task_name);
693
- // }
694
- //
695
- // $logger->log_info(__METHOD__,'End');
696
- // return true;
697
- //
698
- // }
699
-
700
- // /**
701
- // * Create all the tasks for a job
702
- // * @param $job_id
703
- // *
704
- // * @return bool
705
- // */
706
- // private static function create_cleanup_tasks($job_id){
707
- // $logger = new WPBackItUp_Logger(false,null,'debug_job');
708
- // $logger->log_info(__METHOD__,'Begin');
709
- //
710
- // //Create the job tasks
711
- // $last_updated_time=time();
712
- // foreach (self::$cleanup_tasks as $key => $value){
713
- // $task_name = $value;
714
- // $task_data = array(
715
- // 'task_id' => $task_name,
716
- // 'task_status' => 'queued',
717
- // 'task_allocated_id'=>'',
718
- // 'task_last_updated'=>$last_updated_time
719
- // );
720
- // $task_created = update_post_meta( $job_id, $task_name, $task_data );
721
- //
722
- // if (false===$task_created){
723
- // $logger->log_error( __METHOD__, 'Tasks NOT created');
724
- // return false;
725
- // }
726
- // $logger->log_info( __METHOD__, 'task created:' . $task_created );
727
- // }
728
- //
729
- // $logger->log_info(__METHOD__,'End');
730
- // return true;
731
- //
732
- // }
733
-
734
- /**
735
- * @return mixed
736
- */
737
- public function get_job_start_time() {
738
- return $this->job_start_time;
739
- }
740
-
741
- /**
742
- * @return mixed
743
- */
744
- public function get_job_end_time() {
745
- return $this->job_end_time;
746
- }
747
-
748
- /**
749
- * Get Job status
750
- * @return mixed
751
- */
752
- public function get_job_status() {
753
- return $this->job_status;
754
- }
755
- }
756
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-logger.php DELETED
@@ -1,219 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed (logger)');
2
-
3
- /**
4
- * WP Backitup Logging Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
-
12
- class WPBackItUp_Logger {
13
-
14
- private $dfh;
15
- private $logging;
16
-
17
- public $logFileName;
18
- public $logFilePath;
19
-
20
- public function __construct($delete_log, $path=null, $file_name=null, $debugOverride=false) {
21
- global $WPBackitup;
22
-
23
- $this->logging = $WPBackitup->logging();
24
-
25
- //If override debug flag then turn logging on.
26
- if (true===$debugOverride) $this->logging=true;
27
-
28
- //check for optional parms
29
- if (!is_string($path)){
30
- $path = WPBACKITUP__PLUGIN_PATH .'/logs';
31
- }
32
-
33
- if (!is_string($file_name)){
34
- $file_name='debug';
35
- }
36
-
37
-
38
- $this->logFileName=$file_name .'.log';
39
- $this->logFilePath= $path .'/'. $this->logFileName;
40
-
41
- try {
42
- //If debug then open the file handle
43
- if (true===$this->logging){
44
-
45
- //Delete log first
46
- if ($delete_log && file_exists($this->logFilePath)) {
47
- unlink($this->logFilePath);
48
- }
49
-
50
- $this->dfh = fopen($this->logFilePath, 'a');
51
- fwrite($this->dfh, "** Open LOG File ** ". PHP_EOL);
52
- }
53
- } catch(Exception $e) {
54
- //Dont do anything
55
- print $e;
56
- }
57
- }
58
-
59
- function __destruct() {
60
- $this->close_file();
61
- }
62
-
63
- public function close_file() {
64
- try {
65
- if (!is_null($this->dfh) && is_resource($this->dfh)){
66
- fwrite($this->dfh, "** Close LOG File ** ". PHP_EOL);
67
- fclose($this->dfh);
68
- }
69
- } catch(Exception $e) {
70
- //Dont do anything
71
- print $e;
72
- }
73
-
74
- $this->dfh=null;
75
- }
76
-
77
- function log($message) {
78
- try{
79
- if (true===$this->logging){
80
- if (!is_null($this->dfh) && is_resource($this->dfh)){
81
- $date = date_i18n('Y-m-d H:i:s',current_time( 'timestamp' ));
82
- if( is_array( $message ) || is_object( $message ) ){
83
- fwrite($this->dfh, $date ." " .print_r( $message, true ) . PHP_EOL);
84
- } else {
85
- fwrite($this->dfh, $date ." " .$message . PHP_EOL);
86
- }
87
- }
88
- }
89
- } catch(Exception $e) {
90
- //Dont do anything
91
- print $e;
92
- }
93
- }
94
-
95
- //Log Errors
96
- public function log_info($function,$message, $additional_message=null) {
97
- $function='(' . $function . ') INFO: ' . $additional_message;
98
- if( is_array( $message ) || is_object( $message ) ){
99
- $this->log($function);
100
- $this->log($message);
101
- } else {
102
- $this->log($function . $message);
103
- }
104
- }
105
-
106
- //Log Errors
107
- public function log_error($function,$message,$additional_message=null) {
108
- $function='(' . $function . ') ERROR: ' . $additional_message;
109
- if( is_array( $message ) || is_object( $message ) ){
110
- $this->log($function);
111
- $this->log($message);
112
- } else {
113
- $this->log($function .$message);
114
- }
115
- }
116
-
117
- //Log warning
118
- public function log_warning($function,$message,$additional_message=null) {
119
- $function='(' . $function . ') WARNING: ' . $additional_message;
120
- if( is_array( $message ) || is_object( $message ) ){
121
- $this->log($function);
122
- $this->log($message);
123
- } else {
124
- $this->log($function .$message);
125
- }
126
- }
127
-
128
- function log_sysinfo() {
129
- global $wpdb,$WPBackitup;
130
- try{
131
- if (true===$this->logging){
132
-
133
- $this->log("**SYSTEM INFO**");
134
-
135
- $this->log("\n--Site Info--");
136
- $this->log('Site URL:' . site_url());
137
- $this->log('Home URL:' . home_url());
138
- $this->log('Multisite:' . ( is_multisite() ? 'Yes' : 'No' )) ;
139
-
140
- $this->log("\n--Wordpress Info--");
141
- $this->log("Wordpress Version:" . get_bloginfo( 'version'));
142
- $this->log('Language:' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ));
143
- $this->log('Table Prefix:' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ));
144
- $this->log('WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ));
145
- $this->log('Memory Limit:' . WP_MEMORY_LIMIT );
146
-
147
-
148
- $this->log("\n--WordPress Active Plugins--");
149
- // Check if get_plugins() function exists. This is required on the front end of the
150
- // site, since it is in a file that is normally only loaded in the admin.
151
- if ( ! function_exists( 'get_plugins' ) ) {
152
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
153
- }
154
-
155
- $plugins = get_plugins();
156
- $active_plugins = get_option( 'active_plugins', array() );
157
- foreach( $plugins as $plugin_path => $plugin ) {
158
- if( !in_array( $plugin_path, $active_plugins ) ) continue;
159
-
160
- $this->log( $plugin['Name'] . ': ' . $plugin['Version']);
161
- }
162
-
163
- // WordPress inactive plugins
164
- $this->log("\n" . '--WordPress Inactive Plugins--');
165
-
166
- foreach( $plugins as $plugin_path => $plugin ) {
167
- if( in_array( $plugin_path, $active_plugins ) )
168
- continue;
169
-
170
- $this->log($plugin['Name'] . ': ' . $plugin['Version']);
171
- }
172
-
173
- $this->log("\n--Server Info--");
174
- $this->log('PHP Version:' . PHP_VERSION);
175
- $this->log('Webserver Info:' . $_SERVER['SERVER_SOFTWARE']);
176
- $this->log('MySQL Version:' . $wpdb->db_version());
177
-
178
-
179
- $this->log("\n--PHP Info--");
180
- $this->log("PHP Info:" . phpversion());
181
- $this->log("Operating System:" . php_uname());
182
-
183
- if ( @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on' ){
184
- $this->log("PHP Safe Mode: On");
185
- } else{
186
- $this->log("PHP Safe Mode: Off");
187
- }
188
-
189
- if ( @ini_get('sql.safe_mode') || strtolower(@ini_get('sql.safe_mode')) == 'on' ){
190
- $this->log("SQL Safe Mode: On");
191
- } else{
192
- $this->log("SQL Safe Mode: Off");
193
- }
194
- $this->log("Script Max Execution Time:" . ini_get('max_execution_time'));
195
- $this->log('Memory Limit:' . ini_get( 'memory_limit' ));
196
- $this->log('Upload Max Size:' . ini_get( 'upload_max_filesize' ));
197
- $this->log('Post Max Size:' . ini_get( 'post_max_size' ));
198
- $this->log('Upload Max Filesize:' . ini_get( 'upload_max_filesize' ));
199
- $this->log('Max Input Vars:' . ini_get( 'max_input_vars' ));
200
- $this->log('Display Errors:' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ));
201
-
202
-
203
- $this->log("\n--WP BackItUp Info--");
204
- $this->log("WPBACKITUP License Active: " . ($WPBackitup->license_active() ? 'true' : 'false'));
205
- $prefix='WPBACKITUP';
206
- foreach (get_defined_constants() as $key=>$value)
207
- {
208
- if (substr($key,0,strlen($prefix))==$prefix) {
209
- $this->log($key . ':' . $value);
210
- }
211
- }
212
- $this->log("**END SYSTEM INFO**");
213
- }
214
- } catch(Exception $e) {
215
- //Dont do anything
216
- print $e;
217
- }
218
- }
219
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-recursiveFilter_Iterator.php DELETED
@@ -1,34 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup Recurse Iterator
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
-
12
-
13
- class WPBackItUp_RecursiveFilter_Iterator extends RecursiveFilterIterator {
14
-
15
- private $filters=array();
16
- private $logger;
17
-
18
- //Set the ignore list
19
- function set_filter ($ignore) {
20
- $this->filters = $ignore;
21
- }
22
-
23
- public function accept() {
24
- $logger = new WPBackItUp_Logger(false);
25
- $accept = !in_array(
26
- $this->current()->getFilename(),
27
- $this->filters,
28
- true);
29
-
30
- $logger->log('(WPBackItUp_RecursiveFilter_Iterator) accept:' . $this->current()->getFilename() . ":" .$accept);
31
- return $accept;
32
- }
33
-
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-restore.php DELETED
@@ -1,1085 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Backup Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
- class WPBackItUp_Restore {
11
-
12
- private $logger;
13
-
14
- //Public Properties
15
- private $backup_id;
16
- private $backup_name;
17
- private $backup_folder_path;
18
- private $restore_root_folder_path;
19
- private $restore_staging_suffix;
20
-
21
- const SITEDATAPATH = 'site-data';
22
- const PLUGINSPATH = 'wp-content-plugins';
23
- const THEMESPATH = 'wp-content-themes';
24
- const OTHERPATH = 'wp-content-other';
25
- const UPLOADPATH = 'wp-content-uploads';
26
-
27
- function __construct($logger, $backup_name, $backup_id) {
28
- //global $WPBackitup;
29
-
30
- try {
31
- $this->logger = $logger;
32
-
33
- $this->backup_name=$backup_name;
34
- $this->backup_folder_path = WPBACKITUP__BACKUP_PATH .'/' .$backup_name;
35
-
36
- $this->restore_root_folder_path = WPBACKITUP__RESTORE_PATH;
37
-
38
- $this->backup_id=$backup_id;
39
- $this->restore_staging_suffix = '_' .$backup_id;
40
-
41
-
42
- } catch(Exception $e) {
43
- $this->logger->log($e);
44
- print $e;
45
- }
46
- }
47
-
48
- function __destruct() {
49
-
50
- }
51
-
52
- public function delete_restore_folder() {
53
- $this->logger->log_info( __METHOD__, 'Begin delete restore folders.' );
54
-
55
- //get a list of all the folders
56
- $item_list = glob($this->restore_root_folder_path .'/*');
57
- return $this->delete_folders($item_list);
58
- }
59
-
60
- public function delete_staged_folders() {
61
- $this->logger->log_info( __METHOD__, 'Begin delete staged folders.' );
62
-
63
- //get a list of all the staged folders
64
- $item_list = glob(WPBACKITUP__CONTENT_PATH .'/*'.$this->restore_staging_suffix .'*');
65
- return $this->delete_folders($item_list);
66
-
67
- }
68
-
69
- private function delete_folders($item_list) {
70
- $this->logger->log_info( __METHOD__, 'Begin' );
71
-
72
- $this->logger->log_info( __METHOD__, 'Folders to be deleted:' );
73
- $this->logger->log($item_list);
74
-
75
- $file_system = new WPBackItUp_FileSystem($this->logger);
76
- foreach($item_list as $item) {
77
- if (is_dir($item)) {
78
- if (! $file_system->recursive_delete( $item )){
79
- $this->logger->log_error( __METHOD__, 'Folder could NOT be deleted:' . $item);
80
- return false;
81
- }
82
- }else{
83
- if (! unlink($item)){
84
- $this->logger->log_error( __METHOD__, 'File could NOT be deleted:' . $item);
85
- return false;
86
- }
87
- }
88
- }
89
-
90
- $this->logger->log_info( __METHOD__, 'End' );
91
- return true;
92
- }
93
-
94
-
95
- //Create an empty restore folder
96
- public function create_restore_root_folder() {
97
- $this->logger->log_info(__METHOD__,'Create restore folder.' . $this->restore_root_folder_path);
98
-
99
- $fileSystem = new WPBackItUp_FileSystem($this->logger);
100
- if( $fileSystem->create_dir($this->restore_root_folder_path)) {
101
- //Secure restore folder
102
- $fileSystem->secure_folder( $this->restore_root_folder_path);
103
- return true;
104
-
105
- } else{
106
- return false;
107
- }
108
-
109
- }
110
-
111
- //Unzip the backup to the restore folder
112
- function unzip_archive_file($backup_set_list){
113
- $this->logger->log_info(__METHOD__,'Begin');
114
-
115
- if (count($backup_set_list)<=0) return false;
116
-
117
- $backup_file_path = $backup_set_list[0];
118
- $this->logger->log_info(__METHOD__,'Begin - Unzip Backup File:' .$backup_file_path);
119
- try {
120
- $zip = new ZipArchive;
121
- $res = $zip->open($backup_file_path);
122
- if ($res === TRUE) {
123
- if (true===$zip->extractTo($this->restore_root_folder_path)){
124
- $zip->close();
125
- } else {
126
- $zip->close();
127
- $this->logger->log_error(__METHOD__,'Cant unzip backup:'.$backup_file_path);
128
- return false;
129
- }
130
- } else {
131
- $this->logger->log_error(__METHOD__,'Cant open backup archive:'.$backup_file_path);
132
- return false;
133
- }
134
-
135
- $this->logger->log_info(__METHOD__,'Backup file unzipped: ' .$backup_file_path);
136
-
137
- } catch(Exception $e) {
138
- $this->logger->log_error(__METHOD__,'An Unexpected Error has happened: ' .$e);
139
- return false;
140
- }
141
-
142
- return true;
143
- }
144
-
145
- //Validate the restore folder
146
- function validate_restore_folder(){
147
- $this->logger->log_info(__METHOD__,'Begin');
148
-
149
- $restore_folder_root=$this->restore_root_folder_path . '/';
150
- $this->logger->log_info(__METHOD__,'Validate restore folder : ' .$restore_folder_root);
151
-
152
-
153
- //Do we have at least 4 folders - other may sometimes not be there
154
- if ( count( glob( $restore_folder_root.'*', GLOB_ONLYDIR ) ) < 4 ) {
155
- $this->logger->log_error(__METHOD__,'Restore directory INVALID: ' .$restore_folder_root);
156
- return false;
157
- }
158
-
159
-
160
- $site_data_folder = $restore_folder_root .self::SITEDATAPATH;
161
- if(!is_dir($site_data_folder) ){
162
- $this->logger->log_error(__METHOD__,'site-data missing from restore folder:' .$site_data_folder);
163
- return false;
164
- }
165
-
166
- $plugins_folder = $restore_folder_root .self::PLUGINSPATH;
167
- if(!is_dir($plugins_folder) ){
168
- $this->logger->log_error(__METHOD__,'wp-content-plugins missing from restore folder:' .$plugins_folder);
169
- return false;
170
- }
171
-
172
- $themes_folder = $restore_folder_root .self::THEMESPATH;
173
- if(!is_dir($themes_folder) ){
174
- $this->logger->log_error(__METHOD__,'wp-content-themes missing from restore folder:' .$themes_folder);
175
- return false;
176
- }
177
-
178
- //Not an error
179
- $other_folder = $restore_folder_root .self::OTHERPATH;
180
- if(!is_dir($other_folder) ){
181
- $this->logger->log_info(__METHOD__,'wp-content-other missing from restore folder:' .$other_folder);
182
- }
183
-
184
- $uploads_folder = $restore_folder_root .self::UPLOADPATH;
185
- if(!is_dir($uploads_folder) ){
186
- $this->logger->log_error(__METHOD__,'wp-content-uploads missing from restore folder:' .$uploads_folder);
187
- return false;
188
- }
189
-
190
- $this->logger->log_info(__METHOD__,'End - Restoration directory validated: ' .$restore_folder_root);
191
- return true;
192
- }
193
-
194
- //Validate the restore folder
195
- function validate_siteinfo_file(){
196
- $this->logger->log_info(__METHOD__,'Begin');
197
-
198
- $site_info_path = $this->restore_root_folder_path . '/' .self::SITEDATAPATH .'/backupsiteinfo.txt';
199
- $this->logger->log_info(__METHOD__,'Validate Site info file: ' . $site_info_path);
200
- if(! file_exists($site_info_path) || empty($site_info_path)) {
201
- $this->logger->log_error(__METHOD__,'backupsiteinfo.txt missing or empty ' .$site_info_path);
202
- return false;
203
- }
204
-
205
-
206
- //Get file values
207
- $this->logger->log_info(__METHOD__, 'GET Site Info data' );
208
- $import_siteinfo_lines = file( $site_info_path);
209
- if (count($import_siteinfo_lines)<3){
210
- $this->logger->log_error(__METHOD__,'Site Data file NOT valid.' );
211
- return false;
212
- } else {
213
- $restore_siteurl = str_replace( "\n", '', trim( $import_siteinfo_lines[0] ) );
214
- $restore_table_prefix = str_replace( "\n", '', $import_siteinfo_lines[1] );
215
- $restore_wp_version = str_replace( "\n", '', $import_siteinfo_lines[2] );
216
- $restore_wpbackitup_version = str_replace( "\n", '', $import_siteinfo_lines[3] );
217
-
218
- $site_data = array (
219
- 'restore_siteurl'=>$restore_siteurl,
220
- 'restore_table_prefix'=>$restore_table_prefix,
221
- 'restore_wp_version'=>$restore_wp_version,
222
- 'restore_wpbackitup_version'=>$restore_wpbackitup_version,
223
- );
224
-
225
- $this->logger->log_info(__METHOD__,'Site Data:' );
226
- $this->logger->log($site_data);
227
- return $site_data;
228
- }
229
-
230
- }
231
-
232
- //Validate the manifest
233
- function validate_manifest_file($backup_set_list, &$error_code){
234
- $this->logger->log_info(__METHOD__,'Begin');
235
-
236
- $manifest_file_path = $this->restore_root_folder_path . '/' .self::SITEDATAPATH .'/backupmanifest.txt';
237
- $this->logger->log_info(__METHOD__,'Validate backup manifest: ' . $manifest_file_path);
238
-
239
- if(! file_exists($manifest_file_path) || empty($manifest_file_path)) {
240
- $this->logger->log_info(__METHOD__,'No manifest found.');
241
- return true; //Old backups will not have a manifest - OK
242
- }
243
-
244
- $manifest_data_string = file_get_contents($manifest_file_path);
245
- if (false===$manifest_data_string || empty($manifest_data_string)){
246
- $this->logger->log_error(__METHOD__,'Manifest empty.');
247
- $error_code=1;
248
- return false;
249
- }
250
-
251
- // make sure all the files in the manifest are part of the set
252
- $manifest_data_array = json_decode($manifest_data_string,true);
253
- foreach($manifest_data_array as $zip_file)
254
- {
255
- //does this file exist in the set
256
- if (false===$this->search_array($zip_file, $backup_set_list)){
257
- $this->logger->log_error(__METHOD__,'Zip File Missing:' .$zip_file);
258
- $error_code=2;
259
- return false;
260
- }
261
- }
262
-
263
- // Do we have any extra zip files
264
- foreach($backup_set_list as $zip_file)
265
- {
266
- //does this file exist in the manifest
267
- if (false===$this->search_array(basename($zip_file), $manifest_data_array)){
268
- $this->logger->log_error(__METHOD__,'Zip File Not in manifest:' .$zip_file);
269
- $error_code=3;
270
- return false;
271
- }
272
- }
273
-
274
- $this->logger->log_info(__METHOD__,'End' );
275
- return true;
276
-
277
- }
278
-
279
- private function search_array($search, $array)
280
- {
281
- foreach($array as $key => $value)
282
- {
283
- if (stristr($value, $search))
284
- {
285
- return $key;
286
- }
287
- }
288
- return false;
289
- }
290
-
291
- //Make sure there IS a backup to restore
292
- function validate_SQL_exists(){
293
- $this->logger->log_info(__METHOD__,'Begin');
294
-
295
- $backup_sql_file = $this->restore_root_folder_path . '/' .self::SITEDATAPATH . '/' . WPBACKITUP__SQL_DBBACKUP_FILENAME;
296
- $this->logger->log_info(__METHOD__,'Check for database backup file' . $backup_sql_file);
297
- if(!file_exists($backup_sql_file) || empty($backup_sql_file)) {
298
- $this->logger->log_error(__METHOD__,'Database backup file NOT FOUND.');
299
- return false;
300
- }
301
-
302
- $this->logger->log_info(__METHOD__,'Database backup file exists');
303
- return true;
304
- }
305
-
306
- public function export_database(){
307
- $this->logger->log_info(__METHOD__,'Begin');
308
-
309
- $date = date_i18n('Y-m-d-Hi',current_time( 'timestamp' ));
310
- $backup_file = $this->backup_folder_path .'/'. 'db-backup-' . $date .'.cur';
311
-
312
- $sqlUtil = new WPBackItUp_SQL($this->logger);
313
- $this->logger->log_info(__METHOD__,'Begin - Export Database: ' .$backup_file);
314
-
315
- //Try SQLDump First
316
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP');
317
- if(!$sqlUtil->mysqldump_export($backup_file) ) {
318
-
319
- $this->logger->log_info(__METHOD__,'Export DB with MYSQLDUMP/PATH');
320
- if(!$sqlUtil->mysqldump_export($backup_file,true) ) {
321
-
322
- $this->logger->log_info(__METHOD__,'Export DB with Manual SQL EXPORT');
323
- if(!$sqlUtil->manual_export($backup_file) ) {
324
- $this->logger->log_error(__METHOD__,'SQL EXPORT FAILED');
325
- return false;
326
- }
327
- }
328
- }
329
- $this->logger->log_info(__METHOD__,'Database Exported successfully');
330
-
331
- return true;
332
- }
333
-
334
-
335
- public function rename_folder($from_folder_name,$to_folder_name){
336
- $this->logger->log_info(__METHOD__,'Begin');
337
- $this->logger->log_info(__METHOD__,'Rename from folder name:' . $from_folder_name);
338
- $this->logger->log_info(__METHOD__,'Rename to folder name: '. $to_folder_name);
339
-
340
- $file_system = new WPBackItUp_FileSystem($this->logger);
341
- if ( !$file_system->rename_file($from_folder_name,$to_folder_name)) {
342
- $this->logger->log_error(__METHOD__,'Folder could not be renamed');
343
- return false;
344
- }
345
-
346
- $this->logger->log_info(__METHOD__,'End');
347
-
348
- return true;
349
- }
350
-
351
- // Restore everything but plugins
352
- public function restore_wpcontent(){
353
- $this->logger->log_info(__METHOD__,'Begin');
354
- $error_folders = array();
355
- $error_files = array();
356
-
357
- //Create the archive folder
358
- $archive_folder = $this->restore_root_folder_path .'/Archive'.$this->restore_staging_suffix;
359
- if (! is_dir($archive_folder)){
360
- mkdir($archive_folder);
361
- }
362
-
363
- //Get all staged directories and rename them
364
- //Plugins, backup & restore folders wereent staged
365
- $wpcontent_folder_list = glob(WPBACKITUP__CONTENT_PATH .'/*'.$this->restore_staging_suffix ,GLOB_ONLYDIR);
366
- foreach ( $wpcontent_folder_list as $from_folder_name ) {
367
-
368
- $folder_name_only = basename( $from_folder_name );
369
- $this->logger->log_info(__METHOD__,'Folder name:' . $folder_name_only);
370
-
371
- $to_folder_name = WPBACKITUP__CONTENT_PATH . '/' . str_replace( $this->restore_staging_suffix, '', $folder_name_only );
372
-
373
- //rename the existing folder to OLD if exists
374
- $archive_success=true;
375
- if (is_dir($to_folder_name)){
376
- //try to rename it 5 times
377
- $archive_folder_name = $archive_folder .'/' .str_replace( $this->restore_staging_suffix, '', $folder_name_only );
378
- for ($i = 1; $i <= 5; $i++) {
379
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
380
- if ( $this->rename_folder($to_folder_name,$archive_folder_name)) {
381
- $archive_success=true;
382
- break; // break out if rename successful
383
- }else{
384
- $archive_success=false;
385
- sleep(1); //give it a second
386
- }
387
- }
388
- }
389
-
390
- $rename_success=false;
391
- //Rename the staged folder
392
- if ($archive_success) {
393
- for ($i = 1; $i <= 5; $i++) {
394
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
395
- if ( $this->rename_folder( $from_folder_name, $to_folder_name ) ) {
396
- $rename_success=true;
397
- break; // break out if rename successful
398
- }else{
399
- $rename_success=false;
400
- sleep(1); //give it a second
401
- }
402
- }
403
- }
404
-
405
- //keep going on failure
406
- if (! $rename_success){
407
- array_push($error_folders,$from_folder_name);
408
- $this->logger->log_error(__METHOD__, 'Cant restore folder.' .$from_folder_name );
409
- }
410
- }
411
-
412
-
413
- if (count($error_folders)>0){
414
- $this->logger->log_error(__METHOD__,'End - Error Folders:');
415
- $this->logger->log($error_folders);
416
- return $error_folders;
417
- }
418
-
419
- $this->logger->log_info(__METHOD__,'End Restont WPContent Folders- No errors');
420
-
421
- //NOW restore the files
422
- $wpcontent_files_only = array_filter(glob($this->restore_root_folder_path .'/' .self::OTHERPATH .'/*'), 'is_file');
423
- foreach ( $wpcontent_files_only as $from_file_name ) {
424
- $file_name_only = basename( $from_file_name );
425
-
426
- $this->logger->log_info(__METHOD__,'WPContent File name:' . $file_name_only);
427
-
428
- //Archive the old file
429
- $to_file_name = WPBACKITUP__CONTENT_PATH .'/' . $file_name_only;
430
- $archive_success=true;
431
- if (file_exists($to_file_name)){
432
-
433
- //try to rename it 5 times
434
- $archive_file_name = $archive_folder .'/' . $file_name_only;
435
- for ($i = 1; $i <= 5; $i++) {
436
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
437
- if ( $this->rename_folder($to_file_name,$archive_file_name)) {
438
- $archive_success=true;
439
- break; // break out if rename successful
440
- }else{
441
- $archive_success=false;
442
- sleep(1); //give it a second
443
- }
444
- }
445
- }
446
-
447
- $rename_success=false;
448
- if ($archive_success){
449
- //Restore the file
450
- for ($i = 1; $i <= 5; $i++) {
451
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
452
- if ( $this->rename_folder( $from_file_name, $to_file_name ) ) {
453
- $rename_success=true;
454
- break; // break out if rename successful
455
- }else{
456
- $rename_success=false;
457
- sleep(1); //give it a second
458
- }
459
- }
460
-
461
- }
462
-
463
- //keep going on failure but add file to list
464
- if (!$rename_success){
465
- array_push($error_files,$from_folder_name);
466
- $this->logger->log_error(__METHOD__, 'Cant restore file.' .$from_file_name );
467
-
468
- }
469
- }
470
-
471
-
472
- if (count($error_files)>0) {
473
- $this->logger->log_error(__METHOD__,'End - Error Files:');
474
- $this->logger->log($error_files);
475
- return $error_folders;
476
- } else{
477
- $this->logger->log_info(__METHOD__,'End Restore WPContent - No errors');
478
- return true;
479
- }
480
-
481
- }
482
-
483
- public function restore_plugins(){
484
- $this->logger->log_info(__METHOD__,'Begin');
485
- $error_folders = array();
486
- $error_files = array();
487
-
488
- //Create the archive folder if it doesnt exist
489
- $archive_folder = $this->restore_root_folder_path .'/Archive'.$this->restore_staging_suffix;
490
- if (! is_dir($archive_folder)){
491
- mkdir($archive_folder);
492
- }
493
-
494
- //Create the plugins archive
495
- $plugin_archive_folder = $archive_folder .'/' . basename(WPBACKITUP__PLUGINS_ROOT_PATH);
496
- if (! is_dir($plugin_archive_folder)){
497
- mkdir($plugin_archive_folder);
498
- }
499
-
500
-
501
- //Move the folders ONLY
502
- $plugins_folder_list = glob($this->restore_root_folder_path .'/' .self::PLUGINSPATH .'/*' ,GLOB_ONLYDIR);
503
- foreach ( $plugins_folder_list as $from_folder_name ) {
504
- $folder_name_only = basename( $from_folder_name );
505
-
506
- //Dont restore wp backitup plugin
507
- $this->logger->log_info(__METHOD__,'Plugin Folder name:' . $folder_name_only);
508
- if ( $folder_name_only != WPBACKITUP__PLUGIN_FOLDER) {
509
-
510
- //Archive the old plugin
511
- $to_folder_name = WPBACKITUP__PLUGINS_ROOT_PATH .'/' . $folder_name_only;
512
- $archive_success=true;
513
- if (is_dir($to_folder_name)){
514
-
515
- //try to rename it 5 times
516
- $archive_folder_name = $plugin_archive_folder .'/' . $folder_name_only;
517
- for ($i = 1; $i <= 5; $i++) {
518
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
519
- if ( $this->rename_folder($to_folder_name,$archive_folder_name)) {
520
- $archive_success=true;
521
- break; // break out if rename successful
522
- }else{
523
- $archive_success=false;
524
- sleep(1); //give it a second
525
- }
526
- }
527
- }
528
-
529
- $rename_success=false;
530
- if ($archive_success){
531
- //Restore the plugin
532
- for ($i = 1; $i <= 5; $i++) {
533
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
534
- if ( $this->rename_folder( $from_folder_name, $to_folder_name ) ) {
535
- $rename_success=true;
536
- break; // break out if rename successful
537
- }else{
538
- $rename_success=false;
539
- sleep(1); //give it a second
540
- }
541
- }
542
-
543
- }
544
-
545
- //keep going on failure but add folder to list
546
- if (!$rename_success){
547
- array_push($error_folders,$from_folder_name);
548
- $this->logger->log_error(__METHOD__, 'Cant restore plugin folder.' .$from_folder_name );
549
- }
550
- }
551
- }
552
-
553
-
554
- //If error on folders then return
555
- if (count($error_folders)>0){
556
- $this->logger->log_error(__METHOD__,'End - Error Folders:');
557
- $this->logger->log($error_folders);
558
- return $error_folders;
559
- }
560
- $this->logger->log_info(__METHOD__, 'End restore plugin folders.');
561
-
562
-
563
- //NOW move the files
564
- $plugins_files_only = array_filter(glob($this->restore_root_folder_path .'/' .self::PLUGINSPATH .'/*'), 'is_file');
565
- foreach ( $plugins_files_only as $from_file_name ) {
566
- $file_name_only = basename( $from_file_name );
567
-
568
- $this->logger->log_info(__METHOD__,'Plugin File name:' . $file_name_only);
569
-
570
- //Archive the old file
571
- $to_file_name = WPBACKITUP__PLUGINS_ROOT_PATH .'/' . $file_name_only;
572
- $archive_success=true;
573
- if (file_exists($to_file_name)){
574
-
575
- //try to rename it 5 times
576
- $archive_file_name = $plugin_archive_folder .'/' . $file_name_only;
577
- for ($i = 1; $i <= 5; $i++) {
578
- $this->logger->log_info(__METHOD__,'Archive attempt:' . $i);
579
- if ( $this->rename_folder($to_file_name,$archive_file_name)) {
580
- $archive_success=true;
581
- break; // break out if rename successful
582
- }else{
583
- $archive_success=false;
584
- sleep(1); //give it a second
585
- }
586
- }
587
- }
588
-
589
- $rename_success=false;
590
- if ($archive_success){
591
- //Restore the plugin
592
- for ($i = 1; $i <= 5; $i++) {
593
- $this->logger->log_info(__METHOD__,'Restore attempt:' . $i);
594
- if ( $this->rename_folder( $from_file_name, $to_file_name ) ) {
595
- $rename_success=true;
596
- break; // break out if rename successful
597
- }else{
598
- $rename_success=false;
599
- sleep(1); //give it a second
600
- }
601
- }
602
-
603
- }
604
-
605
- //keep going on failure but add file to list
606
- if (!$rename_success){
607
- array_push($error_files,$from_folder_name);
608
- $this->logger->log_error(__METHOD__, 'Cant restore plugin file.' .$from_file_name );
609
-
610
- }
611
- }
612
-
613
-
614
- if (count($error_files)>0) {
615
- $this->logger->log_error(__METHOD__,'End - Error Files:');
616
- $this->logger->log($error_files);
617
- return $error_folders;
618
- } else{
619
- $this->logger->log_info(__METHOD__,'End Restore Plugins - No errors');
620
- return true;
621
- }
622
-
623
-
624
- }
625
-
626
- public function restore_database(){
627
- $this->logger->log_info(__METHOD__,'Begin - restore database.');
628
-
629
- $backup_sql_file = $this->restore_root_folder_path . '/' .self::SITEDATAPATH . '/' . WPBACKITUP__SQL_DBBACKUP_FILENAME;
630
- return $this->run_sql_from_file($backup_sql_file);
631
-
632
- }
633
-
634
- private function run_sql_from_file($sql_file_path){
635
- $this->logger->log_info(__METHOD__,'Begin - SQL: '. $sql_file_path);
636
-
637
-
638
- $dbc = new WPBackItUp_SQL($this->logger);
639
- if(!$dbc->run_sql_exec($sql_file_path)) {
640
- //try with sql path on this time
641
- if(!$dbc->run_sql_exec($sql_file_path,true)) {
642
- //Try manually
643
- if ( ! $dbc->run_sql_manual( $sql_file_path ) ) {
644
- $this->logger->log_error( __METHOD__, 'Database import error.' );
645
- return false;
646
- }
647
- }
648
- }
649
-
650
- $this->logger->log_info(__METHOD__,'End');
651
- return true;
652
- }
653
-
654
- public function activate_plugins(){
655
- $this->logger->log_info(__METHOD__,'Begin');
656
-
657
- $plugins = get_plugins();
658
- foreach ( $plugins as $plugin => $value ) {
659
- //Activate plugin if NOT already active
660
- if (! is_plugin_active($plugin) ) {
661
- $result = activate_plugin($plugin);
662
- if ( is_wp_error( $result ) ) {
663
- $this->logger->log_error(__METHOD__,'Plugin could NOT be activated:' .$plugin);
664
- } else{
665
- $this->logger->log_info(__METHOD__,'Plugin activated:' .$plugin);
666
- }
667
- }
668
- }
669
-
670
- $this->logger->log_info(__METHOD__,'End');
671
- return true;
672
- }
673
-
674
- public function deactivate_plugins(){
675
- $this->logger->log_info(__METHOD__,'Begin');
676
-
677
- $plugins = get_option('active_plugins');
678
- foreach ($plugins as $plugin) {
679
- //dont deactivate wp-backitup
680
- if ('wp-backitup/wp-backitup.php' != $plugin){
681
- deactivate_plugins($plugin);
682
- $this->logger->log_info(__METHOD__,'Plugin Deactivated:' . $plugin);
683
- }
684
- }
685
-
686
- $this->logger->log_info(__METHOD__,'End');
687
- }
688
-
689
- //get siteurl
690
- public function get_siteurl(){
691
- global $table_prefix;
692
- $this->logger->log_info(__METHOD__,'Begin');
693
-
694
- $sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='siteurl';";
695
- $dbc = new WPBackItUp_SQL($this->logger);
696
- $siteurl = $dbc->get_sql_scalar($sql);
697
- if (empty($siteurl)) {
698
- $this->logger->log_error(__METHOD__,'Siteurl not found');
699
- return false;
700
- }
701
-
702
- $this->logger->log_info(__METHOD__,'End - Siteurl found:' .$siteurl);
703
- return $siteurl;
704
- }
705
-
706
- //get homeurl
707
- function get_homeurl(){
708
- global $table_prefix;
709
- $this->logger->log_info(__METHOD__,'Begin');
710
-
711
- $sql = "SELECT option_value FROM " .$table_prefix ."options WHERE option_name ='home';";
712
- $dbc = new WPBackItUp_SQL($this->logger);
713
- $homeurl = $dbc->get_sql_scalar($sql);
714
- if (empty($homeurl)) {
715
- $this->logger->log_error(__METHOD__,' Homeurl not found.');
716
- return false;
717
- }
718
- $this->logger->log_info(__METHOD__,'End - homeurl found:' . $homeurl);
719
- return $homeurl;
720
- }
721
-
722
- //get user login
723
- function get_user_login($user_id){
724
- global $table_prefix;
725
- $this->logger->log_info(__METHOD__,'Begin');
726
-
727
- $sql = "SELECT user_login FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
728
-
729
- $dbc = new WPBackItUp_SQL($this->logger);
730
- $user_login = $dbc->get_sql_scalar($sql);
731
- if (empty($user_login)) {
732
- $this->logger->log_error(__METHOD__,'User_login not found.');
733
- return false;
734
- }
735
-
736
- $this->logger->log_info(__METHOD__,'End - User_login found.');
737
- return $user_login;
738
- }
739
-
740
- //get user pass
741
- function get_user_pass($user_id){
742
- global $table_prefix;
743
- $this->logger->log_info(__METHOD__,'Begin');
744
-
745
- $sql = "SELECT user_pass FROM ". $table_prefix ."users WHERE ID=" .$user_id .";";
746
-
747
- $dbc = new WPBackItUp_SQL($this->logger);
748
- $user_pass = $dbc->get_sql_scalar($sql);
749
- if (empty($user_pass)) {
750
- $this->logger->log_error(__METHOD__,'User_pass not found.');
751
- return false;
752
- }
753
- $this->logger->log_info(__METHOD__,'End - User_pass found.');
754
- return $user_pass;
755
- }
756
-
757
- //get user email
758
- function get_user_email($user_id){
759
- global $table_prefix;
760
- $this->logger->log_info(__METHOD__,'Begin');
761
-
762
- $sql = "SELECT user_email FROM ". $table_prefix ."users WHERE ID=" .$user_id ."";
763
- $dbc = new WPBackItUp_SQL($this->logger);
764
- $user_email = $dbc->get_sql_scalar($sql);
765
- if (empty($user_email)) {
766
- $this->logger->log_error(__METHOD__,'User_email not found.');
767
- return false;
768
- }
769
- $this->logger->log_info(__METHOD__,'End - User_email found.');
770
- return $user_email;
771
- }
772
-
773
-
774
- //Update user credentials
775
- function update_user_credentials($user_id, $user_login, $user_pass_hash, $user_email,$table_prefix){
776
- $this->logger->log_info(__METHOD__,'Begin');
777
-
778
- //prefer SQL update because password hash is safer than plain text update
779
- $sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass_hash ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
780
- $dbc = new WPBackItUp_SQL($this->logger);
781
- if (!$dbc->run_sql_command($sql)){
782
- $this->logger->log_error(__METHOD__,'User Credential database update failed.');
783
- return false;
784
- }
785
- $this->logger->log_info(__METHOD__,'End - User Credential updated in database.');
786
- return true;
787
- }
788
-
789
- //Create user
790
- function create_user_XXX($current_user){
791
- $this->logger->log_info(__METHOD__,'Begin');
792
-
793
- $user_id = wp_insert_user( $current_user ) ;
794
- if( is_wp_error($user_id) ) {
795
- $this->logger->log_error(__METHOD__,'User was not created:' .$user_id->get_error_message());
796
- return false;
797
- }
798
-
799
- $this->logger->log_info(__METHOD__,'End - New user created:' . $user_id);
800
- return true;
801
- }
802
-
803
-
804
- //update credentials
805
- function update_credentials($user_id, $user_full_name, $user_login, $user_pass_hash, $user_email,$table_prefix){
806
- $this->logger->log_info(__METHOD__,'Begin');
807
-
808
- //prefer SQL update because password hash is safer than plain text update
809
-
810
- $dbc = new WPBackItUp_SQL($this->logger);
811
-
812
- //Fetch the user
813
- $sql = "SELECT id from " . $table_prefix ."users where user_login = '" .$user_login ."'";
814
- $query_result = $dbc->get_sql_scalar($sql);
815
- $this->logger->log_info(__METHOD__,'Fetch user by login:' .$query_result);
816
-
817
- if (!empty($query_result)) {
818
- $this->logger->log_info(__METHOD__,'Update User Credentials.');
819
- //update the user
820
- $sql = "UPDATE ". $table_prefix ."users SET user_login='" .$user_login ."', user_pass='" .$user_pass_hash ."', user_email='" .$user_email ."' WHERE ID='" .$user_id ."'";
821
- $dbc = new WPBackItUp_SQL($this->logger);
822
- if (!$dbc->run_sql_command($sql)){
823
- $this->logger->log_error(__METHOD__,'User Credential database update failed.');
824
- return false;
825
- }
826
- $this->logger->log_info(__METHOD__,'End - User Credential updated in database.');
827
- return true;
828
-
829
-
830
- } else {
831
- $this->logger->log_info(__METHOD__,'Create User Credentials.');
832
- //Create the user
833
- $sql = "INSERT INTO ". $table_prefix ."users (user_login, user_nicename, display_name, user_pass, user_email, user_registered, user_status) values('" .$user_login ."','" .$user_full_name ."','" .$user_full_name ."','" .$user_pass_hash ."','" .$user_email ."', NOW() ,'0')";
834
- if (!$dbc->run_sql_command($sql)){
835
- $this->logger->log_error(__METHOD__,'User insert failed.');
836
- return false;
837
- }else{
838
- $this->logger->log_info(__METHOD__,'User inserted in database successfully.');
839
- }
840
-
841
- //Get the new user ID
842
- $sql = "SELECT id from " . $table_prefix ."users where user_login = '" .$user_login ."'";
843
- $user_id = $dbc->get_sql_scalar($sql);
844
- $this->logger->log_info(__METHOD__,'Fetch user by id:' .$user_id);
845
-
846
- $sql = "INSERT INTO ". $table_prefix ."usermeta (user_id, meta_key, meta_value) values(" .$user_id .",'wp_capabilities', 'a:1:{s:13:\"administrator\";s:1:\"1\";}')";
847
- if (!$dbc->run_sql_command($sql)){
848
- $this->logger->log_error(__METHOD__,'user capabilities insert failed.');
849
- return false;
850
- }else {
851
- $this->logger->log_info(__METHOD__,'User capabilities inserted successfully.');
852
- }
853
-
854
- $sql = "INSERT INTO ". $table_prefix ."usermeta (user_id, meta_key, meta_value) values(" .$user_id .",'wp_user_level', '10')";
855
- if (!$dbc->run_sql_command($sql)){
856
- $this->logger->log_error(__METHOD__,'User level insert failed');
857
- return false;
858
- }else{
859
- $this->logger->log_info(__METHOD__,'User level inserted successfully.');
860
- }
861
-
862
- $this->logger->log_info(__METHOD__,'End - User created in database successfully.');
863
- return true;
864
- }
865
-
866
- }
867
-
868
- //update the site URL in the restored database
869
- function update_siteurl($table_prefix, $current_siteurl){
870
- $this->logger->log_info(__METHOD__,'Begin');
871
-
872
- $sql = "UPDATE ". $table_prefix ."options SET option_value='" .$current_siteurl ."' WHERE option_name='siteurl'";
873
- $dbc = new WPBackItUp_SQL($this->logger);
874
- if (!$dbc->run_sql_command($sql)){
875
- $this->logger->log('Error: SiteURL updated failed.');
876
- return false;
877
- }
878
- $this->logger->log_info(__METHOD__,'End - SiteURL updated in database:' .$current_siteurl);
879
- return true;
880
- }
881
-
882
- //Update homeURL
883
- function update_homeurl($table_prefix, $homeurl){
884
- $this->logger->log_info(__METHOD__,'Begin');
885
-
886
- $sql = "UPDATE ". $table_prefix ."options SET option_value='" .$homeurl ."' WHERE option_name='home'";
887
- $dbc = new WPBackItUp_SQL($this->logger);
888
- if (!$dbc->run_sql_command($sql)){
889
- $this->logger->log(__METHOD__,'HomeURL database update failed..');
890
- return false;
891
- }
892
- $this->logger->log_info(__METHOD__,'End - HomeURL updated in database:'.$homeurl);
893
- return true;
894
- }
895
-
896
- function update_permalinks(){
897
- global $wp_rewrite;
898
- $this->logger->log_info(__METHOD__,'Begin');
899
-
900
- try {
901
- $wp_rewrite->flush_rules( true );//Update permalinks - hard flush
902
-
903
- }catch(Exception $e) {
904
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
905
- return false;
906
- }
907
- $this->logger->log_info(__METHOD__,'End - Permalinks updated.');
908
- return true;
909
- }
910
-
911
- public function zip_logs(){
912
- $this->logger->log_info(__METHOD__,'Begin');
913
-
914
- //Zip up all the logs in the log folder
915
- $logs_path = WPBACKITUP__PLUGIN_PATH .'logs';
916
- $zip_file_path = $logs_path .'/Restore_Logs_' .$this->backup_id . '.zip';
917
-
918
- //copy/replace WP debug file
919
- $wpdebug_file_path = WPBACKITUP__CONTENT_PATH . '/debug.log';
920
- $this->logger->log_info(__METHOD__,"Copy WP Debug: " .$wpdebug_file_path);
921
- if (file_exists($wpdebug_file_path)) {
922
- copy( $wpdebug_file_path, $logs_path .'/wpdebug.log' );
923
- }
924
-
925
- $zip = new WPBackItUp_Zip($this->logger,$zip_file_path);
926
- $zip->zip_files_in_folder($logs_path,$this->backup_id,'*.log');
927
- $zip->close();
928
-
929
- $this->logger->log_info(__METHOD__,'End');
930
-
931
- return $zip_file_path;
932
-
933
- }
934
-
935
- function send_notification_email($err, $success,$logs=array(),$notification_email) {
936
- global $logger,$status_array,$backup_job;
937
- $logger->log_info(__METHOD__,"Begin");
938
-
939
- $utility = new WPBackItUp_Utility($logger);
940
-
941
- if($success)
942
- {
943
- //Don't send logs on success unless debug is on.
944
- if (WPBACKITUP__DEBUG!==true){
945
- $logs=array();
946
- }
947
-
948
- $subject = get_bloginfo() . ' - Restore completed successfully.';
949
- $message = '<b>Your site was restored successfully.</b><br/><br/>';
950
-
951
- } else {
952
- $subject = get_bloginfo() .' - Backup did not complete successfully.';
953
- $message = '<b>Your restore did not complete successfully.</b><br/><br/>';
954
- }
955
-
956
- $local_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',current_time( 'timestamp' )));
957
- $message .= 'WordPress Site: <a href="' . home_url() . '" target="_blank">' . home_url() .'</a><br/>';
958
- $message .= 'Restore date: ' . $local_datetime . '<br/>';
959
-
960
- //$message .= 'Completion Code: ' . $backup_job->backup_id .'-'. $processing_minutes .'-' .$processing_seconds .'<br/>';
961
- $message .= 'WP BackItUp Version: ' . WPBACKITUP__VERSION . '<br/>';
962
- $message .= '<br/>';
963
-
964
-
965
- //Add the completed steps on success
966
- // if($success) {
967
- // $message .='<b>Steps Completed</b><br/>';
968
- //
969
- // //Add the completed statuses
970
- // foreach ($status_array as $status_key => $status_value) {
971
- // if ($status_value==2) {
972
- // foreach ($status_description as $msg_key => $msg_value) {
973
- // if ($status_key==$msg_key) {
974
- // $message .= $msg_value . '<br/>';
975
- // break;
976
- // }
977
- // }
978
- // }
979
- // }
980
- // } else {
981
- // //Error occurred
982
- // $message .= '<br/>';
983
- // $message .= 'Errors:<br/>' . get_error_message($err);
984
- // }
985
-
986
- // $term='success';
987
- // if(!$success)$term='error';
988
- // $message .='<br/><br/>Checkout '. $WPBackitup->get_anchor_with_utm('www.wpbackitup.com', '', 'notification+email', $term) .' for info about WP BackItUp and our other products.<br/>';
989
-
990
-
991
- if($notification_email)
992
- $utility->send_email($notification_email,$subject,$message,$logs);
993
-
994
- $logger->log_info(__METHOD__,"End");
995
- }
996
-
997
- function save_process_status($process,$status){
998
- $this->logger->log_info(__METHOD__,"Begin");
999
-
1000
- //Write status to JSON file - cant use database because it will e restored
1001
- $local_datetime = get_date_from_gmt(date( 'Y-m-d H:i:s',current_time( 'timestamp' )));
1002
- $process_status = array(
1003
- 'status' => $status,
1004
- 'start_time'=>$local_datetime,
1005
- 'end_time' =>''
1006
- );
1007
-
1008
- $log_file_path = WPBACKITUP__PLUGIN_PATH .'logs/restore_' .$this->backup_id .'.log';
1009
- $restore_status_string=false;
1010
- if (file_exists($log_file_path)){
1011
- $restore_status_string = file_get_contents($log_file_path);
1012
- }
1013
-
1014
- if (false===$restore_status_string || empty($restore_status_string)){
1015
- $restore_status_array=array($process=>$process_status);
1016
- } else{
1017
- $restore_status_array = json_decode($restore_status_string,true);
1018
-
1019
- //Does the process already exist
1020
- if (! array_key_exists ($process,$restore_status_array)){
1021
- //Add to existing array
1022
- $restore_status_array[$process]=$process_status;
1023
- }else{
1024
- //update the end time
1025
- $restore_status_array[$process]['end_time'] = $local_datetime;
1026
- $restore_status_array[$process]['status'] = $status;
1027
- }
1028
-
1029
- }
1030
-
1031
- $restore_status_string = json_encode($restore_status_array);
1032
- file_put_contents($log_file_path, $restore_status_string);
1033
-
1034
- $this->logger->log_info(__METHOD__,"End");
1035
- }
1036
-
1037
-
1038
-
1039
-
1040
-
1041
- /** GETTERS */
1042
-
1043
- /**
1044
- * @return string
1045
- */
1046
- public function get_backup_folder_path() {
1047
- return $this->backup_folder_path;
1048
- }
1049
-
1050
- /**
1051
- * @return string
1052
- */
1053
- public function get_restore_root_folder_path() {
1054
- return $this->restore_root_folder_path;
1055
- }
1056
-
1057
- /**
1058
- * @return string
1059
- */
1060
- // public function get_restore_folder_path() {
1061
- // return $this->restore_folder_path;
1062
- // }
1063
-
1064
- /**
1065
- * @return mixed
1066
- */
1067
- public function get_backup_name() {
1068
- return $this->backup_name;
1069
- }
1070
-
1071
- /**
1072
- * @return string
1073
- */
1074
- public function get_restore_staging_suffix() {
1075
- return $this->restore_staging_suffix;
1076
- }
1077
-
1078
- /**
1079
- * @return mixed
1080
- */
1081
- public function get_backup_id() {
1082
- return $this->backup_id;
1083
- }
1084
-
1085
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-scheduler.php DELETED
@@ -1,161 +0,0 @@
1
- <?php
2
- /**
3
- * WP BackItUp Scheduler Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
- class WPBackItUp_Scheduler {
12
-
13
-
14
- private $logger;
15
-
16
- /**
17
- * Constructor
18
- */
19
- function __construct() {
20
-
21
- $this->logger = new WPBackItUp_Logger(false,null,'debug_scheduler');
22
-
23
- }
24
-
25
- /**
26
- * Destructor
27
- */
28
- function __destruct() {
29
- $this->logger->close_file();
30
- }
31
-
32
-
33
- /**
34
- * Check to see if task is ready to run
35
- *
36
- * @param $task
37
- * @return bool
38
- */
39
- public function isTaskScheduled($task){
40
- $this->logger->log('Check schedule for task: ' . $task);
41
- switch ($task) {
42
- case "backup":
43
- return $this->check_backup_schedule();
44
- break;
45
- case "cleanup":
46
- return $this->check_cleanup_schedule();
47
- break;
48
- }
49
-
50
- $this->logger->log('Task not found:' . $task);
51
- return false;
52
- }
53
-
54
- /**
55
- * Check the backup schedule to determine if the backup
56
- * task should be run today.
57
- *
58
- * @return bool
59
- */
60
- private function check_backup_schedule(){
61
- global $WPBackitup;
62
- $this->logger->log('**Check Backup Schedule**');
63
-
64
- try {
65
-
66
- ///ONLY active premium get this feature
67
- if (!$WPBackitup->license_active() || 'expired'== $WPBackitup->license_status()){
68
- $this->logger->log('License is not active');
69
- return false;
70
- }
71
-
72
- //Get days scheduled to run on.
73
- $scheduled_dow = $WPBackitup->backup_schedule();
74
- $this->logger->log('Scheduled Days of week: ' .$scheduled_dow); //1=monday, 2=tuesday..
75
-
76
- //What is the current day of the week
77
- $current_datetime = current_time( 'timestamp' );
78
- $current_date = date("Ymd",$current_datetime);
79
- $current_dow = date("N",$current_datetime); //1=monday
80
-
81
- $this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
82
- $this->logger->log('Current Day of Week:' . $current_dow );
83
-
84
- //Get Last RUN date
85
- $lastrun_datetime = $WPBackitup->backup_lastrun_date();
86
-
87
- $lastrun_date = date("Ymd",$lastrun_datetime);
88
- $lastrun_dow =0;//0=none
89
- if ($lastrun_datetime!=-2147483648){// 1901-12-13:never run
90
- $lastrun_dow = date("N",$lastrun_datetime);
91
- }
92
-
93
- $this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
94
- $this->logger->log('Last Run Day of Week:' . $lastrun_dow);
95
-
96
- //Did backup already run today
97
- if ($current_date==$lastrun_date){
98
- $this->logger->log('Backup already ran today');
99
- return false;
100
- }
101
-
102
- //Should it run on this day of the week
103
- if (false===strpos($scheduled_dow,$current_dow)){
104
- $this->logger->log('Not scheduled for: ' .$current_dow);
105
- return false;
106
- }
107
-
108
- $this->logger->log('Backup should be run now.');
109
- return true;
110
-
111
- }catch(Exception $e) {
112
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
113
- return false;
114
- }
115
-
116
- }
117
-
118
- /**
119
- * Check the cleanup schedule to determine if the task should be run today.
120
- * Cleanup will be run once per day
121
- *
122
- * @return bool
123
- */
124
- private function check_cleanup_schedule(){
125
- global $WPBackitup;
126
- $this->logger->log('**Check Cleanup Schedule**');
127
- try {
128
-
129
- //What is the current day of the week
130
- $current_datetime = current_time( 'timestamp' );
131
- $current_date = date("Ymd",$current_datetime);
132
-
133
- $this->logger->log('Current Date time:' . date( 'Y-m-d H:i:s',$current_datetime));
134
-
135
- //Get Last RUN date
136
- $lastrun_datetime = $WPBackitup->cleanup_lastrun_date();
137
-
138
- $lastrun_date = date("Ymd",$lastrun_datetime);
139
- $this->logger->log('Last Run Date Time:' . date( 'Y-m-d H:i:s',$lastrun_datetime));
140
-
141
- //Has it been at least an hour since the last cleanup?
142
-
143
- $next_run_datetime=$lastrun_datetime+3600; //1 hour
144
- $this->logger->log('Next Run Date Time:' . date( 'Y-m-d H:i:s',$next_run_datetime));
145
-
146
- $this->logger->log('TimeToRun:' . $current_datetime . ':'.$next_run_datetime );
147
- if ($current_datetime>=$next_run_datetime){
148
- $this->logger->log('Cleanup should be run now.');
149
- return true;
150
- }
151
-
152
- $this->logger->log('Not yet time to run Cleanup.');
153
- return false;
154
-
155
- }catch(Exception $e) {
156
- $this->logger->log_error(__METHOD__,'Exception: ' .$e);
157
- return false;
158
- }
159
-
160
- }
161
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-sql.php DELETED
@@ -1,520 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
-
3
- /**
4
- * WP Backitup SQL Class
5
- *
6
- * @package WP Backitup
7
- *
8
- * @author cssimmon
9
- *
10
- */
11
- class WPBackItUp_SQL {
12
-
13
- private $logger;
14
- private $connection;
15
-
16
- function __construct($logger) {
17
- try {
18
- $this->logger = $logger;
19
- $this->connection = $this->get_sqlconnection();
20
-
21
- } catch(Exception $e) {
22
- //Dont do anything
23
- print $e;
24
- }
25
- }
26
-
27
- function __destruct() {
28
- // Close the connection
29
- $this->connection->close() ;
30
- }
31
-
32
- public function mysqldump_export($sql_file_path,$with_mysqlpath=false) {
33
-
34
- $this->logger->log('(SQL.mysqldump_export) Export Database to: ' .$sql_file_path);
35
-
36
- $db_name = DB_NAME;
37
- $db_user = DB_USER;
38
- $db_pass = DB_PASSWORD;
39
- $db_host = $this->get_hostonly(DB_HOST);
40
- $db_port = $this->get_portonly(DB_HOST);
41
-
42
- //This is to ensure that exec() is enabled on the server
43
- if(exec('echo EXEC') == 'EXEC') {
44
- try {
45
- $mysql_path='';
46
- if ($with_mysqlpath) {
47
- $mysql_path = $this->get_mysql_path();
48
- if ($mysql_path===false) return false;
49
- }
50
-
51
- $process = $mysql_path .'mysqldump';
52
- $command = $process
53
- . ' --host=' . $db_host;
54
-
55
- //Check for port
56
- if (false!==$db_port){
57
- $command .=' --port=' . $db_port;
58
- }
59
-
60
- $command .=
61
- ' --user=' . $db_user
62
- . ' --password=' . $db_pass
63
- .=' ' . $db_name
64
- . ' > "' . $sql_file_path .'"';
65
-
66
- if (WPBACKITUP__DEBUG) {
67
- $this->logger->log('(SQL.db_SQLDump)Execute command:' . $command);
68
- }
69
-
70
- exec($command,$output,$rtn_var);
71
- $this->logger->log('(SQL.mysqldump_export)Execute output:');
72
- $this->logger->log($output);
73
- $this->logger->log('Return Value:' .$rtn_var);
74
-
75
- //0 is success
76
- if ($rtn_var>0){
77
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED return Value:' .$rtn_var);
78
- return false;
79
- }
80
-
81
- //Did the export work
82
- clearstatcache();
83
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
84
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED: Dump was empty or missing.');
85
- return false;
86
- }
87
- } catch(Exception $e) {
88
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exception: ' .$e);
89
- return false;
90
- }
91
- }
92
- else
93
- {
94
- $this->logger->log('(SQL.mysqldump_export) EXPORT FAILED Exec() disabled.');
95
- return false;
96
- }
97
-
98
- $this->logger->log('(SQL.mysqldump_export) SQL Dump SUCCESS.');
99
- return true;
100
- }
101
-
102
-
103
- public function manual_export($sql_file_path) {
104
- $this->logger->log('(SQL.manual_export)Manually Create SQL Backup File:'.$sql_file_path);
105
-
106
- $mysqli = $this->connection;
107
- $mysqli->set_charset('utf8');
108
-
109
- if (false===$mysqli) {
110
- return false;
111
- }
112
-
113
- // Script Header Information
114
- $return = '';
115
- $return .= "-- ------------------------------------------------------\n";
116
- $return .= "-- ------------------------------------------------------\n";
117
- $return .= "--\n";
118
- $return .= "-- WP BackItUp Manual Database Backup \n";
119
- $return .= "--\n";
120
- $return .= '-- Created: ' . date("Y/m/d") . ' on ' . date("h:i") . "\n";
121
- $return .= "--\n";
122
- $return .= "-- Database : " . DB_NAME . "\n";
123
- $return .= "--\n";
124
- $return .= "-- ------------------------------------------------------\n";
125
- $return .= "-- ------------------------------------------------------\n";
126
- $return .= 'SET AUTOCOMMIT = 0 ;' ."\n" ;
127
- $return .= 'SET FOREIGN_KEY_CHECKS=0 ;' ."\n" ;
128
- $return .= "\n";
129
- $return .= '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' ."\n" ;
130
- $return .= '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;' ."\n" ;
131
- $return .= '/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;' ."\n" ;
132
- $return .= '/*!40101 SET NAMES utf8 */;' ."\n" ;
133
-
134
- $tables = array() ;
135
-
136
- // Exploring what tables this database has
137
- $result = $mysqli->query('SHOW TABLES' ) ;
138
-
139
- // Cycle through "$result" and put content into an array
140
- while ($row = $result->fetch_row()) {
141
- $tables[] = $row[0] ;
142
- }
143
-
144
- // Cycle through each table
145
- foreach($tables as $table) {
146
- // Get content of each table
147
- $result = $mysqli->query('SELECT * FROM '. $table) ;
148
-
149
- // Get number of fields (columns) of each table
150
- $num_fields = $mysqli->field_count ;
151
-
152
- // Add table information
153
- $return .= "--\n" ;
154
- $return .= '-- Table structure for table `' . $table . '`' . "\n" ;
155
- $return .= "--\n" ;
156
- $return.= 'DROP TABLE IF EXISTS `'.$table.'`;' . "\n" ;
157
-
158
- // Get the table-shema
159
- $shema = $mysqli->query('SHOW CREATE TABLE '.$table) ;
160
-
161
- // Extract table shema
162
- $tableshema = $shema->fetch_row() ;
163
-
164
- // Append table-shema into code
165
- $return.= $tableshema[1].";" . "\n\n" ;
166
-
167
- // Cycle through each table-row
168
- while($rowdata = $result->fetch_row()) {
169
-
170
- $return.= 'INSERT INTO '.$table.' VALUES(';
171
- for($j=0; $j<$num_fields; $j++){
172
- $rowdata[$j] = addslashes($rowdata[$j]);
173
- $rowdata[$j] = str_replace("\n","\\n",$rowdata[$j]);
174
-
175
- if (isset($rowdata[$j])) {
176
- $return.= '"'.$rowdata[$j].'"' ;
177
- } else {
178
- if (is_null($rowdata[$j])) {
179
- $return.= 'NULL';//Dont think this is working but not causing issues
180
- } else {
181
- $return.= '""';
182
- }
183
- }
184
-
185
- if ($j<($num_fields-1)) { $return.= ','; }
186
- }
187
- $return.= ");\n";
188
- }
189
- $return .= "\n\n" ;
190
- }
191
-
192
- $return .= 'SET FOREIGN_KEY_CHECKS = 1 ; ' . "\n" ;
193
- $return .= 'COMMIT ; ' . "\n" ;
194
- $return .= 'SET AUTOCOMMIT = 1 ; ' . "\n" ;
195
-
196
- //save file
197
- $handle = fopen($sql_file_path,'w+');
198
- fwrite($handle,$return);
199
- fclose($handle);
200
- clearstatcache();
201
-
202
- //Did the export work
203
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
204
- $this->logger->log('(SQL.manual_export) Failure: SQL Export file was empty or didnt exist.');
205
- return false;
206
- }
207
-
208
- $this->logger->log('(SQL.manual_export)SQL Backup File Created:'.$sql_file_path);
209
- return true;
210
- }
211
-
212
- public function run_sql_exec($sql_file,$with_mysqlpath=false) {
213
- $this->logger->log('(SQL.run_sql_exec)SQL Execute:' .$sql_file);
214
-
215
- //Is the backup sql file empty
216
- if (!file_exists($sql_file) || filesize($sql_file)<=0) {
217
- $this->logger->log('(SQL.run_sql_exec) Failure: SQL File was empty:' .$sql_file);
218
- return false;
219
- }
220
-
221
- //This is to ensure that exec() is enabled on the server
222
- if(exec('echo EXEC') != 'EXEC') {
223
- $this->logger->log('(SQL.run_sql_exec) Failure: Exec() disabled.');
224
- return false;
225
- }
226
-
227
- try {
228
-
229
- $mysql_path='';
230
- if ($with_mysqlpath) {
231
- $mysql_path = $this->get_mysql_path();
232
- if ($mysql_path===false) return false;
233
- }
234
-
235
- $db_name = DB_NAME;
236
- $db_user = DB_USER;
237
- $db_pass = DB_PASSWORD;
238
- $db_host = $this->get_hostonly(DB_HOST);
239
- $db_port = $this->get_portonly(DB_HOST);
240
-
241
- $process = $mysql_path .'mysql';
242
- $command = $process
243
- . ' --host=' . $db_host;
244
-
245
- //Check for port
246
- if (false!==$db_port){
247
- $command .=' --port=' . $db_port;
248
- }
249
-
250
- $command .=
251
- ' --user=' . $db_user
252
- . ' --password=' . $db_pass
253
- . ' --database=' . $db_name
254
- . ' --execute="SOURCE ' . $sql_file .'"';
255
-
256
- if (WPBACKITUP__DEBUG) {
257
- $this->logger->log( '(SQL.db_run_sql)Execute command:' . $command );
258
- }
259
-
260
- //$output = shell_exec($command);
261
- exec($command,$output,$rtn_var);
262
- $this->logger->log('(SQL.run_sql_exec)Execute output:');
263
- $this->logger->log($output);
264
- $this->logger->log('Return Value:' .$rtn_var);
265
-
266
- //0 is success
267
- if ($rtn_var!=0){
268
- $this->logger->log('(SQL.run_sql_exec) An Error has occurred RTNVAL: ' .$rtn_var);
269
- return false;
270
- }
271
-
272
- }catch(Exception $e) {
273
- $this->logger->log('(SQL.run_sql_exec) Exception: ' .$e);
274
- return false;
275
- }
276
-
277
- //Success
278
- $this->logger->log('(SQL.run_sql_exec)SQL Executed successfully');
279
- return true;
280
- }
281
-
282
- public function run_sql_manual_OLD($sql_file) {
283
- $this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file);
284
-
285
- //Is the backup sql file empty
286
- if (!file_exists($sql_file) || filesize($sql_file)<=0) {
287
- $this->logger->log('(SQL.run_sql_manual) Failure: SQL File was empty:' .$sql_file);
288
- return false;
289
- }
290
-
291
- $query = file_get_contents($sql_file);
292
- if (empty($query)) return false;
293
-
294
- try {
295
-
296
- $mysqli = $this->get_sqlconnection();
297
- $mysqli->set_charset('utf8');
298
-
299
- if (false===$mysqli) {
300
- return false;
301
- }
302
-
303
- $ctr=1;
304
- $this->logger->log('(SQL.run_sql_manual) 0: here ');
305
- if($mysqli->multi_query($query))
306
- {
307
- do {
308
-
309
- $this->logger->log('(SQL.run_sql_manual) 1: ' .$ctr++);
310
- /* store first result set */
311
- if($resultSet = $mysqli->store_result())
312
- {
313
- $this->logger->log('(SQL.run_sql_manual) 2: ');
314
-
315
- while($row = $resultSet->fetch_row())
316
- {
317
- $this->logger->log('(SQL.run_sql_manual) 3: ');
318
- }
319
- $resultSet->free();
320
- }
321
-
322
- if (!$mysqli->more_results()) break; //All done
323
-
324
- } while ($mysqli->next_result());
325
-
326
- $this->logger->log('(SQL.run_sql_manual) 4: ');
327
- $mysqli->close();
328
- }
329
-
330
- }catch(Exception $e) {
331
- $this->logger->log('(SQL.run_sql_manual) Exception: ' .$e);
332
- return false;
333
- }
334
-
335
- //Success
336
- $this->logger->log('(SQL.run_sql_manual)SQL Executed successfully:' .$sql_file);
337
- return true;
338
- }
339
-
340
- function run_sql_manual($sql_file_path, $delimiter = ';')
341
- {
342
- $this->logger->log('(SQL.run_sql_manual)SQL Execute:' .$sql_file_path);
343
- set_time_limit(0);
344
-
345
- //Is the backup sql file empty
346
- if (!file_exists($sql_file_path) || filesize($sql_file_path)<=0) {
347
- $this->logger->log('(SQL.run_sql_manual) Failure: SQL File was empty:' .$sql_file_path);
348
- return false;
349
- }
350
-
351
- try {
352
- if (is_file($sql_file_path) === true)
353
- {
354
- $sql_handle = fopen($sql_file_path, 'r');
355
-
356
- if (is_resource($sql_handle) === true)
357
- {
358
- $query = array();
359
-
360
- $mysqli = $this->get_sqlconnection();
361
- $mysqli->set_charset('utf8');
362
- // $mysqli->autocommit(FALSE);
363
- // $mysqli->begin_transaction();
364
-
365
- if (false===$mysqli) {
366
- return false;
367
- }
368
-
369
- $error_count=0;
370
- $total_query=0;
371
- while (feof($sql_handle) === false)
372
- {
373
- $query[] = fgets($sql_handle);
374
-
375
- if (preg_match('~' . preg_quote($delimiter, '~') . '\s*$~iS', end($query)) === 1)
376
- {
377
- $query = trim(implode('', $query));
378
-
379
- //Execute SQL statement
380
- $total_query++;
381
- if ($mysqli->query($query) === false) {
382
- $error_count++;
383
-
384
- $this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
385
- $this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
386
-
387
- $this->logger->log('(SQL.run_sql_manual) SQL ERROR: ' . $query);
388
-
389
- //$mysqli->rollback();
390
- $mysqli->close();
391
-
392
- fclose($sql_handle);
393
- return false;
394
- }
395
- // else {
396
- // $this->logger->log('(SQL.run_sql_manual) SUCCESS: ' . $query);
397
- // }
398
-
399
- while (ob_get_level() > 0)
400
- {
401
- ob_end_flush();
402
- }
403
-
404
- flush();
405
- }
406
-
407
- if (is_string($query) === true)
408
- {
409
- $query = array();
410
- }
411
- }
412
-
413
- //$mysqli->commit();
414
- $mysqli->close();
415
-
416
- $this->logger->log('(SQL.run_sql_manual)SQL Executed successfully:' .$sql_file_path);
417
- $this->logger->log('(SQL.run_sql_manual)Total Queries Executed:' .$total_query);
418
- $this->logger->log('(SQL.run_sql_manual)Query Errors:' .$error_count);
419
- return fclose($sql_handle);
420
- }
421
- }
422
-
423
- }catch(Exception $e) {
424
- $this->logger->log('(SQL.run_sql_manual) Exception: ' .$e);
425
- return false;
426
- }
427
-
428
- $this->logger->log('(SQL.run_sql_manual)SQL File could not be opened:' .$sql_file_path);
429
- return false;
430
- }
431
-
432
- private function get_sqlconnection() {
433
- $this->logger->log('(SQL.get_sqlconnection)Get SQL connection to database.');
434
- $db_name = DB_NAME;
435
- $db_user = DB_USER;
436
- $db_pass = DB_PASSWORD;
437
- $db_host = $this->get_hostonly(DB_HOST);
438
- $db_port = $this->get_portonly(DB_HOST);
439
-
440
- $this->logger->log('(SQL.get_sqlconnection)Host:' . $db_host);
441
- $this->logger->log('(SQL.get_sqlconnection)Port:' . $db_port);
442
-
443
- if (false===$db_port){
444
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name);
445
- }
446
- else {
447
- $mysqli = new mysqli($db_host , $db_user , $db_pass , $db_name,$db_port);
448
- }
449
-
450
- if ($mysqli->connect_errno) {
451
- $this->logger->log('(SQL.get_sqlconnection)Cannot connect to database.' . $mysqli->connect_error);
452
- return false;
453
- }
454
- return $mysqli;
455
- }
456
-
457
- private function get_hostonly($db_host) {
458
- //Check for port
459
- $host_array = explode(':',$db_host);
460
- if (is_array($host_array)){
461
- return $host_array[0];
462
- }
463
- return $db_host;
464
- }
465
-
466
- private function get_portonly($db_host) {
467
- //Check for port
468
- $host_array = explode(':',$db_host);
469
- if (is_array($host_array) && count($host_array)>1){
470
- return $host_array[1];
471
- }
472
-
473
- return false;
474
- }
475
-
476
- //Get SQL scalar value
477
- public function get_sql_scalar($sql){
478
- $value='';
479
- if ($result = mysqli_query($this->connection, $sql)) {
480
- while ($row = mysqli_fetch_row($result)) {
481
- $value = $row[0];
482
- }
483
- mysqli_free_result($result);
484
- }
485
- return $value;
486
- }
487
-
488
- //Run SQL command
489
- public function run_sql_command($sql){
490
- if(!mysqli_query($this->connection, $sql) ) {
491
- $this->logger->log('Error:SQL Command Failed:' .$sql);
492
- return false;
493
- }
494
- return true;
495
- }
496
-
497
- //Get path to MQSQL Bin
498
- private function get_mysql_path(){
499
- $base_directory = $this->get_sql_scalar('select @@basedir');
500
- if (!empty($base_directory)){
501
- $base_directory.='/bin/';
502
- $this->logger->log('MySQL install path found:' .$base_directory);
503
- return $base_directory;
504
- }
505
- $this->logger->log('MySQL install path NOT found');
506
- return false;
507
- }
508
-
509
- //This function is untested
510
- // function get_database_size($dbname) {
511
- // mysqli_select_db($dbname);
512
- // $result = mysqli_query("SHOW TABLE STATUS");
513
- // $dbsize = 0;
514
- // while($row = mysqli_fetch_array($result)) {
515
- // $dbsize += $row["Data_length"] + $row["Index_length"];
516
- // }
517
- // return $dbsize;
518
- // }
519
-
520
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-utility.php DELETED
@@ -1,83 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Utility Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
- class WPBackItUp_Utility {
11
-
12
- private $logger;
13
-
14
- function __construct($logger) {
15
- try {
16
- $this->logger = $logger;
17
- } catch(Exception $e) {
18
- //Dont do anything
19
- print $e;
20
- }
21
- }
22
-
23
- function __destruct() {
24
-
25
- }
26
-
27
-
28
- function send_email($to,$subject,$message,$attachments=array(),$reply_email=null)
29
- {
30
- try {
31
- //global $WPBackitup;
32
- if($to) {
33
-
34
- $from_email = get_bloginfo( 'admin_email' );
35
- $headers[] = 'Content-type: text/html';
36
- $headers[] = 'From: WP BackItUp <'. $from_email .'>';
37
-
38
- if (null!=$reply_email) {
39
- $headers[] = 'Reply-To: <'. $reply_email .'>';
40
- }
41
-
42
- wp_mail($to, $subject, nl2br($message), $headers,$attachments);
43
- $this->logger->log('(send_email)EMail Sent from:' .$from_email);
44
- $this->logger->log('(send_email)EMail Sent to:' .$to);
45
- }
46
-
47
- } catch(Exception $e) {
48
- //Dont do anything
49
- $this->logger->log('(send_email)Send Email Exception:'.$e);
50
- }
51
-
52
- }
53
-
54
- //Function for PHP version 5.2
55
- //Diff Approximation only
56
- function date_diff_days($date1,$date2 ){
57
-
58
- $date_diff_seconds = $this->date_diff_seconds($date1,$date2 );
59
- $days = round($date_diff_seconds/86400);
60
- return $days;
61
- }
62
-
63
- //Function for PHP version 5.2
64
- //Diff Approximation only
65
- function date_diff_seconds($date1,$date2 ){
66
- // the necessary way using PHP 5.2
67
- $date1_string = $date1->format('U');
68
- $date2_string = $date2->format('U');
69
-
70
- // get a difference represented as an int, number of seconds
71
- $date_diff_seconds = abs($date1_string - $date2_string);
72
-
73
- return $date_diff_seconds;
74
- }
75
-
76
- function timestamp_diff_seconds($timestamp1,$timestamp2 ){
77
- // get a difference represented as an int, number of seconds
78
- $timestamp_diff_seconds = abs($timestamp1 - $timestamp2);
79
-
80
- return $timestamp_diff_seconds;
81
- }
82
- }
83
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tags/1.10.1/lib/includes/class-wpbackitup-admin.php DELETED
@@ -1,1741 +0,0 @@
1
- <?php if (!defined ('ABSPATH')) die('No direct access allowed');
2
- /**
3
- * WP Backitup Admin Class
4
- *
5
- * @package WP Backitup
6
- *
7
- * @author cssimmon
8
- *
9
- */
10
-
11
-
12
- class WPBackitup_Admin {
13
-
14
- public $namespace = WPBACKITUP__NAMESPACE;
15
- public $friendly_name = WPBACKITUP__FRIENDLY_NAME;
16
- public $version = WPBACKITUP__VERSION;
17
-
18
- private static $instance = false;
19
-
20
- //Use Getters
21
- private $license_key;//Loaded in getter
22
- private $license_type; //Loaded in getter
23
- private $license_expires;
24
-
25
- private $license_active;//Loaded in getter
26
- private $license_status;//Loaded in getter
27
- private $license_status_message;//Loaded in getter
28
- private $license_type_description; //Getter will load
29
-
30
- private $backup_retained_number; //Getter will load
31
- private $notification_email;//Getter will load
32
- private $logging;//Getter will load
33
-
34
- private $backup_count; //getter will load
35
- private $successful_backup_count;
36
-
37
- public $backup_type;
38
-
39
-
40
- // Default plugin options
41
- public $defaults = array(
42
- 'logging' => false,
43
- 'license_key' => "lite",
44
- 'license_last_check_date'=> "1970-01-01 00:00:00",
45
- 'license_status' => "",
46
- 'license_status_message'=> "",
47
- 'license_type' => "0",
48
- 'license_expires'=> "1970-01-01 00:00:00",
49
- 'license_limit'=> "1",
50
- 'license_sitecount'=> "",
51
- 'notification_email' => "",
52
- 'backup_retained_number' => "3",
53
- 'lite_backup_retained_number' => "1",
54
- 'lite_registration_email' => "",
55
- 'lite_registration_first_name' => "",
56
- 'backup_count'=>0,
57
- 'successful_backup_count'=>0,
58
- 'stats_last_check_date'=> "1970-01-01 00:00:00",
59
- 'backup_schedule'=>"",
60
- 'backup_lastrun_date'=>"-2147483648",
61
- 'cleanup_lastrun_date'=>"-2147483648",
62
- 'backup_batch_size'=>"500",
63
- 'support_email' => "",
64
- );
65
-
66
-
67
- /**
68
- * Retrieve the current WP backItUp instance.
69
- */
70
- public static function get_instance() {
71
- if ( ! self::$instance ) {
72
- self::$instance = new self();
73
- }
74
-
75
- return self::$instance;
76
- }
77
-
78
- /**
79
- * Instantiation construction
80
- *
81
- */
82
- private function __construct() {
83
- /**
84
- * Make this plugin available for translation.
85
- * Translations can be added to the /languages/ directory.
86
- */
87
-
88
- //TODO: Add multi Language Support back
89
- //load_theme_textdomain( $this->namespace, WPBACKITUP__PLUGIN_DIR . '/languages' );
90
-
91
- // Add all action, filter and shortcode hooks
92
- $this->_add_hooks();
93
- }
94
-
95
- /**
96
- * Add in various hooks
97
- */
98
- private function _add_hooks() {
99
-
100
- // Options page for configuration
101
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
102
-
103
- // Route requests for form processing
104
- add_action( 'admin_init', array( &$this, 'route' ) );
105
-
106
- // Add a settings link next to the "Deactivate" link on the plugin listing page
107
- add_filter( 'plugin_action_links', array( &$this, 'plugin_action_links' ), 10, 2 );
108
-
109
- //Load all the resources
110
- add_action( 'admin_enqueue_scripts', array( &$this, 'load_resources' ) );
111
-
112
- //Load the backup action
113
- add_action('wp_ajax_wp-backitup_backup', array( &$this, 'ajax_queue_backup' ));
114
-
115
- //Load the restore action
116
- add_action('wp_ajax_wp-backitup_restore', array( &$this, 'ajax_queue_restore' ));
117
-
118
- //Load the upload action
119
- add_action('wp_ajax_wp-backitup_plupload_action', array($this,'plupload_action'));
120
-
121
- //Status reader for UI
122
- add_action('wp_ajax_wp-backitup_restore_status_reader', array( &$this,'ajax_get_restore_status'));
123
-
124
- add_action('wp_ajax_wp-backitup_backup_status_reader', array( &$this,'ajax_get_backup_status'));
125
-
126
- add_action('wp_ajax_wp-backitup_backup_response_reader', array( &$this,'ajax_backup_response_reader'));
127
-
128
- //Delete File Action
129
- add_action('wp_ajax_wp-backitup_delete_file', array( &$this,'ajax_delete_backup'));
130
-
131
- //View Log Action
132
- add_action('admin_post_viewlog', array( &$this,'admin_viewlog'));
133
-
134
- //Download Backup
135
- add_action('admin_post_download_backup', array( &$this,'admin_download_backup'));
136
-
137
- //Create Daily backup action
138
- add_action( 'wpbackitup_queue_scheduled_jobs', array( &$this,'wpbackitup_queue_scheduled_jobs'));
139
-
140
- add_action( 'wpbackitup_run_backup_tasks', array( &$this,'wpbackitup_run_backup_tasks'));
141
-
142
- add_action( 'wpbackitup_run_cleanup_tasks', array( &$this,'wpbackitup_run_cleanup_tasks'));
143
-
144
- }
145
-
146
- /**
147
- *
148
- * Define the admin menu options for this plugin
149
- *
150
- */
151
- public function admin_menu() {
152
-
153
- // add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
154
- add_menu_page( $this->friendly_name, $this->friendly_name, 'administrator', $this->namespace, array( &$this, 'admin_backup_page' ), WPBACKITUP__PLUGIN_URL .'/images/icon.png', 77);
155
-
156
- //Add Backup Menu Nav
157
- add_submenu_page( $this->namespace, 'Backup', 'Backup', 'administrator', $this->namespace.'-backup', array( &$this, 'admin_backup_page' ) );
158
-
159
- //Add Restore Menu Nav IF licensed
160
- if ($this->license_type()!=0) {
161
- add_submenu_page( $this->namespace, 'Restore', 'Restore', 'administrator', $this->namespace.'-restore', array( &$this, 'admin_restore_page' ) );
162
- }
163
-
164
- //Add Support Menu Nav
165
- add_submenu_page( $this->namespace, 'Support', 'Support', 'administrator', $this->namespace.'-support', array( &$this, 'admin_support_page' ) );
166
-
167
- //Add Settings Menu Nav
168
- add_submenu_page( $this->namespace, 'Settings', 'Settings', 'administrator', $this->namespace.'-settings', array( &$this, 'admin_settings_page' ) );
169
-
170
-
171
- if (WPBACKITUP__DEBUG===true){
172
- add_submenu_page( $this->namespace, 'Test', 'Test', 'administrator', $this->namespace.'-test', array( &$this, 'admin_test_page' ) );
173
- }
174
- // remove duplicate submenu page. wp limitations //
175
- // http://wordpress.stackexchange.com/questions/16401/remove-duplicate-main-submenu-in-admin
176
- remove_submenu_page($this->namespace,$this->namespace);
177
-
178
- }
179
-
180
- public function load_resources() {
181
-
182
- //Only load the JS and CSS when plugin is active
183
- if( !empty($_REQUEST['page']) && substr($_REQUEST['page'], 0, 11) === 'wp-backitup') {
184
-
185
- // Admin JavaScript
186
- wp_register_script( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "js/wpbackitup_admin.js", array( 'jquery' ), $this->version, true );
187
- wp_enqueue_script( "{$this->namespace}-admin" );
188
-
189
- // Admin Stylesheet
190
- wp_register_style( "{$this->namespace}-admin", WPBACKITUP__PLUGIN_URL . "css/wpbackitup_admin.css", array(), $this->version, 'screen' );
191
- wp_enqueue_style( "{$this->namespace}-admin" );
192
-
193
- //Admin fonts
194
- wp_register_style( 'google-fonts', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
195
- wp_enqueue_style( 'google-fonts' );
196
-
197
- //UPLOADS only
198
- if ($_REQUEST['page']=='wp-backitup-restore') {
199
- wp_enqueue_media();
200
- }
201
- }
202
- }
203
-
204
- /**
205
- * The admin section backup page rendering method
206
- *
207
- */
208
- public function admin_backup_page()
209
- {
210
- if( !current_user_can( 'manage_options' ) ) {
211
- wp_die( 'You do not have sufficient permissions to access this page' );
212
- }
213
-
214
- include WPBACKITUP__PLUGIN_PATH . "/views/backup.php";
215
- }
216
-
217
- /**
218
- * The admin section restore page rendering method
219
- *
220
- */
221
- public function admin_restore_page()
222
- {
223
- if( !current_user_can( 'manage_options' ) ) {
224
- wp_die( 'You do not have sufficient permissions to access this page.' );
225
- }
226
-
227
- include WPBACKITUP__PLUGIN_PATH . "/views/restore.php";
228
- }
229
-
230
- /**
231
- * The admin section settings page rendering method
232
- *
233
- */
234
- public function admin_settings_page()
235
- {
236
-
237
- if( !current_user_can( 'manage_options' ) ) {
238
- wp_die( 'You do not have sufficient permissions to access this page.' );
239
- }
240
-
241
- include WPBACKITUP__PLUGIN_PATH . "/views/settings.php";
242
- }
243
-
244
- /**
245
- * The admin section support page rendering method
246
- *
247
- */
248
- public function admin_support_page()
249
- {
250
- include WPBACKITUP__PLUGIN_PATH . "/views/support.php";
251
- }
252
-
253
- /**
254
- * The admin section backup page rendering method
255
- *
256
- */
257
- public function admin_test_page()
258
- {
259
- if( !current_user_can( 'manage_options' ) ) {
260
- wp_die( 'You do not have sufficient permissions to access this page' );
261
- }
262
-
263
- include WPBACKITUP__PLUGIN_PATH . "/views/test.php";
264
- }
265
-
266
- /**
267
- * Route the user based off of environment conditions
268
- *
269
- * @uses WPBackitup::_admin_options_update()
270
- */
271
- public function route() {
272
- $uri = $_SERVER['REQUEST_URI'];
273
- $protocol = isset( $_SERVER['HTTPS'] ) ? 'https' : 'http';
274
- $hostname = $_SERVER['HTTP_HOST'];
275
- $url = "{$protocol}://{$hostname}{$uri}";
276
- $is_post = (bool) ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == "POST" );
277
-
278
- // Check if a nonce was passed in the request
279
- if( isset( $_REQUEST['_wpnonce'] ) ) {
280
- $nonce = $_REQUEST['_wpnonce'];
281
-
282
- $logger = new WPBackItUp_Logger(false);
283
- //$logger->log('NONCE:' .$nonce);
284
-
285
- // Handle POST requests
286
- if( $is_post ) {
287
-
288
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-options" ) ) {
289
- $logger->log('Update Options Form Post');
290
- $this->_admin_options_update();
291
- }
292
-
293
- if( wp_verify_nonce( $nonce, "{$this->namespace}-register-lite" ) ) {
294
- $logger->log('Register Lite Form Post');
295
- $this->_admin_register_lite();
296
- }
297
-
298
- if( wp_verify_nonce( $nonce, "{$this->namespace}-update-schedule" ) ) {
299
- $logger->log('Update Schedule Form Post');
300
-
301
- $jsonResponse = new stdClass();
302
- if ($this->_admin_save_schedule()){
303
- $jsonResponse->message = 'success';
304
- }else{
305
- $jsonResponse->message = 'error';
306
- }
307
-
308
- exit(json_encode($jsonResponse));
309
-
310
- }
311
-
312
- if( wp_verify_nonce( $nonce, "{$this->namespace}-support-form" ) ) {
313
- $logger->log('Support Form Post');
314
- $this->_admin_send_support_request();
315
- }
316
-
317
- }
318
- // Handle GET requests
319
- else {
320
-
321
- }
322
- }
323
- }
324
-
325
- public function initialize(){
326
- $this->check_license();
327
- }
328
-
329
- public function wpbackitup_queue_scheduled_jobs(){
330
-
331
- // Check permissions
332
- if (! self::is_authorized()) exit('Access denied.');
333
-
334
- //Include Scheduler Class
335
- if( !class_exists( 'WPBackItUp_Scheduler' ) ) {
336
- include_once 'class-scheduler.php';
337
- }
338
-
339
- //Include Job class
340
- if( !class_exists( 'WPBackItUp_Job' ) ) {
341
- include_once 'class-job.php';
342
- }
343
-
344
-
345
- //If any jobs are queued or active then just exit
346
- if (WPBackItUp_Job::is_job_queued('backup') ||
347
- WPBackItUp_Job::is_job_queued('restore') ||
348
- WPBackItUp_Job::is_job_queued('cleanup')) {
349
- exit;
350
- }
351
-
352
-
353
- //Is it time for a backup?
354
- //Check scheduler and queue tasks that need to be run
355
- $scheduler = new WPBackItUp_Scheduler();
356
- if ( $scheduler->isTaskScheduled( 'backup' ) ) {
357
-
358
- $backup_job = WPBackItUp_Job::queue_job( 'backup' );
359
-
360
- //Setup the job run event
361
- wp_schedule_single_event( time(), 'wpbackitup_run_backup_tasks' );
362
-
363
- exit( 0 ); //success - don't schedule anything else
364
- }
365
-
366
- //Is it time for a cleanup
367
- //Check scheduler and queue tasks that need to be run
368
- if ( $scheduler->isTaskScheduled( 'cleanup' ) && !WPBackItUp_Job::is_job_queued('backup') ) {
369
-
370
- $cleanup_job = WPBackItUp_Job::queue_job( 'cleanup' );
371
-
372
- //Setup the job run event
373
- wp_schedule_single_event( time(), 'wpbackitup_run_cleanup_tasks' );
374
-
375
- exit( 0 ); //success - don't schedule anything else
376
- }
377
-
378
-
379
- exit(0); //success nothing to schedule
380
- }
381
-
382
- //Run queue manual backup
383
- public function ajax_queue_backup() {
384
- // Check permissions
385
- if (! self::is_authorized()) exit('Access denied.');
386
-
387
- $logger = new WPBackItUp_Logger(false,null,'debug_events');
388
- $logger->log_info(__METHOD__,'Begin');
389
-
390
- //Include Job class
391
- if( !class_exists( 'WPBackItUp_Job' ) ) {
392
- include_once 'class-job.php';
393
- }
394
-
395
- $rtnData = new stdClass();
396
- //If no backup queued already then queue one
397
- if (!WPBackItUp_Job::is_job_queued('backup')){
398
- if (WPBackItUp_Job::queue_job('backup')){
399
- $rtnData->message = 'Backup Queued';
400
- }else {
401
- $rtnData->message = 'Backup could not be queued';
402
- }
403
- }else{
404
- $rtnData->message = 'Backup already in queue';
405
- }
406
-
407
- $logger->log_info(__METHOD__,$rtnData->message);
408
- $logger->log_info(__METHOD__,'End');
409
- echo json_encode($rtnData);
410
- exit;
411
- }
412
-
413
- //Run queue manual restore
414
- public function ajax_queue_restore() {
415
- $rtnData = new stdClass();
416
-
417
- // Check permissions
418
- if (! self::is_authorized()) exit('Access denied.');
419
-
420
- $logger = new WPBackItUp_Logger(false,null,'debug_events');
421
- $logger->log_info(__METHOD__,'Begin');
422
-
423
- //Include Job class
424
- if( !class_exists( 'WPBackItUp_Job' ) ) {
425
- include_once 'class-job.php';
426
- }
427
-
428
- $validation_error=false;
429
- //Get posted values
430
- $backup_file_name = $_POST['selected_file'];//Get the backup file name
431
- if( empty($backup_file_name)) {
432
- $rtnData->message = 'No backup file selected.';
433
- $validation_error=true;
434
- }
435
-
436
- //Get user ID - GET ThIS FROM POST ID
437
- $user_id = $_POST['user_id'];
438
- if( empty($user_id)) {
439
- $rtnData->message = 'No user id found.';
440
- $validation_error=true;
441
- }
442
-
443
- //If no job queued already then queue one
444
- if (! $validation_error){
445
- if (! WPBackItUp_Job::is_job_queued('restore')){
446
- $job=WPBackItUp_Job::queue_job('restore');
447
- if ($job!== false){
448
- $job->update_job_meta('backup_name',$backup_file_name);
449
- $job->update_job_meta('user_id',$user_id);
450
- $rtnData->message = 'Restore Queued';
451
- }else {
452
- $rtnData->message = 'Restore could not be queued';
453
- }
454
- }else{
455
- $rtnData->message = 'Restore already in queue';
456
- }
457
- }
458
-
459
- $logger->log_info(__METHOD__,$rtnData->message);
460
- $logger->log_info(__METHOD__,'End');
461
- echo json_encode($rtnData);
462
- exit;
463
- }
464
-
465
- //Run scheduled backup tasks
466
- function wpbackitup_run_backup_tasks(){
467
-
468
- // Check permissions
469
- if (! self::is_authorized()) exit('Access denied.');
470
-
471
- $process_id = uniqid();
472
-
473
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
474
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
475
-
476
- //Try Run Next Backup Tasks
477
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run Backup Task');
478
-
479
- $this->backup_type='scheduled';
480
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_backup.php' );
481
-
482
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run Backup Task');
483
-
484
- exit(0);
485
- }
486
-
487
- //Run scheduled backup tasks
488
- function wpbackitup_run_cleanup_tasks(){
489
- // Check permissions
490
- if (! self::is_authorized()) exit('Access denied.');
491
-
492
- $process_id = uniqid();
493
-
494
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
495
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
496
-
497
- //Try Run Next Backup Tasks
498
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run cleanup Task');
499
-
500
- $this->backup_type='scheduled';
501
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_cleanup.php' );
502
-
503
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run cleanup Task');
504
-
505
- exit;
506
- }
507
-
508
-
509
- // public function ajax_get_restore_status() {
510
- // // Check permissions
511
- // if (! self::is_authorized()) exit('Access denied.');
512
- //
513
- // $log = WPBACKITUP__PLUGIN_PATH .'/logs/restore_status.log';
514
- // if(file_exists($log) ) {
515
- // readfile($log);
516
- // }
517
- // exit;
518
- // }
519
-
520
-
521
- /**
522
- * Return the backup status and try run tasks
523
- */
524
- public function ajax_get_backup_status() {
525
- // Check permissions
526
- if (! self::is_authorized()) exit('Access denied.');
527
-
528
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
529
-
530
- $event_logger->log_info(__METHOD__ ,'User Permissions: ' .current_user_can( 'manage_options' ));
531
-
532
- //Check permissions
533
- if ( current_user_can( 'manage_options' ) ) {
534
- //echo('RUNNING BACKUP');
535
-
536
- $process_id = uniqid();
537
-
538
-
539
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
540
-
541
- //Try Run Next Backup Tasks
542
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run Backup Task');
543
-
544
- $this->backup_type='manual';
545
- include_once( WPBACKITUP__PLUGIN_PATH.'/lib/includes/job_backup.php' );
546
-
547
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','End Try Run Backup Task');
548
-
549
- //return status
550
- $log = WPBACKITUP__PLUGIN_PATH .'/logs/backup_status.log';
551
- if(file_exists($log) ) {
552
- //Probably should use the database instead now.
553
- readfile($log);
554
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Status sent to browser.');
555
- }
556
- }
557
-
558
- exit;
559
- }
560
-
561
- /**
562
- * Return the restore status and try run tasks
563
- */
564
- public function ajax_get_restore_status() {
565
- // Check permissions
566
- if (! self::is_authorized()) exit('Access denied.');
567
-
568
- $event_logger = new WPBackItUp_Logger(false,null,'debug_events');
569
-
570
- $event_logger->log_info(__METHOD__ ,'User Permissions: ' .current_user_can( 'manage_options' ));
571
-
572
- //Check permissions
573
- if ( current_user_can( 'manage_options' ) ) {
574
- //echo('RUNNING BACKUP');
575
-
576
- $process_id = uniqid();
577
-
578
- $event_logger->log_info(__METHOD__ .'(' .$process_id .')', 'Begin');
579
-
580
- //Try Run Next Backup Tasks
581
- $event_logger->log_info(__METHOD__.'(' .$process_id .')','Try Run restore task');