Location: PHPKode > projects > WH Community > wh_community/signup.php
<?php require('layout/header.php'); ?>

    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['success_registration']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_registration']; ?>"
    	});    
        }                                
    </script>

<div id="content_wrapper">
    <div class="content"><?php

		include_once('functions/flood.php');
		include_once('functions/iplock.php');
		
		echo '<h1>' . $lang['registration'] . '</h1><br>';
		
		if($_SERVER['REQUEST_METHOD'] != 'POST') {
		
		echo '<form method="post" action="">
    		  <p><input type="text" class="fields" name="user_name" size="30"> <strong>User Name</strong></p>
    		  <p><input type="password" class="fields" name="user_pass" size="30"> <strong>' . $lang['password'] . '</strong></p>
    		  <p><input type="password" class="fields" name="user_pass_check" size="30"> <strong>' . $lang['new_pass_repeat'] . '</strong></p>
    		  <p><input type="email" class="fields" name="user_email" size="30"> <strong>' . $lang['email_adress'] . '</strong></p>
    		  <p><small>' . $lang['spam_protection_question'] . ' *</small><br>
    		  <strong>' . $lang['sum_of'] . ' ' . $random1 . ' + ' . $code . ' =</strong> <input size="5" name="zip" id="Spamschutz" type="text" class="fields" /><input type="hidden" name="zip2" value=' . $rand_result . '></p>
    		  <p><input type="submit" class="button" value="' . $lang['to_register'] . '" alt="' . $lang['to_register'] . '"></p>
    		  </form><br>';
    	
		    include_once('functions/rules.php');
		
			}else{
			
			if(sha1($_POST["zip"]) != $_POST["zip2"]) {
			
			echo '<p class="false">' . $lang['invalid_spam'] . '!</p>
			      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
		
		}else{
		
		$errors = array();
		
		if(isset($_POST['user_name'])) {
		if(!ctype_alnum($_POST['user_name'])) {
		$errors[] = '<p>' . $lang['reg_name_allowed'] . '.</p>';
		}
		
		if(strlen($_POST['user_name']) > 30) {
		$errors[] = '<p>' . $lang['reg_not_longer'] . '.</p>';
		}
		
			}else{
			$errors[] = '<p>' . $lang['reg_fill_name'] . '.</p>';
			}
		
		if(isset($_POST['user_pass'])) {
		if(trim($_POST['user_pass']) == "") {
		$errors[] = '<p>' . $lang['not_enter_pass'] . '.</p>';
		}
		
		if($_POST['user_pass'] != $_POST['user_pass_check']) {
		$errors[] = '<p>' . $lang['no_pass_match'] . '.</p>';
		}
		
			}else{
			$errors[] = '<p>' . $lang['fill_in_pass'] . '.</p>';
			}
		
		if(isset($_POST['user_email'])) {
		$user_email = mysql_escape_string($_POST['user_email']);  
		
		if(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $user_email)) {
		$errors[] = '<p>' . $lang['invalid_syntax'] . '.</p>';
		}
		
			}else{
			$errors[] = '<p>' . $lang['fill_in_email'] . '.</p>';
			}
		
		if(!empty($errors)) {
		
		echo '<p class="false"><u>' . $lang['not_filled_all'] . '</u></p>
		      <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p><br>';
		echo '<ul>';
		
		foreach($errors as $key => $value) {
		echo '<li>' . $value . '</li>'; 
		}
		echo '</ul>';
		
			}else{
			
			$pruef = mysql_query("SELECT register FROM iplock WHERE register='$register'") OR die(mysql_error());
		
		if(!mysql_fetch_assoc($pruef)) {
		
		mysql_query("INSERT INTO iplock (register, time) VALUES ('$register', '$jetzt')") OR die(mysql_error());
		
		$hash = mt_rand(0, 1000);
		$email = mysql_real_escape_string($_POST['user_email']);
		$name = mysql_real_escape_string($_POST['user_name']);
		$pass = mysql_real_escape_string($_POST['user_pass']);
		
		$sql = "INSERT INTO
					users(user_name, user_pass, user_email ,user_date, user_level, user_hash)
				VALUES('" . mysql_real_escape_string($_POST['user_name']) . "',
					'" . mysql_real_escape_string(sha1($_POST['user_pass'])) . "',
					'" . mysql_real_escape_string($_POST['user_email']) . "',
					NOW(),
					'0',
					'" . mysql_real_escape_string($hash) . "')";
		
		$result = mysql_query($sql) OR die(mysql_error());
		
		if(!$result) {
		
		echo '<br><p class="false">' . $lang['couldnot_registration'] . '</p><br>';
		echo "<script type=\"text/javascript\">showErrorMessage();</script>";
		
			}else{
			
			if($mailinfo == TRUE) {
			
			$subject1 = '' . $lang['user_has_registered'] . '';
			$body    = '' . $name . ' ' . $lang['just_registered'] . '.

' . $lang['goto_forum'] . ': ' . $forum . '
';
			
			mail("$webmaster","$subject1","$body");
			}
		
		
		$to = $email;
		$subject = '' . $title . ' - ' . $lang['your_registration'] . '';
		$message = '' . $lang['thanks_registration'] . '
' . $lang['verify_first'] . '

-------------------------------
User Name: ' . $name . '
' . $lang['password'] . ':  ' . $pass . '
-------------------------------

' . $lang['click_verify_link'] . ':

' . $forum . 'verify.php?user=' . $name . '&hash=' . $hash . '
';
		
		$headers = 'From:' . $webmaster . '' . "\r\n";
		mail($to, $subject, $message, $headers);
		
		$autoforward = 7;
		
		echo '<p class="right">' . $lang['success_registration'] . '</p>
		<p>' . $lang['now_goto_activate'] . '.</p>
		<p><meta http-equiv="refresh" content="' . $autoforward . '; URL=signin.php">
		<small>(' . $lang['redirected_in'] . ' ' . $autoforward . ' ' . $lang['seconds'] . '...)</small></p>';
		echo "<script type=\"text/javascript\">showSuccessMessage();</script>";
		}
		
			}else{
			
			echo '<p class="false">' . $lang['ip_lock'] . '.</p>';
			echo "<script type=\"text/javascript\">showErrorMessage();</script>";
			
        }}}}
		
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community