Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的PHP锁文件函数_Php_Scripting_Cookies_Symlink - Fatal编程技术网

简单的PHP锁文件函数

简单的PHP锁文件函数,php,scripting,cookies,symlink,Php,Scripting,Cookies,Symlink,有人能帮我使用PHP锁文件函数吗 我想在如下URL之后创建一个符号链接(文件名为“file=”后面的字符): http://www.blah.com/download.php?file=zFZpj4b2AkEFz%2B3O 然后我需要拒绝访问,如果符号链接存在。。。但我不在我的部门 非常感谢您的帮助。您可以使用chmod执行shell脚本以限制访问。在php中使用exec函数 ln -s mysymlink if [ -f mysymlink ] then chmod 000 file

有人能帮我使用PHP锁文件函数吗

我想在如下URL之后创建一个符号链接(文件名为“file=”后面的字符):

http://www.blah.com/download.php?file=zFZpj4b2AkEFz%2B3O

然后我需要拒绝访问,如果符号链接存在。。。但我不在我的部门


非常感谢您的帮助。

您可以使用chmod执行shell脚本以限制访问。在php中使用exec函数

ln -s mysymlink
if [  -f mysymlink ] then
    chmod 000 filenametobedenied
fi 
这可能是shell脚本,将其保存在文档根目录中为filecheck.sh,并通过exec('filecheck.sh')函数运行此脚本参见以下示例(注释是我的):



这可能是shell脚本,将其保存在文档根目录中作为filecheck.sh,并通过exec('filecheck.sh')函数运行此脚本

谢谢。我不确定我是否遵循了,请详细说明一下好吗?使用shell命令创建一个shell脚本,用于创建符号链接,搜索特定文件,然后更改所需文件的权限。然后通过php中的exec函数运行该shell脚本
code
ln-s mysymlink if[-f mysymlink]然后chmod 000 filenametedenied fi
code
这可能是shell脚本,将其保存在文档根目录中为filecheck.sh,并通过exec('filecheck.sh')函数运行此脚本谢谢,我来试一试!用这个编辑你的原始答案。谢谢Treffynnon。我以前试过编辑评论,但失败了,这就是我再次发布的原因。现在我只注意到答案下面的编辑按钮。
<?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