clip_add.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. James Rose <[email protected]>
  21. */
  22. //includes files
  23. require_once dirname(__DIR__, 2) . "/resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (!permission_exists('edit_save')) {
  27. echo "access denied";
  28. exit;
  29. }
  30. //add multi-lingual support
  31. $language = new text;
  32. $text = $language->get();
  33. //connect to the database
  34. $database = database::new();
  35. if (count($_POST)>0) {
  36. $clip_name = $_POST["clip_name"];
  37. $clip_folder = $_POST["clip_folder"];
  38. $clip_text_start = $_POST["clip_text_start"];
  39. $clip_text_end = $_POST["clip_text_end"];
  40. $clip_desc = $_POST["clip_desc"];
  41. $clip_order = $_POST["clip_order"] ?? 0;
  42. //no slashes
  43. $clip_name = str_replace('/', '|', $clip_name);
  44. $clip_name = str_replace('\\', '|', $clip_name);
  45. //sql insert
  46. $array['clips'][0]['clip_uuid'] = uuid();
  47. $array['clips'][0]['clip_name'] = $clip_name;
  48. $array['clips'][0]['clip_folder'] = $clip_folder;
  49. $array['clips'][0]['clip_text_start'] = $clip_text_start;
  50. $array['clips'][0]['clip_text_end'] = $clip_text_end;
  51. $array['clips'][0]['clip_desc'] = $clip_desc;
  52. $array['clips'][0]['clip_order'] = $clip_order;
  53. $p = permissions::new();
  54. $p->add('clip_add', 'temp');
  55. $database->save($array);
  56. unset($array);
  57. $p->delete('clip_add', 'temp');
  58. require_once "header.php";
  59. echo "<meta http-equiv='refresh' content='1;url=clip_options.php'>\n";
  60. echo $text['message-add'];
  61. require_once "footer.php";
  62. exit;
  63. }
  64. //show the content
  65. require_once "header.php";
  66. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  67. echo "<tr>\n";
  68. echo " <td align='left'>\n";
  69. echo "<form method='post' action=''>";
  70. echo "<table width='100%' border='0'>";
  71. echo " <tr>";
  72. echo " <td>Name</td>";
  73. echo " <td><input type='text' class='txt' name='clip_name' id='clip_name'></td>";
  74. echo " </tr>";
  75. echo " <tr>";
  76. echo " <td>".$text['label-folder']."</td>";
  77. echo " <td><input type='text' class='txt' name='clip_folder'></td>";
  78. echo " </tr>";
  79. echo " <tr>";
  80. echo " <td colspan='2'>".$text['label-before-selection']."<br>";
  81. echo " <textarea name='clip_text_start' class='txt' style='resize: vertical;'></textarea>";
  82. echo " </td>";
  83. echo " </tr>";
  84. echo " <tr>";
  85. echo " <td colspan='2'>".$text['label-after-selection']."<br>";
  86. echo " <textarea name='clip_text_end' class='txt' style='resize: vertical;'></textarea>";
  87. echo " </td>";
  88. echo " </tr>";
  89. echo " <tr>";
  90. echo " <td colspan='2'>".$text['label-notes']."<br>";
  91. echo " <textarea name='clip_desc' class='txt' style='resize: vertical;'></textarea>";
  92. echo " </td>";
  93. echo " </tr>";
  94. echo " <tr>";
  95. echo " <td align='left'><input type='button' value='".$text['button-back']."' onclick='history.back()'></td>";
  96. echo " <td align='right'><input type='submit' name='submit' value='".$text['button-add']."'></td>";
  97. echo " </tr>";
  98. echo "</table>";
  99. echo "</form>";
  100. echo " </td>";
  101. echo " </tr>";
  102. echo "</table>";
  103. echo "<script>document.getElementById('clip_name').focus();</script>";
  104. //include the footer
  105. require_once "footer.php";