-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
executable file
·55 lines (39 loc) · 1.28 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
error_reporting(0);
// Change the location where images are stored/retrieved
//$_CACHE_PATH = "../favicon_cache"; // one directory up
//$_CACHE_PATH = "./folder/favicon_cache/"; // one directory down
$_CACHE_PATH = "cache"; // current directory
if (!isset($_GET['url'])) die();
if (substr( $_GET['url'], 0, 4 ) !== "http") {
$_GET['url'] = "http://".$_GET['url'];
}
$parse = parse_url($_GET['url']);
$domain = $parse['host'];
if (isset($_GET['refresh'])) {
@unlink('../'.$_CACHE_PATH.'/'.$domain);
}
if (isset($_GET['debug'])) {
require 'FaviconDownloader.php';
$_favicon = new FaviconDownloader($_GET['url']);
$_favicon->debug();
die();
}
if (file_exists($_CACHE_PATH.'/'.$domain)) {
//show cached copy first!
header('Content-Type: image/png');
echo file_get_contents($_CACHE_PATH.'/'.$domain);
die();
}
require 'FaviconDownloader.php';
$favicon = new FaviconDownloader($_GET['url']);
if($favicon->icoExists){
if (!file_exists($_CACHE_PATH.'/'.$domain)) {
file_put_contents($_CACHE_PATH.'/'.$domain, $favicon->icoData);
}
header('Content-Type: image/png');
echo file_get_contents($_CACHE_PATH.'/'.$domain);
} else {
header('Content-Type: image/png');
echo file_get_contents('default.png');
}