setup.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. $hasMSSQL = is_callable('sqlsrv_connect');
  17. $datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
  18. $vulnerableToNullByte = false;
  19. if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
  20. $vulnerableToNullByte = true;
  21. }
  22. // Protect data directory here, so we can test if the protection is working
  23. OC_Setup::protectDataDirectory();
  24. $opts = array(
  25. 'hasSQLite' => $hasSQLite,
  26. 'hasMySQL' => $hasMySQL,
  27. 'hasPostgreSQL' => $hasPostgreSQL,
  28. 'hasOracle' => $hasOracle,
  29. 'hasMSSQL' => $hasMSSQL,
  30. 'directory' => $datadir,
  31. 'secureRNG' => OC_Util::secureRNGAvailable(),
  32. 'htaccessWorking' => OC_Util::isHtAccessWorking(),
  33. 'vulnerableToNullByte' => $vulnerableToNullByte,
  34. 'errors' => array(),
  35. );
  36. if(isset($_POST['install']) AND $_POST['install']=='true') {
  37. // We have to launch the installation process :
  38. $e = OC_Setup::install($_POST);
  39. $errors = array('errors' => $e);
  40. if(count($e) > 0) {
  41. //OC_Template::printGuestPage("", "error", array("errors" => $errors));
  42. $options = array_merge($_POST, $opts, $errors);
  43. OC_Template::printGuestPage("", "installation", $options);
  44. }
  45. else {
  46. header( 'Location: '.OC_Helper::linkToRoute( 'post_setup_check' ));
  47. exit();
  48. }
  49. }
  50. else {
  51. OC_Template::printGuestPage("", "installation", $opts);
  52. }