-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_container.php
66 lines (58 loc) · 1.67 KB
/
update_container.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require_once 'parse_config.php';
require_once 'internal_or_external.php';
require_once 'find.php';
if( ! $internal ){
die( "You should not be here" );
}
// find container being updated
$container = filter_input( INPUT_GET, 'container',
FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>$config->dir_regex))
);
if( $container === null ){
$container = filter_input( INPUT_POST, 'container',
FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>$config->dir_regex))
);
}
$target = '';
if( FALSE === ($target = find_container($container)) ){
die( "Failed to locate directory '$container'." );
}
// identify attr to update
$attrs = array();
foreach( $config->container_attrs as $attr ){
$val = filter_input( INPUT_GET, "attr_$attr",
FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW & FILTER_FLAG_STRIP_HIGH
);
if( $val !== null ){
$attrs[$attr] = $val;
next;
}
$val = filter_input( INPUT_POST, "attr_$attr",
FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW & FILTER_FLAG_STRIP_HIGH
);
if( $val !== null ){
$attrs[$attr] = $val;
next;
}
}
if( count($attrs) == 0 ){
die( "No known attribute provided." );
}
// update xattr on object
foreach( $attrs as $attr => $val ){
//die( "would set attribute '$attr' to value '$val' on '$target'." );
if( ! xattr_set( $target, $attr, $val ) ){
die( "Failed to set attribute '$attr' to value '$val' on '$target'." );
}
}
header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
die( "Something went wrong" );
if( ! $containers = opendir( $config->image_base ) ){
die( "Error opening base dir" );
}
?>