manage.testcnx.php 955 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Tests database connection.
  4. *
  5. * @package vchamilo
  6. * @author Moheissen Fabien (fabien.moheissen@gmail.com)
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
  8. */
  9. // Loading configuration.
  10. require_once '../../../main/inc/global.inc.php';
  11. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
  12. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
  13. api_protect_admin_script();
  14. $plugininstance = VChamiloPlugin::create();
  15. // Retrieve parameters for database connection test.
  16. $database = array();
  17. $database['db_host'] = $_REQUEST['vdbhost'];
  18. $database['db_user'] = $_REQUEST['vdblogin'];
  19. $database['db_password'] = $_REQUEST['vdbpass'];
  20. $database['root_sys'] = api_get_path(SYS_PATH);
  21. // Works, but need to improve the style...
  22. if (vchamilo_boot_connection($database, false)) {
  23. echo($plugininstance->get_lang('connectionok'));
  24. } else {
  25. echo($plugininstance->get_lang('badconnection'));
  26. }