Add auto-getting favicons for links

This commit is contained in:
mirivlad 2023-08-21 16:18:47 +03:00
parent 0595a64f93
commit 12e0a58258
20 changed files with 62 additions and 2 deletions

0
128.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

0
README.md Normal file → Executable file
View File

0
assets/css/style.css Normal file → Executable file
View File

0
assets/img/fav.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

0
assets/js/iconify.js Normal file → Executable file
View File

0
assets/js/jquery.js vendored Normal file → Executable file
View File

0
assets/js/script.js Normal file → Executable file
View File

16
get_fav.php Normal file
View File

@ -0,0 +1,16 @@
<?php
function save_favicon($url, $path='./ico/') {
$url = parse_url($url, PHP_URL_HOST);
$file = $path.$url.'.png';
if ( !file_exists($file)) {
$fp = fopen ($file, 'w+');
$ch = curl_init('http://www.google.com/s2/favicons?domain='.$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_FILE, $fp); /* Save the returned Data to File */
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
return $file;
}

BIN
ico/hd.kinopoisk.ru.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

BIN
ico/mail.google.com.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

BIN
ico/mail.yandex.ru.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

BIN
ico/music.yandex.ru.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

BIN
ico/ok.ru.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

BIN
ico/vk.com.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

BIN
ico/www.printables.com.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
ico/www.thingiverse.com.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

BIN
ico/youtube.com.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

5
index.php Normal file → Executable file
View File

@ -1,6 +1,7 @@
<?php
include "vars.php";
include "parse.php";
include "quotes.php";
include "get_fav.php";
?>
<!DOCTYPE html>
<html lang="ru">
@ -54,7 +55,7 @@ include "parse.php";
echo '<div class="links-item">';
echo '<h4>'.$cat.'</h4>';
foreach ($val as $link){
echo '<a id="link" href="'.$link['url'].'">'.$link['name'].'</a>';
echo '<a id="link" href="'.$link['url'].'"><img src="'.save_favicon($link['url']).'" style="width:16px;vertical-align: middle; margin-right: 0.5rem;" >'.$link['name'].'</a>';
}
echo '</div>';

43
quotes.php Executable file
View File

@ -0,0 +1,43 @@
<?php
function getElementByClassname ($html, $classname) {
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
$nodes = $xpath->query('//div[@class="' . $classname . '"]');
$tmp_dom = new DOMDocument();
foreach ($nodes as $node) {
$tmp_dom->appendChild($tmp_dom->importNode($node, true));
break;
}
return trim($tmp_dom->saveHTML());
}
$random = rand()&1;
$url= '';
$pre_quote = '';
$quote = "";
$class = '';
if ($random == 0){
$url = "http://ipfw.ru/bash/random";
$pre_quote = "from ipfw.ru/bash:<br><hr style='width: 33%;'>";
$class = "quotebody";
}else{
$url = "http://ibash.org.ru/random.php";
$pre_quote = "from iBASH:<br><hr style='width: 33%;'>";
$class = "quotbody";
}
$data = "";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'
));
$data = curl_exec($curl);
curl_close($curl);
$quote = $pre_quote.getElementByClassname($data, $class);
?>

0
vars.php Normal file → Executable file
View File