made a copy
[atutor.git] / install / include / ustep5.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg, Heidi Hazelton */
6 /* http://atutor.ca                                                                                                             */
7 /*                                                                                                                                              */
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 /************************************************************************/
12 // $Id$
13
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15
16 if(isset($_POST['submit'])) {
17         unset($_POST['submit']);
18         unset($action);
19         store_steps($step);
20         $step++;
21         return;
22 }
23
24 $file = '../include/config.inc.php';
25
26 unset($errors);
27 unset($progress);
28
29 if ( file_exists($file) ) {
30         @chmod($file, 0666);
31         if (!is_writeable($file)) {
32                 $errors[] = '<strong>' . $file . '</strong> is not writeable. Use <kbd>chmod a+rw '.$file.'</kbd> to change permissions.';
33         }else{
34                 $progress[] = '<strong>' . $file . '</strong> is writeable.';
35         }
36 } else {
37         $errors[] = '<strong>' . $file . '</strong> does not exist.';
38 }
39
40 print_progress($step);
41
42 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
43
44 if (isset($errors)) {
45         if (isset($progress)) {
46                 print_feedback($progress);
47         }
48         print_errors($errors);
49
50         echo'<input type="hidden" name="step" value="'.$step.'" />';
51
52         unset($_POST['step']);
53         unset($_POST['action']);
54         unset($errors);
55         print_hidden($step);
56
57         echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
58
59         echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
60
61 } else {
62
63         if (!copy('../../'.$_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) {
64                 echo '<input type="hidden" name="step" value="'.$step.'" />';
65
66                 print_feedback($progress);
67
68                 $errors[] = 'include/config.inc.php cannot be written! Please verify that the file exists and is writeable. On Unix issue the command <kbd>chmod a+rw include/config.inc.php</kbd> to make the file writeable. On Windows edit the file\'s properties ensuring that the <kbd>Read-only</kbd> attribute is <em>not</em> checked and that <kbd>Everyone</kbd> access permissions are given to that file.';
69                 print_errors($errors);
70
71                 echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
72
73                 echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
74
75         } else {
76                 echo '<input type="hidden" name="step" value="'.$step.'" />';
77                 print_hidden($step);
78
79                 $progress[] =  'Data has been saved successfully.';
80
81                 if (version_compare($_POST['step1']['old_version'], '1.5.2', '<')) {
82                         require('include/config_template.php');
83                         
84                         $comments = '/*'.str_pad(' This file was generated by the ATutor 1.5.2 installation script.', 70, ' ').'*/
85                 /*'.str_pad(' File generated '.date('Y-m-d H:m:s'), 70, ' ').'*/';
86
87                         $_POST['db_login'] = urldecode($_POST['db_login']);
88                         $_POST['db_password'] = urldecode($_POST['db_password']);
89
90                         write_config_file('../include/config.inc.php', $comments);
91                 }
92                 @chmod('../include/config.inc.php', 0444);
93
94                 print_feedback($progress);
95
96                 echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p>';
97                 
98         }
99 }
100
101 ?>
102
103 </form>