问题标签 [file-access]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - PHP code to restrict member access by permissions
I am building a website in PHP & mySQL. It has frontend and backend capabilities. Only admin can enter the backend by means of username and password. Now if the admin wants to add other sub-admins to the website, he could do so. By this method, a sub-admin will be able to login and perform all actions that the original admin is able to do.
WHAT I WANT TO DO:
I want to restrict the access of the sub-admins at my choice and assign them permissions so that they are able to access only certain portions of the admin panel.
EXAMPLE OF THE FEATURE THAT I AM TALKING ABOUT:
Consider that I have the following links accessible by original admin. 1. Add articles 2. Approve articles 3. Delete Articles 4. Add User 5. Edit user 6. Delete User 7. Change site settings 8. View Financial info 9. Mail center
If I do not set any permissions, then all sub-admins will be able to access all of above links. Say I create 2 sub-admins 'David' and 'Bob'.
Now I want David to access only the following desired sections of the backend:
- Add articles, 4. Add User, 7. Change site settings
Now I want Bob to access only the following desired sections of the backend:
- Add articles, 2. Approve articles, 3. Delete Articles, 4. Add User, 9. Mail center
I, being the original admin, should be able to access all sections whereas, David and Bob, should be able to see & access only the links and pages (or functionality) that have been assigned to them. I don't have a clue as to how to do this. Also, for example, if I want to restrict a sub-admin to access only 'Add articles' page, then I also want him to access the page that it posts to (considering that the input is on Add articles page) add_articles_next.php page. Also note that 'add_articles_next.php page' does not appear anywhere in the list of links. It is merely a page that is posted to from the page to which the sub-admin has access.
I understand that there is no way for the system to know that unless I explicitly specify it, but yes, that's my question. How to do it? I am not a object oriented person, so PHP code using functions will be great for me.
OTHER LIVE EXAMPLES OF THE FEATURE THAT I AM TALKING ABOUT:
I came across a feature while researching this topic. Click here to visit it. This looks like somewhat similar feature.
Thank you all in advance for any code that you can give me.
php - 如何检查文件是否被拒绝访问以及如何在php中授予文件权限(777)?
我在 ubuntu 上使用 php。当我在网页上使用任何拒绝访问的图像时,页面上会出现警告。我想在显示之前检查它,如果它没有打开权限,那么就给它打开权限。正如我们在终端命令中所做的那样。
如何检查这一点并授予对 php.ini 文件的完全访问权限。
谢谢
c# - UnauthorizedAccessException on newly created files
I have an application that is looking through some files for old data. In order to make sure we don't corrupt good projects, I'm copying the files to a temporary location. Some of the directories I'm checking are source-code directories, and they have .svn folders. We use Subversion to manage our code.
Once I've searched through all of the files, I want to delete the temp cache. Sounds easy, right?
For some reason, all of my .svn directories won't delete from the cache. They crash the app.
For reasons (too deep to go into here), I have to use the temp folder, so just "scan the original file" is out of the question for political reasons.
I can go into explorer and delete them. No problem. No warnings. Just deletes. But the code crashes with "Access to {file} is denied." I'm at my wits end with this one, so any help would be appreciated.
While I've simplified the function a LITTLE for sake of your sanity, the code REALLY is about this simple.
* Update *: The exception is UnauthorizedAccessException. The text is "Access to the path 'C:\temp\cache\some-sub-dirs\.svn\entries' is denied."
It happens under XP, XP-Pro and Windows 7.
* Update 2 * None of my validation even ATTEMPTS to look at subversion files. I do need them, however. That's part of the political crap. I have to show that EVERY file was copied... wheter it was scanned or not.
And I realize what the usual suspects are for File.Delete. I realize what UnauthorizedAccessException means. I don't have access. That's a no-brainer. But I just copied the file. How can I NOT have access to the file?
* Update 3 * The answer was in the "read-only" flag. Here's the code I used to fix it:
python - Python在目录中创建不需要的文件夹
每次我调用此方法时,Python 都会在我的目录中创建一个文件夹。该方法在我的一个需要访问服务器本地区域的 Django 应用程序中。
我想阻止它发生。
请注意:用户可以指定它是否在默认的另一个目录中。因此,默认文件夹是myFolder
,但是如果用户想要使用内部调用的文件夹myOtherFolder
(myFolder
因此~/myFolder/myOtherFolder/
),那么他们可以。这是我试图实现的那种功能,因此folder=''
如果没有参数传递给方法(我认为这是问题),我会使用。
c# - 当用户打开文件时,如何锁定对文件的访问?
我正在编写一个 C#.NET 程序,该程序使用 XmlSerializer 序列化和反序列化当前用户正在处理的项目与 XML 文件之间的关系。这工作正常,但我试图找出一种方法来防止两个用户从网络驱动器打开同一个文件并让一个用户覆盖前一个用户的保存。我本质上想要 MS Word 的行为,如果程序在打开文件时无法获得对文件的写访问权限,它会以只读模式打开文件。
那么如何锁定对文件的访问呢?我是否只是打开文件流对象并保留对它的引用?我是否继续对任何中间保存使用相同的文件流对象,而不是为每次保存打开和关闭它们?还是有其他方法可以锁定对文件的访问?
另外,即使我的应用程序崩溃,我如何确保文件被释放?这是实现 IDisposable 的好案例吗?
c# - 如何拦截对 .NET 程序中文件的访问
我需要在系统尝试访问文件时进行拦截,并在它发生之前做一些事情。
controls - 如何对文件强制执行 READ_ONCE_ONLY 内置控件?
如何控制对硬盘驱动器中文件的访问,使其只能读取一次。第一次访问后,该文件应呈现为不可访问。
php - 如何在外部项目中使用 Wordpress 的 http.php?
答:使用Curl实现...
我正在尝试从托管在另一台服务器上的管道分隔文本文件中解析数据,该文件又将插入数据库中。我猜我的主机(1and1)在php.ini中禁用了allow_url_fopen 。
错误信息 :
代码 :
Wordpress 有这个很酷的 http.php 文件。有更好的方法吗?如果没有,我该如何使用 http.php 来完成这项任务?谢谢你们..
php - 帮助使用 htaccess 和 php 保护文件访问?
我正在一个允许用户购买数字内容的网站上工作,并实施了一种尝试提供安全下载的方法。
我正在使用 CodeIgniter 强制下载如下:
当然,我确保用户在提供下载之前可以使用数据库访问文件,但我想知道是否有办法让这些文件更安全。
我正在使用大约 8-10 个字母键来创建文件路径,因此文件的 url 并不是很容易弄清楚......就像http://mysite.com/as67Hgr/asdo0980/uth89.zip
代替http://mysite.com/downloads/my_file.zip
.
另外,我使用 .htaccess 来拒绝目录浏览,如下所示Options All -Indexes
:
除此之外......我不知道要采取什么步骤。我看过文章建议使用 .htaccess 的用户名和密码方法,但我不明白如何绕过使用该方法会出现的密码提示。
我希望可能有一种方法可以使用标题和cUrl
(或类似的东西)发送用户名和密码组合,但我不知道从哪里开始。
任何帮助将不胜感激。提前致谢!
php - 用PHP下载文件的最简单方法是什么
我需要从某个 URL 下载图像到我的服务器。但是,我的服务器配置不允许我这样做:
因为,它会产生错误:
那么,我可以使用另一种不需要外部库的方法吗?
好的,我用 OIS 的解决方案解决了这个问题: