setup.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // Check for autosetup:
  3. $autosetup_file = OC::$SERVERROOT."/config/autoconfig.php";
  4. if( file_exists( $autosetup_file )) {
  5. OC_Log::write('core', 'Autoconfig file found, setting up owncloud...', OC_Log::INFO);
  6. include $autosetup_file;
  7. $_POST['install'] = 'true';
  8. $_POST = array_merge ($_POST, $AUTOCONFIG);
  9. unlink($autosetup_file);
  10. }
  11. OC_Util::addScript('setup');
  12. $hasSQLite = class_exists('SQLite3');
  13. $hasMySQL = is_callable('mysql_connect');
  14. $hasPostgreSQL = is_callable('pg_connect');
  15. $hasOracle = is_callable('oci_connect');
  16. $datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
  17. // Protect data directory here, so we can test if the protection is working
  18. OC_Setup::protectDataDirectory();
  19. $opts = array(
  20. 'hasSQLite' => $hasSQLite,
  21. 'hasMySQL' => $hasMySQL,
  22. 'hasPostgreSQL' => $hasPostgreSQL,
  23. 'hasOracle' => $hasOracle,
  24. 'directory' => $datadir,
  25. 'secureRNG' => OC_Util::secureRNG_available(),
  26. 'htaccessWorking' => OC_Util::ishtaccessworking(),
  27. 'errors' => array(),
  28. );
  29. if(isset($_POST['install']) AND $_POST['install']=='true') {
  30. // We have to launch the installation process :
  31. $e = OC_Setup::install($_POST);
  32. $errors = array('errors' => $e);
  33. if(count($e) > 0) {
  34. //OC_Template::printGuestPage("", "error", array("errors" => $errors));
  35. $options = array_merge($_POST, $opts, $errors);
  36. OC_Template::printGuestPage("", "installation", $options);
  37. }
  38. else {
  39. header( 'Location: '.OC_Helper::linkToRoute( 'post_setup_check' ));
  40. exit();
  41. }
  42. }
  43. else {
  44. OC_Template::printGuestPage("", "installation", $opts);
  45. }