-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkmd
executable file
·40 lines (37 loc) · 1.28 KB
/
mkmd
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
#!/usr/bin/php
<?php
recurse(".");
function recurse($dir, $lvl = 0) {
print "####>>>> ".$dir." ".strpos($dir, "search")."\n";
if (!strpos($dir, "search")) {
$files = glob("{$dir}/*");
foreach ($files as $file) {
if (strpos($file, "search")!==false) {
continue;
}
if (strstr($file, "search")!==true) {
$searchpath = "./search" . preg_replace("/^\./", '', $file);
if (is_dir($file) && (!preg_match("/node_modules|backup|archive|adminlte|search/i", $file))) {
print "--> $file\n";
if (!file_exists($searchpath)) {
mkdir($searchpath, 0755, true);
print "Created folder {$searchpath}\n";
}
if (!is_link($file)) {
if (strpos($file, "search")!==true) {
$out = recurse($file, $lvl + 1);
}
}
} else if (preg_match("/\.(html)/", $file, $matches)) {
$results = `pandoc -f html -t plain $file`;
$results = preg_replace("/\n\n/", "\n", $results);
file_put_contents($searchpath, $results);
print str_repeat("\t", $lvl) . "+ {$file}\n";
}
}
}
} else {
print "****** Skipping $dir\n";
}
}
?>