Hash path for a folder in php
#1
Hi,

Maybe it's not the correct place to post.

I need help to know how to calculate the hash of a path of a folder but in php language.

I have understood that the function in CPP is :
Code:
int CVideoInfoScanner::GetPathHash(const CFileItemList &items, CStdString &hash)
  {
    // Create a hash based on the filenames, filesize and filedate.  Also count the number of files
    if (0 == items.Size()) return 0;
    XBMC::XBMC_MD5 md5state;
    int count = 0;
    for (int i = 0; i < items.Size(); ++i)
    {
      const CFileItemPtr pItem = items[i];
      md5state.append(pItem->m_strPath);
      md5state.append((unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
      FILETIME time = pItem->m_dateTime;
      md5state.append((unsigned char *)&time, sizeof(FILETIME));
      if (pItem->IsVideo() && !pItem->IsPlayList() && !pItem->IsNFO())
        count++;
    }
    md5state.getDigest(hash);
    return count;
  }

And I try with :
Code:
$tmp = '';
foreach(glob($path.'/*') as $file)
{
  $tmp .= $file.filesize($file).filemtime($file);
}
$hash = md5($tmp);
Of course hash value in php is incorrect.

Where i have done a mistake ?

Help would be very very appreciated.

Regards
Reply

Logout Mark Read Team Forum Stats Members Help
Hash path for a folder in php0