clip_update.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once "resources/check_auth.php";
  24. //check permissions
  25. if (!permission_exists('clip_edit')) {
  26. echo "access denied";
  27. exit;
  28. }
  29. //add multi-lingual support
  30. $language = new text;
  31. $text = $language->get();
  32. //connect to the database
  33. $database = database::new();
  34. //process the HTTP POST
  35. if (count($_POST) > 0) {
  36. $clip_uuid = $_POST["id"];
  37. $clip_name = $_POST["clip_name"];
  38. $clip_folder = $_POST["clip_folder"];
  39. $clip_text_start = empty($_POST["clip_text_start"]) ? '' : $_POST["clip_text_start"];
  40. $clip_text_end = empty($_POST["clip_text_end"]) ? '' : $_POST["clip_text_end"];
  41. $clip_desc = empty($_POST["clip_desc"]) ? '' : $_POST["clip_desc"];
  42. $clip_order = empty($_POST["clip_order"]) ? '0' : $_POST["clip_order"];
  43. //no slashes
  44. $clip_name = str_replace('/', '|', $clip_name);
  45. $clip_name = str_replace('\\', '|', $clip_name);
  46. //sql update
  47. $array['clips'][0]['clip_uuid'] = $clip_uuid;
  48. $array['clips'][0]['clip_name'] = $clip_name;
  49. $array['clips'][0]['clip_folder'] = $clip_folder;
  50. $array['clips'][0]['clip_text_start'] = $clip_text_start;
  51. $array['clips'][0]['clip_text_end'] = $clip_text_end;
  52. $array['clips'][0]['clip_desc'] = $clip_desc;
  53. $array['clips'][0]['clip_order'] = $clip_order;
  54. $p = permissions::new();
  55. $p->add('clip_edit', 'temp');
  56. $database->save($array);
  57. unset($array);
  58. $p->delete('clip_edit', 'temp');
  59. //redirect the browser
  60. require_once "header.php";
  61. echo "<meta http-equiv='refresh' content='1;url=clip_options.php'>\n";
  62. echo $text['message-update'];
  63. require_once "footer.php";
  64. exit;
  65. }
  66. else {
  67. //get the uuid from http values
  68. $clip_uuid = $_GET["id"];
  69. //get the clip
  70. $sql = "select * from v_clips ";
  71. $sql .= "where clip_uuid = :clip_uuid ";
  72. $parameters['clip_uuid'] = $clip_uuid;
  73. $row = $database->select($sql, $parameters, 'row');
  74. if (is_array($row) && @sizeof($row) != 0) {
  75. $clip_name = $row["clip_name"];
  76. $clip_folder = $row["clip_folder"];
  77. $clip_text_start = $row["clip_text_start"];
  78. $clip_text_end = $row["clip_text_end"];
  79. $clip_desc = $row["clip_desc"];
  80. $clip_order = $row["clip_order"];
  81. }
  82. unset($sql, $parameters, $row);
  83. }
  84. //show the content
  85. require_once "header.php";
  86. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  87. echo "<tr>\n";
  88. echo " <td align='left'>\n";
  89. echo "<form method='post' action=''>";
  90. echo "<table border='0' width='100%'>";
  91. echo " <tr>";
  92. echo " <td>Name</td>";
  93. echo " <td><input type='text' class='txt' name='clip_name' value='".$clip_name."'></td>";
  94. echo " </tr>";
  95. echo " <tr>";
  96. echo " <td>Folder</td>";
  97. echo " <td><input type='text' class='txt' name='clip_folder' value='".$clip_folder."'></td>";
  98. echo " </tr>";
  99. echo " <tr>";
  100. echo " <td colspan='2'>Before Selection<br>";
  101. echo " <textarea class='txt' style='resize: vertical;' name='clip_text_start'>".$clip_text_start."</textarea>";
  102. echo " </td>";
  103. echo " </tr>";
  104. echo " <tr>";
  105. echo " <td colspan='2'>After Selection<br>";
  106. echo " <textarea class='txt' style='resize: vertical;' name='clip_text_end'>".$clip_text_end."</textarea>";
  107. echo " </td>";
  108. echo " </tr>";
  109. echo " <tr>";
  110. echo " <td colspan='2'>Notes<br>";
  111. echo " <textarea class='txt' style='resize: vertical;' name='clip_desc'>".$clip_desc."</textarea>";
  112. echo " </td>";
  113. echo " </tr>";
  114. echo " <tr>";
  115. echo " <td align='left'><input type='button' value='".$text['button-back']."' onclick='history.back()'></td>";
  116. echo " <td align='right'>";
  117. echo " <input type='hidden' name='id' value='".$clip_uuid."'>";
  118. echo " <input type='submit' name='submit' value='Update'>";
  119. echo " </td>";
  120. echo " </tr>";
  121. echo "</table>";
  122. echo "</form>";
  123. echo " </td>";
  124. echo " </tr>";
  125. echo "</table>";
  126. //include the footer
  127. require_once "footer.php";