Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class pages{
- function index(){
- include_once('template/header.php');
- include_once('template/menu.html');
- include_once('template/serverstats.php');
- include_once('template/slider.html');
- include_once('template/news.php');
- include_once('template/footer.php');
- }
- function register( $errors = false, $success = false )
- {
- global $main;
- echo('
- <div id="box4" class="box">
- <h1 id="heading4" class="heading">Registration</h1>
- <div class="content">
- <h1 class="title">Register</h1>
- <h2 class="meta">Register for our ingame server and forums!</h2>
- <p>
- <center>');
- if( $success != false) {
- echo('<img src="images/check_mark.png" /><span style="color:green;">'.$success.'</span>');
- }
- elseif( $errors != false )
- {
- $main->func->show_errors( $errors );
- }
- echo('
- <form action="?page=Register&act=do_register" method="post">
- <table border="0">
- <tr><td align="right">
- Username: </td><td><input type="text" name="username" />
- </td></tr>
- <tr><td align="right">
- Password: </td><td><input type="password" name="password" /><br />
- </td></tr>
- <tr><td align="right">
- Confirm Password: </td><td><input type="password" name="password_confirm" /><br />
- </td></tr>
- <tr><td align="right">
- Email: </td><td><input type="text" name="email" /><br />
- </td></tr>
- <tr><td align="right">
- Expansion: </td><td><select name="exp">
- <option value="0">No Expansion</option>
- <option value="1">Burning Crusade</option>
- <option value="1">Wrath of the Lich King</option>
- </select>
- <br />
- </td></tr>
- <tr><td colspan="2" align="center">
- <input type="submit" value="Register" class="button" />
- </td></tr></table>
- </p>
- </div>
- </div>
- ');
- }
- function do_register()
- {
- $errors = 0;
- global $main;
- $data = $main->func->cleanse( $_POST );
- $main->db->con( 'logon' );
- $email = 'select id from account where email = "'.$data['email'].'"';
- $username = 'select id from account where username = "'.$data['username'].'"';
- $email = $main->db->query( $email );
- $username = $main->db->query( $username );
- $email = $main->db->num_rows( $email );
- $username = $main->db->num_rows( $username );
- foreach( $data as $k => $v ) { if( $v == "" ) { $errors++; $error_array[0]='Fill in all required fields.'; } }//empty check
- if( $data['password'] != $data['password_confirm'] ) { $errors++; $error_array[1]='Passwords do not match.'; }//check password
- if( $email >= 2 ) { $errors++; $error_array[2]='Only 2 accounts per email are allowed.'; }//no more than 2 accounts per email
- if( $username != 0 ) { $errors++; $error_array[3]='Username exists.'; }//unique username check
- if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $data['email'])) { $errors++; $error_array[4]='Enter a correct email.'; }//email format check
- if(( $exp != 1 ) && ( $exp != 0 )) { $errors++; $error_array[5] = 'Expansion error, please try again'; }//check for correct exp
- $e_pass = strtoupper(sha1(strtoupper($data['username']).":".strtoupper($data['password'])));
- if( $errors = 0 || $errors == "")
- {
- $main->db->con( 'logon' );
- $sql = 'insert into account (username, sha_pass_hash, email, expansion)
- VALUES("'.$data['username'].'", "'.$e_pass.'", "'.$data['email'].'", "'.$data['exp'].'")';
- $main->db->query( $sql );
- $success = 'Account created successfully!';
- $this->index( false, $success );
- }
- else{
- $this->index( $error_array, false );
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement