[isf-wifidog] Blank lines in files...
Proulx François
fproulx at edito.qc.ca
Jeu 29 Déc 13:23:02 EST 2005
I'm refactoring a bunch of files with old untranslated comments and
documentation from french to english ...
I found that many files had blank lines at the end... which is bad
since it breaks XML outputs (which breaks the Google Maps mashup)
I'm will clean those up, but I will also give you a little secret
script I use ;-) This simple PHP script tells you which files
contains blank lines outside php tags. Very helpful since you don't
have to scroll through all files to find them.
See ya
<html>
<body>
<h1>This script will find any blank lines and/or characters outside
PHP tags</h1>
<?php
// Quick and dirty PHP script that will find all files
containing characters that would break XML files
// (c)2005 - Francois Proulx
function findBlankLines($dir)
{
$dir_handle = opendir($dir);
while ($file = readdir($dir_handle))
{
if(is_dir($file) && $file != "." && $file != "..")
findBlankLines($file);
else if(preg_match("/\.php$/", $file))
{
$path = "{$dir}/{$file}";
// match any characters occuring once or + outside PHP tags
if(preg_match("/^.+<\?php(.+)?\?>$/s", file_get_contents($path)))
echo "File : $path <br>";
if(preg_match("/^<\?php(.+)?\?>.+$/s", file_get_contents($path)))
echo "File : $path <br>";
}
}
closedir($dir_handle);
return;
}
findBlankLines(".");
?>
</body>
</html>
More information about the WiFiDog
mailing list