icreate install wizard

This commit is contained in:
Manuel Raynaud
2013-09-17 12:17:48 +02:00
parent eeb9a0f9eb
commit edd84fb622
11 changed files with 9962 additions and 4 deletions

View File

@@ -62,6 +62,11 @@ class CheckDatabaseConnection extends BaseInstall
/** @var int Database port information */
protected $port = null;
/**
* @var \PDO instance
*/
protected $connection = null;
/**
* Constructor
*
@@ -90,11 +95,28 @@ class CheckDatabaseConnection extends BaseInstall
*/
public function exec()
{
$link = mysql_connect($this->host . ':' . $this->port, $this->user, $this->password);
if (!$link) {
throw new InstallException('Can\'t connect to the given credentials');
$dsn = "mysql:host=%s";
try {
$this->connection = new \PDO(
sprintf($dsn, $this->host),
$this->user,
$this->password
);
} catch (\PDOException $e) {
$this->validationMessages = 'Wrong connection information';
$this->isValid = false;
}
mysql_close($link);
return $this->isValid;
}
public function getConnection()
{
return $this->connection;
}
}

113
web/install/bdd.php Normal file
View File

@@ -0,0 +1,113 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
$step=4;
include("header.php");
if (isset($_POST['host']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['port'])){
$_SESSION['install']['host'] = $_POST['host'];
$_SESSION['install']['username'] = $_POST['username'];
$_SESSION['install']['password'] = $_POST['password'];
$_SESSION['install']['port'] = $_POST['port'];
$checkConnection = new \Thelia\Install\CheckDatabaseConnection($_POST['host'], $_POST['username'], $_POST['password'], $_POST['port']);
if(! $checkConnection->exec() || $checkConnection->getConnection()->query('show databases') === false){
header('location: connection.php?err=1');
exit;
}
}
elseif($_SESSION['install']['step'] >=3) {
$checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']);
}
else {
header('location: connection.php?err=1');
exit;
}
$_SESSION['install']['step'] = 4;
$connection = $checkConnection->getConnection();
$databases = $connection->query('show databases');
?>
<div class="well">
<form action="config.php">
<fieldset>
<legend>Choose your database</legend>
<p>
The SQL server contains multiple databases.<br/>
Select below the one you want to use.
</p>
<?php foreach($databases as $database): ?>
<?php if ($database['Database'] == 'information_schema') continue; ?>
<?php
$connection->exec(sprintf('use %s', $database['Database']));
$tables = $connection->query('SHOW TABLES');
$found = false;
foreach($tables as $table) {
if($table[0] == 'cart_item') {
$found = true;
break;
}
}
?>
<div class="radio">
<label for="database_<?php echo $database['Database']; ?>">
<input type="radio" name="database" id="database_<?php echo $database['Database']; ?>" value="<?php echo $database['Database']; ?>" <?php if($found){ echo "disabled"; } ?>>
<?php echo $database['Database']; ?>
</label>
</div>
<?php endforeach; ?>
<?php
$connection->exec('use information_schema');
$permissions = $connection->query("SELECT COUNT( * ) FROM `USER_PRIVILEGES`
WHERE PRIVILEGE_TYPE = 'CREATE'
AND GRANTEE LIKE '%".$_SESSION['install']['username']."%'
AND IS_GRANTABLE = 'YES';");
$writePermission = false;
if($permissions->fetchColumn(0) > 0) {
?>
<p>
or
</p>
<div class="radio">
<label>
Create an other database
</label>
</div>
<div class="form-group">
<input type="text" name="database_create" class="form-control">
</div>
<?php } ?>
</fieldset>
</form>
</div>
<?php include 'footer.php'; ?>

27
web/install/bootstrap.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
include __DIR__ . "/../../core/bootstrap.php";
$thelia = new \Thelia\Core\Thelia("install", false);
$thelia->boot();

View File

@@ -0,0 +1,67 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
$step = 3;
include("header.php");
if(!$_SESSION['install']['continue'] && $_SESSION['install']['step'] == 2) {
header(sprintf('location: %s', $_SESSION['install']['return_step']));
}
$_SESSION['install']['step'] = 3;
?>
<form action="bdd.php" method="POST" >
<?php if(isset($_GET['err']) && $_GET['err'] == 1){ ?>
<div class="alert alert-danger">Wrong connection information</div>
<?php } ?>
<div class="well">
<div class="form-group">
<label for="host">Host :</label>
<input id="host" class="form-control" type="text" name="host" placeholder="localhost" value="<?php if(isset($_SESSION['install']['host'])){ echo $_SESSION['install']['host']; } ?>">
</div>
<div class="form-group">
<label for="user">Username :</label>
<input id="user" type="text" class="form-control" name="username" placeholder="john" value="<?php if(isset($_SESSION['install']['username'])){ echo $_SESSION['install']['username']; } ?>">
</div>
<div class="form-group">
<label for="password">Password :</label>
<input id="password" type="password" class="form-control" name="password" placeholder="l33t 5p34k" >
</div>
<div class="form-group{if $error} has-error{/if}">
<label for="port">Port :</label>
<input id="port" type="text" class="form-control" name="port" value="<?php if(isset($_SESSION['install']['port'])){ echo $_SESSION['install']['port']; } else { echo '3306'; } ?>">
</div>
</div>
<div class="clearfix">
<div class="control-btn">
<button type="submit" class="pull-right btn btn-default btn-primary">Continue</button>
</div>
</div>
</form>
<?php include("footer.php"); ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

42
web/install/footer.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
?>
</div>
</div>
</div>
</div>
</div>
<hr />
<footer class="footer">
<div class="container">
<p>&copy; Thelia 2013
- <a href="http://www.openstudio.fr/" target="_blank">Édité par OpenStudio</a>
- <a href="http://forum.thelia.net/" target="_blank">Forum Thelia</a>
- <a href="http://contrib.thelia.net/" target="_blank">Contributions Thelia</a>
</p>
</div>
</footer>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="http://thelia.local/assets/0a8bb9e-e6d174d.js"></script>
</body>
</html>

59
web/install/header.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
session_start();
include 'bootstrap.php';
?>
<!DOCTYPE html>
<html lang="">
<head>
<title>Installation</title>
<link rel="shortcut icon" href="fd33fd0-6fda040.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="topbar">
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="version-info">Version undefined</div>
</div>
</div>
</div>
</div>
<div class="install">
<div id="wrapper" class="container">
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<h3 class="title title-without-tabs">Thelia installation wizard</h3>
<div class="wizard">
<ul>
<li class="<?php if($step == 1){ echo 'active'; } elseif ($step > 1) { echo 'complete'; }?>"><span class="badge">1</span>Welcome<span class="chevron"></span></li>
<li class="<?php if($step == 2){ echo 'active'; } elseif ($step > 2) { echo 'complete'; }?>"><span class="badge">2</span>Checking permissions<span class="chevron"></span></li>
<li class="<?php if($step == 3){ echo 'active'; } elseif ($step > 3) { echo 'complete'; }?>"><span class="badge">3</span>Database connection<span class="chevron"></span></li>
<li class="<?php if($step == 4){ echo 'active'; } elseif ($step > 4) { echo 'complete'; }?>"><span class="badge">4</span>Database selection<span class="chevron"></span></li>
<li class="<?php if($step == 5){ echo 'active'; } elseif ($step > 5) { echo 'complete'; }?>"><span class="badge">5</span>General information<span class="chevron"></span></li>
<li class="<?php if($step == 6){ echo 'active'; } elseif ($step > 6) { echo 'complete'; }?>"><span class="badge">6</span>Thanks<span class="chevron"></span></li>
</ul>
</div>

39
web/install/index.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
?>
<?php
$step = 1;
include("header.php");
?>
<div class="well">
<p class="lead text-center">
Welcome in the Thelia installation wizard.
</p>
<p class="text-center">
We will guide you throughout this process to install any application on your system.
</p>
</div>
<div class="clearfix">
<a href="permission.php" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> Continue</a>
</div>
<?php include("footer.php"); ?>

View File

@@ -0,0 +1,56 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* 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/>. */
/* */
/*************************************************************************************/
?>
<?php
$step = 2;
include("header.php");
global $thelia;
$checkPermission = new \Thelia\Install\CheckPermission(true, $thelia->getContainer()->get('thelia.translator'));
$isValid = $checkPermission->exec();
$validationMessage = $checkPermission->getValidationMessages();
$_SESSION['install']['return_step'] = 'permission.php';
$_SESSION['install']['continue'] = $isValid;
$_SESSION['install']['current_step'] = 'permission.php';
$_SESSION['install']['step'] = 2;
?>
<div class="well">
<p>Checking permissions</p>
<ul class="list-unstyled list-group">
<?php foreach($validationMessage as $item => $data): ?>
<li class="list-group-item <?php if ($data['status']) {echo 'text-success';} else { echo 'text-danger';} ?>">
<?php echo $data['text']; ?>
<?php if (!$data['status']) { echo $data['hint']; } ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="clearfix">
<?php if($isValid){ ?>
<a href="connection.php" class="pull-right btn btn-default btn-primary"><span class="glyphicon glyphicon-chevron-right"></span> Continue</a>
<?php } else { ?>
<a href="permission.php" class="pull-right btn btn-default btn-danger"><span class="glyphicon glyphicon-refresh"></span> refresh</a>
<?php } ?>
</div>
<?php include("footer.php"); ?>

1999
web/install/script.js Normal file

File diff suppressed because it is too large Load Diff

7534
web/install/styles.css Normal file

File diff suppressed because one or more lines are too long