Wheatblog PHP Cross Reference Blogging Systems

Source: /registration.php - 124 lines - 3465 bytes - Summary - Text - Print

   1  <?php
   2  //
   3  // File:    admin/manage_users.php
   4  // License: GNU GPL
   5  // Purpose: Used to register for an account.  Do not use sessions here!
   6  //
   7  // Filtered / safe variables begin with capital letters.
   8  //
   9  require ('settings.php');
  10  $page_title = ':: Register Account';
  11  include_once("$wb_inc_dir/header.php");
  12  
  13  $action   = ( isset($_REQUEST['action']) ) ? $_REQUEST['action'] : '';
  14  $login    = ( isset($_POST['login']) )     ? $_POST['login']     : '';
  15  $Login    = $db->quote($login);
  16  $password = ( isset($_POST['password']) )  ? $_POST['password']  : '';
  17  $Password = $db->quote($password);
  18  $cookie   = ( isset($_POST['cookie']) )    ? $_POST['cookie']    : '';
  19  $www      = ( isset($_POST['www']) )       ? $_POST['www']       : '';
  20  $Www      = $db->quote($www);
  21  $email    = ( isset($_POST['email']) )     ? $_POST['email']     : '';
  22  $Email    = $db->quote($email);
  23  
  24  
  25  
  26  
  27  // If an email is given, filter it.
  28  //
  29  $Email_Regex = '/^[^@s]+@([-a-z0-9]+.)+[a-z]{2,}$/i';
  30  
  31  if ( $email != '' &&  ! preg_match($Email_Regex, $email)) 
  32      die('This is not a valid email address');
  33  
  34  
  35  
  36  
  37      ////
  38      ////  User requested to add a new user
  39      ////
  40      ////
  41      if ( $action == 'process' )
  42      {
  43  
  44          if ( ! $Login  ||  ! $password )
  45              die('You must supply a login and password.');
  46  
  47          // Make sure the login is unique.
  48          //
  49          $db->query("SELECT * FROM $tblUsers WHERE login=$Login");
  50          if ( $db->num_rows() > 0 )
  51              die("There's already a user named $login.");
  52  
  53          $flags = 0;
  54          $flags += ( $cookie == 'on' ) ? 2 : 0;
  55          $Flags = $db->quote($flags);
  56  
  57          $db->query("INSERT INTO $tblUsers
  58              VALUES ($Login, $Password, $Flags, $Www, $Email)");
  59  
  60          echo "<p>Thanks for registering, $login.</p>";
  61  
  62          if ( $registered_comments )
  63              echo "<p>An account must be registered before it can comment on " .
  64              "posts.  The administrator will approve registration shortly.</p>";
  65          else
  66              echo '<p>You can begin commenting immediately.</p>';
  67  
  68          echo "Please click <a href=\"$wb_url\">here</a> to return to the " .
  69              "blog.</p>";
  70  
  71          exit(0);
  72      }
  73  
  74  
  75  
  76  
  77  
  78  
  79  
  80  
  81  insert_form_heading('Register As a New User');
  82  
  83  
  84  ?>
  85  <div class="subcontent-heading" id="reg">
  86  <span>This registration process is necessary to prevent unsolicited 
  87  comments from spammers. If you are a frequent visitor, you may enable <strong>Cookies</strong>
  88  to keep your information active with <strong><?= $name_of_blog ?></strong>. For your privacy, they only store your Username and Password.
  89  </span>
  90  </div>
  91  
  92  <div class="subcontent-users">
  93  <form method="post" action="registration.php?action=process">
  94  <table cellpadding="2" cellspacing="0" border="0">
  95  <tr>
  96  <td class="fieldname" width="20%"><label>Login name:</label></td>
  97  <td width="80%"><input name="login" style="width:8em" /></td>
  98  </tr>
  99  <tr>
 100  <td class="fieldname" width="20%"><label>Password:</label></td>
 101  <td width="80%"><input name="password" style="width:8em" /></td>
 102  </tr>
 103  <td class="fieldname" width="20%"><label>Email Address:</label></td>
 104  <td width="80%"><input name="email" style="width:12em" /></td>
 105  </tr>
 106  <tr>
 107  <td class="fieldname" width="20%"><label>Website:</label></td>
 108  <td width="80%"><input name="www" style="width:15em" /></td>
 109  </tr>
 110  <tr>
 111  <tr>
 112  <td class="fieldname" width="20%"><label>Allow cookies:</label></td>
 113  <td width="80%"><input class="check" type="checkbox" name="cookie" /></td>
 114  </tr>
 115  <tr>
 116  <td class="fieldname" width="20%"><label>&nbsp;</label></td>
 117  <td width="80%"><input type="submit" value="Register" /></td>
 118  </tr>
 119  </table>
 120  </form>
 121  </div>
 122  
 123  
 124  <? include_once("$wb_inc_dir/footer.php"); ?>

title

Description

title

Description

title

Description

title

title

Body