1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package admintools
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: create.php 1400 2011-01-21 19:42:51Z FrankH $
|
14
|
* @filesource $HeadURL: $
|
15
|
* @lastmodified $Date: $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// Get dir name and target location
|
20
|
if(!isset($_POST['name']) OR $_POST['name'] == '') {
|
21
|
header("Location: index.php");
|
22
|
exit(0);
|
23
|
} else {
|
24
|
$name = $_POST['name'];
|
25
|
}
|
26
|
if(!isset($_POST['target']) OR $_POST['target'] == '') {
|
27
|
header("Location: index.php");
|
28
|
exit(0);
|
29
|
} else {
|
30
|
$target = $_POST['target'];
|
31
|
}
|
32
|
|
33
|
// Print admin header
|
34
|
require('../../config.php');
|
35
|
require_once(WB_PATH.'/framework/class.admin.php');
|
36
|
$admin = new admin('Media', 'media_create');
|
37
|
|
38
|
if (!$admin->checkFTAN())
|
39
|
{
|
40
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
|
41
|
exit();
|
42
|
}
|
43
|
|
44
|
// Include the WB functions file
|
45
|
require_once(WB_PATH.'/framework/functions.php');
|
46
|
|
47
|
// Check to see if name or target contains ../
|
48
|
if(strstr($name, '..')) {
|
49
|
$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH']);
|
50
|
}
|
51
|
if (!check_media_path($target, false)) {
|
52
|
w_debug("target: $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
|
?>
|