/    Sign up×
Community /Pin to ProfileBookmark

can PHP submit secured folder credentials?

As the title says – I have a password protected folder setup using my cPanel tools. When I attempt to access the folder a dialog pops up which is what I fully expect. Now I am wondering if, for certain scripts that attempt to call scripts contained in this protected folder, PHP can do something to submit the uid/pswd so that the security is satisfied and the protected folder can then be accessed without the dialog popping up.

Is this doable?

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 21.2016 — Is this securing done via HTTP Authentication? If so, PHP does have some functions, though it's been literally years since I did anything with them and have no recollection as to how easy/difficult it was: http://php.net/manual/en/features.http-auth.php
Copy linkTweet thisAlerts:
@ginerjmauthorJan 21.2016 — As I mentioned - my hoster's cPanel product gives me the ability to setup folder security. I believe it is being done via the .htaccess file in the particular folder and the passwd file contained in my site's .htpasswds folder for that particular folder as well. Here is the .htaccess file in the secured folder:
<i>
</i>AuthUserFile "/xxx/yyy/.htpasswds/public_html/homejg/pools/passwd"
AuthType Basic
AuthName "folder pools"
require valid-user
Copy linkTweet thisAlerts:
@rtretheweyJan 22.2016 — You can add the user name and password to the URL passed by your PHP code, as in:

https://username:[email protected]/

Your PHP code will need to create a 'user' with cURL (or ??) to support the authentication for continued/subsequent access.
Copy linkTweet thisAlerts:
@NogDogJan 22.2016 — I'm thinking the simplest solution would be to contrive a way where you could include()/require() the protected file, as opposed to actually accessing it via HTTP (since HTTP authentication -- which that is -- is only triggered by the web server, not by a file system call). It could simply(?) be a file-handler script in your login-controlled PHP area that accepts a parameter that indicates which page to load, and then readfile()'s it.
Copy linkTweet thisAlerts:
@ginerjmauthorJan 22.2016 — So - it looks like the answer is "No". Too bad - oh, well....
Copy linkTweet thisAlerts:
@NogDogJan 22.2016 — I'm not seeing a way to do it from the server side, since HTTP authentication is based on headers exchanged between the browser and the server -- unless there's some what to figure out what those headers would be, and then send them via PHP's header() function upon a successful login?
Copy linkTweet thisAlerts:
@ginerjmauthorJan 22.2016 — Beyond my pay grade. Just thought/hoped someone knew how this might be done on the forum.

I'll just have to re-think the organization of my files when I get too tired of having to provide the creds.

Thanks for trying.
Copy linkTweet thisAlerts:
@web-designingJan 22.2016 — Thanks ! for sharing details

[URL="http://www.rationaltechnologies.com/"]

Web Design Company Hyderabad[/URL]
×

Success!

Help @ginerjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...