<commit_before><?php

require_once(dirname(__DIR__,2) . "/php/classes/autoload.php");
require_once (dirname(__DIR__,2) . "/php/lib/xsrf.php");
require_once("/etc/apache2/capstone-mysql/encrypted-config.php");

use Edu\Cnm\DdcAaaa\Prospect;

/**
 * api for the prospect class
 *
 * @author <NAME> <<EMAIL>>
 **/

//verify the session, start if not active
if(session_status() !== PHP_SESSION_ACTIVE) {
	session_start();
}

//prepare an empty reply
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;

try {
	//grab the mySQL connection
	$pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/ddcaaaa.ini");

	//determine which HTTP method was used
	$method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];

	//sanitize input
	$prospectId = filter_input(INPUT_GET, "prospectId", FILTER_VALIDATE_INT);
	$prospectFirstName = filter_input(INPUT_GET, "prospectFirstName", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectLastName = filter_input(INPUT_GET, "prospectLastName", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectEmail = filter_input(INPUT_GET, "prospectEmail", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectEmail = filter_input(INPUT_GET, "prospectPhoneNumber", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);

	// handle GET request
	if($method === "GET") {
		//set XSRF cookie
		setXsrfCookie();

		//get a specific prospect or all prospects and update reply
		if(empty($prospectId) === false) {
			$prospect = Prospect::getProspectByProspectId($pdo, $prospectId);
			if($prospect !== null) {
				$reply->data = $prospect;
			}
		} else if(empty($prospectFirstName) === false) {
			$prospects = Prospect::getProspectsByProspectName($pdo, $prospectFirstName);
			if($prospects !== null) {
				$reply->data = $prospects->toArray();<commit_msg>fixed bug in get request tested all requests get and post<commit_after><?php

require_once(dirname(__DIR__,2) . "/php/classes/autoload.php");
require_once (dirname(__DIR__,2) . "/php/lib/xsrf.php");
require_once("/etc/apache2/capstone-mysql/encrypted-config.php");

use Edu\Cnm\DdcAaaa\Prospect;

/**
 * api for the prospect class
 *
 * @author <NAME> <<EMAIL>>
 **/

//verify the session, start if not active
if(session_status() !== PHP_SESSION_ACTIVE) {
	session_start();
}

//prepare an empty reply
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;

try {
	//grab the mySQL connection
	$pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/ddcaaaa.ini");

	//determine which HTTP method was used
	$method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];

	//sanitize input
	$prospectId = filter_input(INPUT_GET, "prospectId", FILTER_VALIDATE_INT);
	$prospectFirstName = filter_input(INPUT_GET, "prospectFirstName", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectLastName = filter_input(INPUT_GET, "prospectLastName", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectEmail = filter_input(INPUT_GET, "prospectEmail", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
	$prospectPhoneNumber = filter_input(INPUT_GET, "prospectPhoneNumber", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);

	// handle GET request
	if($method === "GET") {
		//set XSRF cookie
		setXsrfCookie();

		//get a specific prospect or all prospects and update reply
		if(empty($prospectId) === false) {
			$prospect = Prospect::getProspectByProspectId($pdo, $prospectId);
			if($prospect !== null) {
				$reply->data = $prospect;
			}
		} else if(empty($prospectFirstName) === false) {
			$prospects = Prospect::getProspectsByProspectName($pdo, $prospectFirstName);
			if($prospects !== null) {
				$reply->data = $prospects->toArray();
{'fraction_non_alphanumeric': 0.14233576642335766, 'fraction_numerical': 0.0036496350364963502, 'mean_word_length': 6.014625228519195, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '7300893', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1357, 'n_words': 249}