Help - Search - Members - Calendar
Full Version: PHP Includes and Permission Setting Errors
Movable Type Community Forum > Other Product Discussion > Bugs and Odd Behavior
auxblood
So I am trying to use the PHP "require()" function to make server-side includes in my MT pages. The require function basically just pulls in another PHP file and executes in inline... simple stuff.

Here's the issue (or bug): the require function dies completely when it is run on a page MT has physically generated. Let's use index.php as an example. If I download index.php to disk, then delete it from the server, then reupload it, the require function works!!! This tells me it is probably permission-related since uploading a new file effectively resets the permissions.

Furthermore, if I try to change permissions on any MT-generated file, I get an error in my FTP program. Seems the permissions just stay at 666. I've even modified the HTMLPerm line in the mt.cfg file to spit out 777 files, and a Get Info in my FTP program still always shows 666 permissions.

What on earth could be causing this? Why wouldn't MT-generated files be able to handle this PHP function? They handle other PHP functions just fine.

Thanks,

Mike
TweezerMan
There's actually two settings in mt.cfg that determine what permissions end up on a file:

# HTMLUmask 0022
# HTMLPerms 0777

You can think of HTMLPerms as "adding" permissions to a file, while HTMLUmask "subtracts" permissions from a file. The default HTMLUmask is 0111 (subtracting "execute" permissions across the board), so the highest permissions a file will have using the default HTMLUmask setting is 0666, even if HTMLPerms is set to 0777.

The correct setting for HTMLUmask and HTMLPerms depends on what permissions your files need to have on your server. If you uncomment both HTMLUmask and HTMLPerms and use the values above, your files should be created with 0755 permissions (which is typically what PHP files require).

Hope this helps...
auxblood
Thanks, that is very good to know. Unfortunately, even when I set HTMLPerms to 0777 and HTMLUMask to 0000, the files still get written out with 666 permissions.

This is just really strange.

Why would files I upload manually (default permissions) be able to pull in include files and files generated by MT not? And equally perplexing, why can't I even manually change the permissions on an MT-generate file using a standard FTP program?

Thanks, and great job on your Comment Replacement tags... they solved the other big mystery of MT 3.0 for me.
TweezerMan
QUOTE
Unfortunately, even when I set HTMLPerms to 0777 and HTMLUMask to 0000, the files still get written out with 666 permissions.

You may need to delete the files on the server first (the ones with 0666 permissions that you're having problems with). The mt.cfg file says that these settings are used to control permissions for files created, but says nothing about permissions for files that are modified.

You did uncomment both of those lines (remove the "#" from the beginning of the line), right? wink.gif

QUOTE
Why would files I upload manually (default permissions) be able to pull in include files and files generated by MT not?

What permissions are you seeing on files that you upload manually?

Besides permissions, another possible difference between files that you upload versus files MT generates is the owner of the file. Files you upload should be owned by you; files generated by MT are most likely owned by the web server (user "apache", for example) or the user "nobody" (unless you're running MT under cgi-wrap or suexec).

If the permissions are not correct on a web page, most web servers are configured to not allow those web pages to execute PHP instructions.
QUOTE
And equally perplexing, why can't I even manually change the permissions on an MT-generate file using a standard FTP program?

Hard to say - Does your FTP program give you any error message more informative than "Permission denied"? I'm thinking it's a symptom of your permission problem or an ownership problem (or both). What FTP program are you using?

Do you know exactly what your host's requirements are for running PHP (what permissions / ownership are required)?

QUOTE
Thanks, and great job on your Comment Replacement tags... they solved the other big mystery of MT 3.0 for me.

You're welcome! It's nice to know that it's being helpful to other MT users while the next release of MT is being worked on. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.