-
Notifications
You must be signed in to change notification settings - Fork 22
/
directory.php
143 lines (134 loc) · 6.47 KB
/
directory.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
133
134
135
136
137
138
139
140
141
142
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/resource.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Open Speech and Language Resources."/>
<meta charset="UTF-8">
<link rel="icon" type="image/png" href="/openslr_ico.png"/>
<link rel="stylesheet" type="text/css" href="/style.css"/>
<title>openslr.org</title>
</head>
<body>
<div class="container">
<div id="centeredContainer">
<div id="headerBar">
<div id="headerLeft"> <image id="logoImage" src="/openslr.png"> </div>
<div id="headerRight"><h2 class="slrStyle">Open Speech and Language Resources</h2></div>
</div>
<hr/>
<div id="topBar">
<a class="topButtons" href="/index.html">Home</a>
<a class="topButtons" href="/resources.php">Resources</a>
</div>
<hr/>
<div id="rightCol">
<div class = "contact_info">
<div class ="contactTitle">Contact</div>
<a href=mailto:[email protected]> [email protected] </a> <br/>
Phone: 425 247 4129 <br/>
(Daniel Povey) <br/>
</div>
</div>
<div id="mainContent">
<div class="container" >
<?php
$id = $_GET['id'];
$ok = true;
if ($id === false || preg_match('/^[0-9]+$/', $id) != 1) {
print "<h2> Badly formatted resource: $id </h2>\n";
$ok = false;
}
if ($ok) {
$resource_dir = dirname(__FILE__) . "/resources/" . $id;
// e.g. $root = /var/www/openslr/resources/1
$resource = new Resource($resource_dir);
if (! $resource->ok()) {
print "<h2> Resource not found: $id </h2>\n";
$ok = false;
}
}
if ($ok) {
print "<h2 class=\"slrStyle\"> $resource->name </h2>\n";
print "<p class=\"resource\"> <b>Identifier:</b> SLR$resource->id </p>\n";
print "<p class=\"resource\"> <b>Summary:</b> $resource->summary </p>\n";
print "<p class=\"resource\"> <b>Category:</b> $resource->category </p>\n";
print "<p class=\"resource\"> <b>License:</b> $resource->license </p>\n";
if (count($resource->files) == 1) {
$f_array = $resource->files[0]; // array of size 0 or 1.
$file = $f_array[0];
$comment = (count($f_array) > 1 ? $f_array[1] : '');
$size = $resource->get_file_size($file);
$hostname = gethostname();
if ($hostname == "surfingtech") {
print "<p class=\"resource\"> <b>Download:</b> ";
print "<a href=\"http://cn-mirror.openslr.org/resources/$id/$file\"> $file </a> [$size] ($comment) Mirrors: \n";
$file_url="http://www.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> [US] </a> <br> </p> \n";
} else {
print "<p class=\"resource\"> <b>Download:</b> ";
print "<a href=\"http://www.openslr.org/resources/$id/$file\"> $file </a> [$size] ($comment) Mirrors: \n";
$file_url="http://cn-mirror.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> [China] </a> <br> </p>\n";
}
} elseif (count($resource->files) > 1) {
print "<p class=\"resource\"> <b>Downloads (use a mirror closer to you):</b> <br>";
foreach ($resource->files as $f_array) {
$file = $f_array[0];
$size = $resource->get_file_size($file);
$comment = (count($f_array) > 1 ? $f_array[1] : '');
$hostname = gethostname();
if ($hostname == "surfingtech") {
$file_url="http://cn-mirror.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> $file </a> [$size] ($comment) Mirrors: \n";
$file_url="http://www.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> [US] </a> <br> \n";
} else {
$file_url="http://www.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> $file </a> [$size] ($comment) Mirrors: \n";
$file_url="http://cn-mirror.openslr.org/resources/$id/$file";
print "<a href=\"$file_url\"> [China] </a> <br> \n";
}
}
print '</p>';
}
print "<p class=\"resource\"><b>About this resource:</b></p>";
$about = $resource->get_about_html();
if ($about !== false) {
print '<div id="about">';
print $about; // dump out the html from $resource_dir/about.html
print '</div>';
}
if (count($resource->alternate_urls) == 1) {
$u_array = $resource->alternate_urls[0]; // array of size 0 or 1.
$url = $u_array[0];
$comment = (count($u_array) > 1 ? $u_array[1] : '');
print "<p class=\"resource\"> <b>External URL:</b> <a href=\"$url\"> $url </a> $comment </p> \n";
} elseif (count($resource->alternate_urls) > 1) {
print "<p class=\"resource\"> <b>External URLs:</b> <br/>";
foreach ($resource->alternate_urls as $u_array) {
$url = $u_array[0];
$comment = (count($u_array) > 1 ? $u_array[1] : '');
print "<a href=\"$url\"> $url </a> ($comment) <br/> \n";
}
print "</p>";
}
} ?>
<div style="height:300px"> </div>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<div style="clear: both"></div>
<div id="footer">
<p>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
alt="Valid CSS!" />
</a>
</p>
</div>
</div>
</body>
</html>