diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2009-05-27 15:43:09 +0200 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2009-05-27 15:43:09 +0200 |
commit | baffc2d1f698056f2df0a02b7bea04317bc06eb5 (patch) | |
tree | 5ccd90f27c8c17aa9f455511bed559e7da67a5e1 | |
parent | 14fdad085440068cf9ba850e42916a39310979b8 (diff) |
[NEW] new «Big Line» badge, with bested stuff from Classic Badges
-rw-r--r-- | BigLine.php (renamed from Badges_NG.php) | 85 | ||||
-rw-r--r-- | Config.BigLine.php | 63 |
2 files changed, 119 insertions, 29 deletions
diff --git a/Badges_NG.php b/BigLine.php index 802e968..efac935 100644 --- a/Badges_NG.php +++ b/BigLine.php @@ -41,7 +41,9 @@ $type=$pathinfo[2]; $style=$pathinfo[3]; $color=$pathinfo[4]; -include("Config.php"); + +include("Config.BigLine.php"); + mysql_connect(MYSQL_HOST, MYSQL_USER); mysql_select_db(MYSQL_DB); @@ -99,45 +101,70 @@ else $weeks = $duration / (60*60*24*7); $days = $duration / (60*60*24); - $TPM = floor($playcount / $months); // TRACKS PER MONTH - $TPW = floor($playcount / $weeks); // TRACKS PER WEEK - $TPD = floor($playcount / $days); // TRACKS PER DAY - define(ALBUM_TRACKS, 13); - $APD = floor($TPD / ALBUM_TRACKS); // ALBUMS PER DAY - $APM = floor($TPM / ALBUM_TRACKS); // ALBUMS PER MONTH - $APW = floor($TPW / ALBUM_TRACKS); // ALBUMS PER WEEK - - // %user <username> - // %number <number> - // %albumtrack «track»/«album» - // %dayweekmonth «day»/«week»/«month» - // %trueness «a true»/«an untrue» - // %since <month + year> - $formats = array("DEFAULT" => "%number %albumtrack per %dayweekmonth", - "Total" => "%number %albumtrack played", - "Trueness" => "%user is $trueness listener", - "Since" => "listening since %since", - "FAILBACK" => "Sorry, this $type is unavailable"); + $TracksPerDay = floor($playcount / $days); + $TracksPerWeek = floor($playcount / $weeks); + $TracksPerMonth = floor($playcount / $months); + define(TRACKS_PER_ALBUM, 13); + $AlbumsPerDay = floor($TracksPerDay / TRACKS_PER_ALBUM); + $AlbumsPerWeek = floor($TracksPerWeek / TRACKS_PER_ALBUM); + $AlbumsPerMonth = floor($TracksPerMonth / TRACKS_PER_ALBUM); + + $formats = array("DEFAULT" => "\$number \$albumtrack per \$dayweekmonth", + "Total" => "\$number \$albumtrack played", + "Trueness" => "\$username is \$trueness listener", + "Since" => "Since \$since", + "FAILBACK" => "Sorry, '\$type' is unavailable."); switch($type) { - case "(Tracks|Albums)Per(Day|Week|Month)": - $TEXT="DEFAULT"; + case "AlbumsPerDay": + case "AlbumsPerWeek": + case "AlbumsPerMonth": + case "TracksPerDay": + case "TracksPerWeek": + case "TracksPerMonth": + $format="DEFAULT"; + ereg("^(Albums|Tracks)Per(Day|Week|Month)$",$type,$match); + $albumtrack=$match[1]; + $dayweekmonth=$match[2]; + eval("\$number=\$".$albumtrack."Per".$dayweekmonth.";"); break; case "Trueness": + $format=$type; + $trueness = ($TracksPerMonth < TRUENESS ? "a true" : "an untrue"); + break; case "Since": - case "Total": - $TEXT=$type; + $format=$type; + $since=strftime("%B %Y", $statsstart); + break; + case "TotalTracks": + case "TotalAlbums": + $format="Total"; + ereg("^Total(Tracks|Albums)$",$type,$match); + $albumtrack=$match[1]; + switch ($albumtrack) + { + case "Tracks": + $number=$playcount; + break; + case "Albums": + $number = floor($number / ALBUM_TRACKS); + break; + } break; default: - $TEXT="FAILBACK"; + $format="FAILBACK"; break; } - define(ANGLE,rand(2,13)); + define(ANGLE,1); + eval("\$Lines[0]->value=\"$formats[$format]\";"); foreach ($Lines as $Line) + { $Line->font = "import/" . $Styles[$style]; + $Line->angle=ANGLE; + } $y=0; foreach ($Lines as $Line) @@ -174,7 +201,7 @@ else imagepng($img, $Cache); imagedestroy($img); - $QUERY=sprintf("REPLACE INTO badges (username, type, style, color, lastupdate, png) VALUES ('%s','%s','%s','%s', %s, '%s');", + $QUERY=sprintf("REPLACE INTO badges (username, type, style, color, lastupdate, png) VALUES ('\$s','\$s','\$s','\$s', \$s, '\$s');", $username, $type, $style, @@ -227,7 +254,7 @@ function make_db_cache($username){ if ($data['playcount'] != 0) { - $QUERY=(sprintf("REPLACE INTO users (statsstart,playcount,lastupdate,username) VALUES ('%s',%s,'%s','%s');", + $QUERY=(sprintf("REPLACE INTO users (statsstart,playcount,lastupdate,username) VALUES ('\$s',\$s,'\$s','\$s');", time(), $data['playcount'], gpc_addslashes($data['statsstart']), gpc_addslashes(strtolower($username)))); mysql_query($QUERY); } @@ -243,7 +270,7 @@ function touch_badge($username, $type, $style, $color) $hits = $data["hits"]; $hits++; - $QUERY=sprintf("UPDATE badges SET hits=%s, lasthit='%s' WHERE username='%s' AND type='$type' AND style='$style' AND color='$color';", + $QUERY=sprintf("UPDATE badges SET hits=\$s, lasthit='\$s' WHERE username='\$s' AND type='$type' AND style='$style' AND color='$color';", $hits, time(), gpc_addslashes(strtolower($username))); //echo $QUERY; mysql_query($QUERY); diff --git a/Config.BigLine.php b/Config.BigLine.php new file mode 100644 index 0000000..f4db19b --- /dev/null +++ b/Config.BigLine.php @@ -0,0 +1,63 @@ +<? + +define(TRUENESS, 4000); +define(CACHE, (3600*48)); +define(WIDTH, 300); +define(HEIGHT, 50); +putenv("GDFONTPATH=/usr/share/fonts/truetype"); + +define(CACHE_FOLDER, "/var/cache/www/Lastfm"); + +include("Config.mysql"); + +$Styles = array ("Modern" => "It_wasn_t_me", + "Letters" => "JackOLantern", + "Romantic" => "Shelley_Volante", + "Elegant" => "ITCEdScr", + "Screamy" => "Junkyard", + "Girlie" => "girlw___", + "Funny" => "PenguinAttack", + "Curly" => "Curlz___", + "Ruritania"=> "Ruritania", + "Simple" => "Georgia", + "Morpheus" => "Morpheus", + "Flamy" => "Baileysc", + "FaceLift" => "facerg__", + "TypeO" => "typeo___", + "Grindy" => "Jack_the_Hipper", + "Horrorful"=> "horrh___" + ); + +$Colors = array( + "Black" => 0x000000, + "Red" => 0xd11f3c, + "Green" => 0x32dc32, + "Yellow" => 0xdcdc32, + "Blue" => 0x3232dc, + "LightBlue" => 0x6666aa, + "Gray" => 0xdcdcdc, + "White" => 0xffffff + ); + +$Types = array( + "TotalTracks" => "Total tracks_", + "TotalAlbums" => "Total albums_", + "TracksPerDay" => "Daily tracks_", + "TracksPerWeek" => "Weekly tracks_", + "TracksPerMonth" => "Monthly tracks_", + "AlbumsPerDay" => "Daily albums_", + "AlbumsPerWeek" => "Weekly albums_", + "AlbumsPerMonth" => "Monthly albums_", + "Since" => "Since", + "Trueness" => "Trueness", + ); + +$Description = array("Trueness" => "<a href=\"http://www.last.fm/group/true+listener\">What's the heck is this </a> ?"); + +// DEFAULT VALUES // +if ($user == "") $user="gugusse"; +if (!array_key_exists($style, $Styles)) $style="TypeO"; +if (!array_key_exists($color, $Colors)) $color="Black"; +//if (!array_key_exists($type, $Types)) { $type="UNAVAILABLE" ; $color="Black" ; $username="gugusse" ; } + +?> |