1d70512abSGreg Roach<?php 2d70512abSGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg Roach 5d70512abSGreg Roachuse Fisharebest\Webtrees\I18N; 6dc270d8cSGreg Roachuse Illuminate\Support\Collection; 7dc270d8cSGreg Roach 8dc270d8cSGreg Roach/** 9dc270d8cSGreg Roach * @var string $dbhost 10dc270d8cSGreg Roach * @var string $dbname 11dc270d8cSGreg Roach * @var string $dbpass 12dc270d8cSGreg Roach * @var string $dbport 13dc270d8cSGreg Roach * @var string $dbtype 14dc270d8cSGreg Roach * @var string $dbuser 1536779af1SGreg Roach * @var Collection<int,string> $errors 16dc270d8cSGreg Roach * @var string $lang 17dc270d8cSGreg Roach * @var string $tblpfx 1836779af1SGreg Roach * @var Collection<int,string> $warnings 19dc270d8cSGreg Roach * @var string $wtemail 20dc270d8cSGreg Roach * @var string $wtname 21dc270d8cSGreg Roach * @var string $wtpass 22dc270d8cSGreg Roach * @var string $wtuser 23dc270d8cSGreg Roach */ 24d70512abSGreg Roach 25d70512abSGreg Roach?> 26982d76d1SGreg Roach 2783615acfSGreg Roach<form method="post" autocomplete="off"> 28982d76d1SGreg Roach <input name="lang" type="hidden" value="<?= e($lang) ?>"> 29982d76d1SGreg Roach <input name="dbtype" type="hidden" value="<?= e($dbtype) ?>"> 30982d76d1SGreg Roach <input name="wtname" type="hidden" value="<?= e($wtname) ?>"> 31982d76d1SGreg Roach <input name="wtuser" type="hidden" value="<?= e($wtuser) ?>"> 32982d76d1SGreg Roach <input name="wtpass" type="hidden" value="<?= e($wtpass) ?>"> 33982d76d1SGreg Roach <input name="wtemail" type="hidden" value="<?= e($wtemail) ?>"> 34982d76d1SGreg Roach 35982d76d1SGreg Roach <h2> 366b4dc746SGreg Roach <?= I18N::translate('Database connection') ?> – MySQL / MariaDB / Percona 37982d76d1SGreg Roach </h2> 38982d76d1SGreg Roach 39982d76d1SGreg Roach <?php foreach ($errors as $error) : ?> 40982d76d1SGreg Roach <p class="alert alert-danger"><?= $error ?></p> 41982d76d1SGreg Roach <?php endforeach ?> 42982d76d1SGreg Roach 43982d76d1SGreg Roach <?php foreach ($warnings as $warning) : ?> 44982d76d1SGreg Roach <p class="alert alert-warning"><?= $warning ?></p> 45982d76d1SGreg Roach <?php endforeach ?> 46982d76d1SGreg Roach 479e3c2cf9SGreg Roach <div class="row mb-3"> 48*f24a8589SGreg Roach <div class="col"> 49*f24a8589SGreg Roach <?= I18N::translate('Connection type') ?> 50982d76d1SGreg Roach </div> 51982d76d1SGreg Roach </div> 52982d76d1SGreg Roach 539e3c2cf9SGreg Roach <div class="row mb-3"> 54*f24a8589SGreg Roach <div class="col-sm-3"> 55*f24a8589SGreg Roach <div class="form-check"> 56*f24a8589SGreg Roach <input type="radio" name="mysql-type" id="mysql-type-local" class="form-check-input" <?= ($dbhost === '' || $dbhost === 'localhost') ? 'checked="checked"' : '' ?>"> 57*f24a8589SGreg Roach <label class="form-check-label" for="mysql-type-local"> 58*f24a8589SGreg Roach <?= I18N::translate('local') ?> 59982d76d1SGreg Roach </label> 60*f24a8589SGreg Roach </div> 61*f24a8589SGreg Roach </div> 62982d76d1SGreg Roach 63982d76d1SGreg Roach <div class="col-sm-9"> 64*f24a8589SGreg Roach <input type="text" value="localhost:<?= ini_get('pdo_mysql.default_socket') ?>" class="form-control" readonly="readonly"> 65*f24a8589SGreg Roach </div> 66*f24a8589SGreg Roach </div> 67982d76d1SGreg Roach 68*f24a8589SGreg Roach <div class="row mb-3"> 69*f24a8589SGreg Roach <div class="col-sm-3"> 70*f24a8589SGreg Roach <div class="form-check"> 71*f24a8589SGreg Roach <input type="radio" name="mysql-type" id="mysql-type-network" class="form-check-input" <?= ($dbhost === '' || $dbhost === 'localhost') ? '' : 'checked="checked"' ?>"> 72*f24a8589SGreg Roach <label class="form-check-label" for="mysql-type-network"> 73*f24a8589SGreg Roach <?= I18N::translate('network') ?> 74*f24a8589SGreg Roach </label> 75*f24a8589SGreg Roach </div> 76*f24a8589SGreg Roach </div> 77*f24a8589SGreg Roach 78*f24a8589SGreg Roach <div class="col-sm-9"> 79*f24a8589SGreg Roach <div class="row"> 80*f24a8589SGreg Roach <div class="col-8"> 81*f24a8589SGreg Roach <label class="form-label" for="dbhost"> 82*f24a8589SGreg Roach <?= I18N::translate('Server name') ?> 83*f24a8589SGreg Roach </label> 84*f24a8589SGreg Roach </div> 85*f24a8589SGreg Roach <div class="col-4"> 86*f24a8589SGreg Roach <label class="form-label" for="dbport"> 87*f24a8589SGreg Roach <?= I18N::translate('Port number') ?> 88*f24a8589SGreg Roach </label> 89*f24a8589SGreg Roach </div> 90*f24a8589SGreg Roach </div> 91*f24a8589SGreg Roach 92*f24a8589SGreg Roach <div class="row"> 93*f24a8589SGreg Roach <div class="col-8"> 94*f24a8589SGreg Roach <input class="form-control" id="dbhost" name="dbhost" type="text" value="<?= e($dbhost === 'localhost' ? '' : $dbhost) ?>" dir="ltr"> 95*f24a8589SGreg Roach </div> 96*f24a8589SGreg Roach <div class="col-4"> 97*f24a8589SGreg Roach <input class="form-control" id="dbport" name="dbport" pattern="\d+" type="text" value="<?= e($dbport ?: '3306') ?>" dir="ltr"> 98*f24a8589SGreg Roach </div> 99315eb316SGreg Roach </div> 100982d76d1SGreg Roach </div> 101982d76d1SGreg Roach </div> 102982d76d1SGreg Roach 1039e3c2cf9SGreg Roach <div class="row mb-3"> 104982d76d1SGreg Roach <label class="col-form-label col-sm-3" for="dbuser"> 105982d76d1SGreg Roach <?= I18N::translate('Database user account') ?> 106982d76d1SGreg Roach </label> 107982d76d1SGreg Roach 108982d76d1SGreg Roach <div class="col-sm-9"> 109982d76d1SGreg Roach <input class="form-control" id="dbuser" name="dbuser" type="text" value="<?= e($dbuser) ?>" dir="ltr"> 110982d76d1SGreg Roach </div> 111982d76d1SGreg Roach </div> 112982d76d1SGreg Roach 1139e3c2cf9SGreg Roach <div class="row mb-3"> 114982d76d1SGreg Roach <label class="col-form-label col-sm-3" for="dbpass"> 115982d76d1SGreg Roach <?= I18N::translate('Database password') ?> 116982d76d1SGreg Roach </label> 117982d76d1SGreg Roach 118982d76d1SGreg Roach <div class="col-sm-9"> 119d4786c66SGreg Roach <input class="form-control" id="dbpass" name="dbpass" type="password" value="<?= e($dbpass) ?>" dir="ltr" autocomplete="off" data-wt-show-password-text="<?= e(I18N::translate('show')) ?>" data-wt-show-password-title="<?= e(I18N::translate('Show password')) ?>" data-wt-hide-password-text="<?= e(I18N::translate('hide')) ?>" data-wt-hide-password-title="<?= e(I18N::translate('Hide password')) ?>"> 120982d76d1SGreg Roach </div> 121982d76d1SGreg Roach </div> 122982d76d1SGreg Roach 1239e3c2cf9SGreg Roach <div class="row mb-3"> 124982d76d1SGreg Roach <label class="col-form-label col-sm-3" for="dbname"> 125982d76d1SGreg Roach <?= I18N::translate('Database name') ?> 126982d76d1SGreg Roach </label> 127982d76d1SGreg Roach 128982d76d1SGreg Roach <div class="col-sm-9"> 1297bf2ba3bSGreg Roach <input class="form-control" dir="ltr" id="dbname" name="dbname" pattern="[^`'"]{1,64}" type="text" value="<?= e($dbname) ?>"> 130982d76d1SGreg Roach </div> 131982d76d1SGreg Roach </div> 132982d76d1SGreg Roach 1339e3c2cf9SGreg Roach <div class="row mb-3"> 134982d76d1SGreg Roach <label class="col-form-label col-sm-3" for="tblpfx"> 135982d76d1SGreg Roach <?= I18N::translate('Table prefix') ?> 136982d76d1SGreg Roach </label> 137982d76d1SGreg Roach <div class="col-sm-9"> 1386633baf0SGreg Roach <input class="form-control" dir="ltr" id="tblpfx" maxlength="15" name="tblpfx" pattern="[a-zA-Z0-9_]+" type="text" value="<?= e($tblpfx) ?>"> 139315eb316SGreg Roach <div class="form-text"> 140982d76d1SGreg Roach <?= I18N::translate('The prefix is optional, but recommended. By giving the table names a unique prefix you can let several different applications share the same database.') ?> 141982d76d1SGreg Roach <?= I18N::translate('Use letters A-Z, a-z, digits 0-9, or underscores') ?> 142315eb316SGreg Roach </div> 143982d76d1SGreg Roach </div> 144982d76d1SGreg Roach </div> 145982d76d1SGreg Roach 146982d76d1SGreg Roach <hr> 147982d76d1SGreg Roach 148982d76d1SGreg Roach <div class="d-flex justify-content-between"> 149982d76d1SGreg Roach <button class="btn btn-primary" name="step" type="submit" value="5"> 150982d76d1SGreg Roach <?= I18N::translate('next') ?> 151982d76d1SGreg Roach </button> 1523e0eba26SGreg Roach 1533e0eba26SGreg Roach <button class="btn btn-secondary" name="step" type="submit" value="3"> 1543e0eba26SGreg Roach <?= I18N::translate('previous') ?> 1553e0eba26SGreg Roach </button> 156982d76d1SGreg Roach </div> 157982d76d1SGreg Roach</form> 158*f24a8589SGreg Roach 159*f24a8589SGreg Roach<script> 160*f24a8589SGreg Roach (function () { 161*f24a8589SGreg Roach const inputDbHost = document.getElementById('dbhost'); 162*f24a8589SGreg Roach 163*f24a8589SGreg Roach document.getElementById('mysql-type-local').addEventListener('click', () => inputDbHost.value = ''); 164*f24a8589SGreg Roach 165*f24a8589SGreg Roach inputDbHost.addEventListener('change', () => { 166*f24a8589SGreg Roach if (inputDbHost.value === 'localhost') { 167*f24a8589SGreg Roach inputDbHost.value = ''; 168*f24a8589SGreg Roach } 169*f24a8589SGreg Roach if (inputDbHost.value === '') { 170*f24a8589SGreg Roach document.getElementById('mysql-type-local').click(); 171*f24a8589SGreg Roach } else { 172*f24a8589SGreg Roach document.getElementById('mysql-type-network').click(); 173*f24a8589SGreg Roach } 174*f24a8589SGreg Roach }); 175*f24a8589SGreg Roach 176*f24a8589SGreg Roach document.querySelector('form').addEventListener('submit', () => { 177*f24a8589SGreg Roach if (inputDbHost.value === '') { 178*f24a8589SGreg Roach inputDbHost.value = 'localhost' 179*f24a8589SGreg Roach } 180*f24a8589SGreg Roach }); 181*f24a8589SGreg Roach })(); 182*f24a8589SGreg Roach</script> 183