Location: PHPKode > scripts > No Spam class > no-spam-class/nospamclass.php
<?php

class noSpam {

	var $date;
	var $dateHash;

	function noSpam() {
		$this->date = date("Ymd");
		// uses md5 for hashing today's date. Can be better, but this serves
		// the need sufficient.
		$this->dateHash = md5($this->date);
	}

	function setdateNoSpam() {
		$this->date = date("Ymd");
	}

	function setHashNoSpam() {
		$this->dateHash = md5($this->date);
	}

	function getGivenHash() {
		return $this->dateHash;
	}

	function getCurrentHash() {
		return md5(date("Ymd"));
	}
	
	function validatedHash($uriHash, $doValidate=true, $showMessage=true) {
		if ($doValidate) {
			if ($this->dateHash <> $uriHash) {
				$validHash = false;
				if ($showMessage) {
					echo ".... whatever message you want to show ...";
				}
			} else {
				$validHash = true;
			}
		} else {
			$validHash = true;
		}
		return $validHash;
	}
}

?>
Return current item: No Spam class