echo "<title>MySQL Web Interface</title>\n"; echo "</head>\n"; echo "<body>\n"; echo "<table width=100% height=100%><tr><td><center>\n"; echo "<h1>Wrong Password!</h1>\n"; echo "<a href='{$PHP_SELF}?action=logon'>Logon</a>\n"; echo "</center></td></tr></table>\n"; echo "</body>\n"; echo "</html>\n"; } else { header_html(); if ($action == "listDBs") { listDatabases(); } else { if ($action == "createDB") { createDatabase(); } else { if ($action == "dropDB") { dropDatabase(); } else { if ($action == "listTables") { listTables(); } else { if ($action == "createTable") { createTable(); } else { if ($action == "dropTable") { dropTable(); } else { if ($action == "viewSchema") { viewSchema();
{ global $dbName; mysqli_select_db($con, $dbName); } $topics = array("gaming", "movies", "music", "hardware", "comics", "other"); //create tables if they dont exist function createTables($con) { $userTable = "CREATE TABLE users\n\t\t\t(\n\t\t\t\tuserID INT NOT NULL AUTO_INCREMENT,\n\t\t\t\tPRIMARY KEY(userID),\n\t\t\t\tusername CHAR(40) NOT NULL UNIQUE,\n\t\t\t\tname CHAR(40) NOT NULL,\n\t\t\t\temail CHAR(100),\n\t\t\t\tpassword CHAR(50) NOT NULL\n\t\t\t)"; global $topics; foreach ($topics as $topic) { $topicTable = "CREATE TABLE " . $topic . "\n\t\t\t\t(\n\t\t\t\t\ttopicID INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tPRIMARY KEY(topicID),\n\t\t\t\t\tsubject CHAR(40) NOT NULL,\n\t\t\t\t\tuserID INT NOT NULL\n\t\t\t\t)"; mysqli_query($con, $topicTable); if (mysqli_error($con)) { echo "error: " . mysqli_error($con); } } if (!mysqli_query($con, $userTable)) { //echo "error: " . mysqli_error($con); } } function addGuest($con) { $query = "INSERT INTO users(username, name, email, password)\n\t\t\t\tVALUES('guest', 'guest', '*****@*****.**', 1234)"; mysqli_query($con, $query); } createDatabase($connection); connectToDB($connection); createTables($connection); addGuest($connection); mysqli_close($connection);
initializeDefaultVariables($database_driver); if (in_array('-V', $argv) || in_array('--verbose', $argv)) { displayEnvironmentVariables(); } $database = getDatabaseConfig($database_driver); $connectionParams = $database['database']; if ($argv[2] != 'none') { composerSetup(); composerInstall(); } require __DIR__ . '/autoload.php'; out('update permissions...'); updatePermissions($argv); createConfigFiles($database_driver); if (!in_array('--skip-createdb', $argv)) { createDatabase($connectionParams); } if (!in_array('--skip-initdb', $argv)) { $app = createApplication(); initializeDatabase($app); } out('EC-CUBE3 install finished successfully!', 'success'); $root_urlpath = getenv('ROOT_URLPATH'); if (PHP_VERSION_ID >= 50400 && empty($root_urlpath)) { out('PHP built-in web server to run applications, `php -S localhost:8080 -t html`', 'info'); out('Open your browser and access the http://localhost:8080/', 'info'); } exit(0); function displayHelp($argv) { echo <<<EOF
$sql = "INSERT INTO Sectors(sector) VALUES\n ('Recreational'),\n ('Educational'),\n ('Residential'),\n ('Business')\n "; $conn->exec($sql); } } catch (PDOException $e) { echo "<table><tr><th>SQL</th><td>{$sql}</td></tr><tr><th>Error</th><td>" . $e->getMessage() . "</td></tr><tr><th>Line</th><td>" . $e->getLine() . "</td></tr></table><br />"; } } // here's what you do if ($_SERVER["REQUEST_METHOD"] == "POST") { // login info $servername = $_SERVER["SERVER_NAME"]; $username = $_POST["username"]; $password = $_POST["password"]; $dbname = "citybdb"; // create database echo "Create Database:<br />"; createDatabase($servername, $username, $password, $dbname); // initialize database echo "Initialize Database:<br />"; initDatabase($servername, $username, $password, $dbname); } ?> <form action = "database.php" method = "post"> Username: <input type = "text" name = "username" value = "root"></input><br /> Password: <input type = "password" name = "password"></input><br /> <button>Create database</button> </form>
//var_dump($view); $ids = array(); if ($view) { foreach ($view->rows as $row) { if ($row->key != "_design") { $ids[] = $row->key[0]; } } } wrapResponse(null, $ids); }); F3::route('GET /@db/delete-all', function () { global $views; $dbName = F3::get('PARAMS["db"]'); deleteDatabase($dbName); createDatabase($dbName); updateViews($dbName, $dbName, $views); wrapResponse(array("success" => true), null); }); function wrapResponse($response, $doc) { if (isset($response)) { if (isset($response->error)) { $data = '{"error":"' . $response->error . '"}'; } else { $data = '{"success":true, "obj":' . json_encode($doc) . '}'; } } else { $data = json_encode($doc); } $cb = getparam('callback');
$resource->setFront(true); } else { $resource->setFront(false); } $resource->saveDOM(); } } } include "pages/_setcontents.php"; } else { if (isset($_GET['page']) && $_GET['page'] == "managegraphs" && isset($_GET['section']) && ($section = $data->getSectionById($_GET['section']))) { // SET CONTENTS if (isset($_POST['action'])) { // Create Database if ($_POST['action'] == 'createDatabase' && isset($_POST['document']) && ($document = $section->getDocumentById($_POST['document']))) { $dbh = createDatabase($document->getId()); parseGEXF($document->getFile(), $dbh); } // Delete Database if ($_POST['action'] == 'deleteDatabase' && isset($_POST['delete']) && $_POST['delete'] == "y" && isset($_POST['document']) && ($document = $section->getDocumentById($_POST['document']))) { if (!deleteDatabase($document->getId())) { echo "Deletion failed"; } } // Reset Database (formerly 'update') if ($_POST['action'] == 'updateDatabase' && isset($_POST['document']) && ($document = $section->getDocumentById($_POST['document']))) { $dbh = resetDatabase($document->getId()); parseGEXF($document->getFile(), $dbh); } // Change Attribute Viz Type if ($_POST['action'] == 'changeViz' && isset($_POST['document']) && ($document = $section->getDocumentById($_POST['document']))) {
<?php $config = (require __DIR__ . '/config.php'); foreach ($config['databases'] as $databaseKey => $databaseData) { if (isset($databaseData['create']) && $databaseData['create'] === false) { continue; } createDatabase($databaseData['host'], $databaseData['dbname']); checkDatabase($databaseData['host'], $databaseData['dbname']); if (isset($databaseData['isadmin']) && $databaseData['isadmin']) { createAdmin($databaseData['host'], $databaseData['user'], $databaseData['password']); } elseif (isset($databaseData['user'])) { // create user } } function createDatabase($host, $dbname) { $url = 'http://' . $host . '/' . $dbname; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_PUT, 1); curl_setopt($ch, CURLOPT_HEADER, 0); // führe die Aktion aus und gebe die Daten an den Browser weiter curl_exec($ch); // schließe den cURL-Handle und gebe die Systemresourcen frei curl_close($ch); } function createAdmin($host, $user, $password) { $url = $host . '/_config/admins/' . $user;
// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program. If not, see <http://www.gnu.org/licenses/>. | // +------------------------------------------------------------------------+ // +------------------------------------------------------------------------+ // | mysql.inc.php | // +------------------------------------------------------------------------+ $db = @mysql_connect($cfg['mysql_host'], $cfg['mysql_user'], $cfg['mysql_password'], $cfg['mysql_port'] == '' ? null : $cfg['mysql_port'], $cfg['mysql_socket'] == '' ? null : $cfg['mysql_socket']) or message(__FILE__, __LINE__, 'error', '[b]Failed to connect to MySQL server on:[/b][br]' . $cfg['mysql_host']); mysql_set_charset('utf8', $db); unset($cfg['mysql_user'], $cfg['mysql_password']); // select database @mysql_select_db($cfg['mysql_db']) or createDatabase(); // check database version loadServerSettings(); if ($cfg['database_version'] != NJB_DATABASE_VERSION) { updateDatabase(); } // +------------------------------------------------------------------------+ // | Load server settings | // +------------------------------------------------------------------------+ function loadServerSettings() { global $cfg, $db; $query = @mysql_query('SELECT name, value FROM server') or message(__FILE__, __LINE__, 'error', '[b]Failed to load MySQL server settings[/b][br]' . 'When creating the database manually[br]' . 'also import the [i]sql/ompd_' . NJB_DATABASE_VERSION . '.sql[/i] file manually.'); while ($server = mysql_fetch_assoc($query)) { $cfg[$server['name']] = $server['value']; }