|go ahead... be a heretic|
Re: Would somebody like to comment this part of (PHP) code?by rruiz (Monk)
|on Aug 21, 2005 at 09:07 UTC||Need Help??|
You almost got it all figured. I think that what you need is to find a way to generate the same MD5 hash in Perl, as the PHP md5() function. And you can do it with the md5_hex() function of the Digest::MD5 module. A simple search on google for "md5 compare Digest::MD5 php perl", will find the PHP Documentation for the md5() function. There is an example of how to do it.
And while you are at google, search also for "oscommerce php home", go to the home page of the osCommerce project, download the source and unpack them so you can easyly find the tep_* functions with winblows exploder find (it seems like a convention on library functions in the osCommerce source, but I don't know if that's it or not). Also you should find more documentation about osCommerce there that may help you in understanding how to interface with it from Perl (or you may not, I have not tried it).
As for the specifics in the code you mention, the tep_validate_password() function is spliting the $encrypted word in the array $stack, to retrieve the salt to encrypt the $plain password passed to it (something easy to overlook because there is no @ in PHP and you are thinking in Perl). So, something like:
Should do the same as the PHP function mentioned. (NOTE: All code is untested)
And for help on what the PHP standard functions do (like explode(), size_of(), and others without tep_), you may consult the PHP site, or some of the many forums out there that deal with that language. Then come back here with more specific Perl questions, ;)
Update: (1) Replaced $encrypted with $stack on last line of sub. (2) Another typo in defined($encrypted).
HTH, God bless you