You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.6 KiB

15 years ago
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2010 Frank Karlitschek karlitschek@kde.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. $RUNTIME_NOAPPS = TRUE; //no apps, yet
  23. require_once('lib/base.php');
  24. OC_Util::addScript('setup');
  25. $not_installed = !OC_Config::getValue('installed', false);
  26. $install_called = (isset($_POST['install']) AND $_POST['install']=='true');
  27. // First step : check if the server is correctly configured for ownCloud :
  28. $errors = OC_Util::checkServer();
  29. if(count($errors) > 0) {
  30. OC_Template::printGuestPage("", "error", array("errors" => $errors));
  31. }
  32. // Setup required :
  33. elseif($not_installed OR $install_called) {
  34. require_once('setup.php');
  35. exit();
  36. }
  37. if($_SERVER['REQUEST_METHOD']=='PROPFIND'){//handle webdav
  38. header('location: '.OC_Helper::linkTo('files','webdav.php'));
  39. exit();
  40. }
  41. // Someone is logged in :
  42. elseif(OC_User::isLoggedIn()) {
  43. if(isset($_GET["logout"]) and ($_GET["logout"])) {
  44. OC_User::logout();
  45. header("Location: ".$WEBROOT.'/');
  46. exit();
  47. }
  48. else {
  49. header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
  50. exit();
  51. }
  52. }
  53. // Someone wants to log in :
  54. elseif(isset($_POST["user"])) {
  55. OC_App::loadApps();
  56. if(OC_User::login($_POST["user"], $_POST["password"])) {
  57. header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
  58. if(!empty($_POST["remember_login"])){
  59. OC_User::setUsernameInCookie($_POST["user"]);
  60. }
  61. else {
  62. OC_User::unsetUsernameInCookie();
  63. }
  64. exit();
  65. }
  66. else {
  67. if(isset($_COOKIE["username"])){
  68. OC_Template::printGuestPage("", "login", array("error" => true, "username" => $_COOKIE["username"]));
  69. }else{
  70. OC_Template::printGuestPage("", "login", array("error" => true));
  71. }
  72. }
  73. }
  74. // For all others cases, we display the guest page :
  75. else {
  76. OC_App::loadApps();
  77. if(isset($_COOKIE["username"])){
  78. OC_Template::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"]));
  79. }else{
  80. OC_Template::printGuestPage("", "login", array("error" => false));
  81. }
  82. }
  83. ?>