Asked  7 Months ago    Answers:  5   Viewed   34 times

Background: I've got some code that checks to see if a user has a valid session before processing the php page that I would like to set as the auto_prepend_file. However, I need to exclude the page where the user attempts to login from requiring a valid session. I would like to be able to set the auto_prepend_file value on an per directory basis.

Environment: PHP 5.2.6m Apache 2, running php as a cgi not as mod_php, on Windows (if that matters) and on a machine that I have complete control over (not a hosted environment)

Using a htaccess file is out b/c I am not using mod_php. I have not been able to alter the in php.ini to set the auto_prepend_file, the server throws an internal error. And ini_set() does not work b/c it has already loaded the session checking file before I can change the value of auto_prepend_file.

I do not see a way to set auto_prepend_file on a per directory basis if you are not using mod_php/htaccess. Am I missing something?

 Answers

71

Use .user.ini files.

http://php.net/manual/en/configuration.file.per-user.php

Wednesday, March 31, 2021
 
sohum
answered 7 Months ago
38

This will allow either someone from IP 127.0.0.1 or logged as a valid user. Stick it either in your config or .htaccess file.

    <Files learn.php>
        Satisfy any
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1

        AuthType Basic
        AuthName "private"
        AuthUserFile /var/www/phpexperts.pro/.htpasswd
        AuthGroupFile /dev/null
        Require valid-user
    </Files>

IP Alone:

    <Files learn.php>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Files>

That definitely answers your question.

Wednesday, June 30, 2021
 
nhunston
answered 4 Months ago
45

Can I successfully configure Apache/PHP to respond to this request?

Yes. Just use the MultiviewsMatch directive to tell Apache that it can serve .php files regardless of whether their MIME type is compatible with the Accept header:

<Files "*.php">
    MultiviewsMatch Any
</Files>

From the docs, the effect is as follows:

You may finally allow Any extensions to match, even if mod_mime doesn't recognize the extension.

Saturday, July 31, 2021
 
Jens
answered 3 Months ago
87

On the server I ran sudo chown -R git:git /srv/git/ - this fixed my problem but I am wondering if this was the correct thing to do?

Absolutely. The problem previously was that the git user, who you're logging in as via SSH, could not write to the repository.

Depending on your needs, you may consider different combinations of users and SSH keys, or one of the many additional programs (gitolite etc) that can be used to more finely control access.

Wednesday, September 8, 2021
 
Shimmy Weitzhandler
answered 2 Months ago
94

It looks like your p4settings.txt config file isn't being used; otherwise the client name returned by "p4 info" would match the P4CLIENT value in the config file. Run:

p4 set P4CONFIG=p4settings.txt

and make sure that when you run "p4 info" you're doing it from a directory underneath ~/dev/trunk. (Your "p4 info" output in the question shows your current directory as /Applications, so that might explain the problem on its own -- just do "cd ~/dev/trunk" and try again.)

The "client unknown" error suggests that maybe your client spec got deleted (this is assuming you're connecting to the same server and using the same client name you were successfully using before). If that's what happened you can create a new one with the same name by running:

p4 client
Tuesday, September 28, 2021
 
Stubbi
answered 4 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :