View difference between Paste ID: HQNsQPwA and wUrkVf3h
SHOW: | | - or go back to the newest paste.
1
<?php
2
if (PHP_SAPI !== 'cli')
3
{
4
    die ('Access denied');
5
}
6
7
$replaces_from  = [];
8
$replaces_to    = [];
9
10
$fa = fopen(__DIR__ . '/font-awesome.csv', 'r');
11
$header = fgetcsv($fa);
12
while ($row = fgetcsv($fa))
13
{
14
	$oldname = $row[0];
15
	$newname = $row[1];
16
	$newpref = $row[2];
17
	
18
	$replaces_from[] = "fa:{$oldname}";
19
	$replaces_to[]   = "{$newpref}:{$newname}";
20
	
21
	$replaces_from[] = "fa fa-{$oldname}";
22
	$replaces_to[]   = "{$newpref} fa-{$newname}";
23
}
24
fclose($fa);
25
26
$replace_paths = ['app/control', 'app/resources', 'menu.xml'];
27
28
foreach ($replace_paths as $replace_path)
29
{
30
	if (is_file($replace_path))
31
	{
32
		replace($replace_path, $replaces_from, $replaces_to);
33
	}
34
	else
35
	{
36
		foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($replace_path),
37
														 RecursiveIteratorIterator::CHILD_FIRST) as $arquivo)
38
		{
39
			if ( (substr($arquivo, -4) == '.php') || (substr($arquivo, -5) == '.html') || (substr($arquivo, -3) == '.js'))
40
			{
41
				replace($arquivo, $replaces_from, $replaces_to);
42
			}
43
		}
44
	}
45
}
46
47
function replace($arquivo, $replaces_from, $replaces_to)
48
{
49
	echo "Processando...: {$arquivo} \n";
50
	if (is_writable($arquivo))
51
	{
52
		$content = file_get_contents($arquivo);
53
		file_put_contents( $arquivo, str_replace( $replaces_from, $replaces_to, $content) );
54
	}
55
	else
56
	{
57
		echo "Erro de permissão em...: {$arquivo} \n";
58
	}
59
}