Joomla 1.5 Custom CHMOD File
My web hosting has recently upgraded their facilities. Upgrades is a good thing, and that shows how well the company is willing to advance themselves in catering their clients by equipping themselves with the latest technology. At times big guys like these may have forgotten – forgotten to fiddle their settings. Mainly this issues arise can be traced back to the person behind the panel’s professionalism, whether he understood ftp permissions or not.
As webmasters CHMOD is a big thing for us, having a dynamic CMS site swarming with activities day in day out. Having an excuse for a CHMOD hiccup was indeed not advisable. And the person behind that need to know the difference between CHMOD 755 and CHMOD 777.
I was tad disappointed that my web host has decided to disallow users to CHMOD 777 on will. Instead of doing so, their server will force revert back to 755 that means ignoring your orders to the directory to allow itself to read, write and execute. This function is important when you have dynamic stuff running around such as uploading plugins, widgets or performing upgrades of your CMS package or a component within.
My Joomla 1.5 site has recently run into problems. The web host with regards of upgrading their facilities have failed to look at CHMOD permissions. This is because i tried to upgrade my Kunena (forum component) from 1.5.4 to 1.5.5 and it just doesn’t happen.
The symptom that you will realize is when this error was generated – ‘Unable to move file’, highlighted in a red box when you try to upgrade. That means the directory that you wish to meddle won’t let you work on it hence stubbornly retained it’s 755 permission that is disabling write and execute.
There is one way to get around this that is by creating your custom chmod.php file. I am sharing this as this incident really happened to me and it really works.
Fire up a notepad or Dreamweaver, and paste this script;
// your ftp credentials
$ftp_server='ftp.yourftp.com';
$ftp_user='yourusername;
$ftp_pass='yourpassword';
// where is Joomla installed? (trailing slash required)
$base = '/public_html/';
// what files or directories need chmod applied? (trailing slash optional)
$dirs = array( 'administrator/components',
'administrator/language',
'administrator/language/en-GB',
'administrator/modules',
'administrator/templates',
'administrator/cache',
'components',
'images',
'images/banners',
'images/stories',
'media',
'language',
'language/en-GB',
'language/pdf_fonts',
'modules',
'plugins',
'plugins/content',
'plugins/editors',
'plugins/editors-xtd',
'plugins/search',
'plugins/system',
'plugins/user',
'plugins/xmlrpc',
'tmp',
'templates',
'cache'
);
// default to safe 0755 setting
if ($_GET['chmod']) {
$ftp_chmod = $_GET['chmod'];
} else {
$ftp_chmod = "0755";
}
echo "chmod=".$ftp_chmod.'
';
// 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.'
';
}
ftp_close($conn_id);
echo 'DONE';
?>
Save the file as php (if using notepad, you need to add ‘.php’ while saving, ignore .txt by selecting ‘all files’). Upload them to your root directory. Key in the following in your URL;
http://www.yourwebsite.com/chmod.php?chmod=0777 to enable write and execute privileges. Quickly upload your modules, component, template etc via your FTP or your Joomla control panel. Perform the upgrade or installation and then revert them back to 775 by keying http://www.yourwebsite.com/chmod.php?chmod=0755 in your browser URL.
Remember when editing that script you must get your FTP address, username, password and base correct otherwise this wont work!
On the frontend this is how it looked like in your browser when http://www.yourwebsite.com/chmod.php?chmod=0777 was executed;
chmod=0777
success /public_html/administrator/components
success /public_html/administrator/language
success /public_html/administrator/language/en-GB
success /public_html/administrator/modules
success /public_html/administrator/templates
success /public_html/administrator/cache
success /public_html/components
success /public_html/images
success /public_html/images/banners
success /public_html/images/stories
success /public_html/media
success /public_html/language
success /public_html/language/en-GB
success /public_html/language/pdf_fonts
success /public_html/modules
success /public_html/plugins
success /public_html/plugins/content
success /public_html/plugins/editors
success /public_html/plugins/editors-xtd
success /public_html/plugins/search
success /public_html/plugins/system
success /public_html/plugins/user
success /public_html/plugins/xmlrpc
success /public_html/tmp
success /public_html/templates
success /public_html/cache
DONE
The directories listed in the script can be allowed or disallowed based on your needs. As for me the most critical is the component, module and template.
Happy trying!
Note:
- Only try this if your FTP server does not allow you to CHMOD 777 ON DEMAND. (ON DEMAND means whenever you want it)
- Only try this if your webhosting is really a stubborn bunch who does not tolerate your demands of having 777.
- Remember to change back to 755 to prevent your website being compromised by attacks.
I’m new to using Joomla and after the first few bumps have really started to like it. Can anyone provide me a few suggestions for templates?