use PHP to create new pages?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
William_I
Forum Newbie
Posts: 13
Joined: Sat Mar 29, 2003 8:22 am
Location: Manhattan

use PHP to create new pages?

Post by William_I »

hello... I'm more used to the Windows/ColdFusion world... so please excuse the nature of this nOOb question...

I'm helping to expand the capabilities of an XMB-driven online community. One new feature will be free blogs for members of a predefined status. I have some decent bloggin software (pMachine) and would like to create a PHP app that generates new blogs in a completely hands-off way. However, when I used the PHP script to write the new source pages for the blog (name.php), the premissions are set to Apache on the Linux server, not the admin of the virtual domain, which screws up subsequent blog scripts.

Is there a safe way where PHP can control setting the permissions of these newly created files? For now, I SSH to the machine (which I run) and chown * with the appropriate username. While this works, it requires a level of intervention I'd like to avoid.

Thanks.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

You will need to create a process (method/script) that runs a few of the common *nix commands:

Ref : int chmod ( string filename, int mode)
http://uk2.php.net/manual/en/function.chmod.php

Ref : int chgrp ( string filename, mixed group)
http://uk2.php.net/manual/en/function.chgrp.php

Ref : int chown ( string filename, mixed user)
http://uk2.php.net/manual/en/function.chown.php

The generally take the same params as the CLI versions.

Regards,

EDIT>
To try and understand your issue a little better, it may be a job for Apache, or cause problems with apache.

If you have setup some kind of virtual hosting then there are synergies between the OS (adding users) and Apache (using /home/ dirs), but I'd need a better understanding of your system to confirm.
<END
Last edited by cactus on Tue Jul 01, 2003 12:25 pm, edited 1 time in total.
William_I
Forum Newbie
Posts: 13
Joined: Sat Mar 29, 2003 8:22 am
Location: Manhattan

Post by William_I »

I've tried that, and I get a safeMode message that the command is not allowed.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

... note to self: should not edit before checking if OP has replied, doh!

Sorry, what I was adding was, your apache will be running as one user, and as such the files have to be owned by the same user as Apache, unless you have created some sort of virtual hosting system.

Regards,
William_I
Forum Newbie
Posts: 13
Joined: Sat Mar 29, 2003 8:22 am
Location: Manhattan

Post by William_I »

Sorry, I should have supplied more info.

Yes, it is a virtual host scenario running under the Ensim WEBppliance control panel. I own (well lease) and operate the machine. So, the Linux owner of the files in this site is "adminX", and the owner of the php files written by the script is "Apache".

The ultimate goal is to offer a "Start Blog" button for community members that have achieved a certain status or rank. The blog databases would be populated with the user preferences from the forum database, and appropriate blog-specific files written automatically... hands off.
William_I
Forum Newbie
Posts: 13
Joined: Sat Mar 29, 2003 8:22 am
Location: Manhattan

Post by William_I »

-sorry problem solved-

As I reread my response above, I though to myself... "Wait a minute, I own this damn machine and can do what I want."

So I changed ownership of everything in the blog directory to Apache and all seems well. (Until Ensim chokes on it)
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

I'm unsure why you feel the files have to be (ch)owned. The (blog) files will still need to be owned by the "Apache" user to run, if so just ensure that any files created by the "Start Blog" system are owned by "Apache".

Does your "Start Blog" operation run outside of the Apache environment ?

Regards,

EDIT> Posted too late! ;)
William_I
Forum Newbie
Posts: 13
Joined: Sat Mar 29, 2003 8:22 am
Location: Manhattan

Post by William_I »

After uploading and running the installer, some critical includes and write-to files were owned by "adminX", and new files being created by the blog-wizard are owned by "apache". The blog-wizard runs under Apache, so yeah, this way now makes sense. -duh-
Post Reply