Location: PHPKode > projects > WH Community > wh_community/setup/admin.php
<?php

    define('CONFIG_CHECK', 1);
    define('MYSQL_CHECK', 1);

	if(file_exists('../framework/mysql.php') == TRUE)
        include_once('../framework/config.php');
        include_once('../framework/mysql.php');

		if($language == "de") {
			require('../language/de.php');

		}elseif ($language == "en") {
			require('../language/en.php');

    }else{

	echo '<p class="false">' . $lang['config_not_found'] . '!</p><br>';
	exit;
	}

?>
<!DOCTYPE html>
<html>

<head>
    <title><?php echo $title; ?></title>

    <meta charset="ISO-8859-1" />

    <link href="../css/design.css" rel="stylesheet" />
    <link href="../images/favicon.ico" rel="shortcut icon" />

    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>

<body>

<div id="main">

<div id="wrapper">

<div id="header_wrapper">
    <div class="header">
        <div class="header_left"><img src="../images/logo.png" alt="Logo"></div>
        <div class="header_right"><span class="news_blue">Forum - Installation</span><br>
		<span class="datetime"><strong>(<?php echo $lang['step']; ?> 2/2)</strong></span></div>
    </div>
</div>

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

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

		<?php

		if($_SERVER['REQUEST_METHOD'] != 'POST') {
		
		echo '<p><span class="news_blue">' . $lang['create_your_admin'] . '</span></p>';
		
		echo '<form method="post" action="">
			  <p><input type="text" class="fields" name="user_name" size="30"> <strong>Admin 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><input type="submit" class="button" value="' . $lang['create'] . '" alt="' . $lang['create'] . '"></p>
			  </form>';
		 
		}else{
	
		$errors = array();
		
		if(isset($_POST['user_name'])) {
			if(!ctype_alnum($_POST['user_name'])) {
			$errors[] = '<p>' . $lang['reg_name_allowed'] . '.</p><br>';
			}
			
			if(strlen($_POST['user_name']) > 30) {
			$errors[] = '<p>' . $lang['reg_not_longer'] . '.</p><br>';
			}
		
		}else{
		$errors[] = '<p>' . $lang['reg_fill_name'] . '.</p><br>';
		}
		
		if(isset($_POST['user_pass'])) {
			if(trim($_POST['user_pass']) == "") {
			$errors[] = '<p>' . $lang['not_enter_pass'] . '.</p><br>';
			}
			
			if($_POST['user_pass'] != $_POST['user_pass_check']) {
			$errors[] = '<p>' . $lang['no_pass_match'] . '.</p><br>';
			}
			
		}else{
		$errors[] = '<p>' . $lang['fill_in_pass'] . '.</p><br>';
		}
		
		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><br>';
			}
		
		}else{
		$errors[] = '<p>' . $lang['fill_in_email'] . '.</p><br>';
		}
		
		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>' . $value . '</li>'; 
			}
			echo '</ul>';
		
		}else{
		
		$hash = mt_rand(0, 1000);
		$sql = "INSERT INTO
						users(user_name, user_pass, user_email ,user_date, user_level, user_active, 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(),
						'1',
						'1',
						'" . mysql_real_escape_string($hash) . "')";
							
			$result = mysql_query($sql);
			
			if(!$result) {
			
			echo '<p class="false">' . $lang['not_created_admin'] . '.</p>';
			
				}else{
				
				echo '<p class="right">' . $lang['success_created_admin'] . '</p>';
				echo '<p>' . $lang['now_create_cats'] . ' => [ <a href="../admin/signin.php">' . $lang['to_admin_area'] . '</a> ]</p><br>';
				
				echo '<p class="false"><small>' . $lang['dont_forget_delete'] . '</small></p>';
				echo '<p>' . $lang['good_luck'] . ' w&uuml;nscht WebmasterHelp.net</p>';
				}
			}}

        echo '<div class="spacer_div">&nbsp;</div>';

		?>

    </div>
</div>

</div>

</div>

</body>
</html>
Return current item: WH Community