AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.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: ustep4.php 10055 2010-06-29 20:30:24Z cindy $
12
13 ignore_user_abort(true); 
14 @set_time_limit(0); 
15
16 if (!defined('TR_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('../include/classes/FileUtility.class.php'); // for copys()
32
33 $content_dir = urldecode(trim($_POST['step4']['content_dir']));
34 $_POST['step4']['copy_from'] = urldecode(trim($_POST['step4']['copy_from'])) . DIRECTORY_SEPARATOR;
35
36 //copy if copy_from is not empty
37 if ($_POST['step4']['copy_from'] && ($_POST['step4']['copy_from'] != DIRECTORY_SEPARATOR)) {
38         if (is_dir($_POST['step4']['copy_from'])) {
39                 $files = scandir($_POST['step4']['copy_from']);
40
41                 foreach ($files as $file) {
42                         if ($file == '.' || $file == '..') { continue; }
43                         if (is_dir($_POST['step4']['copy_from'] . $file)) {
44                                 FileUtility::copys($_POST['step4']['copy_from'] . $file, $content_dir . $file);
45                                 if (is_dir($content_dir.$course)) {                     
46                                         $progress[] = 'Course content directory <b>'.$file.'</b> copied successfully.';
47                                 } else {
48                                         $errors[] = 'Course content directory <b>'.$file.'</b> <strong>NOT</strong> copied.';
49                                 }
50                         } else {
51                                 // a regular file
52                                 copy($_POST['step4']['copy_from'] . $file, $content_dir  .$file);
53                         }
54                 }
55         }
56 } else {
57         $progress[] = 'Using existing content directory <strong>'.$content_dir.'</strong>.';
58 }
59
60 if (isset($progress)) {
61         print_feedback($progress);
62 }
63 if (isset($errors)) {
64         print_errors($errors);
65 }
66
67 if ($_POST['step1']['cache_dir'] != '') {
68         define('CACHE_DIR', urldecode($_POST['step1']['cache_dir']));
69         define('CACHE_ON', 1);
70         require('../include/phpCache/phpCache.inc.php');
71         cache_gc(NULL, 1, true);
72 }
73
74 ?>
75 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
76 <input type="hidden" name="step" value="<?php echo $step;?>" />
77 <?php print_hidden($step); ?>
78
79 <br /><br /><p align="center"><input type="submit" class="button" value=" Next &raquo;" name="submit" /></p>
80 </form>