-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
207 lines (175 loc) · 5.58 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
//if(isset($_REQUEST['installed'])&& ($_REQUEST['installed']== 1))
//header('Location: http://apps.facebook.com/reachout-two');
require '../src/facebook.php';
$facebook = new Facebook(array(
'appId' => '116117598455174',
'secret' => '',
'cookie' => true,
));
$session = $facebook->getSession();
$me = null;
// Session based API call.
if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
}
}
// login or logout url will be needed depending on current user state.
if ($me) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
if($me && isset($_REQUEST['entry']))
{
include_once("../mysql.config.php");
$qry="INSERT into reachout_registrations (user_fb_id,category,location) values ('".$_REQUEST['fid']."','".$_REQUEST['category']."','".$_REQUEST['stateser']."')";
mysql_query($qry);
mysql_close();
}
if($me && isset($_REQUEST['search']))
{
include_once("../mysql.config.php");
$qry="SELECT DISTINCT(user_fb_id) from reachout_registrations where category='".$_REQUEST['category']."' and location='".$_REQUEST['location']."'";
$result= mysql_query($qry);
$i=0;
while ($thisrow=mysql_fetch_row($result)) //get one row at a time
{
$searchRes[$i]=$thisrow[0];
$i++;
}
mysql_close();
}
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Help Out - RHoK</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $facebook->getAppId(); ?>',
session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// whenever the user logs in, we refresh the page
FB.Event.subscribe('auth.login', function() {
window.location.reload();
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<table style="width:auto;">
<tr >
<td>
<a href="http://picasaweb.google.com/lh/photo/S4vF6FY3hIiuF_TsLemoog?feat=embedwebsite">
<img src="http://lh5.ggpht.com/_e5FwhTNAp00/TPsrJG5N99I/AAAAAAAAH8U/sOLUtHNPo_8/s288/help-out-ico.jpg" height="104" width="144" />
</a>
</td>
<td width="50"></td>
<td align="center">
<h1> Help Out <br/> RHoK</h1>
</td>
</tr>
</table> <br/>
<?php if ($me): ?>
<?php else: ?>
<div>
<fb:login-button></fb:login-button>
</div>
<?php endif ?>
<?php if ($me): ?>
<img src="https://graph.facebook.com/<?php echo $uid; ?>/picture">
<?php echo "Welcome ".$me['name'];?>
<form >
<input type="hidden" name="entry" value ="1"></input>
<input type="hidden" name="fid" value ="<?php echo $me['id'];?>"></input>
<br></br>
<select name="category">
<option value="" selected="selected"> --- Select Category ---</option>
<option id="bdonate" >Blood Donation</option>
<option id="fedu" >Free Education</option>
<option id="health">Health Check up</option>
</select>
<select name="stateser">
<option value="" selected="selected"> --- Select Location ---</option>
<option id="1" >Bangalore</option>
<option id="2">Kolkata</option>
<option id="3">Chennai</option>
<option id="4">Mumbai</option>
<option id="5">Delhi</option>
</select>
<button type="submit">Enlist as a Helping Hand!</button>
<br></br>
</form>
<form name="search" >
<input type="hidden" name="search" value ="1"></input>
<select name="category">
<option value="" selected="selected"> --- Select Category ---</option>
<option id="bdonate">Blood Donation</option>
<option id="fedu">Free Education</option>
<option id="health">Health Check up</option>
</select>
<select name="location">
<option value="" selected="selected"> --- Select Location ---</option>
<option id="1">Bangalore</option>
<option id="2">Kolkata</option>
<option id="3">Chennai</option>
<option id="4">Mumbai</option>
<option id="5">Delhi</option>
</select>
<button type="submit">Search For a Helping Hand!</button>
</form>
<br></br>
<?php if(isset($searchRes))
{?>
<table bordercolor ="black" border="1" >
<tr>
<?php
foreach( $searchRes as $ruid)
{?>
<td width="100" bordercolor ="black" border="5" align="center" >
<a href="http://www.facebook.com/profile.php?id=<?php echo $ruid;?>"> <img src="https://graph.facebook.com/<?php echo $ruid; ?>/picture" />
</a>
</td>
<?php
}
?>
</tr>
</table>
<?php
}
?>
<?php else: ?>
<strong>
<em>You are not Connected.</em>
</strong>
<?php endif ?>
</body>
</html>