PartKeepr::initializeClassLoaders(); $config = new \Doctrine\DBAL\Configuration(); /** * Test if the requested driver is available */ $drivers = PDO::getAvailableDrivers(); $bDriverAvailable = false; if (!in_array($_REQUEST["driver"], $drivers)) { echo json_encode(array("error" => true, "message" => "The requested driver isn't installed as PHP pdo module. Please install the PDO driver for PHP.")); exit; } /** * Check which driver we are going to use, and set the connection parameters accordingly. */ try { $onnectionOptions = Setup::setDatabaseConfigurationFromRequest(); $connectionOptions = PartKeepr::createConnectionOptionsFromConfig(); } catch (\Exception $e) { echo json_encode(array("error" => true, "message" => $e->getMessage())); exit; } $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionOptions, $config); try { $conn->connect(); } catch (\PDOException $e) { $additionalMessage = getPlatformSpecificErrorMessage($_REQUEST["driver"], $e->getCode()); echo json_encode(array("error" => true, "message" => "There was an error connecting to the database:<br/><code>" . $e->getMessage() . "</code>" . $additionalMessage)); exit; } catch (\Exception $e) { echo json_encode(array("error" => true, "message" => "An unknown error occured. The error is: <code>" . $e->getMessage() . "</code>")); exit;
<?php namespace PartKeepr\Setup; use PartKeepr\PartKeepr, PartKeepr\Setup\Setup, PartKeepr\Util\SerializableException; set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); include "../src/backend/PartKeepr/PartKeepr.php"; PartKeepr::initializeClassLoaders(); try { Setup::setDatabaseConfigurationFromRequest(); } catch (\Exception $e) { echo json_encode(array("error" => true, "message" => $e->getMessage())); exit; } PartKeepr::initializeDoctrine(); $setup = new Setup(); try { /** * Workaround for the footprint setup to allow long downloads pass through */ if ($_REQUEST["step"] == "footprint") { @set_time_limit(0); } $result = $setup->runStep($_REQUEST["step"]); //var_dump($result); if ($result !== null) { $aResult = array_merge($result, array("error" => false)); echo json_encode($aResult); } else { echo json_encode(array("error" => false)); }