Skip to content

Commit

Permalink
Fixed PHP bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddshd committed Jul 23, 2022
1 parent 1b7fb2a commit ad74655
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 48 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
This site uses PHP and POST requests into Virginia Tech's live timetable and displays the results in an iFrame. The default Virginia Tech timetable requires the user to select the class department through a dropdown list and then enter the class number.

This website allows the user to just enter the full class information (Dept. ID + Class No.) and it will send the appropriate POST request to Virginia Tech's server. This is a much easier and faster process then VT's own website.

## Update (Jul. 23 2022)

Some of the logic I used to create this tool could be be.. But in the interest to retain my logic from when I created this project (over 3 years ago as of now) I'm going to keep my sloppy logic in place. I've fixed some PHP errors but the core logic of the tools remains the same. It will serve as a representation of how much I've (hopefully) improved over time.
100 changes: 52 additions & 48 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
$query = rawurldecode($_SERVER['QUERY_STRING']);
$query = explode('&', $query);

$termCheckmarkFall = null;
$termCheckmarkSpring = null;
$termCheckmarkSM1 = null;
$termCheckmarkSM2 = null;
$termCheckmarkWinter = null;
$campusCheckmark = array_fill(0, 10, "");
$classDValue = "";

if (sizeof($query) < 3 && sizeof($query) > 1){
header("Location: /vt/", true, 301);
exit();
}

if ($query[1] == '' Or $query[2] == '') {
$queryStatus = "false";
} else {
$queryStatus = "true";
}

if ($_SERVER['QUERY_STRING'] !== "") {
$classDValue = 'value="' . $query[0] . '"';
$submitHTML = '<div class="loader"></div>';
Expand All @@ -22,48 +24,50 @@
$queryStatus = "true";
}

$termCheckmarkFall = null;
$termCheckmarkSpring = null;
$termCheckmarkSM1 = null;
$termCheckmarkSM2 = null;
$termCheckmarkWinter = null;

if ($query[1] == "Fall") {
$termCheckmarkFall = "selected";
} elseif ($query[1] == "Spring") {
$termCheckmarkSpring = "selected";
} elseif ($query[1] == "SM1") {
$termCheckmarkSM1 = "selected";
} elseif ($query[1] == "SM2") {
$termCheckmarkSM2 = "selected";
} elseif ($query[1] == "Winter") {
$termCheckmarkWinter = "selected";
} elseif (date('m') > 02 && date('m') < 10) {
$termCheckmarkFall = "selected";
} else {
$termCheckmarkSpring = "selected";
}

if ($query[2] == "Blacksburg") {
$campusCheckmark[0] = "selected";
} elseif ($query[2] == "Virtual") {
$campusCheckmark[1] = "selected";
} elseif ($query[2] == "VTCSOM") {
$campusCheckmark[2] = "selected";
} elseif ($query[2] == "Western") {
$campusCheckmark[3] = "selected";
} elseif ($query[2] == "Valley") {
$campusCheckmark[4] = "selected";
} elseif ($query[2] == "National Capital Region") {
$campusCheckmark[5] = "selected";
} elseif ($query[2] == "Central") {
$campusCheckmark[6] = "selected";
} elseif ($query[2] == "Hampton Roads Center") {
$campusCheckmark[7] = "selected";
} elseif ($query[2] == "Capital") {
$campusCheckmark[8] = "selected";
} elseif ($query[2] == "Other") {
$campusCheckmark[9] = "selected";
if ($query[0] != "") {
if ($query[1] == '' Or $query[2] == '') {
$queryStatus = "false";
} else {
$queryStatus = "true";
}

if ($query[1] == "Fall") {
$termCheckmarkFall = "selected";
} elseif ($query[1] == "Spring") {
$termCheckmarkSpring = "selected";
} elseif ($query[1] == "SM1") {
$termCheckmarkSM1 = "selected";
} elseif ($query[1] == "SM2") {
$termCheckmarkSM2 = "selected";
} elseif ($query[1] == "Winter") {
$termCheckmarkWinter = "selected";
} elseif (date('m') > 02 && date('m') < 10) {
$termCheckmarkFall = "selected";
} else {
$termCheckmarkSpring = "selected";
}

if ($query[2] == "Blacksburg") {
$campusCheckmark[0] = "selected";
} elseif ($query[2] == "Virtual") {
$campusCheckmark[1] = "selected";
} elseif ($query[2] == "VTCSOM") {
$campusCheckmark[2] = "selected";
} elseif ($query[2] == "Western") {
$campusCheckmark[3] = "selected";
} elseif ($query[2] == "Valley") {
$campusCheckmark[4] = "selected";
} elseif ($query[2] == "National Capital Region") {
$campusCheckmark[5] = "selected";
} elseif ($query[2] == "Central") {
$campusCheckmark[6] = "selected";
} elseif ($query[2] == "Hampton Roads Center") {
$campusCheckmark[7] = "selected";
} elseif ($query[2] == "Capital") {
$campusCheckmark[8] = "selected";
} elseif ($query[2] == "Other") {
$campusCheckmark[9] = "selected";
}
}

?>
Expand Down
3 changes: 3 additions & 0 deletions post.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

$Alert = "";
$defaultValuesAlert = "";

if ($_POST['queryStatus'] == 'false') {
$defaultValuesAlert = '<p style="max-width: 800px;width:80vw;margin-bottom:0px;margin-top:10px;color:white;">Note: You did not include any campus or term information in the direct URL. Default values were used.</p>';
}
Expand Down

0 comments on commit ad74655

Please sign in to comment.