-
Notifications
You must be signed in to change notification settings - Fork 6
/
get_remote_designs_list.php
52 lines (43 loc) · 1.29 KB
/
get_remote_designs_list.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
<?php
/*
FILE NAME : get_remote_designs_list.php
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <[email protected]>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
//$res_xml = file_get_contents("sensors/sensors.xml");
$path = "https://github.com/Elphel/elens";
$contents = file_get_contents($path);
$regexp_xml = '#<a[^>]*href="([^"]*)"[^>]*title=".*.xml"#';
$regexp_zmx = '#<a[^>]*href="([^"]*)"[^>]*title=".*.zmx"#';
$regexp_len = '#<a[^>]*href="([^"]*)"[^>]*title=".*.len"#';
$files = Array();
if(preg_match_all($regexp_xml, $contents, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$files[] = basename($match[1]);
}
}
if(preg_match_all($regexp_len, $contents, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$files[] = basename($match[1]);
}
}
if(preg_match_all($regexp_zmx, $contents, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$files[] = basename($match[1]);
}
}
$res_xml = "<?xml version='1.0'?>\n";
$res_xml .= "<Document>\n";
foreach($files as $file){
$res_xml .= "\t<file>$file</file>\n";
}
$res_xml .= "</Document>";
header("Content-Type: text/xml");
header("Content-Length: ".strlen($res_xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $res_xml);
flush();
?>