PrivateBin
PrivateBin copied to clipboard
[fix] Do not create .htaccess with Nginx
I use editorConfig but I'm not sure for indentation ?
added by @rugk:
replaces PR https://github.com/PrivateBin/PrivateBin/pull/223 fixes https://github.com/PrivateBin/PrivateBin/issues/222
It should do that automatically. That's the whole purpose of this tool.
Thanks for the fixes. Still TODO:
- [ ] detect server version https://github.com/PrivateBin/PrivateBin/pull/226#discussion_r114010427 (if you want)
- [ ] autodetection of server https://github.com/PrivateBin/PrivateBin/pull/226#discussion_r114009918
Thanks for working on this!
The logic of the WebServer class looks quite clean, with my only suggestion being to maybe change the fixed version regex compare to the version_compare one, so it works with future apache versions, too.
Note that .htaccess files may need to be created in various places, not just in the web root, so there should be a mechanism to pass the absolute path into the $file
in canHtaccess()
.
The name canHtaccess()
is also a bit misleading. The "can" prefix would indicate that it is a test and returns a boolean, while it actually just writes a file, if needed. How about a name that more clearly describes its function? In the end it abstracts a mechanism to restrict access across various webserver types, so something like restrictAccessTo($path)
would semantically make more sense.
That aside, I can write the unit tests for this before merging it, if you want.
Yes, is a good idea for change name for this function. restrictAccessTo() is a good name for me.
I also think that I have written badly name of my WebServer function. Would it be more logical to write it ServerWeb as for ServerSalt? if that's okay, I'll rename the file too.
I would like to write the tests, but I can't get them to work properly. I want you to write them;)
Okaydoky on the tests, WebServer as class name is fine by me, as we usually do call these objects "web servers". ;-)
PS: I am now starting to reconsider renaming ServerSalt to simply Salt, since that class is now used to generate the paste salts, too, and not only for the instance wide salt.
i will add $path for a restrictAccessTo() function, but for the moment, i don't know how to added neatly into lib/Model/Paste.php
@magikcypress Any chance you can have a look at finishing the PR?
I don't know, i haven't a lot anytime for patch this PR, sorry.
In fact, i don't know how get a variable $_path in my code for to be used a WebServer class anywhere ?
@magikcypress Are you still interested in completing this? If not, that's no problem, just add a notice, so I know what the current status of this PR is.