makeinstall.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * phpMeccano v0.2.0. Web-framework written with php programming language. Component of the web installer.
  4. * Copyright (C) 2015-2019 Alexei Muzarov
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * e-mail: azexmail@gmail.com
  21. * e-mail: azexmail@mail.ru
  22. * https://bitbucket.org/azexmail/phpmeccano
  23. */
  24. header('Content-type: application/json; charset=utf-8');
  25. require_once 'getconf.php';
  26. require_once 'webinstaller.php';
  27. $webinst = new \core\WebInstaller();
  28. if (isset($_SESSION['webinstaller_step'])) {
  29. // do the step
  30. if ($_SESSION['webinstaller_step'] == 1) {
  31. $webinst->createDbTables();
  32. }
  33. elseif ($_SESSION['webinstaller_step'] == 2) {
  34. $webinst->installPackage();
  35. }
  36. elseif ($_SESSION['webinstaller_step'] == 3) {
  37. $webinst->groupUsers($_SESSION['user_param']);
  38. }
  39. elseif ($_SESSION['webinstaller_step'] == 4) {
  40. $webinst->mControl();
  41. }
  42. // check step
  43. if (!$webinst->errId()) {
  44. if ($_SESSION['webinstaller_step'] === 3 && $_SESSION['user_param']['mcontrol'] === 'false') {
  45. $_SESSION['webinstaller_step'] += 2;
  46. }
  47. else {
  48. $_SESSION['webinstaller_step'] += 1;
  49. }
  50. $removeId = core\makeIdent();
  51. echo json_encode(["response" => $_SESSION['webinstaller_step'], "rid" => $removeId]);
  52. if ($_SESSION['webinstaller_step'] == 5) {
  53. $_SESSION = [];
  54. $_SESSION['rid'] = $removeId;
  55. }
  56. }
  57. else {
  58. echo json_encode(["response" => false, "error" => $webinst->errExp()]);
  59. $_SESSION = [];
  60. }
  61. }
  62. else {
  63. if ($webinst->revalidateAll($_POST)) {
  64. $_SESSION['webinstaller_step'] = 1;
  65. $_SESSION['user_param'] = $_POST;
  66. echo json_encode(["response" => $_SESSION['webinstaller_step']]);
  67. }
  68. else {
  69. echo json_encode(["response" => 0, "error" => $webinst->errExp()]);
  70. }
  71. }