芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/administrator/components/com_akeeba/models/ftpbrowser.php
directory; // Parse directory to parts $parsed_dir = trim($dir,'/'); $this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir); // Find the path to the parent directory if(!empty($parts)) { $copy_of_parts = $parts; array_pop($copy_of_parts); if(!empty($copy_of_parts)) { $this->parent_directory = '/' . implode('/', $copy_of_parts); } else { $this->parent_directory = '/'; } } else { $this->parent_directory = ''; } // Connect to the server if($this->ssl) { $con = @ftp_ssl_connect($this->host, $this->port); } else { $con = @ftp_connect($this->host, $this->port); } if($con === false) { $this->setError(JText::_('FTPBROWSER_ERROR_HOSTNAME')); return false; } // Login $result = @ftp_login($con,$this->username,$this->password); if($result === false) { $this->setError(JText::_('FTPBROWSER_ERROR_USERPASS')); return false; } // Set the passive mode -- don't care if it fails, though! @ftp_pasv($con, $this->passive); // Try to chdir to the specified directory if(!empty($dir)) { $result = @ftp_chdir($con, $dir); if($result === false) { $this->setError(JText::_('FTPBROWSER_ERROR_NOACCESS')); return false; } } // Get a raw directory listing (hoping it's a UNIX server!) $list = @ftp_rawlist($con,'.'); ftp_close($con); if($list === false) { $this->setError(JText::_('FTPBROWSER_ERROR_UNSUPPORTED')); return false; } // Parse the raw listing into an array $folders = $this->parse_rawlist($list); return $folders; } private function parse_rawlist($list) { $folders = array(); foreach($list as $v) { $info = array(); $vinfo = preg_split("/[\s]+/", $v, 9); if ($vinfo[0] !== "total") { $perms = $vinfo[0]; if(substr($perms,0,1) == 'd') { $folders[] = $vinfo[8]; } } } asort($folders); return $folders; } public function doBrowse() { $list = $this->getListing(); $response_array = array( 'error' => $this->getError(), 'list' => $list, 'breadcrumbs' => $this->parts, 'directory' => $this->directory, 'parent' => $this->parent_directory ); return $response_array; } }