<?php
// De codeer-functie
function time_code($time) {
		if (ereg("^[0-9]+$", $time)) {
		$arr = array('a', 'd', 'g', 'h', 'k', 'p', 'q', 't', 'x', 'z');
		$code = str_split($time);
		$newarr = array();
		for ($i = 0; $i < count($code); $i++) {
			$newarr[] = $arr[$code[$i]];
		}
		$string = implode('', $newarr);
		
		$length = strlen($string);
		$newlength = $length;
		$i = 0;
		$ret = '';
		while ($i <= $length) {
			$place = rand(2,3);
			if ($place >= $newlength) {
				$ret .= substr($string, $i);
			}
			else {
				$ret .= substr($string, $i, $place).'.';
			}
			$i = $i + $place;
			$newlength = $newlength - $place;
		}
		
		return $ret;
	}
}

// De decodeer-functie
function time_decode($hash) {
	$arr = array('a', 'd', 'g', 'h', 'k', 'p', 'q', 't', 'x', 'z');
	$array = array_flip($arr);
	$hash = explode('.', $hash);
	$code = implode('', $hash);
	$code = str_split($code);
	$new = array();
	for ($i=0; $i < count($code); $i++) {
		if (array_key_exists($code[$i], $array)) {
			$new[] = $array[$code[$i]];
		}
	}
	
	$ret = implode('', $new);
	
	return $ret;
} ?>