Location: PHPKode > scripts > WH Board > wh_board/signup.php
<?php require('style/layout/header.php'); ?>

    <div class="content_left">
        <ul id="breadcrumbs">
            <li><a href="index.php"><?php echo $lang['main_page']; ?></a></li>
            <li><a href="signup.php" class="actual"><?php echo $lang['signup']; ?></a></li>
        </ul>
    </div>
    <div class="content_right"><form method="post" id="search" action="search.php?search">
        <input type="text" name="search" placeholder="<?php echo $lang['enter_search_term']; ?>..." class="searchfield">
        <input type="hidden" name="submit" value="<?php echo $lang['search']; ?>" alt="<?php echo $lang['search']; ?>">
        </form>
    </div>

    <div class="clear"></div>

    <div id="headline">&nbsp;</div>

    <?php

		echo '<h1>' . $lang['signup'] . '</h1>';

        include_once('functions/flood.php');
		include_once('functions/iplock.php');

		if($_SERVER['REQUEST_METHOD'] != 'POST') {

		echo '<form method="post" action="">
        <p><input type="text" class="textfields" name="user_name" size="30"> User Name</p>
        <p><input type="password" class="textfields" name="user_pass" size="30"> ' . $lang['password'] . '</p>
        <p><input type="password" class="textfields" name="user_pass_check" size="30"> ' . $lang['password_repeat'] . '</p>
        <p><input type="email" class="textfields" name="user_email" size="30"> ' . $lang['email_adress'] . '</p>
        <p><small>' . $lang['spam_protection'] . '*</small><br>
        <strong>' . $lang['the_sum_of'] . ' ' . $random1 . ' + ' . $code . ' =</strong> <input size="5" name="zip" id="Spamschutz" type="text" class="protection"><input type="hidden" name="zip2" value=' . $rand_result . '></p>
        <p><input type="submit" name="submit" value="' . $lang['sign_up']. '" alt="' . $lang['sign_up'] . '" class="buttons"></p>
        </form>';

        echo '<div class="clear_blog"></div>';
	    include_once('functions/rules.php');

			}else{

            $iplock_register = $_SERVER['REMOTE_ADDR'];

			if(sha1($_POST["zip"]) != $_POST["zip2"]) {

			echo '<p class="false">' . $lang['spam_failed'] . '!</p>
            <p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';

		}else{

        if(isset($_POST['user_name'])) {

        $user = htmlentities($_POST['user_name']);
        $sql_check = mysql_query("SELECT user_id FROM users WHERE user_name='" . mysql_real_escape_string($user) . "'") OR die(mysql_error());

            if(intval(mysql_num_rows($sql_check))) {

            echo '<p class="false">' . $lang['user_name_forgive'] . '</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[] = $lang['reg_name_allowed'];
		}

		if(strlen($_POST['user_name']) > 30) {
		$errors[] = $lang['reg_not_longer'];
		}

			}else{
			$errors[] = $lang['enter_user_name'];
			}

		if(isset($_POST['user_pass'])) {
		if(trim($_POST['user_pass']) == "") {
		$errors[] = $lang['not_enter_pass'];
		}

		if($_POST['user_pass'] != $_POST['user_pass_check']) {
		$errors[] = $lang['no_pass_match'];
		}

			}else{
			$errors[] = $lang['not_enter_pass'];
			}

		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[] = $lang['invalid_syntax'];
		}

			}else{
			$errors[] = $lang['fill_in_email'];
			}

		if(!empty($errors)) {

		echo '<p class="false">' . $lang['not_filled_all'] . '</p>
		<p>[ <a href="javascript:history.back();">' . $lang['back'] . '</a> ]</p>';
		echo '<ul>';

		foreach($errors as $key => $value) {
		echo '<li>&#8226; ' . $value . '</li>';
		}
		echo '</ul>';

			}else{

			$ipcheck = mysql_query("SELECT iplock_register FROM iplock WHERE iplock_register='" . $iplock_register . " '") OR die(mysql_error());

		if(!mysql_fetch_assoc($ipcheck)) {

		mysql_query("INSERT INTO iplock (iplock_register, iplock_timed) VALUES ('" . $iplock_register . "', NOW())") 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 '<p class="false">' . $lang['signup_failed'] . '</p>';

			}else{

			if($mailinfo == TRUE) {

			$subject1 = $lang['new_user_has_registered'];
			$body    = '' . $lang['new_user_has_registered'] . ': ' . $name . '.';

			mail("$webmaster","$subject1","$body");
			}


		$to = $email;
		$subject = '' . $title . ' - ' . $lang['complete_registration'] . '';
		$message = '' . $lang['tanks_for_registering'] . '!
' . $lang['activate_your_account'] . '.

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

' . $forum . 'verify.php?user=' . $name . '&hash=' . $hash . '
';

		$headers = 'From:' . $webmaster . '' . "\r\n";
		mail($to, $subject, $message, $headers);

		$autoforward = 7;

		echo '<p class="success">' . $lang['signup_success'] . '!</p>
		<p>' . $lang['email_activation'] . '.</p>
		<p><meta http-equiv="refresh" content="' . $autoforward . '; URL=signin.php"></p>';
		}

			}else{

			echo '<p class="false">' . $lang['ip_lock'] . '</p>';
            }
        }

        }}}}

        echo '<div class="cleaning"></div>';

	?>

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