folder_new.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-2023
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. James Rose <[email protected]>
  21. */
  22. //disable this feature
  23. exit;
  24. //includes files
  25. require_once dirname(__DIR__, 2) . "/resources/require.php";
  26. require_once "resources/check_auth.php";
  27. //check permissions
  28. if (permission_exists('edit_save')) {
  29. //access granted
  30. }
  31. else {
  32. echo "access denied";
  33. exit;
  34. }
  35. //add multi-lingual support
  36. $language = new text;
  37. $text = $language->get();
  38. //preparing the directory
  39. $folder = $_REQUEST["folder"];
  40. $folder = str_replace ("\\", "/", $folder);
  41. $foldername = $_REQUEST["foldername"];
  42. //create the directory or show the html form
  43. if (strlen($folder) > 0 && strlen($foldername) > 0) {
  44. //compare the tokens
  45. $key_name = '/app/edit/folder_new';
  46. $hash = hash_hmac('sha256', $key_name, $_SESSION['keys'][$key_name]);
  47. if (!hash_equals($hash, $_POST['token'])) {
  48. echo "access denied";
  49. exit;
  50. }
  51. //create new folder
  52. mkdir($folder.'/'.$foldername); //, 0700
  53. header("Location: file_options.php");
  54. }
  55. else {
  56. //create a token
  57. $key_name = '/app/edit/folder_new';
  58. $_SESSION['keys'][$key_name] = bin2hex(random_bytes(32));
  59. $_SESSION['token'] = hash_hmac('sha256', $key_name, $_SESSION['keys'][$key_name]);
  60. //show the footer
  61. require_once "header.php";
  62. //show the content
  63. echo "<br>";
  64. echo "<div align='left'>";
  65. echo "<form method='POST' action=''>";
  66. echo "<table>";
  67. echo " <tr>";
  68. echo " <td>".$text['label-path']."</td>";
  69. echo " </tr>";
  70. echo " <tr>";
  71. echo " <td>".$folder."</td>";
  72. echo " </tr>";
  73. echo "</table>";
  74. echo "<br />";
  75. echo "<table>";
  76. echo " <tr>";
  77. echo " <td>".$text['label-folder-name']."</td>";
  78. echo " </tr>";
  79. echo " <tr>";
  80. echo " <td><input type='text' name='foldername' value=''></td>";
  81. echo " </tr>";
  82. echo " <tr>";
  83. echo " <td colspan='1' align='right'>";
  84. echo " <input type='hidden' name='folder' value='$folder'>";
  85. echo " <input type='hidden' name='token' id='token' value='". $_SESSION['token']. "'>";
  86. echo " <input type='button' value='".$text['button-back']."' onclick='history.back()'><input type='submit' value='".$text['button-new-folder']."'>";
  87. echo " </td>";
  88. echo " </tr>";
  89. echo "</table>";
  90. echo "</form>";
  91. echo "</div>";
  92. //show the footer
  93. require_once "footer.php";
  94. }