<?php
if(strcmp(basename($_SERVER['SCRIPT_NAME']), basename(__FILE__)) === 0){

	header("location:../index.php");
}


function genPass1($length=4, $strength=0) {
	$vowels = 'aeuy';
	$consonants = 'bdghjmnpqrstvz';
	if ($strength & 1) {
		$consonants .= 'BDGHJLMNPQRSTVWXZ';
	}
	if ($strength & 2) {
		$vowels .= "AEUY";
	}
	if ($strength & 4) {
		$consonants .= '23456789';
	}
	if ($strength & 8) {
		$consonants .= '@#$%';
	}
 
	$password = '';
	$alt = time() % 2;
	for ($i = 0; $i < $length; $i++) {
		if ($alt == 1) {
			$password .= $consonants[(rand() % strlen($consonants))];
			$alt = 0;
		} else {
			$password .= $vowels[(rand() % strlen($vowels))];
			$alt = 1;
		}
	}
	return $password;
}

function simplesPass($a,$length)
{ 
	$alpha = "abcdefghijklmnopqrstuvwxyz";
	$alpha_upper = strtoupper($alpha);
	$numeric = "0123456789";
	$special = ".-+=_,!@$#*%<>[]{}";
	$chars = "";

    if ($a[0]=='1') { $chars .= $alpha; }
    if ($a[1]=='1') { $chars .= $alpha_upper; }
    if ($a[2]=='1') { $chars .= $numeric; }
    if ($a[3]=='1') { $chars .= $special; }         

 
	$chars = str_shuffle($chars);
	$len = strlen($chars);
	$pw = '';
	 
	for ($i=0;$i<$length;$i++)
	        $pw .= substr($chars, rand(0, $len-1), 1);
	 
	// the finished password
	$pw = str_shuffle($pw);

	return $pw;

}