I've recently come across a script that I thought some people might find handy, and it could possibly be integrated into the OpenCart installation process as well. What it does is automatically perform CHMOD for a defined list of files/folders. As I've set up a number of OpenCart stores, this script has been a handy time-saver for me.
To run the script, just customise the code below, save as a PHP file (e.g. chmod.php), upload to your server and visit the file's location in the address bar (e.g. yoursite.com/store/chmod.php). Optionally the script can use variables to override the permission levels set in your file, e.g. yoursite.com/store/chmod.php?chmod=0777.
Code: Select all
// your ftp credentials
$ftp_server='ftp.yourwebsite.com';
$ftp_user='your_ftp_username';
$ftp_pass='your_ftp_password';
// where is your shopping cart installed? (trailing slash required)
$base = '/public/www/store/';
// what files or directories need chmod applied? (trailing slash optional)
$dirs = array( 'image',
'image/cache',
'image/data',
'system/cache',
'system/logs',
'download',
'config.php',
'admin/config.php'
);
// default to 0755 setting
if ($_GET['chmod']) {
$ftp_chmod = $_GET['chmod'];
} else {
$ftp_chmod = "0755";
}
echo "chmod=".$ftp_chmod.'<br/>';
// connect via ftp and apply chmod
$conn_id = ftp_connect("$ftp_server");
ftp_login($conn_id, $ftp_user, $ftp_pass);
foreach( $dirs as $dir ){
if (ftp_site($conn_id, 'CHMOD '.$ftp_chmod.' '.$base.$dir)) {
echo "success ";
} else {
echo "failed ";
}
echo $base.$dir.'<br/>';
}
ftp_close($conn_id);
echo 'DONE';
Grant