$simpleList, 'detailedList' => $detailedList); } return false; } // Get detailed info on a file from returned info from ftpGetList function ftpGetFileInfo($ftpConn, $directory = '.', $fileName) { // Get both sets of arrays back and get our detailed list $ftpListArrays = ftpGetList($ftpConn, $directory); $detailedList = $ftpListArrays['detailedList']; // Now get the file info for our file $fileInfo = $detailedList[$fileName]; // Return the info return $fileInfo; } // Get contents over FTP function ftpGetContents($ftpConn, $filepath, $ftpMode) { // Create temp handler, this type needed for extended char set $tempHandle = fopen('php://temp', 'r+'); // Get file from FTP assuming that it exists ftp_fget($ftpConn, $tempHandle, $filepath, $ftpMode, 0); // Return our content return stream_get_contents($tempHandle, -1, 0); } // Write file contents over FTP function ftpWriteFile($ftpConn, $filepath, $contents, $ftpMode) { // Create temp handler, this type needed for extended char set $tempHandle = fopen('php://temp', 'r+'); // Write contents to handle and rewind head fwrite($tempHandle, $contents); rewind($tempHandle); // Write our content and return true/false return ftp_fput($ftpConn, $filepath, $tempHandle, $ftpMode, 0); } // Make a new dir over FTP function ftpMkDir($ftpConn, $perms, $dir) { // Create the new dir if (!ftp_mkdir($ftpConn, $dir)) { return false; } else { // Also then set perms (we must be able to do that if we created dir, so can always return true) ftpPerms($ftpConn, $perms, $dir); return true; } } // Rename a dir/dile over FTP function ftpRename($ftpConn, $oldPath, $newPath) { // Return success status of rename return ftp_rename($ftpConn, $oldPath, $newPath); } // Change dir/file perms over FTP function ftpPerms($ftpConn, $perms, $filePath) { // Return success status of perms change return ftp_chmod($ftpConn, $perms, $filePath); } // Delete dir/file over FTP function ftpDelete($ftpConn, $type, $path) { if ($type == "file") { // Delete our file and return true/false return ftp_delete($ftpConn, $path); } else { // Delete our dir and return true/false return ftp_rmdir($ftpConn, $path); } } ?>