ECshop校验文件如何生成MD5文件代码

更新时间:2016-07-08 点击量:1447


很多人不明白什么是MD5?MD5中文名是消息摘要算法第五版是计算机安全领域广泛使用的一种函数,用以提供消息的完整性保护。该算法的文件号为RFC。
优易软件现为大家整理ecshop校验文件生成MD5文件的代码。


 

define('ROOT_PATH', str_replace(basename( __FILE__), '', str_replace('\', '/', __FILE__)));
 
ini_set('max_execution_time', '300');
 
checkfiles('./', '.php', 0);
checkfiles('admin/', '.php|.htm|.js|.css|xml');
checkfiles('api/', '.php');
checkfiles('includes/', '.php|.html|.js',1,'fckeditor');    //fck不检查
checkfiles('js/', '.js|.css');
checkfiles('languages/', '.php');
checkfiles('plugins/', '.php');
checkfiles('wap/', '.php|.wml');
/*
checkfiles('themes/default/', '.dwt|.lbi|.css');   //模板
checkfiles('uc_client/', '.php', 0);
checkfiles('uc_client/control/', '.php');
checkfiles('uc_client/model/', '.php');
checkfiles('uc_client/lib/', '.php');
*/
 
file_put_contents('./admin/ecshopfiles.md5',$md5str);   //保存文件校验信息
 
echo "MD5文件生成完成";
 

/**检查文件
* @param  string $currentdir    //待检查目录
* @param  string $ext           //待检查的文件类型
* @param  int    $sub           //是否检查子目录
* @param  string $skip          //不检查的目录或文件
*/
function checkfiles($currentdir, $ext = '', $sub = 1, $skip = '')
{
    global $md5data, $md5str;
    $dir = @opendir(ROOT_PATH.$currentdir);
    $exts = '/('.$ext.')$/i';
    $skips = explode(',', $skip);
 
    while($entry = @readdir($dir))
    {
        $file = $currentdir.$entry;
        if($entry != '.' && $entry != '..' && $entry != '.svn' && (preg_match($exts, $entry) || $sub && is_dir($file)) && !in_array($entry, $skips))
        {
            if($sub && is_dir($file))
            {
                checkfiles($file.'/', $ext, $sub, $skip);
            }
            else
            {
                if($file != './md5.php')
                {
                    $md5data[$file] = md5_file($file);
                    $md5str .= md5_file($file).' *'.$file."rn";
                }
            }
 
        }
 
    }
}


支付宝扫码打赏 微信打赏

如果文章对您有帮助,就打赏一个吧

在线客服

客户服务

热线电话:

13128985956 服务时间:

周一到周六:9:00-18:00

在线QQ客服

在线微信客服

关于我们 常见问题

支付方式 加盟合作

提交需求
优惠红包 购物车0 反馈留言 返回顶部