354c05a4ddd678c49bcbba458bffa7d13482139a
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 1 year 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 1 year 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) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

14) require_once('class/database.php');
bernd add a function to handle re...

bernd authored 14 years ago

15) require_once('inc/debug.php');
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

16) 
schokokeks.org web services Ermögliche Socket-Angabe fü...

schokokeks.org web services authored 10 years ago

17) function config($key, $localonly = false)
bernd Mehr config-optionen und co...

bernd authored 14 years ago

18) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

19)     global $config;
20) 
21)     if ($key == "modules") {
22)         // Stelle sicher, dass das "index"-Modul immer aktiv ist!
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

23)         if (!in_array("index", $config['modules'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

24)             $config['modules'][] = "index";
25)         }
26)         // Stelle sicher, dass das "about"-Modul immer aktiv ist!
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

27)         if (!in_array("about", $config['modules'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

28)             $config['modules'][] = "about";
29)         }
Bernd Wurst Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

30)     }
31) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

32)     if ($key == 'modules' && isset($_SESSION['restrict_modules'])) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

33)         $modules = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

34)         foreach ($config['modules'] as $mod) {
35)             if (in_array($mod, $_SESSION['restrict_modules'])) {
36)                 $modules[] = $mod;
37)             }
38)         }
39)         return $modules;
bernd Erlaube subusers, die nur Z...

bernd authored 13 years ago

40)     }
41) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

42)     if (array_key_exists($key, $config)) {
43)         return $config[$key];
44)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

46)     if ($localonly) {
47)         return null;
48)     }
schokokeks.org web services Ermögliche Socket-Angabe fü...

schokokeks.org web services authored 10 years ago

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

Hanno authored 5 years ago

50)     /* read configuration from database */
51)     $result = db_query("SELECT `key`, value FROM misc.config");
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

53)     while ($object = $result->fetch()) {
54)         if (!array_key_exists($object['key'], $config)) {
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

55)             $config[$object['key']] = $object['value'];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

56)         }
57)     }
58)     // Sonst wird das Passwort des webadmin-Users mit ausgegeben
59)     $debug_config = $config;
60)     unset($debug_config['db_pass']);
61)     DEBUG($debug_config);
62)     if (array_key_exists($key, $config)) {
63)         return $config[$key];
64)     } else {
65)         logger(LOG_ERR, "inc/base", "config", "Request to read nonexistant config option »{$key}«.");
66)     }
67)     return null;
bernd Mehr config-optionen und co...

bernd authored 14 years ago

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

Hanno authored 5 years ago

70) function have_role($role)
71) {
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 6 years ago

72)     $have = $_SESSION['role'] & $role;
73)     if ($have) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

74)         DEBUG("Current user has role " . $role);
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 6 years ago

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

Hanno Böck authored 6 months ago

76)         DEBUG("Current user does not have role " . $role);
Bernd Wurst Blende Aktionen aus, wenn d...

Bernd Wurst authored 6 years ago

77)     }
78)     return $have;
79) }
80) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

81) function get_server_by_id($id)
82) {
83)     $id = (int) $id;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

84)     $result = db_query("SELECT hostname FROM system.servers WHERE id=?", [$id]);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

85)     $ret = $result->fetch();
86)     return $ret['hostname'];
bernd Info-Seite über Mail-Login-...

bernd authored 13 years ago

87) }
88) 
bernd Mehr config-optionen und co...

bernd authored 14 years ago

89) 
bernd add a function to handle re...

bernd authored 14 years ago

90) function redirect($target)
91) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

92)     global $debugmode;
93)     if ($target == '') {
94)         $target = $_SERVER['REQUEST_URI'];
95)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

96)     if (!$debugmode) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

97)         header("Location: {$target}");
98)     } else {
99)         if (strpos($target, '?') === false) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

100)             print 'REDIRECT: ' . internal_link($target, $target);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

102)             [$file, $qs] = explode('?', $target, 2);
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

103)             print 'REDIRECT: ' . internal_link($file, $target, $qs);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

104)         }
105)     }
106)     die();
bernd add a function to handle re...

bernd authored 14 years ago

107) }
108) 
109) 
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

110) function my_server_id()
111) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

112)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

113)     $result = db_query("SELECT server FROM system.useraccounts WHERE uid=?", [$uid]);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

114)     $r = $result->fetch();
115)     DEBUG($r);
116)     return $r['server'];
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

117) }
118) 
119) 
120) function additional_servers()
121) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

122)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

123)     $result = db_query("SELECT server FROM system.user_server WHERE uid=?", [$uid]);
124)     $servers = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

125)     while ($s = $result->fetch()) {
126)         $servers[] = $s['server'];
127)     }
128)     DEBUG($servers);
129)     return $servers;
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

130) }
131) 
132) 
133) function server_names()
134) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

135)     $result = db_query("SELECT id, hostname FROM system.servers");
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

136)     $servers = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

137)     while ($s = $result->fetch()) {
138)         $servers[$s['id']] = $s['hostname'];
139)     }
140)     DEBUG($servers);
141)     return $servers;
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

142) }
143) 
144) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

145) function maybe_null($value)
146) {
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

147)     if (!$value) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

148)         return null;
149)     }
bernd maybe_null behandelt jetzt...

bernd authored 15 years ago

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

Hanno authored 5 years ago

151)     if (strlen((string) $value) > 0) {
152)         return (string) $value;
153)     } else {
154)         return null;
155)     }
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

156) }
157) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

158) 
bernd Logger mit Logleveln

bernd authored 14 years ago

159) #define('LOG_ERR', 3);
160) #define('LOG_WARNING', 4);
161) #define('LOG_INFO', 6);
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

162) 
bernd Logger mit Logleveln

bernd authored 14 years ago

163) function logger($severity, $scriptname, $scope, $message)
bernd Logging aktiviert

bernd authored 16 years ago

164) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

165)     if (config('logging') < $severity) {
166)         DEBUG("NOT LOGGING $scriptname:$scope:$message");
167)         return;
168)     }
169) 
170)     DEBUG("LOGGING $scriptname:$scope:$message");
171)     $user = null;
172)     if (array_key_exists("role", $_SESSION)) {
173)         if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
174)             $user = $_SESSION['userinfo']['username'];
175)         } elseif ($_SESSION['role'] & ROLE_CUSTOMER) {
176)             $user = $_SESSION['customerinfo']['customerno'];
177)         }
178)     }
179) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

180)     $args = [":user" => $user,
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

181)                 ":remote" => $_SERVER['REMOTE_ADDR'],
182)                 ":scriptname" => $scriptname,
183)                 ":scope" => $scope,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

184)                 ":message" => $message, ];
bernd Logging aktiviert

bernd authored 16 years ago

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

Hanno authored 5 years ago

186)     db_query("INSERT INTO misc.scriptlog (remote, user,scriptname,scope,message) VALUES (:remote, :user, :scriptname, :scope, :message)", $args);
bernd Logging aktiviert

bernd authored 16 years ago

187) }
188) 
Hanno fix codingstyle

Hanno authored 5 years ago

189) function count_failed_logins()
190) {
Bernd Wurst disable brute force check w...

Bernd Wurst authored 5 years ago

191)     if (config('logging') < LOG_WARNING) {
192)         DEBUG("logging is disabled, no brute force check possible");
193)         return;
194)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

195)     $result = db_query("SELECT count(*) AS num FROM misc.scriptlog WHERE user IS NULL AND scriptname='session/start' AND scope='login' AND message LIKE 'wrong user data%' AND remote=:remote AND `timestamp` > NOW() - INTERVAL 10 MINUTE", [":remote" => $_SERVER['REMOTE_ADDR']]);
Bernd Wurst add brute force protection...

Bernd Wurst authored 5 years ago

196)     $data = $result->fetch();
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

197)     DEBUG('seen ' . $data['num'] . ' failed logins from this address within 10 minutes');
Bernd Wurst add brute force protection...

Bernd Wurst authored 5 years ago

198)     return $data['num'];
199) }
200) 
bernd Allow Header entries and AJAX

bernd authored 15 years ago

201) function html_header($arg)
202) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

203)     global $html_header;
204)     $html_header .= $arg;
bernd Allow Header entries and AJAX

bernd authored 15 years ago

205) }
bernd Logging aktiviert

bernd authored 16 years ago

206) 
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

207) function title($arg)
208) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

209)     global $title;
210)     $title = $arg;
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

211) }
212) 
213) function headline($arg)
214) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

215)     global $headline;
216)     $headline = $arg;
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

217) }
218) 
bernd webinterface => /webinterface

bernd authored 17 years ago

219) function output($arg)
220) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

221)     global $output;
222)     $output .= $arg;
bernd webinterface => /webinterface

bernd authored 17 years ago

223) }
224) 
Bernd Wurst Funktion für Fußnoten einge...

Bernd Wurst authored 6 years ago

225) function footnote($explaination)
226) {
227)     global $footnotes;
228)     if (!isset($footnotes) || !is_array($footnotes)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

229)         $footnotes = [];
Bernd Wurst Funktion für Fußnoten einge...

Bernd Wurst authored 6 years ago

230)     }
231)     $fnid = array_search($explaination, $footnotes);
Bernd Wurst Bugfix für Fußnoten

Bernd Wurst authored 6 years ago

232)     DEBUG($footnotes);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

233)     if ($fnid === false) {
Bernd Wurst Bugfix für Fußnoten

Bernd Wurst authored 6 years ago

234)         DEBUG("Footnote »{$explaination}« is not in footnotes!");
Bernd Wurst Funktion für Fußnoten einge...

Bernd Wurst authored 6 years ago

235)         $footnotes[] = $explaination;
236)     }
237)     $fnid = array_search($explaination, $footnotes);
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

238)     return str_repeat('*', ($fnid + 1));
Bernd Wurst Funktion für Fußnoten einge...

Bernd Wurst authored 6 years ago

239) }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

241) function random_string($len)
Bernd Wurst random_string() verwendet u...

Bernd Wurst authored 7 years ago

242) {
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

243)     $s = str_replace('+', '.', base64_encode(random_bytes(ceil($len * 3 / 4))));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

244)     return substr($s, 0, $len);
Bernd Wurst random_string() verwendet u...

Bernd Wurst authored 7 years ago

245) }
bernd webinterface => /webinterface

bernd authored 17 years ago

246) 
247) 
248) function are_you_sure($query_string, $question)
249) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

250)     $query_string = encode_querystring($query_string);
251)     $token = random_string(20);
252)     $_SESSION['are_you_sure_token'] = $token;
253)     title('Sicherheitsabfrage');
254)     output("
bernd * alle internen Links sinnv...

bernd authored 15 years ago

255)     <form action=\"{$query_string}\" method=\"post\">
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

256)     <div class=\"confirmation\">
257)       <div class=\"question\">{$question}</div>
258)       <p class=\"buttons\">
259)         <input type=\"hidden\" name=\"random_token\" value=\"{$token}\" />
260)         <input type=\"submit\" name=\"really\" value=\"Ja\" />
bernd Entities repariert

bernd authored 16 years ago

261)         &#160; &#160;
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

262)         <input type=\"submit\" name=\"not_really\" value=\"Nein\" />
263)       </p>
264)     </div>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

265)     output("</form>\n");
bernd webinterface => /webinterface

bernd authored 17 years ago

266) }
267) 
268) 
269) function user_is_sure()
270) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

271)     if (isset($_POST['really'])) {
Hanno avoid undefined index

Hanno authored 5 years ago

272)         if (array_key_exists('random_token', $_POST) &&
273)             ($_POST['random_token'] == $_SESSION['are_you_sure_token'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

274)             return true;
275)         } else {
276)             system_failure("Possible Cross-site-request-forgery detected!");
277)         }
278)     } elseif (isset($_POST['not_really'])) {
279)         return false;
280)     } else {
281)         return null;
282)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

283) }
284) 
285) 
286) 
bernd XSRF-kram fixed

bernd authored 16 years ago

287) function generate_form_token($form_id)
288) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

289)     require_once("inc/debug.php");
290)     $sessid = session_id();
291)     if ($sessid == "") {
292)         DEBUG("Uh? Session not running? Wtf?");
293)         system_failure("Internal error!");
294)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

295)     if (!isset($_SESSION['session_token'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

296)         $_SESSION['session_token'] = random_string(10);
297)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

298)     return hash('sha256', $sessid . $form_id . $_SESSION['session_token']);
bernd XSRF-kram fixed

bernd authored 16 years ago

299) }
300) 
301) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

302) function check_form_token($form_id, $formtoken = null)
bernd XSRF-kram fixed

bernd authored 16 years ago

303) {
Hanno Böck Warnung wg. undefined index...

Hanno Böck authored 5 years ago

304)     if ($formtoken == null && isset($_REQUEST['formtoken'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

305)         $formtoken = $_REQUEST['formtoken'];
306)     }
307)     $sessid = session_id();
308)     if ($sessid == "") {
309)         DEBUG("Uh? Session not running? Wtf?");
310)         system_failure("Internal error! (Session not running)");
311)     }
312) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

313)     if (!isset($_SESSION['session_token'])) {
Bernd Wurst Erzeuge Session-Token, fall...

Bernd Wurst authored 5 years ago

314)         $_SESSION['session_token'] = random_string(10);
315)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

316)     $correct_formtoken = hash('sha256', $sessid . $form_id . $_SESSION['session_token']);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

318)     if (!($formtoken == $correct_formtoken)) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

319)         system_failure("Possible cross-site-request-forgery!");
320)     }
bernd XSRF-kram fixed

bernd authored 16 years ago

321) }
322) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

323) 
bernd Zeige Links auf dem Startse...

bernd authored 15 years ago

324) function have_module($modname)
325) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

326)     return in_array($modname, config('modules'));
bernd Zeige Links auf dem Startse...

bernd authored 15 years ago

327) }
328) 
329) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

330) function use_module($modname)
Bernd Wurst Rudimentäre Adressauswahl/D...

Bernd Wurst authored 6 years ago

331) {
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

332)     global $prefix, $needed_modules;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

333)     if (!isset($needed_modules)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

334)         $needed_modules = [];
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

335)     }
336)     if (in_array($modname, $needed_modules)) {
337)         return;
338)     }
339)     $needed_modules[] = $modname;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 6 months ago

340)     if (!have_module($modname)) {
Bernd Wurst Rudimentäre Adressauswahl/D...

Bernd Wurst authored 6 years ago

341)         system_failure("Soll nicht verfügbares Modul laden!");
342)     }
343)     /* setup module include path */
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

344)     ini_set('include_path', ini_get('include_path') . ':./modules/' . $modname . '/include:');
345)     $style = 'modules/' . $modname . '/style.css';
Bernd Wurst Rudimentäre Adressauswahl/D...

Bernd Wurst authored 6 years ago

346)     if (file_exists($style)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

347)         html_header('<link rel="stylesheet" href="' . $prefix . $style . '" type="text/css" />' . "\n");
Bernd Wurst Rudimentäre Adressauswahl/D...

Bernd Wurst authored 6 years ago

348)     }
349) }
350) 
351) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

352) function encode_querystring($querystring)
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

353) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

354)     global $debugmode;
355)     if ($debugmode) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

356)         $querystring = 'debug&' . $querystring;
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

357)     }
358)     $query = explode('&', $querystring);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

359)     $new_query = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

360)     foreach ($query as $item) {
361)         if ($item != '') {
362)             $split = explode('=', $item, 2);
363)             if (count($split) == 1) {
364)                 $new_query[] = $split[0];
365)             } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

366)                 $new_query[] = $split[0] . '=' . urlencode($split[1]);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

367)             }
368)         }
369)     }
370)     $querystring = implode('&amp;', $new_query);
371)     if ($querystring) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

372)         $querystring = '?' . $querystring;
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

373)     }
374)     return $querystring;
bernd * alle internen Links sinnv...

bernd authored 15 years ago

375) }
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

376) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

377) 
Bernd Wurst Beta-Hinweis eingefügt

Bernd Wurst authored 6 years ago

378) function beta_notice()
379) {
380)     output('<div class="beta"><h4>Achtung: Testbetrieb</h4><p>Diese Funktion ist im Testbetrieb. Bei Fehlfunktionen, Unklarheiten oder Verbesserungsvorschlägen bitten wir um kurze Nachricht an <a href="mailto:root@schokokeks.org">root@schokokeks.org</a></p></div>');
381) }
382) 
383) 
Bernd Wurst Google-Auth-Token setzen un...

Bernd Wurst authored 11 years ago

384) function addnew($file, $label, $querystring = '', $attribs = '')
bernd addnew() eingeführt

bernd authored 14 years ago

385) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

386)     output('<p class="addnew">' . internal_link($file, $label, $querystring, $attribs) . '</p>');
bernd addnew() eingeführt

bernd authored 14 years ago

387) }
388) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

389) 
390) function internal_link($file, $label, $querystring = '', $attribs = '')
391) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

392)     global $prefix;
393)     if (strpos($file, '/') === 0) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

394)         $file = $prefix . substr($file, 1);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

395)     }
396)     $querystring = encode_querystring($querystring);
397)     return "<a href=\"{$file}{$querystring}\" {$attribs} >{$label}</a>";
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

398) }
399) 
400) 
401) function html_form($form_id, $scriptname, $querystring, $content)
402) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

403)     $querystring = encode_querystring($querystring);
404)     $ret = '';
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

405)     $ret .= '<form id="' . $form_id . '" action="' . $scriptname . $querystring . '" method="post">' . "\n";
406)     $ret .= '<p style="display: none;"><input type="hidden" name="formtoken" value="' . generate_form_token($form_id) . '" /></p>' . "\n";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

407)     $ret .= $content;
408)     $ret .= '</form>';
409)     return $ret;
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

410) }
411) 
412) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 8 months ago

413) function html_select($name, $options, $default = '', $free = '')
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

414) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

415)     require_once('inc/security.php');
416)     $ret = "<select name=\"{$name}\" id=\"{$name}\" size=\"1\" {$free} >\n";
417)     foreach ($options as $key => $value) {
418)         $selected = '';
419)         if ($default == $key) {
420)             $selected = ' selected="selected" ';
421)         }
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

422)         $key = filter_output_html($key);
423)         $value = filter_output_html($value);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

424)         $ret .= "  <option value=\"{$key}\"{$selected}>{$value}</option>\n";
425)     }
426)     $ret .= '</select>';
427)     return $ret;
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

428) }
429) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

431) function get_modules_info()
bernd Index-Blöcke werden jetzt v...

bernd authored 12 years ago

432) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

433)     $modules = config('modules');
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

434)     $modconfig = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

435)     foreach ($modules as $name) {
436)         $modconfig[$name] = null;
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

437)         if (file_exists('modules/' . $name . '/module.info')) {
438)             $modconfig[$name] = parse_ini_file('modules/' . $name . '/module.info');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

439)         }
440)     }
441)     return $modconfig;
bernd Index-Blöcke werden jetzt v...

bernd authored 12 years ago

442) }
Hanno Default exception handler w...

Hanno authored 5 years ago

443) 
Bernd Wurst Funktion send_mail() global...

Bernd Wurst authored 4 years ago

444) 
445) function send_mail($address, $subject, $body)
446) {
447)     if (strstr($subject, "\n") !== false) {
448)         die("Zeilenumbruch im subject!");
449)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

450)     $header = "From: " . config('company_name') . " Web Administration <" . config('adminmail') . ">\r\nCc: " . config('adminmail') . "\r\nContent-Type: text/plain; charset=\"utf-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\nX-schokokeks-org-message: webinterface";
Hanno Böck Use mb_encode_mimeheader in...

Hanno Böck authored 3 years ago

451)     $subject = mb_encode_mimeheader($subject, "utf-8", "Q");
Bernd Wurst fix encoding mail headers a...

Bernd Wurst authored 4 years ago

452)     $body = quoted_printable_encode($body);
Bernd Wurst Funktion send_mail() global...

Bernd Wurst authored 4 years ago

453)     mail($address, $subject, $body, $header);
454) }
455) 
Hanno Default exception handler w...

Hanno authored 5 years ago

456) function handle_exception($e)
457) {
Bernd Wurst send exception via mail onl...

Bernd Wurst authored 5 years ago

458)     if (config('enable_debug')) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

459)         print_r($e->getMessage() . "<br>");
Bernd Wurst print stack trace with exce...

Bernd Wurst authored 5 years ago

460)         debug_print_backtrace();
461)         echo("<br>");
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

462)         print_r(serialize($_POST) . "<br>");
Bernd Wurst send exception via mail onl...

Bernd Wurst authored 5 years ago

463)         print_r(serialize($_SERVER));
464)     } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

465)         $msg = "Exception caught:\n" . $e->getMessage() . "\n" . serialize($_POST) . "\n" . serialize($_SERVER);
Bernd Wurst send exception via mail onl...

Bernd Wurst authored 5 years ago

466)         mail(config("adminmail"), "Exception on configinterface", $msg);
467)     }