active_extensions.php 11 KB

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