Missing ftok() on Windows? Here's my little workaround:
<?php
if( !function_exists('ftok') )
{
function ftok($filename = "", $proj = "")
{
if( empty($filename) || !file_exists($filename) )
{
return -1;
}
else
{
$filename = $filename . (string) $proj;
for($key = array(); sizeof($key) < strlen($filename); $key[] = ord(substr($filename, sizeof($key), 1)));
return dechex(array_sum($key));
}
}
}?>
NOTE: There *may* be duplicate keys, even if probability is low.
The key's were NOT computed like the original UNIX ftok() because i.e. fileinode() is also missing on windows. Normally ftok() computes a key based on the file inode and the system minor id of the harddrive the file resides.
Behaviour is like PHPs ftok(), -1 is returned if file is missing or $filename is empty, computed int as hex on success.
--
Regards,
David Rech