Skip to content

Commit

Permalink
Merge branches 'AshleyDev', 'AllanDev' and 'JacobDev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobAMason committed Apr 17, 2015
3 parents d8be2d0 + 1622511 + c25bd43 commit ddcbadd
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 22 deletions.
71 changes: 65 additions & 6 deletions WebDev/AMAZEing_Game_Webdev/QuestionSubmit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,81 @@
if(!isset($_SESSION['username'])) {
header('Location: index.html');
}

?>
<html>
<head>
<title>Security Question</title>
<style>
body{
background-color:black;
}
a, h1, h4{
text-align:center;
color: white;
display: block;
margin: 0 auto;
}
</style>
</head>
<body>
<?PHP
$dbusername = "dcsp01";
$dbpassword = "AimAtJ";
$dbhostname = "localhost";
$sql = new mysqli($dbhostname, $dbusername, $dbpassword, $dbusername);

$answer = $_POST['question'];
$username = "'".$_SESSION['username']."'";
$question = $_POST['question'];
$answer = $_POST['answer'];

if(strlen($answer) > 1000) {
if(strlen($question) > 1000) {
echo "<h1>Question Submission Failed!</h1><br>";
echo "<h4>The question is longer than 1000 characters</h4><br>";
die('<a href = "SecurityQuestion.php">Return to question page</a>');
}

$username = $_SESSION['username'];
if(strlen($answer) > 100 ) {
echo "<h1>Question Submission Failed!</h1><br>";
echo "<h4>The answer is longer than 100 characters</h4><br>";
die('<a href = "SecurityQuestion.php">Return to question page</a>');
}

$query = "SELECT ID FROM User WHERE username = $username";
$row = $sql->query($query);
$result = $row->fetch_object();
$id = $result->ID;

$query = "SELECT * FROM Question WHERE ID = '$id'";
$row = $sql->query($query);

$query = "INSERT INTO Question SET password ='$password' WHERE username='$username'";
if(mysqli_num_rows($row)) {
$query = "UPDATE Question SET question ='$question', answer = '$answer' WHERE ID ='$id'";

if($sql->query($query) === TRUE) {
echo "<h1>Question Updated!</h1><br>";
echo '<a href = "accountInfoPHP.php">Return to account info page</a>';
}

else {
echo "<h1>Question Not Updated!</h1><br>";
echo '<a href = "accountInfoPHP.php">Return to account info page</a>';
}

}
else {
$query = "INSERT INTO Question (ID, Question, Answer) VALUES ('$id', '$question', '$answer')";

if($sql->query($query) === TRUE) {
echo "<h1>Question Added!</h1><br>";
echo '<a href = "accountInfoPHP.php">Return to account info page</a>';
}

else {
echo "<h1>Question Not Added!</h1><br>";
echo '<a href = "accountInfoPHP.php">Return to account info page</a>';
}
}

if($sql->query($query) === TRUE)
?>
</body>
</html>
4 changes: 2 additions & 2 deletions WebDev/AMAZEing_Game_Webdev/SecurityQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
<br/>

<div id = "answer">
<input type = "text" name = "textAnswer" placeholder="Answer Here" style = "margin-top: 10px;"/>
<input type = "text" name = "answer" placeholder="Answer Here" style = "margin-top: 10px;"/>
</div>
<br/>

<div id = "submit">
<input type = "submit" value = "Submit Question and Answer"/>
<input type = "submit" value = "Submit"/>
</div>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.DCSP.game.android"
android:versionCode="8"
android:versionName="1.1.2" >
android:versionCode="9"
android:versionName="1.1.3" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
Binary file modified android/android-release.apk
Binary file not shown.
1 change: 0 additions & 1 deletion core/src/com/DCSP/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
Expand Down
4 changes: 4 additions & 0 deletions core/src/com/DCSP/game/GameRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public boolean isLoggedIn() {
return userIsLoggedIn;
}

public void logIn() {
userIsLoggedIn = true;
}

// TODO: Move this elsewhere
public void toggleFullscreen(){
isFullscreen = !isFullscreen;
Expand Down
25 changes: 14 additions & 11 deletions core/src/com/DCSP/http/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class HttpConnection {

GameRoot gameParent;
MessageWindow messageWindow;

final private String HOST = "http://pluto.cse.msstate.edu";

public HttpConnection(GameRoot gameParent) {
this.gameParent = gameParent;
Expand All @@ -64,7 +66,7 @@ public HttpConnection(GameRoot gameParent) {
// Returns true/false depending on whether the login succeeded or failed.
public void login(String username, String password, final Window successWindow) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/Login.php");
request.setUrl(HOST + "/~dcsp01/application/Login.php");

Map parameters = new HashMap();
parameters.put("username", username);
Expand All @@ -90,6 +92,7 @@ public void handleHttpResponse(Net.HttpResponse httpResponse) {
result.get("username").toString(),
result.get("email").toString(),
result.get("Name").toString());
gameParent.logIn();
} catch (Exception e) {
System.out.println(e.toString());
}
Expand Down Expand Up @@ -123,7 +126,7 @@ public void cancelled() {
public void register(String username, String password, String name, String email,
final Window connectionFailWindow) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/Register.php");
request.setUrl(HOST + "/~dcsp01/application/Register.php");

Map parameters = new HashMap();
parameters.put("username", username);
Expand Down Expand Up @@ -180,7 +183,7 @@ public void cancelled() {

public void sendScore(int ID, int level, double score) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/sendScores.php");
request.setUrl(HOST + "/~dcsp01/application/sendScores.php");

Map parameters = new HashMap();
parameters.put("ID", String.valueOf(ID));
Expand Down Expand Up @@ -210,7 +213,7 @@ public void cancelled() {

public void getScores(int ID) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/getScores.php");
request.setUrl(HOST + "/~dcsp01/application/getScores.php");

Map parameters = new HashMap();
parameters.put("ID", String.valueOf(ID));
Expand Down Expand Up @@ -250,7 +253,7 @@ public void cancelled() {

public void getHighScores() {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/HighScore.php");
request.setUrl(HOST + "/~dcsp01/application/HighScore.php");

Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
Expand Down Expand Up @@ -286,7 +289,7 @@ public void cancelled() {

public void userLookup(String username) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/userLookup.php");
request.setUrl(HOST + "/~dcsp01/application/userLookup.php");

Map parameters = new HashMap();
parameters.put("username", String.valueOf(username));
Expand Down Expand Up @@ -314,7 +317,7 @@ public void cancelled() {

public void IDLookup(int ID) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/addFriend.php");
request.setUrl(HOST + "/~dcsp01/application/addFriend.php");

Map parameters = new HashMap();
parameters.put("ID", String.valueOf(ID));
Expand Down Expand Up @@ -342,7 +345,7 @@ public void cancelled() {

public void sendChallenge(double score, int level, long seed, String toUsername) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/sendChallenge.php");
request.setUrl(HOST + "/~dcsp01/application/sendChallenge.php");

Map parameters = new HashMap();
parameters.put("ID", String.valueOf(gameParent.profile.getID()));
Expand Down Expand Up @@ -385,7 +388,7 @@ public void cancelled() {

public void getChallenges(int ID) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/getChallenges.php");
request.setUrl(HOST + "/~dcsp01/application/getChallenges.php");

Map parameters = new HashMap();
parameters.put("ID", String.valueOf(ID));
Expand Down Expand Up @@ -444,7 +447,7 @@ public void addFriend(int frienderID, String friendeeUsername, final List friend
}

Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/addFriend.php");
request.setUrl(HOST + "/~dcsp01/application/addFriend.php");

Map parameters = new HashMap();
parameters.put("friender", String.valueOf(frienderID));
Expand Down Expand Up @@ -484,7 +487,7 @@ public void getFriends(int frienderID) {

public void getFriends(int frienderID, final List friendList) {
Net.HttpRequest request = new Net.HttpRequest(Net.HttpMethods.POST);
request.setUrl("http://pluto.cse.msstate.edu/~dcsp01/application/getFriends.php");
request.setUrl(HOST + "/~dcsp01/application/getFriends.php");

Map parameters = new HashMap();
parameters.put("friender", String.valueOf(frienderID));
Expand Down

0 comments on commit ddcbadd

Please sign in to comment.