Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Single Post Page */
- <form>
- <input type="submit" name="exftp" value="Export FTP">
- <?php
- if(isset($GET['exftp'])){
- create_export(the_ID());
- }
- ?>
- </form>
- /* Custom Function */
- <?php
- function create_export($id) {
- $title = get_the_title($id);
- $current_host = get_field('client_website_current_ftp_host', $id);
- $current_user = get_field('client_website_current_ftp_username', $id);
- $current_password = get_field('client_website_current_ftp_password', $id);
- $current_password = base64_encode($current_password);
- $current_port = get_field('client_website_current_ftp_port', $id);
- $file = get_stylesheet_directory_uri().'/export/export.xml';
- // Write the contents to the file
- $content = '<?xml version="1.0" encoding="UTF-8"?>';
- $content .= '<FileZilla3 version="3.27.0.1" platform="mac">';
- $content .= ' <Servers>';
- $content .= ' <Server>';
- $content .= ' <Host>'.$current_host.'</Host>';
- $content .= ' <Port>'.$current_port.'</Port>';
- $content .= ' <Protocol>0</Protocol>';
- $content .= ' <Type>0</Type>';
- $content .= ' <User>'.$current_user.'</User>';
- $content .= ' <Pass encoding="base64">'.$current_password.'</Pass>';
- $content .= ' <Logontype>1</Logontype>';
- $content .= ' <TimezoneOffset>0</TimezoneOffset>';
- $content .= ' <PasvMode>MODE_DEFAULT</PasvMode>';
- $content .= ' <MaximumMultipleConnections>0</MaximumMultipleConnections>';
- $content .= ' <BypassProxy>0</BypassProxy>';
- $content .= ' <BypassProxy>0</BypassProxy>';
- $content .= ' <Name>'.$title.'</Name>';
- $content .= ' <Comments />';
- $content .= ' <Colour>0</Colour>';
- $content .= ' <LocalDir />';
- $content .= ' <RemoteDir />';
- $content .= ' <SyncBrowsing>0</SyncBrowsing>';
- $content .= ' <DirectoryComparison>0</DirectoryComparison>';
- $content .= ' </Server>';
- $content .= ' </Servers>';
- $content .= '</FileZilla3>';
- file_put_contents($file, $content);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement