hello--please help function hash_file ($strFilename) is now broken in

hello--please help function hash_file ($strFilename) is now broken in

am 02.01.2008 22:18:49 von opensourcearts

hello there,

hash_file means something new in php5, and it seems to of broken my
code:

function hash_file ($strFilename) {
$n = 0;
for ($posFilename = strlen($strFilename) -1; $posFilename >= 0;
$posFilename-- ) {
$n *= 2;
if ($n & 4096) { $n |= 1; }
$n ^= (ord($strFilename[$posFilename])*11);
$n &= 4095;
}

return sprintf ("%02o/%02o", ($n/64) & 63 , $n&63);
}

For now, the error that I get with the above code is just:


PHP Fatal error: Cannot redeclare hash_file()

Is there some way to rewrite the above code, or something to
substitute for hash_file? Thanks!

The original coder also wrote this comment with the code:

// Don't even ask me how this works. Apparently it creates a
register for the filenme
// by xoring the characters into a number from right to left. The
top six bits and the
// bottom six bits are returned as the path name. I didn't write it
though, I just
// converted it from a perl function that I found in the pair
Networks private newsgroups.
// - Jason

Thanks for your help!

Re: hello--please help function hash_file ($strFilename) is now

am 03.01.2008 00:23:08 von nc

On Jan 2, 1:18 pm, opensourcea...@gmail.com wrote:
>
> hash_file means something new in php5,

Er, no. Effective PHP 5.1.2, there is a built-in function
hash_file():

http://www.php.net/hash_file

> For now, the error that I get with the above code is just:
>
> PHP Fatal error: Cannot redeclare hash_file()

And you should, as you cannot define a function that already exists.

> Is there some way to rewrite the above code

Why bother? Just use the built-in hash_file() function. To see which
hashing algorithms are supported on your system, call hash_algos():

http://www.php.net/hash_algos

Cheers,
NC

Re: hello--please help function hash_file ($strFilename) is now

am 03.01.2008 05:18:47 von opensourcearts

On Jan 2, 3:23=A0pm, NC wrote:
> On Jan 2, 1:18 pm, opensourcea...@gmail.com wrote:
>
>
>
> > hash_file means something new in php5,
>
> Er, no. =A0Effective PHP 5.1.2, there is a built-in function
> hash_file():
>
> http://www.php.net/hash_file
>
> > For now, the error that I get with the above code is just:
>
> > PHP Fatal error: =A0Cannot redeclare hash_file()
>
> And you should, as you cannot define a function that already exists.
>
> > Is there some way to rewrite the above code
>
> Why bother? =A0Just use the built-in hash_file() function. =A0To see which=

> hashing algorithms are supported on your system, call hash_algos():
>
> http://www.php.net/hash_algos
>
> Cheers,
> NC

Hello there and thanks,

But I am still at a loss as to what to do.

hash_file served a purpose in the php4 code below, but now it is an
official function in php5, so the below code no longer works. any
help owuld be great!

function hash_file ($strFilename) {
$n =3D 0;
for ($posFilename =3D strlen($strFilename) -1; $posFilename >=3D 0;
$posFilename-- ) {
$n *=3D 2;
if ($n & 4096) { $n |=3D 1; }
$n ^=3D (ord($strFilename[$posFilename])*11);
$n &=3D 4095;
}
return sprintf ("%02o/%02o", ($n/64) & 63 , $n&63);
}


For now, the error that I get with the above code is just:

PHP Fatal error: Cannot redeclare hash_file()

Is there some way to rewrite the above code, or something to
substitute for hash_file? Thanks!

Any insight would be great! I'd be willing to paypal someone. :)

How would your rewrite the above code?

Thanks!

Re: hello--please help function hash_file ($strFilename) is now broken in php5

am 03.01.2008 05:45:23 von Jerry Stuckle

opensourcearts@gmail.com wrote:
> On Jan 2, 3:23 pm, NC wrote:
>> On Jan 2, 1:18 pm, opensourcea...@gmail.com wrote:
>>
>>
>>
>>> hash_file means something new in php5,
>> Er, no. Effective PHP 5.1.2, there is a built-in function
>> hash_file():
>>
>> http://www.php.net/hash_file
>>
>>> For now, the error that I get with the above code is just:
>>> PHP Fatal error: Cannot redeclare hash_file()
>> And you should, as you cannot define a function that already exists.
>>
>>> Is there some way to rewrite the above code
>> Why bother? Just use the built-in hash_file() function. To see which
>> hashing algorithms are supported on your system, call hash_algos():
>>
>> http://www.php.net/hash_algos
>>
>> Cheers,
>> NC
>
> Hello there and thanks,
>
> But I am still at a loss as to what to do.
>
> hash_file served a purpose in the php4 code below, but now it is an
> official function in php5, so the below code no longer works. any
> help owuld be great!
>
> function hash_file ($strFilename) {
> $n = 0;
> for ($posFilename = strlen($strFilename) -1; $posFilename >= 0;
> $posFilename-- ) {
> $n *= 2;
> if ($n & 4096) { $n |= 1; }
> $n ^= (ord($strFilename[$posFilename])*11);
> $n &= 4095;
> }
> return sprintf ("%02o/%02o", ($n/64) & 63 , $n&63);
> }
>
>
> For now, the error that I get with the above code is just:
>
> PHP Fatal error: Cannot redeclare hash_file()
>
> Is there some way to rewrite the above code, or something to
> substitute for hash_file? Thanks!
>
> Any insight would be great! I'd be willing to paypal someone. :)
>
> How would your rewrite the above code?
>
> Thanks!
>

Just change the function name - both in the function itself and the
places you call it, i.e. my_hash_file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================