Reply to Re: PHP issues with file ownership

Your name:

Reply:


Posted by gosha bine on 05/16/07 08:03

On 15.05.2007 23:54 joniboy123 wrote:
> Hi,
>
> I have a PHP script which creates new text files in the same directory
> as itself. The new files are also PHP scripts and are built with a
> line of code within them, which runs a function when they are browsed
> to by the user.
>
> E.g. the new file's contents are similar to <?php runFunction(83); ?>
>
> However, because the new file was created by a script, it does not
> have the same owner as the and the function fails. An exact copy of
> the file uploaded from my FTP software works fine as it has the same
> owner as my script.
>
> The error I receive is that there is a safe mode restriction and the
> uid/gid does not match.
>
> I use a shared server, so am reluctant to edit the php.ini file.
>
> I have tried to 'chown' the file after creation but it fails,
> (probably because my script is not superuser).
>
>
>
> I am running out of ideas, is there another way to change the
> ownership to match? Or are there any other options that I can
> investigate?
>
>
> Thanks in advance,
> Jon
>

The simplest way to get around "safe mode" is to change the owner of
main script to www or whatever user your apache runs as. Create a file
"generate.php" with something like

<?php file_put_contents('index.php',
<<<EOF
main script goes here...
EOF
);

upload "generate.php" and run it once. You'll get "index.php" owner by
"www", so it will have full access to other www's files.


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация