Add auto-getting favicons for links

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

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Regular → Executable
View File
Vendored Regular → Executable
View File
Regular → Executable
View File
+16
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;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Regular → Executable
+3 -2
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>';
Executable
+43
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);
?>
Regular → Executable
View File