forked from phpBB-Social-Network/phpBB-Social-Network
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrebuild_gitignore.php
More file actions
83 lines (66 loc) · 1.51 KB
/
rebuild_gitignore.php
File metadata and controls
83 lines (66 loc) · 1.51 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
$filenames = array();
echo "Starting to collect files...\n";
foreach (glob_recursive('phpBB3/*', 0 , true) as $filename)
{
$filenames[] = str_replace('phpBB3/', 'root/', $filename);
}
echo "Starting to collect .htaccess files...\n";
foreach (glob_recursive('phpBB3/.*') as $filename)
{
if (!preg_match('/\.htaccess$/', $filename))
{
continue;
}
$filenames[] = str_replace('phpBB3/', 'root/', $filename);
}
echo "Adding non-phpBB related files into .gitignore...\n";
$data = "*~
# phpBB #
######################
phpBB3/
# sn-theme #
######################
root/includes/hooks/hook_sn-theme.php
sn-theme/*/.file_check
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
# phpBB files #
######################
root/cache/\n";
echo "Adding phpBB files into .gitignore...\n";
$data .= implode("\n", $filenames);
echo "Writing file...\n";
file_put_contents('.gitignore', $data);
echo "Done!\n";
function glob_recursive($pattern, $flags = 0, $skipdirs = false)
{
// do not include cache directory
if (dirname($pattern) != 'phpBB3/cache')
{
$files = glob($pattern, $flags);
}
else
{
$files = array();
}
// search for directories
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
{
if ($skipdirs)
{
// now delete directories from the list
unset( $files[array_search($dir, $files)] );
}
$files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags, $skipdirs));
}
return $files;
}