selfremove.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 MECCANO_CORE_DIR.'/files.php';
  27. if (!session_id()) {
  28. session_start();
  29. }
  30. if (isset($_GET['rid']) && isset($_SESSION['rid']) && (isset($_GET['rid']) == isset($_SESSION['rid']))) {
  31. $path = dirname(__FILE__);
  32. if (\core\Files::remove($path)) {
  33. echo json_encode(["response" => true]);
  34. }
  35. else {
  36. echo json_encode(["response" => false, "error" => \core\Files::errExp()]);
  37. }
  38. }
  39. else {
  40. echo json_encode(["response" => false, "error" => "unauthorized request for self-removing"]);
  41. }