|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZMD5 class 00004 // 00005 // Created on: <04-Feb-2004 22:01:19 kk> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezmd5.php 00032 */ 00033 00034 /*! 00035 \class eZMD5 ezmd5.php 00036 \brief Class handling MD5 file operations 00037 */ 00038 00039 class eZMD5 00040 { 00041 /*! 00042 \static 00043 00044 Check MD5 sum file to check if files have changed. Return array of changed files. 00045 00046 \param file name of md5 check sums 00047 00048 \return array of missmatching files. 00049 */ 00050 static function checkMD5Sums( $file ) 00051 { 00052 //include_once( 'lib/ezfile/classes/ezfile.php' ); 00053 $lines = eZFile::splitLines( $file ); 00054 $result = array(); 00055 00056 if ( is_array( $lines ) ) 00057 { 00058 foreach ( array_keys( $lines ) as $key ) 00059 { 00060 $line =& $lines[$key]; 00061 if ( strlen( $line ) > 34 ) 00062 { 00063 $md5Key = substr( $line, 0, 32 ); 00064 $filename = substr( $line, 34 ); 00065 if ( !file_exists( $filename ) || $md5Key != md5_file( $filename ) ) 00066 { 00067 $result[] = $filename; 00068 } 00069 } 00070 } 00071 } 00072 00073 return $result; 00074 } 00075 } 00076 ?>