Could anyone please help with a PHP lock file function ?
I want to create a symlink when a URL like this is followed (with the filename being the characters after "file="):
http://www.blah.com/download.php?file=zFZpj4b2AkEFz%2B3O
and then I need to deny access if the symlink exists ... but I'm out of my dept !
Help greatly appreciated.
See this example (comments are mine) taken from the PHP Manual for is_link()
:
<?php
$link = 'uploads';
if (is_link($link)) { // check if the link exists
echo(readlink($link)); // echo out path this link points to
// this is where you ban access
} else {
symlink('uploads.php', $link); // create the symlink
}
?>
You can execute a shell script with chmod to restrict access. Use exec function in php.
ln -s mysymlink
if [ -f mysymlink ] then
chmod 000 filenametobedenied
fi
this could be the shell script save it in the document root as filecheck.sh and run this script throgh the exec('filecheck.sh') function
ln -s mysymlink
if [ -f mysymlink ] then
chmod 000 filenametobedenied
fi
this could be the shell script save it in the document root as filecheck.sh and run this script throgh the exec('filecheck.sh') function