Location: PHPKode > projects > PhpBlock > A9.8/script/lockaccount/functionlockplayer.php
<?php
function updateUnlockStr($parPlayerId) {
	$headers ='From: hide@address.com';
	$locStr = md5(rand().rand().rand().rand().rand().rand());
	$locUrl = Site::$INSTALLATION_PATH_TO_BASE."/script/lockaccount/unlockplayer.php?playerId=$parPlayerId&unlock=$locStr";

	global $gloObjectManager;
	$locPlayer = $gloObjectManager->getPlayer($parPlayerId);

	$locMessage="Hi $locPlayer->playerName, you create an account on ".Site::$INSTALLATION_PATH_TO_BASE.", to unlock your account go on this url: ";
	$locMessage.=" $locUrl";

	$row = mysql_fetch_array(executer("SELECT email FROM player WHERE playerId=$parPlayerId"));
	
	$locEmail=$row[0];
	
	if(!mail("$locEmail", "[PhpBlock][Dungeon]email to unlock your account", "$locMessage", $headers)) {
		echo "<br>mail not sent<br>";
	}
	
	executer("UPDATE player SET unlockStr='$locStr' WHERE playerId=$parPlayerId");
}
function sendAnEmailToAccountAndLockIt($parEmail, $parPlayerId, $parPlayerName) {
	executer("UPDATE player SET isLock=1, email='$parEmail' WHERE playerId=$parPlayerId");
	updateUnlockStr($parPlayerId);
}
function isLock($parPlayerId) {
	return mysql_fetch_array(executer("SELECT * FROM player WHERE isLock=1 AND playerId=$parPlayerId"));
}
// checkdnsrr() support for Windows by HM2K <php [spat] hm2k.org>
function win_checkdnsrr($host, $type='MX') {
    if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { return; }
    if (empty($host)) { return; }
    $types=array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
    if (!in_array($type,$types)) {
        user_error("checkdnsrr() Type '$type' not supported", E_USER_WARNING);
        return;
    }
    @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output);
    foreach($output as $line){
        if (preg_match('/^'.$host.'/',$line)) { return true; }
    }
}
// Define
if (!function_exists('checkdnsrr')) {
    function checkdnsrr($host, $type='MX') {
        return win_checkdnsrr($host, $type);
    }
}
function checkEmail($email) {
	if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email)){
		list($username,$domain)=split('@',$email);
		if(!checkdnsrr($domain,'MX')) {
			return false;
		}
		return true;
	}
	return false;
}
?>
Return current item: PhpBlock