0
votes

We maintain over 70 property websites on a single CI application fueled by a database (actually, one database and application for production sites and one database and application for development sites) to provide the necessary differences for each site. We provide a custom CMS so that the property managers can update their site regularly. There is an approval process to push changes made to their development site through the CMS to their production site.

One CMS function is to upload photo albums. Once the album is uploaded on development and approved for production, I need to copy this folder from the development assets to their production assets.

I establish the FTP connection and create the photo album folder without issue using:

$this->ftp->mkdir($path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/', DIR_WRITE_MODE);

($path[‘ftpP’] looks like this: /httpdocs/edrAssets/propsP/700/

When I try to use the mirror function in the FTP class, I don’t get any errors or warnings but I also don’t get any transfer—- just nothing.

Here is that code:

$dLink = $path['ftpD'].'photoAlbums/'.$album[0]['albumFolderName'].'/';
$pLink = $path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/';

$this->ftp->mirror($dLink, $pLink); 

I have been fighting this since late Thursday night and need some advice. ALL help is appreciated.

Jon

REQUESTED LOG FILE:

DEBUG - 2012-06-18 07:15:31 --> Controller Class Initialized

DEBUG - 2012-06-18 07:15:31 --> Ftp class already loaded. Second attempt ignored.

DEBUG - 2012-06-18 07:15:31 --> Trying to FTP here

ERROR - 2012-06-18 07:15:31 --> Severity: Warning --> opendir() [function.opendir]: Unable to access /httpdocs/edrAssets/propsD/700/photoAlbums/theUSOpen2012/ /var/www/vhosts/edrpropertyoperations.com/httpdocs/WEBdev/system/libraries/Ftp.php 532

ERROR - 2012-06-18 07:15:31 --> Severity: Warning --> opendir(/httpdocs/edrAssets/propsD/700/photoAlbums/theUSOpen2012/) [function.opendir]: failed to open dir: No such file or directory /var/www/vhosts/edrpropertyoperations.com/httpdocs/WEBdev/system/libraries/Ftp.php 532

DEBUG - 2012-06-18 07:15:31 --> Final output sent to browser

DEBUG - 2012-06-18 07:15:31 --> Total execution time: 0.1626

ADDED *

    public function approved_create_album( $id ){   
         $thisTask = $this->mcms->getSingleAdminTask( $id );

         $album = $this->mcms->getAlbumByID($thisTask[0]['itemID']);    
         $path = $this->mcms->path_variables( $album[0]['propNumber']);

         $this->load->library('ftp');   
         $ftp['hostname'] = <REMOVED>;
         $ftp['username'] = <REMOVED>;  
         $ftp['password'] = <REMOVED>;
         $ftp['port']     = 21;     
         $ftp['passive']  = FALSE;  
         $ftp['debug']    = TRUE;   
         $ftp['ssl_mode'] = FALSE;  
         $this->ftp->connect($ftp);

         $dLink = $path['ftpD'].'photoAlbums/'.$album[0]['albumFolderName'].'/';    
         $pLink = $path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/';

         if( !file_exists($pLink) && !is_dir($pLink)){
              $this->ftp->mkdir($path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/', DIR_WRITE_MODE);     
         } // end if

         log_message('debug', 'Trying to FTP here');
         $this->ftp->mirror($dLink, $pLink);

         echo $dLink . " to " . $pLink; 
} // end approved_create_album function
2

2 Answers

0
votes

I would suggest step-by-step debugging:

1) Set debug to TRUE,see function reference. You may need to turn error_reporting on.

2) Connect to the server (which you did) and upload a file. If that works you know that a) the connection works and b) you've got the filepath right.

If it still doesn't work, look through the logs (or post them here ;-)). Good luck!

Update:

I tested the FTP library on my own servers. Works like a charm, straight out of the box. So we need to firure out if the problem is with the servers or with your CI configuration.

Here's what I would do next:

1) Try less configuration, less variables, hardcode everything using this example:

<?php
$this->load->library('ftp');
$config['hostname'] = 'ftp.example.com';
$config['username'] = 'your-username'; 
$config['password'] = 'your-password';
$this->ftp->connect($config);
$this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/');
$this->ftp->close(); 

If it doesn't work, then:

2) Download a fresh CI installation and put it on your server. You won't need any configuration or DB connections. Then try the example above in the fresh enviroment.

0
votes

What about just dropping down to unix in your code and using command line rsync.