Permalink
Browse files

Fixes #16849: Drop FTP support.

  • Loading branch information...
vboctor committed Jan 21, 2014
1 parent 0ee5e93 commit 187dbf9d72afbc253bc6dfd97be9e1f68aabcdcd
View
@@ -84,7 +84,6 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
$t_method = config_get( 'file_upload_method' );
switch( $t_method ) {
- case FTP:
case DISK:
if( !file_exists( $t_file_path ) || !is_dir( $t_file_path ) || !is_writable( $t_file_path ) || !is_readable( $t_file_path ) ) {
return SoapObjectsFactory::newSoapFault( 'Server', "Upload folder '{$t_file_path}' doesn't exist.");
@@ -94,16 +93,7 @@ function mci_file_add( $p_id, $p_name, $p_content, $p_file_type, $p_table, $p_ti
if( !file_exists( $t_disk_file_name ) ) {
mci_file_write_local( $t_disk_file_name, $p_content );
-
- if( FTP == $t_method ) {
- $conn_id = file_ftp_connect();
- file_ftp_put( $conn_id, $t_disk_file_name, $t_disk_file_name );
- file_ftp_disconnect( $conn_id );
- file_delete_local( $t_disk_file_name );
- } else {
- chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );
- }
-
+ chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );
$c_content = "''";
}
break;
@@ -224,16 +214,9 @@ function mci_file_get( $p_file_id, $p_type, $p_user_id ) {
} else {
return SoapObjectsFactory::newSoapFault( 'Client', 'Unable to find an attachment with type ' . $p_type. ' and id ' . $p_file_id . ' .' );
}
- case FTP:
- if( file_exists( $t_diskfile ) ) {
- return mci_file_read_local( $t_diskfile );
- } else {
- $ftp = file_ftp_connect();
- file_ftp_get( $ftp, $t_diskfile, $t_diskfile );
- file_ftp_disconnect( $ftp );
- return mci_file_read_local( $t_diskfile );
- }
- default:
+ case DATABASE:
return $t_content;
+ default:
+ trigger_error( ERROR_GENERIC, ERROR );
}
}
View
@@ -1635,13 +1635,13 @@
/**
* Upload destination: specify actual location in project settings
- * DISK, DATABASE, or FTP.
+ * DISK or DATABASE. FTP is now deprecated and will map to DISK.
* @global int $g_file_upload_method
*/
$g_file_upload_method = DATABASE;
/**
- * When using FTP or DISK for storing uploaded files, this setting control
+ * When using DISK for storing uploaded files, this setting control
* the access permissions they will have on the web server: with the default
* value (0400) files will be read-only, and accessible only by the user
* running the apache process (probably "apache" in Linux and "Administrator"
@@ -1652,24 +1652,6 @@
*/
$g_attachments_file_permissions = 0400;
-/**
- * FTP settings, used if $g_file_upload_method = FTP
- * @global string $g_file_upload_ftp_server
- */
-$g_file_upload_ftp_server = 'ftp.myserver.com';
-
-/**
- *
- * @global string $g_file_upload_ftp_user
- */
-$g_file_upload_ftp_user = 'readwriteuser';
-
-/**
- *
- * @global string $g_file_upload_ftp_pass
- */
-$g_file_upload_ftp_pass = 'readwritepass';
-
/**
* Maximum file size that can be uploaded
* Also check your PHP settings (default is usually 2MBs)
@@ -4195,12 +4177,14 @@
'language_auto_map', 'fallback_language', 'login_method', 'plugins_enabled', 'session_handler',
'session_save_path', 'session_validation', 'show_detailed_errors', 'show_queries_count',
'stop_on_errors', 'use_javascript', 'version_suffix', 'custom_strings_file',
- 'file_upload_ftp_server', 'file_upload_ftp_user', 'file_upload_ftp_pass',
'fileinfo_magic_db_file', 'css_include_file', 'css_rtl_include_file', 'meta_include_file',
'file_type_icons', 'path', 'icon_path', 'short_path', 'absolute_path', 'core_path',
'class_path','library_path', 'language_path', 'absolute_path_default_upload_folder',
'ldap_simulation_file_path', 'plugin_path', 'bottom_include_page', 'top_include_page',
'default_home_page', 'logout_redirect_page', 'manual_url', 'logo_url', 'wiki_engine_url',
+
+ // deprecated in 1.3.0dev
+ 'file_upload_ftp_server', 'file_upload_ftp_user', 'file_upload_ftp_pass',
);
/***************
View
@@ -1057,7 +1057,6 @@ function bug_check_workflow( $p_bug_status, $p_wanted_status ) {
/**
* Copy a bug from one project to another. Also make copies of issue notes, attachments, history,
* email notifications etc.
- * @todo Not managed FTP file upload
* @param int $p_bug_id bug id
* @param int $p_target_project_id target project id
* @param bool $p_copy_custom_fields copy custom fields
View
@@ -701,9 +701,6 @@ function config_is_private( $p_config_var ) {
case 'global_settings':
case 'system_font_folder':
case 'phpMailer_method':
- case 'file_upload_ftp_server':
- case 'file_upload_ftp_user':
- case 'file_upload_ftp_pass':
case 'attachments_file_permissions':
case 'file_upload_method':
case 'absolute_path_default_upload_folder':
@@ -729,6 +726,12 @@ function config_is_private( $p_config_var ) {
case 'dot_tool':
case 'neato_tool':
return true;
+
+ // Deprecated in 1.3.0dev
+ case 'file_upload_ftp_server':
+ case 'file_upload_ftp_user':
+ case 'file_upload_ftp_pass':
+ return true;
}
return false;
View
@@ -144,8 +144,8 @@
# file upload methods
define( 'DISK', 1 );
+define( 'FTP', 1 );
define( 'DATABASE', 2 );
-define( 'FTP', 3 );
# show variable values
define( 'BOTH', 0 );
@@ -226,7 +226,7 @@
define( 'ERROR_PROTECTED_ACCOUNT', 12 );
define( 'ERROR_ACCESS_DENIED', 13 );
define( 'ERROR_UPLOAD_FAILURE', 15 );
-define( 'ERROR_FTP_CONNECT_ERROR', 16 );
+define( 'ERROR_FTP_CONNECT_ERROR', 16 ); // deprecated - remove when no longer used in language files.
define( 'ERROR_HANDLER_ACCESS_TOO_LOW', 17 );
define( 'ERROR_PAGE_REDIRECTION', 18 );
define( 'ERROR_INVALID_REQUEST_METHOD', 19 );
View
@@ -382,27 +382,13 @@ function file_delete_attachments( $p_bug_id ) {
return true;
}
- if(( DISK == $t_method ) || ( FTP == $t_method ) ) {
-
- # there may be more than one file
- $ftp = 0;
- if( FTP == $t_method ) {
- $ftp = file_ftp_connect();
- }
+ if ( DISK == $t_method ) {
for( $i = 0;$i < $file_count;$i++ ) {
$row = db_fetch_array( $result );
$t_local_diskfile = file_normalize_attachment_path( $row['diskfile'], bug_get_field( $p_bug_id, 'project_id' ) );
file_delete_local( $t_local_diskfile );
-
- if( FTP == $t_method ) {
- file_ftp_delete( $ftp, $row['diskfile'] );
- }
- }
-
- if( FTP == $t_method ) {
- file_ftp_disconnect( $ftp );
}
}
@@ -423,9 +409,8 @@ function file_delete_project_files( $p_project_id ) {
$t_project_file_table = db_get_table( 'project_file' );
$t_method = config_get( 'file_upload_method' );
- # Delete the file physically (if stored via DISK or FTP)
- if(( DISK == $t_method ) || ( FTP == $t_method ) ) {
-
+ # Delete the file physically (if stored via DISK)
+ if ( DISK == $t_method ) {
# Delete files from disk
$query = "SELECT diskfile, filename
FROM $t_project_file_table
@@ -434,24 +419,11 @@ function file_delete_project_files( $p_project_id ) {
$file_count = db_num_rows( $result );
- $ftp = 0;
- if( FTP == $t_method ) {
- $ftp = file_ftp_connect();
- }
-
for( $i = 0;$i < $file_count;$i++ ) {
$row = db_fetch_array( $result );
$t_local_diskfile = file_normalize_attachment_path( $row['diskfile'], $p_project_id );
file_delete_local( $t_local_diskfile );
-
- if( FTP == $t_method ) {
- file_ftp_delete( $ftp, $row['diskfile'] );
- }
- }
-
- if( FTP == $t_method ) {
- file_ftp_disconnect( $ftp );
}
}
@@ -461,66 +433,6 @@ function file_delete_project_files( $p_project_id ) {
$result = db_query_bound( $query, array( (int) $p_project_id ) );
}
-/**
- * Delete all cached files that are older than configured number of days.
- */
-function file_ftp_cache_cleanup() {
-}
-
-/**
- * Connect to ftp server using configured server address, user name, and password.
- * @return int
- */
-function file_ftp_connect() {
- $conn_id = ftp_connect( config_get( 'file_upload_ftp_server' ) );
- $login_result = ftp_login( $conn_id, config_get( 'file_upload_ftp_user' ), config_get( 'file_upload_ftp_pass' ) );
-
- if(( !$conn_id ) || ( !$login_result ) ) {
- trigger_error( ERROR_FTP_CONNECT_ERROR, ERROR );
- }
-
- return $conn_id;
-}
-
-/**
- * Put a file to the ftp server.
- * @param int $p_conn_id Resource id
- * @param string $p_remote_filename remote filename
- * @param string $p_local_filename local filename
- */
-function file_ftp_put( $p_conn_id, $p_remote_filename, $p_local_filename ) {
- helper_begin_long_process();
- $upload = ftp_put( $p_conn_id, $p_remote_filename, $p_local_filename, FTP_BINARY );
-}
-
-/**
- * Get a file from the ftp server.
- * @param int $p_conn_id Resource id
- * @param string $p_local_filename local filename
- * @param string $p_remote_filename remote filename
- */
-function file_ftp_get( $p_conn_id, $p_local_filename, $p_remote_filename ) {
- helper_begin_long_process();
- $download = ftp_get( $p_conn_id, $p_local_filename, $p_remote_filename, FTP_BINARY );
-}
-
-/**
- * Delete a file from the ftp server
- * @param int $p_conn_id Resource id
- * @param string $p_filename filename
- */
-function file_ftp_delete( $p_conn_id, $p_filename ) {
- @ftp_delete( $p_conn_id, $p_filename );
-}
-
-/**
- * Disconnect from the ftp server
- * @param int $p_conn_id Resource id
- */
-function file_ftp_disconnect( $p_conn_id ) {
- ftp_quit( $p_conn_id );
-}
-
/**
* Delete a local file even if it is read-only.
* @param string $p_filename
@@ -571,13 +483,7 @@ function file_delete( $p_file_id, $p_table = 'bug' ) {
$t_project_id = file_get_field( $p_file_id, 'project_id', $p_table );
}
- if(( DISK == $t_upload_method ) || ( FTP == $t_upload_method ) ) {
- if( FTP == $t_upload_method ) {
- $ftp = file_ftp_connect();
- file_ftp_delete( $ftp, $t_diskfile );
- file_ftp_disconnect( $ftp );
- }
-
+ if ( DISK == $t_upload_method ) {
$t_local_disk_file = file_normalize_attachment_path( $t_diskfile, $t_project_id );
if ( file_exists( $t_local_disk_file ) ) {
file_delete_local( $t_local_disk_file );
@@ -794,17 +700,10 @@ function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc
$t_method = config_get( 'file_upload_method' );
switch( $t_method ) {
- case FTP:
case DISK:
file_ensure_valid_upload_path( $t_file_path );
if( !file_exists( $t_disk_file_name ) ) {
- if( FTP == $t_method ) {
- $conn_id = file_ftp_connect();
- file_ftp_put( $conn_id, $t_disk_file_name, $t_tmp_file );
- file_ftp_disconnect( $conn_id );
- }
-
if( !move_uploaded_file( $t_tmp_file, $t_disk_file_name ) ) {
trigger_error( ERROR_FILE_MOVE_FAILED, ERROR );
}
@@ -1060,25 +959,7 @@ function file_get_content( $p_file_id, $p_type = 'bug' ) {
}
return false;
break;
- case FTP:
- $t_local_disk_file = file_normalize_attachment_path( $row['diskfile'], $t_project_id );
-
- if ( !file_exists( $t_local_disk_file ) ) {
- $ftp = file_ftp_connect();
- file_ftp_get ( $ftp, $t_local_disk_file, $row['diskfile'] );
- file_ftp_disconnect( $ftp );
- }
-
- if ( $finfo_available ) {
- $t_file_info_type = $finfo->file( $t_local_disk_file );
-
- if ( $t_file_info_type !== false ) {
- $t_content_type = $t_file_info_type;
- }
- }
- return array( 'type' => $t_content_type, 'content' => file_get_contents( $t_local_disk_file ) );
- break;
- default:
+ case DATABASE:
if ( $finfo_available ) {
$t_file_info_type = $finfo->buffer( $row['content'] );
@@ -1088,6 +969,8 @@ function file_get_content( $p_file_id, $p_type = 'bug' ) {
}
return array( 'type' => $t_content_type, 'content' => $row['content'] );
break;
+ default:
+ trigger_error( ERROR_GENERIC, ERROR );
}
}
View
@@ -168,3 +168,7 @@
config_obsolete( 'page_title', 'top_include_page' );
config_obsolete( 'limit_email_domain', 'limit_email_domains' );
config_obsolete( 'show_avatar_threshold' );
+config_obsolete( 'file_upload_ftp_server' );
+config_obsolete( 'file_upload_ftp_user' );
+config_obsolete( 'file_upload_ftp_pass' );
+
Oops, something went wrong.

0 comments on commit 187dbf9

Please sign in to comment.