PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/install/core/actions/settingsTest.php

https://gitlab.com/johanlindberg/irvato-crm
PHP | 60 lines | 25 code | 8 blank | 27 comment | 7 complexity | b9b714eb1396dddb33e30ae651609dc1 MD5 | raw file
  1. <?php
  2. /************************************************************************
  3. * This file is part of EspoCRM.
  4. *
  5. * EspoCRM - Open Source CRM application.
  6. * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
  7. * Website: http://www.espocrm.com
  8. *
  9. * EspoCRM is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * EspoCRM is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
  21. *
  22. * The interactive user interfaces in modified source and object code versions
  23. * of this program must display Appropriate Legal Notices, as required under
  24. * Section 5 of the GNU General Public License version 3.
  25. *
  26. * In accordance with Section 7(b) of the GNU General Public License version 3,
  27. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
  28. ************************************************************************/
  29. ob_start();
  30. $result = array('success' => true, 'errors' => array());
  31. $res = $systemHelper->checkRequirements();
  32. $result['success'] &= $res['success'];
  33. if (!empty($res['errors'])) {
  34. $result['errors'] = array_merge($result['errors'], $res['errors']);
  35. }
  36. if ($result['success'] && !empty($_REQUEST['dbName']) && !empty($_REQUEST['hostName']) && !empty($_REQUEST['dbUserName'])) {
  37. $connect = false;
  38. $dbName = trim($_REQUEST['dbName']);
  39. if (strpos($_REQUEST['hostName'],':') === false) {
  40. $_REQUEST['hostName'] .= ":";
  41. }
  42. list($hostName, $port) = explode(':', trim($_REQUEST['hostName']));
  43. $dbUserName = trim($_REQUEST['dbUserName']);
  44. $dbUserPass = trim($_REQUEST['dbUserPass']);
  45. $res = $systemHelper->checkDbConnection($hostName, $port, $dbUserName, $dbUserPass, $dbName);
  46. $result['success'] &= $res['success'];
  47. if (!empty($res['errors'])) {
  48. $result['errors'] = array_merge($result['errors'], $res['errors']);
  49. }
  50. }
  51. ob_clean();
  52. echo json_encode($result);