<commit_before><?php


class Email {
	public $db = null;
	public $email = '';
	public $from = '<EMAIL>';
	public $subject = 'Note Keeper - please confirm your email.';
	public $message = '';
	public $userId = '';

	function __construct($email, $userId) {
		$this->email = $email;
		$this->userId = $userId;
		require_once '../db-connect.inc.php';
		$this->db = Database::ConnectDb();
	}

	function constructConfirmLink() {
		$date = new DateTime();
		$timestamp = $date->getTimestamp();
		$confirm = md5($timestamp);

		$stmt = $this->db->prepare("UPDATE note_users SET EmailConfirmation = :confirm WHERE UserId = :userId");
		$stmt->execute(array(':confirm' => $confirm, ':userId' => $this->userId));

		// TODO : actually generate the below link.
		$link = 'http://localhost/notes/includes/email-confirmation/confirm.php?hash=' . $this->userId . '&user=' . $this->userId;
		$this->message = 'Please follow this link to confirm your account <a href="' . $link . '">' . $link . '</a>';
		$this->sendEmail();
		// TODO : This is too much work for right now so I will have to come back to this. 
		// Basic outline of what is needed:
		// The above link needs to be generated with a random unique link each time - hash the email and time - done
		// The account will need to be check that it has been confirmed when logging in
		// There will have to be a page where the user can go to which will confirm the account.
		// The above page can be automatic or manual entry - GET in request with automatic - this doesn't matter at the current stage
		// Actually create this object and enter the email where the link will be sent too.
		// Update the database to allow the user to use the account after confirming
		// There is probably more to this but I'm going to bed now - good luck future Luke.
		
		
		// http://localhost/notes/includes/email-confirmation/confirm.php?hash=123&user=<EMAIL> - sample generated link
	}

	function sendEmail() {
		mail($this->email, $this->subject, $this->message);
	}
}

?><commit_msg>Remove old comments. Now auto-generates the confirmaion link<commit_after><?php


class Email {
	public $db = null;
	public $email = '';
	public $from = '<EMAIL>';
	public $subject = 'Note Keeper - please confirm your email.';
	public $message = '';
	public $userId = '';

	function __construct($email, $userId) {
		$this->email = $email;
		$this->userId = $userId;
		require_once '../db-connect.inc.php';
		$this->db = Database::ConnectDb();
	}

	function constructConfirmLink() {
		$date = new DateTime();
		$timestamp = $date->getTimestamp();
		$confirm = md5($timestamp);

		$stmt = $this->db->prepare("UPDATE note_users SET EmailConfirmation = :confirm WHERE UserId = :userId");
		$stmt->execute(array(':confirm' => $confirm, ':userId' => $this->userId));

		$url = $_SERVER['SERVER_NAME'];
		$link = 'http://' . $url . '/notes/includes/email-confirmation/confirm.php?hash=' . $this->userId . '&user=' . $this->userId;
		$this->message = 'Please follow this link to confirm your account <a href="' . $link . '">' . $link . '</a>';
		$this->sendEmail();
	}

	function sendEmail() {
		mail($this->email, $this->subject, $this->message);
	}
}

?>
{'fraction_non_alphanumeric': 0.15924170616113745, 'fraction_numerical': 0.001579778830963665, 'mean_word_length': 3.7113095238095237, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 46, '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': '1867609', 'n_tokens_mistral': 1010, 'n_tokens_neox': 962, 'n_words': 325}