2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
7 /* This program is free software. You can redistribute it and/or */
8 /* modify it under the terms of the GNU General Public License */
9 /* as published by the Free Software Foundation. */
10 /************************************************************************/
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
15 if(isset($_POST['submit']) && ($_POST['action'] == 'process')) {
18 $_POST['admin_username'] = trim($_POST['admin_username']);
19 $_POST['admin_email'] = trim($_POST['admin_email']);
20 $_POST['site_name'] = trim($_POST['site_name']);
21 $_POST['home_url'] = trim($_POST['home_url']);
22 $_POST['email'] = trim($_POST['email']);
23 $_POST['account_email'] = trim($_POST['account_email']);
24 $_POST['account_fname'] = trim($_POST['account_fname']);
25 $_POST['account_lname'] = trim($_POST['account_lname']);
27 /* Super Administrator Account checking: */
28 if ($_POST['admin_username'] == ''){
29 $errors[] = 'Administrator username cannot be empty.';
31 /* check for special characters */
32 if (!(preg_match("/^[a-zA-Z0-9_]([a-zA-Z0-9_])*$/i", $_POST['admin_username']))){
33 $errors[] = 'Administrator username is not valid.';
36 if ($_POST['form_admin_password_hidden'] == '') {
37 $errors[] = 'Administrator password cannot be empty.';
39 if ($_POST['admin_email'] == '') {
40 $errors[] = 'Administrator email cannot be empty.';
41 } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['admin_email'])) {
42 $errors[] = 'Administrator email is not valid.';
45 /* System Preferences checking: */
46 if ($_POST['site_name'] == '') {
47 $errors[] = 'Site name cannot be empty.';
49 if ($_POST['email'] == '') {
50 $errors[] = 'Contact email cannot be empty.';
51 } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['email'])) {
52 $errors[] = 'Contact email is not valid.';
55 /* Personal Account checking: */
56 if ($_POST['account_username'] == ''){
57 $errors[] = 'Personal Account Username cannot be empty.';
59 /* check for special characters */
60 if (!(preg_match("/^[a-zA-Z0-9_]([a-zA-Z0-9_])*$/i", $_POST['account_username']))){
61 $errors[] = 'Personal Account Username is not valid.';
63 if ($_POST['account_username'] == $_POST['admin_username']) {
64 $errors[] = 'That Personal Account Username is already being used for the Administrator account, choose another.';
68 if ($_POST['form_account_password_hidden'] == '') {
69 $errors[] = 'Personal Account Password cannot be empty.';
71 if ($_POST['account_email'] == '') {
72 $errors[] = 'Personal Account email cannot be empty.';
73 } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['account_email'])) {
74 $errors[] = 'Invalid Personal Account email is not valid.';
77 if ($_POST['account_fname'] == '') {
78 $errors[] = 'Personal Account First Name cannot be empty.';
80 if ($_POST['account_lname'] == '') {
81 $errors[] = 'Personal Account Last Name cannot be empty.';
83 if (!isset($errors)) {
84 $db = @mysql_connect($_POST['step2']['db_host'] . ':' . $_POST['step2']['db_port'], $_POST['step2']['db_login'], urldecode($_POST['step2']['db_password']));
85 @mysql_select_db($_POST['step2']['db_name'], $db);
87 $_POST['account_email'] = $addslashes($_POST['account_email']);
88 $_POST['account_fname'] = $addslashes($_POST['account_fname']);
89 $_POST['account_lname'] = $addslashes($_POST['account_lname']);
91 $status = 3; // for instructor account
93 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."admins VALUES ('$_POST[admin_username]', '$_POST[form_admin_password_hidden]', '', '$_POST[admin_email]', 'en', 1, NOW())";
94 $result= mysql_query($sql, $db);
96 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."members VALUES (NULL,'$_POST[account_username]','$_POST[form_account_password_hidden]','$_POST[account_email]','','$_POST[account_fname]','','$_POST[account_lname]','0000-00-00','n', '','','','','', '',$status,'', NOW(),'en', 0, 1, '0000-00-00 00:00:00')";
97 $result = mysql_query($sql ,$db);
99 $_POST['site_name'] = $addslashes($_POST['site_name']);
100 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('site_name', '$_POST[site_name]')";
101 $result = mysql_query($sql ,$db);
103 $_POST['email'] = $addslashes($_POST['email']);
104 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('contact_email', '$_POST[email]')";
105 $result = mysql_query($sql ,$db);
107 $_POST['home_url'] = $addslashes($_POST['home_url']);
108 if ($_POST['home_url'] != '') {
109 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('home_url', '$_POST[home_url]')";
110 $result = mysql_query($sql ,$db);
113 $_POST['just_social'] = intval($_POST['just_social']);
114 if ($_POST['just_social'] > 0){
115 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('just_social', '1')";
116 $result = mysql_query($sql ,$db);
119 //if fresh install, use SET NAME to set the mysql connection to UTF8
120 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('set_utf8', '1')";
121 mysql_query($sql ,$db);
123 // Calculate the ATutor installation path and save into database for the usage of
124 // session associated path @ include/vitals.inc.php
125 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."config VALUES ('session_path', '".get_atutor_installation_path(AT_INCLUDE_PATH)."')";
126 mysql_query($sql ,$db);
128 unset($_POST['admin_username']);
129 unset($_POST['form_admin_password_hidden']);
130 unset($_POST['admin_email']);
131 unset($_POST['account_username']);
132 unset($_POST['form_account_password_hidden']);
133 unset($_POST['account_email']);
134 unset($_POST['home_url']);
135 unset($_POST['email']);
136 unset($_POST['site_name']);
137 unset($_POST['just_social']);
140 unset($_POST['submit']);
148 print_progress($step);
150 if (isset($errors)) {
151 print_errors($errors);
154 if (isset($_POST['step1']['old_version']) && $_POST['upgrade_action']) {
155 $defaults['admin_username'] = urldecode($_POST['step1']['admin_username']);
156 $defaults['admin_email'] = urldecode($_POST['step1']['admin_email']);
158 $defaults['site_name'] = urldecode($_POST['step1']['site_name']);
159 $defaults['header_img'] = urldecode($_POST['step1']['header_img']);
160 $defaults['header_logo'] = urldecode($_POST['step1']['header_logo']);
161 $defaults['home_url'] = urldecode($_POST['step1']['home_url']);
163 $defaults = $_defaults;
167 <script language="JavaScript" src="<?php echo AT_INCLUDE_PATH; ?>../../sha-1factory.js" type="text/javascript"></script>
169 <script type="text/javascript">
170 function encrypt_password()
172 document.form.form_admin_password_hidden.value = hex_sha1(document.form.admin_password.value);
173 document.form.form_account_password_hidden.value = hex_sha1(document.form.account_password.value);
174 document.form.admin_password.value = "";
175 document.form.account_password.value = "";
179 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
180 <input type="hidden" name="action" value="process" />
181 <input type="hidden" name="form_admin_password_hidden" value="" />
182 <input type="hidden" name="form_account_password_hidden" value="" />
183 <input type="hidden" name="step" value="<?php echo $step; ?>" />
184 <?php print_hidden($step); ?>
187 /* detect mail settings. if sendmail_path is empty then use SMTP. */
188 if (@ini_get('sendmail_path') == '') {
189 echo '<input type="hidden" name="smtp" value="true" />';
191 echo '<input type="hidden" name="smtp" value="false" />';
195 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
197 <th colspan="2">Super Administrator Account</th>
200 <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>
203 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="username">Administrator Username:</label></b><br />
204 May contain only letters, numbers, or underscores.</td>
205 <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>
208 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="password">Administrator Password:</label></b></td>
209 <td class="row1"><input type="text" name="admin_password" id="password" maxlength="15" size="15" class="formfield" /></td>
212 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="email">Administrator Email:</label></b></td>
213 <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>
219 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
221 <th colspan="2">System Preferences</th>
224 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="sitename">Site Name:</label></b><br />
225 The name of your course server website.<br />Default: <kbd><?php echo $defaults['site_name']; ?></kbd></td>
226 <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>
229 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="cemail">Contact Email:</label></b><br />
230 The email that will be used as the return email when needed.</td>
231 <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>
234 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="just_social">Just Social:</label></b><br />
235 Deploy ATutor as just a Social Networking platform? (without LMS)</td>
237 <label for="social_y">Just Social</label><input type="radio" name="just_social" id="social_y" value="1" class="formfield" <?php echo ($_POST['just_social']==1)?' checked="checked"':''; ?>/>
238 <label for="social_n">Social and LMS</label><input type="radio" name="just_social" id="social_n" value="0" class="formfield" <?php echo ($_POST['just_social']==0 || !isset($_POST['just_social']))?' checked="checked"':''; ?>/>
242 <td class="row1"><div class="optional" title="Optional Field">?</div><b><label for="home_url">Optional 'Home' URL:</label></b><br />
243 This will be the URL for the 'Home' link in the Public Area. Leave empty to have this link not appear. <br /></td>
244 <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>
250 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
252 <th colspan="2">Personal Account</th>
255 <td colspan="2" class="row1">You will need a personal account to view and create courses.</td>
258 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="account_username">Username:</label></b><br />
259 May contain only letters, numbers, and underscores.</td>
260 <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>
263 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="account_password">Password:</label></b></td>
264 <td class="row1"><input type="text" name="account_password" id="account_password" maxlength="15" size="15" class="formfield" /></td>
267 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="account_email">Email:</label></b></td>
268 <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>
271 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="account_fname">First Name:</label></b></td>
272 <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>
275 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="account_lname">Last Name:</label></b></td>
276 <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>
281 <div align="center"><input type="submit" class="button" value=" Next »" name="submit" onclick="return encrypt_password();" /></div>