function fm_mkalllocal($files) { global $ftp, $ftp_prepath; if (!fm_ftpconnect()) { return false; } if (!count($files)) { return $files; } if (!is_dir('cache/down/local')) { mkdir('cache/down/local'); } foreach ($files as $i => $file) { if (fm_isdir($file)) { fm_recursivemklocal('cache/down/local/' . (endsWith($file, '/') ? '' : '/'), endsWith($file, '/') ? '' : '/', ''); $files[$i] = 'cache/down/local/' . basename($file); } else { @ftp_get($ftp, 'cache/down/temp.bin', $ftp_prepath . $file, FTP_BINARY); @chmod('cache/down/temp.bin', 0600); // Don't want those silly hackers @rename('cache/down/temp.bin', 'cache/down/local/' . basename($file)); $files[$i] = 'cache/down/local/' . basename($file); } } return $files; }
function fm_getfiles($path) { $dh = @opendir($GLOBALS['prepath'] . $path); if ($dh === FALSE) { return FALSE; } $dirs = array(); $files = array(); while (false !== ($file = @readdir($dh))) { if ($file == '.' || $file == '..') { continue; } // Skip files not actually in the directory if (fm_isdir($path . $file)) { // directory? $dirs[] = $file . '/'; } else { if (fm_isfile($path . $file)) { $files[] = $file; } } } @closedir($dh); if ($cnfs == '1') { $files = array_merge($dirs, $files); //merge $dirs = array(); } if ($carr !== false) { if ($files) { natcasesort($files); } if ($dirs) { natcasesort($dirs); } } $files = array_merge($dirs, $files); //merge return $files; }
function fm_delete($source) { global $ftp, $ftp_prepath; if (!fm_ftpconnect()) { return false; } if (!fm_isdir($source)) { return @ftp_delete($ftp, $ftp_prepath . $source); } if (substr('/' . $source, -1) != '/') { $source .= '/'; } // enforce trailing slash $csources = fm_fastgetfiles($source); foreach ($csources as $csource) { if ($csource == '.' || $csource == '..') { continue 1; } fm_delete($source . $csource); } return @ftp_rmdir($ftp, substr($ftp_prepath . $source, 0, -1)); }
'); <?php } } } ?> } //document.onDblClick = delsel(); //--> </script> <script language="javascript" type="text/javascript" src="fileman-main.js"></script> </head> <body onload="load()" onkeypress="return keypress(event)" onkeydown="return keydown(event)" onkeyup="return keyup(event)" oncontextmenu="return cmenu_nmo(event);" ondblclick="if (nmo) selall()" onmousedown="return mousedown(event);" onmouseup="return mouseup(event);" onselectstart="return false"> <div class="pad" id="filelist"> <?php if (!fm_isdir($d)) { ?> <div style="padding:20px;"><em style="color:#888888;font-size:12pt;"><strong>Error:</strong> This folder doesn't exist.</em></div> <?php } else { if ($files === FALSE) { ?> <div style="padding:20px;"><em style="color:#888888;font-size:12pt;">Access denied.</em></div> <?php } else { if (count($files) == 0) { ?> <div style="padding:20px;"><em style="color:#888888;font-size:12pt;">This folder is empty.</em></div> <?php } else { ?>
function fm_delete($file) { global $prepath; if (fm_isdir($file)) { if (substr('/' . $file, -1) !== '/') { $file .= '/'; } if (!($handle = @opendir($prepath . $file))) { return false; } while (false !== ($item = readdir($handle))) { if ($item != '.' && $item != '..' && !fm_fdelete($prepath . $file . $item)) { return false; } } closedir($handle); return @rmdir($prepath . $file); } return @unlink($prepath . $file); }