Skip to content

Instantly share code, notes, and snippets.

@stampycode
Created March 4, 2016 14:04
Show Gist options
  • Save stampycode/a88894d72de540ff5932 to your computer and use it in GitHub Desktop.
Save stampycode/a88894d72de540ff5932 to your computer and use it in GitHub Desktop.
check which files/dirs are writeable, recursively
<?php
$out = [];
function readall($dir, &$out) {
$try = explode("\n", `ls -1 $dir/`);
$try = array_flip($try);
foreach($try as $k => $v) {
if(!$k || $k === '.' || $k === '..') {
continue;
}
$k = "$dir/$k";
if(is_dir($k)) {
readall($k, $out);
continue;
}
$fh = fopen($k, 'a');
$out[$k] = ($fh) ? '1' : '0';
}
};
readall('../app', $out);
print_r($out);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment