Permalink
Browse files

first commit

  • Loading branch information...
jessevondoom committed Apr 15, 2010
0 parents commit e159f9e0fe2b885dcfe22cc7ee78a808981f11ea
30 LICENSE
@@ -0,0 +1,30 @@
Copyright (c) 2010, CASH Music
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. Redistributions in binary form must
reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the
distribution. Neither the name of CASH Music nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
More Information:
http://creativecommons.org/licenses/BSD/
http://opensource.org/licenses/bsd-license.php
16 README
@@ -0,0 +1,16 @@
A simple webapp to facilitate downloads for Facebook fans of a specific
fan page. Supports open and S3 secured for downloads.
This requires a basic Facebook application to be created - the only real
requirements are that you give it a name and point it to your domain.
More detailed instructions soon, but you can get started here:
http://developers.facebook.com/get_started.php
Built using the the connect-js (beta) library from Facebook:
http://wiki.github.com/facebook/connect-js/faq
and Jesse Stay's PHP client library reconfigured to work with connect-js:
http://staynalive.com/articles/2010/03/22/geeky-php-client-library-that-works-with-the-new-facebook-javascript-sdk/
@@ -0,0 +1,33 @@
/* RESETS */
html {height:100%;margin:0;padding:0;}
body {height:100%;margin:0;padding:0;background:#fff url(../images/bg.gif) right top no-repeat;font:75%/1.5em helvetica,"helvetica neue",arial,sans-serif;color:#000;text-align:left;}
img {border:0;}
a {color:#344880;text-decoration:none;}
a:hover {text-decoration:underline;}
h2 {font:2em/1.5em HelveticaNeueLTStd-UltLt,"HelveticaNeueLT Std UltLt","Helvetica Neue Ultra Light","Helvetica Neue",HelveticaNeue-UltraLight,HelveticaLTStd-Light,Helvetica,Arial,sans-serif;font-weight:100;color:#000;margin:0;}
p {margin:0 0 1em 0;}
#cash_sitelogo {position:absolute;top:8px;right:8px;text-align:right;overflow:hidden;height:46px;width:46px;z-index:2345;}
#mainspc {position:relative;top:0;left:0;width:49em;height:auto;min-height:100%;margin:0 auto;padding:100px 0 0 0;}
#fbsharelink {color:#5aa2f1;}
.biglink {font-size:1.6em;line-height:1.25em;display:block;margin-top:0.75em;}
.smallmessage {font-size:0.85em;color:#aaa;}
.ifjsdisplayi {display:none;}
.ifjsdisplayi {display:inline;}
.ifjsdisplaynone {display:none;}
.oneoftwo {float:left;width:48%;margin:0;padding:0 4% 0 0;}
.oneofthree {float:left;width:30%;margin:0;padding:0 4% 0 0;}
.oneoffour {float:left;width:22%;margin:0;padding:0 4% 0 0;}
.lastone {padding:0;}
.clearall {height:1px;overflow:hidden;visibility:hidden;clear:both;}
/* FORMS */
input, textarea {padding:0.42em 1% 0.42em 1%;border:1px solid #ccc;width:98%;}
textarea {height:4em;overflow:hidden;}
input:active, input:focus, textarea:active, textarea:focus {outline:0;border:1px solid #888;}
input.button {background-color:#ccc;padding:0.6em 1.75em 0.6em 1.75em;font-weight:bold;cursor:pointer;width:auto;}
input.button:hover {background-color:#aaa;}
input.checkorradio {width:auto;}
label {font-size:0.85em;text-transform:uppercase;color:#999;text-align:right;display:block;}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,35 @@
<?php
if (isset($_GET['approot'])) {
$returnurl = $_GET['approot'];
} else {
$returnurl = '/';
}
if (isset($_GET['uid'])) {
require_once('config.php');
require_once('./lib/facebook.php');
$okaytodownload = false;
// initialize the facebook API with your application API Key and Secret
$facebook = new Facebook(FACEBOOK_KEY,FACEBOOK_SECRET);
$fb_user = $_GET['uid'];
if ($facebook->api_client->pages_isFan(FACEBOOK_FANPAGE_ID, $uid = $fb_user)) {
if (SECURE_DOWNLOAD) {
// use S3 secured download:
require_once('./lib/S3.php');
if (!defined('AMAZONS3_KEY') || !defined('AMAZONS3_SECRET')) {
header('Location: ./');
}
$s3 = new S3(AMAZONS3_KEY, AMAZONS3_SECRET);
header("Location: " . S3::getAuthenticatedURL(AMAZONS3_BUCKET, DOWNLOAD_URI, 120));
} else {
// simple redirect:
header('Location: ' . DOWNLOAD_URI);
}
} else {
header('Location: '.$returnurl.'?logout=1');
}
} else {
header('Location: '.$returnurl);
}
?>
141 index.php
@@ -0,0 +1,141 @@
<?php
require_once('config.php');
$currenturl = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CASH Music</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="title" content="<?php echo FACEBOOK_SHARE_TITLE; ?>" />
<meta name="description" content="<?php echo FACEBOOK_SHARE_DESCRIPTION; ?>" />
<link rel="image_src" href="<?php echo FACEBOOK_SHARE_IMAGE; ?>" / >
<link rel="icon" type="image/png" href="http://cashmusic.org/images/icons/cash.png" />
<script src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js" type="text/javascript"></script>
<script src="http://static.ak.fbcdn.net/connect/en_US/core.js"></script>
<script type="text/javascript">
//<![CDATA[
window.addEvent('domready', function() {
// initialize the library with your API key
// important: do NOT show your API secret here or anywhere in this script
FB.init({ apiKey: '<?php echo FACEBOOK_KEY; ?>' });
FB.getLoginStatus(handleAPIResponse);
// view the page with ?logout=1 to reset authorization
<?php if (isset($_GET['logout'])) { ?>
(function(){
FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {resetMessage();});
FB.logout(handleAPIResponse);
}).delay(3000);
<?php } ?>
function addLoginEvent() {
$('login').addEvent('click', function(e) {
FB.login(handleAPIResponse);
e.stop();
});
}
// no user, clear display
function resetMessage() {
document.id('fb-message').set('html',
'<p><?php echo str_replace("'","\'",WELCOME_MESSAGE); ?></p>'+
'<a href="#" id="login" class="biglink">Connect to Facebook</a>'+
'<p class="smallmessage">verify you are a fan and unlock your download</p>'
);
addLoginEvent();
}
// handle a session response from any of the auth related calls
function handleAPIResponse(response) {
if (!response.session) {
resetMessage();
return;
}
FB.api({
method: 'pages.isFan',
uid: FB.getSession().uid,
page_id: <?php echo FACEBOOK_FANPAGE_ID; ?>
},
function(response) {
if (response) {
document.id('fb-message').set('html',
'<p><?php echo str_replace("'","\'",ISAFAN_MESSAGE); ?></p>'+
'<a href="claimasset.php?uid='+FB.getSession().uid+'&approot=<?php echo $currenturl; ?>" class="biglink"><?php echo DOWNLOAD_TITLE; ?></a>'+
'<p class="smallmessage">'+
'<br />Enjoy it, and <a id="fbsharelink" href="http://www.facebook.com/sharer.php?u=<?php echo urlencode($currenturl) ?>">please share</a>!</p>'
);
document.id('fbsharelink').addEvent('click', function(e){
var poplocation = document.id('fbsharelink').getProperty('href');
e.stop();
window.open(poplocation,'cui_external','width=760,height=400,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');
});
} else {
document.id('fb-message').set('html',
'<p><?php echo str_replace("'","\'",NOTAFAN_MESSAGE); ?></p>'+
'<a href="#" id="login" class="biglink">Connect to Facebook</a>'+
'<p class="smallmessage">verify you are a fan and unlock your download</p>'
);
addLoginEvent();
}
});
}
FB.XFBML.parse()
});
//]]>
</script>
<link href="assets/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<div id="cash_sitelogo"><a href="http://cashmusic.org/"><img src="assets/images/cash.png" alt="CASH Music" width="30" height="30" /></a></div>
<div id="mainspc">
<h2>FBConnect To A Track— Or Code</h2>
<p style="margin-bottom:40px;">
This page uses Facebook's API to give a free download to fans of our
Facebook page. All you need to do is be a fan of <a href="http://www.facebook.com/cashmusic.org">CASH Music on Facebook</a>
for a free download of the code that powers this demo. You can even use the fanbox below to become a fan.
</p>
<div class="oneoftwo" style="margin:-10px 0 0 -10px;">
<fb:fan profile_id="<?php echo FACEBOOK_FANPAGE_ID; ?>" stream="0" connections="0" logobar="0" width="300"></fb:fan>
</div>
<div class="oneoftwo lastone">
<div id="fb-message"></div>
</div>
<div id="fb-root"></div>
<div style="clear:both;height:1px;overflow:hidden;visibility:hidden;">.</div>
<br /><br /><br /><br /><br />
<p style="font-size:0.85em;color:#aaa;">
And if you don't feel like being a fan, you can just <a href="http://github.com/cashmusic/FBConnect-to-Track" style="color:#5aa2f1;">download it from GitHub</a>.
</p>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script><script type="text/javascript">
//<![CDATA[
try {var pageTracker = _gat._getTracker("UA-7451645-1");pageTracker._trackPageview();} catch(err) {}
//]]>
</script>
</body>
</html>
Oops, something went wrong.

0 comments on commit e159f9e

Please sign in to comment.