clip_update.php 4.7 KB

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