master
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) 
Hanno Böck Send mails with phpmailer a...

Hanno Böck authored 1 month ago

17) use PHPMailer\PHPMailer\PHPMailer;
18) use PHPMailer\PHPMailer\Exception;
19) 
20) require_once('vendor/autoload.php');
21) 
schokokeks.org web services Ermögliche Socket-Angabe fü...

schokokeks.org web services authored 10 years ago

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

bernd authored 14 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 10 years ago

35)     }
36) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

39)         foreach ($config['modules'] as $mod) {
40)             if (in_array($mod, $_SESSION['restrict_modules'])) {
41)                 $modules[] = $mod;
42)             }
43)         }
44)         return $modules;
bernd Erlaube subusers, die nur Z...

bernd authored 13 years ago

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

Hanno authored 5 years ago

47)     if (array_key_exists($key, $config)) {
48)         return $config[$key];
49)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

51)     if ($localonly) {
52)         return null;
53)     }
schokokeks.org web services Ermögliche Socket-Angabe fü...

schokokeks.org web services authored 10 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 7 months ago

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

Hanno authored 5 years ago

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

bernd authored 14 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 6 years ago

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 6 years ago

82)     }
83)     return $have;
84) }
85) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

86) function get_server_by_id($id)
87) {
88)     $id = (int) $id;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 13 years ago

92) }
93) 
bernd Mehr config-optionen und co...

bernd authored 14 years ago

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

bernd authored 14 years ago

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

Hanno authored 5 years ago

97)     global $debugmode;
98)     if ($target == '') {
99)         $target = $_SERVER['REQUEST_URI'];
100)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

109)         }
110)     }
111)     die();
bernd add a function to handle re...

bernd authored 14 years ago

112) }
113) 
114) 
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

115) function my_server_id()
116) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

119)     $r = $result->fetch();
120)     DEBUG($r);
121)     return $r['server'];
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

122) }
123) 
124) 
125) function additional_servers()
126) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

130)     while ($s = $result->fetch()) {
131)         $servers[] = $s['server'];
132)     }
133)     DEBUG($servers);
134)     return $servers;
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

135) }
136) 
137) 
138) function server_names()
139) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

142)     while ($s = $result->fetch()) {
143)         $servers[$s['id']] = $s['hostname'];
144)     }
145)     DEBUG($servers);
146)     return $servers;
bernd Hilfsfunktionen bzgl. mehre...

bernd authored 14 years ago

147) }
148) 
149) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

153)         return null;
154)     }
bernd maybe_null behandelt jetzt...

bernd authored 14 years ago

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

Hanno authored 5 years ago

156)     if (strlen((string) $value) > 0) {
157)         return (string) $value;
158)     } else {
159)         return null;
160)     }
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

161) }
162) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

163) 
bernd Logger mit Logleveln

bernd authored 14 years ago

164) #define('LOG_ERR', 3);
165) #define('LOG_WARNING', 4);
166) #define('LOG_INFO', 6);
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

167) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

185)     $args = [":user" => $user,
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 1 month ago

186)         ":remote" => $_SERVER['REMOTE_ADDR'],
187)         ":scriptname" => $scriptname,
188)         ":scope" => $scope,
189)         ":message" => $message, ];
bernd Logging aktiviert

bernd authored 16 years ago

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

Hanno authored 5 years ago

191)     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

192) }
193) 
Hanno fix codingstyle

Hanno authored 5 years ago

194) function count_failed_logins()
195) {
Bernd Wurst disable brute force check w...

Bernd Wurst authored 5 years ago

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

Hanno Böck authored 2 years ago

200)     $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

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 5 years ago

203)     return $data['num'];
204) }
205) 
bernd Allow Header entries and AJAX

bernd authored 15 years ago

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

Hanno authored 5 years ago

208)     global $html_header;
209)     $html_header .= $arg;
bernd Allow Header entries and AJAX

bernd authored 15 years ago

210) }
bernd Logging aktiviert

bernd authored 16 years ago

211) 
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

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

Hanno authored 5 years ago

214)     global $title;
215)     $title = $arg;
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

216) }
217) 
218) function headline($arg)
219) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

220)     global $headline;
221)     $headline = $arg;
bernd Umstellung auf Theme-Suppor...

bernd authored 13 years ago

222) }
223) 
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

226)     global $output;
227)     $output .= $arg;
bernd webinterface => /webinterface

bernd authored 17 years ago

228) }
229) 
Bernd Wurst Funktion für Fußnoten einge...

Bernd Wurst authored 6 years ago

230) function footnote($explaination)
231) {
232)     global $footnotes;
233)     if (!isset($footnotes) || !is_array($footnotes)) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

240)         $footnotes[] = $explaination;
241)     }
242)     $fnid = array_search($explaination, $footnotes);
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 7 months ago

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

Bernd Wurst authored 6 years ago

244) }
bernd webinterface => /webinterface

bernd authored 17 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 7 years ago

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

Hanno Böck authored 7 months ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 7 years ago

250) }
bernd webinterface => /webinterface

bernd authored 17 years ago

251) 
252) 
253) function are_you_sure($query_string, $question)
254) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

255)     $query_string = encode_querystring($query_string);
256)     $token = random_string(20);
257)     $_SESSION['are_you_sure_token'] = $token;
258)     title('Sicherheitsabfrage');
259)     output("
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

bernd authored 16 years ago

261)     <div class=\"confirmation\">
262)       <div class=\"question\">{$question}</div>
263)       <p class=\"buttons\">
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 2 months ago

264)         <input type=\"hidden\" name=\"random_token\" value=\"{$token}\">
265)         <input type=\"submit\" name=\"really\" value=\"Ja\">
bernd Entities repariert

bernd authored 16 years ago

266)         &#160; &#160;
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 2 months ago

267)         <input type=\"submit\" name=\"not_really\" value=\"Nein\">
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

268)       </p>
269)     </div>");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

bernd authored 17 years ago

271) }
272) 
273) 
274) function user_is_sure()
275) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

279)             return true;
280)         } else {
281)             system_failure("Possible Cross-site-request-forgery detected!");
282)         }
283)     } elseif (isset($_POST['not_really'])) {
284)         return false;
285)     } else {
286)         return null;
287)     }
bernd webinterface => /webinterface

bernd authored 17 years ago

288) }
289) 
290) 
291) 
bernd XSRF-kram fixed

bernd authored 16 years ago

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

Hanno authored 5 years ago

294)     require_once("inc/debug.php");
295)     $sessid = session_id();
296)     if ($sessid == "") {
297)         DEBUG("Uh? Session not running? Wtf?");
298)         system_failure("Internal error!");
299)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

bernd authored 16 years ago

304) }
305) 
306) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 5 years ago

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

Hanno authored 5 years ago

310)         $formtoken = $_REQUEST['formtoken'];
311)     }
312)     $sessid = session_id();
313)     if ($sessid == "") {
314)         DEBUG("Uh? Session not running? Wtf?");
315)         system_failure("Internal error! (Session not running)");
316)     }
317) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

bernd authored 16 years ago

326) }
327) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

328) 
bernd Zeige Links auf dem Startse...

bernd authored 14 years ago

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

Hanno authored 5 years ago

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

bernd authored 14 years ago

332) }
333) 
334) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Hanno Böck authored 5 months ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 6 years ago

340)     }
341)     if (in_array($modname, $needed_modules)) {
342)         return;
343)     }
344)     $needed_modules[] = $modname;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 6 years ago

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 6 years ago

351)     if (file_exists($style)) {
Hanno Böck remove obsolete type attrib...

Hanno Böck authored 2 months ago

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

Bernd Wurst authored 6 years ago

353)     }
354) }
355) 
356) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

365)     foreach ($query as $item) {
366)         if ($item != '') {
367)             $split = explode('=', $item, 2);
368)             if (count($split) == 1) {
369)                 $new_query[] = $split[0];
370)             } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

372)             }
373)         }
374)     }
375)     $querystring = implode('&amp;', $new_query);
376)     if ($querystring) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

378)     }
379)     return $querystring;
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

bernd authored 16 years ago

381) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

382) 
Bernd Wurst Beta-Hinweis eingefügt

Bernd Wurst authored 6 years ago

383) function beta_notice()
384) {
385)     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>');
386) }
387) 
388) 
Bernd Wurst Google-Auth-Token setzen un...

Bernd Wurst authored 11 years ago

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

bernd authored 14 years ago

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

Hanno Böck authored 5 months ago

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

bernd authored 14 years ago

392) }
393) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

394) 
395) function internal_link($file, $label, $querystring = '', $attribs = '')
396) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

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

bernd authored 16 years ago

403) }
404) 
405) 
Hanno Böck Fix codingstyle

Hanno Böck authored 2 months ago

406) function html_form($form_id, $scriptname, $querystring, $content, $extraid = "")
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

408)     $querystring = encode_querystring($querystring);
409)     $ret = '';
Hanno Böck remaining autocomplete for...

Hanno Böck authored 2 months ago

410)     $ret .= '<form id="' . $form_id . $extraid . '" ';
411)     if ($scriptname . $querystring !== "") {
412)         $ret .= 'action="' . $scriptname . $querystring . '" ';
413)     }
414)     $ret .= 'method="post">' . "\n";
Hanno Böck Fix HTML errors and warnings

Hanno Böck authored 2 months ago

415)     $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

416)     $ret .= $content;
417)     $ret .= '</form>';
418)     return $ret;
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

419) }
420) 
421) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 7 months ago

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

bernd authored 16 years ago

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

Hanno authored 5 years ago

424)     require_once('inc/security.php');
425)     $ret = "<select name=\"{$name}\" id=\"{$name}\" size=\"1\" {$free} >\n";
426)     foreach ($options as $key => $value) {
427)         $selected = '';
428)         if ($default == $key) {
429)             $selected = ' selected="selected" ';
430)         }
Bernd Wurst accept integer parameters i...

Bernd Wurst authored 4 years ago

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

Hanno authored 5 years ago

433)         $ret .= "  <option value=\"{$key}\"{$selected}>{$value}</option>\n";
434)     }
435)     $ret .= '</select>';
436)     return $ret;
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

437) }
438) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

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

bernd authored 12 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Hanno authored 5 years ago

448)         }
449)     }
450)     return $modconfig;
bernd Index-Blöcke werden jetzt v...

bernd authored 12 years ago

451) }
Hanno Default exception handler w...

Hanno authored 5 years ago

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

Bernd Wurst authored 4 years ago

453) 
Hanno Böck Allow setting message type...

Hanno Böck authored 1 month ago

454) function send_mail($address, $subject, $body, $msgtype = "adminmail")
Bernd Wurst Funktion send_mail() global...

Bernd Wurst authored 4 years ago

455) {
456)     if (strstr($subject, "\n") !== false) {
457)         die("Zeilenumbruch im subject!");
458)     }
Hanno Böck Send mails with phpmailer a...

Hanno Böck authored 1 month ago

459)     if (config("smtp_server")) {
460)         // If we have smtp credentials we use phpmailer
461)         $mail = new PHPMailer(true);
462)         try {
463)             $mail->isSMTP();
464)             $mail->Host = config("smtp_server");
465)             $mail->SMTPAuth = true;
466)             $mail->Username = config("smtp_user");
467)             $mail->Password = config("smtp_pass");
468)             $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
469)             $mail->Port = 465;
470)             $mail->CharSet = 'UTF-8';
471)             $mail->Encoding = 'quoted-printable';
472)             $mail->setFrom(config("adminmail"), config('company_name') . " Web Administration");
473)             $mail->addAddress($address);
474)             if ($address !== config('adminmail')) {
475)                 $mail->addCC(config('adminmail'));
476)             }
477)             $mail->Subject = $subject;
478)             $mail->Body = $body;
479)             $mail->addCustomHeader("X-schokokeks-org-message", $msgtype);
480)             $mail->XMailer = ' ';
481)             $mail->send();
482)         } catch (Exception $e) {
483)             $adminmsg = "PHPMailer error:\n" . $mail->ErrorInfo . "\n\n";
484)             $adminmsg .= "SERVER info:\n" . print_r($_SERVER, 1);
485)             mail(config('adminmail'), $_SERVER['SERVER_NAME'] . ": error sending mail", $adminmsg);
486)             system_failure("Mail konnte nicht verschickt werden, die Administratoren werden informiert.");
487)         }
488)     } else {
489)         $header = [];
490)         $header["From"] = config('company_name') . " Web Administration <" . config('adminmail') . ">";
491)         if ($address !== config('adminmail')) {
492)             $header["Cc"] = config('adminmail');
493)         }
494)         $header["X-schokokeks-org-message"] = $msgtype;
495)         $header["Content-Type"] = "text/plain; charset=\"utf-8\"";
496)         $header["Content-Transfer-Encoding"] = "quoted-printable";
497)         $header["MIME-Version"] = "1.0";
498)         $subject = mb_encode_mimeheader($subject, "utf-8", "Q");
499)         $body = quoted_printable_encode($body);
500)         mail($address, $subject, $body, $header);
Hanno Böck Allow setting message type...

Hanno Böck authored 1 month ago

501)     }
Bernd Wurst Funktion send_mail() global...

Bernd Wurst authored 4 years ago

502) }
503) 
Hanno Default exception handler w...

Hanno authored 5 years ago

504) function handle_exception($e)
505) {
Bernd Wurst send exception via mail onl...

Bernd Wurst authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 5 years ago

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

Hanno Böck authored 5 months ago

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

Bernd Wurst authored 5 years ago

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

Hanno Böck authored 5 months ago

513)         $msg = "Exception caught:\n" . $e->getMessage() . "\n" . serialize($_POST) . "\n" . serialize($_SERVER);
Hanno Böck Always use send_mail() wrap...

Hanno Böck authored 1 month ago

514)         send_mail(config("adminmail"), "Exception on configinterface", $msg);
Bernd Wurst send exception via mail onl...

Bernd Wurst authored 5 years ago

515)     }