Author: Tom Nedvěd (http://programator.ne2d.cz)
Inheritance: extends Control
Beispiel #1
0
    public static function render_sidebar($LastFMUsername, $UserID, $OwnProfile)
    {
        $LastFMInfo = LastFM::get_user_info($LastFMUsername);
        ?>
		<div class="box box_info box_lastfm">
			<div class="head colhead_dark">Last.fm</div>
			<ul class="stats nobullet">
				<li>
					Username: <a id="lastfm_username" href="<?php 
        echo $LastFMInfo['user']['url'];
        ?>
" target="_blank" class="tooltip" title="<?php 
        echo $LastFMInfo['user']['name'];
        ?>
 on Last.fm: <?php 
        echo number_format($LastFMInfo['user']['playcount']);
        ?>
 plays, <?php 
        echo number_format($LastFMInfo['user']['playlists']);
        ?>
 playlist<?php 
        echo $LastFMInfo['user']['playlists'] != 1 ? 's' : '';
        ?>
."><?php 
        echo $LastFMUsername;
        ?>
</a>
				</li>
				<div id="lastfm_stats"<?php 
        echo $OwnProfile ? ' data-uid="1"' : '';
        ?>
>
				</div>
				<li>
					<a href="#" id="lastfm_expand" onclick="return false;" class="brackets">Show more info</a>
<?php 
        //Append the reload stats button only if allowed on the current user page.
        $Response = G::$Cache->get_value("lastfm_clear_cache_{$UserID}");
        if (empty($Response)) {
            ?>
					<span id="lastfm_reload_container">
						<a href="#" id="lastfm_reload" onclick="return false;" class="brackets">Reload stats</a>
					</span>
<?php 
        }
        ?>
				</li>
			</ul>
		</div>
<?php 
    }
Beispiel #2
0
    ?>
				<li<?php 
    echo $Override === 2 ? ' class="paranoia_override"' : '';
    ?>
>Warning expires in: <?php 
    echo time_diff(date('Y-m-d H:i', strtotime($Warned)));
    ?>
</li>
<?php 
}
?>
			</ul>
		</div>
<?php 
// Last.fm statistics and comparability
$LastFMUsername = LastFM::get_lastfm_username($UserID);
if ($LastFMUsername) {
    LastFMView::render_sidebar($LastFMUsername, $UserID, $OwnProfile);
}
if (check_paranoia_here('requestsfilled_count') || check_paranoia_here('requestsfilled_bounty')) {
    $DB->query("\n\t\tSELECT\n\t\t\tCOUNT(DISTINCT r.ID),\n\t\t\tSUM(rv.Bounty)\n\t\tFROM requests AS r\n\t\t\tLEFT JOIN requests_votes AS rv ON r.ID = rv.RequestID\n\t\tWHERE r.FillerID = {$UserID}");
    list($RequestsFilled, $TotalBounty) = $DB->next_record();
} else {
    $RequestsFilled = $TotalBounty = 0;
}
if (check_paranoia_here('requestsvoted_count') || check_paranoia_here('requestsvoted_bounty')) {
    $DB->query("\n\t\tSELECT COUNT(RequestID), SUM(Bounty)\n\t\tFROM requests_votes\n\t\tWHERE UserID = {$UserID}");
    list($RequestsVoted, $TotalSpent) = $DB->next_record();
    $DB->query("\n\t\tSELECT COUNT(r.ID), SUM(rv.Bounty)\n\t\tFROM requests AS r\n\t\t\tLEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID AND rv.UserID = r.UserID\n\t\tWHERE r.UserID = {$UserID}");
    list($RequestsCreated, $RequestsCreatedSpent) = $DB->next_record();
} else {
Beispiel #3
0
<?php

$core = Core::getInstance();
$core->loadModule('org.sygil.lastfm');
$lastfm = new LastFM();
$lastfm->setMode('top_artist');
$lastfm->setUser('Ashaan');
$lastfm->setTheme('blue');
$core->setContent($lastfm);
Beispiel #4
0
<?php

define('LIMIT', 100);
//$Limit = isset($_GET['limit']) ? intval($_GET['limit']) : 100;
//$Limit = in_array($Limit, array(100, 250, 500)) ? $Limit : 100;
$Category = isset($_GET['category']) ? $_GET['category'] : 'weekly';
$Category = in_array($Category, array('all_time', 'weekly', 'hyped')) ? $Category : 'weekly';
$View = isset($_GET['view']) ? $_GET['view'] : 'tiles';
$View = in_array($View, array('tiles', 'list')) ? $View : 'tiles';
switch ($Category) {
    case 'weekly':
        $Artists = json_decode(LastFM::get_weekly_artists(LIMIT), true)['artists']['artist'];
        break;
    case 'hyped':
        $Artists = json_decode(LastFM::get_hyped_artists(LIMIT), true)['artists']['artist'];
        break;
    default:
        break;
}
View::show_header("Last.fm", "jquery.imagesloaded,jquery.wookmark,top10", "tiles");
?>
<div class="thin">
	<div class="header">
		<h2>Last.fm</h2>
<?php 
Top10View::render_linkbox("lastfm");
?>
	</div>
<?php 
Top10View::render_artist_links($Category, $View);
Top10View::render_artist_controls($Category, $View);
Beispiel #5
0
<?php

$Concerts = '';
ob_start();
$ArtistEvents = LastFM::get_artist_events($ArtistID, $Name);
$Hidden = false;
if ($ArtistEvents === false) {
    // Something went wrong
    echo '<br />An error occurred when retrieving concert info.<br />';
} elseif (!isset($ArtistEvents['events']['event'])) {
    // No upcoming events
    echo '<br />This artist has no upcoming concerts.<br />';
    $Hidden = true;
} else {
    echo '<ul>';
    if (isset($ArtistEvents['events']['event'][0])) {
        // Multiple events
        foreach ($ArtistEvents['events']['event'] as $Event) {
            make_concert_link($Event);
        }
    } else {
        // Single event
        make_concert_link($ArtistEvents['events']['event'], $Name);
    }
    echo '</ul>';
}
$Concerts .= ob_get_clean();
?>

<div class="box">
	<div id="concerts" class="head">
Beispiel #6
0
    case 'lastfm_top_artists':
        if (isset($_GET['username'])) {
            echo LastFM::get_top_artists($_GET['username']);
        }
        break;
    case 'lastfm_top_albums':
        if (isset($_GET['username'])) {
            echo LastFM::get_top_albums($_GET['username']);
        }
        break;
    case 'lastfm_top_tracks':
        if (isset($_GET['username'])) {
            echo LastFM::get_top_tracks($_GET['username']);
        }
        break;
    case 'lastfm_clear_cache':
        if (isset($_GET['username']) && isset($_GET['uid'])) {
            echo LastFM::clear_cache($_GET['username'], $_GET['uid']);
        }
        break;
    case 'take_donate':
        break;
    case 'take_update_rank':
        break;
    default:
        if (isset($_REQUEST['id'])) {
            include SERVER_ROOT . '/sections/user/user.php';
        } else {
            header('Location: index.php');
        }
}
 /**
  * Handle requests to methods
  */
 public function __call($name, $args)
 {
     // Include default arguments
     $default_args = array('format' => 'json');
     $args[0] = array_merge($default_args, (array) $args[0]);
     return parent::__call($name, $args);
 }
Beispiel #8
0
#!/usr/bin/env php
<?php 
require 'lib/Spotify.php';
require 'lib/LastFM.php';
$lastFm = new LastFM('***');
$tracks = $lastFm->userGetRecentTracks('Hanse');
file_put_contents('tracks.cache', serialize($tracks));
Beispiel #9
0
 /**
  * @return SimpleXMLElement
  */
 public function getData()
 {
     $data = parent::getData();
     return $data->topalbums->album;
 }
<?php

$core = Core::getInstance();
$core->loadModule('org.sygil.lastfm');
$lastfm = new LastFM();
$lastfm->setMode('weeklyartistchart');
$lastfm->setUser('Ashaan');
$lastfm->setTheme('blue');
$core->setContent($lastfm);
Beispiel #11
0
<?php

require 'main.php';
$username = $_GET['u'];
$page = $_GET['p'];
$data = array();
$last_fm = new LastFM('72fe81934c0a8b1e45950df864a9a442');
$spotify = new Spotify($mysql_host, $mysql_username, $mysql_password, $mysql_database);
$data['artists'] = $last_fm->get_artists($username, $page);
$total_pages = $last_fm->get_total_pages();
$data['spotify_uris'] = $spotify->look_up_artists($data['artists']);
if ($page > 1) {
    $data['last_page'] = $page - 1;
}
if ($page < $total_pages) {
    $data['next_page'] = $page + 1;
}
echo $m->render('run', $data);
Beispiel #12
0
<?php

include_once "services.php";
$pagenumber = !empty($_GET["pagenumber"]) ? $_GET["pagenumber"] : 0;
$page = !empty($_GET["page"]) ? $_GET["page"] : "";
$lastfm = new LastFM();
$S = new Services();
if ($page == "search") {
} else {
    if ($page == "getItem") {
        $uid = $_GET["uid"];
        // since we're using last.fm all we really need is the event id
        $lastfm = new LastFM("event.getInfo");
        $lastfm->getItems($start, $length, array("event" => $uid));
    } else {
        if ($page == "getFilters") {
            echo <<<EOT
<input type="radio" name="location" id="aroundme" /><label for="aroundme">Around me</label>
<input type="radio" name="location" id="city" checked="checked" /><label for="city">City</label><br />
<ul id="forcity">
\t<center><input type="text" value="Des Moines" name="cityvalue" id="cityvalue" /></center>
</ul>
<input type="checkbox" name="radius" id="radius" checked="checked" /><label for="radius">Within</label><br />
<ul>
\t<input type="text" value="50" style="width: 100px" name="radius" id="radiusvalue" /> miles
</ul>

<script type="text/javascript">
\$("#filters-events").show().siblings().hide();
if( !navigator.location )
\t\$("#aroundme").hide();
Beispiel #13
0
 /**
  * @param string $url
  * @return LastFMWeeklyAlbums
  */
 public function init()
 {
     parent::init();
     $this->buildAlbumCache(false);
     return $this;
 }
Beispiel #14
0
<?php

$core = Core::getInstance();
$core->loadModule('org.sygil.lastfm');
$lastfm = new LastFM();
$lastfm->setMode('player');
$lastfm->setStation('user/Ashaan/personal');
$lastfm->setTitle('Sygil.org - Radio');
$lastfm->setTheme('blue');
$core->setContent($lastfm);