48bfd0bb22aeb6e2795cd3368cb424255c7075c8
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 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 Neue MySQL-Verwaltung

Bernd Wurst authored 11 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 Neue MySQL-Verwaltung

Bernd Wurst authored 11 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) require_once('inc/icons.php');
19) require_role(array(ROLE_SYSTEMUSER));
20) 
21) global $prefix;
22) 
23) require_once('mysql.php');
24) 
25) if (isset($_GET['action']) && $_GET['action'] == 'permchange') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

26)     check_form_token('mysql_permchange');
27)     set_mysql_access($_GET['db'], $_GET['user'], ($_GET['access'] == 1));
28)     redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

29) }
30) 
31) if (isset($_GET['action']) && $_GET['action'] == 'newdb') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

32)     check_form_token('mysql_newdb');
33)     $dbname = $_POST['newdb'];
34)     $desc = $_POST['description'];
35)     $server = null;
36)     if (isset($_POST['server'])) {
37)         $server = $_POST['server'];
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

39)     create_mysql_database($dbname, $desc, $server);
40)     if (isset($_POST['access'])) {
41)         foreach ($_POST['access'] as $user) {
42)             set_mysql_access($dbname, $user, true);
43)         }
44)     }
45)     redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

46) }
47) 
48) if (isset($_GET['action']) && $_GET['action'] == 'newuser') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

49)     check_form_token('mysql_newuser');
50)     $username = $_POST['newuser'];
51)     $desc = $_POST['description'];
52)     $password = $_POST['newpass'];
Bernd Wurst add password strength check...

Bernd Wurst authored 5 years ago

53)     $check = strong_password($password);
54)     if ($check !== true) {
55)         system_failure('Das Passwort ist nicht sicher genug.');
56)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

57)     create_mysql_account($username, $desc);
58)     set_mysql_password($username, $password);
59)     if (isset($_POST['access'])) {
60)         foreach ($_POST['access'] as $dbname) {
61)             set_mysql_access($dbname, $username, true);
62)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

64)     redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

65) }
66) 
67) if (isset($_GET['action']) && $_GET['action'] == 'description') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

68)     check_form_token('mysql_description');
69)     if (isset($_GET['db'])) {
70)         $db = $_GET['db'];
71)         $description = $_POST['description'];
72)         set_database_description($db, $description);
73)     }
74)     if (isset($_GET['username'])) {
75)         $user = $_GET['username'];
76)         $description = $_POST['description'];
77)         set_dbuser_description($user, $description);
78)     }
79)     redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

80) }
81) 
82) 
83) if (isset($_GET['action'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

84)     switch ($_GET['action']) {
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

85)     case 'delete_db':
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

86)       if (! has_mysql_database($_GET['db'])) {
87)           system_failure('Ungültige Datenbank');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

89)       $sure = user_is_sure();
90)       if ($sure === null) {
91)           are_you_sure("action=delete_db&db={$_GET['db']}", "Möchten Sie die Datenbank »{$_GET['db']}« wirklich löschen?");
92)       } elseif ($sure === true) {
93)           delete_mysql_database($_GET['db']);
94)           redirect('overview');
95)       } elseif ($sure === false) {
96)           redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

97)       }
98)       break;
99)     case 'delete_user':
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

100)       if (! has_mysql_user($_GET['user'])) {
101)           system_failure('Ungültiger Benutzer');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

103)       $sure = user_is_sure();
104)       if ($sure === null) {
105)           are_you_sure("action=delete_user&user={$_GET['user']}", "Möchten Sie den Benutzer »{$_GET['user']}« wirklich löschen?");
106)       } elseif ($sure === true) {
107)           delete_mysql_account($_GET['user']);
108)           redirect('overview');
109)       } elseif ($sure === false) {
110)           redirect('overview');
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

111)       }
112)       break;
113)     case 'change_pw':
114)       check_form_token('mysql_databases');
Bernd Wurst add password strength check...

Bernd Wurst authored 5 years ago

115)       $check = strong_password($_POST['newpass']);
116)       if ($check !== true) {
117)           system_failure('Das Passwort ist nicht sicher genug.');
118)       }
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

119)       set_mysql_password($_POST['mysql_username'], $_POST['newpass']);
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

120)       redirect('overview');
121)       break;
122)     default:
123)       system_failure("Diese Funktion scheint noch nicht eingebaut zu sein!");
124)   }
125) }
126) 
127) $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
128) $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
129) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

130) if (isset($_POST['accesseditor'])) {
131)     check_form_token('mysql_databases');
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

133)     foreach ($dbs as $db) {
134)         $db = $db['name'];
135)         foreach ($users as $user) {
136)             $user = $user['username'];
137)             if (! isset($_POST['access'][$db])) {
138)                 set_mysql_access($db, $user, false);
139)             } else {
140)                 set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
141)             }
142)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

144)     $mysql_access = null;