9e72630c219258ccea648f94c5f5a4bd028db9c4
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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) 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.
12) */
bernd webinterface => /webinterface

bernd authored 17 years ago

13) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

14) if (!defined("TOP_INCLUDED")) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

15)     define("TOP_INCLUDED", true);
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

17)     require_once("inc/error.php");
18)     require_once("inc/debug.php");
19)     global $prefix, $section;
bernd Auch submenüs sollten gewic...

bernd authored 16 years ago

20) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

21)     $menuitem = [];
22)     $weighted_menuitem = [];
bernd Auch submenüs sollten gewic...

bernd authored 16 years ago

23) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

24)     $submenu = [];
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

26)     foreach (config('modules') as $module) {
Hanno Böck codingstyle fix: array syntax

Hanno Böck authored 2 years ago

27)         $menu = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

28)         if (file_exists("modules/{$module}/menu.php")) {
29)             include("modules/{$module}/menu.php");
30)         }
Bernd Wurst do not initialize $menu as...

Bernd Wurst authored 2 years ago

31)         if (empty($menu)) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

32)             #DEBUG("Modul {$module} hat keine Menüeinträge");
33)             continue;
34)         }
35)         // Menüeinträge spammen den debug-output zu
36)         //DEBUG("<h4>$module</h4>");
37)         //DEBUG($menu);
38)         // $menu["foo"]["file"] enthält den Link
39)         foreach (array_keys($menu) as $key) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

40)             $menu[$key]["file"] = $prefix . "go/" . $module . "/" . $menu[$key]["file"];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

41)             $weight = $menu[$key]["weight"];
42)             if (isset($menu[$key]['submenu'])) {
43)                 if (isset($submenu[$menu[$key]['submenu']][$weight])) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

44)                     $submenu[$menu[$key]['submenu']][$weight] = array_merge($submenu[$menu[$key]['submenu']][$weight], [$key => $menu[$key]]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

45)                 } else {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

46)                     $submenu[$menu[$key]['submenu']][$weight] = [$key => $menu[$key]];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

47)                 }
48)             } else {
49)                 if (array_key_exists($weight, $weighted_menuitem)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

50)                     $weighted_menuitem[$weight] = array_merge($weighted_menuitem[$weight], [$key => $menu[$key]]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

51)                 } else {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

52)                     $weighted_menuitem[$weight] = [$key => $menu[$key]];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

53)                 }
54)             }
55)         }
56)         $menuitem = array_merge($menuitem, $menu);
57)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

58) 
Bernd Wurst Schiebe Menüpunkte auf die...

Bernd Wurst authored 5 years ago

59)     foreach ($submenu as $key => $content) {
60)         $found = false;
61)         foreach ($weighted_menuitem as $weight => $data) {
62)             if (array_key_exists($key, $data)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

63)                 DEBUG("found requested submenu " . $key);
Bernd Wurst Schiebe Menüpunkte auf die...

Bernd Wurst authored 5 years ago

64)                 $found = true;
65)             }
66)         }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

67)         if (!$found) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

68)             DEBUG("Submenu " . $key . " requested but not present!");
Bernd Wurst Schiebe Menüpunkte auf die...

Bernd Wurst authored 5 years ago

69)             // Ein Submenü von einem nicht existierenden Hauptmenü wird angefordert
70)             // Menüpunkt muss als Hauptmenüpunkt geführt werden
71)             $weighted_menuitem = $weighted_menuitem + $content;
72)         }
73)     }
74) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

75)     ksort($weighted_menuitem);
76)     #DEBUG($weighted_menuitem);
bernd Usability: User sieht immer...

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

84)     // Verbiete das Laden in jeglichem Frameset
85)     header("X-FRAME-OPTIONS: DENY");
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

86)     header("Content-Type: " . config('mime_type'));
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Hanno authored 6 years ago

106)         return $result;
107)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

108) 
bernd back-to-admin feature

bernd authored 16 years ago

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

Hanno authored 6 years ago

110)     $menu = '';
111) 
112)     foreach ($weighted_menuitem as $key => $menuitem) {
113)         foreach ($menuitem as $key => $item) {
114)             if ($key == $section) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

115)                 $menu .= '<a href="' . $item['file'] . '" class="menuitem active">' . $item['label'] . '</a>' . "\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

116)             } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

117)                 $menu .= '<a href="' . $item['file'] . '" class="menuitem">' . $item['label'] . '</a>' . "\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

118)             }
119)             if (isset($submenu[$key])) {
120)                 if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists_r($section, $submenu[$key]))) {
121)                     $menu .= "\n";
122)                     foreach ($submenu[$key] as $weight => $mysub) {
123)                         foreach ($mysub as $sec => $item) {
124)                             if ($sec == $section) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

125)                                 $menu .= '<a href="' . $item['file'] . '" class="submenuitem menuitem active">' . $item['label'] . '</a>' . "\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

126)                             } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

127)                                 $menu .= '<a href="' . $item['file'] . '" class="submenuitem menuitem">' . $item['label'] . '</a>' . "\n";
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

128)                             }
129)                         }
130)                     }
131)                     $menu .= "\n";
132)                 }
133)             }
134)         }
135)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

137)     $userinfo = '';
138) 
139)     $role = $_SESSION['role'];
140)     if ($role != ROLE_ANONYMOUS) {
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 10 months ago

141)         $userinfo .= '<p class="userinfo">Angemeldet als:<br>';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

142)         if ($role & ROLE_SYSTEMUSER && isset($_SESSION['subuser'])) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

143)             $userinfo .= '<strong>' . $_SESSION['subuser'] . '</strong>';
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 10 months ago

144)             $userinfo .= '<br>Mitbenutzer von ' . $_SESSION['userinfo']['username'];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

145)         } elseif ($role & ROLE_SYSTEMUSER) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

146)             $userinfo .= '<strong>' . $_SESSION['userinfo']['username'] . '</strong>';
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 10 months ago

147)             $userinfo .= '<br>' . $_SESSION['userinfo']['name'];
148)             $userinfo .= '<br>(UID ' . $_SESSION['userinfo']['uid'] . (($role & ROLE_CUSTOMER) ? ', Kunde ' . $_SESSION['customerinfo']['customerno'] : '') . ')';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

149)         } elseif ($role & ROLE_CUSTOMER) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

150)             $userinfo .= '<strong>' . $_SESSION['customerinfo']['name'] . '</strong>';
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 10 months ago

151)             $userinfo .= '<br>(Kunde ' . $_SESSION['customerinfo']['customerno'] . ')';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

152)         } elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 10 months ago

153)             $userinfo .= '<strong>' . $_SESSION['mailaccount'] . '</strong><br>(Postfach von Benutzer <em>' . $_SESSION['userinfo']['username'] . '</em>)';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

154)         }
155)         $userinfo .= '</p>';
156)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

158)     if (isset($_SESSION['admin_user'])) {
159)         $userinfo .= '<p class="admininfo">';
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

160)         $userinfo .= '<a href="' . $prefix . 'go/su/back_to_admin">Zurück zu »' . $_SESSION['admin_user'] . '«</a>';
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

161)         $userinfo .= '</p>';
162)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Hanno authored 6 years ago

166)     $BASE_PATH = $prefix;
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

167)     $THEME_PATH = $prefix . "themes/" . config('theme') . "/";