remove old readme
[atutor.git] / install / include / ustep4.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 ignore_user_abort(true); 
14 @set_time_limit(0); 
15
16 if (!defined('AT_INCLUDE_PATH')) { exit; }
17
18 if (isset($_POST['submit'])) {
19         if (!isset($errors)) {
20                 unset($_POST['submit']);
21                 unset($action);
22                 store_steps($step);
23                 $step++;
24                 return;
25         }
26 }
27
28 print_progress($step);
29
30 /* try copying the content over from the old dir to the new one */
31 require('../mods/_core/file_manager/filemanager.inc.php'); // for copys()
32
33 $content_dir = urldecode(trim($_POST['step5']['content_dir']));
34 $_POST['step5']['copy_from'] = urldecode(trim($_POST['step5']['copy_from'])) . DIRECTORY_SEPARATOR;
35
36 //copy if copy_from is not empty
37
38 if ($_POST['step5']['copy_from'] && ($_POST['step5']['copy_from'] != DIRECTORY_SEPARATOR)) {
39         if (is_dir($_POST['step5']['copy_from'])) {
40                 $files = scandir($_POST['step5']['copy_from']);
41
42                 foreach ($files as $file) {
43                         if ($file == '.' || $file == '..') { continue; }
44                         if (is_dir($_POST['step5']['copy_from'] . $file)) {
45                                 copys($_POST['step5']['copy_from'] . $file, $content_dir . $file);
46                                 if (is_dir($content_dir.$course)) {                     
47                                         $progress[] = 'Course content directory <b>'.$file.'</b> copied successfully.';
48                                 } else {
49                                         $errors[] = 'Course content directory <b>'.$file.'</b> <strong>NOT</strong> copied.';
50                                 }
51                         } else {
52                                 // a regular file
53                                 copy($_POST['step5']['copy_from'] . $file, $content_dir  .$file);
54                         }
55                 }
56         }
57
58 } else {
59         $progress[] = 'Using existing content directory <strong>'.$content_dir.'</strong>.';
60 }
61 /////////////////////
62 // Create the patcher content directory
63 if (!is_dir($content_dir.'/patcher')) {
64         if (!@mkdir($content_dir.'/patcher')) {
65                 $errors[] = '<strong>'.$content_dir.'/patcher</strong> directory does not exist and cannot be created.';  
66         }
67 } else if (!is_writable($content_dir.'/patcher')){
68         $errors[] = '<strong>'.$content_dir.'/patcher</strong> directory is not writable.';
69 }
70 ////////////////////////
71
72 // Create the module content directory
73 if (!is_dir($content_dir.'/module')) {
74         if (!@mkdir($content_dir.'/module')) {
75                 $errors[] = '<strong>'.$content_dir.'/module</strong> directory does not exist and cannot be created.';  
76         }
77 } else if (!is_writable($content_dir.'/module')){
78         $errors[] = '<strong>'.$content_dir.'/module</strong> directory is not writable.';
79 }
80 ////////////////////////
81
82 // Create the theme content directory
83 if (!is_dir($content_dir.'/theme')) {
84         if (!@mkdir($content_dir.'/theme')) {
85                 $errors[] = '<strong>'.$content_dir.'/theme</strong> directory does not exist and cannot be created.';  
86         }
87 } else if (!is_writable($content_dir.'/theme')){
88         $errors[] = '<strong>'.$content_dir.'/theme</strong> directory is not writable.';
89 }
90 ////////////////////////
91
92 echo '<br />';
93 if (isset($progress)) {
94         print_feedback($progress);
95 }
96 if (isset($errors)) {
97         print_errors($errors);
98 }
99
100 if ($_POST['step1']['cache_dir'] != '') {
101         define('CACHE_DIR', urldecode($_POST['step1']['cache_dir']));
102         define('CACHE_ON', 1);
103         require('../include/phpCache/phpCache.inc.php');
104         cache_gc(NULL, 1, true);
105 }
106
107 ?>
108 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
109 <input type="hidden" name="step" value="<?php echo $step;?>" />
110 <?php print_hidden($step); ?>
111
112 <br /><br /><p align="center"><input type="submit" class="button" value=" Next &raquo;" name="submit" /></p>
113 </form>