<commit_before><?php

require_once 'API.class.php';
class HaliteAPI extends API
{

	// The database
	private $mysqli = NULL;

	public function __construct($request, $origin) {
		$this->initDB();
		parent::__construct($request);
	}

	// Initializes and returns a mysqli object that represents our mysql database
	private function initDB() {
		$this->mysqli = new mysqli("Halite.db.12061709.hostedresource.com", 
			"Halite", 
			"Fustercluck2!", 
			"Halite");
		
		if (mysqli_connect_errno()) { 
			echo "<br><br>There seems to be a problem with our database. Reload the page or try again later.";
			exit(); 
		}
	}

	private function select($sql) {
		$res = mysqli_query($this->mysqli, $sql);
		return mysqli_fetch_array($res, MYSQLI_ASSOC);
	}

	private function insert($sql) {
		mysqli_query($this->mysqli, $sql);
	}

	// API ENDPOINTS
	// Endpoint associated with a users credentials (everything in the User table; i.e. name, email, firstname, etc.)
	protected function user() {
		if($this->method == 'GET') {
			if(isset($_GET["username"]) && isset($_GET["password"])) {
				$username = $_GET["username"];
				$password = $_GET["password"];

				return $this->select("SELECT * FROM User WHERE username = '".$username."' AND password = '".$password."'");
			}
			if(isset($_GET["userID"]) && isset($_GET["password"])) {
				$useID = $_GET["userID"];
				$password = $_GET["password"];
				return $this->select("SELECT * FROM User WHERE userID = $userID AND password = '$password'");
			}
		}

		if($this->method == 'POST') {
			if(isset($_GET["username"]) && isset($_GET["password"])) {
				$username = $_GET["username"];
				$password = $_GET["password"];

				$this->insert("INSERT INTO User (username, password) VALUES ('$username', '$password')");
				return "success";
			}
		}

		return "ERROR";
	}
 }

 ?><commit_msg>Backend Now Works<commit_after><?php

require_once 'API.class.php';
class HaliteAPI extends API
{

	// The database
	private $mysqli = NULL;

	public function __construct($request, $origin) {
		$this->initDB();
		parent::__construct($request);
	}

	// Initializes and returns a mysqli object that represents our mysql database
	private function initDB() {
		$this->mysqli = new mysqli("Halite.db.12061709.hostedresource.com", 
			"Halite", 
			"Fustercluck2!", 
			"Halite");
		
		if (mysqli_connect_errno()) { 
			echo "<br><br>There seems to be a problem with our database. Reload the page or try again later.";
			exit(); 
		}
	}

	private function select($sql) {
		$res = mysqli_query($this->mysqli, $sql);
		return mysqli_fetch_array($res, MYSQLI_ASSOC);
	}

	private function insert($sql) {
		mysqli_query($this->mysqli, $sql);
	}

	// API ENDPOINTS
	// Endpoint associated with a users credentials (everything in the User table; i.e. name, email, firstname, etc.)
	protected function user() {
		if($this->method == 'GET') {
			if(isset($_GET["username"]) && isset($_GET["password"])) {
				$username = $_GET["username"];
				$password = $_GET["password"];

				return $this->select("SELECT * FROM User WHERE username = '$username' AND password = '$password'");
			}
			if(isset($_GET["userID"]) && isset($_GET["password"])) {
				$userID = $_GET["userID"];
				$password = $_GET["password"];
				return $this->select("SELECT * FROM User WHERE userID = $userID AND password = '$password'");
			}
		}

		if($this->method == 'POST') {
			if(isset($_GET["username"]) && isset($_GET["password"])) {
				$username = $_GET["username"];
				$password = $_GET["password"];

				$this->insert("INSERT INTO User (username, password) VALUES ('$username', '$password')");
				return "success";
			}
		}

		return "ERROR";
	}
 }

 ?>
{'fraction_non_alphanumeric': 0.1789329685362517, 'fraction_numerical': 0.004924760601915185, 'mean_word_length': 4.042758620689655, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3282774', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1187, 'n_words': 296}