Odświerzyłem ten skrypt - Teraz można pobrać z listy "Weekly Top Artist" w profilu www.last.fm artystę z pierwszego miejsca i wyświetlić.
Poniżej jest to zrobione dla mojego konta z loginem "bolomas". Wystarczy to zamienić na swój login.
Źródło:
<?
"Co masz zrobic zaraz, zrob jutro",
"Komu w droge temu kaloryfer",
"dzieci + zapalki = ogien wiec ogien - zapalki = dzieci"
);
// Aby użyć listy cytatów należy uzyc
// "text_main" => $cycaty[rand( 0, count( $cycaty )-1)]
// $dane : zawiera dane o wszystkich projektach do wyswietlenia na liscie
"text_main" => "Weekly Top Artist",
"kolor" => array( 100
, 10
, 0
) ), "text_main" => "Moja galeria, blog i cos tam jeszcze" ,
"progress" => 85 ,
"text_short" => "ostatnie poprawki" ),
"text_main" => "Jakis tam drugi projekt" ,
"progress" => 14 ,
"text_short" => "projektowanie" ),
"text_main" => ":[ php 5.0.5 ]:[ MYSQL 5.0.16 ]:[ ALWAYS VALID HTML & CSS ]:[ SMARTY ]:" ,
"kolor" => array( 0
, 10
, 80
) ) );
// podstawowe kolory do całego obrazka
array ( 255, 255, 255 ), // background array ( 245, 245, 245 ), // very_light array ( 230, 230, 230 ), // light array ( 180, 180, 180 ), // normal array ( 0, 0, 0 ), // ramka dla paska postepu array ( 0, 0, 0 ) // text );
for ($i=-1; $i<=count($dane); $i++) { if ($dane[$i]["text_main"] == "Weekly Top Artist") {
// Weekly Top Artist - pobierane ze strony profilu last.fm
$file = fopen("sygnaturka.tmp","r"); list
($wta['time'], $wta['artist']) = explode ("||", @fgets( $file, 1024
)); if ( (time()-604800
) > $wta['time'] OR
empty($wta['time']) ) {//604800 - tydzień w sek. $file = fopen("http://www.last.fm/user/bolomas/charts/&charttype=weekly","r"); while ( $line = @fgets($file, 1024
) ) { if ( strpos($line, '<span class="position star">1</span>') >=1
) { $line = @fgets($file, 2048
); preg_match('/<.*?a.*?href=s*?['"].*?['"].*?>(.+)</.*?a.*?>/i', $line, $match); //
<? $wta['artist'] = $match[1];
break;
}
}
$file = fopen("sygnaturka.tmp","w"); }
$dane[$i] ["text_main"] .= " - ".$wta['artist'];
break;
}
}
header("Content-type: image/png"); $im_height = count($dane) * 15
+ 10; $im_width = 480;
$im = ImageCreate( $im_width , $im_height);
//ustawiam potrzebne kolory
$background = ImageColorAllocate($im, $kolory[0][0], $kolory[0][1], $kolory[0][2]);
$very_light = ImageColorAllocate($im, $kolory[1][0], $kolory[1][1], $kolory[1][2]);
$light = ImageColorAllocate($im, $kolory[2][0], $kolory[2][1], $kolory[2][2]);
$normal = ImageColorAllocate($im, $kolory[3][0], $kolory[3][1], $kolory[3][2]);
$black = ImageColorAllocate($im, $kolory[4][0], $kolory[4][1], $kolory[4][2]);
$text = ImageColorAllocate($im, $kolory[5][0], $kolory[5][1], $kolory[5][2]);
foreach ( $dane as $projekt ) {
$y = 5 + 15 * $item;
// podľwietlenie linijki
ImagefilledRectangle($im, 0, $y + 2, $im_width , $y + 11, $very_light);
ImagefilledRectangle($im, 0, $y + 11, $im_width , $y + 12, $light);
if ($projekt["text_align_right"]) {
if (empty($projekt["progress"])) { for ( $i=1; $i <= 79
- strlen( $projekt["text_main"] ); $i++ ) $tmp .= " ";
} else {
for ( $i=1; $i <= 36
- strlen( $projekt["text_main"] ); $i++ ) $tmp .= " ";
}
$projekt["text_main"] = $tmp . $projekt["text_main"];
}
// jesli jest ustawiony specjalny kolor dla danego projektu to go ustaw
if ( !empty($projekt["kolor"]) ) { $text_spec = ImageColorAllocate($im, $projekt["kolor"][0], $projekt["kolor"][1], $projekt["kolor"][2]);
// wyľwieta nazwę / opis projektu
ImageString($im, 2, 5, $y, $projekt["text_main"], $text_spec);
} else
ImageString($im, 2, 5, $y, $projekt["text_main"], $text);
if ( !empty($projekt["progress"]) ) { // tło pod pasek postępu
ImageFilledRectangle($im, 230, $y + 2, 330, $y + 11, $light);
ImageRectangle($im, 230, $y + 2, 330 , $y + 11, $normal);
/* ustawiam kolor paska postępu
W zależnoľci od podanej w $dane liczby ustawiane jest nasycenie barw
czerwonej i zielonej. Tzn im większy procent tym więcej zielonego, a mniej
czerwonego. W rezultacie 100% = kolor zielony, a np 1% = kolor czerwony. */
$red = round( 255
- $projekt["progress"] * 255
/ 100
, true); $green = round( $projekt["progress"] * 255
/ 100
, true); $kolor_paska = ImageColorAllocate($im, $red, $green, 0);
// pasek postępu
ImageFilledRectangle($im, 230, $y + 2, 230 + $projekt["progress"], $y + 11, $kolor_paska);
ImageRectangle($im, 230, $y + 2, 230 + $projekt["progress"], $y + 11, $black);
/* wyľwietla procent i dodatkowy tekst,
a te małe if'y sš po to żeby kolumny zawsze były równo*/
if ( $projekt["progress"] <= 9 )
$projekt["progress"] = " " . $projekt["progress"];
if ( $projekt["progress"] == 100 )
$offset = 5;
if ( !empty($projekt["kolor"]) ) ImageString($im, 2, 340 - $offset, $y, $projekt["progress"] ."% ". $projekt["text_short"], $text_spec);
else
ImageString($im, 2, 340 - $offset, $y, $projekt["progress"] ."% ". $projekt["text_short"], $text);
$offset = 0;
}
$item++;
}
// rysuje ramkę
ImageRectangle($im, 0, 0, $im_width - 1, $im_height - 1, $light);
//Imagepng($im,"sygnaturka.png");
Imagepng($im);
ImageDestroy($im);
?>
A tak to wygląda w akcji (link może działać wolno albo wcale)
Piszcie co myślicie... :roll2:
Ten post edytował Jim 17.03.2006, 16:29:10