folder_delete.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2025
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //disable this feature
  22. exit;
  23. //includes files
  24. require_once dirname(__DIR__, 2) . "/resources/require.php";
  25. require_once "resources/check_auth.php";
  26. //check the permissions
  27. if (!permission_exists('edit_save')) {
  28. echo "access denied";
  29. exit;
  30. }
  31. //set the variables
  32. $folder = $_GET["folder"];
  33. $folder = str_replace ("\\", "/", $folder);
  34. //delete the directory
  35. if (strlen($folder) > 0 && isset($_POST['token'])) {
  36. //compare the tokens
  37. $key_name = '/app/edit/folder_delete';
  38. $hash = hash_hmac('sha256', $key_name, $_SESSION['keys'][$key_name]);
  39. if (!hash_equals($hash, $_POST['token'])) {
  40. echo "access denied";
  41. exit;
  42. }
  43. //delete the folder
  44. rmdir($folder); //, 0700
  45. header("Location: file_options.php");
  46. }
  47. else {
  48. //create the token
  49. $key_name = '/app/edit/folder_delete';
  50. $_SESSION['keys'][$key_name] = bin2hex(random_bytes(32));
  51. $_SESSION['token'] = hash_hmac('sha256', $key_name, $_SESSION['keys'][$key_name]);
  52. //display form
  53. require_once "header.php";
  54. echo "<br>";
  55. echo "<div align='left'>";
  56. echo " <form method='POST' action=''>";
  57. echo " <table>";
  58. echo " <tr>";
  59. echo " <td>".$text['label-path']."</td>";
  60. echo " </tr>";
  61. echo " <tr>";
  62. echo " <td>".$folder."</td>";
  63. echo " </tr>";
  64. echo " </table>";
  65. echo " <br />";
  66. echo " <table>";
  67. echo " <tr>";
  68. echo " <td colspan='1' align='right'>";
  69. echo " <input type='hidden' name='folder' value='$folder'>";
  70. echo " <input type='hidden' name='token' id='token' value='". $_SESSION['token']. "'>";
  71. echo " <input type='submit' value='".$text['button-del-dir']."'>";
  72. echo " </td>";
  73. echo " </tr>";
  74. echo " </table>";
  75. echo " </form>";
  76. echo "</div>";
  77. //include the footer
  78. require_once "footer.php";
  79. }