Skip to content

Commit

Permalink
Add both user, check tmp writable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Feb 18, 2016
1 parent 0ea624e commit d746189
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion install/class.create_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ public static function create_database($root,$root_pass,$user,$pass,$db,$db_type
$db_type = filter_var($db_type,FILTER_SANITIZE_STRING);
$host = filter_var($host,FILTER_SANITIZE_STRING);
// Dirty hack
if ($host != 'localhost' || $host != '127.0.0.1') {
if ($host != 'localhost' && $host != '127.0.0.1') {
$grantright = $_SERVER['SERVER_ADDR'];
} else $grantright = 'localhost';
try {
$dbh = new PDO($db_type.':host='.$host,$root,$root_pass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($db_type == 'mysql') {
$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
} else if ($db_type == 'pgsql') {
$dbh->exec("CREATE DATABASE ".$db.";
CREATE USER ".$user." WITH PASSWORD '".$password."';
Expand Down
7 changes: 6 additions & 1 deletion install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
require('../footer.php');
exit;
}
if (!is_writable('tmp')) {
print '<div class="info column"><p><strong>The directory <i>install/tmp</i> must be writable.</strong></p></div>';
require('../footer.php');
exit;
}
if (!set_time_limit(0)) {
print '<div class="info column"><p><strong>You may need to update the maximum execution time.</strong></p></div>';
}
Expand Down Expand Up @@ -544,7 +549,7 @@
<label for="aircrafticoncolor">Color of aircraft icon on map</label>
<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
<?php
if (!is_writable('cache')) {
if (!is_writable('../cache')) {
?>
<b>The directory cache is not writable, aircraft icon will not be cached</b>
<?php
Expand Down

0 comments on commit d746189

Please sign in to comment.