示例#1
0
/**
 * Shows the Flash MP3 Player
 *
 * @param string $release_slug The release_slug of the release to display a player for.
 * @return void
 * @author Alex Andrews <*****@*****.**>
 **/
function show_player($release_slug)
{
    global $artists, $artist, $current_artist;
    global $releases, $release, $current_release;
    $release = get_release_by_slug($release_slug, FALSE, FALSE);
    if (is_wp_error($release)) {
        ribcage_404();
    }
    $artist['artist_name'] = get_artistname_by_id($release['release_artist']);
    if (is_wp_error($artist)) {
        ribcage_404();
    }
    $url = release_soundcloud_url(false);
    ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>ROR Player</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css">
</head>
<body>
<iframe width="100%" height="465" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=<?php 
    echo $url;
    ?>
"></iframe>
</iframe>
</body>
</html>
<?php 
    return 0;
}
示例#2
0
/**
 * Outputs the file selected from database to user for download.
 *
 * @author Alex Andrews <*****@*****.**>
 * @param string $release_slug The slug of the release to download.
 * @param string $format The format of the release to download, flac|mp3|ogg
 * @return void
 */
function download_release($release_slug, $format)
{
    global $release;
    if (empty($release_slug)) {
        return new WP_Error('ribcage-no-release-to-download', __("You didn't specify a release to grab."));
    }
    $release = get_release_by_slug($release_slug, FALSE, FALSE);
    // If we don't know the release, then error nicely, not with a snarky SQL error.
    // Remember this page is user viewed. Display a 404.
    if (is_wp_error($release)) {
        return $release;
    }
    if ($format == 'mp3') {
        $file = $release['release_mp3'];
    } elseif ($format == 'ogg') {
        $file = $release['release_ogg'];
    } else {
        if ($format == 'flac') {
            $file = $release['release_flac'];
        } else {
            return new WP_Error('ribcage-incorrect-format', __("{$format} isn't a format I am aware of.<br />Hence it isn't a format you can download, sorry."));
        }
    }
    ribcage_log();
    ribcage_download($file);
}
示例#3
0
/**
 * Stream a whole release as xspf or m3u.
 *
 * @return void
 * @param string $release_slug The slug of the release to stream
 * @param string $stream_format The format of the streaming, either xspf or m3u
 **/
function stream_release($release_slug, $stream_format)
{
    global $wp_query, $release, $artist;
    global $tracks, $track, $current_track;
    if (empty($release_slug)) {
        return new WP_Error('ribcage-no-release-to-stream', __("You didn't specify a release to stream."));
        ribcage_404();
    }
    $release = get_release_by_slug($release_slug, TRUE, FALSE);
    if (is_wp_error($release)) {
        ribcage_404();
    }
    $artist['artist_name'] = get_artistname_by_id($release['release_artist']);
    if (is_wp_error($artist)) {
        ribcage_404();
    }
    $tracks = $release['release_tracks'];
    $track = $tracks[$current_track];
    if (is_wp_error($release)) {
        ribcage_404();
    }
    if ($stream_format == 'xspf') {
        $load = ribcage_load_template('./stream/xspf.php');
    } elseif ($stream_format == 'm3u') {
        $load = ribcage_load_template('stream/m3u.php');
    }
    if (is_wp_error($load)) {
        return $load;
    }
}
示例#4
0
function ribcage_donate_download_thanks()
{
    global $release, $artist, $wp_query;
    $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
    $artist = get_artist($release['release_artist']);
    $load = ribcage_load_template('download-thanks.php');
}
示例#5
0
function show_player($release_slug)
{
    global $artists, $artist, $current_artist;
    global $releases, $release, $current_release;
    $release = get_release_by_slug($release_slug, FALSE, FALSE);
    $artist['artist_name'] = get_artistname_by_id($release['release_artist']);
    ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>ROR Player</title>
<style type="text/css" media="screen">
	* {
		margin: 0;
		padding: 0;
	}
</style>
<body>
<embed src="<?php 
    echo get_option('siteurl');
    ?>
/wp-content/plugins/ribcage/flash/mp3player.swf" width="320" height="140" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=<?php 
    echo get_option('siteurl') . '/stream/' . $release_slug . '/xspf/';
    ?>
&height=140&width=320&displaywidth=120&showicons=false&repeat=list&autostart=true&shuffle=false&callback=<?php 
    echo get_option('siteurl');
    ?>
/player/stats/" />
</body>
</html>
<?php 
    return 0;
}
示例#6
0
/**
 * Displays thank you message to the user returning from PayPal
 *
 * @author Alex Andrews <*****@*****.**>
 * @return void
 */
function ribcage_donate_download_thanks()
{
    global $release, $artist, $wp_query;
    $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
    if (is_wp_error($release)) {
        ribcage_404();
    }
    $artist = get_artist($release['release_artist']);
    if (is_wp_error($artist)) {
        ribcage_404();
    }
    if ($release["release_slug"] === 'christmas-koto') {
        $load = ribcage_load_template('download-thanks-koto.php');
    } else {
        $load = ribcage_load_template('download-thanks.php');
    }
}
示例#7
0
/**
 * Runs the whole of Ribcage.
 * A filter on the template that tries to find out if we are on a Ribcage page and responds accordingly.
 *
 * @author Alex Andrews <*****@*****.**>
 * @return void
 */
function ribcage_init()
{
    global $wp_query;
    global $artists, $artist, $current_artist;
    global $releases, $release, $current_release;
    global $tracks, $track, $current_track;
    global $reviews, $review, $current_review;
    global $product;
    wp_enqueue_script('ribcage-player-popup', plugins_url('js/player.js', __FILE__), null, '3.0');
    // Add our streams.
    add_filter('wp_head', 'ribcage_release_feeds');
    if (is_ribcage_page() == 0) {
        return;
    }
    $GLOBALS['ribcage_page'] = TRUE;
    // Add our bits to the page title in the header ans elsewhere.
    add_filter('wp_title', 'ribcage_page_title', 10, 3);
    // Donate IPN from Paypal
    if (isset($wp_query->query_vars['ribcage_donate_ipn'])) {
        ribcage_donate_ipn();
    }
    // Artist Index
    if (isset($wp_query->query_vars['artist_index'])) {
        $artists = list_artists_blurb();
        $artist = $artists[$current_artist];
        $wp_query->query_vars['pagename'] = 'artists';
        $load = ribcage_load_template('artist-index.php');
    }
    // Individual Artist (including bio, contact et al)
    if (isset($wp_query->query_vars['artist_slug'])) {
        $artist = get_artist_by_slug($wp_query->query_vars['artist_slug']);
        if (is_wp_error($artist)) {
            ribcage_404();
        }
        $wp_query->query_vars['pagename'] = $wp_query->query_vars['artist_slug'];
        if (is_artist_page()) {
            switch ($wp_query->query_vars['artist_page']) {
                case 'press':
                    $releases = list_artist_releases($artist['artist_id'], TRUE);
                    $load = ribcage_load_template('press.php');
                    break;
                case 'bio':
                    $load = ribcage_load_template('bio.php');
                    break;
                case 'feed':
                    $releases = list_artist_releases($artist['artist_id']);
                    $load = ribcage_load_template('feeds/artist-rss2.php');
                    break;
                default:
                    $release = get_release_by_slug($wp_query->query_vars['artist_page']);
                    if (is_wp_error($release)) {
                        ribcage_404();
                    }
                    $tracks = $release['release_tracks'];
                    $reviews = $release['release_reviews'];
                    $load = ribcage_load_template('release.php');
            }
        } else {
            $releases = list_artist_releases($artist['artist_id']);
            $load = ribcage_load_template('artist.php');
        }
    }
    // Releases Index
    if (isset($wp_query->query_vars['release_index']) or isset($wp_query->query_vars['release_feed'])) {
        $releases = list_recent_releases_blurb();
        $artists = list_artists_blurb();
        $wp_query->query_vars['pagename'] = 'releases';
        if (isset($wp_query->query_vars['release_feed'])) {
            $load = ribcage_load_template('feeds/release-rss2.php');
        } else {
            $load = ribcage_load_template('release-index.php');
        }
    }
    // Downloads
    if (isset($wp_query->query_vars['ribcage_download'])) {
        // Download whole release.
        if (isset($wp_query->query_vars['release_slug']) && isset($wp_query->query_vars['format'])) {
            // Re-direct them to donate at Paypal
            if ($wp_query->query_vars['format'] == 'donate') {
                $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
                if (is_wp_error($release)) {
                    ribcage_404();
                }
                $artist = get_artist($release['release_artist']);
                if (is_wp_error($artist)) {
                    ribcage_404();
                }
                ribcage_donate();
            } else {
                if ($wp_query->query_vars['format'] == 'back') {
                    ribcage_donate_download_thanks();
                } else {
                    if ($wp_query->query_vars['format'] == 'skip') {
                        $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
                        if (is_wp_error($release)) {
                            ribcage_404();
                        }
                        $artist = get_artist($release['release_artist']);
                        if (is_wp_error($artist)) {
                            ribcage_404();
                        }
                        $load = ribcage_load_template('download.php');
                    } else {
                        $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
                        if (is_wp_error($release)) {
                            ribcage_404();
                        }
                        $artist = get_artist($release['release_artist']);
                        if (is_wp_error($artist)) {
                            ribcage_404();
                        }
                        $load = ribcage_load_template('post-download.php');
                    }
                }
            }
        } else {
            if (isset($wp_query->query_vars['track_slug'])) {
                $load = download_track($wp_query->query_vars['track_slug'], $wp_query->query_vars['format']);
            } else {
                if (isset($wp_query->query_vars['release_slug'])) {
                    $release = get_release_by_slug($wp_query->query_vars['release_slug'], FALSE, FALSE);
                    if (is_wp_error($release)) {
                        ribcage_404();
                    }
                    $artist = get_artist($release['release_artist']);
                    if (is_wp_error($artist)) {
                        ribcage_404();
                    }
                    // Special case for Matthew Jenning's Christmas Koto
                    if ($release["release_slug"] === 'christmas-koto') {
                        $load = ribcage_load_template('koto-nag.php');
                        die;
                    }
                    // If we haven't seen the user before, then nag them about the download.
                    if (!isset($_COOKIE["ask_donate"])) {
                        setcookie("ask_donate", "1", time() + 3600);
                        $load = ribcage_load_template('nag.php');
                    } else {
                        if (isset($_COOKIE["ask_donate"])) {
                            $random = rand(1, 8);
                            if ($random == 5) {
                                $load = ribcage_load_template('nag.php');
                            } else {
                                $load = ribcage_load_template('download.php');
                            }
                        }
                    }
                    // If the user has just got back from Paypal congratulate them on their brillance and given them
                    // the download. Maybe lower the chance of a nag?
                }
            }
        }
    }
    // Streams
    if (isset($wp_query->query_vars['ribcage_stream'])) {
        // Stream whole release.
        if (isset($wp_query->query_vars['release_slug'])) {
            $load = stream_release($wp_query->query_vars['release_slug'], $wp_query->query_vars['stream_format']);
        }
        // Stream individual track.
        if (isset($wp_query->query_vars['track_slug'])) {
            $load = stream_track($wp_query->query_vars['track_slug']);
        }
    }
    if (isset($wp_query->query_vars['ribcage_player'])) {
        if ($wp_query->query_vars['release_slug'] == 'stats') {
            ribcage_log_play();
        } else {
            $load = show_player($wp_query->query_vars['release_slug']);
        }
    }
    // Purchases
    if (isset($wp_query->query_vars['ribcage_buy']) && isset($wp_query->query_vars['ribcage_product_id'])) {
        // Lookup the item they are looking for in the database.
        $product = get_product($wp_query->query_vars['ribcage_product_id']);
        if (is_wp_error($product)) {
            ribcage_404();
        }
        // Some products are associated with releases, some are not.
        if (isset($product['product_related_release'])) {
            $release = get_release($product['product_related_release']);
            $artist = get_artist($release['release_artist']);
        }
        // Set this so the feeds at the bottom of the page show up for the artist.
        $wp_query->query_vars['artist_slug'] = true;
        if (isset($wp_query->query_vars['ribcage_buy_mode'])) {
            switch ($wp_query->query_vars['ribcage_buy_mode']) {
                // Send them to Paypal
                case 'go-ww':
                case 'go-uk':
                    ribcage_buy_process();
                    break;
                    // They just got back from Paypal and it was a success. Thank them for it.
                // They just got back from Paypal and it was a success. Thank them for it.
                case 'thanks':
                    $load = ribcage_load_template('thanks.php');
                    break;
                    // We are recieving an IPN ping from Paypal.
                // We are recieving an IPN ping from Paypal.
                case 'ipn':
                    ribcage_buy_ipn();
                    break;
                    // They cancelled.
                // They cancelled.
                case 'cancel':
                    echo "Cancelled";
                    break;
            }
        } else {
            $load = ribcage_load_template('buy.php');
        }
    }
    // Did we get an error by the end of all this? If so let the user know.
    if (is_wp_error($load)) {
        echo $load->get_error_message();
    }
    // Don't output anything else.
    die;
}