/** * Gets the album art from gracenote for the specified artist and album. * */ function getArtFromSong($song, $size = 'small') { if (isset($song->arturl)) { return $song->arturl; } return getArt($song->artist, $song->album, $song->albumId, $size); }
$json = getJson($lastfmApi); $sns = SnsClient::factory(array('credentials.cache' => $cache, 'region' => 'eu-west-1')); $sns->publish(array('TopicArn' => 'arn:aws:sns:eu-west-1:346795263809:LastFM-API-CAlls', 'Message' => $json, 'Subject' => $user . "s JSON API Call")); $jsonhash = md5($json); //Cache based on user set variables and JSON hash $filename = "images/{$user}.{$period}.{$rows}.{$cols}.{$albumInfo}.{$plays}.{$jsonhash}"; //if a previous file exists - request is cached, serve from cache and exit if (file_exists($filename)) { header("Content-Type: image/jpeg"); error_log("Serving from cache - " . $filename); echo file_get_contents($filename); exit; } //otherwise carry on and getAlbums from LastFM. $albums = getAlbums(json_decode($json)); //Pass the Albums to getArt to download the art into a $covers array $covers = getArt($albums, 3); //From the covers array, create a collage while passing user variables required $image = createCollage($covers, 3, 0, $cols, $rows, $albumInfo, $plays); //Output HTTP ContentType header. header("Content-Type: image/jpeg"); //Output image on stdout. imagejpeg($image, NULL, 100); //Save image to local filesystem as cache imagejpeg($image, $filename, 100); //After output, save image to S3 for static content $result = $s3->putObject(array('Bucket' => $bucket, 'Key' => strtolower($key), 'SourceFile' => $filename, 'ACL' => 'public-read', 'ContentType' => 'image/jpeg', 'CacheControl' => 'max-age=16400')); //delete file unlink($filename); //Free resources imagedestroy($image);
?> <table><tr><td valign="top"> <div id="leftcolumn" style="padding:0px !important;" ><div class="ndiv" id="s_ch"><?php echo $res . $ress; ?> </div></div></td><td valign="top"><div id="rightcolumn"> <div id="aside"> <div class="ndiv">Media results for ’<b><?php echo $arg; ?> </b>‘</div><br/> <div class="title">Art</div> <div id="box" align="center"> <?php echo getArt($conc, $arg, $s1, $s2); ?> </div> <div class="title"> Music</div> <div id="box" class="playlist" > <ul id="plid"> <?php echo getMusic($conc, $arg, $s1, $s2); ?> </ul> </div> <div class="title"> Videos</div> <div id="box" class="playlist" >
$q = mysqli_query($conc, "SELECT videos.id,videos.user,videos.name,videos.info,videos.pict,videos.vid,videos.dl,videos.date,users.user FROM `videos` INNER JOIN users ON users.id = videos.user WHERE videos.user = {$uid} "); if (mysqli_num_rows($q) == 0) { echo "<div class='m_s_g'>No content has been added yet</div>"; } $n = 0; echo "<table><tr>"; while ($r = mysqli_fetch_array($q)) { $n++; echo "<td ><a href='./video-{$r['0']}' onclick='return setURI(\"video\",{$r['0']})' ><div style='background:url(" . PTH . "/img/load/ml.gif) no-repeat center;height:120px;width:120px;padding:10px;'><div style='background:url(" . PTH . "/prev/{$r['4']}) left;' class='vid_prev' title='{$r['3']}' onclick='playvideo(event)' prev='{$r['4']}' vid='{$r['0']}' video='{$r['5']}' info='{$r['3']}' owner='{$r['8']}' uid='{$uid}' vidname='{$r['2']}' vdate='" . gtime($r[7]) . "'>{$r['2']}<br/>{$r['3']}</div></div></a><br/></td>"; echo $n % 4 == 0 ? "</tr><tr>" : ""; } echo "</tr></table>"; $con->close_db_con($conc); exit; } switch ($type) { case 0: getArt($uuid); break; case 1: getMusic($uuid); break; case 2: getVid($uuid); break; default: $con->close_db_con($conc); exit("<div class='m_s_g'>Invalid argument</div>"); break; } $con->close_db_con($conc);
} function getMusic($con, $uid) { $q = mysqli_query($con, "SELECT * FROM `music` WHERE user = {$uid}"); if (mysqli_num_rows($q) == 0) { echo "<div class='m_s_g'>No content has been added yet</div>"; } while ($r = mysqli_fetch_array($q)) { echo "<a href='#' class='media_p' type='music' onclick='media_post(event,1)' title='{$r['3']}' tid='{$r['0']}'>{$r['2']}</a><br/>"; } } function getVid($con, $uid) { $q = mysqli_query($con, "SELECT * FROM `videos`WHERE user = {$uid} "); if (mysqli_num_rows($q) == 0) { echo "<div class='m_s_g'>No content has been added yet</div>"; } while ($r = mysqli_fetch_array($q)) { echo "<a href='#' class='media_p' type='video' onclick='media_post(event,1)' title='{$r['3']}' tid='{$r['0']}'>{$r['2']}</a><br/>"; } } $con = new db(); $conc = $con->c(); echo "<div style='height:200px;overflow-y:scroll;'><B>Your Art</b><hr/>"; getArt($conc, $uid); echo "<b>Your Music</b><hr/>"; getMusic($conc, $uid); echo "<b>Your Videos</b><hr/>"; getVid($conc, $uid); echo "</div>"; $con->close_db_con($conc);
{ $con = new db(); $conc = $con->c(); $q = mysqli_query($conc, "SELECT videos.id,videos.user,videos.name,videos.info,videos.pict,videos.vid,videos.dl,videos.date,users.user FROM `videos` INNER JOIN users ON users.id = videos.user WHERE videos.id = {$id} "); if (mysqli_num_rows($q) == 0) { echo "({status:false,msg:'Sorry, this video cannot be found'})"; //echo "<div class='m_s_g'>Sorry, this video cannot be found.</div>"; } else { $n = 0; $r = mysqli_fetch_array($q); echo "({status:true,type:3,class:'vid_prev',title:'{$r['3']}',uid:'{$r['1']}',owner:'{$r['8']}',vid:'{$r['0']}',video:'{$r['5']}',prev:'{$r['4']}',vname:'{$r['2']}',vdate:'" . gtime($r[7]) . "'})"; //echo"<table><tr>"; //echo "<a href='#!/video=$r[0]'><div style='background:url(".PTH."/img/load/ml.gif) no-repeat center;' ><div vid='$r[0]' style='background:url(".PTH."/prev/$r[4]) no-repeat center;' class='vid_prev' title='$r[3]' onclick='playvideo(event);$(\"#pwindow\").fadeOut(500);' prev='$r[4]' video='$r[5]' info='$r[3]' vidname='$r[2]' vdate='".gtime($r[7])."' owner='$r[8]' uid='$r[1]'>$r[2]<br/>$r[3]</div></div></a>"; } $con->close_db_con($conc); exit; } switch ($type) { case 0: getArt($id); break; case 1: getMusic($id); break; case 2: getVid($id); break; default: exit("({status:false,msg:'Invalid arguments'})"); break; }
return $ans; } function getVid($con, $s, $s1, $s2) { $q = mysqli_query($con, "SELECT videos.id,videos.user,videos.name,videos.info,videos.pict,videos.vid,videos.dl,videos.date,users.user FROM `videos` INNER JOIN users ON users.id = videos.user WHERE videos.name LIKE '%{$s}%' OR videos.info LIKE '%{$s}%' LIMIT 0 , 10 "); $ans = ""; if (mysqli_num_rows($q) == 0) { return ""; } while ($r = mysqli_fetch_array($q)) { $name = str_replace($s, "<_>" . $s . "</_>", $r[2]); $ans .= "<a href='./video-{$r['0']}' onclick='return setURI(\"video\",{$r['0']})'><li class='vid_item' vid='{$r['0']}' title='{$r['3']}' onclick='playvideo(event)' prev='{$r['4']}' video='{$r['5']}' info='{$r['3']}' vidname='{$r['2']}' vdate='" . gtime($r[7]) . "' owner='{$r['8']}' style='width:220px;' uid='{$r['1']}'>{$name}</li></a>"; } return $ans; } $result .= !isset($mobi) ? "<ul>" . getArt($conc, $arg, $s1, $s2) . "</ul>" : ""; $result .= !isset($mobi) ? "<ul>" . getMusic($conc, $arg, $s1, $s2) . "</ul>" : ""; $result .= !isset($mobi) ? "<ul>" . getVid($conc, $arg, $s1, $s2) . "</ul>" : ""; $result = str_replace("<_>", "<b class='j'>", $result); $result = str_replace("</_>", "</b>", $result); echo $result . "</div>"; $con->close_db_con($conc); } ?> <a href="#!/trend=<?php echo $arg; ?> " id="no_no" onclick="return _st(event,'<?php echo $arg; ?> ');" style="font-size:small;background:url("<?php