device_log_edit.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?php
  2. /*
  3. Copyright (c) 2019-2023 Mark J Crane <[email protected]>
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
  13. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  16. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  17. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  18. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  19. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  20. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  21. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. SUCH DAMAGE.
  23. */
  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('device_log_add') || permission_exists('device_log_edit')) {
  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. //connect to the database
  39. $database = new database;
  40. //action add or update
  41. if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
  42. $action = "update";
  43. $device_log_uuid = $_REQUEST["id"];
  44. $id = $_REQUEST["id"];
  45. }
  46. else {
  47. $action = "add";
  48. }
  49. //get http post variables and set them to php variables
  50. if (is_array($_POST)) {
  51. $device_log_uuid = $_POST["device_log_uuid"] ?? null;
  52. $device_uuid = $_POST["device_uuid"] ?? null;
  53. $timestamp = $_POST["timestamp"] ?? '';
  54. $device_address = $_POST["device_address"] ?? '';
  55. $request_scheme = $_POST["request_scheme"] ?? '';
  56. $http_host = $_POST["http_host"] ?? '';
  57. $server_port = $_POST["server_port"] ?? '';
  58. $server_protocol = $_POST["server_protocol"] ?? '';
  59. $query_string = $_POST["query_string"] ?? '';
  60. $remote_address = $_POST["remote_address"] ?? '';
  61. $http_user_agent = $_POST["http_user_agent"] ?? '';
  62. $http_status = $_POST["http_status"] ?? '';
  63. $http_status_code = $_POST["http_status_code"] ?? '';
  64. $http_content_body = $_POST["http_content_body"] ?? '';
  65. }
  66. //process the user data and save it to the database
  67. if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
  68. //delete the bridge
  69. if (permission_exists('bridge_delete')) {
  70. if ($_POST['action'] == 'delete' && is_uuid($device_log_uuid)) {
  71. //prepare
  72. $array[0]['checked'] = 'true';
  73. $array[0]['uuid'] = $device_log_uuid;
  74. //delete
  75. $obj = new device_logs;
  76. $obj->delete($array);
  77. //redirect
  78. header('Location: device_logs.php');
  79. exit;
  80. }
  81. }
  82. //get the uuid from the POST
  83. if ($action == "update") {
  84. $device_log_uuid = $_POST["device_log_uuid"];
  85. }
  86. //validate the token
  87. $token = new token;
  88. if (!$token->validate($_SERVER['PHP_SELF'])) {
  89. message::add($text['message-invalid_token'],'negative');
  90. header('Location: device_logs.php');
  91. exit;
  92. }
  93. //check for all required data
  94. $msg = '';
  95. //if (strlen($device_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-device_uuid']."<br>\n"; }
  96. if (strlen($timestamp) == 0) { $msg .= $text['message-required']." ".$text['label-timestamp']."<br>\n"; }
  97. if (strlen($device_address) == 0) { $msg .= $text['message-required']." ".$text['label-device_address']."<br>\n"; }
  98. if (strlen($request_scheme) == 0) { $msg .= $text['message-required']." ".$text['label-request_scheme']."<br>\n"; }
  99. if (strlen($http_host) == 0) { $msg .= $text['message-required']." ".$text['label-http_host']."<br>\n"; }
  100. if (strlen($server_port) == 0) { $msg .= $text['message-required']." ".$text['label-server_port']."<br>\n"; }
  101. if (strlen($server_protocol) == 0) { $msg .= $text['message-required']." ".$text['label-server_protocol']."<br>\n"; }
  102. if (strlen($query_string) == 0) { $msg .= $text['message-required']." ".$text['label-query_string']."<br>\n"; }
  103. if (strlen($remote_address) == 0) { $msg .= $text['message-required']." ".$text['label-remote_address']."<br>\n"; }
  104. if (strlen($http_user_agent) == 0) { $msg .= $text['message-required']." ".$text['label-http_user_agent']."<br>\n"; }
  105. if (strlen($http_status) == 0) { $msg .= $text['message-required']." ".$text['label-http_status']."<br>\n"; }
  106. if (strlen($http_status_code) == 0) { $msg .= $text['message-required']." ".$text['label-http_status_code']."<br>\n"; }
  107. //if (strlen($http_content_body) == 0) { $msg .= $text['message-required']." ".$text['label-http_content_body']."<br>\n"; }
  108. if (strlen($msg) > 0 && empty($_POST["persistformvar"])) {
  109. require_once "resources/header.php";
  110. require_once "resources/persist_form_var.php";
  111. echo "<div align='center'>\n";
  112. echo "<table><tr><td>\n";
  113. echo $msg."<br />";
  114. echo "</td></tr></table>\n";
  115. persistformvar($_POST);
  116. echo "</div>\n";
  117. require_once "resources/footer.php";
  118. return;
  119. }
  120. //add the device_log_uuid
  121. if (!is_uuid($_POST["device_log_uuid"])) {
  122. $device_log_uuid = uuid();
  123. }
  124. //prepare the array
  125. $array['device_logs'][0]['device_log_uuid'] = $device_log_uuid;
  126. $array['device_logs'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
  127. $array['device_logs'][0]['device_uuid'] = $device_uuid;
  128. $array['device_logs'][0]['timestamp'] = $timestamp;
  129. $array['device_logs'][0]['device_address'] = $device_address;
  130. $array['device_logs'][0]['request_scheme'] = $request_scheme;
  131. $array['device_logs'][0]['http_host'] = $http_host;
  132. $array['device_logs'][0]['server_port'] = $server_port;
  133. $array['device_logs'][0]['server_protocol'] = $server_protocol;
  134. $array['device_logs'][0]['query_string'] = $query_string;
  135. $array['device_logs'][0]['remote_address'] = $remote_address;
  136. $array['device_logs'][0]['http_user_agent'] = $http_user_agent;
  137. $array['device_logs'][0]['http_status'] = $http_status;
  138. $array['device_logs'][0]['http_status_code'] = $http_status_code;
  139. $array['device_logs'][0]['http_content_body'] = $http_content_body;
  140. //save the data
  141. $database->app_name = 'device logs';
  142. $database->app_uuid = '78b1e5c7-5028-43e7-a05b-a36b44f87087';
  143. $database->save($array);
  144. //$message = $database->message;
  145. //redirect the user
  146. if (isset($action)) {
  147. if ($action == "add") {
  148. $_SESSION["message"] = $text['message-add'];
  149. }
  150. if ($action == "update") {
  151. $_SESSION["message"] = $text['message-update'];
  152. }
  153. header('Location: device_logs.php');
  154. //header('Location: device_log_edit.php?id='.urlencode($device_log_uuid));
  155. return;
  156. }
  157. }
  158. //pre-populate the form
  159. if (is_array($_GET) && empty($_POST["persistformvar"])) {
  160. $device_log_uuid = $_GET["id"] ?? '';
  161. $sql = "select * from v_device_logs ";
  162. $sql .= "where device_log_uuid = :device_log_uuid ";
  163. //$sql .= "and domain_uuid = :domain_uuid ";
  164. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  165. $parameters['device_log_uuid'] = $device_log_uuid;
  166. $row = $database->select($sql, $parameters, 'row');
  167. if (is_array($row) && sizeof($row) != 0) {
  168. $device_uuid = $row["device_uuid"];
  169. $timestamp = $row["timestamp"];
  170. $device_address = $row["device_address"];
  171. $request_scheme = $row["request_scheme"];
  172. $http_host = $row["http_host"];
  173. $server_port = $row["server_port"];
  174. $server_protocol = $row["server_protocol"];
  175. $query_string = $row["query_string"];
  176. $remote_address = $row["remote_address"];
  177. $http_user_agent = $row["http_user_agent"];
  178. $http_status = $row["http_status"];
  179. $http_status_code = $row["http_status_code"];
  180. $http_content_body = $row["http_content_body"];
  181. }
  182. unset($sql, $parameters, $row);
  183. }
  184. // load editor preferences/defaults
  185. $setting_size = !empty($_SESSION["editor"]["font_size"]["text"]) ? $_SESSION["editor"]["font_size"]["text"] : '12px';
  186. $setting_theme = !empty($_SESSION["editor"]["theme"]["text"]) ? $_SESSION["editor"]["theme"]["text"] : 'cobalt';
  187. $setting_invisibles = isset($_SESSION["editor"]["invisibles"]["boolean"]) && $_SESSION["editor"]["invisibles"]["boolean"] != '' ? $_SESSION["editor"]["invisibles"]["boolean"] : 'false';
  188. $setting_indenting = isset($_SESSION["editor"]["indent_guides"]["boolean"]) && $_SESSION["editor"]["indent_guides"]["boolean"] != '' ? $_SESSION["editor"]["indent_guides"]["boolean"] : 'false';
  189. $setting_numbering = isset($_SESSION["editor"]["line_numbers"]["boolean"]) && $_SESSION["editor"]["line_numbers"]["boolean"] != '' ? $_SESSION["editor"]["line_numbers"]["boolean"] : 'true';
  190. //create token
  191. $object = new token;
  192. $token = $object->create($_SERVER['PHP_SELF']);
  193. //show the header
  194. $document['title'] = $text['title-device_log'];
  195. require_once "resources/header.php";
  196. echo "<script language='JavaScript' type='text/javascript'>\n";
  197. echo " function toggle_option(opt) {\n";
  198. echo " switch (opt) {\n";
  199. echo " case 'numbering':\n";
  200. echo " toggle_option_do('showLineNumbers');\n";
  201. echo " toggle_option_do('fadeFoldWidgets');\n";
  202. echo " break;\n";
  203. echo " case 'invisibles':\n";
  204. echo " toggle_option_do('showInvisibles');\n";
  205. echo " break;\n";
  206. echo " case 'indenting':\n";
  207. echo " toggle_option_do('displayIndentGuides');\n";
  208. echo " break;\n";
  209. echo " }\n";
  210. echo " focus_editor();\n";
  211. echo " }\n";
  212. echo " function toggle_option_do(opt_name) {\n";
  213. echo " var opt_val = editor.getOption(opt_name);\n";
  214. echo " editor.setOption(opt_name, ((opt_val) ? false : true));\n";
  215. echo " }\n";
  216. echo " function focus_editor() {\n";
  217. echo " editor.focus();\n";
  218. echo " }\n";
  219. //copy the value from the editor on submit
  220. echo " function set_value() {\n";
  221. echo " $('#http_content_body').val(editor.session.getValue());\n";
  222. echo " }\n";
  223. //load editor value from hidden textarea
  224. echo " function load_value() {\n";
  225. echo " editor.session.setValue($('#http_content_body').val());";
  226. echo " }\n";
  227. echo "</script>\n";
  228. echo "<style>\n";
  229. echo " div#editor {\n";
  230. echo " text-align: left;\n";
  231. echo " width: 100%;\n";
  232. echo " height: 600px;\n";
  233. echo " font-size: 12px;\n";
  234. echo " }\n";
  235. echo "</style>\n";
  236. //show the content
  237. echo "<form name='frm' id='frm' method='post' action=''>\n";
  238. echo "<div class='action_bar' id='action_bar'>\n";
  239. echo " <div class='heading'><b>".$text['title-device_log']."</b></div>\n";
  240. echo " <div class='actions'>\n";
  241. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'device_logs.php']);
  242. if ($action == 'update' && permission_exists('device_log_delete')) {
  243. echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>'margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
  244. }
  245. if ($action == 'update' && permission_exists('device_log_copy')) {
  246. echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>'margin-right: 15px;','link'=>'device_log_copy.php']);
  247. }
  248. echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','name'=>'action','value'=>'save']);
  249. echo " </div>\n";
  250. echo " <div style='clear: both; text-align: left;'>".$text['description-device_logs']."</div>\n";
  251. echo "</div>\n";
  252. if ($action == 'update' && permission_exists('device_log_delete')) {
  253. echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
  254. }
  255. echo "<div class='card'>\n";
  256. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  257. echo "<tr>\n";
  258. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  259. echo " ".$text['label-device_uuid']."\n";
  260. echo "</td>\n";
  261. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  262. echo " <input class='formfld' type='text' name='device_uuid' maxlength='255' value='".escape($device_uuid)."'>\n";
  263. echo "<br />\n";
  264. echo $text['description-device_uuid']."\n";
  265. echo "</td>\n";
  266. echo "</tr>\n";
  267. echo "<tr>\n";
  268. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  269. echo " ".$text['label-timestamp']."\n";
  270. echo "</td>\n";
  271. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  272. echo " <input class='formfld' type='text' name='timestamp' maxlength='255' value='".escape($timestamp)."'>\n";
  273. echo "<br />\n";
  274. echo $text['description-timestamp']."\n";
  275. echo "</td>\n";
  276. echo "</tr>\n";
  277. echo "<tr>\n";
  278. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  279. echo " ".$text['label-device_address']."\n";
  280. echo "</td>\n";
  281. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  282. echo " <input class='formfld' type='text' name='device_address' maxlength='255' value='".escape($device_address)."'>\n";
  283. echo "<br />\n";
  284. echo $text['description-device_address']."\n";
  285. echo "</td>\n";
  286. echo "</tr>\n";
  287. echo "<tr>\n";
  288. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  289. echo " ".$text['label-request_scheme']."\n";
  290. echo "</td>\n";
  291. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  292. echo " <input class='formfld' type='text' name='request_scheme' maxlength='255' value='".escape($request_scheme)."'>\n";
  293. echo "<br />\n";
  294. echo $text['description-request_scheme']."\n";
  295. echo "</td>\n";
  296. echo "</tr>\n";
  297. echo "<tr>\n";
  298. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  299. echo " ".$text['label-http_host']."\n";
  300. echo "</td>\n";
  301. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  302. echo " <input class='formfld' type='text' name='http_host' maxlength='255' value='".escape($http_host)."'>\n";
  303. echo "<br />\n";
  304. echo $text['description-http_host']."\n";
  305. echo "</td>\n";
  306. echo "</tr>\n";
  307. echo "<tr>\n";
  308. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  309. echo " ".$text['label-server_port']."\n";
  310. echo "</td>\n";
  311. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  312. echo " <input class='formfld' type='text' name='server_port' maxlength='255' value='".escape($server_port)."'>\n";
  313. echo "<br />\n";
  314. echo $text['description-server_port']."\n";
  315. echo "</td>\n";
  316. echo "</tr>\n";
  317. echo "<tr>\n";
  318. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  319. echo " ".$text['label-server_protocol']."\n";
  320. echo "</td>\n";
  321. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  322. echo " <input class='formfld' type='text' name='server_protocol' maxlength='255' value='".escape($server_protocol)."'>\n";
  323. echo "<br />\n";
  324. echo $text['description-server_protocol']."\n";
  325. echo "</td>\n";
  326. echo "</tr>\n";
  327. echo "<tr>\n";
  328. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  329. echo " ".$text['label-query_string']."\n";
  330. echo "</td>\n";
  331. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  332. echo " <input class='formfld' type='text' name='query_string' maxlength='255' value='".escape($query_string)."'>\n";
  333. echo "<br />\n";
  334. echo $text['description-query_string']."\n";
  335. echo "</td>\n";
  336. echo "</tr>\n";
  337. echo "<tr>\n";
  338. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  339. echo " ".$text['label-remote_address']."\n";
  340. echo "</td>\n";
  341. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  342. echo " <input class='formfld' type='text' name='remote_address' maxlength='255' value='".escape($remote_address)."'>\n";
  343. echo "<br />\n";
  344. echo $text['description-remote_address']."\n";
  345. echo "</td>\n";
  346. echo "</tr>\n";
  347. echo "<tr>\n";
  348. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  349. echo " ".$text['label-http_user_agent']."\n";
  350. echo "</td>\n";
  351. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  352. echo " <input class='formfld' type='text' name='http_user_agent' maxlength='255' value='".escape($http_user_agent)."'>\n";
  353. echo "<br />\n";
  354. echo $text['description-http_user_agent']."\n";
  355. echo "</td>\n";
  356. echo "</tr>\n";
  357. echo "<tr>\n";
  358. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  359. echo " ".$text['label-http_status']."\n";
  360. echo "</td>\n";
  361. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  362. echo " <input class='formfld' type='text' name='http_status' maxlength='255' value='".escape($http_status)."'>\n";
  363. echo "<br />\n";
  364. echo $text['description-http_status']."\n";
  365. echo "</td>\n";
  366. echo "</tr>\n";
  367. echo "<tr>\n";
  368. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  369. echo " ".$text['label-http_status_code']."\n";
  370. echo "</td>\n";
  371. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  372. echo " <input class='formfld' type='text' name='http_status_code' maxlength='255' value='".escape($http_status_code)."'>\n";
  373. echo "<br />\n";
  374. echo $text['description-http_status_code']."\n";
  375. echo "</td>\n";
  376. echo "</tr>\n";
  377. echo "<tr>\n";
  378. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  379. echo " ".$text['label-http_content_body']."\n";
  380. echo "</td>\n";
  381. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  382. echo " <textarea class='formfld' name='http_content_body' id='http_content_body' style='display: none;'>".$http_content_body."</textarea>\n";
  383. echo " <div id='editor'></div>\n";
  384. echo " <table cellpadding='0' cellspacing='0' border='0' style='float: right; padding-top: 5px;'>\n";
  385. echo " <tr>\n";
  386. echo " <td valign='middle' style='padding-left: 6px;'><i class='fas fa-list-ul fa-lg ace_control' title=\"".$text['label-toggle_line_numbers']."\" onclick=\"toggle_option('numbering');\"></i></td>\n";
  387. echo " <td valign='middle' style='padding-left: 6px;'><i class='fas fa-eye-slash fa-lg ace_control' title=\"".$text['label-toggle_invisibles']."\" onclick=\"toggle_option('invisibles');\"></i></td>\n";
  388. echo " <td valign='middle' style='padding-left: 6px;'><i class='fas fa-indent fa-lg ace_control' title=\"".$text['label-toggle_indent_guides']."\" onclick=\"toggle_option('indenting');\"></i></td>\n";
  389. echo " <td valign='middle' style='padding-left: 6px;'><i class='fas fa-search fa-lg ace_control' title=\"".$text['label-find_replace']."\" onclick=\"editor.execCommand('replace');\"></i></td>\n";
  390. echo " <td valign='middle' style='padding-left: 6px;'><i class='fas fa-chevron-down fa-lg ace_control' title=\"".$text['label-go_to_line']."\" onclick=\"editor.execCommand('gotoline');\"></i></td>\n";
  391. echo " <td valign='middle' style='padding-left: 15px;'>\n";
  392. echo " <select id='size' class='formfld' onchange=\"document.getElementById('editor').style.fontSize = this.options[this.selectedIndex].value; focus_editor();\">\n";
  393. $sizes = explode(',','9px,10px,11px,12px,14px,16px,18px,20px');
  394. if (!in_array($setting_size, $sizes)) {
  395. echo " <option value='".$setting_size."'>".escape($setting_size)."</option>\n";
  396. echo " <option value='' disabled='disabled'></option>\n";
  397. }
  398. foreach ($sizes as $size) {
  399. $selected = $size == $setting_size ? 'selected' : null;
  400. echo " <option value='".$size."' ".$selected.">".escape($size)."</option>\n";
  401. }
  402. echo " </select>\n";
  403. echo " </td>\n";
  404. echo " <td valign='middle' style='padding-left: 4px; padding-right: 0px;'>\n";
  405. $themes['Light']['chrome']= 'Chrome';
  406. $themes['Light']['clouds']= 'Clouds';
  407. $themes['Light']['crimson_editor']= 'Crimson Editor';
  408. $themes['Light']['dawn']= 'Dawn';
  409. $themes['Light']['dreamweaver']= 'Dreamweaver';
  410. $themes['Light']['eclipse']= 'Eclipse';
  411. $themes['Light']['github']= 'GitHub';
  412. $themes['Light']['iplastic']= 'IPlastic';
  413. $themes['Light']['solarized_light']= 'Solarized Light';
  414. $themes['Light']['textmate']= 'TextMate';
  415. $themes['Light']['tomorrow']= 'Tomorrow';
  416. $themes['Light']['xcode']= 'XCode';
  417. $themes['Light']['kuroir']= 'Kuroir';
  418. $themes['Light']['katzenmilch']= 'KatzenMilch';
  419. $themes['Light']['sqlserver']= 'SQL Server';
  420. $themes['Dark']['ambiance']= 'Ambiance';
  421. $themes['Dark']['chaos']= 'Chaos';
  422. $themes['Dark']['clouds_midnight']= 'Clouds Midnight';
  423. $themes['Dark']['cobalt']= 'Cobalt';
  424. $themes['Dark']['idle_fingers']= 'idle Fingers';
  425. $themes['Dark']['kr_theme']= 'krTheme';
  426. $themes['Dark']['merbivore']= 'Merbivore';
  427. $themes['Dark']['merbivore_soft']= 'Merbivore Soft';
  428. $themes['Dark']['mono_industrial']= 'Mono Industrial';
  429. $themes['Dark']['monokai']= 'Monokai';
  430. $themes['Dark']['pastel_on_dark']= 'Pastel on dark';
  431. $themes['Dark']['solarized_dark']= 'Solarized Dark';
  432. $themes['Dark']['terminal']= 'Terminal';
  433. $themes['Dark']['tomorrow_night']= 'Tomorrow Night';
  434. $themes['Dark']['tomorrow_night_blue']= 'Tomorrow Night Blue';
  435. $themes['Dark']['tomorrow_night_bright']= 'Tomorrow Night Bright';
  436. $themes['Dark']['tomorrow_night_eighties']= 'Tomorrow Night 80s';
  437. $themes['Dark']['twilight']= 'Twilight';
  438. $themes['Dark']['vibrant_ink']= 'Vibrant Ink';
  439. echo " <select id='theme' class='formfld' onchange=\"editor.setTheme('ace/theme/' + this.options[this.selectedIndex].value); focus_editor();\">\n";
  440. foreach ($themes as $optgroup => $theme) {
  441. echo " <optgroup label='".$optgroup."'>\n";
  442. foreach ($theme as $value => $label) {
  443. $selected = strtolower($label) == strtolower($setting_theme) ? 'selected' : null;
  444. echo " <option value='".$value."' ".$selected.">".escape($label)."</option>\n";
  445. }
  446. echo " </optgroup>\n";
  447. }
  448. echo " </select>\n";
  449. echo " </td>\n";
  450. echo " </tr>\n";
  451. echo " </table>\n";
  452. echo "<br />\n";
  453. echo $text['description-http_content_body']."\n";
  454. echo "</td>\n";
  455. echo "</tr>\n";
  456. echo "</table>";
  457. echo "</div>\n";
  458. echo "<br /><br />";
  459. if ($action == "update") {
  460. echo "<input type='hidden' name='device_log_uuid' value='".escape($device_log_uuid)."'>\n";
  461. }
  462. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  463. echo "</form>";
  464. echo "<script type='text/javascript' src='".PROJECT_PATH."/resources/ace/ace.js' charset='utf-8'></script>\n";
  465. echo "<script type='text/javascript'>\n";
  466. //load editor
  467. echo " var editor = ace.edit('editor');\n";
  468. echo " editor.setOptions({\n";
  469. echo " mode: 'ace/mode/".(substr($query_string, -3) == 'xml' ? 'xml' : 'ini')."',\n";
  470. echo " theme: 'ace/theme/'+document.getElementById('theme').options[document.getElementById('theme').selectedIndex].value,\n";
  471. echo " selectionStyle: 'text',\n";
  472. echo " cursorStyle: 'smooth',\n";
  473. echo " showInvisibles: ".$setting_invisibles.",\n";
  474. echo " displayIndentGuides: ".$setting_indenting.",\n";
  475. echo " showLineNumbers: ".$setting_numbering.",\n";
  476. echo " showGutter: true,\n";
  477. echo " scrollPastEnd: true,\n";
  478. echo " fadeFoldWidgets: ".$setting_numbering.",\n";
  479. echo " showPrintMargin: false,\n";
  480. echo " highlightGutterLine: false,\n";
  481. echo " useSoftTabs: false\n";
  482. echo " });\n";
  483. echo " document.getElementById('editor').style.fontSize='".$setting_size."';\n";
  484. echo " focus_editor();\n";
  485. //load value into editor
  486. echo " load_value();\n";
  487. //remove certain keyboard shortcuts
  488. echo " editor.commands.bindKey('Ctrl-T', null);\n"; //disable transpose letters - prefer new browser tab
  489. echo " editor.commands.bindKey('Ctrl-F', null);\n"; //disable find - control broken with bootstrap
  490. echo " editor.commands.bindKey('Ctrl-H', null);\n"; //disable replace - control broken with bootstrap
  491. echo "</script>\n";
  492. //include the footer
  493. require_once "resources/footer.php";
  494. ?>