-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuitest.php
More file actions
66 lines (56 loc) · 2.1 KB
/
Copy pathuitest.php
File metadata and controls
66 lines (56 loc) · 2.1 KB
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
<pre>
</pre>
<?php
require_once('includes/autoload.php');
define('_DIRECTORY', './R60_2005/');
define('_DESCRIPTION', 'Description');
define('_LISTENTRY', 'ListEntry');
define('_RANGES', 'Ranges');
define('_RANGESCOUNT', 'RangesCount');
$files = scandir(_DIRECTORY);
//var_dump($files);
foreach($files as $file){
if(strpos($file, '.2PF')===false)continue;
ob_start();
$mapIni = parse_ini_string(preg_replace("/\=(.+)\r/", "=\"$1\"\r", file_get_contents(_DIRECTORY.$file)), true);
$output = ob_get_clean();
ob_end_flush();
if(!$mapIni){
echo '<span style="color: red;">Failed loading '.$file.': '.$output.'</span><br />';
continue;
}
$map = new Map(str_replace('.2PF', '', $file));
?>
<?=$mapIni[$map->getAbbreviation().'0'][_DESCRIPTION]?>: <select name="setting[<?=$map->getAbbreviation()?>]">
<?php
foreach($mapIni as $sectionName => $section){
switch($sectionName){
case _RANGES:
$rangesCount = $section[_RANGESCOUNT];
for($i=1; $i <= $rangesCount; $i++){
if(!array_key_exists('Range'.$i.'Start', $section) || !array_key_exists('Range'.$i.'End', $section)) {
throw new Exception('RangesCount differs from actual number of ranges');
}
$range = new Range($section['Range'.$i.'Start'], $section['Range'.$i.'End']);
$map->addRange($range);
}
break;
default:
$setting = new Setting($sectionName, $section[_DESCRIPTION], $section[_LISTENTRY], array());
?>
<option value="<?=$sectionName?>"><?=$section[_LISTENTRY]?></option>
<?php
foreach($section as $key => $value){
if($key == _DESCRIPTION || $key == _LISTENTRY) continue;
$value = new Value($key, $value);
$setting->addValue($value);
}
$map->addSetting($setting);
break;
}
}
?>
</select><br />
<?php
}
?>