setup.php 2.1 KB

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