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

Hanno Böck authored 1 year ago

5) Written 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) 
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 Neue MySQL-Verwaltung

Bernd Wurst authored 11 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) */
13) 
14) require_once('session/start.php');
15) require_once('inc/icons.php');
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

16) require_role([ROLE_SYSTEMUSER]);
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

17) 
18) global $prefix;
19) 
20) require_once('mysql.php');
21) 
22) if (isset($_GET['action']) && $_GET['action'] == 'permchange') {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

77) }
78) 
79) 
80) if (isset($_GET['action'])) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

94)       }
95)       break;
96)     case 'delete_user':
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

108)       }
109)       break;
110)     case 'change_pw':
111)       check_form_token('mysql_databases');
Bernd Wurst add password strength check...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

141)     $mysql_access = null;