1 |
4
|
ryan
|
<?php
|
2 |
|
|
|
3 |
286
|
stefan
|
// $Id$
|
4 |
4
|
ryan
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
310
|
ryan
|
Copyright (C) 2004-2006, Ryan Djurovich
|
9 |
4
|
ryan
|
|
10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with Website Baker; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
// Get dir name and target location
|
27 |
|
|
if(!isset($_POST['name']) OR $_POST['name'] == '') {
|
28 |
|
|
header("Location: index.php");
|
29 |
286
|
stefan
|
exit(0);
|
30 |
4
|
ryan
|
} else {
|
31 |
|
|
$name = $_POST['name'];
|
32 |
|
|
}
|
33 |
|
|
if(!isset($_POST['target']) OR $_POST['target'] == '') {
|
34 |
|
|
header("Location: index.php");
|
35 |
286
|
stefan
|
exit(0);
|
36 |
4
|
ryan
|
} else {
|
37 |
|
|
$target = $_POST['target'];
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
// Print admin header
|
41 |
|
|
require('../../config.php');
|
42 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
43 |
|
|
$admin = new admin('Media', 'media_create');
|
44 |
|
|
|
45 |
|
|
// Include the WB functions file
|
46 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
47 |
|
|
|
48 |
|
|
// Check to see if name or target contains ../
|
49 |
|
|
if(strstr($name, '../')) {
|
50 |
|
|
$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH']);
|
51 |
|
|
}
|
52 |
|
|
if(strstr($target, '../')) {
|
53 |
|
|
$admin->print_error($MESSAGE['MEDIA']['TARGET_DOT_DOT_SLASH']);
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
// Remove bad characters
|
57 |
|
|
$name = media_filename($name);
|
58 |
|
|
|
59 |
|
|
// Create relative path of the new dir name
|
60 |
|
|
$relative = WB_PATH.$target.'/'.$name;
|
61 |
|
|
|
62 |
|
|
// Check to see if the folder already exists
|
63 |
|
|
if(file_exists($relative)) {
|
64 |
|
|
$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS']);
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
// Try and make the dir
|
68 |
|
|
if(make_dir($relative)) {
|
69 |
|
|
// Create index.php file
|
70 |
|
|
$content = ''.
|
71 |
|
|
"<?php
|
72 |
|
|
|
73 |
|
|
header('Location: ../');
|
74 |
|
|
|
75 |
|
|
?>";
|
76 |
|
|
$handle = fopen($relative.'/index.php', 'w');
|
77 |
|
|
fwrite($handle, $content);
|
78 |
|
|
fclose($handle);
|
79 |
|
|
change_mode($relative.'/index.php', 'file');
|
80 |
|
|
$admin->print_success($MESSAGE['MEDIA']['DIR_MADE']);
|
81 |
|
|
} else {
|
82 |
|
|
$admin->print_error($MESSAGE['MEDIA']['DIR_NOT_MADE']);
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
// Print admin
|
86 |
|
|
$admin->print_footer();
|
87 |
|
|
|
88 |
|
|
?>
|