PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/options.php

https://gitlab.com/jbenicky/Mods-for-HESK
PHP | 393 lines | 347 code | 17 blank | 29 comment | 5 complexity | 67fc6f9c192f5244a199029ad2b3ed5c MD5 | raw file
  1. <?php
  2. /*******************************************************************************
  3. * Title: Help Desk Software HESK
  4. * Version: 2.6.8 from 10th August 2016
  5. * Author: Klemen Stirn
  6. * Website: http://www.hesk.com
  7. ********************************************************************************
  8. * COPYRIGHT AND TRADEMARK NOTICE
  9. * Copyright 2005-2015 Klemen Stirn. All Rights Reserved.
  10. * HESK is a registered trademark of Klemen Stirn.
  11. * The HESK may be used and modified free of charge by anyone
  12. * AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
  13. * By using this code you agree to indemnify Klemen Stirn from any
  14. * liability that might arise from it's use.
  15. * Selling the code for this program, in part or full, without prior
  16. * written consent is expressly forbidden.
  17. * Using this code, in part or full, to create derivate work,
  18. * new scripts or products is expressly forbidden. Obtain permission
  19. * before redistributing this software over the Internet or in
  20. * any other medium. In all cases copyright and header must remain intact.
  21. * This Copyright is in full effect in any country that has International
  22. * Trade Agreements with the United States of America or
  23. * with the European Union.
  24. * Removing any of the copyright notices without purchasing a license
  25. * is expressly forbidden. To remove HESK copyright notice you must purchase
  26. * a license for this script. For more information on how to obtain
  27. * a license please visit the page below:
  28. * https://www.hesk.com/buy.php
  29. *******************************************************************************/
  30. define('IN_SCRIPT', 1);
  31. define('HESK_PATH', '../');
  32. /* Get all the required files and functions */
  33. require(HESK_PATH . 'hesk_settings.inc.php');
  34. require(HESK_PATH . 'inc/common.inc.php');
  35. require(HESK_PATH . 'inc/admin_functions.inc.php');
  36. $id = hesk_input(hesk_GET('i'));
  37. $query = hesk_input(hesk_utf8_urldecode(hesk_GET('q')));
  38. $type = hesk_input(hesk_GET('t', 'text'));
  39. $maxlen = intval(hesk_GET('m', 255));
  40. $query = stripslashes($query);
  41. ?>
  42. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML; 1.0 Transitional//EN"
  43. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  44. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  45. <head>
  46. <title><?php echo $hesklang['opt']; ?></title>
  47. <meta http-equiv="Content-Type" content="text/html;charset=<?php echo $hesklang['ENCODING']; ?>"/>
  48. <style type="text/css">
  49. body {
  50. margin: 5px 5px;
  51. padding: 0;
  52. background: #fff;
  53. color: black;
  54. font: 68.8%/1.5 Verdana, Geneva, Arial, Helvetica, sans-serif;
  55. text-align: left;
  56. }
  57. p {
  58. color: black;
  59. font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  60. font-size: 1.0em;
  61. }
  62. h3 {
  63. color: #AF0000;
  64. font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  65. font-weight: bold;
  66. font-size: 1.0em;
  67. text-align: center;
  68. }
  69. .title {
  70. color: black;
  71. font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  72. font-weight: bold;
  73. font-size: 1.0em;
  74. }
  75. .wrong {
  76. color: red;
  77. }
  78. .correct {
  79. color: green;
  80. }
  81. </style>
  82. </head>
  83. <body>
  84. <h3><?php echo $hesklang['opt']; ?></h3>
  85. <p><i><?php echo $hesklang['ns']; ?></i></p>
  86. <?php
  87. switch ($type) {
  88. case 'text':
  89. echo '
  90. <script language="javascript">
  91. function hesk_saveOptions()
  92. {
  93. window.opener.document.getElementById(\'s_' . $id . '_val\').value = document.getElementById(\'o2\').value;
  94. window.opener.document.getElementById(\'s_' . $id . '_maxlen\').value = document.getElementById(\'o1\').value;
  95. window.close();
  96. }
  97. </script>
  98. <table border="0">
  99. <tr>
  100. <td>' . $hesklang['custom_l'] . ':<td>
  101. <td><input type="text" name="o1" id="o1" value="' . $maxlen . '" size="30" /></td>
  102. </tr>
  103. <tr>
  104. <td>' . $hesklang['defw'] . ':<td>
  105. <td><input type="text" name="o2" id="o2" value="' . $query . '" size="30" /></td>
  106. </tr>
  107. </table>
  108. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  109. ';
  110. break;
  111. case 'hidden':
  112. echo '
  113. <script language="javascript">
  114. function hesk_saveOptions()
  115. {
  116. window.opener.document.getElementById(\'s_' . $id . '_val\').value = document.getElementById(\'o1\').value;
  117. window.close();
  118. }
  119. </script>
  120. <p>' . $hesklang['hidden_custom_field_help'] . '</p>
  121. <table border="0">
  122. <tr>
  123. <td>' . $hesklang['value_colon'] . '<td>
  124. <td><input type="text" name="o1" id="o1" value="' . $query . '" size="30" /></td>
  125. </tr>
  126. </table>
  127. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  128. ';
  129. break;
  130. case 'readonly':
  131. echo '
  132. <script language="javascript">
  133. function hesk_saveOptions()
  134. {
  135. window.opener.document.getElementById(\'s_' . $id . '_val\').value = document.getElementById(\'o1\').value;
  136. window.close();
  137. }
  138. </script>
  139. <p>' . $hesklang['readonly_custom_field_help'] . '</p>
  140. <table border="0">
  141. <tr>
  142. <td>' . $hesklang['value_colon'] . '<td>
  143. <td><input type="text" name="o1" id="o1" value="' . $query . '" size="30" /></td>
  144. </tr>
  145. </table>
  146. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  147. ';
  148. break;
  149. case 'textarea':
  150. if (strpos($query, '#') !== false) {
  151. list($rows, $cols) = explode('#', $query);
  152. } else {
  153. $rows = '';
  154. $cols = '';
  155. }
  156. echo '
  157. <script language="javascript">
  158. function hesk_saveOptions()
  159. {
  160. window.opener.document.getElementById(\'s_' . $id . '_val\').value = document.getElementById(\'o1\').value + "#" + document.getElementById(\'o2\').value;
  161. window.close();
  162. }
  163. </script>
  164. <table border="0">
  165. <tr>
  166. <td>' . $hesklang['rows'] . ':<td>
  167. <td><input type="text" name="o1" id="o1" value="' . $rows . '" size="5" /></td>
  168. </tr>
  169. <tr>
  170. <td>' . $hesklang['cols'] . ':<td>
  171. <td><input type="text" name="o2" id="o2" value="' . $cols . '" size="5" /></td>
  172. </tr>
  173. </table>
  174. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  175. ';
  176. break;
  177. case 'radio':
  178. $options = str_replace('#HESK#', "\n", $query);
  179. echo '
  180. <script language="javascript">
  181. function hesk_saveOptions()
  182. {
  183. text = document.getElementById(\'o1\').value;
  184. text = text.replace(/^\s\s*/, \'\').replace(/\s\s*$/, \'\');
  185. text = escape(text);
  186. if(text.indexOf(\'%0D%0A\') > -1)
  187. {
  188. re_nlchar = /%0D%0A/g ;
  189. }
  190. else if(text.indexOf(\'%0A\') > -1)
  191. {
  192. re_nlchar = /%0A/g ;
  193. }
  194. else if(text.indexOf(\'%0D\') > -1)
  195. {
  196. re_nlchar = /%0D/g ;
  197. }
  198. else
  199. {
  200. alert(\'' . addslashes($hesklang['atl2']) . '\');
  201. return false;
  202. }
  203. text = unescape(text.replace(re_nlchar,\'#HESK#\'));
  204. window.opener.document.getElementById(\'s_' . $id . '_val\').value = text;
  205. window.close();
  206. }
  207. </script>
  208. <p>' . $hesklang['opt2'] . '</p>
  209. <textarea name="o1" id="o1" rows="6" cols="40">' . $options . '</textarea>
  210. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  211. ';
  212. break;
  213. case 'select':
  214. $query = str_replace('{HESK_SELECT}', '', $query, $show_select);
  215. $options = str_replace('#HESK#', "\n", $query);
  216. echo '
  217. <script language="javascript">
  218. function hesk_saveOptions()
  219. {
  220. text = document.getElementById(\'o1\').value;
  221. text = text.replace(/^\s\s*/, \'\').replace(/\s\s*$/, \'\');
  222. text = escape(text);
  223. if(text.indexOf(\'%0D%0A\') > -1)
  224. {
  225. re_nlchar = /%0D%0A/g ;
  226. }
  227. else if(text.indexOf(\'%0A\') > -1)
  228. {
  229. re_nlchar = /%0A/g ;
  230. }
  231. else if(text.indexOf(\'%0D\') > -1)
  232. {
  233. re_nlchar = /%0D/g ;
  234. }
  235. else
  236. {
  237. alert(\'' . addslashes($hesklang['atl2']) . '\');
  238. return false;
  239. }
  240. text = unescape(text.replace(re_nlchar,\'#HESK#\'));
  241. if (document.getElementById(\'show_select\').checked)
  242. {
  243. text = "{HESK_SELECT}" + text;
  244. }
  245. window.opener.document.getElementById(\'s_' . $id . '_val\').value = text;
  246. window.close();
  247. }
  248. </script>
  249. <p>' . $hesklang['opt3'] . '</p>
  250. <p><label><input type="checkbox" name="show_select" id="show_select" value="1" ' . ($show_select ? 'checked="checked"' : '') . ' /> ' . $hesklang['show_select'] . '</label></p>
  251. <textarea name="o1" id="o1" rows="6" cols="40">' . $options . '</textarea>
  252. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  253. ';
  254. break;
  255. case 'checkbox':
  256. $options = str_replace('#HESK#', "\n", $query);
  257. echo '
  258. <script language="javascript">
  259. function hesk_saveOptions()
  260. {
  261. text = document.getElementById(\'o1\').value;
  262. text = text.replace(/^\s\s*/, \'\').replace(/\s\s*$/, \'\');
  263. text = escape(text);
  264. if(text.indexOf(\'%0D%0A\') > -1)
  265. {
  266. re_nlchar = /%0D%0A/g ;
  267. }
  268. else if(text.indexOf(\'%0A\') > -1)
  269. {
  270. re_nlchar = /%0A/g ;
  271. }
  272. else if(text.indexOf(\'%0D\') > -1)
  273. {
  274. re_nlchar = /%0D/g ;
  275. }
  276. else
  277. {
  278. alert(\'' . addslashes($hesklang['atl2']) . '\');
  279. return false;
  280. }
  281. text = unescape(text.replace(re_nlchar,\'#HESK#\'));
  282. window.opener.document.getElementById(\'s_' . $id . '_val\').value = text;
  283. window.close();
  284. }
  285. </script>
  286. <p>' . $hesklang['opt4'] . '</p>
  287. <textarea name="o1" id="o1" rows="6" cols="40">' . $options . '</textarea>
  288. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  289. ';
  290. break;
  291. case 'date':
  292. echo '<p>' . $hesklang['date_custom_field_text'] . '</p>';
  293. break;
  294. case 'multiselect':
  295. $options = str_replace('#HESK#', "\n", $query);
  296. echo '
  297. <script language="javascript">
  298. function hesk_saveOptions()
  299. {
  300. text = document.getElementById(\'o1\').value;
  301. text = text.replace(/^\s\s*/, \'\').replace(/\s\s*$/, \'\');
  302. text = escape(text);
  303. if(text.indexOf(\'%0D%0A\') > -1)
  304. {
  305. re_nlchar = /%0D%0A/g ;
  306. }
  307. else if(text.indexOf(\'%0A\') > -1)
  308. {
  309. re_nlchar = /%0A/g ;
  310. }
  311. else if(text.indexOf(\'%0D\') > -1)
  312. {
  313. re_nlchar = /%0D/g ;
  314. }
  315. else
  316. {
  317. alert(\'' . addslashes($hesklang['atl2']) . '\');
  318. return false;
  319. }
  320. text = unescape(text.replace(re_nlchar,\'#HESK#\'));
  321. window.opener.document.getElementById(\'s_' . $id . '_val\').value = text;
  322. window.close();
  323. }
  324. </script>
  325. <p>' . $hesklang['multiple_select_custom_field_text'] . '</p>
  326. <textarea name="o1" id="o1" rows="6" cols="40">' . $options . '</textarea>
  327. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  328. ';
  329. break;
  330. case 'email':
  331. $ccSelected = $query == 'cc' ? 'selected="selected"' : '';
  332. $bccSelected = $query == 'bcc' ? 'selected="selected"' : '';
  333. echo '
  334. <script language="javascript">
  335. function hesk_saveOptions()
  336. {
  337. var dropdown = document.getElementById(\'o1\');
  338. window.opener.document.getElementById(\'s_' . $id . '_val\').value = dropdown.options[dropdown.selectedIndex].value;
  339. window.close();
  340. }
  341. </script>
  342. <p>' . $hesklang['email_custom_field_help'] . '</p>
  343. <table border="0">
  344. <tr>
  345. <td>' . $hesklang['email_custom_field_label'] . ':</td>
  346. <td>
  347. <select name="o1" id="o1">
  348. <option value="cc" ' . $ccSelected . '>' . $hesklang['cc'] . '</option>
  349. <option value="bcc" ' . $bccSelected . '>' . $hesklang['bcc'] . '</option>
  350. </select>
  351. </td>
  352. </tr>
  353. </table>
  354. <p><input type="button" value=" ' . $hesklang['ok'] . ' " onclick="Javascript:hesk_saveOptions()" /></p>
  355. ';
  356. break;
  357. default:
  358. die('Invalid type');
  359. }
  360. ?>
  361. <p align="center"><a href="#" onclick="Javascript:window.close()"><?php echo $hesklang['cwin']; ?></a></p>
  362. <p>&nbsp;</p>
  363. </body>
  364. </html>
  365. <?php
  366. exit();
  367. ?>