function recusiveFolder($folder, $first = false, $name = "") { global $_options; global $_type; $excluse = array(".", "..", ".svn", ".csv", ".git"); if ($first) { $_options = array(); $_options[] = "<option value='{$folder}' style='font-weight:bold'>{$name}</option>"; clearstatcache(); } if ($handle = opendir($folder)) { while ($file = readdir($handle)) { if (!in_array($file, $excluse)) { if (is_dir($folder . $file)) { if ($first) { $_options[] = "<option value='" . replaceValue($folder . $file) . "'>" . printSpace(3) . $file . "</option>"; } recusiveFolder($folder . $file . DS, false); } else { if (substr($file, strrpos($file, '.') + 1) == $_type) { $size = calculateSize(filesize($folder . $file)); $_options[] = "<option value='" . replaceValue($folder . $file) . "'>" . printSpace(9) . $file . " [{$size}]</option>"; } } } } closedir($handle); } }
/** * Function code 95% from WPEX Replace DB Urls https://plugins.trac.wordpress.org/browser/wpex-replace/trunk/replacestring.class.php */ function replaceValue($value, $replaceList) { if (is_array($value)) { $a = array(); foreach ($value as $k => $v) { $a[$k] = replaceValue($v, $replaceList); } return $a; } if (is_object($value)) { $o = new stdClass(); foreach ($value as $k => $v) { $o->{$k} = replaceValue($v, $replaceList); } return $o; } if (strncasecmp($value, 'a:', 2) == 0) { $a = maybe_unserialize($value); if ($a === false) { return $value; } foreach ($a as $k => $v) { $a[$k] = replaceValue($v, $replaceList); } return maybe_serialize($a); } if (strncasecmp($value, 'o:', 2) == 0) { $o = maybe_unserialize($value); if ($o === false) { return $value; } foreach ($o as $k => $v) { $o->{$k} = replaceValue($v, $replaceList); } return maybe_serialize($o); } $oldValue = $value; $newValue = str_replace(array_keys($replaceList), array_values($replaceList), $value); if (strcasecmp($oldValue, $newValue) == 0) { return $value; } return $newValue; }