function file_exists($file) { if (ext_isFTPMode()) { if ($file == '/') { return true; } // The root directory always exists $dir = $GLOBALS['FTPCONNECTION']->pwd(); if (!is_array($file)) { $dir = dirname($file); $file = array('name' => basename($file)); } $list = getCachedFTPListing($dir); if (is_array($list)) { foreach ($list as $item) { if ($item['name'] == $file['name']) { return true; } } } return false; } else { if ($GLOBALS['use_mb']) { if (mb_detect_encoding($file) == 'ASCII') { return file_exists(utf8_decode($file)); } else { return file_exists($file); } } else { return file_exists(utf8_decode($file)); } } }
function get_dir_list($dir = '') { if (ext_isFTPMode()) { $files = getCachedFTPListing(empty($dir) ? '.' : $dir); } else { $files = extReadDirectory(get_abs_dir($dir), '.', false, true); } $dirs = array(); foreach ($files as $item) { $itemname = ext_isFTPMode() ? (empty($dir) ? '' : $dir . '/') . $item['name'] : $item; $itemname = str_replace('\\', '/', $itemname); if (get_is_dir($item)) { $index = str_replace(str_replace('\\', '/', $GLOBALS['home_dir'] . $GLOBALS['separator']), '', $itemname); $dirs[$index] = basename($index); } } return $dirs; }
/** * Returns the LS info array from an ftp directory listing * * @param unknown_type $dir * @param unknown_type $item * @return unknown */ function get_item_info($dir, $item) { $ls = getCachedFTPListing($dir); foreach ($ls as $entry) { if ($entry['name'] == $item) { return $entry; } } if ($dir != '') { return $dir . '/' . $item; } return $item; }