Location: PHPKode > scripts > phpEmailUser > login_reg_functions.php
<?php

/* phpemailuser by georgfly */

function randomword($wordlength)
{
	$chars = 'abcdefghijkmnpqrstuvwxyz23456789';
	srand((double)microtime()*1000000);
	$randword = '';
	for ($i = 0; $i < $wordlength; $i++)
	{
		$num = rand() % strlen($chars);
		$randword .= substr($chars, $num, 1);
	}
	return $randword;
}

function mysqli_get_colnames($connection,$table)
{
	$result = mysqli_query($connection,"SHOW COLUMNS FROM $table")
	or die("Query died: get columns.");
	$colnames = array();
	for ($i = 1; $i <= mysqli_num_rows($result); $i++)
	{
		$resultrow = mysqli_fetch_row($result);
		$colnames[] = $resultrow[0];
	}
	return $colnames;
}
 
function isValidEmail($email)
{
 //Perform a basic syntax-Check
 //If this check fails, there's no need to continue
 if(!filter_var($email, FILTER_VALIDATE_EMAIL))
 {
 return false;
 }
 
 //extract host
 list($user, $host) = explode("@", $email);
 //check, if host is accessible
 if (!checkdnsrr($host, "MX") && !checkdnsrr($host, "A"))
 {
 return false;
 }
 
 return true;
}

function mathscaptcha()
{
	$operations = array("plus","minus","times");
	$numberstrings = array("zero","one","two","three","four","five","six","seven","eight","nine","ten");
	srand((double)microtime()*1000000);
	$num1 = rand() % sizeof($numberstrings);
	$num2 = rand() % sizeof($numberstrings);
	$num3 = rand() % sizeof($operations);
	
	switch ($num3)
	{
		case 0:
			$result = $num1 + $num2;
		break;
		case 1:
			$result = $num1 - $num2;
		break;
		case 2:
			$result = $num1 * $num2;
		break;
	}
	$mystring = array($numberstrings[$num1],$operations[$num3],$numberstrings[$num2]);
	$returnarray = array($result,$mystring);

	return $returnarray;
}
?>
Return current item: phpEmailUser