Update of /cvsroot/easymod/easymod2/mods/easymod/em_includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28517
Modified Files:
em_cipher.php
Log Message:
Make sure the FTP password is stored using ascii chars to avoid problems in certain SQL servers where storing binary data in char files (phpbb_config table is out of scope here) might generate conflicts. This is now achived using plain PHP functions rather than using the UTF8 encoder/decoder, which is part of the XML module and it might not be available on some servers.
Index: em_cipher.php
===================================================================
RCS file: /cvsroot/easymod/easymod2/mods/easymod/em_includes/em_cipher.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** em_cipher.php 2 Nov 2005 09:22:42 -0000 1.5
--- em_cipher.php 4 Nov 2005 22:03:58 -0000 1.6
***************
*** 521,525 ****
class Cipher_BlockMode_cbc
{
!
var $_iv = "\0\0\0\0\0\0\0\0"; // String containing the initilization vector.
var $blowfish; // will contain a blowfish class
--- 521,525 ----
class Cipher_BlockMode_cbc
{
!
var $_iv = "\0\0\0\0\0\0\0\0"; // String containing the initilization vector.
var $blowfish; // will contain a blowfish class
***************
*** 527,531 ****
var $key_set;
-
// constructor
function Cipher_BlockMode_cbc()
--- 527,530 ----
***************
*** 535,544 ****
}
-
// encrypts the text a chunk at a time and then strings them all together and returns the value
function encrypt($plaintext, $key)
{
$this->setkey($key);
!
$encrypted = '';
--- 534,542 ----
}
// encrypts the text a chunk at a time and then strings them all together and returns the value
function encrypt($plaintext, $key)
{
$this->setkey($key);
!
$encrypted = '';
***************
*** 570,583 ****
// all just so the string is formed properly and what actually gets stored in the DB is "single'quote". The
// same is true for any slashes that get added. The slashes won't actually show up when viewing the DB ;-)
-
- // change encoding for storage (postgres problems)
- if( function_exists('utf8_encode') )
- {
- $encrypted = utf8_encode($encrypted);
- }
-
- return $encrypted ;
- }
// decrypts the cipher a chunk at a time and returns the plaintext
--- 568,577 ----
// all just so the string is formed properly and what actually gets stored in the DB is "single'quote". The
// same is true for any slashes that get added. The slashes won't actually show up when viewing the DB ;-)
+ // change encoding for storage (postgres problems with binary string)
+ $encrypted = $this->bin2hex($encrypted);
+
+ return $encrypted;
+ }
// decrypts the cipher a chunk at a time and returns the plaintext
***************
*** 585,594 ****
{
$this->setkey($key);
!
! // decode for use (postgres storage problems)
! if( function_exists('utf8_decode') )
! {
! $ciphertext = utf8_decode($ciphertext);
! }
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
--- 579,585 ----
{
$this->setkey($key);
!
! // decode for use (postgres storage problems with binary string)
! $ciphertext = $this->hex2bin($ciphertext);
// TAKE TWO: the way General Config settings work in phpBB, this isn't sufficient, get rid of the ' all together
***************
*** 623,629 ****
$this->key_set = true;
}
!
return;
}
}
--- 614,640 ----
$this->key_set = true;
}
!
return;
}
+
+ // 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;
+ }
}
|