From 073837369020369dedd25f26e8d826e691f20d61 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Sat, 6 Nov 2010 18:55:00 +0000 Subject: [PATCH] * More consistent way of getting favicons, through Google * Colors tweak in charts git-svn-id: http://yourls.googlecode.com/svn/trunk@521 12232710-3e20-11de-b438-597f59cd7555 --- includes/functions-infos.php | 22 +++++++++++++++++----- yourls-infos.php | 5 +++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/includes/functions-infos.php b/includes/functions-infos.php index 9698798..94c35bc 100644 --- a/includes/functions-infos.php +++ b/includes/functions-infos.php @@ -147,6 +147,8 @@ function yourls_stats_line( $values, $legend1_list, $legend2_list ) { 'chxt'=> 'x,x,y', 'chd' => 't:'.( join(',' , $values ) ), 'chds' => '0,'.$max, + 'chm' => 'B,E3F3FF,0,0,0|o,5FA3C6,0,-1,6|o,FFFFFF,0,-1,4', + 'chco' => '5FA3C6', 'chxl'=> '0:|'. $legend1 .'|1:|'. $legend2 .'|2:|'. $label_clicks ); $line_src = 'http://chart.apis.google.com/chart?' . http_build_query( $line ); @@ -172,15 +174,25 @@ function yourls_stats_get_best_day( $list_of_days ) { // Return domain of a URL function yourls_get_domain( $url, $include_scheme = false ) { $parse = parse_url( $url ); - $host = $parse['host']; - $scheme = $parse['scheme']; - - if ( $include_scheme ) + + // Get host & scheme. Fall back to path if not found. + $host = isset( $parse['host'] ) ? $parse['host'] : ''; + $scheme = isset( $parse['scheme'] ) ? $parse['scheme'] : ''; + $path = isset( $parse['path'] ) ? $parse['path'] : ''; + if( !$host ) + $host = $path; + + if ( $include_scheme && $scheme ) $host = $scheme.'://'.$host; return $host; } +// Return favicon URL +function yourls_get_favicon_url( $url ) { + return 'http://www.google.com/s2/u/0/favicons?domain=' . yourls_get_domain( $url, false ); +} + // Scale array of data from 0 to 100 max function yourls_scale_data( $data ) { $max = max( $data ); @@ -218,4 +230,4 @@ function yourls_array_granularity( $array, $grain = 100, $preserve_max = true ) } } return $array; -} \ No newline at end of file +} diff --git a/yourls-infos.php b/yourls-infos.php index 1f205fe..a0a8a15 100644 --- a/yourls-infos.php +++ b/yourls-infos.php @@ -194,7 +194,7 @@ if( count( $keyword_list ) > 1 ) echo ' '; } ?> -

Long URL:

+

Long URL:

@@ -481,7 +481,8 @@ $i = 0; foreach( $referrer_sort as $site => $count ) { $i++; - echo "
  • $site: $count (details)
  • \n"; + $favicon = yourls_get_favicon_url( $site ); + echo "
  • $site: $count (details)
  • \n"; echo "