Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/workspace.xml
817 changes: 0 additions & 817 deletions .idea/workspace.xml

This file was deleted.

17 changes: 13 additions & 4 deletions create_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$game = $_POST['game'];
$memberlimit = $_POST['memberlimit'];
//$memberlimit = $_POST['memberlimit'];
$memberlimit = 0;
$locx = $_POST['locx'];
$locy = $_POST['locy'];
$name = $_POST['name'];
$skill = $_POST['skill'];
$privacy = $_POST['privacy'];
$skill--;
//$privacy = $_POST['privacy'];
$privacy = "open";
$posters = $_POST['posters'];
$timetoexpire = $_POST['timetoexpire'];
$timetoexpire = $timetoexpire * 3600;
$ownerid = $_SESSION['id'];
$insert_group = $conn->prepare("INSERT INTO groups VALUES (LEFT(UUID(), 10), :game, :memberlimit, POINT(:locx, :locy), :groupname, :skill, :privacy, :posters, FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + :timetoexpire), CURRENT_TIMESTAMP(), :ownerid)");
$set_id = $conn->prepare("SET @g=LEFT(UUID(), 10)");
$set_id->execute();
$insert_group = $conn->prepare("INSERT INTO groups VALUES (@g, :game, :memberlimit, POINT(:locx, :locy), :groupname, :skill, :privacy, :posters, FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + :timetoexpire), CURRENT_TIMESTAMP(), :ownerid)");
$insert_group->bindParam(":game", $game);
$insert_group->bindParam(":memberlimit", $memberlimit);
$insert_group->bindParam(":locx", $locx);
Expand All @@ -37,8 +43,11 @@
$insert_group->bindParam(":privacy", $privacy);
$insert_group->bindParam(":posters", $posters);
$insert_group->bindParam(":timetoexpire", $timetoexpire);
$insert_group->bindParam(":ownerid", $_SESSION['id']);
$insert_group->bindParam(":ownerid", $ownerid);
$insert_group->execute();
$add_self_to_group = $conn->prepare("INSERT INTO groupmembers VALUES(:ownerid, @g)");
$add_self_to_group->bindParam(":ownerid", $ownerid);
$add_self_to_group->execute();
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
Expand Down
2 changes: 1 addition & 1 deletion css/bootstrap.min.css

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>ComPlay: You must sign in</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link href = "css/navbar.css" rel = "stylesheet">
<!-- Button CSS -->
<link href = "css/bootstrap-social.css" rel = "stylesheet">

<link rel="stylesheet" type="text/css" href="css/complay.css" />
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

<script src="complay.js"></script>
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand topnav" href="#"><strong>ComPlay</strong></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
</div>
<!-- /.container -->
</nav>
<div id="signinprompt"><p style="padding-left: 15px; margin-left: 88.5px; margin-top: 5px">A database error has occurred. Please try again later. You will be redirected to the home page in 5 seconds.</p></div>
<script>
// Note: This example requires that you consent to location sharing when
// prompted by your browser. If you see the error "The Geolocation service
// failed.", it means you probably did not give permission for the browser to
// locate you.
setTimeout(function() {
window.location = "index.html";
}, 5000);
</script>
</body>
</html>
Binary file added favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion get_group_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$groupid = $_GET['groupid'];
$select_group = $conn->prepare("SELECT * FROM groups WHERE groupid=:groupid");
$select_group = $conn->prepare("SELECT groupid, game, memberlimit, X(location) AS latitude, Y(location) AS longitude, name, skill, privacy, posters, expirytime, timecreated, ownerid FROM groups WHERE groupid = :groupid");
$select_group->bindParam(":groupid", $groupid);
$select_group->execute();
$select_group->setFetchMode(PDO::FETCH_ASSOC);
Expand Down
21 changes: 11 additions & 10 deletions get_location_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* Time: 7:30 AM
*/
class MapDataPoint {
private $type;
private $lat;
private $long;
private $id;
public $type;
public $lat;
public $lng;
public $id;

/**
* MapDataPoint constructor.
Expand All @@ -18,10 +18,10 @@ class MapDataPoint {
* @param $long
* @param $id
*/
public function __construct($type, $lat, $long, $id) {
public function __construct($type, $lat, $lng, $id) {
$this->type = $type;
$this->lat = $lat;
$this->long = $long;
$this->lng = $lng;
$this->id = $id;
}

Expand Down Expand Up @@ -73,7 +73,7 @@ public function setType($newtype){
$maxlat = $_POST['maxlat'];
$minlong = $_POST['minlong'];
$maxlong = $_POST['maxlong'];
$get_locations = $conn->prepare("SELECT userid, X(location) AS xcoord, Y(location) AS ycoord FROM users WHERE X(location) BETWEEN :minlat AND :maxlat AND Y(location) BETWEEN :minlong AND :maxlong");
$get_locations = $conn->prepare("SELECT userid, X(location), Y(location) FROM users WHERE X(location) BETWEEN :minlat AND :maxlat AND Y(location) BETWEEN :minlong AND :maxlong");
$get_locations->bindParam(":minlat", $minlat);
$get_locations->bindParam(":maxlat", $maxlat);
$get_locations->bindParam(":minlong", $minlong);
Expand All @@ -83,18 +83,19 @@ public function setType($newtype){
$results = $get_locations->fetchAll();
$mappoints = [];
foreach($results as $row){
$mappoints[] = new MapDataPoint("user", $row['xcoord'], $row['ycoord'], $row['userid']);
$mappoints[] = new MapDataPoint("user", $row['X(location)'], $row['Y(location)'], $row['userid']);
}
$get_group_locations = $conn->prepare("SELECT groupid, X(location) AS xcoord, Y(location) AS ycoord FROM groupid WHERE X(location) BETWEEN :minlat AND :maxlat AND Y(location) BETWEEN :minlong AND :maxlong");
$get_group_locations = $conn->prepare("SELECT groupid, X(location), Y(location), expirytime FROM groups WHERE X(location) BETWEEN :minlat AND :maxlat AND Y(location) BETWEEN :minlong AND :maxlong");
$get_group_locations->bindParam(":minlat", $minlat);
$get_group_locations->bindParam(":maxlat", $maxlat);
$get_group_locations->bindParam(":minlong", $minlong);
$get_group_locations->bindParam(":maxlong", $maxlong);
$get_group_locations->execute();
$get_group_locations->setFetchMode(PDO::FETCH_ASSOC);
$results = $get_group_locations->fetchAll();
error_log(count($results));
foreach($results as $row){
$mappoints[] = new MapDataPoint("group", $row['xcoord'], $row['ycoord'], $row['userid']);
$mappoints[] = new MapDataPoint("group", $row['X(location)'], $row['Y(location)'], $row['groupid']);
}
echo json_encode($mappoints);
} catch(PDOException $e){
Expand Down
30 changes: 30 additions & 0 deletions get_messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Created by PhpStorm.
* User: sid
* Date: 9/5/15
* Time: 6:52 AM
*/
session_start();
$servername = "us-cdbr-azure-east-b.cloudapp.net";
$username = "b0e812d8bf4e3e";
$password = "124f7801";
if(!isset($_SESSION['id']) || $_SESSION['loggedin'] === false){
header("Location: login.html");
die();
}
try{
$conn = new PDO("mysql:host=$servername;dbname=complaydb", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$postsettings = $conn->prepare("SELECT * FROM messages WHERE groupid = :groupid");
$groupid = $_POST['groupid'];
$postsettings->bindParam(":groupid", $groupid);
$postsettings->execute();
$postsettings->setFetchMode(PDO::FETCH_ASSOC);
$results = $postsettings->fetchAll();
echo json_encode($results);
} catch(PDOException $e){
echo "Connection failed: " . $e->getMessage();
}
?>
2 changes: 1 addition & 1 deletion get_user_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userid = $_GET['userid'];
$select_user = $conn->prepare("SELECT * FROM users WHERE userid=:userid");
$select_user = $conn->prepare("SELECT userid, username, timecreated, name, bio, email, phone, X(location) AS latitude, Y(location) AS longitude FROM users WHERE userid=:userid");
$select_user->bindParam(":userid", $userid);
$select_user->execute();
$select_user->setFetchMode(PDO::FETCH_ASSOC);
Expand Down
54 changes: 54 additions & 0 deletions incorrect_user_pass.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>ComPlay: You must sign in</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link href = "css/navbar.css" rel = "stylesheet">
<!-- Button CSS -->
<link href = "css/bootstrap-social.css" rel = "stylesheet">

<link rel="stylesheet" type="text/css" href="css/complay.css" />
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

<script src="complay.js"></script>
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand topnav" href="#"><strong>ComPlay</strong></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
</div>
<!-- /.container -->
</nav>
<div id="signinprompt"><p style="padding-left: 15px; margin-left: 88.5px; margin-top: 5px">Incorrect username or password. Please try again. You will be redirected to the login page in 5 seconds.</p></div>
<script>
setTimeout(function() {
window.location = "index.html";
}, 5000);
</script>
</body>
</html>
39 changes: 31 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<link href = "css/bootstrap-social.css" rel = "stylesheet">

<link rel="stylesheet" type="text/css" href="css/complay.css" />
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon'/>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

Expand All @@ -26,6 +27,7 @@
</script> <script src="complay.js"></script>
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<title>ComPlay: Connecting through Competition</title>
</head>
<body>
<!-- Navigation -->
Expand All @@ -46,17 +48,17 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#contact">Sign Up</a>
<a href="#signup">Sign Up</a>
</li>
</ul>
<form class = "navbar-form navbar-right" method="post" action="login.php" >
<form id="loginform" class = "navbar-form navbar-right" method="post" action="login.php" >
<div class="form-group">
<label class="sr-only" for="exampleInputEmail3">Email address</label>
<input type="email" class="form-control" name="username" placeholder="Enter email">
<label class="sr-only" for="exampleInputEmail3">Username</label>
<input type="text" class="form-control" name="username" required placeholder="Username">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword3">Password</label>
<input type="password" class="form-control" name="password" placeholder="Password">
<input type="password" class="form-control" name="password" required placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
Expand Down Expand Up @@ -91,7 +93,7 @@ <h3>Come Play: Connecting people through competition </h3>
<div class="col-lg-5 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">What is ComPlay</h2>
<h2 class="section-heading">What is ComPlay?</h2>
<p class="lead">ComPlay allows people in similar neighboorhoods to join an event of their liking and play with other people in your area. Whether it is basketball, Halo, or Blackjack, ComPlay has you covered. </p>
</div>
<div class="col-lg-5 col-lg-offset-2 col-sm-6">
Expand Down Expand Up @@ -121,7 +123,7 @@ <h2 class="section-heading">ComPlay's Mission</h2>
</div>
<!-- /.content-section-b -->

<div class = "information-fill">
<div class = "information-fill" id="signup">
<div class = "container">
<div class = "row">
<div class = "col-lg-12">
Expand Down Expand Up @@ -194,9 +196,30 @@ <h2 class = "section-heading"> Sign Up for ComPlay</h2>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script>
var sessiondata = getSessionData();
function getSessionData() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("POST", "get_session_data.php", false);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send();
var $_SESSION = JSON.parse(xmlhttp.responseText);
if($_SESSION.hasOwnProperty("loggedin") && $_SESSION.loggedin === true) {
window.location = "map.html";
}
return $_SESSION;
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
</html>
36 changes: 36 additions & 0 deletions is_in_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Created by PhpStorm.
* User: sid
* Date: 9/5/15
* Time: 7:30 AM
*/
session_start();
$servername = "us-cdbr-azure-east-b.cloudapp.net";
$username = "b0e812d8bf4e3e";
$password = "124f7801";
if(!isset($_SESSION['id']) || $_SESSION['loggedin'] === false){
header("Location: login.html");
die();
}
try{
$conn = new PDO("mysql:host=$servername;dbname=complaydb", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userid = $_SESSION['id'];
$groupid = $_GET['groupid'];
$get_group_locations = $conn->prepare("SELECT COUNT(*) FROM groupmembers WHERE userid=:userid AND groupid=:groupid");;
$get_group_locations->bindParam(":userid", $userid);
$get_group_locations->bindParam(":groupid", $groupid);
$get_group_locations->execute();
$get_group_locations->setFetchMode(PDO::FETCH_ASSOC);
$results = $get_group_locations->fetchAll();
if($results[0]['COUNT(*)'] >= 1) {
echo "true";
} else {
echo "false";
}
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
Loading