-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·110 lines (98 loc) · 3.47 KB
/
index.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
<?php
$password = "whatever";
$dir = "/var/www/html/models/models";
header("Content-type: text/html; charset=utf-8");
if(empty($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password) {
header('WWW-Authenticate: Basic realm=""');
header('HTTP/1.0 401 Unauthorized');
echo 'Password Required';
exit;
} else {
echo "<title>".(isset($title)?$title:"Models.")."</title>\n";
}
?>
<html>
<head>
<title>Models.</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
<link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./index.style.css">
<script src="./js/jquery.js"></script>
<script src="./bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="text-center" id="model-viewer">
<iframe name="model" frameborder="0" scrolling="no" src="./webgl.php?file="></iframe>
</div>
<script type="text/javascript">
function listinit(){
var options = {
valueNames: [ 'name' ]
};
var userList = new List('models', options);
}
if(window.addEventListener) {
window.addEventListener('load',listinit,false); //W3C
} else {
window.attachEvent('onload',listinit); //IE
}
</script>
<div id="description">
<h1>Model Repository</h1>
<p>This collection is comprised primarily of models designed by Miguel Zavala (mz4250), and are provided here for easy access for 3D printing. Most models were originally distributed through Shapeways, which does not provide for easy downloading of files.</p>
<?php
$files1 = scandir($dir);
$files2 = scandir($dir, 1);
?>
<p>There are a total of <?php echo count($files1) ?> files in this directory.</p>
</div>
<div id="models">
<div class="model-search">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">
Sort
</button>
</div>
<ul class="list">
<?php
foreach ($files1 as &$value) {
if(preg_match('([a-zA-Z])', $value)) {
echo "<li>";
echo "<a class='name' href=\"./models/$value\">" . substr($value, 0, -4) . "</a> - <a href=\"webgl.php?file=$value\" target=\"model\">(Preview)</a>";
echo "</li>";
}
}
// $arr is now array(2, 4, 6, 8)
unset($value); // break the reference with the last element
?>
<li><a class='name'>Mike sucks</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Oh man</a></li>
<li><a class='name'>Hell boy</a></li>
</ul>
</div>
</div>
<script>
function resize() {
$('.list').height(
$('.container').outerHeight(true)
- $('#model-viewer').outerHeight(true)
- $('#description').outerHeight(true)
- $('.model-search').outerHeight(true)
- 50
);
}
resize();
$(window).on('resize', () => {
resize();
});
</script>
</body>
</html>