techcode has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Would somebody like to comment this part of (PHP) code?
by rnahi (Curate) on Aug 20, 2005 at 05:19 UTC
    And I search, tried even (Windows) search files option

    Go back to Google, and search for ctags.

    With ctags, you can have cross-indexing of your source files identifiers (functions, variables, etc) in 33 different languages (including Perl and PHP). Using that, you can get a function within your editor (provided that your editor is a serious one, such as emacs or vim. Forget Notepad) using just a few keystrokes.

    Oh, and, BTW, did you notice that this is a Perl forum?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Would somebody like to comment this part of (PHP) code?
by castaway (Parson) on Aug 20, 2005 at 06:04 UTC
    Is there an actual question involving Perl in this somewhere?

    C.

Re: Would somebody like to comment this part of (PHP) code?
by rruiz (Monk) on Aug 21, 2005 at 09:07 UTC

    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:

    use Digest::MD5 qw(md5_hex); sub tep_perl_validate_password { my ($plain, $encrypted) = @_; return 0 unless defined($plain) && defined($encrypted); my @stack = split ':', $encrypted; return 0 if(scalar(@stack) != 2); return md5_hex( $stack[1] . $plain ) eq $stack[0]; }

    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[0] on last line of sub. (2) Another typo in defined($encrypted).

    HTH, God bless you
    rruiz