diff --git a/classes/add/add.php b/classes/add/add.php index 3b714e0..19b52cd 100644 --- a/classes/add/add.php +++ b/classes/add/add.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -44,7 +44,7 @@ $classColor = str_replace("#", "", $classColor); // Add class to DB and get inserted ID -if ($stmt = $con->prepare('INSERT INTO ' . config_table_name_classes . ' (name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) { +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["classes"] . ' (name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) { $stmt->bind_param('sssiisis', $className, $classColor, $_SESSION["user_id"], $gradingTypeK, $gradingTypeM, $gradingTypeT, $gradingTypeS, $_SESSION["setting_years"]); $stmt->execute(); $classID = $stmt->insert_id; diff --git a/classes/add/index.php b/classes/add/index.php index aa589fe..bff04d1 100644 --- a/classes/add/index.php +++ b/classes/add/index.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/classes/edit/delete.php b/classes/edit/delete.php index e736b56..f2b4c57 100644 --- a/classes/edit/delete.php +++ b/classes/edit/delete.php @@ -10,10 +10,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); diff --git a/classes/edit/index.php b/classes/edit/index.php index 2ba1580..c4686d8 100644 --- a/classes/edit/index.php +++ b/classes/edit/index.php @@ -17,10 +17,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/classes/edit/modify.php b/classes/edit/modify.php index a3ba634..596810a 100644 --- a/classes/edit/modify.php +++ b/classes/edit/modify.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -39,7 +39,7 @@ if (!isset($classID)) die("missing-classid"); // Check if class exists and belongs to user -if ($stmt = $con->prepare('SELECT user_id FROM ' . config_table_name_classes . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["classes"] . ' WHERE id = ?')) { $stmt->bind_param('i', $classID); $stmt->execute(); $stmt->store_result(); @@ -57,10 +57,10 @@ $classColor = str_replace("#", "", $classColor); // Make an sql statement to update the class -// exit("UPDATE ".config_table_name_classes." SET name = '".$className."', color = '".$classColor."', grade_k = ".$gradingTypeK.", grade_m = ".$gradingTypeM.", grade_t = '".$gradingTypeT."', grade_s = ".$gradingTypeS." WHERE id = ".$classID); +// exit("UPDATE ".$config["db"]["tables"]["classes"]." SET name = '".$className."', color = '".$classColor."', grade_k = ".$gradingTypeK.", grade_m = ".$gradingTypeM.", grade_t = '".$gradingTypeT."', grade_s = ".$gradingTypeS." WHERE id = ".$classID); // Update class in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_classes . ' SET name = ?, color = ?, grade_k = ?, grade_m = ?, grade_t = ?, grade_s = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET name = ?, color = ?, grade_k = ?, grade_m = ?, grade_t = ?, grade_s = ? WHERE id = ?')) { $stmt->bind_param('ssiisii', $className, $classColor, $gradingTypeK, $gradingTypeM, $gradingTypeT, $gradingTypeS, $classID); $stmt->execute(); $stmt->close(); diff --git a/classes/grades/add/add.php b/classes/grades/add/add.php index 10a10be..0ec3d6c 100644 --- a/classes/grades/add/add.php +++ b/classes/grades/add/add.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -33,7 +33,7 @@ if (!isset($class_id)) die("missing-class"); // Check if class is owned by user -if ($stmt = $con->prepare('SELECT user_id FROM ' . config_table_name_classes . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["classes"] . ' WHERE id = ?')) { $stmt->bind_param('i', $class_id); $stmt->execute(); $stmt->store_result(); @@ -67,13 +67,13 @@ if (strlen($note) > 25) die("invalid-note"); // Add grade -if ($stmt = $con->prepare('INSERT INTO ' . config_table_name_grades . ' (user_id, class, note, type, date, grade, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["grades"] . ' (user_id, class, note, type, date, grade, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { $stmt->bind_param('sisssss', $_SESSION["user_id"], $class_id, $note, $type, $date, $grade_float, $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); // Change class last used - if ($stmt = $con->prepare('UPDATE ' . config_table_name_classes . ' SET last_used = ? WHERE id = ?')) { + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { $stmt->bind_param('si', $date, $class_id); $stmt->execute(); $stmt->close(); diff --git a/classes/grades/add/index.php b/classes/grades/add/index.php index 378cf31..74a4fe5 100644 --- a/classes/grades/add/index.php +++ b/classes/grades/add/index.php @@ -17,10 +17,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/classes/grades/edit/delete.php b/classes/grades/edit/delete.php index 7b82867..cf1feed 100644 --- a/classes/grades/edit/delete.php +++ b/classes/grades/edit/delete.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -22,7 +22,7 @@ $grade_id = $_POST["grade_id"]; // Check if grade is owned by user -if ($stmt = $con->prepare('SELECT user_id FROM ' . config_table_name_grades . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { $stmt->bind_param('i', $grade_id); $stmt->execute(); $stmt->store_result(); @@ -35,13 +35,13 @@ } // Delete grade -if ($stmt = $con->prepare('DELETE FROM ' . config_table_name_grades . ' WHERE id = ?')) { +if ($stmt = $con->prepare('DELETE FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { $stmt->bind_param('s', $grade_id); $stmt->execute(); $stmt->close(); // Change class last used - if ($stmt = $con->prepare('UPDATE ' . config_table_name_classes . ' SET last_used = ? WHERE id = ?')) { + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { $stmt->bind_param('si', $date, $class_id); $stmt->execute(); $stmt->close(); diff --git a/classes/grades/edit/edit.php b/classes/grades/edit/edit.php index 32e3b0c..5f4fe6d 100644 --- a/classes/grades/edit/edit.php +++ b/classes/grades/edit/edit.php @@ -14,10 +14,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -36,7 +36,7 @@ if (!isset($grade)) die("missing-grade"); // Check if grade is owned by user -if ($stmt = $con->prepare('SELECT user_id FROM ' . config_table_name_grades . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { $stmt->bind_param('i', $grade_id); $stmt->execute(); $stmt->store_result(); @@ -70,13 +70,13 @@ if (strlen($note) > 25) die("invalid-note"); // Add grade -if ($stmt = $con->prepare('UPDATE ' . config_table_name_grades . ' SET note = ?, type = ?, date = ?, grade = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["grades"] . ' SET note = ?, type = ?, date = ?, grade = ? WHERE id = ?')) { $stmt->bind_param('sssss', $note, $type, $date, $grade_float, $grade_id); $stmt->execute(); $stmt->close(); // Change class last used - if ($stmt = $con->prepare('UPDATE ' . config_table_name_classes . ' SET last_used = ? WHERE id = ?')) { + if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["classes"] . ' SET last_used = ? WHERE id = ?')) { $stmt->bind_param('si', $date, $class_id); $stmt->execute(); $stmt->close(); diff --git a/classes/grades/edit/index.php b/classes/grades/edit/index.php index 819b794..269ac0b 100644 --- a/classes/grades/edit/index.php +++ b/classes/grades/edit/index.php @@ -20,15 +20,15 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Get grade -if ($stmt = $con->prepare('SELECT user_id, class, note, type, date, grade FROM ' . config_table_name_grades . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT user_id, class, note, type, date, grade FROM ' . $config["db"]["tables"]["grades"] . ' WHERE id = ?')) { $stmt->bind_param('s', $grade_id); $stmt->execute(); $stmt->store_result(); diff --git a/classes/grades/index.php b/classes/grades/index.php index 3f5be07..b1be407 100644 --- a/classes/grades/index.php +++ b/classes/grades/index.php @@ -20,10 +20,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/classes/index.php b/classes/index.php index b4aa0d1..edcd11d 100644 --- a/classes/index.php +++ b/classes/index.php @@ -14,10 +14,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); @@ -29,7 +29,7 @@ // Get all classes $classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ?" . $sorting_appendix)) { +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?" . $sorting_appendix)) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); diff --git a/homework/add/add.php b/homework/add/add.php index 510c65b..d7b8cd6 100644 --- a/homework/add/add.php +++ b/homework/add/add.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -39,7 +39,7 @@ $date_given = date("Y-m-d"); // Add class to DB and get inserted ID -if ($stmt = $con->prepare('INSERT INTO ' . config_table_name_homework . ' (user_id, class, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { +if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, class, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) { $stmt->bind_param('sisssss', $_SESSION["user_id"], $class, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); diff --git a/homework/add/index.php b/homework/add/index.php index f206a5b..d41de31 100644 --- a/homework/add/index.php +++ b/homework/add/index.php @@ -11,16 +11,16 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Get all classes $classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . config_table_name_classes . " WHERE user_id = ?")) { +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); diff --git a/homework/edit/delete.php b/homework/edit/delete.php index 3c40cf6..19aef89 100644 --- a/homework/edit/delete.php +++ b/homework/edit/delete.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -22,7 +22,7 @@ $task_id = $_POST["task_id"]; // Update task in DB -if ($stmt = $con->prepare('DELETE FROM ' . config_table_name_homework . ' WHERE entry_id = ? AND user_id = ?')) { +if ($stmt = $con->prepare('DELETE FROM ' . $config["db"]["tables"]["homework"] . ' WHERE entry_id = ? AND user_id = ?')) { $stmt->bind_param('is', $task_id, $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/homework/edit/edit.php b/homework/edit/edit.php index e404951..3dff7e0 100644 --- a/homework/edit/edit.php +++ b/homework/edit/edit.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -40,7 +40,7 @@ $date_given = date("Y-m-d"); // Update task in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_homework . ' SET class = ?, given = ?, deadline = ?, text = ?, type = ? WHERE entry_id = ? AND user_id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["homework"] . ' SET class = ?, given = ?, deadline = ?, text = ?, type = ? WHERE entry_id = ? AND user_id = ?')) { $stmt->bind_param('sssssis', $class, $date_given, $date_due, $task, $type, $task_id, $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/homework/edit/index.php b/homework/edit/index.php index 23f185e..b9e2411 100644 --- a/homework/edit/index.php +++ b/homework/edit/index.php @@ -18,16 +18,16 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Get all classes $classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . config_table_name_classes . " WHERE user_id = ?")) { +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); @@ -44,7 +44,7 @@ } // Get task -if ($stmt = $con->prepare("SELECT class, type, text, deadline FROM " . config_table_name_homework . " WHERE entry_id = ? AND user_id = ?")) { +if ($stmt = $con->prepare("SELECT class, type, text, deadline FROM " . $config["db"]["tables"]["homework"] . " WHERE entry_id = ? AND user_id = ?")) { $stmt->bind_param("is", $task_id, $_SESSION["user_id"]); $stmt->execute(); $result = $stmt->get_result(); diff --git a/homework/edit/state.php b/homework/edit/state.php index 7561eae..99a83a4 100644 --- a/homework/edit/state.php +++ b/homework/edit/state.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -27,7 +27,7 @@ if (!isset($entry_id)) die("missing-entry-id"); // Update entry -if ($stmt = $con->prepare('UPDATE ' . config_table_name_homework . ' SET status = ? WHERE entry_id = ? AND user_id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["homework"] . ' SET status = ? WHERE entry_id = ? AND user_id = ?')) { $stmt->bind_param("iis", $status, $entry_id, $_SESSION["user_id"]); $stmt->execute(); // Check if entry was updated diff --git a/homework/index.php b/homework/index.php index 391ed08..a51b64a 100644 --- a/homework/index.php +++ b/homework/index.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); @@ -26,7 +26,7 @@ } // Get all tasks -if ($stmt = $con->prepare("SELECT * FROM " . config_table_name_homework . " WHERE user_id = ? AND year = ?" . $showall_text)) { +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["homework"] . " WHERE user_id = ? AND year = ?" . $showall_text)) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); @@ -34,7 +34,7 @@ } // Get all classes -if ($stmt = $con->prepare("SELECT * FROM " . config_table_name_classes . " WHERE user_id = ? and year = ?")) { +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? and year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); diff --git a/homework/state.php b/homework/state.php index adff8d6..209290f 100644 --- a/homework/state.php +++ b/homework/state.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -27,7 +27,7 @@ if (!isset($entry_id)) die("missing-entry-id"); // Update entry -if ($stmt = $con->prepare('UPDATE ' . config_table_name_homework . ' SET status = ? WHERE entry_id = ? AND user_id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["homework"] . ' SET status = ? WHERE entry_id = ? AND user_id = ?')) { $stmt->bind_param("iis", $checked, $entry_id, $_SESSION["user_id"]); $stmt->execute(); // Check if entry was updated diff --git a/index.php b/index.php index 736b681..c92e69b 100644 --- a/index.php +++ b/index.php @@ -14,16 +14,16 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Count homework status // Count for status 0,1 or 2 seperately -if ($stmt = $con->prepare("SELECT status FROM " . config_table_name_homework . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT status FROM " . $config["db"]["tables"]["homework"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($status); @@ -39,7 +39,7 @@ if (!isset($status_count[2])) $status_count[2] = 0; // Get homework due tomorrow or earlier -if ($stmt = $con->prepare("SELECT * FROM " . config_table_name_homework . " WHERE user_id = ? AND deadline <= ? AND status = 0 AND year = ?")) { +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["homework"] . " WHERE user_id = ? AND deadline <= ? AND status = 0 AND year = ?")) { // If day is sat or sun (and friday - AFTER 15 o clock), set to monday if (date("N") == 5 && date("H") >= 15) $tomorrow = date("Y-m-d", strtotime("+3 day")); else if (date("N") == 6) $tomorrow = date("Y-m-d", strtotime("+2 day")); @@ -52,14 +52,14 @@ } // Get all classes -if ($stmt = $con->prepare("SELECT * FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); $classes = $result->fetch_all(MYSQLI_ASSOC); } // Count grades -if ($stmt = $con->prepare("SELECT COUNT(*) FROM " . config_table_name_grades . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT COUNT(*) FROM " . $config["db"]["tables"]["grades"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($num_of_grades); @@ -68,7 +68,7 @@ } // Get last inserted grade -if ($stmt = $con->prepare("SELECT grade FROM " . config_table_name_grades . " WHERE user_id = ? AND year = ? ORDER BY id DESC LIMIT 1")) { +if ($stmt = $con->prepare("SELECT grade FROM " . $config["db"]["tables"]["grades"] . " WHERE user_id = ? AND year = ? ORDER BY id DESC LIMIT 1")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($last_grade); @@ -77,7 +77,7 @@ } // Calculate average -if ($stmt = $con->prepare("SELECT average FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($average); diff --git a/settings/add-year/add-year.php b/settings/add-year/add-year.php index d0fd428..024124b 100644 --- a/settings/add-year/add-year.php +++ b/settings/add-year/add-year.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); @@ -68,13 +68,13 @@ for ($i = 0; $i < 8; $i++) { $class_id .= $chars[rand(0, strlen($chars) - 1)]; } - if ($stmt = $con->prepare("SELECT id FROM " . config_table_name_classes . " WHERE id = ?")) { + if ($stmt = $con->prepare("SELECT id FROM " . $config["db"]["tables"]["classes"] . " WHERE id = ?")) { $stmt->bind_param("s", $class_id); $stmt->execute(); if ($stmt->get_result()->num_rows == 0) { $stmt->close(); $regenerate = false; - if ($stmt = $con->prepare("INSERT INTO " . config_table_name_classes . " (id, name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { + if ($stmt = $con->prepare("INSERT INTO " . $config["db"]["tables"]["classes"] . " (id, name, color, user_id, grade_k, grade_m, grade_t, grade_s, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("sssssssss", $class_id, $class["name"], $class["color"], $_SESSION["user_id"], $class["grade_k"], $class["grade_m"], $class["grade_t"], $class["grade_s"], $year_id); $stmt->execute(); $stmt->close(); diff --git a/settings/add-year/index.php b/settings/add-year/index.php index 7422c6a..384f080 100644 --- a/settings/add-year/index.php +++ b/settings/add-year/index.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); @@ -31,7 +31,7 @@ } // Get classes -if ($stmt = $con->prepare("SELECT * FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("SELECT * FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $result = $stmt->get_result(); diff --git a/settings/change_pw.php b/settings/change_pw.php index 927e7f2..1e814f7 100644 --- a/settings/change_pw.php +++ b/settings/change_pw.php @@ -10,10 +10,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -28,7 +28,7 @@ if (strlen($newpw) < 8) die("The new password is too short (min. 8 characters)"); // Check if old password is correct -if ($stmt = $con->prepare('SELECT password FROM ' . config_table_name_accounts . ' WHERE id = ?')) { +if ($stmt = $con->prepare('SELECT password FROM ' . $config["db"]["tables"]["accounts"] . ' WHERE id = ?')) { $stmt->bind_param('s', $_SESSION["user_id"]); $stmt->execute(); $stmt->bind_result($password); @@ -38,7 +38,7 @@ if (!password_verify($oldpw, $password)) die("The old password is incorrect"); // Update password in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_accounts . ' SET password = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["accounts"] . ' SET password = ? WHERE id = ?')) { $stmt->bind_param('ss', password_hash($newpw, PASSWORD_DEFAULT), $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/settings/delete_grades.php b/settings/delete_grades.php index 86d42d2..acc76b6 100644 --- a/settings/delete_grades.php +++ b/settings/delete_grades.php @@ -11,22 +11,22 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Delete all grades -if ($stmt = $con->prepare("DELETE FROM " . config_table_name_grades . " WHERE user_id = ?")) { +if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["grades"] . " WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); } // Set all averages to 0 -if ($stmt = $con->prepare("UPDATE " . config_table_name_classes . " SET average = 0 WHERE user_id = ?")) { +if ($stmt = $con->prepare("UPDATE " . $config["db"]["tables"]["classes"] . " SET average = 0 WHERE user_id = ?")) { $stmt->bind_param("s", $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/settings/export_grades.php b/settings/export_grades.php index 69a8640..45a85d2 100644 --- a/settings/export_grades.php +++ b/settings/export_grades.php @@ -11,16 +11,16 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Get all classes $classlist = array(); -if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ? ORDER BY average ASC")) { +if ($stmt = $con->prepare("SELECT name, color, id, last_used, average FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ? ORDER BY average ASC")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->bind_result($class_name, $class_color, $class_id, $class_last_used, $class_grade_average); diff --git a/settings/grade_system.php b/settings/grade_system.php index 9b7e4fa..33eba8b 100644 --- a/settings/grade_system.php +++ b/settings/grade_system.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -25,7 +25,7 @@ if ($system != "noten" && $system != "punkte") $system = "noten"; // Update system in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_accounts . ' SET gradesystem = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["accounts"] . ' SET gradesystem = ? WHERE id = ?')) { $stmt->bind_param('ss', $system, $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); @@ -36,7 +36,7 @@ // Check if user has grades their floats end in .5 if ($system == "punkte") { - if ($stmt = $con->prepare('SELECT grade FROM ' . config_table_name_grades . ' WHERE user_id = ?')) { + if ($stmt = $con->prepare('SELECT grade FROM ' . $config["db"]["tables"]["grades"] . ' WHERE user_id = ?')) { $stmt->bind_param('s', $_SESSION["user_id"]); $stmt->execute(); $result = $stmt->get_result(); diff --git a/settings/index.php b/settings/index.php index 5c92e6f..ec285a8 100644 --- a/settings/index.php +++ b/settings/index.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/settings/manage-year/delete.php b/settings/manage-year/delete.php index 1fafa43..390d17a 100644 --- a/settings/manage-year/delete.php +++ b/settings/manage-year/delete.php @@ -11,29 +11,29 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); // Delete all grades -if ($stmt = $con->prepare("DELETE FROM " . config_table_name_grades . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["grades"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); } // Delete all classes -if ($stmt = $con->prepare("DELETE FROM " . config_table_name_classes . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["classes"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); } // Delete homework -if ($stmt = $con->prepare("DELETE FROM " . config_table_name_homework . " WHERE user_id = ? AND year = ?")) { +if ($stmt = $con->prepare("DELETE FROM " . $config["db"]["tables"]["homework"] . " WHERE user_id = ? AND year = ?")) { $stmt->bind_param("ss", $_SESSION["user_id"], $_SESSION["setting_years"]); $stmt->execute(); $stmt->close(); diff --git a/settings/manage-year/index.php b/settings/manage-year/index.php index 2f4c018..2d49b9b 100644 --- a/settings/manage-year/index.php +++ b/settings/manage-year/index.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/settings/manage-year/update.php b/settings/manage-year/update.php index 88ecf89..fb7e4ba 100644 --- a/settings/manage-year/update.php +++ b/settings/manage-year/update.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); diff --git a/settings/rounding.php b/settings/rounding.php index 8292318..44fe050 100644 --- a/settings/rounding.php +++ b/settings/rounding.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -25,7 +25,7 @@ if ($rounding !== "0" && $rounding !== "1" && $rounding !== "2") $rounding = "0"; // Update rounding in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_accounts . ' SET rounding = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["accounts"] . ' SET rounding = ? WHERE id = ?')) { $stmt->bind_param('ss', $rounding, $_SESSION["user_id"]); $stmt->execute(); $stmt->close(); diff --git a/settings/school_years.php b/settings/school_years.php index df37a64..b3efca0 100644 --- a/settings/school_years.php +++ b/settings/school_years.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) exit("Error with the Database"); @@ -30,7 +30,7 @@ // Set school year $_SESSION["setting_years"] = $_POST["school_year"]; -if ($stmt = $con->prepare("UPDATE " . config_table_name_accounts . " SET school_year = ? WHERE id = ?")) { +if ($stmt = $con->prepare("UPDATE " . $config["db"]["tables"]["accounts"] . " SET school_year = ? WHERE id = ?")) { $stmt->bind_param("ss", $_SESSION["school_year"], $_SESSION["user_id"]); $stmt->execute(); } diff --git a/settings/sorting.php b/settings/sorting.php index 4332453..4d4cb2a 100644 --- a/settings/sorting.php +++ b/settings/sorting.php @@ -11,10 +11,10 @@ // DB Connection $con = mysqli_connect( - config_db_host, - config_db_user, - config_db_password, - config_db_name + $config["db"]["credentials"]["host"], + $config["db"]["credentials"]["user"], + $config["db"]["credentials"]["password"], + $config["db"]["credentials"]["name"] ); if (mysqli_connect_errno()) die("Error with the Database"); @@ -25,7 +25,7 @@ if ($sorting !== "average" && $sorting !== "alphabet" && $sorting !== "lastuse") $sorting = "average"; // Update sorting in DB -if ($stmt = $con->prepare('UPDATE ' . config_table_name_accounts . ' SET sorting = ? WHERE id = ?')) { +if ($stmt = $con->prepare('UPDATE ' . $config["db"]["tables"]["accounts"] . ' SET sorting = ? WHERE id = ?')) { $stmt->bind_param('ss', $sorting, $_SESSION["user_id"]); $stmt->execute(); $stmt->close();