-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
994 lines (455 loc) · 15.1 KB
/
Copy pathmain.php
File metadata and controls
994 lines (455 loc) · 15.1 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<?php
include_once("mysql.scupoints.inc.php");
?>
<html>
<html lang="en">
<head>
<script src="jquery/jquery.js"></script>
<script src="js/qtip2.js"></script>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SCU Points[Homepage]</title>
<meta name="description" content="Sell your SCU dining points for money!" />
<meta name="author" content="rirribarren" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/qtip2.css" />
<script src="js/modernizr.custom.63321.js"></script>
<!--[if lte IE 7]><style>.main{display:none;} .support-note .note-ie{display:block;}</style><![endif]-->
<!--JQUERY UI HERE -->
<link rel="stylesheet" href="jquery-ui-1.10.2.custom/css/blitzer/jquery-ui-1.10.2.custom.css"/>
<script src="jquery-ui-1.10.2.custom/js/jquery-ui-1.10.2.custom.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }
h1 { font-size: 1.2em; margin: .6em 0; }
div#users-contain { width: 350px; margin: 20px 0; }
div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
.ui-dialog .ui-state-error { padding: .3em; }
.validateTips { border: 1px solid transparent; padding: 0.3em; }
</style>
<!-- JQUERY UI ABOVE -->
<style>
@import url(http://fonts.googleapis.com/css?family=Raleway:400,700);
body {
background: #7f9b4e url(images/scubg.png) no-repeat center top;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
.container > header h1,
.container > header h2 {
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}
marquee {
marquee-speed: slow;
}
.clean-red{
border:solid 2px #D55544;
background: #F6CBCA;
color:#DE645C;
padding:4px;
text-align:center;
}
.clean-red > a {
color: #FFAACC;
}
#main-content{
width: 700px;
margin-top: auto; margin-bottom: auto;
height:auto;
text-align: center;
margin:0px;
margin-left: 360px;
margin-right: 10px;
background-color: white;
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#main-content:hover {
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
}
#side-bar{
margin-top: auto; margin-bottom: auto;
float: left;
height: 100%;
width: 350px;
margin-top: 0px;
background-color: #7D1411;
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#side-bar:hover + #main-content {
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
}
#side-bar:hover {
zoom: 1;
filter: alpha(opacity=100);
opacity: 1;
}
#points_label, #verify_label, #profile_label {
margin-top: 20px;
margin-left: 5px;
font-size: 32px;
color : white;
}
#verify_label {
color: #0000EE;
text-decoration: underline;
}
.points_options {
position:relative;
top: 20px;
left: 35px;
margin-top: 20px;
margin-left: 5px;
font-size: 20px;
color : white;
}
input.rounded {
margin-top: 10px;
margin-left: 5px;
width: 90%;
border: 1px solid #ccc;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
font-size: 12px;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none;
}
input.rounded:focus {
border-color: #339933;
}
#welcome_span {
font:normal 40pt Arial;
color:#EA1212;
text-shadow: 0 1px 0 #ccc,
0 2px 0 #c9c9c9,
0 3px 0 #bbb,
0 4px 0 #b9b9b9,
0 5px 0 #aaa,
0 6px 1px rgba(0,0,0,.1),
0 0 5px rgba(0,0,0,.1),
0 1px 3px rgba(0,0,0,.3),
0 3px 5px rgba(0,0,0,.2),
0 5px 10px rgba(0,0,0,.25),
0 10px 10px rgba(0,0,0,.2),
0 20px 20px rgba(0,0,0,.15);
}
.points_checkbox {
margin-left: 15px;
margin-top: 5px;
}
.emailPerson {
background:#25A6E1;
background:-moz-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#25A6E1),color-stop(100%,#188BC0));
background:-webkit-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
background:-o-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
background:-ms-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
background:linear-gradient(top,#25A6E1 0%,#188BC0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#25A6E1',endColorstr='#188BC0',GradientType=0);
padding:8px 13px;
color:#fff;
font-family:'Helvetica Neue',sans-serif;
font-size:17px;
border-radius:4px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
border:1px solid #1A87B9;
margin-bottom: 15px;
}
.fb-like
{
margin-top:10px;
}
#update-points, #logout{
margin-top: 50px;
margin-left: 5%;
width:80%;
font-size:3em;
}
#formInfo {
font-size: 17px;
margin-left: 5px;
}
.search_result_entry {
text-align: left;
margin-top: 10px;
margin-left: 50px;
font-size: 24px;
}
.fbImg {
position: relative;
top: 200px;
width: 200px;
height: 200px
}
.contactInfo {
margin-left: 210px;
}
</style>
<script>
//Javascript main is here for my webpage
$(function() {
//jquery ui dialog handler hooked here
var dialogfield_Points = $( "#dialogfield_Points" ),
dialogfield_PPD = $( "#dialogfield_PPD" ),
allFields = $( [] ).add( dialogfield_Points ).add( dialogfield_PPD );
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false;
} else {
return true;
}
}
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 400,
width: 550,
modal: true,
buttons: {
"Set your new info": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( dialogfield_Points, "Points", 1, 4 )
bValid = bValid && checkLength( dialogfield_PPD, "Points Per Dollar", 1, 5 );
if ( bValid ) {
//where we call an ajax script to update the mysql data
if (email_from == "none"){ alert("reload page"); return; }
$.post("updateRates.php", { emailFrom: email_from, Points: dialogfield_Points.val(), Ppd: dialogfield_PPD.val() })
.done(function(data) {
alert(data);
});
$( this ).dialog( "close" );
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#update-points" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
$( "#logout" )
.button()
.click(function() {
window.location = "logout.php";
});
//add the qtip to the verify facebook item
$('#verify_label').qtip({
content: 'By Verifying yourself on Facebook, people are way more likely to contact you when they want to buy your dining points from you, although you do not have to, <strong>It is highly reccomended that you do verify</strong>',
position: {
my: 'top left',
target: 'mouse',
viewport: $(window), // Keep it on-screen at all times if possible
adjust: {
x: 10, y: 10
}
},
hide: {
fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
},
style: {
'font-size': 64,
name: 'cream'
}
});
var email_from = "<?php echo (isset($_SESSION['email'])==true && !empty($_SESSION['email'])) ? $_SESSION['email']."@scu.edu" : "none"; ?>";
//when they enter the points here it will do ajax on a page that searches for points with the best rates
$('#fbVerified').click (function ()
{
$('#points').trigger('change');
});
$('#points').change(
function myOnchange() {
if (!$(this).val()){return;}
//the ajax is called here
$.post("search.php", { points: $('#points').val(), fbVerify: $('#fbVerified').is(":checked") })
.done(function(data) {
//alert("Data Loaded: " + data);
var obj = jQuery.parseJSON(data);
//first destroy all elements first
$(".search_result_entry").remove();
//then append the datas
for ( var i = 0; i < obj.length-1; i++)
{
var new_div;
if (obj[i].isFBConnect==0)
new_div = createDivFromDataNoFB(obj[i]);
else
new_div = createDivFromDataYesFB(obj[i]);
$("#results").append(new_div);
}
//after appending the results we have to register the click listeners!
$(".emailPerson").click(function() {
var email_to = $(this).attr("data-email");
var points = $(this).attr("data-points");
var isNumber = /^\d+$/.test(points);
if (isNumber == false)
{
alert("Invalid points");
return;
}
console.log(email_to);
console.log(points);
console.log(email_from);
if (email_from == "none"){ alert("reload page"); return; }
$.post("sendEmail.php", { points: $('#points').val(), emailFrom: email_from, emailTo: email_to })
.done(function(data) {
alert(data);
});
});
});
$('#points').trigger("change");
});
//the end of "main" for Jquery
<?php
// if they didnt set their rates then we have to
// show the dialog for them
if (hasSetRates($_SESSION['email'])==False)
{
echo<<<dialogopen
$( "#dialog-form" ).dialog( "open" );
dialogopen;
}
?>
});
function createDivFromDataNoFB( data )
{
var ans = "<div class='search_result_entry'><div class='contactInfo' >";
//lets put the name here
ans += "Email: "+data.Email+"</br>";
ans += "Points Owned: "+data.Points+"</br>";
ans += "Points Per Dollar: "+data.PPD+"</br>";
ans += "<button class='emailPerson' data-email='"+data.Email+"'"+" data-points='"+$('#points').val()+"'>Send An Email</button></br>";
ans += "</div></div>";
return ans;
}
function createDivFromDataYesFB( data )
{
var fb_img_url = 'https://graph.facebook.com';
var loc = data.fb_link;
fb_img_url += loc.substring(loc.lastIndexOf('/'));
fb_img_url += '/picture';
var ans = "<div class='search_result_entry'>";
//lets put the name here
ans += "<a href='"+data.fb_link+"'><img class='fbImg' src='"+fb_img_url+"'/></a><div class='contactInfo' >";
ans += "Facebook Verified!</br>";
ans += "Name: "+data.Name+"</br>";
ans += "Email: "+data.Email+"</br>";
ans += "Points Owned: "+data.Points+"</br>";
ans += "Points Per Dollar: "+data.PPD+"</br>";
ans += "<button class='emailPerson' data-email='"+data.Email+"'"+" data-points='"+$('#points').val()+"'>Send An Email</button></br>";
ans += "</div></div>";
return ans;
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=312549098871198";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
//if the email isnt set they have to go to the register/login page which is the same thing
if (isset($_SESSION['email']) == False)
{
echo<<<redir
<script>
window.location="register.php";
</script>
redir;
}
?>
<div class="codrops-top">
<a href="main.php"><strong>« HomePage: </strong></a>
<span class="right" style="width:70%;"><marquee><strong>SCU Points</strong></marquee></span>
</div>
<div id="side-bar">
<div id="points_label">Search for points</div>
<input type="text" id="points" name="points" class="rounded" placeholder="Enter # of points wanted"/>
<span class="points_options">Has Facebook Verified</span>
<input type="checkbox" name="fbVerified" value="fbVerified" id="fbVerified" class="points_checkbox"/>
<!-- the jquery form -->
<div id="dialog-form" title="Update Your Points">
<p class="validateTips">All form fields are required.</p>
<form>
<div id="formInfo">
<p>We don't automatically track your points, you have to enter them in for others to see</p>
<ul>
<li>Points: How many dining points you want to sell
<li>Points Per Dollar: The larger the number, means you will give more points per dollar, which makes your ranking higher in the search results</li>
</ul>
</div>
<fieldset>
<label for="dialogfield_Points">Points</label>
<input type="text" name="dialogfield_Points" id="dialogfield_Points" class="text ui-widget-content ui-corner-all" />
<label for="dialogfield_PPD">Points Per Dollar</label>
<input type="text" name="dialogfield_PPD" id="dialogfield_PPD" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
<button id="update-points">Update Points</button></br>
<button id="logout">Logout</button>
<?php
if (hasVerifiedFacebook($_SESSION['email']) == False)
{
?>
<a href="verifyFacebook.php"><div id="verify_label" title="This is my tooltip">Verify Facebook</div></a>
<?php
}
?>
</div>
<div id="main-content">
<span id="welcome_span">Welcome <?php echo $_SESSION['email']; ?><br></span>
<img src="images/coverimage.png" width=600/></br>
<div class="fb-like" data-href="http://www.scupoints.com/verifyFacebook.php" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true"></div>
<div id="results">
<div class='search_result_entry'>  </div>
<div class='search_result_entry'>  </div>
<div class='search_result_entry'>  </div>
</div>
</div>
</body>
</html>