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