You are not registered.
Registration allows you to subscribe to projects, open projects, and more. Click here to register.Website Source Code
<< Back
register.php
register.php
<?php
function get_register()
{
global $url;
if (isset($_POST['username']))
{
$username = trim($_POST['username']);
$name = trim($_POST['name']);
$password = $_POST['password'];
$email = trim($_POST['email']);
$hide = isset($_POST['hide_email']);
$about = $_POST['about'];
$contact = $_POST['contact'];
$avatar = $_POST['avatar'];
$errors = '';
if (strlen($username) > 30)
$errors .= 'Username is too long.<br />';
if (strlen($username) == 0)
$errors .= 'Please type a username.<br />';
if (strlen($name) > 30)
$errors .= 'Name is too long.<br />';
if (strlen($password) > 32)
$errors .= 'Password is too long.<br />';
if (strlen($password) < 8)
$errors .= 'Password is too short.<br />';
if (!check_email_address($email))
$errors .= 'E-Mail is not valid.<br />';
if ((strlen($username) <= 30) and (strlen($username) > 0))
{
if (mysql_num_rows(mysql_query('SELECT `id` FROM `users` WHERE `username` = \'' . db_escape($username) . '\' LIMIT 1;')) > 0)
{
$errors .= 'Username already taken.';
}
}
if ($errors == '')
{
srand(time());
$md5 = md5((rand() % 99) . $name);
$body = "Welcome to TVProjects!\nTo activate your account please click on this link: {$url}activate/$md5";
if (mail($email, 'Welcome to TVProjects', $body, 'From: noreply@noreplyland.com'))
{
mysql_query('INSERT INTO `users` (`name`, `username`, `password`, `email`, `date`, `activating`, `hide_email`, `about`, `contact`, `avatar`) VALUES (\'' . db_escape($name) .'\', \'' . db_escape($username) .'\', \'' . md5($password) .'\', \'' . db_escape($email) .'\', ' . time() . ', \'' . $md5 . '\', \'' . $hide . '\', \'' . db_escape($about) . '\', \'' . db_escape($contact) . '\', \'' . db_escape($avatar) . '\');');
tell_users(4, -1, 'New user in TVProjects: ' . $username, 'New user has been registered: ' . $username . "\nYou can look his profile here:\n" . $url . 'users/' . mysql_insert_id() . '-' . format_title_address($username) . '/');
return '<div style="font-weight: bold">Registration Successful!</div>A validation E-Mail has been sent to <span style="font-weight: bold">' . escape_html($email) . '</span> with the confirmation link.';
}
else
{
return '<div style="font-weight: bold">Registration Failed</div>Sending a validation E-Mail to <span style="font-weight: bold">' . escape_html($email) . '</span> has failed.';
}
}
else
{
$vars['ERRORS'] = $errors;
$vars['USERNAME'] = escape_html($username);
$vars['NAME'] = escape_html($name);
$vars['PASSWORD'] = escape_html($password);
$vars['EMAIL'] = escape_html($email);
$vars['HIDE'] = $hide ? ' checked="checked"' : '';
$vars['ABOUT'] = escape_html($about);
$vars['CONTACT'] = escape_html($contact);
$vars['AVATAR'] = escape_html($avatar);
return get_template('register', $vars);
}
}
else
{
$vars['ERRORS'] = ' ';
$vars['USERNAME'] = '';
$vars['NAME'] = '';
$vars['PASSWORD'] = '';
$vars['EMAIL'] = '';
$vars['HIDE'] = ' checked="checked"';
$vars['ABOUT'] = '';
$vars['CONTACT'] = '';
$vars['AVATAR'] = '';
return get_template('register', $vars);
}
}
// Taken from http://www.ilovejackdaniels.com/php/email-address-validation/
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
//
?>


