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 / test-ftp.php

test-ftp.php in WP Database Backup – Unlimited Database & Files Backup by Backup for WP 2.1.1, at includes/admin/Destination/FTP/test-ftp.php

77 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 // Direct calls to this file are Forbidden when core files are not present
4 // Thanks to Ed from ait-pro.com for this code
5 // @since 2.1
6
7 if ( !function_exists('add_action') ){
8 header('Status: 403 Forbidden');
9 header('HTTP/1.1 403 Forbidden');
10 exit();
11 }
12
13 if ( !current_user_can('manage_options') ){
14 header('Status: 403 Forbidden');
15 header('HTTP/1.1 403 Forbidden');
16 exit();
17 }
18
19 //
20 //
21
22 function backupbreeze_test_ftp() {
23
24 // now let's see if we can connect to the FTP repo
25 // set up variables
26 $host = get_option('backupbreeze_ftp_host');
27 $user = get_option('backupbreeze_ftp_user');
28 $pass = get_option('backupbreeze_ftp_pass');
29 $subdir = get_option('backupbreeze_ftp_subdir');
30 if ($subdir =='') {
31 $subdir = '/';
32 }
33 $remotefile = $subdir . '/' . $filename;
34
35 // @since 2.0
36 // checking FTP Details
37 // extra security @since 2.1
38 // If in WP Dashboard or Admin Panels
39 if ( is_admin() ) {
40 // If user has WP manage options permissions
41 if ( current_user_can('manage_options')) {
42 // connect to host ONLY if the 2 security conditions are valid / met
43 $conn = ftp_connect($host);
44 }
45 }
46
47 if (!$conn)
48 {
49 $trouble = "I could not connect to your FTP server.<br />Please check your FTP Host and try again.";
50 return $trouble;
51 }
52 // can we log in?
53 $result = ftp_login($conn, $user, $pass);
54 if (!$result) {
55 $trouble = "I could connect to the FTP server but I could not log in.<br />Please check your credentials and try again.";
56 return $trouble;
57 }
58 // and does the remote directory exist?
59 $success = ftp_chdir($conn, $subdir);
60 if (!$success) {
61 $trouble = "I can connect to the FTP server, but I cannot change into the FTP subdirectory you specified. <br />Is the path correct? Does the directory exist? Is it wrritable?<br />Please check using an FTP client like FileZilla.";
62 return $trouble;
63 }
64
65 // and is it writeable?
66
67 // got til here? Wow - everything must be fine then
68 $trouble = 'OK';
69
70 // lose this connection
71 ftp_close($conn);
72 return $trouble;
73
74 } // end of function
75
76
77 ?>