2626dd47daad110c63a82c0560b134e2364eeac3
bernd webinterface => /webinterface

bernd authored 17 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd webinterface => /webinterface

bernd authored 17 years ago

16) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

17) if (! defined("TOP_INCLUDED")) {
18)     define("TOP_INCLUDED", true);
bernd webinterface => /webinterface

bernd authored 17 years ago

19) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

20)     require_once("inc/error.php");
21)     require_once("inc/debug.php");
22)     global $prefix, $section;
bernd Auch submenüs sollten gewic...

bernd authored 16 years ago

23) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

24)     $menuitem = array();
25)     $weighted_menuitem = array();
bernd Auch submenüs sollten gewic...

bernd authored 16 years ago

26) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

27)     $submenu = array();
bernd webinterface => /webinterface

bernd authored 17 years ago

28) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

29)     foreach (config('modules') as $module) {
30)         $menu = false;
31)         if (file_exists("modules/{$module}/menu.php")) {
32)             include("modules/{$module}/menu.php");
33)         }
34)         if ($menu === false) {
35)             #DEBUG("Modul {$module} hat keine Menüeinträge");
36)             continue;
37)         }
38)         // Menüeinträge spammen den debug-output zu
39)         //DEBUG("<h4>$module</h4>");
40)         //DEBUG($menu);
41)         // $menu["foo"]["file"] enthält den Link
42)         foreach (array_keys($menu) as $key) {
43)             $menu[$key]["file"] = $prefix."go/".$module."/".$menu[$key]["file"];
44)             $weight = $menu[$key]["weight"];
45)             if (isset($menu[$key]['submenu'])) {
46)                 if (isset($submenu[$menu[$key]['submenu']][$weight])) {
47)                     $submenu[$menu[$key]['submenu']][$weight] = array_merge($submenu[$menu[$key]['submenu']][$weight], array($key => $menu[$key]));
48)                 } else {
49)                     $submenu[$menu[$key]['submenu']][$weight] = array($key => $menu[$key]);
50)                 }
51)             } else {
52)                 if (array_key_exists($weight, $weighted_menuitem)) {
53)                     $weighted_menuitem[$weight] = array_merge($weighted_menuitem[$weight], array($key => $menu[$key]));
54)                 } else {
55)                     $weighted_menuitem[$weight] = array($key => $menu[$key]);
56)                 }
57)             }
58)         }
59)         $menuitem = array_merge($menuitem, $menu);
60)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

61) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

62)     ksort($weighted_menuitem);
63)     #DEBUG($weighted_menuitem);
bernd Usability: User sieht immer...

bernd authored 17 years ago

64) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

65)     foreach ($submenu as $weight => $data) {
66)         ksort($submenu[$weight]);
bernd submenu-items korrekt zuordnen

bernd authored 16 years ago

67)     }
68) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

69)     #DEBUG($submenu);
bernd submenu-items korrekt zuordnen

bernd authored 16 years ago

70) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

71)     // Verbiete das Laden in jeglichem Frameset
72)     header("X-FRAME-OPTIONS: DENY");
73)     header("Content-Type: ".config('mime_type'));
bernd webinterface => /webinterface

bernd authored 17 years ago

74) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

75)     if (!isset($html_header)) {
76)         $html_header = '';
77)     }
78) 
79)     function array_key_exists_r($needle, $haystack)
80)     {
81)         $result = array_key_exists($needle, $haystack);
82)         if ($result) {
83)             return $result;
84)         }
85)         foreach ($haystack as $v) {
86)             if (is_array($v)) {
87)                 $result = array_key_exists_r($needle, $v);
88)             }
89)             if ($result) {
90)                 return $result;
91)             }
bernd webinterface => /webinterface

bernd authored 17 years ago

92)         }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

93)         return $result;
94)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

95) 
bernd back-to-admin feature

bernd authored 16 years ago

96) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

97)     $menu = '';
98) 
99)     foreach ($weighted_menuitem as $key => $menuitem) {
100)         foreach ($menuitem as $key => $item) {
101)             if ($key == $section) {
102)                 $menu .= '<a href="'.$item['file'].'" class="menuitem active">'.$item['label'].'</a>'."\n";
103)             } else {
104)                 $menu .= '<a href="'.$item['file'].'" class="menuitem">'.$item['label'].'</a>'."\n";
105)             }
106)             if (isset($submenu[$key])) {
107)                 if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists_r($section, $submenu[$key]))) {
108)                     $menu .= "\n";
109)                     foreach ($submenu[$key] as $weight => $mysub) {
110)                         foreach ($mysub as $sec => $item) {
111)                             if ($sec == $section) {
112)                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem active">'.$item['label'].'</a>'."\n";
113)                             } else {
114)                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem">'.$item['label'].'</a>'."\n";
115)                             }
116)                         }
117)                     }
118)                     $menu .= "\n";
119)                 }
120)             }
121)         }
122)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

123) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

124)     $userinfo = '';
125) 
126)     $role = $_SESSION['role'];
127)     if ($role != ROLE_ANONYMOUS) {
128)         $userinfo .= '<p class="userinfo">Angemeldet als:<br />';
129)         if ($role & ROLE_SYSTEMUSER && isset($_SESSION['subuser'])) {
130)             $userinfo .= '<strong>'.$_SESSION['subuser'].'</strong>';
131)             $userinfo .= '<br />Mitbenutzer von '.$_SESSION['userinfo']['username'];
132)         } elseif ($role & ROLE_SYSTEMUSER) {
133)             $userinfo .= '<strong>'.$_SESSION['userinfo']['username'].'</strong>';
134)             $userinfo .= '<br />'.$_SESSION['userinfo']['name'];
135)             $userinfo .= '<br />(UID '.$_SESSION['userinfo']['uid'].(($role & ROLE_CUSTOMER) ? ', Kunde '.$_SESSION['customerinfo']['customerno'] : '').')';
136)         } elseif ($role & ROLE_CUSTOMER) {
137)             $userinfo .= '<strong>'.$_SESSION['customerinfo']['name'].'</strong>';
138)             $userinfo .= '<br />(Kunde '.$_SESSION['customerinfo']['customerno'].')';
139)         } elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
140)             $userinfo .= '<strong>'.$_SESSION['mailaccount'].'</strong><br />(Postfach von Benutzer <em>'.$_SESSION['userinfo']['username'].'</em>)';
141)         }
142)         $userinfo .= '</p>';
143)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

144) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

145)     if (isset($_SESSION['admin_user'])) {
146)         $userinfo .= '<p class="admininfo">';
147)         $userinfo .= '<a href="'.$prefix.'go/su/back_to_admin">Zurück zu »'.$_SESSION['admin_user'].'«</a>';
148)         $userinfo .= '</p>';
149)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

150) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

151)     $messages = get_messages();
bernd webinterface => /webinterface

bernd authored 17 years ago

152) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

153)     $BASE_PATH = $prefix;
154)     $THEME_PATH = $prefix."themes/".config('theme')."/";