Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
commit | author | age
532ae5 1 <?php
L 2
3 /*
4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
b1a6a5 31 require_once '../lib/config.inc.php';
MC 32 require_once '../lib/app.inc.php';
532ae5 33
L 34 $app->uses('tpl');
35
36 //** Top Naviation
37 if(isset($_GET['nav']) && $_GET['nav'] == 'top') {
38
39     $app->tpl->newTemplate('topnav.tpl.htm');
40
41     //* Check User Login and current module
42     if(isset($_SESSION["s"]["user"]) && $_SESSION["s"]["user"]['active'] == 1 && is_array($_SESSION['s']['module'])) {
43         //* Loading modules of the user and building top navigation
44         $modules = explode(',', $_SESSION['s']['user']['modules']);
45         /*
46          * If the dashboard is in the list of modules it always has to be the first!
47          */
a563d5 48         /*
2696e1 49         asort($modules);
532ae5 50         if (in_array('dashboard', $modules)) {
L 51             $key = array_search('dashboard', $modules);
52             unset($modules[$key]);
53             $modules = array_merge(array('dashboard'), $modules);
54         }
a563d5 55         */
532ae5 56         if(is_array($modules)) {
L 57             foreach($modules as $mt) {
58                 if(is_file($mt.'/lib/module.conf.php')) {
59                     if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.');
a563d5 60                     if($mt == 'dns'){
MC 61                         $dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1");
62                         if($dns_servers['cnt'] == 0) continue;
63                     }
64                     if($mt == 'mail'){
65                         $mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1");
66                         if($mail_servers['cnt'] == 0) continue;
67                     }
68                     if($mt == 'sites'){
69                         $web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1");
70                         if($web_servers['cnt'] == 0) continue;
71                     }
d1fcdc 72                     if($mt == 'vm'){
FS 73                         $vm_servers = $app->db->queryOneRecord("SELECT COUNT(*) AS cnt FROM server WHERE vserver_server = 1 AND active = 1");
74                         if($vm_servers['cnt'] == 0) continue;
75                     }
76
b1a6a5 77                     include_once $mt.'/lib/module.conf.php';
e75e35 78                     $language = (isset($_SESSION['s']['user']['language']))?$_SESSION['s']['user']['language']:$conf['language'];
T 79                     $app->load_language_file('web/'.$mt.'/lib/'.$language.'.lng');
532ae5 80                     $active = ($module['name'] == $_SESSION['s']['module']['name']) ? 1 : 0;
0e14d7 81                     $topnav[$module['order'].'-'.$module['name']] = array( 'title'  => $app->lng($module['title']),
b1a6a5 82                         'active'  => $active,
MC 83                         'module' => $module['name']);
532ae5 84                 }
L 85             }
a563d5 86             ksort($topnav);
532ae5 87         }
L 88     } else {
89         //*  Loading Login Module
b79c5b 90         /*
b1a6a5 91         include_once 'login/lib/module.conf.php';
532ae5 92         $_SESSION['s']['module'] = $module;
b1a6a5 93         $topnav[] = array( 'title'  => 'Login',
MC 94             'active'  => 1);
532ae5 95         $module = null;
L 96         unset($module);
b79c5b 97         */
TB 98         header('Location: /login/');
99         die();
532ae5 100     }
L 101
102     //* Topnavigation
b1a6a5 103     $app->tpl->setLoop('nav_top', $topnav);
532ae5 104
L 105 }
106
107 //** Side Naviation
108 if(isset($_GET['nav']) && $_GET['nav'] == 'side') {
109
110     if(isset($_SESSION['s']['module']['name']) && is_file($_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php')) {
b1a6a5 111         include_once $_SESSION['s']['module']['name'].'/lib/custom_menu.inc.php';
532ae5 112     } else {
b1a6a5 113
532ae5 114         $app->tpl->newTemplate('sidenav.tpl.htm');
L 115
116         //* translating module navigation
117         $nav_translated = array();
118         if(isset($_SESSION['s']['module']['nav']) && is_array($_SESSION['s']['module']['nav'])) {
119             foreach($_SESSION['s']['module']['nav'] as $nav) {
120                 $tmp_items = array();
121                 foreach($nav['items'] as $item) {
122                     $item['title'] = $app->lng($item['title']);
123                     $tmp_items[] = $item;
124                 }
125                 $nav['title'] = $app->lng($nav['title']);
126                 $nav['startpage'] = $nav['items'][0]['link'];
127                 $nav['items'] = $tmp_items;
128                 $nav_translated[] = $nav;
129             }
130         } else {
131             $nav_translated = null;
132         }
b1a6a5 133         $app->tpl->setLoop('nav_left', $nav_translated);
MC 134
532ae5 135     }
L 136
137 }
138
139 $app->tpl_defaults();
140 $app->tpl->pparse();
141
b1a6a5 142 ?>