Advertisement
cenz

Export XML

Feb 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. /* Single Post Page */
  2. <form>
  3.     <input type="submit" name="exftp" value="Export FTP">
  4.     <?php
  5.         if(isset($GET['exftp'])){
  6.             create_export(the_ID());
  7.         }
  8.     ?>
  9. </form>
  10.  
  11. /* Custom Function */
  12. <?php
  13. function create_export($id) {
  14.     $title = get_the_title($id);
  15.     $current_host = get_field('client_website_current_ftp_host', $id);
  16.     $current_user = get_field('client_website_current_ftp_username', $id);
  17.     $current_password = get_field('client_website_current_ftp_password', $id);
  18.     $current_password = base64_encode($current_password);
  19.     $current_port = get_field('client_website_current_ftp_port', $id);
  20.  
  21.     $file = get_stylesheet_directory_uri().'/export/export.xml';
  22.     // Write the contents to the file
  23.     $content = '<?xml version="1.0" encoding="UTF-8"?>';
  24.     $content .= '<FileZilla3 version="3.27.0.1" platform="mac">';
  25.     $content .= '   <Servers>';
  26.     $content .= '       <Server>';
  27.     $content .= '           <Host>'.$current_host.'</Host>';
  28.     $content .= '           <Port>'.$current_port.'</Port>';
  29.     $content .= '           <Protocol>0</Protocol>';
  30.     $content .= '           <Type>0</Type>';
  31.     $content .= '           <User>'.$current_user.'</User>';
  32.     $content .= '           <Pass encoding="base64">'.$current_password.'</Pass>';
  33.     $content .= '           <Logontype>1</Logontype>';
  34.     $content .= '           <TimezoneOffset>0</TimezoneOffset>';
  35.     $content .= '           <PasvMode>MODE_DEFAULT</PasvMode>';
  36.     $content .= '           <MaximumMultipleConnections>0</MaximumMultipleConnections>';
  37.     $content .= '           <BypassProxy>0</BypassProxy>';
  38.     $content .= '           <BypassProxy>0</BypassProxy>';
  39.     $content .= '           <Name>'.$title.'</Name>';
  40.     $content .= '           <Comments />';
  41.     $content .= '           <Colour>0</Colour>';
  42.     $content .= '           <LocalDir />';
  43.     $content .= '           <RemoteDir />';
  44.     $content .= '           <SyncBrowsing>0</SyncBrowsing>';
  45.     $content .= '           <DirectoryComparison>0</DirectoryComparison>';
  46.     $content .= '       </Server>';
  47.     $content .= '   </Servers>';
  48.     $content .= '</FileZilla3>';
  49.  
  50.     file_put_contents($file, $content);
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement