function dir_chmod($dir, $mode = '', $require = 0) { if (!$require) { $require = substr($dir, -1) == '*' ? 2 : 0; } if ($require) { if ($require == 2) { $dir = substr($dir, 0, -1); } $dir = dir_path($dir); $list = glob($dir . '*'); foreach ($list as $v) { if (is_dir($v)) { dir_chmod($v, $mode, 1); } else { @chmod(basename($v), $mode); } } } if (is_dir($dir)) { @chmod($dir, $mode); } else { @chmod(basename($dir), $mode); } }
$url_pass = $PHP_URL ? true : false; $percent = '20%'; include IN_ROOT . '/step_' . $step . '.tpl.php'; break; case '3': //属性 $ISWIN = strpos(strtoupper(PHP_OS), 'WIN') === false ? false : true; $files = file_get_contents(IN_ROOT . '/chmod.txt'); $files = explode("\n", $files); $files = array_map('trim', $files); $FILES = array(); $pass = true; foreach ($files as $k => $v) { $FILES[$k]['name'] = $v; if (!$ISWIN) { dir_chmod(DT_ROOT . '/' . $v, DT_CHMOD); } if (is_write(DT_ROOT . '/' . str_replace('*', 'index.html', $v))) { $FILES[$k]['write'] = true; if (strpos($v, 'index.html') !== false) { $c = file_get(DT_ROOT . '/' . $v) . '<!--WriteTest-->'; file_put(DT_ROOT . '/' . $v, $c); $c = file_get(DT_ROOT . '/' . $v); if (strpos($c, 'WriteTest') === false) { $FILES[$k]['write'] = $pass = false; } } if ($ISWIN && $v == 'config.inc.php') { $c = file_get(DT_ROOT . '/' . $v); $c = str_replace($CFG['authkey'], 'WriteTest', $c); file_put(DT_ROOT . '/' . $v, $c);