a7d7ac4b3b472d37b23d858dde2119ce2185de7b
[acontent.git] / docs / install / include / step5.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
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
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14
15 if (isset($_POST['submit']) && ($_POST['action'] == 'process')) {
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>' . realpath($file) . '</strong> is not writeable.';
32         }else{
33                 $progress[] = '<strong>' . realpath($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 echo '  <input type="hidden" name="action" value="process" />';
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         require('include/config_template.php');
63                 
64         $comments = '/*'.str_pad(' This file was generated by the AContent '.$new_version. ' installation script.', 70, ' ').'*/
65 /*'.str_pad(' File generated '.date('Y-m-d H:m:s'), 70, ' ').'*/';
66
67         if (!write_config_file('../include/config.inc.php', $comments)) {
68                 echo '<input type="hidden" name="step" value="'.$step.'" />';
69
70                 print_feedback($progress);
71
72                 $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.';
73                 print_errors($errors);
74
75                 echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
76
77                 echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
78
79         } else {
80                 echo '<input type="hidden" name="step" value="'.$step.'" />';
81                 print_hidden($step);
82
83                 $progress[] =  'Data has been saved successfully.';
84
85                 @chmod('../include/config.inc.php', 0444);
86
87                 print_feedback($progress);
88
89                 echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p>';
90                 
91         }
92 }
93
94 echo '</form>';
95 ?>