<commit_before><?php

include "func.php";

$msg = "";
$error = "";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
        $p = $_POST['p'];
	valid_p($p) or die("Invalid URL");

        $appname  = $_POST['appname'];
        $appemail = $_POST['appemail'];
        $antispam = $_POST['antispam'];

	valid_name_email($appname, $appemail);

	if ($antispam != antispam_result($p) ) {
		die("Wrong antispam response, try again.");
	}

	$h=do_hash($appemail);

	# add address to applicants
	$applicants = explode( "\n", get_applicants($p) );
	$key = array_search( $appemail, $applicants );
	if ($key === false) {
		$fh = fopen(file_applicants($p), 'a') or die("can't open file");
		fwrite($fh, $appemail . "\n");
		fclose($fh);

		# store name/email
		if (!is_dir(file_jobdocuments($p))) mkdir( file_jobdocuments($p) );
		if (!is_dir(file_appdir($p, $h))) mkdir( file_appdir($p, $h) );
		$fh = fopen( file_appname($p, $h), 'w+') or die("can't open file");
		fwrite($fh, $appname);
		fclose($fh);
		$fh = fopen( file_appemail($p, $h), 'w+') or die("can't open file");
		fwrite($fh, $appemail);
		fclose($fh);

		$msg="Thank you $appname for applying to $jobtitle, please check your email ($appemail) for a link to continue with your application.";
	}else{
		$error="$appemail already applied, sending email again.";
	}

	# email unique link to fill details<commit_msg>when position is closed, app and ref can't change a thing<commit_after><?php

include "func.php";

$msg = "";
$error = "";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
        $p = $_POST['p'];
	valid_p($p) or die("Invalid URL");

        $appname  = $_POST['appname'];
        $appemail = $_POST['appemail'];
        $antispam = $_POST['antispam'];

	valid_name_email($appname, $appemail);

	$status = get_jobstatus($p);
	if ( $status == "close" ) {
		die("Dead $appname, the position is now closed");
	}

	if ($antispam != antispam_result($p) ) {
		die("Wrong antispam response, try again.");
	}


	$h=do_hash($appemail);

	# add address to applicants
	$applicants = explode( "\n", get_applicants($p) );
	$key = array_search( $appemail, $applicants );
	if ($key === false) {
		$fh = fopen(file_applicants($p), 'a') or die("can't open file");
		fwrite($fh, $appemail . "\n");
		fclose($fh);

		# store name/email
		if (!is_dir(file_jobdocuments($p))) mkdir( file_jobdocuments($p) );
		if (!is_dir(file_appdir($p, $h))) mkdir( file_appdir($p, $h) );
		$fh = fopen( file_appname($p, $h), 'w+') or die("can't open file");
		fwrite($fh, $appname);
		fclose($fh);
		$fh = fopen( file_appemail($p, $h), 'w+') or die("can't open file");
		fwrite($fh, $appemail);
		fclose($fh);

		$msg="Thank you $appname for applying to $jobtitle, please check your email ($appemail) for a link to continue with your application.";
	}else{
		$error="$appemail already applied, sending email again.";
	}

	# email unique link to fill details
{'fraction_non_alphanumeric': 0.19874913134120917, 'fraction_numerical': 0.0, 'mean_word_length': 4.391385767790262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4372086', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1044, 'n_words': 273}