Jump to content

Writing a ".php" file with php, then changing permissions.Am I doing this right?


physaux

Recommended Posts

Hey guys, I want to create a PHP file, and then chance its permissions.

I am doing this because I want to "update" a file that will be included in other pages.

I want to set a cronjob to do this once a day or such, so I need to be sure that the permissions will be set properly so that nobody else can activate/ see that file. Here is what I have so far:

 

<?php
$myFile = TEMPVARIABLESNAME;  // is something like "temp.php"
$filepermissions = TEMPFILEPERMISSIONS;  // is a int value, such as 700

$fh = fopen($myFile, 'w');
$tempstring = '<?php';
//...
$tempstring.= '?>';
fwrite($fh, $tempstring);
fclose($fh);
chmod($myFile, $filepermissions);
?>

 

 

Which permissions level should I set for a file that I only want to be accessible from other files "include()"ing it?

 

Any suggestions? thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.