2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('TR_INCLUDE_PATH', 'include/');
14 require(TR_INCLUDE_PATH.'vitals.inc.php');
15 include(TR_INCLUDE_PATH."securimage/securimage.php");
17 if (isset($_POST['cancel'])) {
18 header('Location: index.php');
20 } else if (isset($_POST['submit'])) {
21 require_once(TR_INCLUDE_PATH. 'classes/DAO/UsersDAO.class.php');
22 $usersDAO = new UsersDAO();
24 /* password check: password is verified front end by javascript. here is to handle the errors from javascript */
25 if ($_POST['password_error'] <> "")
27 $pwd_errors = explode(",", $_POST['password_error']);
29 foreach ($pwd_errors as $pwd_error)
31 if ($pwd_error == "missing_password")
32 $missing_fields[] = _AT('password');
34 $msg->addError($pwd_error);
38 if ($_config['use_captcha']==TR_STATUS_ENABLED){
39 $img = new Securimage();
40 $valid = $img->check($_POST['secret']);
42 $msg->addError('SECRET_ERROR');
45 if (!$msg->containsErrors())
47 if (isset($_POST['is_author'])) $is_author = 1;
50 $user_id = $usersDAO->Create(TR_USER_GROUP_USER,
52 $_POST['form_password_hidden'],
57 $_POST['organization'],
63 $_POST['postal_code'],
66 if (is_int($user_id) && $user_id > 0)
68 if (defined('TR_EMAIL_CONFIRMATION') && TR_EMAIL_CONFIRMATION) {
69 $msg->addFeedback('REG_THANKS_CONFIRM');
71 $code = substr(md5($_POST['email'] . $now . $user_id), 0, 10);
73 $confirmation_link = $_base_href . 'confirm.php?id='.$user_id.SEP.'m='.$code;
75 /* send the email confirmation message: */
76 require(TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php');
77 $mail = new TransformableMailer();
79 $mail->From = $_config['contact_email'];
80 $mail->AddAddress($_POST['email']);
81 $mail->Subject = SITE_NAME . ' - ' . _AT('email_confirmation_subject');
82 $mail->Body = _AT('email_confirmation_message', SITE_NAME, $confirmation_link)."\n\n";
89 $usersDAO->setLastLogin($user_id);
90 $_SESSION['user_id'] = $user_id;
92 // show web service ID in success message
93 $row = $usersDAO->getUserByID($user_id);
94 $msg->addFeedback(array('REGISTER_SUCCESS', $row['web_service_id']));
95 header('Location: index.php');
102 /*****************************/
103 /* template starts down here */
106 $onload = 'document.form.login.focus();';
108 $savant->assign('title', _AT('registration'));
109 $savant->assign('submit_button_text', _AT('register'));
110 $savant->assign('show_user_group', false);
111 $savant->assign('show_status', false);
112 $savant->assign('show_password', true);
113 if ($_config['use_captcha'] == TR_STATUS_ENABLED) $savant->assign('use_captcha', true);
115 $savant->display('register.tmpl.php');