Please note, other than some spot testing, this has not been tested much.
By it's design, it appears that the original use case had this run as a web script whereas I am using it as a command line tool so it should be tested for the various environments/use cases.
Changes
[x] Functions grap_favicon and load now have an additional parameter, $consolemode.
[x] grap_favicon array now has an additional parameter, OVR for overwriting files. Default is false.
[x] Command Line switches are implemented. Any parameter with a space in it needs to be quoted.
Command Line Switches:
[x] --list (or -l) can be a text file with a list or URLs or a , ; or space delimited list.
[x] --path (or -p), local save path
[x] --store; store local files (alias --save) (default)
[x] --nostore; do not store local files (alias --nosave)
[x] --tryhomepage; try homepage first (defautl)
[x] --onlyuseapis; only use apis
[x] --consolemode; output regular text
[x] --noconsolemode; output html (default; subject to detect)
[x] --overwrite (overwrite local file if present)
[x] --skip (skip local file if present; default)
[x] --debug; enable debug mode
[x] --help (or -? or -h)
Other Features:
[x] Detects image format and saves the local file accordingly
[x] Detects console or HTTP/CGI mode
[x] "Console Mode" shows regular text instead of HTML
Other Items:
[x] Checks if local save path exists (if set other than default)
I've been testing pretty heavily, I've made some changes but nothing major, adding some more debug entries (mostly for me lol).
There is an issue where sometimes it takes a really long time for a download to fail but I think it's beyond the script and sometimes CURL is not honoring timeouts.
Changes since this PR
Added --curl-verbose and --user-agent command line options (--user-agent allows you to set cURL's User Agent)
Added timeout support for curl (default is still 60)
Overview
Please note, other than some spot testing, this has not been tested much.
By it's design, it appears that the original use case had this run as a web script whereas I am using it as a command line tool so it should be tested for the various environments/use cases.
Changes
grap_favicon
andload
now have an additional parameter,$consolemode
.grap_favicon
array now has an additional parameter,OVR
for overwriting files. Default isfalse
.Command Line Switches:
Other Features:
Other Items:
Usage Examples
C:\php\php.exe get-fav.php --list=sites.txt --path=icons --save --debug
C:\php\php.exe get-fav.php --list=http://www.microsoft.com,http://www.google.com --path=icons --save
Notes
I've been testing pretty heavily, I've made some changes but nothing major, adding some more debug entries (mostly for me lol).
There is an issue where sometimes it takes a really long time for a download to fail but I think it's beyond the script and sometimes CURL is not honoring timeouts.
Changes since this PR
--curl-verbose
and--user-agent
command line options (--user-agent allows you to set cURL's User Agent)set_time_limit