Code: Select all
<?php
$ftp_root = '/httpdocs/DEV/D1/';
function chmod_open()
{
$ftp_user_name = 'username';
$ftp_user_pass = 'password';
$ftp_server = 'ftp.myserver.co.za';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
echo "DEBUG Info: <br>";
echo "=========== <br>";
echo "<br>" ;
echo "Server Name: " . $ftp_server . "<br>";
echo "FTP Username: " . $ftp_user_pass . "<br>";
echo "DEBUG: Login Result - " . $login_result . "<br>";
echo "<br>" ;
return $conn_id;
}
function chmod_file($conn_id, $permissions, $path)
{
if (ftp_site($conn_id, 'CHMOD ' . $permissions . ' ' . $ftp_root . $path) !== false)
{
return TRUE;
}
else
{
return FALSE;
}
}
function chmod_close($conn_id)
{
ftp_close($conn_id);
echo "Connection Closed";
}
$conn_id = chmod_open();
echo chmod_file($conn_id, 777, 'administrator/backups/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . '<br>';
echo chmod_file($conn_id, 777, 'administrator/cache/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'administrator/components/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'administrator/language/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'administrator/language/en-GB/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'administrator/modules/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'administrator/templates/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'cache/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'components/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'images/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'images/banners/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'images/stories/') ? 'CHMODed successfully!' : 'Error' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'language/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'language/en-GB/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'language/pdf_fonts/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'modules/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/content/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/editors/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/editors-xtd/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/search/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/system/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/user/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'plugins/xmlrpc/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'tmp/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
echo chmod_file($conn_id, 777, 'templates/') ? 'CHMODed successfully!' : 'Error:' . $ftp_root . $path . ' <br>';
chmod_close($conn_id);
?>