<span style="COLOR: #000000"><span style="COLOR: #0000bb"></span><span style="COLOR: #007700"><?</SPAN><SPAN style="COLOR: #0000bb"><U><FONT color=#336699>php</FONT></U><BR></SPAN><SPAN style="COLOR: #ff8000">/******************************************************************<BR>Check MD5(md5sum for <U><FONT color=#336699>php</FONT></U>)<BR>2008-11-09<BR>amxku.net<BR><BR><BR>校验文件的准确性.<BR>在网站被入侵后,检查文件的准确性。<BR><BR><BR>*UIX下可以用md5sum * >md5sum 来得到所有文件的md5值,然后把两次得到的<br>MD5值来进行对比。<br><br><br>在<u><font color="#336699">代码</font></u>检查方面那么有一丁点用处,别的没什么用。<br>******************************************************************/<br></span><span style="COLOR: #007700">echo </span><span style="COLOR: #dd0000"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></span><span style="COLOR: #007700">;<br>echo </span><span style="COLOR: #dd0000"><title>Check MD5(md5sum for <u><font color="#336699">php</font></u>)</title></span><span style="COLOR: #007700">;<br></span><span style="COLOR: #0000bb">check_md5</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"."</span><span style="COLOR: #007700">);<br><br><br>function </span><span style="COLOR: #0000bb">check_md5</span><span style="COLOR: #007700">(</span><span style="COLOR: #0000bb">$directory</span><span style="COLOR: #007700">){<br> </span><span style="COLOR: #0000bb">$check_md5_dir </span><span style="COLOR: #007700">= @</span><span style="COLOR: #0000bb">opendir</span><span style="COLOR: #007700">(</span><span style="COLOR: #0000bb">$directory</span><span style="COLOR: #007700">);<br> echo </span><span style="COLOR: #dd0000"><ul></span><span style="COLOR: #007700">;<br> while (</span><span style="COLOR: #0000bb">$file </span><span style="COLOR: #007700">= @</span><span style="COLOR: #0000bb">readdir</span><span style="COLOR: #007700">(</span><span style="COLOR: #0000bb">$check_md5_dir</span><span style="COLOR: #007700">)) {<br> if (</span><span style="COLOR: #0000bb">$file </span><span style="COLOR: #007700">!= </span><span style="COLOR: #dd0000">"." </span><span style="COLOR: #007700">&& </span><span style="COLOR: #0000bb">$file </span><span style="COLOR: #007700">!= </span><span style="COLOR: #dd0000">".."</span><span style="COLOR: #007700">) {<br> if(</span><span style="COLOR: #0000bb">is_dir</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"$directory/$file"</span><span style="COLOR: #007700">)){<br> echo </span><span style="COLOR: #dd0000"><li><strong></span><span style="COLOR: #007700">.</span><span style="COLOR: #0000bb">$file</span><span style="COLOR: #007700">.</span><span style="COLOR: #dd0000"></strong></li></span><span style="COLOR: #007700">;<br> </span><span style="COLOR: #0000bb">tree</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"$directory/$file"</span><span style="COLOR: #007700">);<br> }else{<br> echo </span><span style="COLOR: #dd0000"><li></span><span style="COLOR: #007700">.</span><span style="COLOR: #0000bb">$file</span><span style="COLOR: #007700">.</span><span style="COLOR: #dd0000"> ==> </span><span style="COLOR: #007700">.</span><span style="COLOR: #0000bb">md5_file</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"$directory/$file"</span><span style="COLOR: #007700">).</span><span style="COLOR: #dd0000"></li></span><span style="COLOR: #007700">;<br> }<br> }<br> }<br> echo </span><span style="COLOR: #dd0000"></ul></span><span style="COLOR: #007700">;<br> </span><span style="COLOR: #0000bb">closedir</span><span style="COLOR: #007700">(</span><span style="COLOR: #0000bb">$check_md5_dir</span><span style="COLOR: #007700">);<br>}<br></span><span style="COLOR: #0000bb">?></span></span>