<?php
/*===================================================+ 
|| # HoloCMS - Website and Content Management System
|+===================================================+ 
|| # Copyright © 2012 DnT [Tutti i diritti riservati]
|| # http://dnt.webnet32.com/
|+===================================================+ 
|| # DnT HoloCMS v2 - Created By Donatello (DnT)
|| # http://code.google.com/p/dnt-project/downloads/list
|+===================================================*/ 


require_once("../core.php");
session_start();
if(!$_SESSION['reg_date'] || !$_SESSION['reg_gender'] || !$_SESSION['reg_name'] || !$_SESSION['reg_email'] || !$_SESSION['reg_password'])
{
	header("Location: ".$path."quickregister/start");
	unset($_SESSION['reg_date']);
	unset($_SESSION['reg_gender']);
	unset($_SESSION['reg_name']);
	unset($_SESSION['reg_email']);
	unset($_SESSION['reg_password']);
}
if(is_numeric($_GET['p']))
{
	if(($_SESSION['register-captcha-bubble'] == strtolower($_POST['captchaResponse']) && !empty($_SESSION['register-captcha-bubble'])))
	{
		
		unset($_SESSION['register-captcha-bubble']);
		$password = HoloHash($_SESSION['reg_password'],$_SESSION['reg_name']);
		$username = $_SESSION['reg_name'];
		$mail = $_SESSION['reg_email'];
		if(!preg_match("/^[0-9a-zA-Z\xE0-\xFF ]+$/i",$username)){
			unset($_SESSION['reg_date']);
			unset($_SESSION['reg_gender']);
			unset($_SESSION['reg_name']);
			unset($_SESSION['reg_email']);
			unset($_SESSION['reg_password']);
			header("Location: start");
			exit;
		}
		

	$rand = rand(0,4);
	$figure = '';
	switch($rand)
	{
		case 0:
		$figure = 'hr-145-31.hd-185-10.ch-255-62.lg-270-62.he-1601';
		break;
		
		case 1:
		$figure = 'hr-145-31.hd-185-10.ch-255-62.lg-270-62.he-1601';
		break;
		
		case 2:
		$figure = 'hr-145-31.hd-185-10.ch-255-62.lg-270-62.he-1601';
		break;
		
		case 3:
		$figure = 'hr-145-31.hd-185-10.ch-255-62.lg-270-62.he-1601';
		break;
		
		case 4:
		$figure = 'hr-145-31.hd-185-10.ch-255-62.lg-270-62.he-1601';
		break;
	}

    mysql_query("INSERT INTO users (username, vip_points, real_name, password, mail, credits, look, motto, account_created, last_online, ip_last, ip_reg, home_room) VALUES ('".$username."', '15', '".FilterText($real_name)."', '".$password."', '".$mail."', '50000', '".$figure."', '".$motto."Benvenuto in $shortname Hotel! ;D', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['REMOTE_ADDR']."', '".$home_room."')");
    $user_id = mysql_insert_id();
    mysql_query("INSERT INTO user_stats (id, RoomVisits, OnlineTime, Respect, RespectGiven, GiftsGiven, GiftsReceived, DailyRespectPoints, DailyPetRespectPoints) VALUES ('".$user_id."', 0, 0, 0, 0, 0, 0, 3, 3)");
    mysql_query("INSERT INTO user_info (user_id, bans, cautions, reg_timestamp, login_timestamp, cfhs, cfhs_abusive) VALUES ('".$user_id."', '0', '0', UNIX_TIMESTAMP(), '0', '0', '0')");


		if($email_force_verify == true)
		{
		$hash = "";
		$length = 8;
		$possible = "0123456789qwertyuiopasdfghjkzxcvbnm";
		$i = 0;
		while ($i < $length) {
			$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
			if (!strstr($hash, $char)) {
				$hash .= $char;
				$i++;
			}
		}
		$hash = sha1($hash);
		mysql_query("INSERT INTO cms_verify (name,email,key_hash) VALUES ('".$_SESSION['reg_name']."','".$_SESSION['reg_email']."','".$hash."')");
		
		header("Location: /verify?email=".$_SESSION['reg_email']."&hash=".$hash."&name=".$_SESSION['reg_name']."&date=".$_SESSION['reg_date']);
		exit;
		
		}else{
			unset($_SESSION['reg_date']);
			unset($_SESSION['reg_gender']);
			unset($_SESSION['reg_name']);
			unset($_SESSION['reg_email']);
			unset($_SESSION['reg_password']);
			
			$location = "../security_check?welcome=true";
			
			$_SESSION['username'] = $username;
			$_SESSION['password'] = $password;

			header("Location: ".$location);
			 
		}
	}else{

		$error = '<div id="error-messages-container" class="cbb">

		<div class="rounded" style="background-color: #cb2121;">

		<div id="error-title" class="error">

		Questo codice di sicurezza non &egrave; valido, inseriscilo nuovamente <br />

		</div>

		</div>

		</div>';
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:og="http://opengraphprotocol.org/schema/">

<head>

	<meta http-equiv="content-type" content="text/html; charset=utf-8" />

	<title><?php echo $sitename; ?>: Registrazione 3/3</title>

	


<script type="text/javascript">

var andSoItBegins = (new Date()).getTime();

</script>

<script src="/web-gallery/static/js/visual.js" type="text/javascript"></script>

<script src="/web-gallery/static/js/libs.js" type="text/javascript"></script>

<link rel="stylesheet" href="/web-gallery/v2/styles/captcha.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/style.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/buttons.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/boxes.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/tooltips.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/changepassword.css" type="text/css" />

<link rel="stylesheet" href="/web-gallery/v2/styles/quickregister.css" type="text/css" />

<script src="/web-gallery/static/js/common2.js" type="text/javascript"></script>

<script type="text/javascript">

var ad_keywords = "";

var ad_key_value = "";

</script>
<div class="middle_image"></div>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
	var img = document.images['captcha'];
	img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>

<script type="text/javascript">

document.habboLoggedIn = true;

var habboName = null;

var habboReqPath = "/";

var habboStaticFilePath = "./web-gallery";

var habboImagerUrl = "http://www.habbo.it/habbo-imaging/";

var habboPartner = "Meth0d.org";

window.name = "habboMain";



</script>



<link rel="stylesheet" href="/web-gallery/v2/styles/forcedemaillogin.css" type="text/css" />
<script src="/web-gallery/static/js/landing.js" type="text/javascript"></script>


<meta name="description" content="<?php echo $shortname; ?> Hotel &egrave; un hotel in cui puoi conoscere tanti nuovi Amici!" />

<meta name="keywords" content="<?php echo $shortname; ?>,<?php echo $shortname; ?> Hotel,virtuale, mondo, social network, gratis, community, avatar, personaggio, chat, online, giovane, gruppi, forum, sicurezza, giocare, giochi, online, amici, rari, furni rari, collezione, creare, collezionare, furni, creare stanze, distintivi, badge, uscire, mmo, mmorpg, multiplayer" />



<!--[if IE 8]>

<link rel="stylesheet" href="/web-gallery/v2/styles/ie8.css" type="text/css" />

<![endif]-->

<!--[if lt IE 8]>

<link rel="stylesheet" href="/web-gallery/v2/styles/ie.css" type="text/css" />

<![endif]-->

<!--[if lt IE 7]>

<link rel="stylesheet" href="/web-gallery/v2/styles/ie6.css" type="text/css" />

<script src="/web-gallery/static/js/pngfix.js" type="text/javascript"></script>

<script type="text/javascript">

try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

</script>



<style type="text/css">

body { behavior: url(/js/csshover.htc); }

</style>

<![endif]-->

</head>

<div id="forced-email-login" style="display: none;">

<div id="forced-email-login-container" class="clearfix">

<div id="forced-email-login-title" class="bottom-border">Hai dimenticato la password?</div>

<div class="bottom-border">
<ul id="forced-email-login-content" class="clearfix">

<li>
<span>Ciao! Ti abbiamo appena inviato un'email con il link alla pagina in cui potrai modificare la tua Password.</span>
</li>
<div class="change-password-buttons">
	<div id="email-sent-container"><?php echo $_POST['emailAddress']; ?></div>
</div>

</ul>
</div>

<a href="#" id="force-email-ok-button" class="new-button"><b>Chiudi</b><i></i></a>

</div>
<div id="forced-email-login-container-bottom"></div>

</div>  

<body id="client" class="background-accountdetails-male">

<div id="overlay"></div>

<img src="/web-gallery/v2/images/page_loader.gif" style="position:absolute; margin: -1500px;" />


<div id="stepnumbers">

    <div class="stepdone">Data di nascita e sesso</div>

    <div class="stepdone">Dettagli Account</div>

    <div class="step3focus">Controllo sicurezza</div>

</div>



<div id="main-container">

       <div id="error-placeholder"></div><div id="bubble-container" class="cbb">

        <div id="bubble-content" class="rounded">

             <div id="bubble-title">

                Controllo sicurezza

            </div>

            <div id="captcha-image-container">

<div id="captcha_image"><img id="captcha" src="/captcha/captcha?rand=<?php echo rand(); ?>" width="300" height="60"></div>
            </div>

            <div id="captcha-reload-container">

                <a id="recaptcha-reload" href="javascript:refreshCaptcha();">Prova ad usare altre parole</a>

            </div>

        </div>

    </div>

    <div class="delimiter_smooth">

        <div class="flat">&nbsp;</div>

        <div class="arrow">&nbsp;</div>

        <div class="flat">&nbsp;</div>

    </div>

    <div id="inner-container">
<?php echo $error; ?>
        <form id="captcha-form" method="post" action="/quickregister/captcha?p=2" onsubmit="Overlay.show(null,'Caricamento...');">

            <div id="recaptcha-input-title">Scrivi la parola che vedi nell'immagine:</div>

            <div id="recaptcha-input">

                <input type="text" tabindex="2" name="captchaResponse" id="recaptcha_response_field">

            </div>

        </form>

    </div>

    <div id="select">
        <a href="/quickregister/email_password" id="back-link">Torna indietro</a>

        <div class="button">

            <a id="proceed-button" href="#" class="area">Fatto</a>

            <span class="close"></span>

        </div>

   </div>

    <script type="text/javascript">

	document.observe("dom:loaded", function() {

    Event.observe($("captcha-reload"), "click", function(e) {Utils.reloadCaptcha()});

});

            if($("proceed-button")) {

                $("proceed-button").observe("click", function(e) {

                    Event.stop(e);

                    Overlay.show(null,'Loading...');

                    $("captcha-form").submit();

                });

                Event.observe($("back-link"), "click", function() {

                    Overlay.show(null,'Loading...');

                });

            }



    </script>

</div>



<script type="text/javascript">

    HabboView.run();

</script>



</body>

</html>