active_extensions.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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/pdo.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('active_extension_view')) {
  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. //http get and set variables
  37. $event_type = $_GET['event_type']; //open_window //iframe
  38. if ($event_type=="iframe") {
  39. $iframe_width = $_GET['iframe_width'];
  40. $iframe_height = $_GET['iframe_height'];
  41. $iframe_postition = $_GET['iframe_postition'];
  42. if (strlen($iframe_postition) > 0) { $iframe_postition = 'right'; }
  43. if (strlen($iframe_width) > 0) { $iframe_width = '25%'; }
  44. if (strlen($iframe_height) > 0) { $iframe_height = '100%'; }
  45. }
  46. if (strlen($_GET['url']) > 0) {
  47. $url = $_GET['url'];
  48. }
  49. if (strlen($_GET['rows']) > 0) {
  50. $rows = $_GET['rows'];
  51. }
  52. else {
  53. $rows = 0;
  54. }
  55. $conference_name = trim($_REQUEST["c"]);
  56. $tmp_conference_name = str_replace("_", " ", $conference_name);
  57. require_once "resources/header.php";
  58. ?><script type="text/javascript">
  59. <!--
  60. //declare variables
  61. var previous_uuid_1 = '';
  62. var previous_uuid_2 = '';
  63. var url = '<?php echo $url; ?>';
  64. //define the ajax function
  65. function loadXmlHttp(url, id) {
  66. var f = this;
  67. f.xmlHttp = null;
  68. /*@cc_on @*/ // used here and below, limits try/catch to those IE browsers that both benefit from and support it
  69. /*@if(@_jscript_version >= 5) // prevents errors in old browsers that barf on try/catch & problems in IE if Active X disabled
  70. try {f.ie = window.ActiveXObject}catch(e){f.ie = false;}
  71. @end @*/
  72. if (window.XMLHttpRequest&&!f.ie||/^http/.test(window.location.href))
  73. f.xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari, others, IE 7+ when live - this is the standard method
  74. else if (/(object)|(function)/.test(typeof createRequest))
  75. f.xmlHttp = createRequest(); // ICEBrowser, perhaps others
  76. else {
  77. f.xmlHttp = null;
  78. // Internet Explorer 5 to 6, includes IE 7+ when local //
  79. /*@cc_on @*/
  80. /*@if(@_jscript_version >= 5)
  81. try{f.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  82. catch (e){try{f.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){f.xmlHttp=null;}}
  83. @end @*/
  84. }
  85. if(f.xmlHttp != null){
  86. f.el = document.getElementById(id);
  87. f.xmlHttp.open("GET",url,true);
  88. f.xmlHttp.onreadystatechange = function(){f.stateChanged();};
  89. f.xmlHttp.send(null);
  90. }
  91. }
  92. loadXmlHttp.prototype.stateChanged=function () {
  93. if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
  94. document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
  95. if (document.getElementById('uuid_1')) {
  96. uuid_1 = document.getElementById('uuid_1').innerHTML;
  97. }
  98. else {
  99. uuid_1 = "";
  100. }
  101. if (document.getElementById('direction_1')) {
  102. direction_1 = document.getElementById('direction_1').innerHTML;
  103. }
  104. else {
  105. direction_1 = "";
  106. }
  107. if (document.getElementById('cid_name_1')) {
  108. cid_name_1 = document.getElementById('cid_name_1').innerHTML;
  109. }
  110. else {
  111. cid_name_1 = "";
  112. }
  113. if (document.getElementById('cid_num_1')) {
  114. cid_num_1 = document.getElementById('cid_num_1').innerHTML;
  115. }
  116. else {
  117. cid_num_1 = "";
  118. }
  119. //get the user_status from the database
  120. if (document.getElementById('db_user_status')) {
  121. db_user_status = document.getElementById('db_user_status').innerHTML;
  122. }
  123. if (previous_uuid_1 != uuid_1) {
  124. if (cid_num_1.length > 6) {
  125. var new_url = url;
  126. new_url = new_url.replace("{cid_name}", cid_name_1);
  127. new_url = new_url.replace("{cid_num}", cid_num_1);
  128. new_url = new_url.replace("{uuid}", uuid_1);
  129. previous_uuid_1 = uuid_1;
  130. <?php
  131. if ($event_type=="open_window") {
  132. echo "open_window = window.open(new_url,'width='+window.innerWidth+',height='+window.innerHeight+',left=0px;toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');";
  133. echo "if (window.focus) {open_window.focus()}\n";
  134. }
  135. if ($event_type=="iframe") {
  136. echo "document.getElementById('iframe1').src = new_url;\n";
  137. //iframe_postition
  138. //iframe_width
  139. //iframe_height
  140. }
  141. ?>
  142. }
  143. else {
  144. //hangup or initial page load detected
  145. }
  146. previous_uuid_1 = uuid_1;
  147. }
  148. }
  149. var requestTime = function() {
  150. <?php
  151. echo "var url = 'active_extensions_inc.php?". $_SERVER["QUERY_STRING"]."';\n";
  152. echo "new loadXmlHttp(url, 'ajax_reponse');\n";
  153. if (strlen($_SESSION["ajax_refresh_rate"]) == 0) { $_SESSION["ajax_refresh_rate"] = "900"; }
  154. echo "setInterval(function(){new loadXmlHttp(url, 'ajax_reponse');}, ".$_SESSION["ajax_refresh_rate"].");";
  155. ?>
  156. }
  157. if (window.addEventListener) {
  158. window.addEventListener('load', requestTime, false);
  159. }
  160. else if (window.attachEvent) {
  161. window.attachEvent('onload', requestTime);
  162. }
  163. function send_cmd(url) {
  164. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
  165. xmlhttp=new XMLHttpRequest();
  166. }
  167. else {// code for IE6, IE5
  168. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  169. }
  170. xmlhttp.open("GET",url,false);
  171. xmlhttp.send(null);
  172. document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;
  173. }
  174. var record_count = 0;
  175. var cmd;
  176. var destination;
  177. // -->
  178. </script>
  179. <?php
  180. //get the user status when the page loads
  181. $sql = "select * from v_users ";
  182. $sql .= "where domain_uuid = :domain_uuid ";
  183. $sql .= "and username = :username ";
  184. $sql .= "and user_enabled = 'true' ";
  185. $parameters['domain_uuid'] = $domain_uuid;
  186. $parameters['username'] = $_SESSION['username'];
  187. $database = new database;
  188. $row = $database->select($sql, $parameters ?? null, 'row');
  189. $user_status = $row["user_status"] ?? null;
  190. unset($parameters);
  191. echo "<div align='center'>";
  192. echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
  193. echo " <tr>\n";
  194. echo " <td align='left' colspan='2' nowrap='nowrap'>\n";
  195. echo " <b>".$text['title-2']."</b><br>\n";
  196. echo " </td>\n";
  197. /*
  198. if ($_SESSION['user_status_display'] == "false") {
  199. //hide the user_status when it is set to false
  200. }
  201. else {
  202. echo " <td class='' width='40%'>\n";
  203. echo " &nbsp;";
  204. echo " </td>\n";
  205. echo " <td class='' valign='bottom' align='right' style='width:200px' nowrap='nowrap'>\n";
  206. //status list
  207. echo " &nbsp;";
  208. echo " <strong>".$text['label-status']."</strong>&nbsp;\n";
  209. $cmd = "'calls_exec.php?action=user_status&data='+this.value+'";
  210. $cmd .= "&cmd=callcenter_config+agent+set+status+".$_SESSION['username']."@".$_SESSION['domain_name']."+'+this.value";
  211. echo " <select id='agent_status' name='agent_status' class='formfld' style='width:125px' nowrap='nowrap' onchange=\"send_cmd($cmd);\">\n";
  212. echo " <option value=' '></option>\n";
  213. if ($user_status == "Available") {
  214. echo " <option value='Available' selected='selected'>".$text['check-available-status']."</option>\n";
  215. }
  216. else {
  217. echo " <option value='Available'>".$text['check-available-status']."</option>\n";
  218. }
  219. if ($user_status == "Available (On Demand)") {
  220. echo " <option value='Available_On_Demand' selected='selected'>".$text['check-available-on-demand-status']."</option>\n";
  221. }
  222. else {
  223. echo " <option value='Available_On_Demand'>".$text['check-available-on-demand-status']."</option>\n";
  224. }
  225. if ($user_status == "Logged Out") {
  226. echo " <option value='Logged_Out' selected='selected'>".$text['check-loggedout-status']."</option>\n";
  227. }
  228. else {
  229. echo " <option value='Logged_Out'>".$text['check-loggedout-status']."</option>\n";
  230. }
  231. if ($user_status == "On Break") {
  232. echo " <option value='On_Break' selected='selected'>".$text['check-onbreak-status']."</option>\n";
  233. }
  234. else {
  235. echo " <option value='On_Break'>".$text['check-onbreak-status']."</option>\n";
  236. }
  237. if ($user_status == "Do Not Disturb") {
  238. echo " <option value='Do_Not_Disturb' selected='selected'>".$text['check-do-not-disturb-status']."</option>\n";
  239. }
  240. else {
  241. echo " <option value='Do_Not_Disturb'>".$text['check-do-not-disturb-status']."</option>\n";
  242. }
  243. echo " </select>\n";
  244. echo " </td>\n";
  245. }
  246. */
  247. echo " <td align='right' nowrap='nowrap'>\n";
  248. echo " &nbsp;";
  249. //echo " <strong>".$text['label-transfer']."</strong>\n";
  250. //echo " <input type=\"text\" id=\"form_value\" name=\"form_value\" class='formfld' style='width:125px'/>\n";
  251. echo " </td>\n";
  252. echo " </tr>\n";
  253. echo " <tr>\n";
  254. echo " <td align='left' colspan='99'>\n";
  255. echo " ".$text['description-2']."\n";
  256. echo " </td>\n";
  257. echo " </tr>\n";
  258. echo "</table>\n";
  259. echo "<div id=\"url\"></div>\n";
  260. echo "<br />\n";
  261. echo "<div class='card'>\n";
  262. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  263. echo " <tr class='border'>\n";
  264. if ($event_type=="iframe") {
  265. echo " <td align=\"left\" width='".escape($iframe_width)."'>\n";
  266. }
  267. else {
  268. echo " <td align=\"left\" width='100%'>\n";
  269. }
  270. echo " <div id=\"ajax_reponse\"></div>\n";
  271. echo " <div id=\"time_stamp\" style=\"visibility:hidden\">".date('Y-m-d-s')."</div>\n";
  272. echo " </td>\n";
  273. if ($event_type=="iframe") {
  274. echo "</td>\n";
  275. echo "<td width='".escape($iframe_width)."' height='".escape($iframe_height)."'>\n";
  276. echo " <iframe src ='$url' width='100%' id='iframe1' height='100%' frameborder=0>\n";
  277. echo " <p>Your browser does not support iframes.</p>\n";
  278. echo " </iframe>\n";
  279. echo "</td>\n";
  280. }
  281. echo " </tr>";
  282. echo "</table>";
  283. echo "</div>\n";
  284. echo "</div>\n";
  285. echo "<script type=\"text/javascript\">\n";
  286. echo "<!--\n";
  287. echo "function get_transfer_cmd(uuid) {\n";
  288. echo " destination = document.getElementById('form_value').value;\n";
  289. echo " if (destination.length > 1) { \n";
  290. echo " cmd = \"uuid_transfer \"+uuid+\" -bleg \"+destination+\" xml ".$_SESSION['user_context']."\";\n";
  291. echo " }\n";
  292. echo " else {\n";
  293. echo " cmd = '';\n";
  294. echo " alert(\"Please provide a number to transfer the call to.\");\n";
  295. echo " }\n";
  296. echo " return escape(cmd);\n";
  297. echo "}\n";
  298. echo "\n";
  299. echo "function get_park_cmd(uuid) {\n";
  300. echo " cmd = \"uuid_transfer \"+uuid+\" -bleg *6000 xml ".$_SESSION['user_context']."\";\n";
  301. echo " return escape(cmd);\n";
  302. echo "}\n";
  303. echo "\n";
  304. echo "function get_record_cmd(uuid, prefix, name) {\n";
  305. echo " cmd = \"uuid_record \"+uuid+\" start ".$_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\";\n";
  306. echo " return escape(cmd);\n";
  307. echo "}\n";
  308. echo "-->\n";
  309. echo "</script>\n";
  310. require_once "resources/footer.php";