remove old readme
[atutor.git] / install / include / step6.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* http://atutor.ca                                                     */
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 /************************************************************************/
11 // $Id$
12
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14
15 if(isset($_POST['submit'])) {
16         unset($_POST['submit']);
17         unset($action);
18         store_steps($step);
19         $step++;
20         return;
21 }
22
23 $file = '../include/config.inc.php';
24
25 unset($errors);
26 unset($progress);
27
28 if ( file_exists($file) ) {
29         @chmod($file, 0666);
30         if (!is_writeable($file)) {
31                 $errors[] = '<strong>' . $file . '</strong> is not writeable.';
32         }else{
33                 $progress[] = '<strong>' . $file . '</strong> is writeable.';
34         }
35 } else {
36         $errors[] = '<strong>' . $file . '</strong> does not exist.';
37 }
38
39 print_progress($step);
40
41 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
42
43 if (isset($errors)) {
44         if (isset($progress)) {
45                 print_feedback($progress);
46         }
47         print_errors($errors);
48
49         echo'<input type="hidden" name="step" value="'.$step.'" />';
50
51         unset($_POST['step']);
52         unset($_POST['action']);
53         unset($errors);
54         print_hidden($step);
55
56         echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
57
58         echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
59
60 } else {
61         require('include/config_template.php');
62                 
63         $comments = '/*'.str_pad(' This file was generated by the ATutor '.$new_version. ' installation script.', 70, ' ').'*/
64 /*'.str_pad(' File generated '.date('Y-m-d H:m:s'), 70, ' ').'*/';
65
66         if (!write_config_file('../include/config.inc.php', $comments)) {
67                 echo '<input type="hidden" name="step" value="'.$step.'" />';
68
69                 print_feedback($progress);
70
71                 $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.';
72                 print_errors($errors);
73
74                 echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
75
76                 echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
77
78         } else {
79                 /* if header img and logo were carried forward AND the upgrade was from 1.4.3 to 1.5 then */
80                 if (($_POST['step1']['header_img'] != '' || $_POST['step1']['header_logo'] != '') 
81                         && $new_version == '1.5' && $_POST['step1']['old_version'] == '1.4.3')
82                         {
83                                 $db = mysql_connect($_POST['step1']['db_host'] . ':' . $_POST['step1']['db_port'], $_POST['step1']['db_login'], urldecode($_POST['step1']['db_password']));
84                                 mysql_select_db($_POST['step1']['db_name'], $db);
85
86                                 $sql = "INSERT INTO ".$_POST['step1']['tb_prefix']."themes VALUES ('ATutor_alt', '1.5', 'default_oldheader', NOW() , 'Backwards compatible default theme', 2)";
87                                 @mysql_query($sql, $db);
88
89                                 $sql = "UPDATE ".$_POST['step1']['tb_prefix']."themes SET status=0, version='1.5' WHERE dir_name = 'default'";
90                                 @mysql_query($sql, $db);
91                         }
92
93                 echo '<input type="hidden" name="step" value="'.$step.'" />';
94                 print_hidden($step);
95
96                 $progress[] =  'Data has been saved successfully.';
97
98                 $cdir = urldecode(trim($_POST['step4']['content_dir']));
99
100                 @chmod('../include/config.inc.php', 0444);
101
102                 print_feedback($progress);
103
104                 echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p>';
105                 
106         }
107 }
108
109 ?>
110
111 </form>