mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00

Conflicts: .gitignore .travis.yml Vagrantfile lib/Alchemy/Phrasea/Controller/Datafiles.php lib/Alchemy/Phrasea/Controller/Setup.php lib/Alchemy/Phrasea/Helper/DatabaseHelper.php lib/classes/connection/pdo.php lib/classes/task/period/subdef.php lib/classes/task/period/writemeta.php locale/de_DE/LC_MESSAGES/phraseanet.mo locale/de_DE/LC_MESSAGES/phraseanet.po locale/en_GB/LC_MESSAGES/phraseanet.mo locale/en_GB/LC_MESSAGES/phraseanet.po locale/fr_FR/LC_MESSAGES/phraseanet.mo locale/fr_FR/LC_MESSAGES/phraseanet.po locale/nl_NL/LC_MESSAGES/phraseanet.mo locale/nl_NL/LC_MESSAGES/phraseanet.po locale/phraseanet.pot templates/web/setup/step2.html.twig vagrant/vms/phraseanet-php54-nginx/puphpet/config.yaml vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/setup vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup vagrant/vms/phraseanet-php54-nginx/puphpet/shell/important-notices.txt vagrant/vms/phraseanet-php54-nginx/puphpet/shell/self-promotion.txt
85 lines
2.3 KiB
PHP
85 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Helper;
|
|
|
|
class DatabaseHelper extends Helper
|
|
{
|
|
public function checkConnection()
|
|
{
|
|
$hostname = $this->request->query->get('hostname', '127.0.0.1');
|
|
$port = (int) $this->request->query->get('port', 3306);
|
|
$user = $this->request->query->get('user');
|
|
$password = $this->request->query->get('password');
|
|
$dbname = $this->request->query->get('dbname');
|
|
|
|
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
|
|
|
try {
|
|
$conn = $this->app['dbal.provider']->get([
|
|
'host' => $hostname,
|
|
'port' => $port,
|
|
'user' => $user,
|
|
'password' => $password,
|
|
'dbname' => $dbname
|
|
]);
|
|
$conn->connect();
|
|
$connection_ok = true;
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
|
|
|
if (null !== $dbname && $connection_ok) {
|
|
try {
|
|
$conn = $this->app['dbal.provider']->get([
|
|
'host' => $hostname,
|
|
'port' => $port,
|
|
'user' => $user,
|
|
'password' => $password,
|
|
'dbname' => $dbname,
|
|
]);
|
|
|
|
$conn->connect();
|
|
|
|
$db_ok = true;
|
|
|
|
$sql = "SHOW TABLE STATUS";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
|
|
$empty = $stmt->rowCount() === 0;
|
|
|
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
$stmt->closeCursor();
|
|
|
|
foreach ($rs as $row) {
|
|
if ($row["Name"] === 'sitepreff') {
|
|
$is_appbox = true;
|
|
}
|
|
if ($row["Name"] === 'pref') {
|
|
$is_databox = true;
|
|
}
|
|
}
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
|
}
|
|
|
|
return [
|
|
'connection' => $connection_ok,
|
|
'database' => $db_ok,
|
|
'is_empty' => $empty,
|
|
'is_appbox' => $is_appbox,
|
|
'is_databox' => $is_databox
|
|
];
|
|
}
|
|
}
|