da2eaa6d6f8367bf912f8f72272dedd012cbf3e2
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 5 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 5 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 5 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 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 17 years ago

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

Hanno authored 5 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) 
Bernd Wurst Schiebe Menüpunkte auf die...

Bernd Wurst authored 5 years ago

62)     foreach ($submenu as $key => $content) {
63)         $found = false;
64)         foreach ($weighted_menuitem as $weight => $data) {
65)             if (array_key_exists($key, $data)) {
66)                 DEBUG("found requested submenu ".$key);
67)                 $found = true;
68)             }
69)         }
70)         if (! $found) {
71)             DEBUG("Submenu ".$key." requested but not present!");
72)             // Ein Submenü von einem nicht existierenden Hauptmenü wird angefordert
73)             // Menüpunkt muss als Hauptmenüpunkt geführt werden
74)             $weighted_menuitem = $weighted_menuitem + $content;
75)         }
76)     }
77) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

78)     ksort($weighted_menuitem);
79)     #DEBUG($weighted_menuitem);
bernd Usability: User sieht immer...

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

83)     }
84) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 17 years ago

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

Hanno authored 5 years ago

91)     if (!isset($html_header)) {
92)         $html_header = '';
93)     }
94) 
95)     function array_key_exists_r($needle, $haystack)
96)     {
97)         $result = array_key_exists($needle, $haystack);
98)         if ($result) {
99)             return $result;
100)         }
101)         foreach ($haystack as $v) {
102)             if (is_array($v)) {
103)                 $result = array_key_exists_r($needle, $v);
104)             }
105)             if ($result) {
106)                 return $result;
107)             }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

109)         return $result;
110)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

111) 
bernd back-to-admin feature

bernd authored 15 years ago

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

Hanno authored 5 years ago

113)     $menu = '';
114) 
115)     foreach ($weighted_menuitem as $key => $menuitem) {
116)         foreach ($menuitem as $key => $item) {
117)             if ($key == $section) {
118)                 $menu .= '<a href="'.$item['file'].'" class="menuitem active">'.$item['label'].'</a>'."\n";
119)             } else {
120)                 $menu .= '<a href="'.$item['file'].'" class="menuitem">'.$item['label'].'</a>'."\n";
121)             }
122)             if (isset($submenu[$key])) {
123)                 if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists_r($section, $submenu[$key]))) {
124)                     $menu .= "\n";
125)                     foreach ($submenu[$key] as $weight => $mysub) {
126)                         foreach ($mysub as $sec => $item) {
127)                             if ($sec == $section) {
128)                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem active">'.$item['label'].'</a>'."\n";
129)                             } else {
130)                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem">'.$item['label'].'</a>'."\n";
131)                             }
132)                         }
133)                     }
134)                     $menu .= "\n";
135)                 }
136)             }
137)         }
138)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

140)     $userinfo = '';
141) 
142)     $role = $_SESSION['role'];
143)     if ($role != ROLE_ANONYMOUS) {
144)         $userinfo .= '<p class="userinfo">Angemeldet als:<br />';
145)         if ($role & ROLE_SYSTEMUSER && isset($_SESSION['subuser'])) {
146)             $userinfo .= '<strong>'.$_SESSION['subuser'].'</strong>';
147)             $userinfo .= '<br />Mitbenutzer von '.$_SESSION['userinfo']['username'];
148)         } elseif ($role & ROLE_SYSTEMUSER) {
149)             $userinfo .= '<strong>'.$_SESSION['userinfo']['username'].'</strong>';
150)             $userinfo .= '<br />'.$_SESSION['userinfo']['name'];
151)             $userinfo .= '<br />(UID '.$_SESSION['userinfo']['uid'].(($role & ROLE_CUSTOMER) ? ', Kunde '.$_SESSION['customerinfo']['customerno'] : '').')';
152)         } elseif ($role & ROLE_CUSTOMER) {
153)             $userinfo .= '<strong>'.$_SESSION['customerinfo']['name'].'</strong>';
154)             $userinfo .= '<br />(Kunde '.$_SESSION['customerinfo']['customerno'].')';
155)         } elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
156)             $userinfo .= '<strong>'.$_SESSION['mailaccount'].'</strong><br />(Postfach von Benutzer <em>'.$_SESSION['userinfo']['username'].'</em>)';
157)         }
158)         $userinfo .= '</p>';
159)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

161)     if (isset($_SESSION['admin_user'])) {
162)         $userinfo .= '<p class="admininfo">';
163)         $userinfo .= '<a href="'.$prefix.'go/su/back_to_admin">Zurück zu »'.$_SESSION['admin_user'].'«</a>';
164)         $userinfo .= '</p>';
165)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

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

bernd authored 17 years ago

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

Hanno authored 5 years ago

169)     $BASE_PATH = $prefix;
170)     $THEME_PATH = $prefix."themes/".config('theme')."/";