2626dd47daad110c63a82c0560b134e2364eeac3
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

1) <?php
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 Zwischenversion

Bernd Wurst authored 7 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 Zwischenversion

Bernd Wurst authored 7 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) */
16) 
17) require_once('session/start.php');
18) 
19) require_once('invoice.php');
20) 
21) require_role(ROLE_CUSTOMER);
22) 
23) $section = $_SESSION['more_storage_section'];
24) 
25) title('Zusätzlichen Speicherplatz buchen');
26) 
27) 
28) check_form_token('more_storage');
29) 
30) $valid = false;
31) if (isset($_POST['more_storage_handle']) && isset($_SESSION['more_storage_handle']) &&
32)   $_POST['more_storage_handle'] == $_SESSION['more_storage_handle']) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

33)     $valid = true;
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

34) }
35) if (!$valid) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

36)     system_failure("Ungültige Session");
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

37) }
38) 
39) if (!isset($_SESSION['more_storage_items']) || !isset($_SESSION['more_storage_count'])) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

40)     system_failure('Keine Daten');
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

41) }
42) 
43) $items = $_SESSION['more_storage_items'];
44) $count = $_SESSION['more_storage_count'];
45) 
46) if (count($items) < 2) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

47)     system_failure("Ungültige Daten");
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

48) }
49) 
50) $stub = $items[0];
51) if ($stub['anzahl'] == 0) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

52)     $stub = null;
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

53) }
54) $regular = $items[1];
55) 
56) $clean_items = array();
57) 
58) if ($stub) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

59)     $i = array();
60)     $i['beschreibung'] = $stub['beschreibung'];
61)     $i['datum'] = $stub['startdatum'];
62)     $i['kuendigungsdatum'] = $stub['enddatum'];
63)     $i['betrag'] = $stub['betrag'];
64)     $i['brutto'] = $stub['brutto'];
65)     $i['monate'] = $stub['anzahl'];
66)     $i['anzahl'] = $stub['anzahl'];
67)     $clean_items[] = $i;
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

68) }
69) 
70) $i = array();
71) $i['beschreibung'] = $regular['beschreibung'];
72) $i['datum'] = $regular['startdatum'];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

73) $i['kuendigungsdatum'] = null;
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

74) $i['betrag'] = $regular['betrag'];
75) $i['brutto'] = $regular['brutto'];
76) $i['monate'] = $regular['anzahl'];
77) $i['anzahl'] = $regular['anzahl'];
78) $clean_items[] = $i;
79) 
80) save_more_storage($clean_items, $count);
81) 
82) if (have_module('systemuser')) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

83)     require('modules/systemuser/include/useraccounts.php');
84)     $useraccounts = list_useraccounts();
85)     if (isset($_POST['more_storage_user'])) {
86)         foreach ($useraccounts as $u) {
87)             if ($u['uid'] == $_POST['more_storage_user']) {
88)                 $account = get_account_details($u['uid']);
89)                 $account['quota'] = $account['quota'] + $count;
90)                 set_account_details($account);
91)             }
92)         }
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

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

Hanno authored 6 years ago

94)     unset($_SESSION['more_storage_user']);
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

95) }
96) 
97) 
98) unset($_SESSION['more_storage_handle']);
99) unset($_SESSION['more_storage_items']);
100) unset($_SESSION['more_storage_count']);
101) 
102) if (isset($_SESSION['more_storage_section'])) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

103)     DEBUG('Weiterleitung zu: '.$prefix.'go/'.str_replace('_', '/', $_SESSION['more_storage_section']));
104)     redirect($prefix.'go/'.str_replace('_', '/', $_SESSION['more_storage_section']));
Bernd Wurst Zwischenversion

Bernd Wurst authored 7 years ago

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

Hanno authored 6 years ago

106)     redirect($prefix.'go/invoice/current');