ayuda con el reg.php xfavor

serlli
23 de Mayo del 2008
wenas jente a ver si me podeis echar una mano dios estoy muy liado miren esto va de un juego donde al registrase (aora pondre los codigos mas abajo) teneis que poner un nombre de usuario y contraseña y edad y nombre de tu casa y sexo.estos datos se enviaran por correo electronico al jugador.

entonces queria añadir algo para tambien dar a elegir la poscion donde quiere que se cree la casa.

por que con este codigo que tengo sale aleatoria la casa en cualquier lugar y asi cuando pongan todos los datos tambien puedan elegir donde la kieren poscion.

y si ya esta ocupada ese lugar que salte un error y que pueda elegir otro lugar.

miren aki esta los 3 codigos uno es el reg.php y el otro es el template registry_form.tpl y ahy otro mas que es el reg.mo donde esta todo el lenguaje de la pagina reg

aki reg.php
Cita:
<?php

/**
* reg.php
*
* @version 1.1
* @copyright 2008 by serllidance
*/

define('INSIDE' , true);
define('INSTALL' , false);

includeLang('reg');

function sendpassemail($emailaddress, $password) {
global $lang;

$parse['gameurl'] = GAMEURL;
$parse['password'] = $password;
$email = parsetemplate($lang['mail_welcome'], $parse);
$status = mymail($emailaddress, $lang['mail_title'], $email);
return $status;
}

function mymail($to, $title, $body, $from = '') {
$from = trim($from);

if (!$from) {
$from = ADMINEMAIL;
}

$rp = ADMINEMAIL;

$head = '';
$head .= "Content-Type: text/html ";
$head .= "charset: iso-8859-1 ";
$head .= "Date: " . date('r') . " ";
$head .= "Return-Path: $rp ";
$head .= "From: $from ";
$head .= "Sender: $from ";
$head .= "Reply-To: $from ";
$head .= "Organization: $org ";
$head .= "X-Sender: $from ";
$head .= "X-Priority: 3 ";
$body = str_replace(" ", " ", $body);
$body = str_replace(" ", " ", $body);

return mail($to, $title, $body, $head);
}

if ($_POST) {
$errors = 0;
$errorlist = "";

$_POST['email'] = strip_tags($_POST['email']);
if (!is_email($_POST['email'])) {
$errorlist .= """ . $_POST['email'] . "" " . $lang['error_mail'];
$errors++;
}

if (!$_POST['planet']) {
$errorlist .= $lang['error_planet'];
$errors++;
}

if (preg_match("/[^A-z0-9_-]/", $_POST['hplanet']) == 1) {
$errorlist .= $lang['error_planetnum'];
$errors++;
}

if (!$_POST['character']) {
$errorlist .= $lang['error_character'];
$errors++;
}

if (strlen($_POST['passwrd']) < 4) {
$errorlist .= $lang['error_password'];
$errors++;
}

if (preg_match("/[^A-z0-9_-]/", $_POST['character']) == 1) {
$errorlist .= $lang['error_charalpha'];
$errors++;
}

if ($_POST['rgt'] != 'on') {
$errorlist .= $lang['error_rgt'];
$errors++;
}

// aja
$ExistUser = doquery("SELECT `username` FROM {{table}} WHERE `username` = '". mysql_escape_string($_POST['character']) ."' LIMIT 1;", 'users', true);
if ($ExistUser) {
$errorlist .= $lang['error_userexist'];
$errors++;
}

// aja 2
$ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '". mysql_escape_string($_POST['email']) ."' LIMIT 1;", 'users', true);
if ($ExistMail) {
$errorlist .= $lang['error_emailexist'];
$errors++;
}

if ($_POST['sex'] != '' &&
$_POST['sex'] != 'F' &&
$_POST['sex'] != 'M') {
$errorlist .= $lang['error_sex'];
$errors++;
}

if ($errors != 0) {
message ($errorlist, $lang['Register']);
} else {
$newpass = $_POST['passwrd'];
$UserName = CheckInputStrings ( $_POST['character'] );
$UserEmail = CheckInputStrings ( $_POST['email'] );
$UserPlanet = CheckInputStrings ( $_POST['planet'] );

$md5newpass = md5($newpass);
// Creation de l'utilisateur
$QryInsertUser = "INSERT INTO {{table}} SET ";
$QryInsertUser .= "`username` = '". mysql_escape_string(strip_tags( $UserName )) ."', ";
$QryInsertUser .= "`email` = '". mysql_escape_string( $UserEmail ) ."', ";
$QryInsertUser .= "`email_2` = '". mysql_escape_string( $UserEmail ) ."', ";
$QryInsertUser .= "`sex` = '". mysql_escape_string( $_POST['sex'] ) ."', ";
$QryInsertUser .= "`id_planet` = '0', ";
$QryInsertUser .= "`register_time` = '". time() ."', ";
$QryInsertUser .= "`new_message` = '1', ";
$QryInsertUser .= "`password`='". $md5newpass ."';";
doquery( $QryInsertUser, 'users');

// On cherche le numero d'enregistrement de l'utilisateur fraichement créé
$NewUser = doquery("SELECT `id` FROM {{table}} WHERE `username` = '". mysql_escape_string($_POST['character']) ."' LIMIT 1;", 'users', true);
$iduser = $NewUser['id'];

//Mensaje de bienvenida
$msgwelcome = addslashes ( $game_config['mp_bienvenue']);

// Envoie du message de bienvenue
$QryInsertUser = "INSERT INTO {{table}} SET ";
$QryInsertUser .= "`message_id` = '', ";
$QryInsertUser .= "`message_owner` = '" . $iduser . "', ";
$QryInsertUser .= "`message_sender` = '0', ";
$QryInsertUser .= "`message_time` = '" . time() . "', ";
$QryInsertUser .= "`message_type` = '0', ";
$QryInsertUser .= "`message_from` = 'Administrador', ";
$QryInsertUser .= "`message_subject` = 'Bienvenido !', ";
$QryInsertUser .= "`message_text` = '" . $msgwelcome . "';";
doquery( $QryInsertUser, 'messages');

// Recherche d'une place libre !
$LastSettedGalaxyPos = $game_config['LastSettedGalaxyPos'];
$LastSettedSystemPos = $game_config['LastSettedSystemPos'];
$LastSettedPlanetPos = $game_config['LastSettedPlanetPos'];
while (!isset($newpos_checked)) {
for ($Galaxy = $LastSettedGalaxyPos; $Galaxy <= MAX_GALAXY_IN_WORLD; $Galaxy++) {
for ($System = $LastSettedSystemPos; $System <= MAX_SYSTEM_IN_GALAXY; $System++) {
for ($Posit = $LastSettedPlanetPos; $Posit <= 4; $Posit++) {
$Planet = round (rand ( 4, 12) );

switch ($LastSettedPlanetPos) {
case 1:
$LastSettedPlanetPos += 1;
break;
case 2:
$LastSettedPlanetPos += 1;
break;
case 3:
if ($LastSettedSystemPos == MAX_SYSTEM_IN_GALAXY) {
$LastSettedGalaxyPos += 1;
$LastSettedSystemPos = 1;
$LastSettedPlanetPos = 1;
break;
} else {
$LastSettedPlanetPos = 1;
}
$LastSettedSystemPos += 1;
break;
}
break;
}
break;
}
break;
}

$QrySelectGalaxy = "SELECT * ";
$QrySelectGalaxy .= "FROM {{table}} ";
$QrySelectGalaxy .= "WHERE ";
$QrySelectGalaxy .= "`galaxy` = '". $Galaxy ."' AND ";
$QrySelectGalaxy .= "`system` = '". $System ."' AND ";
$QrySelectGalaxy .= "`planet` = '". $Planet ."' ";
$QrySelectGalaxy .= "LIMIT 1;";
$GalaxyRow = doquery( $QrySelectGalaxy, 'galaxy', true);

if ($GalaxyRow["id_planet"] == "0") {
$newpos_checked = true;
}

if (!$GalaxyRow) {
CreateOnePlanetRecord ($Galaxy, $System, $Planet, $NewUser['id'], $UserPlanet, true);
$newpos_checked = true;
}
if ($newpos_checked) {
doquery("UPDATE {{table}} SET `config_value` = '". $LastSettedGalaxyPos ."' WHERE `config_name` = 'LastSettedGalaxyPos';", 'config');
doquery("UPDATE {{table}} SET `config_value` = '". $LastSettedSystemPos ."' WHERE `config_name` = 'LastSettedSystemPos';", 'config');
doquery("UPDATE {{table}} SET `config_value` = '". $LastSettedPlanetPos ."' WHERE `config_name` = 'LastSettedPlanetPos';", 'config');
}
}
// Recherche de la reference de la nouvelle planete (qui est unique normalement !
$PlanetID = doquery("SELECT `id` FROM {{table}} WHERE `id_owner` = '". $NewUser['id'] ."' LIMIT 1;", 'planets', true);

// Mise a jour de l'enregistrement utilisateur avec les infos de sa planete mere
$QryUpdateUser = "UPDATE {{table}} SET ";
$QryUpdateUser .= "`id_planet` = '". $PlanetID['id'] ."', ";
$QryUpdateUser .= "`current_planet` = '". $PlanetID['id'] ."', ";
$QryUpdateUser .= "`galaxy` = '". $Galaxy ."', ";
$QryUpdateUser .= "`system` = '". $System ."', ";
$QryUpdateUser .= "`planet` = '". $Planet ."' ";
$QryUpdateUser .= "WHERE ";
$QryUpdateUser .= "`id` = '". $NewUser['id'] ."' ";
$QryUpdateUser .= "LIMIT 1;";
doquery( $QryUpdateUser, 'users');

// Mise a jour du nombre de joueurs inscripts
doquery("UPDATE {{table}} SET `config_value` = `config_value` + '1' WHERE `config_name` = 'users_amount' LIMIT 1;", 'config');

$Message = $lang['thanksforregistry'];
if (sendpassemail($_POST['email'], "$newpass")) {
$Message .= " (" . htmlentities($_POST["email"]) . ")";
} else {
$Message .= " (" . htmlentities($_POST["email"]) . ")";
$Message .= "<br><br>". $lang['error_mailsend'] ." <b>" . $newpass . "</b>";
}
message( $Message, $lang['reg_welldone']);
}
} else {
// Afficher le formulaire d'enregistrement
$parse = $lang;
$parse['servername'] = $game_config['game_name'];
$page = parsetemplate(gettemplate('registry_form'), $parse);

display ($page, $lang['registry'], false);
}

// -----------------------------------------------------------------------------------------------------------
// version by serllidance

?>