forked from Project-Pier/ProjectPier-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utf8bom.php
33 lines (29 loc) · 794 Bytes
/
utf8bom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/php
<?php
define('STR_BOM', "\xEF\xBB\xBF");
$file = null;
$directory = getcwd();
echo '<xmp>';
$rit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);
try {
$count = 0;
foreach ($rit as $file) {
if ($file->isFile()) {
$path_parts = pathinfo($file->getRealPath());
if ('php' == $path_parts['extension']) {
$object = new SplFileObject($file->getRealPath());
if (false !== strpos($object->getCurrentLine(), STR_BOM)) {
$count++;
print $file->getRealPath()."\n";
}
}
} else {
print 'processing ' . $file->getRealPath()."\n";
flush();
}
}
echo 'done ' . $count . ' files found with BOM mark';
} catch (Exception $e) {
die ('Exception caught: '. $e->getMessage());
}
?>