PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 6.11
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v6.11
7.13 7.12 trunk 1.1 2.1.1 5.9 6.0 6.1 6.10 6.11 6.12 6.12.1 6.2 6.3 6.4 6.5 6.5.1 6.6 6.7 6.8 6.9 7.0 7.0.1 7.1 7.10 All 34 releases
wp-database-backup / includes / admin / Destination / FTP / preflight.php

preflight.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 6.11, at includes/admin/Destination/FTP/preflight.php

54 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Destination file.
4 *
5 * @package wpdbbkp
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Error checking.
14 *
15 * @param string $trouble - Trouble response.
16 */
17 function backupbreeze_preflight_problem( $trouble ) {
18 $error_log = $trouble;
19 }
20
21 // set up variables.
22 $host = get_option( 'backupbreeze_ftp_host' );
23 $user = get_option( 'backupbreeze_ftp_user' );
24 $pass = get_option( 'backupbreeze_ftp_pass' );
25 $subdir = get_option( 'backupbreeze_ftp_subdir' );
26 if ( '' === $subdir ) {
27 $subdir = '/';
28 }
29
30 if ( $host ) {
31 // If in WP Dashboard or Admin Panels.
32 if ( is_admin() ) {
33 // If user has WP manage options permissions.
34 if ( current_user_can( 'manage_options' ) ) {
35 // Connect to host ONLY if the 2 security conditions are valid / met.
36 $conn = ftp_connect( $host );
37 if ( ! $conn ) {
38 $trouble = 'I could not connect to your FTP server.<br />Please check your FTP Host settings and try again (leave FTP Host BLANK for local backups).';
39 backupbreeze_preflight_problem( $trouble );
40 }
41 $result = ftp_login( $conn, $user, $pass );
42 if ( ! $result ) {
43 $trouble = 'I could not log in to your FTP server.<br />Please check your FTP Username and Password, then try again.<br />For local backups, please leave the FTP Host option BLANK.';
44 backupbreeze_preflight_problem( $trouble );
45 }
46 $success = ftp_chdir( $conn, $subdir );
47 if ( ! $success ) {
48 $trouble = 'I cannot change into the FTP subdirectory you specified. Does it exist?<br />You must create it first using an FTP client like FileZilla.<br />Please check and try again.';
49 backupbreeze_preflight_problem( $trouble );
50 }
51 }
52 }
53 }
54