Add auto-getting favicons for links
| 
		 Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB  | 
| 
		 Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB  | 
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
		 After Width: | Height: | Size: 292 B  | 
| 
		 After Width: | Height: | Size: 726 B  | 
| 
		 After Width: | Height: | Size: 726 B  | 
| 
		 After Width: | Height: | Size: 488 B  | 
| 
		 After Width: | Height: | Size: 436 B  | 
| 
		 After Width: | Height: | Size: 275 B  | 
| 
		 After Width: | Height: | Size: 229 B  | 
| 
		 After Width: | Height: | Size: 258 B  | 
| 
		 After Width: | Height: | Size: 228 B  | 
| 
						 | 
				
			
			@ -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>';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
?>
 | 
			
		||||