2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay, Joel Kronenberg, Heidi Hazelton */
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 /************************************************************************/
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 if(isset($_POST['submit']) && ($_POST['action'] == 'process')) {
19 $_POST['admin_username'] = trim($_POST['admin_username']);
20 $_POST['admin_password'] = trim($_POST['admin_password']);
21 $_POST['admin_email'] = trim($_POST['admin_email']);
22 $_POST['site_name'] = trim($_POST['site_name']);
23 $_POST['home_url'] = trim($_POST['home_url']);
24 $_POST['email'] = trim($_POST['email']);
25 $_POST['account_email'] = trim($_POST['account_email']);
26 $_POST['account_fname'] = trim($_POST['account_fname']);
27 $_POST['account_lname'] = trim($_POST['account_lname']);
29 /* Super Administrator Account checking: */
30 if ($_POST['admin_username'] == ''){
31 $errors[] = 'Administrator username cannot be empty.';
33 /* check for special characters */
34 if (!(eregi("^[a-zA-Z0-9_]([a-zA-Z0-9_])*$", $_POST['admin_username']))){
35 $errors[] = 'Administrator username is not valid.';
38 if ($_POST['admin_password'] == '') {
39 $errors[] = 'Administrator password cannot be empty.';
41 if ($_POST['admin_email'] == '') {
42 $errors[] = 'Administrator email cannot be empty.';
43 } else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$", $_POST['admin_email'])) {
44 $errors[] = 'Administrator email is not valid.';
47 /* System Preferences checking: */
48 if ($_POST['site_name'] == '') {
49 $errors[] = 'Site name cannot be empty.';
51 if ($_POST['email'] == '') {
52 $errors[] = 'Contact email cannot be empty.';
53 } else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$", $_POST['email'])) {
54 $errors[] = 'Contact email is not valid.';
57 /* Personal Account checking: */
58 if ($_POST['account_username'] == ''){
59 $errors[] = 'Personal Account Username cannot be empty.';
61 /* check for special characters */
62 if (!(eregi("^[a-zA-Z0-9_]([a-zA-Z0-9_])*$", $_POST['account_username']))){
63 $errors[] = 'Personal Account Username is not valid.';
65 if ($_POST['account_username'] == $_POST['admin_username']) {
66 $errors[] = 'That Personal Account Username is already being used for the Administrator account, choose another.';
70 if ($_POST['account_password'] == '') {
71 $errors[] = 'Personal Account Password cannot be empty.';
73 if ($_POST['account_email'] == '') {
74 $errors[] = 'Personal Account email cannot be empty.';
75 } else if (!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$", $_POST['email'])) {
76 $errors[] = 'Invalid Personal Account email is not valid.';
79 if ($_POST['account_fname'] == '') {
80 $errors[] = 'Personal Account First Name cannot be empty.';
82 if ($_POST['account_lname'] == '') {
83 $errors[] = 'Personal Account Last Name cannot be empty.';
85 if (!isset($errors)) {
86 $db = @mysql_connect($_POST['step2']['db_host'] . ':' . $_POST['step2']['db_port'], $_POST['step2']['db_login'], urldecode($_POST['step2']['db_password']));
87 @mysql_select_db($_POST['step2']['db_name'], $db);
89 $_POST['account_email'] = $addslashes($_POST['account_email']);
90 $_POST['account_fname'] = $addslashes($_POST['account_fname']);
91 $_POST['account_lname'] = $addslashes($_POST['account_lname']);
93 if ($_POST['instructor']) {
98 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."admins VALUES ('$_POST[admin_username]', '$_POST[admin_password]', '', '$_POST[admin_email]', 'en', 1, NOW())";
99 $result= mysql_query($sql, $db);
101 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."members VALUES (NULL,'$_POST[account_username]','$_POST[account_password]','$_POST[account_email]','','$_POST[account_fname]','','$_POST[account_lname]','0000-00-00','n', '','','','','', '',$status,'', NOW(),'en', 0, 1, '0000-00-00 00:00:00')";
102 $result = mysql_query($sql ,$db);
104 $_POST['site_name'] = $addslashes($_POST['site_name']);
105 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('site_name', '$_POST[site_name]')";
106 $result = mysql_query($sql ,$db);
108 $_POST['email'] = $addslashes($_POST['email']);
109 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('contact_email', '$_POST[email]')";
110 $result = mysql_query($sql ,$db);
112 $_POST['home_url'] = $addslashes($_POST['home_url']);
113 if ($_POST['home_url'] != '') {
114 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('home_url', '$_POST[home_url]')";
115 $result = mysql_query($sql ,$db);
118 unset($_POST['admin_username']);
119 unset($_POST['admin_password']);
120 unset($_POST['admin_email']);
121 unset($_POST['account_username']);
122 unset($_POST['account_password']);
123 unset($_POST['account_email']);
124 unset($_POST['home_url']);
125 unset($_POST['email']);
126 unset($_POST['site_name']);
129 unset($_POST['submit']);
137 print_progress($step);
139 if (isset($errors)) {
140 print_errors($errors);
143 if (isset($_POST['step1']['old_version']) && $_POST['upgrade_action']) {
144 $defaults['admin_username'] = urldecode($_POST['step1']['admin_username']);
145 $defaults['admin_password'] = urldecode($_POST['step1']['admin_password']);
146 $defaults['admin_email'] = urldecode($_POST['step1']['admin_email']);
148 $defaults['site_name'] = urldecode($_POST['step1']['site_name']);
149 $defaults['header_img'] = urldecode($_POST['step1']['header_img']);
150 $defaults['header_logo'] = urldecode($_POST['step1']['header_logo']);
151 $defaults['home_url'] = urldecode($_POST['step1']['home_url']);
153 $defaults = $_defaults;
158 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
159 <input type="hidden" name="action" value="process" />
160 <input type="hidden" name="step" value="<?php echo $step; ?>" />
161 <?php print_hidden($step); ?>
164 /* detect mail settings. if sendmail_path is empty then use SMTP. */
165 if (@ini_get('sendmail_path') == '') {
166 echo '<input type="hidden" name="smtp" value="true" />';
168 echo '<input type="hidden" name="smtp" value="false" />';
172 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
174 <th colspan="2">Super Administrator Account</th>
177 <td colspan="2" class="row1">The Super Administrator account is used for managing ATutor. The Super Administrator can also create additional Administrators each with their own privileges and roles. Administrator accounts cannot enroll in courses.</td>
180 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="username">Administrator Username:</label></b><br />
181 May contain only letters, numbers, or underscores.</td>
182 <td class="row1"><input type="text" name="admin_username" id="username" maxlength="20" size="20" value="<?php if (!empty($_POST['admin_username'])) { echo stripslashes(htmlspecialchars($_POST['admin_username'])); } else { echo $defaults['admin_username']; } ?>" class="formfield" /></td>
185 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="password">Administrator Password:</label></b></td>
186 <td class="row1"><input type="text" name="admin_password" id="password" maxlength="15" size="15" value="<?php if (!empty($_POST['admin_password'])) { echo stripslashes(htmlspecialchars($_POST['admin_password'])); } else { echo $defaults['admin_password']; } ?>" class="formfield" /></td>
189 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="email">Administrator Email:</label></b></td>
190 <td class="row1"><input type="text" name="admin_email" id="email" size="40" value="<?php if (!empty($_POST['admin_email'])) { echo stripslashes(htmlspecialchars($_POST['admin_email'])); } else { echo $defaults['admin_email']; } ?>" class="formfield" /></td>
196 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
198 <th colspan="2">System Preferences</th>
201 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="sitename">Site Name:</b><br />
202 The name of your course server website.<br />Default: <kbd><?php echo $defaults['site_name']; ?></kbd></td>
203 <td class="row1"><input type="text" name="site_name" size="28" maxlength="60" id="sitename" value="<?php if (!empty($_POST['site_name'])) { echo stripslashes(htmlspecialchars($_POST['site_name'])); } else { echo $defaults['site_name']; } ?>" class="formfield" /></td>
206 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="cemail">Contact Email:</label></b><br />
207 The email that will be used as the return email when needed and when instructor account requests are made.</td>
208 <td class="row1"><input type="text" name="email" id="cemail" size="40" value="<?php if (!empty($_POST['email'])) { echo stripslashes(htmlspecialchars($_POST['email'])); } else { echo $defaults['email']; } ?>" class="formfield" /></td>
211 <td class="row1"><div class="optional" title="Optional Field">?</div><b><label for="home_url">Optional 'Home' URL:</b><br />
212 This will be the URL for the 'Home' link in the Public Area. Leave empty to have this link not appear. <br /></td>
213 <td class="row1"><input type="text" name="home_url" size="28" maxlength="60" id="home_url" value="<?php if (!empty($_POST['home_url'])) { echo stripslashes(htmlspecialchars($_POST['home_url'])); } else { echo $defaults['home_url']; } ?>" class="formfield" /></td>
219 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
221 <th colspan="2">Personal Account</th>
224 <td colspan="2" class="row1">You will need a personal account to view and, optionally, create courses.</td>
227 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="account_username">Username:</label></b><br />
228 May contain only letters, numbers, and underscores.</td>
229 <td class="row1"><input type="text" name="account_username" id="account_username" maxlength="20" size="20" value="<?php if (!empty($_POST['account_username'])) { echo stripslashes(htmlspecialchars($_POST['account_username'])); } ?>" class="formfield" /></td>
232 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="account_password">Password:</label></b></td>
233 <td class="row1"><input type="text" name="account_password" id="account_password" maxlength="15" size="15" value="<?php if (!empty($_POST['account_password'])) { echo stripslashes(htmlspecialchars($_POST['account_password'])); } ?>" class="formfield" /></td>
236 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="account_email">Email:</label></b></td>
237 <td class="row1"><input type="text" name="account_email" id="account_email" size="40" maxlength="60" value="<?php if (!empty($_POST['account_email'])) { echo stripslashes(htmlspecialchars($_POST['account_email'])); } ?>" class="formfield" /></td>
240 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="account_fname">First Name:</label></b></td>
241 <td class="row1"><input type="text" name="account_fname" id="account_fname" size="40" maxlength="60" value="<?php if (!empty($_POST['account_fname'])) { echo stripslashes(htmlspecialchars($_POST['account_fname'])); } ?>" class="formfield" /></td>
244 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="account_lname">Last Name:</label></b></td>
245 <td class="row1"><input type="text" name="account_lname" id="account_lname" size="40" maxlength="60" value="<?php if (!empty($_POST['account_lname'])) { echo stripslashes(htmlspecialchars($_POST['account_lname'])); } ?>" class="formfield" /></td>
248 <td class="row1"><div class="optional" title="Optional Field">?</div><b>Instructor Account:</b><br />
249 Do you want this to be an instructor account allowing you to create courses?</td>
250 <td class="row1"><input type="radio" name="instructor" value="1" id="en_y" <?php if($_POST['instructor']== 1 || empty($_POST['instructor'])) { echo "checked"; }?>/><label for="en_y">Yes</label>, <input type="radio" name="instructor" value="0" id="en_n" <?php if($_POST['instructor']===0) { echo "checked"; }?>/><label for="en_n">No</label></td>
255 <div align="center"><input type="submit" class="button" value=" Next »" name="submit" /></div>