clip_add.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. //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. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. if (count($_POST)>0) {
  37. $clip_name = $_POST["clip_name"];
  38. $clip_folder = $_POST["clip_folder"];
  39. $clip_text_start = $_POST["clip_text_start"];
  40. $clip_text_end = $_POST["clip_text_end"];
  41. $clip_desc = $_POST["clip_desc"];
  42. $clip_order = $_POST["clip_order"];
  43. if (strlen($clip_order) == 0) { $clip_order = 0; }
  44. //no slashes
  45. $clip_name = str_replace('/', '|', $clip_name);
  46. $clip_name = str_replace('\\', '|', $clip_name);
  47. //sql insert
  48. $array['clips'][0]['clip_uuid'] = 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 = permissions::new();
  56. $p->add('clip_add', '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_add', 'temp');
  63. require_once "header.php";
  64. echo "<meta http-equiv=\"refresh\" content=\"1;url=clip_options.php\">\n";
  65. echo $text['message-add'];
  66. require_once "footer.php";
  67. exit;
  68. }
  69. //show the content
  70. require_once "header.php";
  71. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  72. echo "<tr>\n";
  73. echo " <td align=\"left\">\n";
  74. echo "<form method='post' action=''>";
  75. echo "<table width='100%' border='0'>";
  76. echo " <tr>";
  77. echo " <td>Name</td>";
  78. echo " <td><input type='text' class='txt' name='clip_name' id='clip_name'></td>";
  79. echo " </tr>";
  80. echo " <tr>";
  81. echo " <td>".$text['label-folder']."</td>";
  82. echo " <td><input type='text' class='txt' name='clip_folder'></td>";
  83. echo " </tr>";
  84. echo " <tr>";
  85. echo " <td colspan='2'>".$text['label-before-selection']."<br>";
  86. echo " <textarea name='clip_text_start' class='txt' style='resize: vertical;'></textarea>";
  87. echo " </td>";
  88. echo " </tr>";
  89. echo " <tr>";
  90. echo " <td colspan='2'>".$text['label-after-selection']."<br>";
  91. echo " <textarea name='clip_text_end' class='txt' style='resize: vertical;'></textarea>";
  92. echo " </td>";
  93. echo " </tr>";
  94. echo " <tr>";
  95. echo " <td colspan='2'>".$text['label-notes']."<br>";
  96. echo " <textarea name='clip_desc' class='txt' style='resize: vertical;'></textarea>";
  97. echo " </td>";
  98. echo " </tr>";
  99. echo " <tr>";
  100. echo " <td align='left'><input type='button' value='".$text['button-back']."' onclick='history.back()'></td>";
  101. echo " <td align='right'><input type='submit' name='submit' value='".$text['button-add']."'></td>";
  102. echo " </tr>";
  103. echo "</table>";
  104. echo "</form>";
  105. echo " </td>";
  106. echo " </tr>";
  107. echo "</table>";
  108. echo "<script>document.getElementById('clip_name').focus();</script>";
  109. //include the footer
  110. require_once "footer.php";