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 / sendaway.php

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

86 lines 2.4 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 // doesn't work when file is included by script :-(
7 /*
8 if ( !function_exists('add_action') ){
9 header('Status: 403 Forbidden');
10 header('HTTP/1.1 403 Forbidden');
11 exit();
12 }
13
14 if ( !current_user_can('manage_options') ){
15 header('Status: 403 Forbidden');
16 header('HTTP/1.1 403 Forbidden');
17 exit();
18 }
19 */
20 //
21 //
22 echo "<h2>Send package to FTP site</h2>";
23
24 // set up variables
25 $host = get_option('backupbreeze_ftp_host');
26 $user = get_option('backupbreeze_ftp_user');
27 $pass = get_option('backupbreeze_ftp_pass');
28 $subdir = get_option('backupbreeze_ftp_subdir');
29 $wp_upload_dir = wp_upload_dir();
30
31 $wp_upload_dir['basedir'] = str_replace('\\', '/', $wp_upload_dir['basedir']);
32 $remotefile = $subdir.'/'.$filename;
33 $localfile = trailingslashit($wp_upload_dir['basedir'].'/db-backup'). $filename;
34
35 // see if port option is blank and set it to 21 if it isn't
36 if (!get_option('backupbreeze_ftp_port')) {
37 $port == '21';
38 } else {
39 $port = get_option('backupbreeze_ftp_port');
40 }
41 // extra security
42 // @since 2.1
43 // doesn't work when file is included by script :-(
44 // If in WP Dashboard or Admin Panels
45 // if ( is_admin() ) {
46 // If user has WP manage options permissions
47 // if ( current_user_can('manage_options')) {
48 // connect to host ONLY if the 2 security conditions are valid / met
49 $conn = ftp_connect($host,$port);
50 // }
51 // }
52
53 // @since 1.6
54 // new passive FTP connection to avoid timeouts
55 // thanks to Kara for this code ;-)
56
57 if (!$conn) {
58 echo '<div class="error">Could not connect to ftp server. This will be local backup.<br /></div>';
59 }
60 else {
61 echo "Connected to $host.<br />";
62 // log in to host
63 $result = @ftp_login($conn, $user, $pass);
64 if (!$result) {
65 echo '<div class="error">Could not log on as $user. This will be local backup.<br /></div>';
66 }
67 else {
68 echo '<div class="error">Logged in as $user<br /></div>';
69 // Switch to passive mode
70 ftp_pasv($conn, true);
71 // upload file
72 echo '<div class="error">Uploading package to FTP repository...<br /></div>';
73 if (!$success = ftp_put($conn, $remotefile, $localfile, FTP_BINARY)) {
74 echo '<div class="error">Error: Could not upload file. This will be local backup.<br /></div>';
75 }
76 else {
77 echo '<div class="error">File was uploaded successfully <br /></div>';
78 }
79 }
80 }
81 // close connection to host
82 ftp_quit($conn);
83
84 // echo "... Done!";
85
86 ?>