function mmcache_encode_dir($src, $out, $s, $r, $l, $c, $f) { if (!($dir = opendir($src))) { return mmcache_error("Can't open source directory \"{$src}\""); } while (($file = readdir($dir)) !== false) { if ($file == '.' || $file == '..') { continue; } $i = "{$src}/{$file}"; $o = empty($out) ? $out : "{$out}/{$file}"; if (is_link($i)) { if ($c && !empty($o)) { mmcache_copy_link($i, $o, $f); global $web_error; if (!empty($web_error)) { echo "<font color=\"#ff0000\">{$web_error}</font><br />\n"; flush(); $web_error = ''; } continue; } else { if (!$l) { continue; } } } if (is_dir($i)) { if ($r && mmcache_copy_dir($i, $o, $f)) { mmcache_encode_dir($i, $o, $s, $r, $l, $c, $f); } } else { if (is_file($i)) { if (empty($s)) { mmcache_encode_file($i, $o, $f, $c); } else { if (is_string($s)) { if (preg_match('/' . preg_quote(".{$s}") . '$/i', $file)) { mmcache_encode_file($i, $o, $f, $c); } else { if (!empty($o) && $c) { mmcache_copy_file($i, $o, $f); } } } else { if (is_array($s)) { $encoded = false; foreach ($s as $z) { if (preg_match('/' . preg_quote(".{$z}") . '$/i', $file)) { mmcache_encode_file($i, $o, $f, $c); $encoded = true; break; } } if (!$encoded && !empty($o) && $c) { mmcache_copy_file($i, $o, $f); } } } } } } global $web_error; if (!empty($web_error)) { echo "<font color=\"#ff0000\">{$web_error}</font><br />\n"; flush(); $web_error = ''; } } closedir($dir); }
function mmcache_encode_dir($src, $out, $s, $r, $l, $c, $f, $web) { if ($dir = @opendir($src)) { while (($file = readdir($dir)) !== false) { if ($file == "." || $file == "..") { continue; } $i = "{$src}/{$file}"; $o = empty($out) ? $out : "{$out}/{$file}"; if (is_link($i)) { if ($c && !empty($o)) { mmcache_copy_link($i, $o, $f, $web); if ($web) { global $web_error; if (!empty($web_error)) { echo "<font color=\"#ff0000\">{$web_error}</font><br>\n"; flush(); $web_error = ""; } } continue; } else { if (!$l) { continue; } } } if (is_dir($i)) { if ($r) { if (mmcache_copy_dir($i, $o, $f, $web)) { mmcache_encode_dir($i, $o, $s, $r, $l, $c, $f, $web); } } } else { if (is_file($i)) { if (empty($s)) { mmcache_encode_file($i, $o, $f, $c, $web); } else { if (is_string($s)) { if (preg_match("/" . preg_quote(".{$s}") . "\$/i", $file)) { mmcache_encode_file($i, $o, $f, $c, $web); } else { if (!empty($o) && $c) { mmcache_copy_file($i, $o, $f, $web); } } } else { if (is_array($s)) { $encoded = false; foreach ($s as $z) { if (preg_match("/" . preg_quote(".{$z}") . "\$/i", $file)) { mmcache_encode_file($i, $o, $f, $c, $web); $encoded = true; break; } } if (!$encoded && !empty($o) && $c) { mmcache_copy_file($i, $o, $f, $web); } } } } } } if ($web) { global $web_error; if (!empty($web_error)) { echo "<font color=\"#ff0000\">{$web_error}</font><br>\n"; flush(); $web_error = ""; } } } closedir($dir); } else { mmcache_error("Can't open source directory \"{$src}\"", $web); } }