This is a follow on from my previous problem.
I have now managed, with help, to copy a file to a new file name.
However, the file is useless for use by the user because it is chown
apache.apache.
I need it to be
countrymusic.apache to be usable.
This is my code up to now:
PHP Code:
// CREATE CLUB CODE
$number = fopen("club_code.txt", "r");
$club_code = fgets($number);
$club_code += 1;
fclose($number);
$newnumber = fopen("club_code.txt", "w");
fputs($newnumber, $club_code);
fclose($newnumber);
$club_code = "fr".$club_code;
//CREATE NEW CLUB INPUT FILE
if($club_code != '') {
$old = 'fr_addclub.php';
$new = "add_".$club_code.".php";
copy($old, $new) or die("Unable to copy $old to $new.");
}
//CHANGE OWNERSHIP OF NEW CLUB INPUT FILE
$user_name = "countrymusic";
chown($new,$user_name) or print_r(error_get_last()); die();
This is the output of the trap:
Code:
Array ( [type] => 2 [message] => chown(): Operation not permitted [file] => /home/countrymusic/countrymusic.org.uk/html/clubs/fr_clubs/fr_admin/register-exec.php [line] => 120 )
I suspect that the reason is that only ROOT can perform this operation and the script is running as APACHE.
How can I change to root within the script ???
Can anybody help, please.