e8c61cfc80c89428674111c2da9cdcfe5dcf4dd2
[atutor.git] / docs / install / include / step4.php
1 <?php
2 exit('this file is no longer used');
3
4 /************************************************************************/
5 /* ATutor                                                                                                                               */
6 /************************************************************************/
7 /* Copyright (c) 2002-2010                                              */
8 /* http://atutor.ca                                                     */
9 /* This program is free software. You can redistribute it and/or        */
10 /* modify it under the terms of the GNU General Public License          */
11 /* as published by the Free Software Foundation.                        */
12 /************************************************************************/
13 // $Id$
14
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16
17 if(isset($_POST['submit']) && ($_POST['action'] == 'process')) {
18         unset($errors);
19         $_POST['username'] = trim($_POST['username']);
20         $_POST['password'] = trim($_POST['password']);
21         $_POST['email']    = trim($_POST['email']);
22
23         $_POST['instructor'] = intval($_POST['instructor']);
24         $_POST['welcome_course'] = intval($_POST['welcome_course']);
25
26         /* login name check */
27         if ($_POST['username'] == ''){
28                 $errors[] = 'Username cannot be empty.';
29         } else {
30                 /* check for special characters */
31                 if (!(preg_match("/^[a-zA-Z0-9_]([a-zA-Z0-9_])*$/i", $_POST['username']))){
32                         $errors[] = 'Username is not valid.';
33                 } else {
34                         if ($_POST['username'] == $_POST['step3']['admin_username']) {
35                                 $errors[] = 'That Username is already being used for the Administrator account, choose another.';
36                         }
37                 }
38         }
39
40         if ($_POST['password'] == '') {
41                 $errors[] = 'Password cannot be empty.';
42         }
43
44         if ($_POST['email'] == '') {
45                 $errors[] = 'Email cannot be empty.';
46         } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['email'])) {
47                 $errors[] = 'Invalid email format.';
48         }
49         
50         if (!isset($errors)) {
51                 unset($_POST['submit']);
52                 unset($_POST['action']);
53
54                 if ($_POST['instructor']) {
55                         $status = 3;
56                 } else {
57                         $status = 2;
58                 }
59
60                 $db = mysql_connect($_POST['step2']['db_host'] . ':' . $_POST['step2']['db_port'], $_POST['step2']['db_login'], urldecode($_POST['step2']['db_password']));
61                 mysql_select_db($_POST['step2']['db_name'], $db);
62
63                 $sql = "INSERT INTO ".$_POST['step2']['tb_prefix']."members VALUES (NULL,'$_POST[username]','$_POST[password]','$_POST[email]','','','','', '','', '','','','','', '',$status,'', NOW(),'en', 0, 1, '0000-00-00 00:00:00')";
64                 $result = mysql_query($sql ,$db);
65                 $m_id   = mysql_insert_id($db);
66
67                 if ($_POST['welcome_course'] && $_POST['instructor']) {
68                         $_POST['tb_prefix'] = $_POST['step2']['tb_prefix'];
69                         queryFromFile('db/atutor_welcome_course.sql');
70                 }
71                 
72                 store_steps($step);
73                 $step++;
74                 return;
75         }
76 } else {
77         unset($_POST['email']);
78 }
79
80 print_progress($step);
81
82 if (isset($errors)) {
83         print_errors($errors);
84 }
85
86 ?>
87 <p>You will need a personal account to view and, optionally, create courses.</p>
88
89 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
90         <input type="hidden" name="step" value="4" />
91         <input type="hidden" name="action" value="process" />
92         <?php
93                 print_hidden($step);
94         ?>
95         <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
96         <tr>
97                 <td class="row1"><small><b><label for="username">Username:</label></b><br />
98                 May contain only letters, numbers, or underscores.<br />20 character maximum.</small></td>
99                 <td class="row1"><input type="text" name="username" id="username" maxlength="20" size="20" value="<?php if (!empty($_POST['username'])) { echo $stripslashes(htmlspecialchars($_POST['username'])); } ?>" class="formfield" /></td>
100         </tr>
101         <tr>
102                 <td class="row1"><small><b><label for="password">Password:</label></b><br />
103                 Use a combination of letters, numbers and symbols.<br />15 character maximum.</small></td>
104                 <td class="row1"><input type="text" name="password" id="password" maxlength="15" size="15" value="<?php if (!empty($_POST['password'])) { echo $stripslashes(htmlspecialchars($_POST['password'])); } ?>" class="formfield" /></td>
105         </tr>
106         <tr>
107                 <td class="row1"><small><b><label for="email">Email:</label></b></small></td>
108                 <td class="row1"><input type="text" name="email" id="email" size="30" maxlength="60" value="<?php if (!empty($_POST['email'])) { echo $stripslashes(htmlspecialchars($_POST['email'])); } ?>" class="formfield" /></td>
109         </tr>
110         <tr>
111                 <td class="row1"><small><b>Instructor Account:</b><br />
112                 Do you want this to be an instructor account allowing you to create courses?<br />
113                 Default: <kbd>Yes</kbd></small></td>
114                 <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>
115         </tr>
116         <tr>
117                 <td class="row1"><small><b>Welcome Course:</b><br />
118                 Do you want the basic <em>Welcome Course</em> created? Only possible if an instructor account above is created.<br />
119                 Default: <kbd>Yes</kbd></small></td>
120                 <td class="row1"><input type="radio" name="welcome_course" value="1" id="wc_y" <?php if($_POST['welcome_course']== 1 || empty($_POST['welcome_course'])) { echo 'checked'; }?>/><label for="wc_y">Yes</label>, <input type="radio" name="welcome_course" value="0" id="wc_n" <?php if ($_POST['welcome_course'] === 0) { echo 'checked'; }?>/><label for="wc_n">No</label></td>
121         </tr>
122         </table>
123
124         <br /><br /><p align="center"><input type="submit" class="button" value="Next &raquo; " name="submit" /></p>
125
126 </form>