-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnav.php
74 lines (61 loc) · 2.1 KB
/
nav.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
<?php
// search config file
$file_search = str_replace('\\','/',dirname(__FILE__).'/datasets/documents/homepage/config/search/content.md');
// navigator config file
$file_nav = str_replace('\\','/',dirname(__FILE__).'/datasets/documents/homepage/config/nav/content.md');
// Daily Motto
$file_dm = str_replace('\\','/',dirname(__FILE__).'/datasets/documents/homepage/config/dailymotto/content.md');
// search config array
$arr_sd = '';
// navigator url config array
$arr_nd = '';
function AnalyseConfig($file, &$arr) {
$arr = '';
$ss = array('');
if(file_exists($file)){
// load file to array
$ss = file($file);
foreach($ss as $v){
// trim blank
$a = trim($v);
if ($a == '') continue;
// first char must be '-' or '*'
if (($a[0] <> '-')&&(($a[0] <> '*'))) continue;
// replace ',' to ',' then explode to sub-array $tmp
$tmp = explode('|', substr($a, 1));
$arr = $arr.'[';
for($n=0; $n<count($tmp); $n++){
$arr = $arr.'"'.trim($tmp[$n]).'",';
}
$arr = $arr.'],';
}
}
// add '[ ]'
$arr = '['.$arr.'[""]];';
}
AnalyseConfig($file_search, $arr_sd);
AnalyseConfig($file_nav, $arr_nd);
$dm = $dmh = $dms = '';
if(file_exists($file_dm)){
$ss = file($file_dm);
$ar = array();
foreach($ss as $v){
// trim blank
$a = trim($v);
if ($a == '') continue;
// first char must be '-' or '*'
if (($a[0] <> '-')&&(($a[0] <> '*'))) continue;
// add a line
$t = trim(substr($a, 1));
if ($t != '')
array_push($ar, $t);
}
if(count($ar) > 0) {
$tdm = explode('|', $ar[randint_day() % count($ar)]);
if(isset($tdm[0]))$dm = $tdm[0];
if(isset($tdm[1]))$dmh = $tdm[1];
if(isset($tdm[2]))$dms = $tdm[2];
}
}
echo "<script> SXYH_ArraySearch = ".$arr_sd.";\n SXYH_ArrayNav = ".$arr_nd.";\n SXYH_dm = '".addslashes(trim($dm))."';\n SXYH_dm_hint ='".addslashes(trim($dmh))."';\n SXYH_dm_style = '".trim($dms)."';\n</script>";
?>