开发者

Simple PHP lock file function

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.p开发者_运维问答hp?file=zFZpj4b2AkEFz%2B3O

and then I need to deny access if the symlink exists ... but I'm out of my dept !

Help greatly appreciated.


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


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
}
?>


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜