Part of the EllisLab Network
   
 
User manual lies again
Posted: 23 July 2007 05:09 PM   [ Ignore ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2517
Joined  06-11-2007

This is not the first time i have noticed a libary fail to include default config values. I created ftp.php and it was not working. With the values being passed via array to the connect() function it worked fine, with them in the /config/ftp.php config file… no dice! So im wondering why, I look at the user manual and it says:

If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at config/ftp.php and it will be used automatically.

But there is no code in the FTP class that does anything close! I made a dodgy little hack below to add the functionality the class is intended to have but im sure there is a nice way to do this.

/**
  * is a value equal to a certain value
  *
  * @access public
  * @param array
  * @return bool
  */
function connect($config = array())
{  
  
if (count($config) > 0)
  
{
   $this
->initialize($config);
  
}
  
// If no config variable was passed then load the default config file
  
else
  
{
   $this
->CI =& get_instance();
   
$this->CI->config->load('ftp');
   
   
$config['hostname'] = $this->CI->config->item('hostname');
   
$config['username'] = $this->CI->config->item('username');
   
$config['password'] = $this->CI->config->item('password');
   
$config['port']  = $this->CI->config->item('port');
   
$config['passive']  = $this->CI->config->item('passive');
   
$config['debug'] = $this->CI->config->item('debug');

   
$this->initialize($config);
  
} // End -- Where was this part?!

  
if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port)))
  
{
   
if ($this->debug == TRUE)
   
{
    $this
->_error('ftp_unable_to_connect');
   
}  
   
return FALSE;
  
}
  
  
if ( ! $this->_login())
  
{
   
if ($this->debug == TRUE)
   
{
    $this
->_error('ftp_unable_to_login');
   
}  
   
return FALSE;
  
}
  
  
// Set passive mode if needed
  
if ($this->passive == TRUE)
  
{
   ftp_pasv
($this->conn_id, TRUE);
  
}
  
  
return TRUE;
}

If you prefer you can store your FTP preferences in a config file. Simply create a new file called the ftp.php, add the $config array in that file. Then save the file at config/ftp.php and it will be used automatically.

 Signature 

Blog | Twitter | GitHub
————————-
CodeIgniter 2: Everything you need to know
————————
PyroCMS - open source modular CMS built with CodeIgniter
CleverAndy - get money for un-used concept designs
————————
Libraries: Asset, Dwoo, Cache, cURL, CLI, REST, Template

Profile
 
 
Posted: 23 July 2007 05:21 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1749
Joined  06-23-2006

I’ve found that case is important when specifying the name of the config class. I have to use “config/Ftp.php”, for example.

Here is the relevant code you were looking for:

function CI_FTP($config = array())
{  
  
if (count($config) > 0)
  
{
   $this
->initialize($config);
  
}

  log_message
('debug', "FTP Class Initialized");
}

The manual wasn’t lying, but it fails to mention the importance of naming the file with the correct case. Linux servers are case-sensitive.

 Signature 

Mac OS X 10.4.10, Apache 1.3.3, PHP 5.2.3, CodeIgniter 1.5.x., baby!

Profile
 
 
Posted: 23 July 2007 05:23 PM   [ Ignore ]   [ # 2 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2517
Joined  06-11-2007

Hmm, odd! Well ok it wasnt lying about what I said but still lying, it said “ftp.php” :p

 Signature 

Blog | Twitter | GitHub
————————-
CodeIgniter 2: Everything you need to know
————————
PyroCMS - open source modular CMS built with CodeIgniter
CleverAndy - get money for un-used concept designs
————————
Libraries: Asset, Dwoo, Cache, cURL, CLI, REST, Template

Profile
 
 
Posted: 23 July 2007 05:31 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1749
Joined  06-23-2006
thepyromaniac - 23 July 2007 05:23 PM

Hmm, odd! Well ok it wasnt lying about what I said but still lying, it said “ftp.php” :p

Keeping the user manual in sync with the codebase is a big task. At some point, a portion of CI was rewritten and this changed. “ftp.php” used to work, but then “Ftp.php” was required. I was bitten by that annoying requirement a few times. I hope to see some progress in this area soon.

 Signature 

Mac OS X 10.4.10, Apache 1.3.3, PHP 5.2.3, CodeIgniter 1.5.x., baby!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120466 Total Logged-in Users: 33
Total Topics: 126545 Total Anonymous Users: 3
Total Replies: 665388 Total Guests: 304
Total Posts: 791933    
Members ( View Memberlist )
Newest Members:  DistrikerGerd Pansenneilgroomart.maniaakoloans5kmotion1jelevinlizandermagnosismx2428