Bug or not ? (mantis 1.06 or 1.1)

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Bug or not ? (mantis 1.06 or 1.1)

Post by Cakeman »

Hello,

I have found a bug I think concerning the file upload with FTP. The code is:

Code: Select all

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, $p_tmp_file );
						file_ftp_disconnect ( $conn_id );
					}

					if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
					    trigger_error( FILE_MOVE_FAILED, ERROR );
					}
					chmod( $t_disk_file_name, 0400 );

					$c_content = '';
				} else {
					trigger_error( ERROR_FILE_DUPLICATE, ERROR );
				}
				break;
But it does not work on php on IIS. Indeed, you put the file on the FTP serveur with:

Code: Select all

if ( FTP == $t_method ) {
						$conn_id = file_ftp_connect();
						file_ftp_put ( $conn_id, $t_disk_file_name, $p_tmp_file );
And after, you try to move the file with:

Code: Select all

if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
					    trigger_error( FILE_MOVE_FAILED, ERROR );
					}
It is not logical because $t_disk_file_name is the name on the FTP serveur and not the webserveur !!!
It doesnot matter with apache (no error) but not with IIS. Moreover the function chmod is dangerous.

I make a little correction:

Code: Select all

switch ( $t_method ) {
			case FTP: 
                                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, $p_tmp_file );
						file_ftp_disconnect ( $conn_id );
					}
				} else {
					trigger_error( ERROR_FILE_DUPLICATE, ERROR );
				}
				break;
			case DISK:
				file_ensure_valid_upload_path( $t_file_path );

				if ( !file_exists( $t_disk_file_name ) ) {
					if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {echo $p_tmp_file.'!!!'. $t_disk_file_name ;
					    trigger_error( FILE_MOVE_FAILED, ERROR );
					}
					chmod( $t_disk_file_name, 0400 );

					$c_content = '';
				} else {
					trigger_error( ERROR_FILE_DUPLICATE, ERROR );
				}
				break;
It works very well.
Only one problem: There is no cache with file uploaded on the webserveur. But I think it is normal because FTP method allows us to have the file on an other server.

cheers
Last edited by Cakeman on 15 Dec 2006, 15:07, edited 1 time in total.
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Post by Cakeman »

Another problem:

Code: Select all

	file_ftp_get ( $ftp, $v_diskfile, $v_diskfile );
It can not work in my case. FTP server is not the same than web serveur


I change this

Code: Select all

$ftp = file_ftp_connect();
file_ftp_get ( $ftp, $v_diskfile, $v_diskfile ); 
file_ftp_disconnect( $ftp );
readfile( $v_filename ); 
into this

Code: Select all

$ftp = file_ftp_connect();
file_ftp_get ( $ftp, $v_filename, $v_diskfile );
file_ftp_disconnect( $ftp );
readfile( $v_filename ); 
unlink ( $v_filename ); 
No more cache
Last edited by Cakeman on 15 Dec 2006, 17:01, edited 2 times in total.
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Post by Cakeman »

In the FTP method, $g_absolute_path_default_upload_folder seems to represent the path on the ftp serveur and not on the web server
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Post by Cakeman »

May I have an answer ?

Because I see the bug I report about it is deleted :)

(sorry the bug was reported twice)
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Post by Cakeman »

up ?
Cakeman
Posts: 7
Joined: 15 Dec 2006, 11:09

Post by Cakeman »

I found an other problem with my method FTP: the file_path of a project.
In fact the path is a path on the FTP serveur and not on the web serveur.

The function file_ensure_valid_upload_path must verify the path on the FTP serveur and not on the web server.
Post Reply