forked from Project-Pier/ProjectPier-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
themes-diff.php
56 lines (55 loc) · 1.66 KB
/
themes-diff.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
ob_start();
$themes = array();
$files = array();
$directory = './public/assets/themes';
echo "<html><a href='?download'>Download</a>";
echo '<xmp>';
foreach (new DirectoryIterator($directory) as $fileInfo) {
if($fileInfo->isDot()) continue;
if($fileInfo->isFile()) continue;
//echo $fileInfo->getFilename() . "\n";
//echo $fileInfo->getPathname() . "\n";
process_theme( $fileInfo->getFilename(), $fileInfo->getPathname() );
}
if (isset($_GET['download'])) {
ob_end_clean();
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=themesdiff.txt;');
foreach( $files as $k1 => $v1 ) {
foreach( $v1 as $k2 => $v2 ) {
foreach( $v2 as $k3 => $v3 ) {
print "$k1;$k2;$k3;$v3\n";
}
}
}
die();
}
print_r($themes);
print_r($files);
ob_end_flush();
function process_theme($theme, $theme_path) {
global $themes;
global $files;
$rit = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($theme_path), RecursiveIteratorIterator::CHILD_FIRST);
try {
$count = 0;
foreach ($rit as $file) {
if ($file->isDir()) continue;
$count++;
$path = $file->getPath();
$path = str_replace( $theme_path, '', $path );
$path = str_replace( $theme, '', $path );
$name = $file->getBasename();
//print 'processing ' . $path ."\n";
//print 'processing ' . $name ."\n";
$themes[$theme][$path][$name]=$file->getSize();
$files[$name][$path][$theme]=$file->getSize();;
flush();
}
echo 'done ' . $count . ' files found with ' . $theme . "\n";
} catch (Exception $e) {
die ('Exception caught: '. $e->getMessage());
}
}
?>