[FIX] FTP ERROR: login failed

Want to share what MODs you've gotten to work with EM? Happy about all the time your're saving? Want to say "thanks"? Here's the place.
Forum rules
DO NOT give out any FTP passwords to anyone! There is no reason to do so! If you need help badly enough, create a temporary FTP account that is restricted to only the files that you need help with and give the information for that. Giving out FTP information can be very dangerous!
Locked
User avatar
Nux
Registered User
Posts: 943
Joined: Tue Jun 14, 2005 5:09 pm
Location: 3cities, Poland
Contact:

[FIX] FTP ERROR: login failed

Post by Nux »

This shouldn't be needed any more - it has been fixed in the latest EM:
viewtopic.php?p=127968#127968


If you've got the above error then this should help you:
(it should also help when EM suddenly stops during the installation)

Code: Select all

#
#-----[ OPEN ]---------------------------------------------
#
# NOTE! If you already installed EM then you need to change the file&#58
# admin/em_includes/em_cipher.php
#
# NOTE! If you want to (re)install then change the file&#58
# admin/mods/easymod/em_includes/em_cipher.php
#
admin/mods/easymod/em_includes/em_cipher.php

#
#-----[ FIND ]---------------------------------------------
#
$encrypted = addslashes( $encrypted) ;
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// $encrypted = addslashes( $encrypted) ;

#
#-----[ FIND ]---------------------------------------------
#
$encrypted = str_replace( "\'", "NUTTICK", $encrypted) ;
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// $encrypted = str_replace( "\'", "NUTTICK", $encrypted) ;

#
#-----[ FIND ]---------------------------------------------
#
$encrypted  = utf8_encode($encrypted);
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// $encrypted  = utf8_encode($encrypted);
$encrypted  = urlencode($encrypted);

#
#-----[ FIND ]---------------------------------------------
#
$ciphertext = utf8_decode($ciphertext);
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// $ciphertext = utf8_decode($ciphertext);
$ciphertext = urldecode($ciphertext);

#
#-----[ FIND ]---------------------------------------------
#
$ciphertext = str_replace( 'NUTTICK', "'", $ciphertext) ;
#
#-----[ REPLACE WITH ]---------------------------------------------
#
// $ciphertext = str_replace( 'NUTTICK', "'", $ciphertext) ;
Important: After you apply this fix you need to set the EM and FTP pass again in the settings of EM (or reinstall EM).
Last edited by Nux on Fri Nov 11, 2005 1:56 pm, edited 3 times in total.

User avatar
Nux
Registered User
Posts: 943
Joined: Tue Jun 14, 2005 5:09 pm
Location: 3cities, Poland
Contact:

Re: [FIX] FTP ERROR: login failed

Post by Nux »

The above error occured because of:
  1. Unsymmetric changes that were done to prevent illegal characters from occuring (for writting in the DB).
  2. Using utf8_encode (decode) was not enough to prevent all illegal characters from occuring.
This is not the best of fixes that could be done, because it makes the string very long. But I think it's the most universal and easy solution.

If someone have any information that '%' sign is an illegal character on any SQL database supported by phpBB, then please report here.

matthat
Registered User
Posts: 21
Joined: Fri Oct 21, 2005 10:46 am

Re: [FIX] FTP ERROR: login failed

Post by matthat »

instructions followed but it still seems to be broken (installed JuniorZ's plugin too if that makes a dif...) what have I done wrong?
helphelphelphelp (( viewtopic.php?f=21&t=21131 )) ...

Install Zarath's shop with EM: viewtopic.php?f=21&t=21120&p=127065#127065

User avatar
Nux
Registered User
Posts: 943
Joined: Tue Jun 14, 2005 5:09 pm
Location: 3cities, Poland
Contact:

Re: [FIX] FTP ERROR: login failed

Post by Nux »

I finally figured that maybe you didn't set the EM and FTP pass again in the settings of EM (reinstallation of EM should also work).

markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: [FIX] FTP ERROR: login failed

Post by markus_petrux »

I believe that if you update the EM password but leave the FTP empty, it gets corrupted in the DB so it causes some of these FTP login failed issues. Can anyone confirm?

User avatar
Nux
Registered User
Posts: 943
Joined: Tue Jun 14, 2005 5:09 pm
Location: 3cities, Poland
Contact:

Re: [FIX] FTP ERROR: login failed

Post by Nux »

Yes, that is correct.

markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: [FIX] FTP ERROR: login failed

Post by markus_petrux »

Thanks

The workaround, at least for now, is enter the FTP password along the EM passwords, always.

Fix commited to CVS ;)

PS: Those UTF8 functions won't be used either, still something is needed to avoid conflicts storing binary data (the encrypted FTP password) into the database (it goes to the phpbb_config table, which is a simpe varchar), so your fix posted above, Nux, might not work on all scenarios. A different method will be used to convert the binary data into an hexadecimal string.

User avatar
Nux
Registered User
Posts: 943
Joined: Tue Jun 14, 2005 5:09 pm
Location: 3cities, Poland
Contact:

Re: [FIX] FTP ERROR: login failed

Post by Nux »

markus_petrux wrote: your fix posted above, Nux, might not work on all scenarios
Name one :twisted: ;-). AFAIK urlencode codes even more then needed. It will of course make the string very long, but the original pass would have to be more then 80 characters long (255/3=85).
markus_petrux wrote: A different method will be used to convert the binary data into an hexadecimal string.
I've tested this encrypting algorithm and (if I remember correctly) most of the chars in the encrypted text are above or below "normal" characters, so any prefixing coding wouldn't be a good idea (though I don't know what did you planned). Simply coding all the bytes to hexadecimal would be a good idea (IMHO) it would still leave more then 120 chars for the pass...

I don't really remember if my calculations about the length of FTP pass are correct (I remember that there are some characters added to the string and I don't remember if Blowfish splits characters to more then on byte).


I need to get some sleep now :-).
Cheers.

markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: [FIX] FTP ERROR: login failed

Post by markus_petrux »

The extra characters have been removed and I'm using this to convert bin2hex/hex2bin:

Code: Select all

// convert a binary string into an hexadecimal string
function bin2hex($bin)
{
	for( $hex = '', $i = 0, $length = strlen($bin); $i < $length; $i++ )
	{
		$hex .= substr('0' . dechex(ord($bin[$i])), -2);
	}
	return $hex;
}

// convert an hexadecimal string into a binary string
function hex2bin($hex)
{
	for( $bin = '', $i = 0, $length = strlen($hex); $i < $length; $i=$i+2 )
	{
		$bin .= chr(hexdec(substr($hex, $i, 2)));
	}
	return $bin;
}
More or less... each byte will need 2 characters in the DB (we save the percent signs added by urlencode), the config_value field is varchar(255), I guess it will be able to hold the average password. :)

Locked