Currently I have a search engine script set in the root folder. When a search is conducted it automatically writes folders and files relating to the variables entered for the search.
Then if exactly the same search is entered again at a subsequent time, the script automatically fpassthru()the relevant file.
The problem I have is that when the script writes the folders and files, the owner is always "www", which leaves me without the usual access for deleting, changing perms etc etc.
As you can imagine the size of this stored data could well get out of hand, and I therefore wish to be able to periodically delete so of the folders and files.
I've considered putting chown() into the script but was advised this cause a serious security issue.
So somehow I need to be able to turn these files into my ownership without compromising security.
I was wondering if there was a way to do it via a .htaccess file.
Or
If it would be easy to create a script which would spider the huge number of files and folders and change all their ownerships at once.
I would guess there must be a simple solution, as I would have thought this problem could be quite common.
Here is the excert from the script which writes the folders and then the files (if its of any use!):
if(!file_exists($cachedirectory)) // check to see if the directory already exists
{
$directorypieces = explode("/", $cachedirectory); //break the directory path into pieces
foreach($directorypieces As $folder) //run through the pieces
{
$folder1 = "/" . $folder; //add each folder in order of appearance
$folder2 = $folder2 . $folder1;
$folder3 = "/home/chilli/chillisauce-www" . $folder2;
if(!file_exists($folder3)) //check to see if folder exists
{
mkdir($folder3, 0777); //create a folder if it doesn't
}
}
$fp = fopen($cachefilepath, "w"); //create and open the file
fwrite($fp, $Output); //Write output to the file and close
fclose($fp);