<?php
/****************************************************************************************/
/* ACollab */
/****************************************************************************************/
/* Copyright (c) 2002-2004 Adaptive Technology Resource Centre / University of Toronto */
/* */
/* http://atutor.ca/acollab */
/* */
/* This program is free software. You may redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version 2 of the License, */
/* or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You may access the GNU General Public License at: */
/* http://www.opensource.org/licenses/gpl-license.php */
/* */
/* You may contact the Adaptive Technology Resource Centre at */
/* Robarts Library, University of Toronto */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5 */
/* Further contact information is available at http://www.utoronto.ca/atrc/ */
/****************************************************************************************/
/* Programmer: */
/* Joel Kronenberg - ATRC */
/****************************************************************************************/
if (!defined('AC_INCLUDE_PATH')) { exit; }
if (isset($_POST['cancel'])) {
Header('Location: users.php');
exit;
}
if (isset($_POST['submit'])) {
$_POST['login'] = trim($_POST['login']);
$_POST['password'] = trim($_POST['password']);
$_POST['email'] = trim($_POST['email']);
$_POST['fname'] = trim($_POST['fname']);
$_POST['lname'] = trim($_POST['lname']);
$_POST['title'] = trim($_POST['title']);
$_POST['organization'] = trim($_POST['organization']);
$_POST['branch'] = trim($_POST['branch']);
$_POST['address'] = trim($_POST['address']);
$_POST['city'] = trim($_POST['city']);
$_POST['province'] = trim($_POST['province']);
$_POST['country'] = trim($_POST['country']);
$_POST['status'] = intval($_POST['status']);
/* group admins can only create regular accounts, not super admins */
if (!authenticate(USER_ADMIN, USER_RETURN_CHECK)) {
$_POST['status'] = USER_CLIENT;
}
$sql = "SELECT login, member_id, first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE login='$_POST[login]'";
$result = mysql_query($sql, $db);
if ($row = mysql_fetch_assoc($result)) {
$error[] = E_REG_USER_EXISTS;
}
if ($_POST['login'] == '') {
$error[] = E_REG_EMPTY_USERNAME;
} else if (!(eregi("^[a-zA-Z0-9_]([a-zA-Z0-9_])*$", $_POST['login']))){
$error[] = E_REG_WRONG_FORM;
}
if (!$add_option) {
if ($_POST['email'] == '') {
$error[] = E_REG_MISSING_EMAIL;
} else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $_POST['email'])) {
$error[] = E_REG_INVALID_EMAIL;
} else {
$sql = "SELECT login, member_id, first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE email='$_POST[email]'";
$result = mysql_query($sql, $db);
if ($row = mysql_fetch_assoc($result)) {
$error[] = E_REG_EMAIL_EXISTS;
}
}
}
if ($_POST['password'] == '') {
$error[] = E_REG_EMPTY_PASS;
}
if (!isset($error)) {
$_POST['login'] = $addslashes($_POST['login']);
$_POST['password'] = $addslashes($_POST['password']);
$_POST['email'] = $addslashes($_POST['email']);
$_POST['fname'] = $addslashes($_POST['fname']);
$_POST['lname'] = $addslashes($_POST['lname']);
$_POST['clang'] = $addslashes($_POST['clang']);
$_POST['title'] = $addslashes($_POST['title']);
$_POST['address'] = $addslashes($_POST['address']);
$_POST['city'] = $addslashes($_POST['city']);
$_POST['province'] = $addslashes($_POST['province']);
$_POST['country'] = $addslashes($_POST['country']);
$_POST['postal_code'] = $addslashes($_POST['postal_code']);
$_POST['phone'] = $addslashes($_POST['phone']);
$_POST['fax'] = $addslashes($_POST['fax']);
$sql = "INSERT INTO ".TABLE_PREFIX."members VALUES (0, '$_POST[login]', '$_POST[password]', '$_POST[email]', '$_POST[fname]', '$_POST[lname]', NOW(), '$_POST[clang]', '$_POST[title]', '$_POST[address]', '$_POST[city]', '$_POST[province]', '$_POST[country]', '$_POST[postal_code]', '$_POST[phone]', '$_POST[fax]', '0000-00-00')";
if (mysql_query($sql, $db)) {
header('Location: users.php?f='.F_USER_CREATED);
exit;
} else {
$error[] = E_REG_NEW_USER_ERROR;
}
}
}
require(AC_INCLUDE_PATH.$admin.'/header.inc.php');
if (isset($error)) {
print_errors($error);
}
?>
<br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="0" cellpadding="2" align="center" class="box2">
<tr>
<th colspan="5" class="box"><h3><?php echo _AC('create_member_account'); ?></h3></th>
</tr>
<tr>
<td class="row1"> </td>
<td colspan="3" class="row1"><img src="images/clr.gif" height="1" width="1" alt="" /><br /><?php
echo _AC('denotes_required', '<img src="images/required.gif" height="14" width="14" alt="'._AC('required_field').'" />');
?><br /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="username"><b><?php echo _AC('username'); ?>:</b></label></td>
<td class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
<td class="row1"><input type="text" name="login" class="input" size="20" maxlength="30" id="username" value="<?php echo $_POST['login']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="password"><b><?php echo _AC('password'); ?>:</b></label></td>
<td class="row1"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" /></td>
<td class="row1"><input type="text" name="password" class="input" size="20" id="password" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right" valign="top"><label for="email"><b><?php echo _AC('email'); ?>:</b></label></td>
<td class="row1" valign="top"><img src="images/required.gif" height="14" width="14" alt="<?php echo _AC('required_field'); ?>" class="img" /></td>
<td class="row1"><input type="text" name="email" class="input" size="30" id="email" value="<?php echo $_POST['email']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="fname"><b><?php echo _AC('first_name'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="fname" class="input" size="20" id="fname" value="<?php echo $_POST['fname']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="lname"><b><?php echo _AC('last_name'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="lname" class="input" size="20" id="lname" value="<?php echo $_POST['lname']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="title"><b><?php echo _AC('title'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="title" class="input" size="20" id="title" value="<?php echo $_POST['title']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr>
<td class="row1"> </td>
<td class="row1" align="right" valign="top"><label for="address"><b><?php echo _AC('address'); ?>:</b></label></td>
<td class="row1" valign="top"> </td>
<td class="row1"><textarea name="address" id="address" cols="40" rows="3" class="input" onfocus="this.className='input highlight'" onblur="this.className='input'"><?php echo $_POST['address']; ?></textarea></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="city"><b><?php echo _AC('city'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="city" class="input" size="20" id="city" value="<?php echo $_POST['city']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="province"><b><?php echo _AC('province_territory'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="province" class="input" size="20" id="province" value="<?php echo $row['province']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="country"><b><?php echo _AC('country'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="country" class="input" size="20" id="country" value="<?php echo $row['country']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="postal_code"><b><?php echo _AC('postal_code'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="postal_code" class="input" size="8" id="postal_code" value="<?php echo $_POST['postal_code']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="phone"><b><?php echo _AC('phone'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="phone" class="input" size="20" id="phone" value="<?php echo $_POST['phone']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" align="right"><label for="fax"><b><?php echo _AC('fax'); ?>:</b></label></td>
<td class="row1"> </td>
<td class="row1"><input type="text" name="fax" class="input" size="20" id="fax" value="<?php echo $_POST['fax']; ?>" onfocus="this.className='input highlight'" onblur="this.className='input'" /></td>
<td class="row1"> </td>
</tr>
<tr bgcolor="white">
<td class="row1"> </td>
<td class="row1" colspan="3" align="right"><br /><input type="submit" name="submit" value="<?php echo _AC('create'); ?>" class="submitY" onfocus="this.className='submitY highlight'" onblur="this.className='submitY'" /> <input type="submit" name="cancel" value="<?php echo _AC('cancel'); ?>" class="submitN" onfocus="this.className='submitN highlight'" onblur="this.className='submitN'" /><br /><br /></td>
<td class="row1"> </td>
</tr>
</table>
</form>