-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.php
132 lines (126 loc) · 3.7 KB
/
object.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
// headers here
// then common stuff
require_once 'parse_config.php';
require_once 'internal_or_external.php';
require_once 'find.php';
/* candidate for validate_container.php */
$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))
);
}
if( $container === false ){
die( "container validation failed." );
}
$container_path='';
if( 0 !== substr_compare(
$container_path=absolutepath( $config->image_base . "/$container" ),
$config->image_base,
0,
strlen($config->image_base)
)
){
die( "Path '$container_path' is not under base dir." );
}
/* end candidate */
$object = filter_input( INPUT_GET, 'object',
FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>$config->dir_regex))
);
if( $object === null ){
$object = filter_input( INPUT_POST, 'object',
FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>$config->dir_regex))
);
}
if( $object !== null
and $obj_path = "$container_path/$object"
and is_file( $obj_path )
){
// This is easier to read than negating the conditions
}
else{
print "Can't find '$container_path/$object'";
// header( "Location: container.php?container=$container" );
die();
}
?><!DOCTYPE html>
<html>
<head>
<?php // include mobile zoom meta tags
readfile( "zoom.html" )
?>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="common.js"></script>
</head>
<body>
<?php
chdir( $container_path )
or die( "Failed to change to container directory." );
print "<div>In container '$container'</div>";
print "Remote host '$_SERVER[REMOTE_ADDR]' is probably "
. ($internal ? '' : 'not')
. " internal";
if( $internal ){
// object details
print "<div id='object_details'>"
. "<form action='update_object.php'>"
;
#var_dump($config);
$attrs = xattr_list( $obj_path );
//$attrs = array();
foreach( $attrs as $attr ){
$val = xattr_get( $obj_path, $attr );
if( $val === FALSE ){
$val = '';
}
$val = 'pie';
# TODO: escape $atr for input naming purposes
print "<div id='attr_$attr' class='table_row'>"
. "<label for='attr_$attr' class='container_attr'>$attr</label>"
#. "<div class='container_val'>"
. "<input type='text' name='attr_$attr' value='$val' />"
. "</div>"
;
}
print ""
. "</form>"
. "</div>"
;
}
print "<div>$obj_path</div>";
print "<div class='object'><img src='/inventory_images/$container/$object' /></div>";
if( ! $container_handle = opendir( $container_path ) ){
die( "Error opening container dir" );
}
while( false !== ($subcontainer = readdir($container_handle)) ){
if( $subcontainer == '.' or $subcontainer == '..' ){
continue;
}
$containers[] = $subcontainer;
}
foreach( $containers as $subcontainer ){
if( is_dir( "$container_path/$subcontainer" ) ){
print "<div class='container'>
Container: <a class='container' href='container.php?"
. "container=" . urlencode($container.'/'.$subcontainer)
. "'>$subcontainer</a></div>\n";
}
}
foreach( $containers as $subcontainer ){
if( ! is_dir( "$container_path/$subcontainer" ) ){
print "<div class='container'>
Object: <a class='object' href='object.php?"
. "container=" . urlencode($container.'/'.$subcontainer)
. "'>$subcontainer</a></div>\n";
}
}
?>
</body>
</html>