Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
HeadStand Posted August 10, 2017 Posted August 10, 2017 I had this code in 4.1 that worked perfectly: $form->add( new \IPS\Helpers\Form\Ftp( 'directory_ftp', $this->ftp, true, array( 'validate' => false ), function( $val ){ if( empty( $val ) ) { $val = \IPS\Request::i()->directory_ftp; } $conn_id = ftp_connect( $val['server'], $val['port'] ); $login_result = ftp_login( $conn_id, $val['un'], $val['pw'] ); if( !$conn_id || !$login_result ) { throw new \InvalidArgumentException( 'FTP Connection Failed' ); } ftp_pasv( $conn_id, true ); if( !ftp_chdir( $conn_id, $val['path'] ) ) { throw new \InvalidArgumentException( 'Could not change directory' ); } ftp_close( $conn_id ); } ) ); This is completely broken in 4.2. I needed to use a custom validation function because the standard FTP connection didn't work correctly for this particular server. All good. However, now I see that the value passed in to the custom validation function has pw set to '*******'. I am playing around with \IPS\Text\Encrypt and I cannot get the password out if you held a gun to my head. Anyone have any suggestions?
newbie LAC Posted August 11, 2017 Posted August 11, 2017 $ftpData = $this->ftp; $form->add( new \IPS\Helpers\Form\Ftp( 'directory_ftp', $this->ftp, true, array( 'validate' => false ), function( $val ) use($ftpData) { if( empty( $val ) ) { $val = \IPS\Request::i()->directory_ftp; } if ($val['pw'] === '********') { $val['pw'] = $ftpData['pw']; } $conn_id = ftp_connect( $val['server'], $val['port'] ); $login_result = ftp_login( $conn_id, $val['un'], $val['pw'] ); if( !$conn_id || !$login_result ) { throw new \InvalidArgumentException( 'FTP Connection Failed' ); } ftp_pasv( $conn_id, true ); if( !ftp_chdir( $conn_id, $val['path'] ) ) { throw new \InvalidArgumentException( 'Could not change directory' ); } ftp_close( $conn_id ); } ) );
Recommended Posts
Archived
This topic is now archived and is closed to further replies.