Welcome Guest, Not a member yet? Register   Sign In
[function.ftp-get]: failed to open stream: Permission denied
#7

[eluser]Jay Logan[/eluser]
Solved. Had to rethink my strategy and came up with this ugly, yet functional solution. The problem was I was moving 300 accounts over to a dedicated server. Although HostGator offers a transfer server, they tend to ignore .htaccess files and I also needed to update my local DB with the new log in info and server IP addresses. Plus I wanted to transfer my AWStats. Here is what I came up with.

Code:
$this->load->library(array('ftp', 'whm'));
$this->load->model('sites_model');
$this->load->helper('array');

$site_id = $this->sites_model->get_random_active_site();

if ($site_id) {

$site_info = $this->sites_model->get_info(array('id' => $site_id));

$cpanel_parameters = array(

'ip' => 'n',
'cgi' => 'n',
'frontpage' => 'n',
'cpmod' => 'x3',
'useregns' => '0',
'reseller' => '0',
'domain' => str_replace('http://www.', '', $site_info['url']),
'customip' => $ip_address,
'username' => $site_info['cpanel_user_name'],
'password' => 'charlo2010',
'plan' => 'dealer_site',
'contactemail' => '[email protected]'

);

$new_account = $this->whm->createAccount($cpanel_parameters);

if ($new_account->result->status == 1) {

$config1['hostname'] = "www.old-domain.com";
$config1['username'] = $site_info['cpanel_user_name'];
$config1['password'] = "oldpassword";
$config1['debug'] = TRUE;

$this->ftp->connect($config1);

$awstats = $this->ftp->list_files('/tmp/awstats');

unset($awstats[0]);
unset($awstats[1]);

foreach ($awstats as $file) {

$this->ftp->download('/tmp/awstats/'.$file, $file, 'ASCII', 0755);

}

$this->ftp->close();

$config2['hostname'] = "www.new-domain.com";
$config2['username'] = $site_info['cpanel_user_name'];
$config2['password'] = "newpassword";
$config2['debug'] = TRUE;

$this->ftp->connect($config2);

$this->ftp->upload('/home/username/public_html/.htaccess', '/public_html/.htaccess', 'ASCII', 0644);
$this->ftp->upload('/home/username/public_html/new_account_index.php', '/public_html/index.php', 'ASCII', 0644);

$this->ftp->mkdir('/tmp/awstats/', 0755);

foreach ($awstats as $file) {

$this->ftp->upload('/home/username/public_html/'.$file, '/tmp/awstats/'.$file, 'ASCII', 0644);

}

$this->ftp->close();

$this->sites_model->convert_site($site_id);

echo "Site converted.";

} else {

print_r($new_account);

}

} else {

echo "DONE";

}


Messages In This Thread
[function.ftp-get]: failed to open stream: Permission denied - by El Forum - 04-13-2010, 01:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB