예제 #1
0
function getSongs($songsMixTitle, $sqlconn)
{
    $songs = array();
    $startTimes = array();
    $songsMixTitle = str_replace("'", "\\'", $songsMixTitle);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$songsMixTitle}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}' ORDER BY SongId", 'MixSongs');
    $songids = getSongIds($res);
    foreach ($songids as $songid) {
        $res = $sqlconn->complexQuery("Select", "SELECT * FROM Songs WHERE SongId = '{$songid}'", 'Songs');
        $songs[] = getSong($res);
        $startTimes[] = getStartTime($res);
    }
    $args = array('VideoId' => $songs, 'StartTime' => $startTimes);
    $xml = createXML('Songs', $args);
    return $xml;
}
예제 #2
0
                            <?php 
echo getChartCategories();
?>
                        </ul>
                    </li> <!-- Submenu -->
                    <li><a href="songs.php">SONGS</a></li>
                    <li><a href="playlists.php">PLAYLISTS</a></li>
                    <li><a href="contacts.php">CONTACTS</a></li>
                </ul>
            </nav>
        </section>

        <section id="content-wrapper">
            <?php 
if (isset($_GET['song'])) {
    getSong($_GET['song']);
    getComments($_GET['song'], 'song');
} else {
    if (isset($_GET['playlist'])) {
        getPlaylist($_GET['playlist']);
        getComments($_GET['playlist'], 'playlist');
    } else {
        searchResult();
    }
}
?>
    </div>
    <div id="playlist-msg">
        <p id="msg"></p>
    </div>
예제 #3
0
 function rest_getSong($artist, $songName, $fmt)
 {
     wfProfileIn(__METHOD__);
     global $wgRequest;
     // I'm not sure why, but in this context underscores don't behave like spaces automatically.
     $artist = str_replace("_", " ", $artist);
     $songName = str_replace("_", " ", $songName);
     // Allow debug suffix to persist (needs an underscore instead of a space). It is recommended to use debug=1 instead though.
     $songName = preg_replace("/ debug\$/i", "_debug", $songName);
     // allow the debug suffix to be passed through correctly.
     // Allow "&debug=1" as a URL param option instead of just messing with the song name (cleaner this way).
     $debugMode = $wgRequest->getBool('debug');
     if ($debugMode) {
         $songName .= "_debug";
     }
     $client = strtolower(getVal($_GET, 'client'));
     $lyricsTagFound = false;
     // will be modified by reference
     $doHyphens = true;
     $ns = NS_MAIN;
     $isOuterRequest = true;
     // optional parameters which we need to hardcode to get to the last parameter
     $result = getSong($artist, $songName, $doHyphens, $ns, $isOuterRequest, $debugMode, $lyricsTagFound);
     // Special case: if there was no lyrics tag found, attempt to parse the returned wikitext to look for a tracklisting.
     if (!$lyricsTagFound && 0 < preg_match("/\\[\\[.*\\]\\]/", getVal($result, 'lyrics'))) {
         // The result wasn't lyrics, but was some other page which appears to contain a tracklisting. Pass off processing to handle that.
         $this->rest_printListing($result['artist'] . ":" . $result['song'], $result['lyrics'], $fmt);
     } else {
         switch ($fmt) {
             case 'php':
                 print serialize($result);
                 break;
             case "text":
                 print utf8_decode($result['lyrics']);
                 //print "\n\n".$result['url'];
                 break;
             case "js":
                 $this->writeJS($result);
                 break;
             case "json":
                 $this->writeJSON_deprecated($result);
                 break;
             case "realjson":
                 /**
                  * Add Comscore reporting (BugzId:33112),
                  * unfortunately we can't repackage the app ATM,
                  * this is hacky but we need to get that reporting now.
                  *
                  * @TODO remove when we'll get to v2 of the app
                  * @author Jakub Olek
                  */
                 $fullApiAuth = $wgRequest->getVal('fullApiAuth');
                 if (!empty($fullApiAuth)) {
                     $result['lyrics'] .= self::COMSCORE_TAG_PLACEHOLDER;
                 }
                 $this->writeRealJSON($result);
                 break;
             case "xml":
                 header('Content-Type: application/xml', true);
                 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                 print "<LyricsResult>\n";
                 // TODO: Would probably be best to extract this whole XMLing function and make it recursive for inner-arrays (look into dumpXml_hacky() and why that's not being used here).
                 foreach ($result as $keyName => $val) {
                     if (is_array($val)) {
                         print "\t<{$keyName}>\n";
                         $innerTagName = $keyName . "_value";
                         // standard name of inner-tag
                         // If wrapping tag is plural, make inner-tag the singular if that's straightforward.
                         $matches = array();
                         if (0 < preg_match("/^(.*?)e?s\$/i", $keyName, $matches)) {
                             $innerTagName = $matches[1];
                         }
                         foreach ($val as $innerVal) {
                             print "\t\t<{$innerTagName}>" . utf8_decode(htmlspecialchars($innerVal, ENT_QUOTES, "UTF-8")) . "</{$innerTagName}>\n";
                         }
                         print "\t</{$keyName}>\n";
                     } else {
                         print "\t<{$keyName}>" . utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8")) . "</{$keyName}>\n";
                     }
                 }
                 print "</LyricsResult>\n";
                 break;
             case "html":
             default:
                 // Link to the song & artist pages as a heading.
                 $this->htmlHead($result['artist'] . " " . $result['song'] . " lyrics");
                 print Xml::openElement('h3');
                 print Xml::openElement('a', array('href' => $this->root . $this->linkEncode($result['artist'] . ":" . $result['song'])));
                 print utf8_decode(htmlspecialchars($result['song'], ENT_QUOTES, "UTF-8"));
                 print Xml::closeElement('a');
                 print ' by ';
                 print Xml::openElement('a', array('href' => $this->root . $this->linkEncode($result['artist'])));
                 print utf8_decode(htmlspecialchars($result['artist'], ENT_QUOTES, "UTF-8"));
                 print Xml::closeElement('a');
                 print Xml::closeElement('h3');
                 print "\n";
                 print Xml::openElement('pre');
                 print "\n";
                 $lyricsHtml = utf8_decode(htmlspecialchars($result['lyrics'], ENT_QUOTES, "UTF-8"));
                 // Special case to make sure the gracenote copyright symbol gets parsed correctly when needed.
                 $lyricsHtml = str_replace("&amp;copy;", "&copy;", $lyricsHtml);
                 print $lyricsHtml;
                 print Xml::closeElement('pre');
                 // Make it extensible by displaying any extra data in a UL.
                 unset($result['artist']);
                 unset($result['song']);
                 unset($result['lyrics']);
                 if (count($result) > 0) {
                     print "<hr/> Additional Info:\n";
                     print Xml::openElement('ul');
                     print "\n";
                     foreach ($result as $keyName => $val) {
                         if (is_array($val)) {
                             print Xml::openElement('li');
                             print Xml::openElement('strong');
                             print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": ";
                             print Xml::openElement('ul');
                             foreach ($val as $innerVal) {
                                 print Xml::openElement('li');
                                 // TODO: IF keyName == "searchResults", MAKE THESE INTO LINKS TO WIKI PAGES INSTEAD OF JUST PLAINTEXT.
                                 print $innerVal;
                                 print Xml::closeElement('li');
                             }
                             print Xml::closeElement('ul');
                             print Xml::closeElement('strong');
                             print Xml::closeElement('li');
                         } else {
                             if (0 < preg_match("/^http:\\/\\//", $val)) {
                                 print Xml::openElement('a', array('href' => $val, 'title' => $keyName));
                                 print utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8"));
                                 print Xml::closeElement('a');
                                 print "\n";
                                 print Xml::openElement('li');
                                 print Xml::openElement('strong');
                                 print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": ";
                                 print Xml::closeElement('strong');
                                 print htmlspecialchars($val, ENT_QUOTES, "UTF-8");
                                 print Xml::closeElement('li');
                             } else {
                                 print Xml::openElement('li');
                                 print Xml::openElement('strong');
                                 print htmlspecialchars($keyName, ENT_QUOTES, "UTF-8") . ": ";
                                 print Xml::closeElement('strong');
                                 print utf8_decode(htmlspecialchars($val, ENT_QUOTES, "UTF-8"));
                                 print Xml::closeElement('li');
                                 print "\n";
                             }
                         }
                     }
                     print Xml::closeElement('ul') . "\n";
                 }
                 print Xml::closeElement('body') . "\n" . Xml::closeElement('html') . "\n";
                 break;
         }
         // end switch
     }
     wfProfileOut(__METHOD__);
 }
예제 #4
0
/**
 * Given an artist, album-name, and year, attempts to return a matching album data (including track-listing).
 *
 * @param artist
 * @param album - album name (not including the year)
 * @param year - year the album was published
 * @return an array whose keys are 'artist', 'album' (the album name), 'year', 'amazonLink', 'imgUrl', and 'songs' which is
 * itself an array of the page-titles (as strings) of all of the songs on the album (in the order that they appear
 * on the album). The image returned will be the album cover or other appropriate image (such as the image of the artist) if
 * a suitable match can be found.  If no suitable match can be found, an empty string will be returned.
 *
 * TODO: Right now there are no guarantees about image dimensions. Should we make this method promise to only return square images
 * and use ImageServing/ImageService to do that even for the Artist images (which are the fallback)?
 */
function getAlbum($artist, $album, $year)
{
    wfProfileIn(__METHOD__);
    global $amazonRoot;
    $id = requestStarted(__METHOD__, "{$artist}");
    // Set up the default return value
    $link = $amazonRoot . urlencode("{$artist} {$album}");
    $retVal = array('artist' => 'Staind', 'album' => $album, 'year' => $year, 'amazonLink' => $link, 'imgUrl' => '', 'url' => '', 'songs' => array());
    // TODO: ADD ALBUM-ART IMG INTO RESULT ONCE THERE IS A SERVICE TO GET IT (use the ImageService... for albums we won't even need the LyricWiki hooks for fallback to artist to start with since many, many album pages have images).
    // TODO: ADD ALBUM-ART IMG INTO RESULT ONCE THERE IS A SERVICE TO GET IT (use the ImageService... for albums we won't even need the LyricWiki hooks for fallback to artist to start with since many, many album pages have images).
    global $SHUT_DOWN_API;
    if (!$SHUT_DOWN_API) {
        // TODO: For now, we use the horrible hack of calling getSong(), then parsing the result... once the title-finding code is extracted better (that's already been done on the Vostro computer, we just need to merge that change back in and TEST the damn thing... NEEEEEEED UNIT TESTSSS!!!1!one!! FIXME!)
        $doHyphens = true;
        $ns = NS_MAIN;
        $isOuterRequest = true;
        $debug = false;
        $lyricsTagFound = false;
        // defaults
        $GIMME_FULL_WIKITEXT = true;
        // don't allow the default lyrics-truncation to happen... we need the full article
        $songResult = getSong($artist, "{$album} ({$year})", $doHyphens, $ns, $isOuterRequest, $debug, $lyricsTagFound, $GIMME_FULL_WIKITEXT);
        // TODO: SWITCH TO LINE BELOW... JUST TRYING TO ENABLE DEBUG.
        $retVal['artist'] = $songResult['artist'];
        // If the title was fixed (due to capitalization, redirects, etc.), use the final version
        $matches = array();
        $finalAlbum = $songResult['song'];
        if (0 < preg_match("/^(.*) \\(([0-9]{4})\\)\$/i", $finalAlbum, $matches)) {
            $album = $matches[1];
            $year = $matches[2];
            $retVal['album'] = $album;
            $retVal['year'] = $year;
            $retVal['amazonLink'] = $amazonRoot . urlencode("{$artist} {$album}");
            $finalName = $retVal['artist'] . ":" . $retVal['album'] . " (" . $retVal['year'] . ")";
        } else {
            $finalName = $songResult['artist'] . ":" . $songResult['song'];
        }
        $finalName = str_replace(" ", "_", $finalName);
        // TODO: Link to the LyricWiki page
        $ns = $songResult['page_namespace'];
        $LW_NS_STRING = "LyricWiki";
        $nsString = $ns == NS_PROJECT ? $LW_NS_STRING . ":" : "";
        // TODO: is there a better way to get this?
        $urlRoot = "http://lyrics.wikia.com/";
        // may differ from default URL, should contain a slash after it. - TODO: This is also defined in getSong()... refactor it to be global or make it a member function of a class.
        $url = $urlRoot . $nsString . str_replace("%3A", ":", urlencode($finalName));
        // %3A as ":" is for readability.
        $retVal['url'] = $url;
        $content = $songResult['lyrics'];
        // getSong is used as a temporary hack (until the refactoring) to get the full wikitext of the article.
        if (0 < preg_match_all("/#[^\n]*\\[\\[(.*?)(\\||\\]\\])/is", $content, $matches)) {
            $fullNames = $matches[1];
            $songNames = array();
            foreach ($fullNames as $songName) {
                // Remove the artist name from the front of the link if it belongs to the same artist (to be consistent with getArtist()).
                if (startsWith($songName, $songResult['artist'] . ":")) {
                    $songName = substr($songName, strlen($songResult['artist'] . ":"));
                }
                $songNames[] = $songName;
            }
            $retVal['songs'] = $songNames;
        }
    }
    requestFinished($id);
    wfProfileOut(__METHOD__);
    return $retVal;
}
예제 #5
0
<?php

$contents = getSong();
$secsnow = $contents[1];
$secstotal = $contents[2];
?>
<html>
<head>
    <title></title>
    <script type="text/javascript"><!--
    var secsnow = '<?php 
echo $secsnow;
?>
';
    var secstotal = '<?php 
echo $secstotal;
?>
';
    function loadContent()
    {
        parent.content = document.getElementById('content').innerHTML;
        parent.secsnow = <?php 
echo $secsnow;
?>
;
        parent.secstotal = <?php 
echo $secstotal;
?>
;
        parent.do_refresh();
    }