diff --git a/watchbird.php b/watchbird.php index e021d2a..fa38f77 100644 --- a/watchbird.php +++ b/watchbird.php @@ -1618,20 +1618,100 @@ function showlog(){ function install($dir){ $layer_list = scandir($dir); foreach ($layer_list as $i){ - if ($i === '.' || $i == "..") {continue;} + if ($i === '.' || $i === "..") { + continue; + } $next = $dir . $i; - if (is_dir($next)){ - if ($next[strlen($next) - 1] !== '/') {$next .= "/";} + if (is_dir($next)) { + if ($next[strlen($next) - 1] !== '/') { + $next .= "/"; + } install($next); - } - else{ + } else { $ext = end(explode('.', $next)); $php_ext = ["php", "php5", "phtml"]; - if (in_array($ext, $php_ext) && strlen($ext) !== strlen($next)){ + if (in_array($ext, $php_ext) && strlen($ext) !== strlen($next)) { $old_file_str = file_get_contents($next); - if (strpos($old_file_str, "" . $old_file_str); + $start_pos = strpos($old_file_str, "" . $old_file_str); + } } } } @@ -1655,10 +1735,13 @@ function uninstall($dir) $php_ext = ["php", "php5", "phtml"]; if (in_array($ext, $php_ext) && strlen($ext) !== strlen($next)) { $old_file_str = file_get_contents($next); - if (strpos($old_file_str, "") === 0) { + if (strpos(ltrim($old_file_str), "") === 0) { echo $next . "\n"; file_put_contents($next, substr($old_file_str, strlen(""))); } + else { + file_put_contents($next, str_replace("\ninclude_once '" . __FILE__ . "';\n", "", $old_file_str)); + } } } }