gaffling / PHP-Grab-Favicon

🖼 Saves the favicon of the given URL and returns the image path.
http://suchmaschine.biz
MIT License
26 stars 6 forks source link

Web Mode (Not-Console/CLI) #11

Open LeeThompson opened 1 year ago

LeeThompson commented 1 year ago

The original design of get-fav.php seems to have been to be used on a web server. The command line switches aren't very useful in this mode so I'm designing a system for processing options in "web mode".

There will be a master switch to enable these new options, it will default to disabled for security reasons.

define('ENABLE_WEB_INPUT', false);

My current thought is to have options come in over the query string and/or form fields. I have not go into any specifics yet but they will likely follow the general syntax of the command line switches.

I don't really use the script this way so this is a chance for comments/suggestions/notes.

I don't plan on adding security checks to the script itself for incoming requests as that should be handled by the server configuration (htaccess or whatever). I do plan on having some checks with paths, especially for anything that can write.

gaffling commented 1 year ago

That sounds good to me!

Let me ask, what is your use case for getting all favicons of a list?

LeeThompson commented 1 year ago

My personal use case is command line driven, I give it a list and run it in a window. More specifically, I found PHP-Grab-Favicon for a project, I'm converting my old HTML based bookmark page to Dasherr and wanted a way to more easily download icons for use on it.

But I do notice the PHP-Grab-Favicon a lot of web-mode stuff and I don't want to trounce on that so I'm thinking it should be able to do more stuff in that mode too. I don't really have a use case for it in that mode which is partially why I opened this as an issue so we (and others) could talk about it.

My intention is to have it, by default, work like it does now, for security reasons. But if with define('ENABLE_WEB_INPUT', true); it should be able to do everything you can do in console/command line mode (although the input mechanics would be different of course). Like I was thinking for a list of URLs, it would accept a form submit from a textarea or something.

gaffling commented 1 year ago

Let us glue your and my version together, I'm fine and happy with it if you will push your version also into this repo 🥇

LeeThompson commented 1 year ago

That's the plan, I just have more stuff to do and test before I do a PR.

LeeThompson commented 1 year ago

If anyone uses get-fav.php in web mode please share your use cases, does it need more functionality?

LeeThompson commented 1 year ago

As stated above, I don't personally use the script in an HTTP/HTML context but others might. If this is you and you're reading this please feel free to add comments on what you think.

Proposed Web Variables

(This is incomplete, mostly a placeholder for now)

Variable Internal/INI File Switch Comments
DEBUG debug --debug Enables special debug mode