Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid - Version 1.6.1

Version Description

Release Date: May 24th, 2018

  • Update: Ran PHPCBF to beautify PHP code.
  • Update: $_POST sanitization
  • Update: Cron system updated to avoid calling core files directly
Download this release

Release Info

Developer boldgrid
Plugin Icon 128x128 Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid
Version 1.6.1
Comparing to
See all releases

Version 1.6.1

Files changed (195) hide show
  1. LICENSE.txt +339 -0
  2. admin/class-boldgrid-backup-admin-archive-actions.php +189 -0
  3. admin/class-boldgrid-backup-admin-archive-browser.php +285 -0
  4. admin/class-boldgrid-backup-admin-archive-details.php +176 -0
  5. admin/class-boldgrid-backup-admin-archive-fail.php +178 -0
  6. admin/class-boldgrid-backup-admin-archive-log.php +199 -0
  7. admin/class-boldgrid-backup-admin-archive.php +359 -0
  8. admin/class-boldgrid-backup-admin-archives-all.php +217 -0
  9. admin/class-boldgrid-backup-admin-archives.php +239 -0
  10. admin/class-boldgrid-backup-admin-auto-rollback.php +1033 -0
  11. admin/class-boldgrid-backup-admin-backup-dir.php +391 -0
  12. admin/class-boldgrid-backup-admin-compressor.php +76 -0
  13. admin/class-boldgrid-backup-admin-compressors.php +133 -0
  14. admin/class-boldgrid-backup-admin-config.php +466 -0
  15. admin/class-boldgrid-backup-admin-core-files.php +98 -0
  16. admin/class-boldgrid-backup-admin-core.php +2722 -0
  17. admin/class-boldgrid-backup-admin-cron.php +994 -0
  18. admin/class-boldgrid-backup-admin-crypt.php +98 -0
  19. admin/class-boldgrid-backup-admin-db-dump.php +199 -0
  20. admin/class-boldgrid-backup-admin-db-get.php +89 -0
  21. admin/class-boldgrid-backup-admin-db-import.php +167 -0
  22. admin/class-boldgrid-backup-admin-db-omit.php +312 -0
  23. admin/class-boldgrid-backup-admin-email.php +191 -0
  24. admin/class-boldgrid-backup-admin-filelist.php +138 -0
  25. admin/class-boldgrid-backup-admin-folder-exclusion.php +492 -0
  26. admin/class-boldgrid-backup-admin-go-pro.php +128 -0
  27. admin/class-boldgrid-backup-admin-home-dir.php +67 -0
  28. admin/class-boldgrid-backup-admin-in-progress.php +274 -0
  29. admin/class-boldgrid-backup-admin-jobs.php +295 -0
  30. admin/class-boldgrid-backup-admin-notice.php +230 -0
  31. admin/class-boldgrid-backup-admin-remote.php +100 -0
  32. admin/class-boldgrid-backup-admin-restore-git.php +45 -0
  33. admin/class-boldgrid-backup-admin-restore-helper.php +296 -0
  34. admin/class-boldgrid-backup-admin-scheduler.php +139 -0
  35. admin/class-boldgrid-backup-admin-settings.php +806 -0
  36. admin/class-boldgrid-backup-admin-test.php +729 -0
  37. admin/class-boldgrid-backup-admin-time.php +412 -0
  38. admin/class-boldgrid-backup-admin-tools.php +54 -0
  39. admin/class-boldgrid-backup-admin-upload.php +366 -0
  40. admin/class-boldgrid-backup-admin-utility.php +866 -0
  41. admin/class-boldgrid-backup-admin-wp-cron.php +360 -0
  42. admin/class-boldgrid-backup-admin-xhprof.php +130 -0
  43. admin/class-boldgrid-backup-admin.php +199 -0
  44. admin/compressor/pcl_zip.php +546 -0
  45. admin/compressor/php_zip.php +212 -0
  46. admin/css/boldgrid-backup-admin-customizer.css +6 -0
  47. admin/css/boldgrid-backup-admin-folder-exclude.css +105 -0
  48. admin/css/boldgrid-backup-admin-ftp-settings.css +8 -0
  49. admin/css/boldgrid-backup-admin-hide-all.css +24 -0
  50. admin/css/boldgrid-backup-admin-home.css +16 -0
  51. admin/css/boldgrid-backup-admin-new-thickbox-style.css +26 -0
  52. admin/css/boldgrid-backup-admin-settings.css +9 -0
  53. admin/css/boldgrid-backup-admin-test.css +46 -0
  54. admin/css/boldgrid-backup-admin-zip-browser.css +32 -0
  55. admin/css/boldgrid-backup-admin.css +129 -0
  56. admin/index.php +2 -0
  57. admin/js/boldgrid-backup-admin-archive-actions.js +164 -0
  58. admin/js/boldgrid-backup-admin-archive-details.js +163 -0
  59. admin/js/boldgrid-backup-admin-backup-now.js +236 -0
  60. admin/js/boldgrid-backup-admin-customizer.js +125 -0
  61. admin/js/boldgrid-backup-admin-folder-exclude.js +413 -0
  62. admin/js/boldgrid-backup-admin-ftp-settings.js +69 -0
  63. admin/js/boldgrid-backup-admin-home.js +196 -0
  64. admin/js/boldgrid-backup-admin-rollback.js +440 -0
  65. admin/js/boldgrid-backup-admin-settings.js +311 -0
  66. admin/js/boldgrid-backup-admin-table-include.js +112 -0
  67. admin/js/boldgrid-backup-admin-update-selectors.js +148 -0
  68. admin/js/boldgrid-backup-admin-zip-browser.js +285 -0
  69. admin/js/boldgrid-backup-admin.js +269 -0
  70. admin/partials/archive-details/browser-entry.php +49 -0
  71. admin/partials/archive-details/browser.php +31 -0
  72. admin/partials/archive-details/db.php +50 -0
  73. admin/partials/archive-details/details.php +95 -0
  74. admin/partials/archive-details/not-found.php +16 -0
  75. admin/partials/archive-details/only-remote.php +32 -0
  76. admin/partials/archive-details/remote-storage.php +80 -0
  77. admin/partials/archives/add-new.php +91 -0
  78. admin/partials/archives/note-pre-backup.php +55 -0
  79. admin/partials/boldgrid-backup-admin-archive-details.php +240 -0
  80. admin/partials/boldgrid-backup-admin-backup-button.php +40 -0
  81. admin/partials/boldgrid-backup-admin-backup-modal.php +36 -0
  82. admin/partials/boldgrid-backup-admin-backup.php +161 -0
  83. admin/partials/boldgrid-backup-admin-home.php +74 -0
  84. admin/partials/boldgrid-backup-admin-mail-restore.php +78 -0
  85. admin/partials/boldgrid-backup-admin-nav.php +60 -0
  86. admin/partials/boldgrid-backup-admin-settings.php +146 -0
  87. admin/partials/boldgrid-backup-admin-test.php +377 -0
  88. admin/partials/boldgrid-backup-admin-tools.php +53 -0
  89. admin/partials/remote/ftp.php +88 -0
  90. admin/partials/settings/auto-updates.php +155 -0
  91. admin/partials/settings/backup-directory.php +57 -0
  92. admin/partials/settings/compressor.php +72 -0
  93. admin/partials/settings/connect-key.php +68 -0
  94. admin/partials/settings/days-of-week.php +52 -0
  95. admin/partials/settings/db.php +83 -0
  96. admin/partials/settings/folders.php +262 -0
  97. admin/partials/settings/notifications.php +56 -0
  98. admin/partials/settings/premium-message.php +57 -0
  99. admin/partials/settings/retention.php +58 -0
  100. admin/partials/settings/scheduler.php +53 -0
  101. admin/partials/settings/storage-location.php +59 -0
  102. admin/partials/settings/storage.php +89 -0
  103. admin/partials/settings/time-of-day.php +79 -0
  104. admin/partials/tools/local-remote.php +130 -0
  105. admin/remote/ftp-hooks.php +287 -0
  106. admin/remote/ftp-page.php +190 -0
  107. admin/remote/ftp.php +858 -0
  108. admin/remote/sftp.php +553 -0
  109. admin/storage/local.php +100 -0
  110. boldgrid-backup-cron.php +72 -0
  111. boldgrid-backup.php +146 -0
  112. cron/run_jobs.php +61 -0
  113. includes/class-boldgrid-backup-activator.php +46 -0
  114. includes/class-boldgrid-backup-deactivator.php +35 -0
  115. includes/class-boldgrid-backup-i18n.php +37 -0
  116. includes/class-boldgrid-backup-loader.php +132 -0
  117. includes/class-boldgrid-backup.php +430 -0
  118. includes/config/.gitignore +1 -0
  119. includes/config/config.plugin.php +43 -0
  120. includes/config/config.sample.php +24 -0
  121. includes/config/index.php +2 -0
  122. includes/index.php +2 -0
  123. index.php +2 -0
  124. languages/boldgrid-backup.pot +0 -0
  125. readme.txt +276 -0
  126. uninstall.php +25 -0
  127. vendor/autoload.php +7 -0
  128. vendor/boldgrid/library/.eslintrc.js +22 -0
  129. vendor/boldgrid/library/.gitignore +7 -0
  130. vendor/boldgrid/library/.prettierrc +6 -0
  131. vendor/boldgrid/library/.travis.yml +54 -0
  132. vendor/boldgrid/library/LICENSE +339 -0
  133. vendor/boldgrid/library/README.md +73 -0
  134. vendor/boldgrid/library/bin/install-wp-tests.sh +78 -0
  135. vendor/boldgrid/library/composer.json +33 -0
  136. vendor/boldgrid/library/package-lock.json +1907 -0
  137. vendor/boldgrid/library/package.json +13 -0
  138. vendor/boldgrid/library/phpunit.xml +19 -0
  139. vendor/boldgrid/library/src/Library/Api/Availability.php +118 -0
  140. vendor/boldgrid/library/src/Library/Api/Call.php +270 -0
  141. vendor/boldgrid/library/src/Library/Configs.php +95 -0
  142. vendor/boldgrid/library/src/Library/Filter.php +186 -0
  143. vendor/boldgrid/library/src/Library/Key.php +303 -0
  144. vendor/boldgrid/library/src/Library/Key/Validate.php +169 -0
  145. vendor/boldgrid/library/src/Library/License.php +373 -0
  146. vendor/boldgrid/library/src/Library/Notice.php +235 -0
  147. vendor/boldgrid/library/src/Library/Notice/ClaimPremiumKey.php +190 -0
  148. vendor/boldgrid/library/src/Library/Notice/KeyPrompt.php +244 -0
  149. vendor/boldgrid/library/src/Library/Plugin/Checker.php +141 -0
  150. vendor/boldgrid/library/src/Library/Registration.php +74 -0
  151. vendor/boldgrid/library/src/Library/ReleaseChannel.php +141 -0
  152. vendor/boldgrid/library/src/Library/Reseller.php +63 -0
  153. vendor/boldgrid/library/src/Library/Start.php +128 -0
  154. vendor/boldgrid/library/src/Library/Ui.php +183 -0
  155. vendor/boldgrid/library/src/Library/Update.php +62 -0
  156. vendor/boldgrid/library/src/Library/Util/Plugin.php +71 -0
  157. vendor/boldgrid/library/src/Library/Views/ClaimPremiumKey.php +19 -0
  158. vendor/boldgrid/library/src/Library/Views/ConnectionIssue.php +15 -0
  159. vendor/boldgrid/library/src/Library/Views/InvalidLicense.php +5 -0
  160. vendor/boldgrid/library/src/Library/Views/KeyPrompt.php +103 -0
  161. vendor/boldgrid/library/src/Util/Load.php +212 -0
  162. vendor/boldgrid/library/src/Util/Option.php +124 -0
  163. vendor/boldgrid/library/src/Util/Plugin.php +52 -0
  164. vendor/boldgrid/library/src/Util/Registration.php +114 -0
  165. vendor/boldgrid/library/src/Util/Registration/Plugin.php +38 -0
  166. vendor/boldgrid/library/src/Util/Registration/RegistrationInterface.php +57 -0
  167. vendor/boldgrid/library/src/Util/Registration/Theme.php +38 -0
  168. vendor/boldgrid/library/src/Util/Version.php +107 -0
  169. vendor/boldgrid/library/src/assets/css/api-notice.css +98 -0
  170. vendor/boldgrid/library/src/assets/css/ui.css +133 -0
  171. vendor/boldgrid/library/src/assets/js/api-notice.js +231 -0
  172. vendor/boldgrid/library/src/assets/js/license.js +35 -0
  173. vendor/boldgrid/library/src/assets/js/notice.js +33 -0
  174. vendor/boldgrid/library/src/assets/js/sticky.js +288 -0
  175. vendor/boldgrid/library/src/assets/js/ui.js +68 -0
  176. vendor/boldgrid/library/src/library.global.php +82 -0
  177. vendor/boldgrid/library/tests/Library/Util/test-plugin.php +42 -0
  178. vendor/boldgrid/library/tests/Util/test-option.php +38 -0
  179. vendor/boldgrid/library/tests/bootstrap.php +19 -0
  180. vendor/boldgrid/library/tests/test-reseller.php +45 -0
  181. vendor/boldgrid/library/yarn.lock +1260 -0
  182. vendor/cbschuld/browser.php +1 -0
  183. vendor/composer/ClassLoader.php +445 -0
  184. vendor/composer/LICENSE +21 -0
  185. vendor/composer/autoload_classmap.php +9 -0
  186. vendor/composer/autoload_files.php +11 -0
  187. vendor/composer/autoload_namespaces.php +9 -0
  188. vendor/composer/autoload_psr4.php +12 -0
  189. vendor/composer/autoload_real.php +70 -0
  190. vendor/composer/autoload_static.php +52 -0
  191. vendor/composer/installed.json +248 -0
  192. vendor/ifsnop/mysqldump-php/.gitignore +9 -0
  193. vendor/ifsnop/mysqldump-php/.scrutinizer.yml +43 -0
  194. vendor/ifsnop/mysqldump-php/.travis.yml +49 -0
  195. vendor/ifsnop/mysqldump-php/LICENSE +253 -0
LICENSE.txt ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
admin/class-boldgrid-backup-admin-archive-actions.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Archive Actions class.
4
+ *
5
+ * @link http://www.boldgrid.com
6
+ * @since 1.5.4
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid.com
11
+ * @version $Id$
12
+ * @author BoldGrid.com <wpb@boldgrid.com>
13
+ */
14
+
15
+ /**
16
+ * BoldGrid Backup Admin Archive Actions Class.
17
+ *
18
+ * @since 1.5.4
19
+ */
20
+ class Boldgrid_Backup_Admin_Archive_Actions {
21
+
22
+ /**
23
+ * The core class object.
24
+ *
25
+ * @since 1.5.4
26
+ * @access private
27
+ * @var Boldgrid_Backup_Admin_Core
28
+ */
29
+ private $core;
30
+
31
+ /**
32
+ * Constructor.
33
+ *
34
+ * @since 1.5.4
35
+ *
36
+ * @param Boldgrid_Backup_Admin_Core $core Core class object.
37
+ */
38
+ public function __construct( $core ) {
39
+ $this->core = $core;
40
+ }
41
+
42
+ /**
43
+ * Enqueue scripts.
44
+ *
45
+ * @since 1.5.4
46
+ */
47
+ public function enqueue_scripts() {
48
+ $access_type = get_filesystem_method();
49
+ $archive_nonce = wp_create_nonce( 'archive_auth' );
50
+ $delete_confirm_text = esc_html__(
51
+ 'Please confirm the deletion of the archive file:' . PHP_EOL,
52
+ 'boldgrid-backup'
53
+ );
54
+ $restore_confirm_text = esc_html__(
55
+ 'Please confirm the restoration of this WordPress installation from the archive file:' .
56
+ PHP_EOL . '"%s"' . PHP_EOL . PHP_EOL .
57
+ 'Please be aware that you may get logged-out if your session token does not exist in the database restored.',
58
+ 'boldgrid-backup'
59
+ );
60
+
61
+ $handle = 'boldgrid-backup-admin-archive-actions';
62
+ wp_register_script( $handle,
63
+ plugin_dir_url( __FILE__ ) . 'js/' . $handle . '.js',
64
+ array( 'jquery' ),
65
+ BOLDGRID_BACKUP_VERSION,
66
+ false
67
+ );
68
+ $translation = array(
69
+ 'accessType' => $access_type,
70
+ 'archiveNonce' => $archive_nonce,
71
+ 'deleteConfirmText' => $delete_confirm_text,
72
+ 'restoreConfirmText' => $restore_confirm_text,
73
+ );
74
+ wp_localize_script( $handle, 'BoldGridBackupAdminArchiveActions', $translation );
75
+ wp_enqueue_script( $handle );
76
+ }
77
+
78
+ /**
79
+ * Return a link to delete an archive.
80
+ *
81
+ * @since 1.5.4
82
+ *
83
+ * @param string $filename
84
+ * @return string
85
+ */
86
+ public function get_delete_link( $filename ) {
87
+ $archive = $this->core->archive->get_by_name( $filename );
88
+
89
+ if ( empty( $archive ) ) {
90
+ $link = '';
91
+ } else {
92
+ $link = sprintf( '
93
+ <form method="post" id="delete-action" >
94
+ <input type="hidden" name="delete_now" value="1" />
95
+ <input type="hidden" name="archive_key" value="%2$s" />
96
+ <input type="hidden" name="archive_filename" value="%3$s" />
97
+ %4$s
98
+ <a href="" class="submitdelete" data-key="%2$s" data-filename="%3$s">%5$s</a>
99
+ <span class="spinner"></span>
100
+ </form>',
101
+ /* 1 */ get_admin_url( null, 'admin.php?page=boldgrid-backup-archive-details' ),
102
+ /* 2 */ $archive['key'],
103
+ /* 3 */ $archive['filename'],
104
+ /* 4 */ wp_nonce_field( 'archive_auth', 'archive_auth', true, false ),
105
+ /* 5 */ __( 'Delete backup', 'boldgrid-backup' )
106
+ );
107
+ }
108
+
109
+ return $link;
110
+ }
111
+
112
+ /**
113
+ * Return a link to download an archive.
114
+ *
115
+ * @since 1.5.4
116
+ *
117
+ * @param string $filename
118
+ * @return string
119
+ */
120
+ public function get_download_button( $filename ) {
121
+ $archive = $this->core->archive->get_by_name( $filename );
122
+
123
+ if ( empty( $archive ) ) {
124
+ $button = '';
125
+ } else {
126
+ $button = sprintf( '
127
+ <a
128
+ id="backup-archive-download-%1$s"
129
+ class="button button-primary action-download"
130
+ href="#"
131
+ data-key="%1$s"
132
+ data-filepath="%2$s"
133
+ data-filename="%3$s">
134
+ %4$s
135
+ </a>',
136
+ /* 1 */ $archive['key'],
137
+ /* 2 */ $archive['filepath'],
138
+ /* 3 */ $archive['filename'],
139
+ /* 4 */ __( 'Download to Local Machine', 'boldgrid-backup' )
140
+ );
141
+ }
142
+
143
+ return $button;
144
+ }
145
+
146
+ /**
147
+ * Return a link to restore an archive.
148
+ *
149
+ * @since 1.5.4
150
+ *
151
+ * @param string $filename
152
+ * @param array $args
153
+ * @return string
154
+ */
155
+ public function get_restore_button( $filename, $args = array() ) {
156
+ $defaults = array(
157
+ 'button_text' => __( 'Restore' ),
158
+ );
159
+
160
+ $args = wp_parse_args( $args, $defaults );
161
+
162
+ $archive = $this->core->archive->get_by_name( $filename );
163
+
164
+ if ( empty( $archive ) ) {
165
+ $button = '';
166
+ } else {
167
+ $button = sprintf('
168
+ <a
169
+ data-restore-now="1"
170
+ data-archive-key="%2$s"
171
+ data-archive-filename="%3$s"
172
+ data-nonce="%4$s"
173
+ class="button restore-now"
174
+ href="">
175
+ %5$s
176
+ </a>
177
+ %6$s',
178
+ /* 1 */ get_admin_url( null, 'admin.php?page=boldgrid-backup' ),
179
+ /* 2 */ $archive['key'],
180
+ /* 3 */ $filename,
181
+ /* 4 */ wp_create_nonce( 'boldgrid_backup_restore_archive' ),
182
+ /* 5 */ $args['button_text'],
183
+ /* 6 */ $this->core->lang['spinner']
184
+ );
185
+ }
186
+
187
+ return $button;
188
+ }
189
+ }
admin/class-boldgrid-backup-admin-archive-browser.php ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Archive Browser class.
4
+ *
5
+ * @link http://www.boldgrid.com
6
+ * @since 1.5.2
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid.com
11
+ * @version $Id$
12
+ * @author BoldGrid.com <wpb@boldgrid.com>
13
+ */
14
+
15
+ /**
16
+ * BoldGrid Backup Admin Archive Browser Class.
17
+ *
18
+ * @since 1.5.2
19
+ */
20
+ class Boldgrid_Backup_Admin_Archive_Browser {
21
+
22
+ /**
23
+ * The core class object.
24
+ *
25
+ * @since 1.5.2
26
+ * @access private
27
+ * @var Boldgrid_Backup_Admin_Core
28
+ */
29
+ private $core;
30
+
31
+ /**
32
+ * Constructor.
33
+ *
34
+ * @since 1.5.2
35
+ *
36
+ * @param Boldgrid_Backup_Admin_Core $core Core class object.
37
+ */
38
+ public function __construct( $core ) {
39
+ $this->core = $core;
40
+ }
41
+
42
+ /**
43
+ * Authorize an ajax request.
44
+ *
45
+ * Many of the ajax handlers in this method require the same
46
+ * current_user_can() and check_ajax_referer() checks.
47
+ *
48
+ * @since 1.5.4
49
+ */
50
+ public function authorize() {
51
+ if ( ! current_user_can( 'update_plugins' ) ) {
52
+ wp_send_json_error( __( 'Permission denied.', 'boldgrid-backup' ) );
53
+ }
54
+
55
+ if ( ! check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false ) ) {
56
+ wp_send_json_error( __( 'Invalid nonce.', 'boldgrid-backup' ) );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Render and return html markup for a .sql file.
62
+ *
63
+ * When a user clicks to "View details" of a database dump, this
64
+ * method will create a table showing all the tables in that backup.
65
+ *
66
+ * @since 1.5.4
67
+ *
68
+ * @param string $filepath Zip file.
69
+ * @param string $file Sql file name.
70
+ * @return string
71
+ */
72
+ public function get_sql_details( $filepath, $file ) {
73
+ $tables_with_records = $this->core->db_dump->get_insert_count( $filepath, $file );
74
+ $prefixed_tables = $this->core->db_get->prefixed_count();
75
+
76
+ $in_backup = __( '# Records in this backup', 'boldgrid-backup' );
77
+ $in_current = __( '# Records in current database', 'boldgrid-backup' );
78
+
79
+ $return = sprintf( '
80
+ <table class="wp-list-table fixed striped widefat">
81
+ <thead>
82
+ <tr>
83
+ <th>Table</th>
84
+ <th>%1$s</th>
85
+ <th class="bulk-action-notice">
86
+ %2$s
87
+ <span class="toggle-indicator"></span>
88
+ </th>
89
+ </tr>
90
+ </thead>
91
+ <tbody>',
92
+ /* 1 */ $in_backup,
93
+ /* 2 */ $in_current
94
+ );
95
+
96
+ foreach ( $prefixed_tables as $table => $record_count ) {
97
+ $return .= sprintf(
98
+ '<tr>
99
+ <td>%1$s</td>
100
+ <td>%2$s</td>
101
+ <td>%3$s</td>
102
+ </tr>',
103
+ esc_html( $table ),
104
+ isset( $tables_with_records[ $table ] ) ? $tables_with_records[ $table ] : '0',
105
+ esc_html( $record_count )
106
+ );
107
+ }
108
+
109
+ $return .= '</tbody></table>';
110
+
111
+ return $return;
112
+ }
113
+
114
+ /**
115
+ * Allow the user to browse an archive file.
116
+ *
117
+ * Returns a formatted table to the browser.
118
+ *
119
+ * @since 1.5.3
120
+ */
121
+ public function wp_ajax_browse_archive() {
122
+ $error = __( 'Unable to get contents of archive file:', 'boldgrid-backup' );
123
+
124
+ $this->authorize();
125
+
126
+ $filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
127
+ $filepath = $this->core->backup_dir->get_path_to( $filename );
128
+ if ( empty( $filename ) || ! $this->core->wp_filesystem->exists( $filepath ) ) {
129
+ wp_send_json_error( $error . ' ' . __( 'Invalid archive filename.', 'boldgrid-backup' ) );
130
+ }
131
+
132
+ $this->core->archive->init( $filepath );
133
+
134
+ $dump_file = $this->core->get_dump_file( $filepath );
135
+
136
+ // An array of files not to show in the archive browser.
137
+ $no_show = array(
138
+ /*
139
+ * If this is our database dump file, skip over it. We have another
140
+ * section of the archive details page that will help with restoring
141
+ * a dump file.
142
+ */
143
+ basename( $dump_file ),
144
+ basename( $this->core->archive->log_filepath ),
145
+ );
146
+
147
+ $dir = ! empty( $_POST['dir'] ) ? trim( strip_tags( $_POST['dir'] ) ) : null;
148
+
149
+ $zip = new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this->core );
150
+
151
+ $contents = $zip->browse( $filepath, $dir );
152
+
153
+ $tr = '';
154
+ $empty_directory = '<tr><td colspan="3">' . __( 'Empty directory', 'boldgrid-backup' ) . '</td></tr>';
155
+
156
+ $table = sprintf(
157
+ '<table class="wp-list-table fixed striped remote-storage widefat">
158
+ <thead>
159
+ <tr>
160
+ <th>%1$s</th>
161
+ <th>%2$s</th>
162
+ <th class="bulk-action-notice">
163
+ %3$s
164
+ <span class="toggle-indicator"></span>
165
+ </th>
166
+ </tr>
167
+ </thead>
168
+ <tbody>
169
+ ',
170
+ __( 'Name', 'boldgrid-backup' ),
171
+ __( 'Size', 'boldgrid-backup' ),
172
+ __( 'Last Modified', 'boldgrid-backup' )
173
+ );
174
+
175
+ foreach ( $contents as $file ) {
176
+ if ( in_array( basename( $file['filename'] ), $no_show, true ) ) {
177
+ continue;
178
+ }
179
+
180
+ $tr .= include BOLDGRID_BACKUP_PATH . '/admin/partials/archive-details/browser-entry.php';
181
+ }
182
+
183
+ $table .= empty( $tr ) ? $empty_directory : $tr;
184
+
185
+ $table .= '</tbody></table>';
186
+
187
+ wp_send_json_success( $table );
188
+ }
189
+
190
+ /**
191
+ * Show available actions for a single file.
192
+ *
193
+ * When the user clicks on a single file in a backup archive, show them
194
+ * what options they have available.
195
+ *
196
+ * @since 1.5.3
197
+ */
198
+ public function wp_ajax_file_actions() {
199
+ $this->authorize();
200
+
201
+ $filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
202
+ $filepath = $this->core->backup_dir->get_path_to( $filename );
203
+ $file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
204
+ if ( empty( $filepath ) || empty( $file ) ) {
205
+ wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
206
+ }
207
+
208
+ // Here's the default message.
209
+ $upgrade_message = __( 'With BoldGrid Backup Premium, you can view and restore files from here.', 'boldgrid-backup' );
210
+
211
+ /**
212
+ * Allow other plugins to add functionality.
213
+ *
214
+ * @since 1.5.3
215
+ *
216
+ * @param string $upgrade_message
217
+ * @param string $file Example: wp-admin/import.php
218
+ */
219
+ $upgrade_message = apply_filters( 'boldgrid_backup_file_actions', $upgrade_message, $file );
220
+
221
+ wp_send_json_success( $upgrade_message );
222
+ }
223
+
224
+ /**
225
+ * Restore a database dump.
226
+ *
227
+ * This handles an ajax call for restoring a dump from the archive details
228
+ * page.
229
+ *
230
+ * @since 1.5.4
231
+ */
232
+ public function wp_ajax_restore_db() {
233
+ $this->authorize();
234
+
235
+ $filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
236
+ $filepath = $this->core->backup_dir->get_path_to( $filename );
237
+ $file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
238
+ if ( empty( $filepath ) || empty( $file ) ) {
239
+ wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
240
+ }
241
+
242
+ $importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
243
+ $success = $importer->import_from_archive( $filepath, $file );
244
+
245
+ if ( ! $success ) {
246
+ $this->core->notice->add_user_notice(
247
+ sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
248
+ $this->core->notice->lang['dis_error']
249
+ );
250
+ } else {
251
+ $this->core->notice->add_user_notice(
252
+ sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
253
+ $this->core->notice->lang['dis_success']
254
+ );
255
+ }
256
+ }
257
+
258
+ /**
259
+ * View the details of a database.
260
+ *
261
+ * This method handles the ajax call of "View details" for a database on the
262
+ * archive details page.
263
+ *
264
+ * @since 1.5.4
265
+ */
266
+ public function wp_ajax_view_db() {
267
+ $this->authorize();
268
+
269
+ $filename = ! empty( $_POST['filename'] ) ? sanitize_file_name( $_POST['filename'] ) : false;
270
+ $filepath = $this->core->backup_dir->get_path_to( $filename );
271
+ $file = ! empty( $_POST['file'] ) ? trim( strip_tags( $_POST['file'] ) ) : false;
272
+ if ( empty( $filename ) || empty( $filepath ) || empty( $file ) ) {
273
+ wp_send_json_error( __( 'Invalid file / filepath.', 'boldgrid-backup' ) );
274
+ }
275
+
276
+ $table = $this->get_sql_details( $filepath, $file );
277
+
278
+ if ( empty( $table ) ) {
279
+ $error = $this->core->notice->get_notice_markup( 'notice notice-error is-dismissible', __( 'Error, unable to get details from this database backup.', 'boldgrid-backup' ) );
280
+ wp_send_json_error( $error );
281
+ } else {
282
+ wp_send_json_success( $table );
283
+ }
284
+ }
285
+ }
admin/class-boldgrid-backup-admin-archive-details.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Archive Details class.
4
+ *
5
+ * @link http://www.boldgrid.com
6
+ * @since 1.5.1
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid.com
11
+ * @version $Id$
12
+ * @author BoldGrid.com <wpb@boldgrid.com>
13
+ */
14
+
15
+ /**
16
+ * BoldGrid Backup Admin Archive Details Class.
17
+ *
18
+ * @since 1.5.1
19
+ */
20
+ class Boldgrid_Backup_Admin_Archive_Details {
21
+
22
+ /**
23
+ * The core class object.
24
+ *
25
+ * @since 1.5.1
26
+ * @access private
27
+ * @var Boldgrid_Backup_Admin_Core
28
+ */
29
+ private $core;
30
+
31
+ /**
32
+ * An array of remote storage locations.
33
+ *
34
+ * @since 1.5.4
35
+ * @access public
36
+ * @var array
37
+ */
38
+ public $remote_storage_li = array();
39
+
40
+ /**
41
+ * Constructor.
42
+ *
43
+ * @since 1.5.1
44
+ *
45
+ * @param Boldgrid_Backup_Admin_Core $core Core class object.
46
+ */
47
+ public function __construct( $core ) {
48
+ $this->core = $core;
49
+ }
50
+
51
+ /**
52
+ * Get a link for an archive's details page.
53
+ *
54
+ * @since 1.6.0
55
+ *
56
+ * @param string $filename
57
+ * @return string
58
+ */
59
+ public function get_url( $filename ) {
60
+ return get_admin_url( null, 'admin.php?page=boldgrid-backup-archive-details&filename=' . $filename );
61
+ }
62
+
63
+ /**
64
+ * Enqueue scripts.
65
+ *
66
+ * @since 1.5.4
67
+ */
68
+ public function enqueue_scripts() {
69
+ wp_enqueue_style(
70
+ 'boldgrid-backup-admin-zip-browser',
71
+ plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-zip-browser.css',
72
+ array(),
73
+ BOLDGRID_BACKUP_VERSION,
74
+ 'all'
75
+ );
76
+
77
+ wp_register_script(
78
+ 'boldgrid-backup-admin-archive-details',
79
+ plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-archive-details.js',
80
+ array( 'jquery' ),
81
+ BOLDGRID_BACKUP_VERSION
82
+ );
83
+ $translations = array(
84
+ 'uploading' => __( 'Uploading', 'boldgrid-backup' ),
85
+ 'uploaded' => __( 'Uploaded', 'boldgrid-backup' ),
86
+ 'failUpload' => __( 'Unable to upload backup file.', 'boldgrid-backup' ),
87
+ );
88
+ wp_localize_script( 'boldgrid-backup-admin-archive-details', 'boldgrid_backup_archive_details', $translations );
89
+ wp_enqueue_script( 'boldgrid-backup-admin-archive-details' );
90
+
91
+ wp_register_script(
92
+ 'boldgrid-backup-admin-zip-browser',
93
+ plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-zip-browser.js',
94
+ array( 'jquery' ),
95
+ BOLDGRID_BACKUP_VERSION
96
+ );
97
+ $unknown_error = __( 'An unknown error has occurred.', 'boldgrid-backup' );
98
+ $translations = array(
99
+ 'loading' => __( 'Loading', 'boldgrid-backup' ),
100
+ 'home' => __( 'Home', 'boldgrid-backup' ),
101
+ 'restoring' => __( 'Restoring', 'boldgrid-backup' ),
102
+ 'confirmDbRestore' => __( 'Are you sure you want to restore this database backup?', 'boldgrid-backup' ),
103
+ 'unknownBrowseError' => __( 'An unknown error has occurred when trying to get a listing of the files in this archive.', 'boldgrid-backup' ),
104
+ 'unknownError' => $unknown_error,
105
+ 'unknownErrorNotice' => sprintf( '<div class="%1$s"><p>%2$s</p></div>', $this->core->notice->lang['dis_error'], $unknown_error ),
106
+ );
107
+ wp_localize_script( 'boldgrid-backup-admin-zip-browser', 'boldgrid_backup_zip_browser', $translations );
108
+ wp_enqueue_script( 'boldgrid-backup-admin-zip-browser' );
109
+
110
+ wp_enqueue_style( 'bglib-ui-css' );
111
+
112
+ /**
113
+ * Allow other plugins to enqueue scripts on this page.
114
+ *
115
+ * @since 1.5.3
116
+ */
117
+ do_action( 'boldgrid_backup_enqueue_archive_details' );
118
+ }
119
+
120
+ /**
121
+ * Render the details page of an archive.
122
+ *
123
+ * @since 1.5.1
124
+ */
125
+ public function render_archive() {
126
+ if ( ! empty( $_POST['delete_now'] ) ) {
127
+ $this->core->delete_archive_file();
128
+ }
129
+
130
+ $this->enqueue_scripts();
131
+ $this->core->archive_actions->enqueue_scripts();
132
+
133
+ $archive_found = false;
134
+
135
+ $filename = ! empty( $_GET['filename'] ) ? sanitize_file_name( $_GET['filename'] ) : false;
136
+ if ( ! $filename ) {
137
+ echo __( 'No archive specified.', 'boldgrid-backup' );
138
+ return;
139
+ }
140
+
141
+ // Get our archive.
142
+ $archive = $this->core->archive->get_by_name( $filename );
143
+ if ( $archive ) {
144
+ $log = $this->core->archive_log->get_by_zip( $archive['filepath'] );
145
+ $archive = array_merge( $log, $archive );
146
+ $archive_found = true;
147
+ $dump_file = $this->core->get_dump_file( $archive['filepath'] );
148
+ } else {
149
+ $archive = array(
150
+ 'filename' => $filename,
151
+ 'filepath' => $this->core->backup_dir->get_path_to( $archive['filename'] ),
152
+ );
153
+ }
154
+
155
+ // Initialize the archive. We will need it in our included template below.
156
+ $this->core->archive->init( $archive['filepath'] );
157
+
158
+ include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-archive-details.php';
159
+ }
160
+
161
+ /**
162
+ * Validate the nonce on the Backup Archive Details page.
163
+ *
164
+ * On the backup archive page, there is a nonce used by several different
165
+ * methods, boldgrid_backup_remote_storage_upload. This method is an easy
166
+ * way to validate the nonce.
167
+ *
168
+ * The nonce can be added to an ajax request's data via:
169
+ * 'security' : $( '#_wpnonce' ).val()
170
+ *
171
+ * @since 1.5.4
172
+ */
173
+ public function validate_nonce() {
174
+ return check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false );
175
+ }
176
+ }
admin/class-boldgrid-backup-admin-archive-fail.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BoldGrid Backup Admin Archive Fail.
4
+ *
5
+ * @link http://www.boldgrid.com
6
+ * @since 1.5.2
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid.com
11
+ * @version $Id$
12
+ * @author BoldGrid.com <wpb@boldgrid.com>
13
+ */
14
+
15
+ /**
16
+ * BoldGrid Backup Admin Archive Fail Class.
17
+ *
18
+ * @since 1.5.1
19
+ */
20
+ class Boldgrid_Backup_Admin_Archive_Fail {
21
+ /**
22
+ * The core class object.
23
+ *
24
+ * @since 1.5.2
25
+ * @access private
26
+ * @var Boldgrid_Backup_Admin_Core
27
+ */
28
+ private $core;
29
+
30
+ /**
31
+ * A string that will hold memory for emergency purposes.
32
+ *
33
+ * @since 1.5.2
34
+ * @access public
35
+ * @var string
36
+ * @see archive_files_init
37
+ */
38
+ public $memory = '';
39
+
40
+ /**
41
+ * Generic lang string stating unable to backup.
42
+ *
43
+ * @since 1.5.4
44
+ * @access public
45
+ * @var string
46
+ */
47
+ public $unable_to_backup;
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 1.5.2
53
+ *
54
+ * @param Boldgrid_Backup_Admin_Core $core Core class object.
55
+ */
56
+ public function __construct( $core ) {
57
+ $this->core = $core;
58
+
59
+ $this->unable_to_backup = __( 'We were unable to create a backup of your website due to the following:', 'boldgrid-backup' );
60
+ }
61
+
62
+ /**
63
+ * Add actions to "boldgrid_backup_archive_files_init".
64
+ *
65
+ * The "boldgrid_backup_archive_files_init" action is done as the first
66
+ * thing within the archive files method.
67
+ *
68
+ * @since 1.5.2
69
+ */
70
+ public function archive_files_init() {
71
+ add_action( 'shutdown', array( $this, 'shutdown' ) );
72
+
73
+ /*
74
+ * Store ~0.35 MB of memory for use in an emergency.
75
+ *
76
+ * If there's a fatal error, our shutdown method will need enough
77
+ * memory to complete a few tasks. 0.25 MB seems sufficient, but we'll
78
+ * save 0.35 to be on the safe side.
79
+ *
80
+ * Tests have shown the following memory limits are sufficient enough
81
+ * for executing our shutdown function:
82
+ * # YES 1 MB
83
+ * # YES .5 MB
84
+ * # YES .25 MB
85
+ * # NO .10 MB shutdown function fails early on when calling
86
+ * error_get_last().
87
+ */
88
+ $mb = 1000000;
89
+ $this->memory = str_repeat( '0', ( 0.35 * $mb ) );
90
+ }
91
+
92
+ /**
93
+ * Send an email if a backup failed during cron.
94
+ *
95
+ * @since 1.5.2
96
+ *
97
+ * @param array $data Array of data, containing a message to send via email.
98
+ * @return bool
99
+ */
100
+ public function cron_fail_email( $data ) {
101
+ $subject = __( 'Backup failed for', 'boldgrid-backup' ) . ' ' . get_site_url();
102
+ return $this->core->email->send( $subject, $data['message'] );
103
+ }
104
+
105
+ /**
106
+ * Create a "backup failed" email and schedule it to be sent via jobs.
107
+ *
108
+ * @since 1.5.4
109
+ *
110
+ * @param string $message Error message.
111
+ */
112
+ public function schedule_fail_email( $message ) {
113
+ $message = sprintf(
114
+ $this->unable_to_backup . "\n\n%1\$s",
115
+ strip_tags( $message )
116
+ );
117
+
118
+ $email_body = $this->core->email->fill_generic_template( $message, false );
119
+
120
+ $args = array(
121
+ 'action' => 'boldgrid_backup_cron_fail_email',
122
+ 'action_data' => array(
123
+ 'message' => $email_body,
124
+ ),
125
+ 'action_title' => __( 'Send warning email because backup failed', 'boldgrid-backup' ),
126
+ );
127
+
128
+ $this->core->jobs->add( $args );
129
+ }
130
+
131
+ /**
132
+ * Hook into shutdown.
133
+ *
134
+ * @since 1.5.2
135
+ */
136
+ public function shutdown() {
137
+
138
+ // Free up memory so we have enough to complete this method.
139
+ $this->memory = null;
140
+
141
+ // If we had a fatal error, tell the system we're no longer backing up.
142
+ $this->core->in_progress->end();
143
+
144
+ /*
145
+ * If an archive fails, there may be a rogue db dump sitting out there.
146
+ * If it exists, delete it, it should be in the archive file.
147
+ */
148
+ if ( $this->core->wp_filesystem->exists( $this->core->db_dump_filepath ) ) {
149
+ $this->core->wp_filesystem->delete( $this->core->db_dump_filepath );
150
+ }
151
+
152
+ $last_error = error_get_last();
153
+
154
+ /*
155
+ * If there's no error or this is not fatal, abort.
156
+ *
157
+ * @see http://php.net/manual/en/errorfunc.constants.php
158
+ */
159
+ if ( empty( $last_error ) || 1 !== $last_error['type'] ) {
160
+ return;
161
+ }
162
+
163
+ $error_message = sprintf(
164
+ '<strong>%1$s</strong>: %2$s in %3$s on line %4$s',
165
+ __( 'Fatal error', 'boldgrid-backup' ),
166
+ $last_error['message'],
167
+ $last_error['file'],
168
+ $last_error['line']
169
+ );
170
+
171
+ $this->schedule_fail_email( $error_message );
172
+
173
+ if ( ! $this->core->doing_cron ) {
174
+ $data['errorText'] = $this->unable_to_backup . '<br />' . $error_message;
175
+ wp_send_json_error( $data );
176
+ }
177
+ }
178
+ }
admin/class-boldgrid-backup-admin-archive-log.php ADDED
@@ -0,0 +1,199 @@