function set_chmod($dir, $chmod, $type = 'is_file')
{
    global $filesystem;
    if (file_exists($dir) && $type($dir)) {
        if (!check_chmod(decoct($chmod), get_chmod($dir))) {
            $filesystem->chmod($dir, $chmod);
        }
    } else {
        $filesystem->mkdir($dir, $chmod);
        set_chmod($dir, $chmod, CHMOD_DIR);
    }
}
function set_chmod($dir, $chmod, $type = CHMOD_FILE, $stop = false)
{
    global $filesystem;
    if (file_exists($dir) && $type($dir)) {
        if (!check_chmod(decoct($chmod), get_chmod($dir))) {
            $filesystem->chmod($dir, $chmod);
        }
    } else {
        if ($type == CHMOD_DIR && !$stop) {
            $filesystem->mkdir($dir, $chmod);
            set_chmod($dir, $chmod, CHMOD_DIR, true);
        } elseif (!$stop) {
            $filesystem->file_put_contents($dir, '');
            set_chmod($dir, $chmod, CHMOD_FILE, true);
        }
    }
}
Esempio n. 3
0
                $files[] = array('path' => $f, 'chmod' => $dat['chmod'], 'recursive' => false, 'req' => $dat['req']);
            }
        } else {
            if ($dat['chmod'] == CHMOD_EX) {
                set_chmod($dat['path'], 0777, CHMOD_DIR);
            } elseif ($dat['chmod'] == CHMOD_WR) {
                set_chmod($dat['path'], 0666, CHMOD_FILE);
            }
            $files[] = $dat;
        }
    }
    @clearstatcache();
    sort($files);
    foreach ($files as $arr) {
        $chmod = get_chmod($arr['path']);
        if (check_chmod($arr['chmod'], $chmod)) {
            $status = '<strong style="color: #008000;">' . $lang->phrase('admin_explorer_chmod_status_ok') . '</strong>';
        } elseif ($arr['req'] == false) {
            $status = '<strong style="color: #ffaa00;">' . $lang->phrase('admin_explorer_chmod_status_failure_x') . '</strong>';
        } else {
            $status = '<strong style="color: #ff0000;">' . $lang->phrase('admin_explorer_chmod_status_failure') . '</strong>';
        }
        ?>
	<tr class="mbox">
		<td><?php 
        echo $arr['path'];
        ?>
</td>
		<td><?php 
        echo $arr['chmod'];
        ?>