Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/initplayer.php
<?php

//FIXME : avoid multi creation of player in same time

include_once "../../site.class.php";
include_once $PATH_TO_CODE."/script/connect.php";
include_once $PATH_TO_CODE."/script/player.class.php";
include_once $PATH_TO_CODE."/script/server.class.php";
include_once $PATH_TO_CODE."/script/message/playermessage.class.php";
include_once $PATH_TO_CODE."/script/lockaccount/functionlockplayer.php";

include_once $PATH_TO_CODE."/script/log.class.php";
include_once $PATH_TO_CODE."/script/disconnect.php";
include_once $PATH_TO_CODE."/modules/dungeon/objectmanager.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/dungeonserver.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/dungeonfunction.php";

Log::getInstance()->isDebugOn = false;
$locPlayerEmail = getGetPost("email");
$locPlayerLogin = getGetPost("login");
$locAllianceName= getGetPost("allianceName");
$locLordName = getGetPost("lordName");
$locPlayerPassword = getGetPost("password");
$locPlayerType = getGetPost("playerType");
$locLanguage = getGetPost("language");

$gloParaError = "&language=$locLanguage&login=$locPlayerLogin&password=$locPlayerPassword&email=$locPlayerEmail
		&allianceName=$locAllianceName&lordName=$locLordName&playerType=$locPlayerType";

function errorInitPlayer($parMessage) {
	global $gloParaError;
	header("location: createplayer.php?warnmsg=$parMessage$gloParaError");
	exit(0);
}
function testPara($parPara) {
	if(!isset($_POST["$parPara"]) ||empty($_POST["$parPara"])) {
		errorInitPlayer("$parPara is empty");
	}	
}
global $gloObjectManager;
testPara("login");
testPara("allianceName");
testPara("lordName");
testPara("password");
testPara("email");
testPara("language");
testPara("allianceName");
testPara("color1");
testPara("color2");
testPara("color3");

if(strlen($_POST["color1"]) == 6
&& strlen($_POST["color2"]) == 6
&& strlen($_POST["color3"]) == 6) {

	$locColor1 = formatNumber(array_search($_POST["color1"], Constante::$COLOR_LIST), 2);
	$locColor2 = formatNumber(array_search($_POST["color2"], Constante::$COLOR_LIST), 2);
	$locColor3 = formatNumber(array_search($_POST["color3"], Constante::$COLOR_LIST), 2);

	$locResult = Player::testPlayerCreation($locLordName, $locAllianceName, $locPlayerLogin, $locPlayerPassword, "$locColor1$locColor2$locColor3", $locPlayerEmail, $parResultMessage);

	if($locResult) {
		$locPlayerId = $gloObjectManager->createNewPlayer($locLordName, $locAllianceName, $locPlayerLogin, $locPlayerPassword, "$locColor1$locColor2$locColor3");
		$locPlayer = $gloObjectManager->getPlayer($locPlayerId);
		$locPlayer->setAllianceId($locPlayerId);
		$locPlayer->setPlayerType($locPlayerType);
		$locPlayer->setLanguage($locLanguage);
		
		sendAnEmailToAccountAndLockIt($locPlayerEmail, $locPlayerId, $locPlayerLogin);
		echoAccountCreateSuccess($locPlayerLogin);
		disconnect();
	} else {
		errorInitPlayer($parResultMessage);
	}
} else {
	errorInitPlayer("player error");
}
function echoAccountCreateSuccess($parPlayerLogin) {
?>
<html>
<head>
<TITLE>Dungeon - account created</TITLE>
<?php echoBaseHead()?>
<link rel="stylesheet" href="css/phpblock.css" type="text/css" />
<link rel="stylesheet" href="modules/dungeon/css/interface.css"	type="text/css" />
</head>
<body class="dungeonstyle">
Welcome on dungeon <?php echo $parPlayerLogin?>, your account is created.
<br>
Return to the
<a href="modules/dungeon/login.php?login=<?php echo $parPlayerLogin?>">login page</a>
and use the key sent to your email (check your spam too !!!) to unlock your account
</body>
</html>
<?php
}
Return current item: PhpBlock