Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class File {
- /**
- * @param $path
- * @return string
- * calculates the files fast hash
- */
- public function getFhash( $path ){
- $fhash = '';
- //GET SIZE
- $size = $this->getSize( $path );
- if( $size > 150000 ){
- $fhandle = fopen($path, "r+");
- $contents = fread($fhandle, 100000 );
- fclose($fhandle);
- $fhash = hash( 'md5', $contents );
- }
- else{
- $fhash = $this->getMd5( $path );
- }
- $fhash = md5( $fhash . $size );
- return $fhash;
- }
- /**
- * @param $path
- * @return int
- * gets filesize
- */
- public function getSize( $path ){
- $size = filesize( $path );
- if( $size == false ){
- $size = 0;
- }
- return $size;
- }
- /**
- * @param $path
- * @return string
- * calculates the files md5 hash
- */
- public function getMd5( $path ){
- return md5_file( $path );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement