function set_chmod_r($dir, $chmod, $type = CHMOD_DIR, $files = array()) { $dh = opendir($dir); if (count($files) == 0 && $type == CHMOD_DIR) { set_chmod($dir, $chmod, $type); $files[] = $dir; } while ($file = readdir($dh)) { if($file != '.' && $file != '..') { $fullpath = $dir.'/'.$file; if($type($fullpath)) { set_chmod($fullpath, $chmod, $type); $files[] = $fullpath; } if (is_dir($fullpath)) { $files = set_chmod_r($fullpath, $chmod, $type, $files); } } } closedir($dh); return $files; }
?> </strong></td> <td width="10%"><strong><?php echo $lang->phrase('admin_explorer_chmod_state'); ?> </strong></td> </tr> <?php $files = array(); foreach ($chmod as $dat) { if ($dat['recursive']) { $filenames = array(); if ($dat['chmod'] == CHMOD_EX) { $filenames = set_chmod_r($dat['path'], 0777, CHMOD_DIR); } elseif ($dat['chmod'] == CHMOD_WR) { $filenames = set_chmod_r($dat['path'], 0666, CHMOD_FILE); } foreach ($filenames as $f) { $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);
?> )</strong></td> <td width="10%"><strong>Required</strong></td> <td width="10%"><strong>Given</strong></td> <td width="10%"><strong>State</strong></td> </tr> <?php $files = array(); foreach ($chmod as $dat) { $path = '../' . $dat['path']; if ($dat['recursive']) { $filenames = array(); if ($dat['chmod'] == CHEX) { $filenames = set_chmod_r($path, 0777, CHMOD_DIR); } elseif ($dat['chmod'] == CHWR) { $filenames = set_chmod_r($path, 0666, CHMOD_FILE); } foreach ($filenames as $f) { $f = str_replace('../', '', $f); $files[] = array('path' => $f, 'chmod' => $dat['chmod'], 'recursive' => false, 'req' => $dat['req']); } } else { if ($dat['chmod'] == CHEX) { set_chmod($path, 0777, CHMOD_DIR); } elseif ($dat['chmod'] == CHWR) { set_chmod($path, 0666, CHMOD_FILE); } $files[] = $dat; } } @clearstatcache();