Drake CMS Official Forums - read-only archive

You are reading the Drake CMS Official Forums archive, available for historical purposes only.

Drake CMS has been rebranded into Lanius CMS, visit the new Lanius CMS Official Forums if you need support about Lanius CMS or Drake CMS -> Lanius CMS migration.



Home page Off-topic Dicussions > How to take back control of files created by PHP Permanent link to this page
 
 
Author Message:
legolas558
How to take back control of files created by PHP
18 June 2007 07:33
Anonymous On some hosts (mostly shared linux hosts not using the SuExec mode) the PHP user is nobody and has write permissions; the FTP user is instead a proper user and cannot edit or delete files created by any other user (also nobody).

In this situation files created by PHP (so, by Drake CMS or veloce.php or any other PHP script you might run) cannot be changed by your FTP user and you should fix the issue via PHP. Note: This is not a Drake CMS or veloce.php issue but a host provider issue.

You can chown all the files to your proper FTP user with the following script (to be placed in the root folder):
Code:

<?php

function chown_all($path, $user) {
$handle = opendir($path);
$noerror = chown($path, $user);
if (!$noerror) return false;
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') continue;
if (is_dir($path.$file)) {
$noerror = chown_all ($path.$file."/", $user);
if (!$noerror) break;
} else {
$noerror = chown($path.$file, $user);
if (!$noerror) break;
}
}
closedir($handle);
return $noerror;
}

// get the path of the current folder
$path = dirname(__FILE__).'/';

// insert your FTP username below here
$user = ;

if (!chown_all($path, $user))
die('Cannot chown_all '.$path);



You will have to set $user to your FTP user before running the script.
 
marc
Re: How to take back control of files created by PHP
19 June 2007 21:54
Anonymous Sorry legolas558,

where it functions, one will not need it, where one could need it, it does not function.
When the Apache could give the rights at his files arbitrary other users, would be to Hackers in this way opened door and gate.
Good approach, however one already needs optimized webspace without restrictions

Greetings from Germany
Marc
 
transdrake
Yanıt : How to take back control of files created by PHP
20 June 2007 00:41
Anonymous Thanks (even I did not try it) cos I really need it cos of my non SuExec hosting that I cant run Drake stable.

But matter is I'm not familiar with web languages and I dont know where to replace the correct things.

Just for a little example before or after ";" smileI know, ok too much inexperienced smile
Could you please send the same code with username "MYNAME" and path "EXAMPLEDOMAIN.COM/DRAKE"

I'll be pleased and can edit it much more easier without causing a trouble in my folders.

Regards
 
trex1512
Re : Yanıt : How to take back control of files created by PHP
21 June 2007 01:24
Anonymous Hi

You don't need to add the domain name or path just the user name.

<?php

function chown_all($path, $user) {
$handle = opendir($path);
$noerror = chown($path, $user);
if (!$noerror) return false;
while (false !== ($file = readdir($handle))) {
if ($file[0] == '.') continue;
if (is_dir($path.$file)) {
$noerror = chown_all ($path.$file."/", $user);
if (!$noerror) break;
} else {
$noerror = chown($path.$file, $user);
if (!$noerror) break;
}
}
closedir($handle);
return $noerror;
}

// get the path of the current folder
$path = dirname(__FILE__).'/';

// insert your FTP username below here
$user = MYNAME;

if (!chown_all($path, $user))
die('Cannot chown_all '.$path);
?>


 
legolas558
Re: How to take back control of files created by PHP
21 June 2007 21:15
Anonymous Quote:

Sorry legolas558,

where it functions, one will not need it, where one could need it, it does not function.
When the Apache could give the rights at his files arbitrary other users, would be to Hackers in this way opened door and gate.
Good approach, however one already needs optimized webspace without restrictions

Greetings from Germany
Marc


... it's mostly an Apache configuration problem, as far a s I know sad
 
Top