d0416d23b70a701e7c12b884bd947d4c670cc50e
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'];
53)     create_mysql_account($username, $desc);
54)     set_mysql_password($username, $password);
55)     if (isset($_POST['access'])) {
56)         foreach ($_POST['access'] as $dbname) {
57)             set_mysql_access($dbname, $username, true);
58)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 11 years ago

107)       }
108)       break;
109)     case 'change_pw':
110)       check_form_token('mysql_databases');
Bernd Wurst Passwort-Erzeugung auch bei...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

125)     foreach ($dbs as $db) {
126)         $db = $db['name'];
127)         foreach ($users as $user) {
128)             $user = $user['username'];
129)             if (! isset($_POST['access'][$db])) {
130)                 set_mysql_access($db, $user, false);
131)             } else {
132)                 set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
133)             }
134)         }
Bernd Wurst Neue MySQL-Verwaltung

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

136)     $mysql_access = null;