Rouji / single_php_filehost

Simple Filehosting Page in a Single PHP File (obvious 0x0 clone)
ISC License
235 stars 35 forks source link

Create site_url() function and use everywhere #11

Closed mulquin closed 2 years ago

mulquin commented 2 years ago

This prevents the need to manually change the protocol and build site URLs when they are needed.

The ShareX and hupl configs need testing as I don't make use of those programs.

mulquin commented 2 years ago

If you don't like the idea of a whole function for this, you could make HTTP_PROTO a ternary that sets to either http or https.

Rouji commented 2 years ago

Again, pretty sensible. I was thinking about just making it one dumb config string without any $_SERVER magic, for KISS reasons. But this gives you the choice to do either, which is nice. Will have a proper look/test tomorrow probably.

mulquin commented 2 years ago

This implementation removes HTTP_PROTO and replaces it with SITE_URL. I found going from dev/test on local machine and then deploying it, I forgot to change the string and was confused why my links weren't working lol. I understand wanting to keep it simple so this may not be the best approach for this script considering it's only an issue that happens very rarely.

Rouji commented 2 years ago

Sorry, irl stuff kind of happened. Generally lgtm, except the heredoc still has $url in it, which is now undefined

mulquin commented 2 years ago

Woops my mistake, updated :)

mulquin commented 2 years ago

I'm thinking of closing this, it throws a notice up when purging files as HTTP_HOST is not set.

Rouji commented 2 years ago

I'm thinking of closing this, it throws a notice up when purging files as HTTP_HOST is not set.

Ah yes, it does. You could just explicitly check for that though.

mulquin commented 2 years ago

Done