setup.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 = array_merge ($_POST, $AUTOCONFIG);
  8. $_REQUEST = array_merge ($_REQUEST, $AUTOCONFIG);
  9. }
  10. $dbIsSet = isset($_POST['dbtype']);
  11. $directoryIsSet = isset($_POST['directory']);
  12. $adminAccountIsSet = isset($_POST['adminlogin']);
  13. if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) {
  14. $_POST['install'] = 'true';
  15. if( file_exists( $autosetup_file )) {
  16. unlink($autosetup_file);
  17. }
  18. }
  19. OC_Util::addScript('setup');
  20. $hasSQLite = class_exists('SQLite3');
  21. $hasMySQL = is_callable('mysql_connect');
  22. $hasPostgreSQL = is_callable('pg_connect');
  23. $hasOracle = is_callable('oci_connect');
  24. $hasMSSQL = is_callable('sqlsrv_connect');
  25. $datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
  26. $vulnerableToNullByte = false;
  27. if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
  28. $vulnerableToNullByte = true;
  29. }
  30. // Protect data directory here, so we can test if the protection is working
  31. OC_Setup::protectDataDirectory();
  32. $opts = array(
  33. 'hasSQLite' => $hasSQLite,
  34. 'hasMySQL' => $hasMySQL,
  35. 'hasPostgreSQL' => $hasPostgreSQL,
  36. 'hasOracle' => $hasOracle,
  37. 'hasMSSQL' => $hasMSSQL,
  38. 'directory' => $datadir,
  39. 'secureRNG' => OC_Util::secureRNGAvailable(),
  40. 'htaccessWorking' => OC_Util::isHtAccessWorking(),
  41. 'vulnerableToNullByte' => $vulnerableToNullByte,
  42. 'errors' => array(),
  43. 'dbIsSet' => $dbIsSet,
  44. 'directoryIsSet' => $directoryIsSet,
  45. );
  46. if(isset($_POST['install']) AND $_POST['install']=='true') {
  47. // We have to launch the installation process :
  48. $e = OC_Setup::install($_POST);
  49. $errors = array('errors' => $e);
  50. if(count($e) > 0) {
  51. //OC_Template::printGuestPage("", "error", array("errors" => $errors));
  52. $options = array_merge($_POST, $opts, $errors);
  53. OC_Template::printGuestPage("", "installation", $options);
  54. }
  55. else {
  56. header( 'Location: '.OC_Helper::linkToRoute( 'post_setup_check' ));
  57. exit();
  58. }
  59. }
  60. else {
  61. OC_Template::printGuestPage("", "installation", $opts);
  62. }