mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00

Conflicts: lib/Alchemy/Phrasea/Controller/Admin/Publications.php lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php lib/Alchemy/Phrasea/Controller/Api/V1.php lib/Alchemy/Phrasea/Controller/Lightbox.php lib/Alchemy/Phrasea/Controller/Permalink.php lib/Alchemy/Phrasea/Controller/Prod/Feed.php lib/Alchemy/Phrasea/Controller/Prod/Order.php lib/Alchemy/Phrasea/Controller/Prod/Push.php lib/Alchemy/Phrasea/Controller/Prod/Share.php lib/Alchemy/Phrasea/Controller/Root/Login.php lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php lib/Alchemy/Phrasea/Controller/Root/Session.php lib/Alchemy/Phrasea/Controller/Setup.php lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php lib/classes/Feed/Entry/Item.php lib/classes/record/adapter.php lib/classes/task/Scheduler.php lib/classes/task/manager.php lib/classes/task/period/RecordMover.php lib/classes/task/period/archive.php lib/classes/task/period/cindexer.php lib/classes/task/period/ftp.php lib/classes/task/period/ftpPull.php lib/classes/task/period/subdef.php lib/classes/task/period/writemeta.php tests/Alchemy/Tests/Phrasea/Border/ManagerTest.php tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php tests/classes/Feed/Entry/Feed_Entry_ItemTest.php tests/classes/PhraseanetPHPUnitAbstract.php
92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2013 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Controller\Utils;
|
|
|
|
use Silex\Application;
|
|
use Silex\ControllerProviderInterface;
|
|
|
|
/**
|
|
*
|
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
* @link www.phraseanet.com
|
|
*/
|
|
class ConnectionTest implements ControllerProviderInterface
|
|
{
|
|
public function connect(Application $app)
|
|
{
|
|
$app['controller.utils.connection-test'] = $this;
|
|
|
|
$controllers = $app['controllers_factory'];
|
|
|
|
/**
|
|
* @todo : check this as it would lead to a security issue
|
|
*/
|
|
$controllers->get('/mysql/', function (Application $app) {
|
|
|
|
$request = $app['request'];
|
|
$hostname = $request->query->get('hostname', '127.0.0.1');
|
|
$port = (int) $request->query->get('port', 3306);
|
|
$user = $request->query->get('user');
|
|
$password = $request->query->get('password');
|
|
$dbname = $request->query->get('dbname');
|
|
|
|
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
|
|
|
try {
|
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false);
|
|
$connection_ok = true;
|
|
} catch (\Exception $e) {
|
|
|
|
}
|
|
|
|
if ($dbname && $connection_ok === true) {
|
|
try {
|
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false);
|
|
$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) {
|
|
|
|
}
|
|
}
|
|
|
|
$datas = array(
|
|
'connection' => $connection_ok
|
|
, 'database' => $db_ok
|
|
, 'is_empty' => $empty
|
|
, 'is_appbox' => $is_appbox
|
|
, 'is_databox' => $is_databox
|
|
);
|
|
|
|
return $app->json($datas);
|
|
});
|
|
|
|
return $controllers;
|
|
}
|
|
}
|