Tag for ATutor 1.6.
[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['step4']['content_dir']));
35 $_POST['step4']['copy_from'] = urldecode(trim($_POST['step4']['copy_from'])) . DIRECTORY_SEPARATOR;
36
37 //copy if copy_from is not empty
38
39 if ($_POST['step4']['copy_from'] && ($_POST['step4']['copy_from'] != DIRECTORY_SEPARATOR)) {
40         if (is_dir($_POST['step4']['copy_from'])) {
41                 $files = scandir($_POST['step4']['copy_from']);
42
43                 foreach ($files as $file) {
44                         if ($file == '.' || $file == '..') { continue; }
45                         if (is_dir($_POST['step4']['copy_from'] . $file)) {
46                                 copys($_POST['step4']['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['step4']['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 echo '<br />';
64 if (isset($progress)) {
65         print_feedback($progress);
66 }
67 if (isset($errors)) {
68         print_errors($errors);
69 }
70
71 if ($_POST['step1']['cache_dir'] != '') {
72         define('CACHE_DIR', urldecode($_POST['step1']['cache_dir']));
73         define('CACHE_ON', 1);
74         require('../include/phpCache/phpCache.inc.php');
75         cache_gc(NULL, 1, true);
76 }
77
78 ?>
79 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
80 <input type="hidden" name="step" value="<?php echo $step;?>" />
81 <?php print_hidden($step); ?>
82
83 <br /><br /><p align="center"><input type="submit" class="button" value=" Next &raquo;" name="submit" /></p>
84 </form>