forked from StacksNetwork/StacksNetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navbar.inc.php
654 lines (558 loc) · 28.6 KB
/
navbar.inc.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage webui
* @copyright (C) 2006-2015 Adam Armstrong
*
*/
// FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways)
?>
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#main-nav">
<span class="oicon-bar"></span>
<span class="oicon-bar"></span>
<span class="oicon-bar"></span>
</button>
<a class="brand brand-observium" href="<?php generate_url(''); ?>"> </a>
<div class="nav-collapse" id="main-nav">
<ul class="nav">
<?php
//////////// Build main "globe" menu
$navbar['observium'] = array('url' => generate_url(array('page' => 'overview')), 'icon' => 'oicon-globe-model');
$navbar['observium']['entries'][] = array('title' => '概述', 'url' => generate_url(array('page' => 'overview')), 'icon' => 'oicon-globe-model');
$navbar['observium']['entries'][] = array('divider' => TRUE);
if (isset($config['enable_map']) && $config['enable_map'])
{ // FIXME link is wrong. Is this a supported feature?
$navbar['observium']['entries'][] = array('title' => '网络拓扑', 'url' => generate_url(array('page' => 'overview')), 'icon' => 'oicon-map');
}
$navbar['observium']['entries'][] = array('title' => '事件日志', 'url' => generate_url(array('page' => 'eventlog')), 'icon' => 'oicon-clipboard-audit');
if (isset($config['enable_syslog']) && $config['enable_syslog'])
{
$navbar['observium']['entries'][] = array('title' => '系统日志', 'url' => generate_url(array('page' => 'syslog')), 'icon' => 'oicon-clipboard-eye');
}
$navbar['observium']['entries'][] = array('title' => '轮询信息', 'url' => generate_url(array('page' => 'pollerlog')), 'icon' => 'oicon-clipboard-report-bar');
$navbar['observium']['entries'][] = array('divider' => TRUE);
if (OBSERVIUM_EDITION != 'community')
{
$navbar['observium']['entries'][] = array('title' => '警报', 'url' => generate_url(array('page' => 'alerts')), 'icon' => 'oicon-bell');
$navbar['observium']['entries'][] = array('title' => '警报检测', 'url' => generate_url(array('page' => 'alert_checks')), 'icon' => 'oicon-eye');
$navbar['observium']['entries'][] = array('title' => '警报日志', 'url' => generate_url(array('page' => 'alert_log')), 'icon' => 'oicon-bell--exclamation');
$navbar['observium']['entries'][] = array('divider' => TRUE);
$navbar['observium']['entries'][] = array('title' => '分组', 'url' => generate_url(array('page' => 'groups')), 'icon' => 'oicon-category');
$navbar['observium']['entries'][] = array('divider' => TRUE);
}
$navbar['observium']['entries'][] = array('title' => '清单', 'url' => generate_url(array('page' => 'inventory')), 'icon' => 'oicon-wooden-box');
$navbar['observium']['entries'][] = array('divider' => TRUE);
if ($cache['packages']['count'])
{
$navbar['observium']['entries'][] = array('title' => '软件包', 'url' => generate_url(array('page' => 'packages')), 'icon' => 'oicon-box-zipper');
$navbar['observium']['entries'][] = array('divider' => TRUE);
}
// Build search submenu
$search_sections = array('ipv4' => 'IPv4地址', 'ipv6' => 'IPv6地址', 'mac' => 'MAC地址', 'arp' => 'ARP/NDP表', 'fdb' => 'FDB表');
if ($cache['wifi_sessions']['count'])
{
$search_sections['dot1x'] = '.1x Sessions';
}
foreach ($search_sections as $search_page => $search_name)
{
$search_menu[] = array('title' => $search_name, 'url' => generate_url(array('page' => 'search', 'search' => $search_page)), 'icon' => 'oicon-magnifier-zoom-actual');
}
$navbar['observium']['entries'][] = array('title' => '搜索', 'url' => generate_url(array('page' => 'search')), 'icon' => 'oicon-magnifier-zoom-actual', 'entries' => $search_menu);
//////////// Build devices menu
$navbar['devices'] = array('url' => generate_url(array('page' => 'devices')), 'icon' => 'oicon-servers', 'title' => '设备');
// FIXME In the old code the menu width was 200px specifically - we don't do this now but doesn't seem to be a problem?
$navbar['devices']['entries'][] = array('title' => '所有设备', 'url' => generate_url(array('page' => 'devices')), 'icon' => 'oicon-servers');
$navbar['devices']['entries'][] = array('divider' => TRUE);
// Build location submenu
if ($config['geocoding']['enable'] && $config['location_menu_geocoded'])
{
$navbar['devices']['entries'][] = array('locations' => TRUE); // Pretty complicated recursive function, workaround not having it converted to returning an array
} else {
// Non-geocoded menu
foreach (get_locations() as $location)
{
$name = ($location === '' ? OBS_VAR_UNSET : escape_html($location));
$location_menu[] = array('url' => generate_location_url($location), 'icon' => 'oicon-building-small', 'title' => $name);
}
$navbar['devices']['entries'][] = array('title' => '位置', 'url' => generate_url(array('page' => 'locations')), 'icon' => 'oicon-building', 'entries' => $location_menu);
}
$navbar['devices']['entries'][] = array('divider' => TRUE);
// Build list per device type
foreach ($config['device_types'] as $devtype)
{
if (in_array($devtype['type'], array_keys($cache['device_types'])))
{
$navbar['devices']['entries'][] = array('title' => $devtype['text'],'icon' => $devtype['icon'], 'count' => $cache['device_types'][$devtype['type']], 'url' => generate_url(array('page' => 'devices', 'type' => $devtype['type'])));
}
}
if ($devices['down']+$devices['ignored']+$devices['disabled'])
{
$navbar['devices']['entries'][] = array('divider' => TRUE);
if ($devices['down'])
{
$navbar['devices']['entries'][] = array('url' => generate_url(array('page' => 'devices', 'status' => '0')), 'icon' => 'oicon-circle-red', 'title' => '异常');
}
if ($devices['ignored'])
{
$navbar['devices']['entries'][] = array('url' => generate_url(array('page' => 'devices', 'ignore' => '1')), 'icon' => 'oicon-circle-yellow', 'title' => '忽略');
}
if ($devices['disabled'])
{
$navbar['devices']['entries'][] = array('url' => generate_url(array('page' => 'devices', 'disabled' => '1')), 'icon' => 'oicon-circle-metal', 'title' => '禁用');
}
}
if ($_SESSION['userlevel'] >= '5')
{
$navbar['devices']['entries'][] = array('divider' => TRUE);
$navbar['devices']['entries'][] = array('url' => generate_url(array('page' => 'addhost')), 'icon' => 'oicon-server--plus', 'title' => '添加设备');
$navbar['devices']['entries'][] = array('url' => generate_url(array('page' => 'delhost')), 'icon' => 'oicon-server--minus', 'title' => '删除设备');
}
//////////// Build ports menu
$navbar['ports'] = array('url' => generate_url(array('page' => 'ports')), 'icon' => 'oicon-network-ethernet', 'title' => '端口');
$navbar['ports']['entries'][] = array('title' => '所有端口', 'count' => $ports['count'], 'url' => generate_url(array('page' => 'ports')), 'icon' => 'oicon-network-ethernet');
$navbar['ports']['entries'][] = array('divider' => TRUE);
if ($config['enable_billing'])
{
$navbar['ports']['entries'][] = array('title' => '流量账单', 'url' => generate_url(array('page' => 'bills')), 'icon' => 'oicon-money-coin');
$ifbreak = 1;
}
if ($config['enable_pseudowires'] && $cache['pseudowires']['count'])
{
$navbar['ports']['entries'][] = array('title' => '伪流量 ('.$cache['pseudowires']['count'].')', 'url' => generate_url(array('page' => 'pseudowires')), 'icon' => 'oicon-layer-shape-curve');
$ifbreak = 1;
}
if ($cache['cbqos']['count'])
{
$navbar['ports']['entries'][] = array('title' => 'CBQoS ('.$cache['cbqos']['count'].')', 'url' => generate_url(array('page' => 'ports', 'cbqos' => 'yes')), 'icon' => 'oicon-category-group');
$ifbreak = 1;
}
if ($ifbreak)
{
$navbar['ports']['entries'][] = array('divider' => TRUE);
$ifbreak = 0;
}
if ($_SESSION['userlevel'] >= '5')
{
// FIXME new icons
if ($config['int_customers']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'customers')), 'image' => "images/16/group_link.png", 'title' => '客户'); $ifbreak = 1; }
if ($config['int_l2tp']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => 'l2tp')), 'image' => "images/16/user.png", 'title' => 'L2TP'); $ifbreak = 1; }
if ($config['int_transit']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => 'transit')), 'image' => "images/16/lorry_link.png", 'title' => '透传'); $ifbreak = 1; }
if ($config['int_peering']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => 'peering')), 'image' => "images/16/bug_link.png", 'title' => '对等互联'); $ifbreak = 1; }
if ($config['int_peering'] && $config['int_transit']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => 'peering,transit')), 'image' => "images/16/world_link.png", 'title' => '对等互联 & 透传'); $ifbreak = 1; }
if ($config['int_core']) { $navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => 'core')), 'image' => "images/16/brick_link.png", 'title' => '核心'); $ifbreak = 1; }
// Custom interface groups can be set - see Interface Description Parsing
foreach ($config['int_groups'] as $int_type)
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'iftype', 'type' => $int_type)), 'image' => "images/16/brick_link.png", 'title' => $int_type); $ifbreak = 1;
}
}
if ($ifbreak) { $navbar['ports']['entries'][] = array('divider' => TRUE); }
/// FIXME. Make Down/Ignored/Disabled ports as submenu. --mike
if (isset($ports['alerts']))
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'ports', 'alerted' => 'yes')), 'icon' => 'oicon-chain--exclamation', 'title' => '警报', 'count' => $ports['alerts']);
}
if ($ports['errored'])
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'ports', 'errors' => 'yes')), 'icon' => 'oicon-exclamation-button', 'title' => '错误', 'count' => $ports['errored']);
}
if ($ports['down'])
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'ports', 'state' => 'down')), 'icon' => 'oicon-network-status-busy', 'title' => '异常');
}
if ($ports['ignored'])
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'ports', 'ignore' => '1')), 'icon' => 'oicon-network-status-away', 'title' => '忽略');
}
if ($ports['disabled'])
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'ports', 'state' => 'admindown')), 'icon' => 'oicon-network-status-offline', 'title' => '禁用');
}
if ($ports['deleted'])
{
$navbar['ports']['entries'][] = array('url' => generate_url(array('page' => 'deleted-ports')), 'icon' => 'oicon-badge-square-minus', 'title' => '已删除', 'count' => $ports['deleted']);
}
//////////// Build health menu
$navbar['health'] = array('url' => '#', 'icon' => 'oicon-system-monitor', 'title' => '系统健康');
$health_items = array('processor' => array('text' => "处理器", 'icon' => 'oicon-processor'),
'mempool' => array('text' => "内存", 'icon' => 'oicon-memory'),
'storage' => array('text' => "存储", 'icon' => 'oicon-drive'));
if ($cache['toner']['count'])
{
$health_items['toner'] = array('text' => "硒鼓", 'icon' => 'oicon-contrast');
}
if ($cache['status']['count'])
{
$health_items['status'] = array('text' => "Status", 'icon' => $config['entities']['status']['icon']);
}
foreach ($health_items as $item => $item_data)
{
$navbar['health']['entries'][] = array('url' => generate_url(array('page' => 'health', 'metric' => $item)), 'icon' => $item_data['icon'], 'title' => $item_data['text']);
unset($menu_sensors[$item]);$sep++;
}
$menu_items[0] = array('fanspeed','humidity','temperature','airflow');
$menu_items[1] = array('current','voltage','power','apower','frequency');
$menu_items[2] = array_diff(array_keys($cache['sensor_types']), $menu_items[0], $menu_items[1]);
foreach ($menu_items as $items)
{
foreach ($items as $item)
{
if ($cache['sensor_types'][$item])
{
if ($sep)
{
$navbar['health']['entries'][] = array('divider' => TRUE);
$sep = 0;
}
$alert_icon = ($cache['sensor_types'][$item]['alert'] ? '<i class="oicon-exclamation-red"></i>' : '');
$navbar['health']['entries'][] = array('url' => generate_url(array('page' => 'health', 'metric' => $item)), 'icon' => $config['sensor_types'][$item]['icon'], 'title' => nicecase($item) . ' ' . $alert_icon);
}
}
$sep++;
}
//////////// Build applications menu
if ($_SESSION['userlevel'] >= '5' && ($cache['applications']['count']) > 0)
{
$navbar['apps'] = array('url' => '#', 'icon' => 'oicon-application-icon-large', 'title' => '应用');
$app_list = dbFetchRows("SELECT `app_type` FROM `applications` WHERE 1 ".$cache['where']['devices_permitted']." GROUP BY `app_type`;");
foreach ($app_list as $app)
{
$image = $config['html_dir']."/images/icons/".$app['app_type'].".png";
$icon = (file_exists($image) ? $app['app_type'] : "apps");
$navbar['apps']['entries'][] = array('url' => generate_url(array('page' => 'apps', 'app' => $app['app_type'])), 'image' => 'images/icons/'.$icon.'.png', 'title' => nicecase($app['app_type']));
}
}
//////////// Build routing menu
if ($_SESSION['userlevel'] >= '5' && ($routing['bgp']['count']+$routing['ospf']['count']+$routing['cef']['count']+$routing['vrf']['count']) > 0)
{
$navbar['routing'] = array('url' => '#', 'icon' => 'oicon-arrow-branch-000-left', 'title' => '路由');
$separator = 0;
if ($_SESSION['userlevel'] >= '5' && $routing['vrf']['count'])
{
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'vrf')), 'icon' => 'oicon-arrow-branch-byr', 'title' => 'VRFs', 'count' => $routing['vrf']['count']);
$separator++;
}
if ($_SESSION['userlevel'] >= '5' && $routing['ospf']['up'])
{
if ($separator)
{
$navbar['routing']['entries'][] = array('divider' => TRUE);
$separator = 0;
}
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'ospf')), 'image' => 'images/16/text_letter_omega.png', 'title' => 'OSPF', 'count' => $routing['ospf']['up']);
$separator++;
}
// BGP Sessions
if ($_SESSION['userlevel'] >= '5' && $routing['bgp']['count'])
{
if ($separator)
{
$navbar['routing']['entries'][] = array('divider' => TRUE);
$separator = 0;
}
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'bgp', 'type' => 'all', 'graph' => 'NULL')), 'image' => "images/16/link.png", 'title' => 'BGP所有会话', 'count' => $routing['bgp']['count']);
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'bgp', 'type' => 'external', 'graph' => 'NULL')), 'image' => "images/16/world_link.png", 'title' => 'BGP外部流量');
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'bgp', 'type' => 'internal', 'graph' => 'NULL')), 'image' => "images/16/brick_link.png", 'title' => 'BGP内部流量');
}
// Do Alerts at the bottom
if ($routing['bgp']['alerts'])
{
$navbar['routing']['entries'][] = array('divider' => TRUE);
$navbar['routing']['entries'][] = array('url' => generate_url(array('page' => 'routing', 'protocol' => 'bgp', 'adminstatus' => 'start', 'state' => 'down')), 'image' => "images/16/link_error.png", 'title' => 'BGP警报', 'count' => $routing['bgp']['alerts']);
}
}
// Custom navbar entries.
if (is_file("includes/navbar-custom.inc.php"))
{
include("includes/navbar-custom.inc.php");
}
// DOCME needs phpdoc block
function navbar_location_menu($array)
{
global $config;
ksort($array['entries']);
echo('<ul class="dropdown-menu">');
if (count($array['entries']) > "3")
{
foreach ($array['entries'] as $entry => $entry_data)
{
$image = '<i class="menu-icon oicon-building"></i>';
if ($entry_data['level'] == "location_country")
{
$code = $entry;
$entry = country_from_code($entry);
$image = '<i class="flag flag-'.$code.'"></i>';
}
elseif ($entry_data['level'] == "location")
{
$name = ($entry === '' ? OBS_VAR_UNSET : escape_html($entry));
echo(' <li><a href="' . generate_location_url($entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' ['.$entry_data['count'].']</a></li>');
continue;
}
$url = ($entry_data['level'] == 'location_country' ? $code : $entry);
echo('<li class="dropdown-submenu"><a href="' . generate_url(array('page' => 'devices', $entry_data['level'] => var_encode($url))) .
'">' . $image . ' ' . $entry . ' ['.$entry_data['count'].']</a>');
navbar_location_menu($entry_data);
echo('</li>');
}
} else {
$new_entry_array = array();
foreach ($array['entries'] as $new_entry => $new_entry_data)
{
if ($new_entry_data['level'] == "location_country")
{
$code = $new_entry;
$new_entry = country_from_code($new_entry);
$image = '<i class="flag flag-'.$code.'"></i> ';
}
elseif ($new_entry_data['level'] == "location")
{
$name = ($new_entry === '' ? OBS_VAR_UNSET : escape_html($new_entry));
echo(' <li><a href="' . generate_location_url($new_entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' ['.$new_entry_data['count'].']</a></li>');
continue;
}
echo('<li class="nav-header">'.$image.$new_entry.'</li>');
foreach ($new_entry_data['entries'] as $sub_entry => $sub_entry_data)
{
if (is_array($sub_entry_data['entries']))
{
echo('<li class="dropdown-submenu"><a style="" href="' . generate_url(array('page'=>'devices', $sub_entry_data['level'] => var_encode($sub_entry))) . '">
<i class="menu-icon oicon-building"></i> ' . $sub_entry . ' ['.$sub_entry_data['count'].']</a>');
navbar_location_menu($sub_entry_data);
} else {
$name = ($sub_entry === '' ? OBS_VAR_UNSET : escape_html($sub_entry));
echo(' <li><a href="' . generate_location_url($sub_entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' ['.$sub_entry_data['count'].']</a></li>');
}
}
}
}
echo('</ul>');
}
// DOCME needs phpdoc block
function navbar_submenu($entry, $level = 1)
{
echo(str_pad('',($level-1)*2) . ' <li class="dropdown-submenu"><a href="' . $entry['url'] . '"><i class="menu-icon ' . $entry['icon'] . '"></i> ' . $entry['title'] . '</a>' . PHP_EOL);
echo(str_pad('',($level-1)*2) . ' <ul class="dropdown-menu">' . PHP_EOL);
foreach ($entry['entries'] as $subentry)
{
if (count($subentry['entries']))
{
navbar_submenu($subentry, $level+1);
} else {
navbar_entry($subentry, $level+2);
}
}
echo(str_pad('',($level-1)*2) . ' </ul>' . PHP_EOL);
echo(str_pad('',($level-1)*2) . ' <li>' . PHP_EOL);
}
// DOCME needs phpdoc block
function navbar_entry($entry, $level = 1)
{
global $cache;
if ($entry['divider'])
{
echo(str_pad('',($level-1)*2) . ' <li class="divider"></li>' . PHP_EOL);
} elseif ($entry['locations']) { // Workaround until the menu builder returns an array instead of echo()
echo(str_pad('',($level-1)*2) . ' <li class="dropdown-submenu">' . PHP_EOL);
echo(str_pad('',($level-1)*2) . ' <a href="'.generate_url(array('page'=>'locations')).'"><i class="menu-icon oicon-building-hedge"></i> 位置</a>' . PHP_EOL);
navbar_location_menu($cache['locations']);
echo(str_pad('',($level-1)*2) . ' </li>' . PHP_EOL);
} else {
echo(str_pad('',($level-1)*2) . ' <li><a href="' . $entry['url'] . '"><i class="menu-icon ' . $entry['icon'] . '"></i> ');
if (isset($entry['image'])) { echo('<img src="' . $entry['image'] . '" alt="" /> '); }
echo($entry['title']);
if (isset($entry['count'])) { echo(' <span class="right">(' . $entry['count'] . ')</span>'); }
echo(str_pad('',($level-1)*2) . '</a></li>' . PHP_EOL);
}
}
// Build navbar from $navbar array
foreach ($navbar as $dropdown)
{
echo(' <li class="divider-vertical" style="margin: 0;"></li>' . PHP_EOL);
echo(' <li class="dropdown">' . PHP_EOL);
echo(' <a href="' . $dropdown['url'] . '" class="hidden-sm dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . PHP_EOL);
echo(' <i class="' . $dropdown['icon'] . '"></i> ' . $dropdown['title'] . ' <b class="caret"></b></a>' . PHP_EOL);
echo(' <a href="' . $dropdown['url'] . '" class="visible-sm dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . PHP_EOL);
echo(' <i class="' . $dropdown['icon'] . '"></i> <b class="caret"></b></a>' . PHP_EOL);
echo(' <ul class="dropdown-menu">' . PHP_EOL);
foreach ($dropdown['entries'] as $entry)
{
if (count($entry['entries']))
{
navbar_submenu($entry);
} else {
navbar_entry($entry);
}
}
echo(' </ul>' . PHP_EOL);
echo(' </li>' . PHP_EOL);
}
unset($navbar);
// The menus on the right are not handled by the navbar array code yet.
?>
</ul>
<ul class="nav pull-right">
<li class="dropdown hidden-xs">
<form id="searchform" class="navbar-search" action="#" style="margin-left: 5px; margin-right: 10px; margin-top: 5px; margin-bottom: -5px;">
<input style="width: 100px;" onkeyup="lookup(this.value);" onblur="$('#suggestions').fadeOut()" type="text" value="" class="dropdown-toggle" placeholder="搜索" />
</form>
<div id="suggestions" class="typeahead dropdown-menu"></div>
</li>
<?php
if ($_SESSION['touch'] == "yes")
{
$url = generate_url($vars, array('touch' => 'no'));
} else {
$url = generate_url($vars, array('touch' => 'yes'));
}
$browser = detect_browser();
if ($vars['touch'] == 'yes') { $icon = 'oicon-hand-point-090'; }
elseif ($browser == 'mobile') { $icon = 'icon-mobile-phone'; }
elseif ($browser == 'tablet') { $icon = 'icon-tablet'; }
else { $icon = 'icon-laptop'; }
echo('<li><a href="' . $url . '"> <i class="' . $icon . '"></i></a></li>');
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="oicon-gear"></i> <b class="caret"></b></a>
<ul class="dropdown-menu">
<?php
// Refresh menu
echo('<li class="dropdown-submenu">');
echo(' <a tabindex="-1" href="'.generate_url($vars).'"><i class="oicon-arrow-circle"></i> 刷新 <span id="countrefresh"></span></a>');
echo(' <ul class="dropdown-menu">');
foreach ($page_refresh['list'] as $refresh_time)
{
$refresh_class = ($refresh_time == $page_refresh['current'] ? 'active' : '');
if (!$page_refresh['allowed']) { $refresh_class = 'disabled'; }
if ($refresh_time == 0)
{
echo(' <li class="'.$refresh_class.'"><a href="'.generate_url($vars, array('refresh' => '0')).'"><i class="icon-ban-circle"></i> 手动</a></li>');
} else {
echo(' <li class="'.$refresh_class.'"><a href="'.generate_url($vars, array('refresh' => $refresh_time)).'"><i class="icon-refresh"></i> 平均每 '.formatUptime($refresh_time, 'longest').'</a></li>');
}
}
echo(' </ul>');
echo('</li>');
echo('<li class="divider"></li>');
if ($_SESSION['widescreen'] == 1)
{
echo('<li><a href="'.generate_url($vars, array('widescreen' => 'no')).'" title="切换到标准宽度"><i class="oicon-arrow-in" style="font-size: 16px; color: #555;"></i> 标准宽度</a></li>');
} else {
echo('<li><a href="'.generate_url($vars, array('widescreen' => 'yes')).'" title="切换到宽屏显示"><i class="oicon-arrow-move" style="font-size: 16px; color: #555;"></i> 宽屏</a></li>');
}
if ($_SESSION['big_graphs'] == 1)
{
echo('<li><a href="'.generate_url($vars, array('big_graphs' => 'no')).'" title="切换为普通图像"><i class="oicon-layout-6" style="font-size: 16px; color: #555;"></i> 普通图像</a></li>');
} else {
echo('<li><a href="'.generate_url($vars, array('big_graphs' => 'yes')).'" title="切换到大图"><i class="oicon-layout-4" style="font-size: 16px; color: #555;"></i> 大图</a></li>');
}
if ($config['api']['enabled'])
{
echo('<li class="divider"></li>');
echo('<li class="dropdown-submenu">');
echo(' <a tabindex="-1" href="'.generate_url(array('page' => 'simpleapi')).'"><i class="oicon-application-block"></i> 独立API</a>');
echo(' <ul class="dropdown-menu">');
echo(' <li><a href="'.generate_url(array('page' => 'simpleapi')).'"><i class="oicon-application-block"></i> API手册</a></li>');
echo(' <li><a href="'.generate_url(array('page' => 'simpleapi','api' => 'errorcodes')).'"><i class="oicon-application--exclamation"></i> 错误代码</a></li>');
echo(' </ul>');
echo('</li>');
}
if ($_SESSION['userlevel'] >= 10)
{
echo('<li class="divider"></li>');
echo('<li class="dropdown-submenu">');
echo(' <a tabindex="-1" href="'.generate_url(array('page' => 'adduser')).'"><i class="oicon-users"></i> 用户</a>');
echo(' <ul class="dropdown-menu">');
if (auth_usermanagement())
{
echo(' <li><a href="'.generate_url(array('page' => 'adduser')).'"><i class="oicon-user--plus"></i> 添加用户</a></li>');
}
echo(' <li><a href="'.generate_url(array('page' => 'edituser')).'"><i class="oicon-user--pencil"></i> 编辑用户</a></li>');
if (auth_usermanagement())
{
echo(' <li><a href="'.generate_url(array('page' => 'edituser')).'"><i class="oicon-user--minus"></i> 删除用户</a></li>');
}
echo(' <li><a href="'.generate_url(array('page' => 'authlog')).'"><i class="oicon-user-detective"></i> 认证日志</a></li>');
echo(' </ul>');
echo('</li>');
}
?>
<li class="divider"></li>
<li><a href="<?php echo(generate_url(array('page' => 'settings'))); ?>" title="全局设置"><i class="oicon-wrench"></i> 全局设置</a></li>
<li><a href="<?php echo(generate_url(array('page' => 'preferences'))); ?>" title="我的设置 "><i class="oicon-wrench-screwdriver"></i> 我的设置</a></li>
<?php
if (auth_can_logout())
{
?>
<li class="divider"></li>
<li><a href="<?php echo(generate_url(array('page' => 'logout'))); ?>" title="注销"><i class="oicon-door-open-out"></i> 注销</a></li>
<?php
}
?>
<li class="divider"></li>
<li><a href="<?php echo OBSERVIUM_URL; ?>/wiki/Documentation" title="帮助"><i class="oicon-question"></i> 帮助</a></li>
<li><?php echo(generate_link('<i class="oicon-information"></i> 关于 '.OBSERVIUM_PRODUCT, array('page' => 'about'), array(), FALSE)); ?></li>
</ul>
</li>
</ul>
</div><!-- /.nav-collapse -->
</div>
</div><!-- /navbar-inner -->
</header>
<script type="text/javascript">
key_count_global = 0;
function lookup(inputString) {
if (inputString.trim().length == 0) {
$('#suggestions').fadeOut(); // Hide the suggestions box
} else {
key_count_global++;
setTimeout("lookupwait("+key_count_global+",\""+inputString+"\")", 300); // Added timeout 0.3s before send query
}
}
function lookupwait(key_count,inputString) {
if(key_count == key_count_global) {
$.post("ajax/search.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
$('#suggestions').fadeIn(); // Show the suggestions box
$('#suggestions').html(data); // Fill the suggestions box
});
}
}
<?php
if (isset($page_refresh['nexttime'])) // Begin Refresh JS
{
?>
// set initial seconds left we're counting down to
var seconds_left = <?php echo($page_refresh['nexttime'] - time()); ?>;
// get tag element
var countrefresh = document.getElementById('countrefresh');
// update the tag with id "countdown" every 1 second
setInterval(function () {
// do some time calculations
var minutes = parseInt(seconds_left / 60);
var seconds = parseInt(seconds_left % 60);
// format countdown string + set tag value
if (minutes > 0) {
minutes = minutes + '分 ';
seconds = seconds + '秒';
} else {
minutes = '';
if (seconds > 0) {
seconds = seconds + '秒';
} else {
seconds = '0秒';
}
}
countrefresh.innerHTML = '<span class="label">' + minutes + seconds + '</span>';
seconds_left = seconds_left - 1;
}, 1000);
<?php
} // End Refresh JS
?>
</script>