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

/wp-content/plugins/backupbuddy/controllers/ajax.php

https://bitbucket.org/betaimages/chakalos
PHP | 1179 lines | 680 code | 279 blank | 220 comment | 146 complexity | cb350b4b918efc3b3a0b26eb9e53e9ae MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. class pb_backupbuddy_ajax extends pb_backupbuddy_ajaxcore {
  3. // Used for recent backup listing.
  4. public function backup_step_status() {
  5. $serial = pb_backupbuddy::_GET( 'serial' );
  6. pb_backupbuddy::load();
  7. pb_backupbuddy::$ui->ajax_header();
  8. echo '<h3>Backup Process Technical Details</h3>';
  9. echo '<b>Step Details:</b><br>';
  10. echo '<textarea style="width: 100%; height: 120px;" wrap="off">';
  11. print_r( pb_backupbuddy::$options['backups'][$serial] );
  12. echo '</textarea><br><br>';
  13. // Output status log if it exists.
  14. $log_directory = WP_CONTENT_DIR . '/uploads/pb_' . pb_backupbuddy::settings( 'slug' ) . '/';
  15. $serial_file = $log_directory . 'status-' . $serial . '_' . pb_backupbuddy::$options['log_serial'] . '.txt';
  16. if ( file_exists( $serial_file ) ) {
  17. echo '<b>Log Details:</b><br>';
  18. echo '<textarea style="width: 100%; height: 120px;" wrap="off">';
  19. echo file_get_contents( $serial_file );
  20. echo '</textarea><br><br>';
  21. }
  22. echo 'This information is primarily used for troubleshooting when working with support. If you are encountering problems providing this information to support may assist in troubleshooting.';
  23. pb_backupbuddy::$ui->ajax_footer();
  24. die();
  25. } // End backup_step_status().
  26. // IMPORTANT: MUST provide 3rd param, backup serial ID, when using pb_backupbuddy::status() within this function for it to show for this backup.
  27. public function backup_status() {
  28. $serial = trim( pb_backupbuddy::_POST( 'serial' ) );
  29. // Make sure the serial exists.
  30. if ( ( $serial == '' ) || empty( pb_backupbuddy::$options['backups'][$serial] ) ) {
  31. echo '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|0|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|error|~|Error #9031. Invalid backup serial (' . htmlentities( $serial ) . '). Please check directory permissions for your wp-content/uploads/ directory recursively, your PHP error_log for any errors, and that you have enough free disk space. If seeking support please provide this full status log and PHP error log. Fatal error.' . "\n";
  32. echo '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|0|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|halt_script' . "\n";
  33. } else {
  34. //***** Begin outputting status of the current step.
  35. foreach( pb_backupbuddy::$options['backups'][$serial]['steps'] as $step ) {
  36. if ( ( $step['start_time'] != 0 ) && ( $step['finish_time'] == 0 ) ) { // A step has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
  37. // For database dump step output the SQL file current size.
  38. if ( $step['function'] == 'backup_create_database_dump' ) {
  39. $sql_file = pb_backupbuddy::$options['backups'][$serial]['temp_directory'] . 'db_1.sql';
  40. if ( file_exists( $sql_file ) ) {
  41. $sql_filesize = pb_backupbuddy::$format->file_size( filesize( $sql_file ) );
  42. } else { // No SQL file yet.
  43. $sql_filesize = '[SQL file not found yet]';
  44. }
  45. pb_backupbuddy::status( 'details', 'Current SQL database dump file size: ' . $sql_filesize . '.', $serial );
  46. }
  47. pb_backupbuddy::status( 'details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . ( time() - $step['start_time'] ) . ' seconds ago.', $serial );
  48. if ( ( time() - $step['start_time'] ) > 300 ) {
  49. pb_backupbuddy::status( 'warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . ( time() - $step['start_time'] ) . ' seconds). The backup may have stalled.', $serial );
  50. }
  51. } elseif ( $step['start_time'] == 0 ) { // Step that has not started yet.
  52. } else { // Last case: Finished. Skip.
  53. // Do nothing.
  54. }
  55. }
  56. //***** End outputting status of the current step.
  57. //***** Begin output of temp zip file size.
  58. $temporary_zip_directory = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $serial . '/';
  59. if ( file_exists( $temporary_zip_directory ) ) { // Temp zip file.
  60. $directory = opendir( $temporary_zip_directory );
  61. while( $file = readdir( $directory ) ) {
  62. if ( ( $file != '.' ) && ( $file != '..' ) && ( $file != 'exclusions.txt' ) ) {
  63. $stats = stat( $temporary_zip_directory . $file );
  64. //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy' ) .': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
  65. pb_backupbuddy::status( 'details', __('Temporary ZIP file size', 'it-l10n-backupbuddy' ) .': ' . pb_backupbuddy::$format->file_size( $stats['size'] ), $serial );
  66. //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
  67. pb_backupbuddy::status( 'action', 'archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ), $serial );
  68. }
  69. }
  70. closedir( $directory );
  71. unset( $directory );
  72. }
  73. //***** End output of temp zip file size.
  74. // Output different stuff to the browser depending on whether backup is finished or not.
  75. if ( pb_backupbuddy::$options['backups'][$serial]['finish_time'] > 0 ) { // BACKUP FINISHED.
  76. // OUTPUT COMPLETED ZIP FINAL SIZE.
  77. if( file_exists( pb_backupbuddy::$options['backups'][$serial]['archive_file'] ) ) { // Final zip file.
  78. $stats = stat( pb_backupbuddy::$options['backups'][$serial]['archive_file'] );
  79. //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|details|~|' . __('Completed backup final ZIP file size', 'it-l10n-backupbuddy' ) . ': ' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";;
  80. pb_backupbuddy::status( 'details', __('Completed backup final ZIP file size', 'it-l10n-backupbuddy' ) . ': ' . pb_backupbuddy::$format->file_size( $stats['size'] ), $serial );
  81. //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . '|~|' . round ( microtime( true ) - pb_backupbuddy::$start_time, 2 ) . '|~|' . round( memory_get_peak_usage() / 1048576, 2 ) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ) . "\n";
  82. pb_backupbuddy::status( 'action', 'archive_size^' . pb_backupbuddy::$format->file_size( $stats['size'] ), $serial );
  83. $backup_finished = true;
  84. } else {
  85. pb_backupbuddy::status( 'error', __( 'Backup reports success but unable to access final ZIP file. Verify permissions and ownership. If the error persists insure that server is properly configured with suphp and proper ownership & permissions.', 'it-l10n-backupbuddy' ), $serial );
  86. }
  87. pb_backupbuddy::status( 'message', __('Backup successfully completed in ', 'it-l10n-backupbuddy' ) . ' ' . pb_backupbuddy::$format->time_duration( pb_backupbuddy::$options['backups'][$serial]['finish_time'] - pb_backupbuddy::$options['backups'][$serial]['start_time'] ) . '.', $serial );
  88. pb_backupbuddy::status( 'action', 'finish_backup', $serial );
  89. } else { // NOT FINISHED
  90. //$return_status .= '!' . pb_backupbuddy::$format->localize_time( time() ) . "|~|0|~|0|~|ping\n";
  91. pb_backupbuddy::status( 'message', __( 'Ping. Waiting for server . . .', 'it-l10n-backupbuddy' ), $serial );
  92. }
  93. //***** Begin getting status log information.
  94. $return_status = '';
  95. $status_lines = pb_backupbuddy::get_status( $serial, true, false, true ); // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
  96. if ( $status_lines !== false ) { // Only add lines if there is status contents.
  97. foreach( $status_lines as $status_line ) {
  98. //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
  99. $return_status .= '!' . implode( '|~|', $status_line ) . "\n";
  100. }
  101. }
  102. //***** End getting status log information.
  103. echo $return_status; // Return messages.
  104. }
  105. die();
  106. } // End backup_status().
  107. /* importbuddy()
  108. *
  109. * Compile ImportBuddy and stream download to browser.
  110. *
  111. */
  112. public function importbuddy() {
  113. $pass_hash = '';
  114. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  115. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  116. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  117. }
  118. if ( pb_backupbuddy::_GET( 'p' ) != '' ) {
  119. $pass_hash = md5( pb_backupbuddy::_GET( 'p' ) );
  120. if ( pb_backupbuddy::$options['importbuddy_pass_hash'] == '' ) { // if no default pass is set then we set this as default.
  121. pb_backupbuddy::$options['importbuddy_pass_hash'] = $pass_hash;
  122. pb_backupbuddy::$options['importbuddy_pass_length'] = strlen( pb_backupbuddy::_GET( 'p' ) ); // length of pass pre-hash.
  123. pb_backupbuddy::save();
  124. }
  125. }
  126. pb_backupbuddy::$classes['core']->importbuddy( '', $pass_hash ); // Outputs importbuddy to browser for download.
  127. die();
  128. } // End importbuddy().
  129. /* repairbuddy()
  130. *
  131. * Compile RepairBuddy and stream download to browser.
  132. *
  133. */
  134. public function repairbuddy() {
  135. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  136. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  137. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  138. }
  139. pb_backupbuddy::$classes['core']->repairbuddy(); // Outputs repairbuddy to browser for download.
  140. die();
  141. } // End repairbuddy().
  142. public function hash() {
  143. pb_backupbuddy::load();
  144. pb_backupbuddy::$ui->ajax_header();
  145. require_once( 'ajax/_hash.php' );
  146. pb_backupbuddy::$ui->ajax_footer();
  147. die();
  148. } // End destination_picker().
  149. /* destination_picker()
  150. *
  151. * iframe remote destination selector page.
  152. *
  153. */
  154. public function destination_picker() {
  155. pb_backupbuddy::load();
  156. pb_backupbuddy::$ui->ajax_header();
  157. $mode = 'destination';
  158. require_once( 'ajax/_destination_picker.php' );
  159. pb_backupbuddy::$ui->ajax_footer();
  160. die();
  161. } // End destination_picker().
  162. /* migration_picker()
  163. *
  164. * Same as destination picker but in migration mode (only limited destinations are available).
  165. *
  166. */
  167. public function migration_picker() {
  168. pb_backupbuddy::load();
  169. pb_backupbuddy::$ui->ajax_header();
  170. $mode = 'migration';
  171. require_once( 'ajax/_destination_picker.php' );
  172. pb_backupbuddy::$ui->ajax_footer();
  173. die();
  174. } // End migration_picker().
  175. /* remote_send()
  176. *
  177. * Send backup archive to a remote destination manually. Optionally sends importbuddy.php with files.
  178. * Sends are scheduled to run in a cron and are passed to the cron.php remote_send() method.
  179. *
  180. * @return null
  181. */
  182. public function remote_send() {
  183. if ( defined( 'PB_DEMO_MODE' ) ) {
  184. die( 'Access denied in demo mode.' );
  185. }
  186. $success_output = false; // Set to true onece a leading 1 has been sent to the javascript to indicate success.
  187. $destination_id = pb_backupbuddy::_POST( 'destination_id' );
  188. if ( pb_backupbuddy::_POST( 'file' ) != 'importbuddy.php' ) {
  189. $backup_file = pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_POST( 'file' );
  190. } else {
  191. $backup_file = '';
  192. }
  193. if ( pb_backupbuddy::_POST( 'send_importbuddy' ) == '1' ) {
  194. $send_importbuddy = true;
  195. pb_backupbuddy::status( 'details', 'Cron send to be scheduled with importbuddy sending.' );
  196. } else {
  197. $send_importbuddy = false;
  198. pb_backupbuddy::status( 'details', 'Cron send to be scheduled WITHOUT importbuddy sending.' );
  199. }
  200. // For Stash we will check the quota prior to initiating send.
  201. if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) {
  202. // Pass off to destination handler.
  203. require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
  204. $send_result = pb_backupbuddy_destinations::get_info( 'stash' ); // Used to kick the Stash destination into life.
  205. $stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][$destination_id], true );
  206. //print_r( $stash_quota );
  207. if ( $backup_file != '' ) {
  208. $backup_file_size = filesize( $backup_file );
  209. } else {
  210. $backip_file_size = 50000;
  211. }
  212. if ( ( $backup_file_size + $stash_quota['quota_used'] ) > $stash_quota['quota_total'] ) {
  213. echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n";
  214. echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size( $backup_file_size ) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. ';
  215. echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
  216. die();
  217. } else {
  218. if ( isset( $stash_quota['quota_warning'] ) && ( $stash_quota['quota_warning'] != '' ) ) {
  219. echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n";
  220. $success_output = true;
  221. }
  222. }
  223. }
  224. wp_schedule_single_event( time(), pb_backupbuddy::cron_tag( 'remote_send' ), array( $destination_id, $backup_file, pb_backupbuddy::_POST( 'trigger' ), $send_importbuddy ) );
  225. spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit.
  226. update_option( '_transient_doing_cron', 0 ); // Prevent cron-blocking for next item.
  227. // SEE cron.php remote_send() for sending function that we pass to via the cron above.
  228. if ( $success_output === false ) {
  229. echo 1;
  230. }
  231. die();
  232. } // End remote_send().
  233. /* migrate_status()
  234. *
  235. * Gives the current migration status. Echos.
  236. *
  237. * @return null
  238. */
  239. function migrate_status() {
  240. $step = pb_backupbuddy::_POST( 'step' );
  241. $backup_file = pb_backupbuddy::_POST( 'backup_file' );
  242. $url = trim( pb_backupbuddy::_POST( 'url' ) );
  243. switch( $step ) {
  244. case 'step1': // Make sure backup file has been transferred properly.
  245. // Find last migration.
  246. $last_migration_key = '';
  247. foreach( pb_backupbuddy::$options['remote_sends'] as $send_key => $send ) { // Find latest migration send for this file.
  248. if ( basename( $send['file'] ) == $backup_file ) {
  249. if ( $send['trigger'] == 'migration' ) {
  250. $last_migration_key = $send_key;
  251. }
  252. }
  253. } // end foreach.
  254. $migrate_send_status = pb_backupbuddy::$options['remote_sends'][$last_migration_key]['status'];
  255. if ( $migrate_send_status == 'timeout' ) {
  256. $status_message = 'Status: Waiting for backup to finish uploading to server...';
  257. $next_step = '1';
  258. } elseif ( $migrate_send_status == 'failure' ) {
  259. $status_message = 'Status: Sending backup to server failed.';
  260. $next_step = '0';
  261. } elseif ( $migrate_send_status == 'success' ) {
  262. $status_message = 'Status: Success sending backup file.';
  263. $next_step = '2';
  264. }
  265. die( json_encode( array(
  266. 'status_code' => $migrate_send_status,
  267. 'status_message' => $status_message,
  268. 'next_step' => $next_step,
  269. ) ) );
  270. break;
  271. case 'step2': // Hit importbuddy file to make sure URL is correct, it exists, and extracts itself fine.
  272. $url = rtrim( $url, '/' ); // Remove trailing slash if its there.
  273. if ( strpos( $url, 'importbuddy.php' ) === false ) { // If no importbuddy.php at end of URL add it.
  274. $url .= '/importbuddy.php';
  275. }
  276. if ( ( false === strstr( $url, 'http://' ) ) && ( false === strstr( $url, 'https://' ) ) ) { // http or https is missing; prepend it.
  277. $url = 'http://' . $url;
  278. }
  279. $response = wp_remote_get( $url . '?api=ping', array(
  280. 'method' => 'GET',
  281. 'timeout' => 45,
  282. 'redirection' => 5,
  283. 'httpversion' => '1.0',
  284. 'blocking' => true,
  285. 'headers' => array(),
  286. 'body' => null,
  287. 'cookies' => array()
  288. )
  289. );
  290. if( is_wp_error( $response ) ) {
  291. die( json_encode( array(
  292. 'status_code' => 'failure',
  293. 'status_message' => 'Status: HTTP error checking for importbuddy.php at `' . $url . '`. Error: `' . $response->get_error_message() . '`.',
  294. 'next_step' => '0',
  295. ) ) );
  296. }
  297. if ( trim( $response['body'] ) == 'pong' ) { // Importbuddy found.
  298. die( json_encode( array(
  299. 'import_url' => $url . '?display_mode=embed&file=' . pb_backupbuddy::_POST( 'backup_file' ) . '&v=' . pb_backupbuddy::$options['importbuddy_pass_hash'],
  300. 'status_code' => 'success',
  301. 'status_message' => 'Sucess verifying URL is valid importbuddy.php location. Continue migration below.',
  302. 'next_step' => '0',
  303. ) ) );
  304. } else { // No importbuddy here.
  305. die( json_encode( array(
  306. 'status_code' => 'failure',
  307. 'status_message' => '<b>Error</b>: The importbuddy.php file uploaded was not found at <a href="' . $url . '">' . $url . '</a>. Please verify the URL properly matches & corresponds to the upload directory entered for this destination\'s settings.<br><br><b>Tip:</b> This error is only caused by URL not properly matching, permissions on the destination server blocking the script, or other destination server error. You may manually verify that the importbuddy.php scripts exists in the expected location on the destination server and that the script URL <a href="' . $url . '">' . $url . '</a> properly loads the ImportBuddy tool. You may manually upload importbuddy.php and the backup ZIP file to the destination server & navigating to its URL in your browser for an almost-as-quick alternative.',
  308. 'next_step' => '0',
  309. ) ) );
  310. }
  311. break;
  312. default:
  313. echo 'Invalid migrate_status() step: `' . pb_backupbuddy::_POST( 'step' ) . '`.';
  314. break;
  315. } // End switch on action.
  316. die();
  317. } // End migrate_status().
  318. /* icicle()
  319. *
  320. * Builds and returns graphical directory size listing. Echos.
  321. *
  322. * @return null
  323. */
  324. public function icicle() {
  325. pb_backupbuddy::set_greedy_script_limits(); // Building the directory tree can take a bit.
  326. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  327. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  328. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  329. }
  330. $response = pb_backupbuddy::$classes['core']->build_icicle( ABSPATH, ABSPATH, '', -1 );
  331. echo $response[0];
  332. die();
  333. } // End icicle().
  334. public function remote_delete() {
  335. pb_backupbuddy::verify_nonce(); // Security check.
  336. // Destination ID.
  337. $destination_id = pb_backupbuddy::_GET( 'pb_backupbuddy_destinationid' );
  338. // Delete the destination.
  339. require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
  340. $delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true );
  341. // Response.
  342. if ( $delete_response !== true ) { // Some kind of error so just echo it.
  343. echo 'Error #544558: `' . $delete_response . '`.';
  344. } else { // Success.
  345. echo 'Destination deleted.';
  346. }
  347. die();
  348. } // End remote_delete().
  349. /* remote_test()
  350. *
  351. * Remote destination testing. Echos.
  352. *
  353. * @return null
  354. */
  355. function remote_test() {
  356. if ( defined( 'PB_DEMO_MODE' ) ) {
  357. die( 'Access denied in demo mode.' );
  358. }
  359. require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
  360. $form_settings = array();
  361. foreach( pb_backupbuddy::_POST() as $post_id => $post ) {
  362. if ( substr( $post_id, 0, 15 ) == 'pb_backupbuddy_' ) {
  363. $id = substr( $post_id, 15 );
  364. if ( $id != '' ) {
  365. $form_settings[$id] = $post;
  366. }
  367. }
  368. }
  369. $test_result = pb_backupbuddy_destinations::test( $form_settings );
  370. if ( $test_result === true ) {
  371. echo 'Test successful.';
  372. } else {
  373. echo "Test failed.\n\n";
  374. echo $test_result;
  375. }
  376. die();
  377. } // End remote_test().
  378. /* remote_save()
  379. *
  380. * Remote destination saving.
  381. *
  382. * @return null
  383. */
  384. public function remote_save() {
  385. pb_backupbuddy::verify_nonce();
  386. require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' );
  387. $settings_form = pb_backupbuddy_destinations::configure( array( 'type' => pb_backupbuddy::_POST( 'pb_backupbuddy_type' ) ), 'save' );
  388. $save_result = $settings_form->process();
  389. $destination_id = trim( pb_backupbuddy::_GET( 'pb_backupbuddy_destinationid' ) );
  390. if ( count( $save_result['errors'] ) == 0 ) {
  391. if ( $destination_id == 'NEW' ) { // ADD NEW.
  392. // Dropbox Kludge. Sigh.
  393. $save_result['data']['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
  394. pb_backupbuddy::$options['remote_destinations'][] = $save_result['data'];
  395. pb_backupbuddy::save();
  396. echo 'Destination Added.';
  397. } elseif ( !isset( pb_backupbuddy::$options['remote_destinations'][$destination_id] ) ) { // EDITING NONEXISTANT.
  398. echo 'Error #54859. Invalid destination ID.';
  399. } else { // EDITING EXISTING -- Save!
  400. pb_backupbuddy::$options['remote_destinations'][$destination_id] = $save_result['data'];
  401. //echo '<pre>' . print_r( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ) . '</pre>';
  402. pb_backupbuddy::save();
  403. echo 'Settings saved.';
  404. }
  405. } else {
  406. echo "Error saving settings.\n\n";
  407. echo implode( "\n", $save_result['errors'] );
  408. }
  409. die();
  410. } // End remote_save().
  411. /* refresh_site_size()
  412. *
  413. * Server info page site size refresh. Echos out the new site size (pretty version).
  414. *
  415. * @return null
  416. */
  417. public function refresh_site_size() {
  418. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  419. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  420. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  421. }
  422. $site_size = pb_backupbuddy::$classes['core']->get_site_size(); // array( site_size, site_size_sans_exclusions ).
  423. echo pb_backupbuddy::$format->file_size( $site_size[0] );
  424. die();
  425. } // End refresh_site_size().
  426. /* refresh_site_size_excluded()
  427. *
  428. * Server info page site size (sans exclusions) refresh. Echos out the new site size (pretty version).
  429. *
  430. * @return null
  431. */
  432. public function refresh_site_size_excluded() {
  433. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  434. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  435. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  436. }
  437. $site_size = pb_backupbuddy::$classes['core']->get_site_size(); // array( site_size, site_size_sans_exclusions ).
  438. echo pb_backupbuddy::$format->file_size( $site_size[1] );
  439. die();
  440. } // End refresh_site_size().
  441. /* refresh_database_size()
  442. *
  443. * Server info page database size refresh. Echos out the new site size (pretty version).
  444. *
  445. * @return null
  446. */
  447. public function refresh_database_size() {
  448. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  449. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  450. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  451. }
  452. $database_size = pb_backupbuddy::$classes['core']->get_database_size(); // array( database_size, database_size_sans_exclusions ).
  453. echo pb_backupbuddy::$format->file_size( $database_size[1] );
  454. die();
  455. } // End refresh_site_size().
  456. /* refresh_database_size_excluded()
  457. *
  458. * Server info page database size (sans exclusions) refresh. Echos out the new site size (pretty version).
  459. *
  460. * @return null
  461. */
  462. public function refresh_database_size_excluded() {
  463. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  464. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  465. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  466. }
  467. $database_size = pb_backupbuddy::$classes['core']->get_database_size(); // array( database_size, database_size_sans_exclusions ).
  468. echo pb_backupbuddy::$format->file_size( $database_size[1] );
  469. die();
  470. } // End refresh_site_size().
  471. /* exclude_tree()
  472. *
  473. * Directory exclusion tree for settings page.
  474. *
  475. * @return null
  476. */
  477. function exclude_tree() {
  478. $root = ABSPATH . urldecode( pb_backupbuddy::_POST( 'dir' ) );
  479. if( file_exists( $root ) ) {
  480. $files = scandir( $root );
  481. natcasesort( $files );
  482. // Sort with directories first.
  483. $sorted_files = array(); // Temporary holder for sorting files.
  484. $sorted_directories = array(); // Temporary holder for sorting directories.
  485. foreach( $files as $file ) {
  486. if ( ( $file == '.' ) || ( $file == '..' ) ) {
  487. continue;
  488. }
  489. if( is_file( str_replace( '//', '/', $root . $file ) ) ) {
  490. array_push( $sorted_files, $file );
  491. } else {
  492. array_unshift( $sorted_directories, $file );
  493. }
  494. }
  495. $files = array_merge( array_reverse( $sorted_directories ), $sorted_files );
  496. unset( $sorted_files );
  497. unset( $sorted_directories );
  498. unset( $file );
  499. if( count( $files ) > 2 ) { /* The 2 accounts for . and .. */
  500. echo '<ul class="jqueryFileTree" style="display: none;">';
  501. foreach( $files as $file ) {
  502. if( file_exists( str_replace( '//', '/', $root . $file ) ) ) {
  503. if ( is_dir( str_replace( '//', '/', $root . $file ) ) ) {
  504. echo '<li class="directory collapsed"><a href="#" rel="' . htmlentities( str_replace( ABSPATH, '', $root ) . $file) . '/">' . htmlentities($file) . ' <img src="' . pb_backupbuddy::plugin_url() . '/images/bullet_delete.png" style="vertical-align: -3px;" /></a></li>';
  505. } else {
  506. echo '<li class="file collapsed"><a href="#" rel="' . htmlentities( str_replace( ABSPATH, '', $root ) . $file) . '">' . htmlentities($file) . ' <img src="' . pb_backupbuddy::plugin_url() . '/images/bullet_delete.png" style="vertical-align: -3px;" /></a></li>';
  507. }
  508. }
  509. }
  510. echo '</ul>';
  511. } else {
  512. echo '<ul class="jqueryFileTree" style="display: none;">';
  513. echo '<li><a href="#" rel="' . htmlentities( pb_backupbuddy::_POST( 'dir' ) . 'NONE' ) . '"><i>Empty Directory ...</i></a></li>';
  514. echo '</ul>';
  515. }
  516. } else {
  517. echo 'Error #1127555. Unable to read site root.';
  518. }
  519. die();
  520. } // End exclude_tree().
  521. /* download_archive()
  522. *
  523. * Handle allowing download of archive.
  524. *
  525. * @param
  526. * @return
  527. */
  528. public function download_archive() {
  529. if ( is_multisite() && !current_user_can( 'manage_network' ) ) { // If a Network and NOT the superadmin must make sure they can only download the specific subsite backups for security purposes.
  530. // Load core if it has not been instantiated yet.
  531. if ( !isset( pb_backupbuddy::$classes['core'] ) ) {
  532. require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' );
  533. pb_backupbuddy::$classes['core'] = new pb_backupbuddy_core();
  534. }
  535. // Only allow downloads of their own backups.
  536. if ( !strstr( pb_backupbuddy::_GET( 'backupbuddy_backup' ), pb_backupbuddy::$classes['core']->backup_prefix() ) ) {
  537. die( 'Access Denied. You may only download backups specific to your Multisite Subsite. Only Network Admins may download backups for another subsite in the network.' );
  538. }
  539. }
  540. // Make sure file exists we are trying to get.
  541. if ( !file_exists( pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_GET( 'backupbuddy_backup' ) ) ) { // Does not exist.
  542. die( 'Error #548957857584784332. The requested backup file does not exist. It may have already been deleted.' );
  543. }
  544. // Make sure file to download is in a publicly accessible location (beneath WP web root technically).
  545. if ( FALSE === stristr( pb_backupbuddy::$options['backup_directory'], ABSPATH ) ) {
  546. die( 'Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.' );
  547. }
  548. // Made it this far so download dir is within this WP install.
  549. $sitepath = str_replace( ABSPATH, '', pb_backupbuddy::$options['backup_directory'] );
  550. $download_url = rtrim( site_url(), '/\\' ) . '/' . trim( $sitepath, '/\\' ) . '/' . pb_backupbuddy::_GET( 'backupbuddy_backup' );
  551. //$download_url = site_url() . '/wp-content/uploads/backupbuddy_backups/' . pb_backupbuddy::_GET( 'backupbuddy_backup' );
  552. if ( pb_backupbuddy::$options['lock_archives_directory'] == '1' ) { // High security mode.
  553. if ( file_exists( pb_backupbuddy::$options['backup_directory'] . '.htaccess' ) ) {
  554. $unlink_status = @unlink( pb_backupbuddy::$options['backup_directory'] . '.htaccess' );
  555. if ( $unlink_status === false ) {
  556. die( 'Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.' );
  557. }
  558. }
  559. header( 'Location: ' . $download_url );
  560. ob_clean();
  561. flush();
  562. sleep( 8 ); // Wait 8 seconds before creating security file.
  563. $htaccess_creation_status = @file_put_contents( pb_backupbuddy::$options['backup_directory'] . '.htaccess', 'deny from all' );
  564. if ( $htaccess_creation_status === false ) {
  565. die( 'Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.' );
  566. }
  567. } else { // Normal mode.
  568. header( 'Location: ' . $download_url );
  569. }
  570. die();
  571. } // End download_archive().
  572. // Server info page phpinfo button.
  573. public function phpinfo() {
  574. phpinfo();
  575. die();
  576. }
  577. /* set_backup_note()
  578. *
  579. * Used for setting a note to a backup archive.
  580. *
  581. * @return null
  582. */
  583. public function set_backup_note() {
  584. if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) {
  585. require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
  586. pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( pb_backupbuddy::$options['backup_directory'] );
  587. }
  588. $backup_file = pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_POST( 'backup_file' );
  589. $note = pb_backupbuddy::_POST( 'note' );
  590. $note = ereg_replace( "[[:space:]]+", ' ', $note );
  591. $note = ereg_replace( "[^[:print:]]", '', $note );
  592. $note = htmlentities( substr( $note, 0, 200 ) );
  593. // Returns true on success, else the error message.
  594. $comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment( $backup_file, $note );
  595. if ( $comment_result !== true ) {
  596. echo $comment_result;
  597. } else {
  598. echo '1';
  599. }
  600. // Even if we cannot save the note into the archive file, store it in internal settings.
  601. $serial = pb_backupbuddy::$classes['core']->get_serial_from_file( $backup_file );
  602. pb_backupbuddy::$options['backups'][$serial]['integrity']['comment'] = $note;
  603. pb_backupbuddy::save();
  604. die();
  605. } // End set_backup_note().
  606. public function integrity_status() {
  607. $serial = pb_backupbuddy::_GET( 'serial' );
  608. pb_backupbuddy::load();
  609. pb_backupbuddy::$ui->ajax_header();
  610. $integrity = pb_backupbuddy::$options['backups'][$serial]['integrity'];
  611. // Backup overall status.
  612. /*
  613. echo 'Backup status: ';
  614. if ( $integrity['status'] == 'pass' ) { // Pass.
  615. echo '<span class="pb_label pb_label-success">Good</span>';
  616. } else { // Fail.
  617. echo '<span class="pb_label pb_label-important">Bad</span>';
  618. }
  619. echo '<br>';
  620. */
  621. //***** BEGIN TESTS AND RESULTS.
  622. if ( ! is_array( $integrity['status_details'] ) ) { // $integrity['status_details'] is NOT array (old, pre-3.1.9).
  623. echo '<h3>Integrity Technical Details</h3>';
  624. echo '<textarea style="width: 100%; height: 175px;" wrap="off">';
  625. foreach( pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value ) {
  626. $item_value = str_replace( '<br />', '<br>', $item_value );
  627. $item_value = str_replace( '<br><br>', '<br>', $item_value );
  628. $item_value = str_replace( '<br>', "\n ", $item_value );
  629. echo $item_name . ' => ' . $item_value . "\n";
  630. }
  631. echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.';
  632. } else { // $integrity['status_details'] is array.
  633. echo '<br>';
  634. function pb_pretty_results( $value ) {
  635. if ( $value === true ) {
  636. return '<span class="pb_label pb_label-success">Pass</span>';
  637. } else {
  638. return '<span class="pb_label pb_label-important">Fail</span>';
  639. }
  640. }
  641. // The tests & their status..
  642. $tests = array();
  643. $tests[] = array( 'BackupBackup data file exists', pb_pretty_results( $integrity['status_details']['found_dat'] ) );
  644. $tests[] = array( 'Database SQL file exists', pb_pretty_results( $integrity['status_details']['found_sql'] ) );
  645. if ( $integrity['detected_type'] == 'full' ) { // Full backup.
  646. $tests[] = array( 'WordPress wp-config.php exists (full backups only)', pb_pretty_results( $integrity['status_details']['found_wpconfig'] ) );
  647. } else { // DB only.
  648. $tests[] = array( 'WordPress wp-config.php exists (full backups only)', '<span class="pb_label pb_label-success">N/A</span>' );
  649. }
  650. $columns = array(
  651. __( 'Integrity Test', 'it-l10n-backupbuddy' ),
  652. __( 'Status', 'it-l10n-backupbuddy' ),
  653. );
  654. pb_backupbuddy::$ui->list_table(
  655. $tests,
  656. array(
  657. 'columns' => $columns,
  658. 'css' => 'width: 100%; min-width: 200px;',
  659. )
  660. );
  661. } // end $integrity['status_details'] is an array.
  662. //***** END TESTS AND RESULTS.
  663. echo '<br><br>';
  664. //***** BEGIN STEPS.
  665. $steps = array();
  666. if ( isset( pb_backupbuddy::$options['backups'][$serial]['steps'] ) ) {
  667. foreach( pb_backupbuddy::$options['backups'][$serial]['steps'] as $step ) {
  668. if ( isset( $step['finish_time'] ) && ( $step['finish_time'] != 0 ) ) {
  669. // Step name.
  670. if ( $step['function'] == 'backup_create_database_dump' ) {
  671. $step_name = 'Database dump';
  672. } elseif ( $step['function'] == 'backup_zip_files' ) {
  673. $step_name = 'Zip archive creation';
  674. } elseif ( $step['function'] == 'post_backup' ) {
  675. $step_name = 'Post-backup cleanup';
  676. } else {
  677. $step_name = $step['function'];
  678. }
  679. // Step time taken.
  680. $step_time = (string)( $step['finish_time'] - $step['start_time'] ) . ' seconds';
  681. // Compile details for this step into array.
  682. $steps[] = array(
  683. $step_name,
  684. $step_time,
  685. $step['attempts'],
  686. );
  687. }
  688. } // End foreach.
  689. } else { // End if serial in array is set.
  690. $step_times[] = 'unknown';
  691. } // End if serial in array is NOT set.
  692. $columns = array(
  693. __( 'Backup Step', 'it-l10n-backupbuddy' ),
  694. __( 'Time Taken', 'it-l10n-backupbuddy' ),
  695. __( 'Attempts', 'it-l10n-backupbuddy' ),
  696. );
  697. if ( count( $steps ) == 0 ) {
  698. _e( 'No step step statistics were found for this backup.', 'it-l10n-backupbuddy' );
  699. } else {
  700. pb_backupbuddy::$ui->list_table(
  701. $steps,
  702. array(
  703. 'columns' => $columns,
  704. 'css' => 'width: 100%; min-width: 200px;',
  705. )
  706. );
  707. }
  708. //***** END STEPS.
  709. if ( isset( pb_backupbuddy::$options['backups'][$serial]['trigger'] ) ) {
  710. $trigger = pb_backupbuddy::$options['backups'][$serial]['trigger'];
  711. } else {
  712. $trigger = 'Unknown trigger';
  713. }
  714. $scanned = pb_backupbuddy::$format->date( $integrity['scan_time'] );
  715. echo '<br><br>';
  716. echo ucfirst( $trigger ) . " backup {$integrity['file']} last scanned {$scanned}.";
  717. echo '<br><br>';
  718. /*
  719. echo '<h3>Integrity Technical Details</h3>';
  720. echo '<textarea style="width: 100%; height: 175px;" wrap="off">';
  721. foreach( pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value ) {
  722. $item_value = str_replace( '<br />', '<br>', $item_value );
  723. $item_value = str_replace( '<br><br>', '<br>', $item_value );
  724. $item_value = str_replace( '<br>', "\n ", $item_value );
  725. echo $item_name . ' => ' . $item_value . "\n";
  726. }
  727. echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.<br><br>If you are encountering problems providing this information to support may assist in troubleshooting.';
  728. */
  729. pb_backupbuddy::$ui->ajax_footer();
  730. die();
  731. } // End integrity_status().
  732. /* db_check()
  733. *
  734. * Check database integrity on a specific table. Used on server info page.
  735. *
  736. * @return null
  737. */
  738. public function db_check() {
  739. $table = base64_decode( pb_backupbuddy::_GET( 'table' ) );
  740. $check_level = 'MEDIUM';
  741. pb_backupbuddy::$ui->ajax_header();
  742. echo '<h2>Database Table Check</h2>';
  743. echo 'Checking table `' . $table . '` using ' . $check_level . ' scan...<br><br>';
  744. $result = mysql_query( "CHECK TABLE `" . mysql_real_escape_string( $table ) . "` " . $check_level );
  745. echo '<b>Results:</b><br><br>';
  746. echo '<table class="widefat">';
  747. while( $rs = mysql_fetch_array( $result ) ) {
  748. echo '<tr>';
  749. echo '<td>' . $rs['Msg_type'] . '</td>';
  750. echo '<td>' . $rs['Msg_text'] . '</td>';
  751. echo '</tr>';
  752. }
  753. echo '</table>';
  754. pb_backupbuddy::$ui->ajax_footer();
  755. die();
  756. } // End db_check().
  757. /* db_repair()
  758. *
  759. * Repair specific table. Used on server info page.
  760. *
  761. * @return null
  762. */
  763. public function db_repair() {
  764. $table = base64_decode( pb_backupbuddy::_GET( 'table' ) );
  765. pb_backupbuddy::$ui->ajax_header();
  766. echo '<h2>Database Table Repair</h2>';
  767. echo 'Repairing table `' . $table . '`...<br><br>';
  768. $result = mysql_query( "REPAIR TABLE `" . mysql_real_escape_string( $table ) . "`" );
  769. echo '<b>Results:</b><br><br>';
  770. echo '<table class="widefat">';
  771. while( $rs = mysql_fetch_array( $result ) ) {
  772. echo '<tr>';
  773. echo '<td>' . $rs['Msg_type'] . '</td>';
  774. echo '<td>' . $rs['Msg_text'] . '</td>';
  775. echo '</tr>';
  776. }
  777. echo '</table>';
  778. pb_backupbuddy::$ui->ajax_footer();
  779. die();
  780. } // End db_repair().
  781. /* php_max_runtime_test()
  782. *
  783. * Tests the ACTUAL PHP maximum runtime of the server by echoing and logging to the status log the seconds elapsed.
  784. *
  785. * @param int $stop_time_limit Time after which the test will stop if it is still running.
  786. * @return null
  787. */
  788. public function php_max_runtime_test() {
  789. $stop_time_limit = 240;
  790. pb_backupbuddy::set_greedy_script_limits(); // Crank it up for the test!
  791. $m = "# Starting BackupBuddy PHP Max Execution Time Tester. Determines what your ACTUAL limit is (usually shorter than the server reports so now you can find out the truth!). Stopping test if it gets to `{$stop_time_limit}` seconds. When your browser stops loading this page then the script has most likely timed out at your actual PHP limit.";
  792. pb_backupbuddy::status( 'details', $m );
  793. echo $m . "<br>\n";
  794. $t = 0; // Time = 0;
  795. while( $t < $stop_time_limit ) {
  796. pb_backupbuddy::status( 'details', 'Max PHP Execution Time Test status: ' . $t );
  797. echo $t . "<br>\n";
  798. sleep( 1 );
  799. flush();
  800. $t++;
  801. }
  802. $m = '# Ending BackupBuddy PHP Max Execution Time The test was stopped as the test time limit of ' . $stop_time_limit . ' seconds.';
  803. pb_backupbuddy::status( 'details', $m );
  804. echo $m . "<br>\n";
  805. die();
  806. } // End php_max_runtime_test().
  807. public function disalert() {
  808. $unique_id = pb_backupbuddy::_POST( 'unique_id' );
  809. pb_backupbuddy::$options['disalerts'][$unique_id] = time();
  810. pb_backupbuddy::save();
  811. die('1');
  812. } // End disalert().
  813. public function importexport_settings() {
  814. pb_backupbuddy::load();
  815. pb_backupbuddy::$ui->ajax_header();
  816. if ( pb_backupbuddy::_POST( 'import_settings' ) != '' ) {
  817. $import = trim( stripslashes( pb_backupbuddy::_POST( 'import_data' ) ) );
  818. $import = base64_decode( $import );
  819. if ( $import === false ) { // decode failed.
  820. pb_backupbuddy::alert( 'Unable to decode settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.' );
  821. } else { // decode success.
  822. if ( ( $import = maybe_unserialize( $import ) ) === false ) { // unserialize fail.
  823. pb_backupbuddy::alert( 'Unable to unserialize settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.' );
  824. } else { // unserialize success.
  825. if ( !isset( $import['data_version'] ) ) { // missing expected content.
  826. pb_backupbuddy::alert( 'Unserialized settings data but it did not contain expected data. Import aborted. Insure that you fully copied the settings and did not change any of the text.' );
  827. } else { // contains expected content.
  828. pb_backupbuddy::$options = $import;
  829. require_once( pb_backupbuddy::plugin_path() . '/controllers/activation.php' ); // Run data migration to upgrade if needed.
  830. pb_backupbuddy::save();
  831. pb_backupbuddy::alert( 'Provided settings successfully imported. Prior settings overwritten.' );
  832. }
  833. }
  834. }
  835. }
  836. echo '<h2>Export BackupBuddy Settings</h2>';
  837. echo 'Copy the encoded plugin settings below and paste it into the destination BackupBuddy Settings Import page.<br><br>';
  838. echo '<textarea style="width: 100%; height: 100px;" wrap="on">';
  839. echo base64_encode( serialize( pb_backupbuddy::$options ) );
  840. echo '</textarea>';
  841. echo '<br><br><br>';
  842. echo '<h2>Import BackupBuddy Settings</h2>';
  843. echo 'Paste encoded plugin settings below to import & replace current settings. If importing settings from an older version and errors are encountered please deactivate and reactivate the plugin.<br><br>';
  844. echo '<form method="post" action="' . pb_backupbuddy::ajax_url( 'importexport_settings' ) . '">';
  845. echo '<textarea style="width: 100%; height: 100px;" wrap="on" name="import_data"></textarea>';
  846. echo '<br><br><input type="submit" name="import_settings" value="Import Settings" class="button button-primary">';
  847. echo '</form>';
  848. pb_backupbuddy::$ui->ajax_footer();
  849. die();
  850. } // End importexport_settings().
  851. /*
  852. public function view_status_log() {
  853. pb_backupbuddy::$ui->ajax_header();
  854. if ( pb_backupbuddy::_GET( 'serial' ) == '' ) {
  855. die( 'Error #85487478555. Missing `serial` parameter.' );
  856. }
  857. $serial = pb_backupbuddy::_GET( 'serial' );
  858. $log_directory = WP_CONTENT_DIR . '/uploads/pb_' . pb_backupbuddy::settings( 'slug' ) . '/';
  859. $serial_file = $log_directory . 'status-' . $serial . '_' . pb_backupbuddy::$options['log_serial'] . '.txt';
  860. if ( ! file_exists( $serial_file ) ) {
  861. die( 'Status log file `' . $serial_file . '` does not exist. It may have already been deleted. If it does exist, verify permissions.' );
  862. }
  863. $status_log = pb_backupbuddy::get_status( $serial, false, false );
  864. echo '<h3>Backup Status Log</h3>';
  865. echo '<textarea style="width: 100%; height: 70%;" wrap="off">';
  866. echo print_r( $status_log, true );
  867. foreach( $status_log as $status_log_line ) {
  868. echo pb_backupbuddy::$format->localize_time( $status_log_line[0] );
  869. echo
  870. }
  871. echo '</textarea><br><br>';
  872. pb_backupbuddy::$ui->ajax_footer();
  873. die();
  874. } // End view_status_log().
  875. */
  876. /* refresh_zip_methods()
  877. *
  878. * Server Info page refreshing available zip methods. Useful since these are normally cached.
  879. *
  880. */
  881. public function refresh_zip_methods() {
  882. delete_transient( 'pb_backupbuddy_avail_zip_methods_classic' );
  883. delete_transient( 'pluginbuddy_backupbuddy_avail_zip_methods' );
  884. if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) {
  885. require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' );
  886. pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( ABSPATH );
  887. }
  888. echo implode( ', ', pb_backupbuddy::$classes['zipbuddy']->_zip_methods );
  889. die();
  890. } // End refresh_zip_methods().
  891. } // end class.
  892. ?>