git.schokokeks.org
Repositories
Help
Report an Issue
webinterface.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
354c05a
Branches
Tags
master
ticket
webinterface.git
modules
mysql
newdb.php
Spaces between string concat (.) operator, new PER codingstyle
Hanno Böck
commited
354c05a
at 2023-10-31 17:49:30
newdb.php
Blame
History
Raw
<?php /* This file belongs to the Webinterface of schokokeks.org Hosting Written by schokokeks.org Hosting, namely Bernd Wurst <bernd@schokokeks.org> Hanno Böck <hanno@schokokeks.org> This code is published under a 0BSD license. 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. */ require_once('session/start.php'); require_once('inc/icons.php'); require_role([ROLE_SYSTEMUSER]); global $prefix; require_once('mysql.php'); $dbs = get_mysql_databases($_SESSION['userinfo']['uid']); $users = get_mysql_accounts($_SESSION['userinfo']['uid']); $username = $_SESSION['userinfo']['username']; $section = 'mysql_overview'; title('Neue MySQL-Datenbank'); $dbnames = []; foreach ($dbs as $db) { $dbnames[] = $db['name']; } $suggestion = $username . '_1'; $count = 2; while (in_array($suggestion, $dbnames)) { $suggestion = $username . '_' . $count; $count++; } $hint = 'Der Datenbankname muss mit <strong>' . $username . '_</strong> beginnen.'; $form = '<h4>Name der neuen Datenbank</h4> <input type="text" name="newdb" value="' . $suggestion . '" /> <p>Bitte nur Kleinbuchstaben, Zahlen und Unterstrich verwenden. ' . $hint . '</p> <p><label for="description">Optionale Beschreibung dieser Datenbank:</label> <input type="text" name="description" id="description" /></p> '; if (count(additional_servers()) > 0) { $form .= '<h4>Server</h4>'; $form .= '<p>Auf welchem Server soll diese Datenbank eingerichtet werden?</p>'; $available_servers = additional_servers(); $available_servers[] = my_server_id(); $available_servers = array_unique($available_servers); $selectable_servers = []; $all_servers = server_names(); foreach ($all_servers as $id => $fqdn) { if (in_array($id, $available_servers)) { $selectable_servers[$id] = $fqdn; } } $form .= html_select('server', $selectable_servers, my_server_id()); $form .= '<p>Alle Benutzer die auf diese Datenbank zugreifen dürfen, werden automatisch auf dem passenden Server eingerichtet</p>'; } if (count($users) > 0) { $form .= '<h4>Berechtigungen</h4>'; $form .= '<p>Welche der bisher vorhandenen Datenbank-Benutzer dürfen auf diese Datenbank zugreifen?</p>'; foreach ($users as $user) { $form .= '<p><input type="checkbox" id="access_' . $user['username'] . '" name="access[]" value="' . $user['username'] . '" /> <label for="access_' . $user['username'] . '">' . $user['username'] . '</label></p>'; } } $form .= '<p><input type="submit" name="submit" value="Speichern"/><p>'; output(html_form('mysql_newdb', 'save', 'action=newdb', $form));