-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
177 lines (175 loc) · 5.78 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
require 'config.php';
$session = $FB->getSession();
$loggedIn = ($session['uid']) ? true : false;
if (isset($_POST['fb_sig_profile_user'])) {
$session['uid'] = $_POST['fb_sig_profile_user'];
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>FriendZei</title>
<style type="text/css">
html, body {
font-family: Tahoma, sans-serif;
}
#header {
width: 100%;
padding: 0;
margin: 0;
}
#content {
width: 100%;
padding: 0;
margin: 0;
}
#col1 {
float: left;
width: 45%;
}
#col2 {
float: right;
width: 45%;
}
#footer {
clear: both;
font-size: 10px;
padding: 5px;
text-align: right;
}
.block {
border: 1px solid #1D4088;
margin: 15px 0;
}
.block .header {
background-color: #627AAD;
color: #FFF;
font-size: 12px;
font-weight: bold;
padding: 5px 10px;
}
.block .content {
padding: 10px;
}
.block .content ul {
list-style-type: none;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>FriendZei</h1>
</div>
<div id="content">
<?php if (!$loggedIn) { ?>
<div class="block">
<div class="header">
Permission Required
</div>
<div class="content">
You must first log in to Facebook/grant FriendZei permission to access your data before you can continue.<br/>
<fb:login-button perms="read_stream"></fb:login-button>
</div>
</div>
<?php } else { ?>
<div id="col1">
<div class="block" id="under-construction">
<div class="header">
Under Construction
</div>
<div class="content">
</div>
</div>
<div class="block" id="top-commenters">
<div class="header">
Top Commenters This Week
</div>
<div class="content">
</div>
</div>
</div>
<div id="col2">
<div class="block" id="top-commented-posts">
<div class="header">
Top Most Commented Wall Posts
</div>
<div class="content">
</div>
</div>
<div class="block" id="top-liked-posts">
<div class="header">
Top Most Liked Wall Posts
</div>
<div class="content">
</div>
</div>
</div>
<?php } ?>
</div>
<div id="footer">
Concept by <a href="http://chris.pirillo.com" target="_blank">Chris Pirillo</a><br/>
Development by <a href="http://eddieringle.com" target="_blank">Eddie Ringle</a><br/>
Hosted by <a href="http://idlesoft.net" target="_blank">Idlesoft</a>
</div>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function fillWithContent(selector, content, anim) {
if (anim === true) {
$(selector).slideUp('slow', function() {
$(selector).html(content);
$(selector).slideDown('slow');
});
} else {
$(selector).html(content);
}
}
function topCommenters() {
$.getJSON('topCommenters.php?json=1&uid=<?php echo $session['uid']; ?>&since=-1%20week&count=1000', function(resp) {
var users = "<ul>";
for (i in resp) {
if (resp[i]['count'] === 1) {
commentWord = 'comment';
} else {
commentWord = 'comments';
}
users = users + "<li>";
users = users + "<img src=\"http://graph.facebook.com/" + resp[i]['uid'] + "/picture\"></img>";
users = users + resp[i]['name'];
users = users + ": " + resp[i]['count'] + " " + commentWord;
users = users + "</li>";
}
users = users + "</ul>";
fillWithContent('#top-commenters div.content', users, true);
});
}
function runAway() {
// redirect to the Facebook homepage
}
function continueJourney() {
fillWithContent('.block div.content', 'Loading... <img src="spinner.gif" alt="Please wait."></img>');
topCommenters();
}
window.fbAsyncInit = function() {
FB.init({appId: '159073957460563', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('auth.sessionChange', function(resp) {
window.location.reload();
});
FB.api('/<?php echo $session['uid']; ?>', function(resp) {
fillWithContent("#under-construction div.content", "Logged in as " + resp.name + "; UID: " + resp.id, true);
});
<?php if ($loggedIn) { ?>
continueJourney();
<?php } ?>
};
</script>
</div>
</body>
</html>