function traverseDir($dir) { echo "<h2>Listing {$dir} ...</h2>"; if (!($handle = opendir($dir))) { die("Cannot open {$dir}."); } $files = array(); while ($file = readdir($handle)) { if ($file != "." && $file != "..") { if (is_dir($dir . "/" . $file)) { $file .= "/"; } $files[] = $file; } } sort($files); echo "<ul>"; foreach ($files as $file) { echo "<li>{$file}</li>"; } echo "</ul>"; foreach ($files as $file) { if (substr($file, -1) == "/") { traverseDir("{$dir}/" . substr($file, 0, -1)); } } closedir($handle); }
function traverseDir($path) { global $doc_dir; if (false !== opendir($path)) { $d = opendir($path); while (false !== ($f = readdir($d))) { $full_path = $path . '/' . $f; if (0 != strncmp($f, '.', 1)) { if (is_dir($full_path)) { traverseDir($full_path); } else { if ('.js' != substr($f, -3)) { continue; } if (false === strpos($full_path, 'widget')) { if ('ac.fry.' != substr($f, 0, 7)) { continue; } } generateAPI($full_path, $f); } } } closedir($d); } }
function traverseDir($dir) { echo "<h4>Listing {$dir} ...</h4>"; if (!($handle = opendir($dir))) { die("Cannot open {$dir}."); } $files = array(); while ($file = readdir($handle)) { if ($file != "." && $file != "..") { if (is_dir($dir . "/" . $file)) { $file .= "/"; } $files[] = $file; } } sort($files); echo "<ul>"; foreach ($files as $file) { echo "<li>{$file}</li>"; } echo '</ul>'; // Once we get entries for directory, loop thru them // and if entry is directory, call travereDir recursively foreach ($files as $file) { if (substr($file, -1) == "/") { traverseDir("{$dir}/" . substr($file, 0, -1)); } } closedir($handle); }
function traverseDir($path) { if (false !== opendir($path)) { $d = opendir($path); while (false !== ($f = readdir($d))) { $full_path = $path . '/' . $f; if (0 != strncmp($f, '.', 1)) { if (is_dir($full_path)) { traverseDir($full_path); } else { if (!$_REQUEST['clean'] && '.js' == substr($f, -3) && 0 != strncmp('dist.', $f, 5) && 0 != strncmp('obf.', $f, 4)) { echo "<p>Shrinking <strong>{$f}</strong> at <small>{$path}</small><br/>"; $source = file_get_contents($full_path); $size = strlen($source); $new_source = shrinkSource($source); $new_size = strlen($new_source); $new_path = $path . '/dist.' . $f; file_put_contents($new_path, $new_source); chmod($new_path, 0777); echo 'Original size: <strong>' . $size . '</strong>, new size: <strong>' . $new_size . '</strong>. Shrinked to <strong>' . 100 * $new_size / $size . '%</strong> of the original.'; $obf_source = obfuscateSource($new_source); $obf_size = strlen($obf_source); $obf_path = $path . '/obf.' . $f; file_put_contents($obf_path, $obf_source); chmod($obf_path, 0777); echo '<br>Obfuscated size: <strong>' . $obf_size . '</strong>. Shrinked to <strong>' . 100 * $obf_size / $size . '%</strong> of the original.'; echo '</p>'; // die(); } else { if ($_REQUEST['clean'] && '.js' == substr($f, -3) && (0 == strncmp('dist.', $f, 5) || 0 == strncmp('obf.', $f, 4))) { // cleaning echo "<p>Cleaning <strong>{$f}</strong> at <small>{$path}</small></p>"; unlink($full_path); } } } } } closedir($d); } }