PluginProbe
WP Database Backup – Unlimited Database & Files Backup by Backup for WP / 2.1.1
WP Database Backup – Unlimited Database & Files Backup by Backup for WP v2.1.1
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 2.1.1, at includes/admin/Destination/FTP/preflight.php

73 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function backupbreeze_preflight_problem($trouble) {
4 echo '<div class="error"><h3>Houston, we have a problem: </h3>' .$trouble . '<br /><br /></div>';
5 echo '<hr><br />';
6
7
8 exit;
9 }
10
11
12
13
14 // now let's see if we can connect to the FTP repo
15 // set up variables
16 $host = get_option('backupbreeze_ftp_host');
17 $user = get_option('backupbreeze_ftp_user');
18 $pass = get_option('backupbreeze_ftp_pass');
19 $subdir = get_option('backupbreeze_ftp_subdir');
20 if ($subdir =='') {
21 $subdir = '/';
22 }
23 $remotefile = $subdir . '/' . $filename;
24
25 // @since 1.6.1
26 // only check FTP Connection if we have details
27 // otherwise skip this and do a local backup
28 //
29
30 if ($host) {
31 // connect to host
32 // extra security
33 // @since 2.1
34 // If in WP Dashboard or Admin Panels
35 if ( is_admin() ) {
36 // If user has WP manage options permissions
37 if ( current_user_can('manage_options')) {
38 // connect to host ONLY if the 2 security conditions are valid / met
39 $conn = ftp_connect($host);
40 if (!$conn)
41 {
42 $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).';
43 backupbreeze_preflight_problem($trouble);
44 }
45 // can we log in?
46 $result = ftp_login($conn, $user, $pass);
47 if (!$result)
48 {
49 $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.';
50 backupbreeze_preflight_problem($trouble);
51 }
52 // and does the remote directory exist?
53 $success = ftp_chdir($conn, $subdir);
54 if (!$success)
55 {
56 $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.';
57 backupbreeze_preflight_problem($trouble);
58 }
59 // and is it writeable?
60 // ah... I don't know how to test that :-(
61
62 // end if
63 }
64 }
65 }
66 else {
67 echo "The FTP Details are missing or not complete. This will be a local backup only.<br />";
68 }
69
70 echo "All good - let's Backup!<br />";
71
72 ?>
73