Advertisement
Guest User

app/extensions/extension_edit.php

a guest
Apr 14th, 2017
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 84.44 KB | None | 0 0
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5.  
  6. The contents of this file are subject to the Mozilla Public License Version
  7. 1.1 (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.mozilla.org/MPL/
  10.  
  11. Software distributed under the License is distributed on an "AS IS" basis,
  12. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. for the specific language governing rights and limitations under the
  14. License.
  15.  
  16. The Original Code is FusionPBX
  17.  
  18. The Initial Developer of the Original Code is
  19. Mark J Crane <markjcrane@fusionpbx.com>
  20. Copyright (C) 2008-2015 All Rights Reserved.
  21.  
  22. Contributor(s):
  23. Mark J Crane <markjcrane@fusionpbx.com>
  24. Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
  25. */
  26.  
  27. //includes
  28. include "root.php";
  29. require_once "resources/require.php";
  30. require_once "resources/check_auth.php";
  31.  
  32. //check permissions
  33. if (permission_exists('extension_add') || permission_exists('extension_edit')) {
  34. //access granted
  35. }
  36. else {
  37. echo "access denied";
  38. exit;
  39. }
  40.  
  41. //detect billing app
  42. $billing_app_exists = file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php");
  43. if ($billing_app_exists) {
  44. require_once "app/billing/resources/functions/currency.php";
  45. require_once "app/billing/resources/functions/rating.php";
  46. }
  47.  
  48. //add multi-lingual support
  49. $language = new text;
  50. $text = $language->get();
  51.  
  52. //set the action as an add or an update
  53. if (isset($_REQUEST["id"])) {
  54. $action = "update";
  55. $extension_uuid = check_str($_REQUEST["id"]);
  56. }
  57. else {
  58. $action = "add";
  59. }
  60.  
  61. //get total extension count from the database, check limit, if defined
  62. if ($action == 'add') {
  63. if ($_SESSION['limit']['extensions']['numeric'] != '') {
  64. $sql = "select count(*) as num_rows from v_extensions where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  65. $prep_statement = $db->prepare($sql);
  66. if ($prep_statement) {
  67. $prep_statement->execute();
  68. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  69. $total_extensions = $row['num_rows'];
  70. }
  71. unset($prep_statement, $row);
  72. if ($total_extensions >= $_SESSION['limit']['extensions']['numeric']) {
  73. $_SESSION['message_mood'] = 'negative';
  74. $_SESSION['message'] = $text['message-maximum_extensions'].' '.$_SESSION['limit']['extensions']['numeric'];
  75. header('Location: extensions.php');
  76. return;
  77. }
  78. }
  79. }
  80.  
  81. //get the http values and set them as php variables
  82. if (count($_POST) > 0) {
  83. //get the values from the HTTP POST and save them as PHP variables
  84. $extension = str_replace(' ','-',check_str($_POST["extension"]));
  85. $number_alias = check_str($_POST["number_alias"]);
  86. $password = check_str($_POST["password"]);
  87.  
  88. // server verification on account code
  89. if (if_group("superadmin")) {
  90. $accountcode = $_POST["accountcode"];
  91. }
  92. elseif (if_group("admin") && $billing_app_exists) {
  93. $sql_accountcode = "SELECT COUNT(*) as count FROM v_billings WHERE domain_uuid = '".$_SESSION['domain_uuid']."' AND type_value='".$_POST["accountcode"]."'";
  94. $prep_statement_accountcode = $db->prepare(check_sql($sql_accountcode));
  95. $prep_statement_accountcode->execute();
  96. $row_accountcode = $prep_statement_accountcode->fetch(PDO::FETCH_ASSOC);
  97. if ($row_accountcode['count'] > 0) {
  98. $accountcode = $_POST["accountcode"];
  99. }
  100. else {
  101. $accountcode = $_SESSION['domain_name'];
  102. }
  103. unset($sql_accountcode, $prep_statement_accountcode, $row_accountcode);
  104. }
  105.  
  106. $effective_caller_id_name = check_str($_POST["effective_caller_id_name"]);
  107. $effective_caller_id_number = check_str($_POST["effective_caller_id_number"]);
  108. $outbound_caller_id_name = check_str($_POST["outbound_caller_id_name"]);
  109. $outbound_caller_id_number = check_str($_POST["outbound_caller_id_number"]);
  110. $emergency_caller_id_name = check_str($_POST["emergency_caller_id_name"]);
  111. $emergency_caller_id_number = check_str($_POST["emergency_caller_id_number"]);
  112. $directory_full_name = check_str($_POST["directory_full_name"]);
  113. $directory_visible = check_str($_POST["directory_visible"]);
  114. $directory_exten_visible = check_str($_POST["directory_exten_visible"]);
  115. $limit_max = check_str($_POST["limit_max"]);
  116. $limit_destination = check_str($_POST["limit_destination"]);
  117. $device_uuid = check_str($_POST["device_uuid"]);
  118. $device_line = check_str($_POST["device_line"]);
  119. $voicemail_password = check_str($_POST["voicemail_password"]);
  120. $voicemail_enabled = check_str($_POST["voicemail_enabled"]);
  121. $voicemail_mail_to = check_str($_POST["voicemail_mail_to"]);
  122. $voicemail_file = check_str($_POST["voicemail_file"]);
  123. $voicemail_local_after_email = check_str($_POST["voicemail_local_after_email"]);
  124. $user_context = check_str($_POST["user_context"]);
  125. $range = check_str($_POST["range"]);
  126. $autogen_users = check_str($_POST["autogen_users"]);
  127. $missed_call_app = check_str($_POST["missed_call_app"]);
  128. $missed_call_data = check_str($_POST["missed_call_data"]);
  129. $toll_allow = check_str($_POST["toll_allow"]);
  130. $call_timeout = check_str($_POST["call_timeout"]);
  131. $call_group = check_str($_POST["call_group"]);
  132. $call_screen_enabled = check_str($_POST["call_screen_enabled"]);
  133. $user_record = check_str($_POST["user_record"]);
  134. $hold_music = check_str($_POST["hold_music"]);
  135. $auth_acl = check_str($_POST["auth_acl"]);
  136. $cidr = check_str($_POST["cidr"]);
  137. $sip_force_contact = check_str($_POST["sip_force_contact"]);
  138. $sip_force_expires = check_str($_POST["sip_force_expires"]);
  139. $nibble_account = check_str($_POST["nibble_account"]);
  140. $mwi_account = check_str($_POST["mwi_account"]);
  141. $sip_bypass_media = check_str($_POST["sip_bypass_media"]);
  142. $absolute_codec_string = check_str($_POST["absolute_codec_string"]);
  143. $force_ping = check_str($_POST["force_ping"]);
  144. $dial_string = check_str($_POST["dial_string"]);
  145. $enabled = check_str($_POST["enabled"]);
  146. $description = check_str($_POST["description"]);
  147. }
  148.  
  149. //delete the user from the v_extension_users
  150. if ($_REQUEST["delete_type"] == "user" && strlen($_REQUEST["delete_uuid"]) > 0 && permission_exists("extension_delete")) {
  151. //set the variables
  152. $extension_uuid = check_str($_REQUEST["id"]);
  153. $user_uuid = check_str($_REQUEST["delete_uuid"]);
  154. //delete the group from the users
  155. $sql = "delete from v_extension_users ";
  156. $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  157. $sql .= "and extension_uuid = '".$extension_uuid."' ";
  158. $sql .= "and user_uuid = '".$user_uuid."' ";
  159. $db->exec(check_sql($sql));
  160. }
  161.  
  162. //delete the line from the v_device_lines
  163. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/devices')) {
  164. if ($_REQUEST["delete_type"] == "device_line" && strlen($_REQUEST["delete_uuid"]) > 0 && permission_exists("extension_delete")) {
  165. //set the variables
  166. $extension_uuid = check_str($_REQUEST["id"]);
  167. $device_line_uuid = check_str($_REQUEST["delete_uuid"]);
  168. //delete device_line
  169. $sql = "delete from v_device_lines ";
  170. $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  171. $sql .= "and device_line_uuid = '$device_line_uuid' ";
  172. $db->exec(check_sql($sql));
  173. unset($sql);
  174. }
  175. }
  176.  
  177. //assign the extension to the user
  178. if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0) {
  179. //set the variables
  180. $user_uuid = check_str($_REQUEST["user_uuid"]);
  181. $extension_uuid = check_str($_REQUEST["id"]);
  182. //assign the user to the extension
  183. $sql_insert = "insert into v_extension_users ";
  184. $sql_insert .= "(";
  185. $sql_insert .= "extension_user_uuid, ";
  186. $sql_insert .= "domain_uuid, ";
  187. $sql_insert .= "extension_uuid, ";
  188. $sql_insert .= "user_uuid ";
  189. $sql_insert .= ")";
  190. $sql_insert .= "values ";
  191. $sql_insert .= "(";
  192. $sql_insert .= "'".uuid()."', ";
  193. $sql_insert .= "'".$_SESSION['domain_uuid']."', ";
  194. $sql_insert .= "'".$extension_uuid."', ";
  195. $sql_insert .= "'".$user_uuid."' ";
  196. $sql_insert .= ")";
  197. $db->exec($sql_insert);
  198. }
  199.  
  200. //assign the line to the device
  201. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/devices')) {
  202. if (strlen($_REQUEST["device_mac_address"]) > 0 && strlen($_REQUEST["id"]) > 0) {
  203.  
  204. //set the variables
  205. $extension_uuid = check_str($_REQUEST["id"]);
  206. $device_uuid= uuid();
  207. $device_line_uuid = uuid();
  208. $device_template = check_str($_REQUEST["device_template"]);
  209. $line_number = check_str($_REQUEST["line_number"]);
  210. $device_mac_address = check_str($_REQUEST["device_mac_address"]);
  211. $device_mac_address = strtolower($device_mac_address);
  212. $device_mac_address = preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address);
  213.  
  214. //set a default line number
  215. if (strlen($line_number) == 0) { $line_number = '1'; }
  216.  
  217. //add the device if it doesn't exist, if it does exist get the device_uuid
  218. $sql = "select device_uuid from v_devices ";
  219. $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  220. $sql .= "and device_mac_address = '$device_mac_address' ";
  221. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  222. $prep_statement = $db->prepare($sql);
  223. if ($prep_statement) {
  224. $prep_statement->execute();
  225. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  226. if (strlen($row['device_uuid']) > 0) {
  227. //device found get the device_uuid
  228. $device_uuid = $row['device_uuid'];
  229.  
  230. //update device template
  231. if (strlen($device_template) > 0) {
  232. $sql = "update v_devices set ";
  233. $sql .= "device_template = '$device_template' ";
  234. $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
  235. $sql .= "and device_uuid = '$device_uuid'";
  236. $db->exec(check_sql($sql));
  237. unset($sql);
  238. }
  239. }
  240. else {
  241. //device not found
  242. $sql_insert = "insert into v_devices ";
  243. $sql_insert .= "(";
  244. $sql_insert .= "device_uuid, ";
  245. $sql_insert .= "domain_uuid, ";
  246. $sql_insert .= "device_mac_address, ";
  247. $sql_insert .= "device_template, ";
  248. $sql_insert .= "device_enabled ";
  249. $sql_insert .= ") ";
  250. $sql_insert .= "values ";
  251. $sql_insert .= "(";
  252. $sql_insert .= "'".$device_uuid."', ";
  253. $sql_insert .= "'".$_SESSION['domain_uuid']."', ";
  254. $sql_insert .= "'".$device_mac_address."', ";
  255. $sql_insert .= "'".$device_template."', ";
  256. $sql_insert .= "'true' ";
  257. $sql_insert .= ")";
  258. //echo $sql_insert."<br />\n";
  259. $db->exec($sql_insert);
  260. }
  261. }
  262.  
  263. //assign the line to the device
  264. $sql_insert = "insert into v_device_lines ";
  265. $sql_insert .= "(";
  266. $sql_insert .= "device_uuid, ";
  267. $sql_insert .= "device_line_uuid, ";
  268. $sql_insert .= "domain_uuid, ";
  269. $sql_insert .= "server_address, ";
  270. $sql_insert .= "display_name, ";
  271. $sql_insert .= "user_id, ";
  272. $sql_insert .= "auth_id, ";
  273. $sql_insert .= "password, ";
  274. $sql_insert .= "line_number, ";
  275. $sql_insert .= "sip_port, ";
  276. $sql_insert .= "sip_transport, ";
  277. $sql_insert .= "register_expires, ";
  278. $sql_insert .= "enabled ";
  279. $sql_insert .= ") ";
  280. $sql_insert .= "values ";
  281. $sql_insert .= "(";
  282. $sql_insert .= "'".$device_uuid."', ";
  283. $sql_insert .= "'".$device_line_uuid."', ";
  284. $sql_insert .= "'".$_SESSION['domain_uuid']."', ";
  285. $sql_insert .= "'".$_SESSION['domain_name']."', ";
  286. $sql_insert .= "'".$extension."', ";
  287. $sql_insert .= "'".$extension."', ";
  288. $sql_insert .= "'".$extension."', ";
  289. $sql_insert .= "'".$password."', ";
  290. $sql_insert .= "'".$line_number."', ";
  291. $sql_insert .= "'".$_SESSION['provision']['line_sip_port']['numeric']."', ";
  292. $sql_insert .= "'".$_SESSION['provision']['line_sip_transport']['text']."', ";
  293. $sql_insert .= "'".$_SESSION['provision']['line_register_expires']['numeric']."', ";
  294. $sql_insert .= "'true' ";
  295. $sql_insert .= ")";
  296. //echo $sql_insert."<br />\n";
  297. $db->exec($sql_insert);
  298. }
  299. }
  300.  
  301. if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
  302.  
  303. //get the id
  304. if ($action == "update") {
  305. $extension_uuid = check_str($_POST["extension_uuid"]);
  306. }
  307.  
  308. //set the domain_uuid
  309. if (permission_exists('extension_domain')) {
  310. $domain_uuid = check_str($_POST["domain_uuid"]);
  311. }
  312. else {
  313. $domain_uuid = $_SESSION['domain_uuid'];
  314. }
  315.  
  316. //check for all required data
  317. $msg = '';
  318. if (strlen($extension) == 0) { $msg .= $text['message-required'].$text['label-extension']."<br>\n"; }
  319. if (permission_exists('extension_enabled')) {
  320. if (strlen($enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
  321. }
  322. //if (strlen($description) == 0) { $msg .= $text['message-required']."Description<br>\n"; }
  323. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  324. require_once "resources/header.php";
  325. require_once "resources/persist_form_var.php";
  326. echo "<div align='center'>\n";
  327. echo "<table><tr><td>\n";
  328. echo $msg."<br />";
  329. echo "</td></tr></table>\n";
  330. persistformvar($_POST);
  331. echo "</div>\n";
  332. require_once "resources/footer.php";
  333. return;
  334. }
  335.  
  336. //set the default user context
  337. if (permission_exists("extension_user_context")) {
  338. //allow a user assigned to super admin to change the user_context
  339. }
  340. else {
  341. //if the user_context was not set then set the default value
  342. $user_context = $_SESSION['domain_name'];
  343. }
  344.  
  345. //prevent users from bypassing extension limit by using range
  346. if ($_SESSION['limit']['extensions']['numeric'] != '') {
  347. if ($total_extensions + $range > $_SESSION['limit']['extensions']['numeric']){
  348. $range = $_SESSION['limit']['extensions']['numeric'] - $total_extensions;
  349. }
  350. }
  351.  
  352. //add or update the database
  353. if ($_POST["persistformvar"] != "true") {
  354. //prep missed call values for db insert/update
  355. switch ($missed_call_app) {
  356. case 'email':
  357. $missed_call_data = str_replace(';',',',$missed_call_data);
  358. $missed_call_data = str_replace(' ','',$missed_call_data);
  359. if (substr_count($missed_call_data, ',') > 0) {
  360. $missed_call_data_array = explode(',', $missed_call_data);
  361. foreach ($missed_call_data_array as $array_index => $email_address) {
  362. if (!valid_email($email_address)) { unset($missed_call_data_array[$array_index]); }
  363. }
  364. //echo "<pre>".print_r($missed_call_data_array, true)."</pre><br><br>";
  365. if (sizeof($missed_call_data_array) > 0) {
  366. $missed_call_data = implode(',', $missed_call_data_array);
  367. }
  368. else {
  369. unset($missed_call_app, $missed_call_data);
  370. }
  371. //echo "Multiple Emails = ".$missed_call_data;
  372. }
  373. else {
  374. //echo "Single Email = ".$missed_call_data."<br>";
  375. if (!valid_email($missed_call_data)) {
  376. //echo "Invalid Email<br><br>";
  377. unset($missed_call_app, $missed_call_data);
  378. }
  379. }
  380. break;
  381. case 'text':
  382. $missed_call_data = str_replace('-','',$missed_call_data);
  383. $missed_call_data = str_replace('.','',$missed_call_data);
  384. $missed_call_data = str_replace('(','',$missed_call_data);
  385. $missed_call_data = str_replace(')','',$missed_call_data);
  386. $missed_call_data = str_replace(' ','',$missed_call_data);
  387. if (!is_numeric($missed_call_data)) { unset($missed_call_app, $missed_call_data); }
  388. break;
  389. }
  390.  
  391. //add the extension to the database
  392. if ($action == "add" && permission_exists('extension_add')) {
  393. $user_email = '';
  394. if ($_SESSION["user"]["unique"]["text"] != "global") {
  395. if ($autogen_users == "true") {
  396. $auto_user = $extension;
  397. for ($i=1; $i<=$range; $i++) {
  398. $user_last_name = $auto_user;
  399. $user_password = generate_password();
  400. user_add($auto_user, $user_password, $user_email);
  401. $generated_users[$i]['username'] = $auto_user;
  402. $generated_users[$i]['password'] = $user_password;
  403. $auto_user++;
  404. }
  405. unset($auto_user);
  406. }
  407. }
  408.  
  409. $j = 0;
  410. for ($i=1; $i<=$range; $i++) {
  411. if (extension_exists($extension)) {
  412. //extension exists
  413. }
  414. else {
  415. //extension does not exist add it
  416. $extension_uuid = uuid();
  417. $password = generate_password();
  418. $sql = "insert into v_extensions ";
  419. $sql .= "(";
  420. $sql .= "domain_uuid, ";
  421. $sql .= "extension_uuid, ";
  422. $sql .= "extension, ";
  423. if (permission_exists('number_alias')) {
  424. $sql .= "number_alias, ";
  425. }
  426. $sql .= "password, ";
  427. if (if_group("superadmin") || (if_group("admin") && $billing_app_exists)) {
  428. $sql .= "accountcode, ";
  429. }
  430. $sql .= "effective_caller_id_name, ";
  431. $sql .= "effective_caller_id_number, ";
  432. $sql .= "outbound_caller_id_name, ";
  433. $sql .= "outbound_caller_id_number, ";
  434. $sql .= "emergency_caller_id_name, ";
  435. $sql .= "emergency_caller_id_number, ";
  436. $sql .= "directory_full_name, ";
  437. $sql .= "directory_visible, ";
  438. $sql .= "directory_exten_visible, ";
  439. $sql .= "limit_max, ";
  440. $sql .= "limit_destination, ";
  441. $sql .= "user_context, ";
  442. if (permission_exists('extension_missed_call')) {
  443. $sql .= "missed_call_app, ";
  444. $sql .= "missed_call_data, ";
  445. }
  446. if (permission_exists('extension_toll')) {
  447. $sql .= "toll_allow, ";
  448. }
  449. if (strlen($call_timeout) > 0) {
  450. $sql .= "call_timeout, ";
  451. }
  452. $sql .= "call_group, ";
  453. $sql .= "call_screen_enabled, ";
  454. $sql .= "user_record, ";
  455. $sql .= "hold_music, ";
  456. $sql .= "auth_acl, ";
  457. $sql .= "cidr, ";
  458. $sql .= "sip_force_contact, ";
  459. if (strlen($sip_force_expires) > 0) {
  460. $sql .= "sip_force_expires, ";
  461. }
  462. if (if_group("superadmin")) {
  463. if (strlen($nibble_account) > 0) {
  464. $sql .= "nibble_account, ";
  465. }
  466. }
  467. if (strlen($mwi_account) > 0) {
  468. $sql .= "mwi_account, ";
  469. }
  470. $sql .= "sip_bypass_media, ";
  471. if (permission_exists('extension_absolute_codec_string')) {
  472. $sql .= "absolute_codec_string, ";
  473. }
  474. if (permission_exists('extension_force_ping')) {
  475. $sql .= "force_ping, ";
  476. }
  477. if (permission_exists('extension_dial_string')) {
  478. $sql .= "dial_string, ";
  479. }
  480. $sql .= "enabled, ";
  481. $sql .= "description ";
  482. $sql .= ")";
  483. $sql .= "values ";
  484. $sql .= "(";
  485. $sql .= "'".$domain_uuid."', ";
  486. $sql .= "'$extension_uuid', ";
  487. $sql .= "'$extension', ";
  488. if (permission_exists('number_alias')) {
  489. $sql .= "'$number_alias', ";
  490. }
  491. $sql .= "'$password', ";
  492. if (if_group("superadmin") || (if_group("admin") && $billing_app_exists)) {
  493. $sql .= "'$accountcode', ";
  494. }
  495. $sql .= "'$effective_caller_id_name', ";
  496. $sql .= "'$effective_caller_id_number', ";
  497. $sql .= "'$outbound_caller_id_name', ";
  498. $sql .= "'$outbound_caller_id_number', ";
  499. $sql .= "'$emergency_caller_id_name', ";
  500. $sql .= "'$emergency_caller_id_number', ";
  501. $sql .= "'$directory_full_name', ";
  502. $sql .= "'$directory_visible', ";
  503. $sql .= "'$directory_exten_visible', ";
  504. $sql .= "'$limit_max', ";
  505. $sql .= "'$limit_destination', ";
  506. $sql .= "'$user_context', ";
  507. if (permission_exists('extension_missed_call')) {
  508. $sql .= "'$missed_call_app', ";
  509. $sql .= "'$missed_call_data', ";
  510. }
  511. if (permission_exists('extension_toll')) {
  512. $sql .= "'$toll_allow', ";
  513. }
  514. if (strlen($call_timeout) > 0) {
  515. $sql .= "'$call_timeout', ";
  516. }
  517. $sql .= "'$call_group', ";
  518. $sql .= "'$call_screen_enabled', ";
  519. $sql .= "'$user_record', ";
  520. $sql .= "'$hold_music', ";
  521. $sql .= "'$auth_acl', ";
  522. $sql .= "'$cidr', ";
  523. $sql .= "'$sip_force_contact', ";
  524. if (strlen($sip_force_expires) > 0) {
  525. $sql .= "'$sip_force_expires', ";
  526. }
  527. if (if_group("superadmin")) {
  528. if (strlen($nibble_account) > 0) {
  529. $sql .= "'$nibble_account', ";
  530. }
  531. }
  532. if (strlen($mwi_account) > 0) {
  533. if (strpos($mwi_account, '@') === false) {
  534. if (count($_SESSION["domains"]) > 1) {
  535. $mwi_account .= "@".$_SESSION['domain_name'];
  536. }
  537. else {
  538. $mwi_account .= "@\$\${domain}";
  539. }
  540. }
  541. $sql .= "'$mwi_account', ";
  542. }
  543. $sql .= "'$sip_bypass_media', ";
  544. if (permission_exists('extension_absolute_codec_string')) {
  545. $sql .= "'$absolute_codec_string', ";
  546. }
  547. if (permission_exists('extension_force_ping')) {
  548. $sql .= "'$force_ping', ";
  549. }
  550. if (permission_exists('extension_dial_string')) {
  551. $sql .= "'$dial_string', ";
  552. }
  553. if (permission_exists('extension_enabled')) {
  554. $sql .= "'$enabled', ";
  555. }
  556. else {
  557. $sql .= "'true', ";
  558. }
  559. $sql .= "'$description' ";
  560. $sql .= ")";
  561.  
  562. $db->exec(check_sql($sql));
  563. unset($sql);
  564. $j++;
  565. }
  566.  
  567. //add or update voicemail
  568. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) {
  569. //set the voicemail password
  570. if (strlen($voicemail_password) == 0) {
  571. $voicemail_password = generate_password($_SESSION['voicemail']['password_length']['numeric'], 1);
  572. }
  573. //voicemail class
  574. $ext = new extension;
  575. $ext->db = $db;
  576. $ext->domain_uuid = $domain_uuid;
  577. $ext->extension = $extension;
  578. if (permission_exists('number_alias')) {
  579. $ext->number_alias = $number_alias;
  580. }
  581. $ext->voicemail_password = $voicemail_password;
  582. $ext->voicemail_mail_to = $voicemail_mail_to;
  583. $ext->voicemail_file = $voicemail_file;
  584. $ext->voicemail_local_after_email = $voicemail_local_after_email;
  585. $ext->voicemail_enabled = $voicemail_enabled;
  586. $ext->description = $description;
  587. $ext->voicemail();
  588. unset($ext);
  589. }
  590. //increment the extension number
  591. $extension++;
  592. }
  593.  
  594. if ($billing_app_exists) {
  595. // Let's bill $j has the number of extensions to bill
  596. $db2 = new database;
  597. $db2->sql = "SELECT currency, billing_uuid, balance FROM v_billings WHERE type_value='$destination_accountcode'";
  598. $db2->result = $db2->execute();
  599. $default_currency = (strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD');
  600. $billing_currency = (strlen($db2->result[0]['currency'])?$db2->result[0]['currency']:$default_currency);
  601. $billing_uuid = $db2->result[0]['billing_uuid'];
  602. $balance = $db2->result[0]['balance'];
  603. unset($db2->sql, $db2->result);
  604.  
  605. $default_extension_pricing = (strlen($_SESSION['billing']['extension.pricing']['numeric'])?$_SESSION['billing']['extension.pricing']['numeric']:'0');
  606. $total_price = $default_extension_pricing * $j;
  607. $total_price_current_currency = currency_convert($total_price,$billing_currency,$default_currency);
  608. $balance -= $total_price_current_currency;
  609.  
  610. $db2->sql = "UPDATE v_billings SET balance = $balance, old_balance = $balance WHERE type_value='$destination_accountcode'";
  611. $db2->result = $db2->execute();
  612. unset($db2->sql, $db2->result);
  613.  
  614. $billing_invoice_uuid = uuid();
  615. $user_uuid = check_str($_SESSION['user_uuid']);
  616. $settled=1;
  617. $mc_gross = -1 * $total_price_current_currency;
  618. $post_payload = serialize($_POST);
  619. $db2->sql = "INSERT INTO v_billing_invoices (billing_invoice_uuid, billing_uuid, payer_uuid, billing_payment_date, settled, amount, debt, post_payload,plugin_used, domain_uuid) VALUES ('$billing_invoice_uuid', '$billing_uuid', '$user_uuid', NOW(), $settled, $mc_gross, $balance, '$post_payload', '$j extension(s) created', '".$_SESSION['domain_uuid']."' )";
  620. $db2->result = $db2->execute();
  621. unset($db2->sql, $db2->result);
  622. }
  623. } //if ($action == "add")
  624.  
  625. //update the database
  626. if ($action == "update" && permission_exists('extension_edit')) {
  627. //generate a password
  628. if (strlen($password) == 0) {
  629. $password = generate_password();
  630. }
  631. //set the voicemail password
  632. if (strlen($voicemail_password) == 0) {
  633. $voicemail_password = generate_password($_SESSION['voicemail']['password_length']['numeric'], 1);
  634. }
  635. //update extensions
  636. $sql = "update v_extensions set ";
  637. if (permission_exists('extension_domain')) {
  638. $sql .= "domain_uuid = '$domain_uuid', ";
  639. }
  640. $sql .= "extension = '$extension', ";
  641. if (permission_exists('number_alias')) {
  642. $sql .= "number_alias = '$number_alias', ";
  643. }
  644. if (permission_exists('extension_password')) {
  645. $sql .= "password = '$password', ";
  646. }
  647. if (if_group("superadmin") || (if_group("admin") && $billing_app_exists)) {
  648. $sql .= "accountcode = '$accountcode', ";
  649. }
  650. $sql .= "effective_caller_id_name = '$effective_caller_id_name', ";
  651. $sql .= "effective_caller_id_number = '$effective_caller_id_number', ";
  652. $sql .= "outbound_caller_id_name = '$outbound_caller_id_name', ";
  653. $sql .= "outbound_caller_id_number = '$outbound_caller_id_number', ";
  654. $sql .= "emergency_caller_id_name = '$emergency_caller_id_name', ";
  655. $sql .= "emergency_caller_id_number = '$emergency_caller_id_number', ";
  656. $sql .= "directory_full_name = '$directory_full_name', ";
  657. $sql .= "directory_visible = '$directory_visible', ";
  658. $sql .= "directory_exten_visible = '$directory_exten_visible', ";
  659. $sql .= "limit_max = '$limit_max', ";
  660. $sql .= "limit_destination = '$limit_destination', ";
  661. if (permission_exists("extension_user_context")) {
  662. $sql .= "user_context = '$user_context', ";
  663. }
  664. if (permission_exists('extension_missed_call')) {
  665. $sql .= "missed_call_app = '$missed_call_app', ";
  666. $sql .= "missed_call_data = '$missed_call_data', ";
  667. }
  668. if (permission_exists('extension_toll')) {
  669. $sql .= "toll_allow = '$toll_allow', ";
  670. }
  671. if (strlen($call_timeout) > 0) {
  672. $sql .= "call_timeout = '$call_timeout', ";
  673. }
  674. $sql .= "call_group = '$call_group', ";
  675. $sql .= "call_screen_enabled = '$call_screen_enabled', ";
  676. if (permission_exists('extension_user_record')) {
  677. $sql .= "user_record = '$user_record', ";
  678. }
  679. $sql .= "hold_music = '$hold_music', ";
  680. $sql .= "auth_acl = '$auth_acl', ";
  681. $sql .= "cidr = '$cidr', ";
  682. $sql .= "sip_force_contact = '$sip_force_contact', ";
  683. if (strlen($sip_force_expires) == 0) {
  684. $sql .= "sip_force_expires = null, ";
  685. }
  686. else {
  687. $sql .= "sip_force_expires = '$sip_force_expires', ";
  688. }
  689. if (if_group("superadmin")) {
  690. if (strlen($nibble_account) == 0) {
  691. $sql .= "nibble_account = null, ";
  692. }
  693. else {
  694. $sql .= "nibble_account = '$nibble_account', ";
  695. }
  696. }
  697. if (strlen($mwi_account) > 0) {
  698. if (strpos($mwi_account, '@') === false) {
  699. if (count($_SESSION["domains"]) > 1) {
  700. $mwi_account .= "@".$_SESSION['domain_name'];
  701. }
  702. else {
  703. $mwi_account .= "@\$\${domain}";
  704. }
  705. }
  706. }
  707. $sql .= "mwi_account = '$mwi_account', ";
  708. $sql .= "sip_bypass_media = '$sip_bypass_media', ";
  709. if (permission_exists('extension_absolute_codec_string')) {
  710. $sql .= "absolute_codec_string = '$absolute_codec_string', ";
  711. }
  712. if (permission_exists('extension_force_ping')) {
  713. $sql .= "force_ping = '$force_ping', ";
  714. }
  715. if (permission_exists('extension_dial_string')) {
  716. $sql .= "dial_string = '$dial_string', ";
  717. }
  718. if (permission_exists('extension_enabled')) {
  719. $sql .= "enabled = '$enabled', ";
  720. }
  721. $sql .= "description = '$description' ";
  722. $sql .= "where extension_uuid = '$extension_uuid' ";
  723. if (!permission_exists('extension_domain')) {
  724. $sql .= "and domain_uuid = '".$domain_uuid."' ";
  725. }
  726. $db->exec(check_sql($sql));
  727. unset($sql);
  728.  
  729. //add or update voicemail
  730. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) {
  731. require_once "app/extensions/resources/classes/extension.php";
  732. $ext = new extension;
  733. $ext->db = $db;
  734. $ext->domain_uuid = $domain_uuid;
  735. $ext->extension = $extension;
  736. if (permission_exists('number_alias')) {
  737. $ext->number_alias = $number_alias;
  738. }
  739. $ext->voicemail_password = $voicemail_password;
  740. $ext->voicemail_mail_to = $voicemail_mail_to;
  741. $ext->voicemail_file = $voicemail_file;
  742. $ext->voicemail_local_after_email = $voicemail_local_after_email;
  743. $ext->voicemail_enabled = $voicemail_enabled;
  744. $ext->description = $description;
  745. $ext->voicemail();
  746. unset($ext);
  747. }
  748.  
  749. //update devices having extension assigned to line(s) with new password
  750. if (permission_exists('extension_password')) {
  751. $sql = "update v_device_lines set ";
  752. $sql .= "password = '".$password."' ";
  753. $sql .= "where domain_uuid = '".$domain_uuid."' ";
  754. $sql .= "and server_address = '".$_SESSION['domain_name']."' ";
  755. $sql .= "and user_id = '".$extension."' ";
  756. $db->exec(check_sql($sql));
  757. unset($sql);
  758. }
  759.  
  760. } //if ($action == "update")
  761.  
  762. //check the permissions
  763. if (permission_exists('extension_add') || permission_exists('extension_edit')) {
  764.  
  765. //synchronize configuration
  766. if (is_writable($_SESSION['switch']['extensions']['dir'])) {
  767. require_once "app/extensions/resources/classes/extension.php";
  768. $ext = new extension;
  769. $ext->xml();
  770. unset($ext);
  771. }
  772.  
  773. //write the provision files
  774. if (strlen($_SESSION['provision']['path']['text']) > 0) {
  775. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/provision')) {
  776. $prov = new provision;
  777. $prov->domain_uuid = $domain_uuid;
  778. $response = $prov->write();
  779. }
  780. }
  781.  
  782. //clear the cache
  783. $cache = new cache;
  784. $cache->delete("directory:".$extension."@".$user_context);
  785. if (permission_exists('number_alias') && strlen($number_alias) > 0) {
  786. $cache->delete("directory:".$number_alias."@".$user_context);
  787. }
  788. }
  789.  
  790. //show the action and redirect the user
  791. if ($action == "add") {
  792. //prepare for alternating the row style
  793. $c = 0;
  794. $row_style["0"] = "row_style0";
  795. $row_style["1"] = "row_style1";
  796.  
  797. //show the action and redirect the user
  798. if (count($generated_users) == 0) {
  799. //action add
  800. $_SESSION["message"] = $text['message-add'];
  801. header("Location: extension_edit.php?id=".$extension_uuid);
  802. }
  803. else {
  804. //auto-generate user with extension as login name
  805. require_once "resources/header.php";
  806. echo "<br />\n";
  807. echo "<div align='center'>\n";
  808. echo " <table width='40%' border='0' cellpadding='0' cellspacing='0'>\n";
  809. echo " <tr>\n";
  810. echo " <td colspan='2'><strong>New User Accounts</strong></td>\n";
  811. echo " </tr>\n";
  812. echo " <tr>\n";
  813. echo " <th>Username</th>\n";
  814. echo " <th>Password</th>\n";
  815. echo " </tr>\n";
  816. foreach($generated_users as $tmp_user){
  817. echo " <tr>\n";
  818. echo " <td valign='top' class='".$row_style[$c]."'>".$tmp_user['username']."</td>\n";
  819. echo " <td valign='top' class='".$row_style[$c]."'>".$tmp_user['password']."</td>\n";
  820. echo " </tr>\n";
  821. }
  822. if ($c==0) { $c=1; } else { $c=0; }
  823. echo " </table>";
  824. echo "</div>\n";
  825. require_once "resources/footer.php";
  826. }
  827. return;
  828. }
  829. if ($action == "update") {
  830. if ($action == "update") {
  831. $_SESSION["message"] = $text['message-update'];
  832. }
  833. else {
  834. $_SESSION["message"] = $text['message-add'];
  835. }
  836. header("Location: extension_edit.php?id=".$extension_uuid);
  837. return;
  838. }
  839. } //if ($_POST["persistformvar"] != "true")
  840. } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
  841.  
  842. //pre-populate the form
  843. if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
  844. $extension_uuid = check_str($_GET["id"]);
  845. $sql = "select * from v_extensions ";
  846. $sql .= "where extension_uuid = '".$extension_uuid."' ";
  847. $sql .= "and domain_uuid = '".$domain_uuid."' ";
  848. $prep_statement = $db->prepare(check_sql($sql));
  849. $prep_statement->execute();
  850. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  851. foreach ($result as &$row) {
  852. $extension = $row["extension"];
  853. $number_alias = $row["number_alias"];
  854. $password = $row["password"];
  855. $accountcode = $row["accountcode"];
  856. $effective_caller_id_name = $row["effective_caller_id_name"];
  857. $effective_caller_id_number = $row["effective_caller_id_number"];
  858. $outbound_caller_id_name = $row["outbound_caller_id_name"];
  859. $outbound_caller_id_number = $row["outbound_caller_id_number"];
  860. $emergency_caller_id_name = $row["emergency_caller_id_name"];
  861. $emergency_caller_id_number = $row["emergency_caller_id_number"];
  862. $directory_full_name = $row["directory_full_name"];
  863. $directory_visible = $row["directory_visible"];
  864. $directory_exten_visible = $row["directory_exten_visible"];
  865. $limit_max = $row["limit_max"];
  866. $limit_destination = $row["limit_destination"];
  867. $user_context = $row["user_context"];
  868. $missed_call_app = $row["missed_call_app"];
  869. $missed_call_data = $row["missed_call_data"];
  870. $toll_allow = $row["toll_allow"];
  871. $call_timeout = $row["call_timeout"];
  872. $call_group = $row["call_group"];
  873. $call_screen_enabled = $row["call_screen_enabled"];
  874. $user_record = $row["user_record"];
  875. $hold_music = $row["hold_music"];
  876. $auth_acl = $row["auth_acl"];
  877. $cidr = $row["cidr"];
  878. $sip_force_contact = $row["sip_force_contact"];
  879. $sip_force_expires = $row["sip_force_expires"];
  880. $nibble_account = $row["nibble_account"];
  881. $mwi_account = $row["mwi_account"];
  882. $sip_bypass_media = $row["sip_bypass_media"];
  883. $absolute_codec_string = $row["absolute_codec_string"];
  884. $force_ping = $row["force_ping"];
  885. $dial_string = $row["dial_string"];
  886. $enabled = $row["enabled"];
  887. $description = $row["description"];
  888. }
  889. unset ($prep_statement);
  890.  
  891. //get the voicemail data
  892. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) {
  893. //get the voicemails
  894. $sql = "select * from v_voicemails ";
  895. $sql .= "where domain_uuid = '".$domain_uuid."' ";
  896. $sql .= "and voicemail_id = '".((is_numeric($number_alias)) ? $number_alias : $extension)."' ";
  897. $prep_statement = $db->prepare(check_sql($sql));
  898. $prep_statement->execute();
  899. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  900. foreach ($result as &$row) {
  901. $voicemail_password = $row["voicemail_password"];
  902. $voicemail_mail_to = $row["voicemail_mail_to"];
  903. $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to);
  904. $voicemail_file = $row["voicemail_file"];
  905. $voicemail_local_after_email = $row["voicemail_local_after_email"];
  906. $voicemail_enabled = $row["voicemail_enabled"];
  907. }
  908. unset ($prep_statement);
  909. //clean the variables
  910. $voicemail_password = str_replace("#", "", $voicemail_password);
  911. $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to);
  912. }
  913.  
  914. }
  915. else {
  916. $voicemail_file = $_SESSION['voicemail']['voicemail_file']['text'];
  917. $voicemail_local_after_email = $_SESSION['voicemail']['keep_local']['boolean'];
  918. }
  919.  
  920. //get the device lines
  921. $sql = "SELECT d.device_mac_address, d.device_template, d.device_description, l.device_line_uuid, l.device_uuid, l.line_number ";
  922. $sql .= "FROM v_device_lines as l, v_devices as d ";
  923. $sql .= "WHERE (l.user_id = '".$extension."' or l.user_id = '".$number_alias."')";
  924. $sql .= "AND l.domain_uuid = '".$domain_uuid."' ";
  925. $sql .= "AND l.device_uuid = d.device_uuid ";
  926. $sql .= "ORDER BY l.line_number, d.device_mac_address asc ";
  927. $prep_statement = $db->prepare(check_sql($sql));
  928. $prep_statement->execute();
  929. $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  930. unset($sql, $prep_statement);
  931.  
  932. //get the devices
  933. $sql = "SELECT * FROM v_devices ";
  934. $sql .= "WHERE domain_uuid = '".$domain_uuid."' ";
  935. $sql .= "ORDER BY device_mac_address asc ";
  936. $prep_statement = $db->prepare(check_sql($sql));
  937. $prep_statement->execute();
  938. $devices = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  939. unset($sql, $prep_statement);
  940.  
  941. //get assigned users
  942. if (is_uuid($extension_uuid)) {
  943. $sql = "SELECT u.username, e.user_uuid FROM v_extension_users as e, v_users as u ";
  944. $sql .= "where e.user_uuid = u.user_uuid ";
  945. $sql .= "and u.user_enabled = 'true' ";
  946. $sql .= "and e.domain_uuid = '".$domain_uuid."' ";
  947. $sql .= "and e.extension_uuid = '".$extension_uuid."' ";
  948. $sql .= "order by u.username asc ";
  949. $prep_statement = $db->prepare(check_sql($sql));
  950. $prep_statement->execute();
  951. $assigned_users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  952. foreach($assigned_users as $field) {
  953. $assigned_user_uuids[] = $field['user_uuid'];
  954. }
  955. unset($sql, $prep_statement);
  956. }
  957.  
  958. //get the users
  959. $sql = "SELECT * FROM v_users ";
  960. $sql .= "where domain_uuid = '".$domain_uuid."' ";
  961. if (isset($assigned_user_uuids)) foreach($assigned_user_uuids as $assigned_user_uuid) {
  962. $sql .= "and user_uuid <> '".$assigned_user_uuid."' ";
  963. }
  964. unset($assigned_user_uuids);
  965. $sql .= "and user_enabled = 'true' ";
  966. $sql .= "order by username asc ";
  967. $prep_statement = $db->prepare(check_sql($sql));
  968. $prep_statement->execute();
  969. $users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  970. unset($sql, $prep_statement);
  971.  
  972. //get the destinations
  973. $sql = "select * from v_destinations ";
  974. $sql .= "where domain_uuid = '".$domain_uuid."' ";
  975. $sql .= "and destination_type = 'inbound' ";
  976. $sql .= "order by destination_number asc ";
  977. $prep_statement = $db->prepare(check_sql($sql));
  978. $prep_statement->execute();
  979. $destinations = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
  980. unset ($sql, $prep_statement);
  981.  
  982. //set the defaults
  983. if (strlen($limit_max) == 0) { $limit_max = '5'; }
  984. if (strlen($limit_destination) == 0) { $limit_destination = 'error/user_busy'; }
  985. if (strlen($call_timeout) == 0) { $call_timeout = '30'; }
  986. if (strlen($call_screen_enabled) == 0) { $call_screen_enabled = 'false'; }
  987.  
  988. //begin the page content
  989. require_once "resources/header.php";
  990. if ($action == "update") {
  991. $document['title'] = $text['title-extension-edit'];
  992. }
  993. elseif ($action == "add") {
  994. $document['title'] = $text['title-extension-add'];
  995. }
  996.  
  997. echo "<script type=\"text/javascript\" language=\"JavaScript\">\n";
  998. echo "\n";
  999. echo "function enable_change(enable_over) {\n";
  1000. echo " var endis;\n";
  1001. echo " endis = !(document.iform.enable.checked || enable_over);\n";
  1002. echo " document.iform.range_from.disabled = endis;\n";
  1003. echo " document.iform.range_to.disabled = endis;\n";
  1004. echo "}\n";
  1005. echo "\n";
  1006. echo "function show_advanced_config() {\n";
  1007. echo " $('#show_advanced_box').slideToggle();\n";
  1008. echo " $('#show_advanced').slideToggle();\n";
  1009. echo "}\n";
  1010. echo "\n";
  1011. echo "function copy_extension() {\n";
  1012. echo " var new_ext = prompt('".$text['message-extension']."');\n";
  1013. echo " if (new_ext != null) {\n";
  1014. echo " if (!isNaN(new_ext)) {\n";
  1015. echo " document.location.href='extension_copy.php?id=".$extension_uuid."&ext=' + new_ext;\n";
  1016. echo " }\n";
  1017. echo " else {\n";
  1018. echo " var new_number_alias = prompt('".$text['message-number_alias']."');\n";
  1019. echo " if (new_number_alias != null) {\n";
  1020. echo " if (!isNaN(new_number_alias)) {\n";
  1021. echo " document.location.href='extension_copy.php?id=".$extension_uuid."&ext=' + new_ext + '&alias=' + new_number_alias;\n";
  1022. echo " }\n";
  1023. echo " }\n";
  1024. echo " }\n";
  1025. echo " }\n";
  1026. echo "}\n";
  1027. echo "</script>";
  1028.  
  1029. echo "<form method='post' name='frm' id='frm' action=''>\n";
  1030. echo "<table width='100%' border='0' cellpdding='0' cellspacing='0'>\n";
  1031. echo "<tr>\n";
  1032. if ($action == "add") {
  1033. echo "<td width='30%' nowrap='nowrap' align='left' valign='top'><b>".$text['header-extension-add']."</b></td>\n";
  1034. }
  1035. if ($action == "update") {
  1036. echo "<td width='30%' nowrap='nowrap' align='left' valign='top'><b>".$text['header-extension-edit']."</b></td>\n";
  1037. }
  1038. echo "<td width='70%' align='right' valign='top'>\n";
  1039. echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='extensions.php'\" value='".$text['button-back']."'>\n";
  1040. if ($action == 'update' && (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb'))) {
  1041. echo " <input type='button' class='btn' alt='".$text['button-call_routing']."' onclick=\"window.location='../calls/call_edit.php?id=".$extension_uuid."';\" value='".$text['button-call_routing']."'>\n";
  1042. }
  1043. if ($action == "update") {
  1044. echo " <input type='button' class='btn' alt='".$text['button-copy']."' onclick=\"copy_extension();\" value='".$text['button-copy']."'>\n";
  1045. }
  1046. echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
  1047. echo " <br /><br />\n";
  1048. echo "</td>\n";
  1049. echo "</tr>\n";
  1050.  
  1051. // Billing
  1052. if ($billing_app_exists) {
  1053. if ($action == "add" && permission_exists('extension_add')) { // only when adding
  1054. echo "<tr>\n";
  1055. echo "<td colspan='2' width='30%' nowrap='nowrap' align='left' valign='top'>\n";
  1056. echo " <center>".$text['label-billing_warning']."</center>\n";
  1057. echo "</td>\n";
  1058. echo "</tr>\n";
  1059. }
  1060. }
  1061. echo "<tr>\n";
  1062. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  1063. echo " ".$text['label-extension']."\n";
  1064. echo "</td>\n";
  1065. echo "<td class='vtable' align='left'>\n";
  1066. echo " <input class='formfld' type='text' name='extension' autocomplete='off' maxlength='255' value=\"$extension\" required='required'>\n";
  1067. echo "<br />\n";
  1068. echo $text['description-extension']."\n";
  1069. echo "</td>\n";
  1070. echo "</tr>\n";
  1071.  
  1072. if (permission_exists('number_alias')) {
  1073. echo "<tr>\n";
  1074. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1075. echo " ".$text['label-number_alias']."\n";
  1076. echo "</td>\n";
  1077. echo "<td class='vtable' align='left'>\n";
  1078. echo " <input class='formfld' type='number' name='number_alias' autocomplete='off' maxlength='255' min='0' step='1' value=\"$number_alias\">\n";
  1079. echo "<br />\n";
  1080. echo $text['description-number_alias']."\n";
  1081. echo "</td>\n";
  1082. echo "</tr>\n";
  1083. }
  1084.  
  1085. if (permission_exists('extension_password') && $action == "update") {
  1086. echo "<tr>\n";
  1087. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  1088. echo " ".$text['label-password']."\n";
  1089. echo "</td>\n";
  1090. echo "<td class='vtable' align='left'>\n";
  1091. echo " <input class='formfld' type='password' name='password' id='password' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='50' value=\"$password\">\n";
  1092. echo " <br />\n";
  1093. echo " ".$text['description-password']."\n";
  1094. echo "</td>\n";
  1095. echo "</tr>\n";
  1096. }
  1097.  
  1098. if ($action == "add") {
  1099. echo "<tr>\n";
  1100. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  1101. echo " ".$text['label-range']."\n";
  1102. echo "</td>\n";
  1103. echo "<td class='vtable' align='left'>\n";
  1104. echo " <select class='formfld' name='range'>\n";
  1105. echo " <option value='1'>1</option>\n";
  1106. echo " <option value='2'>2</option>\n";
  1107. echo " <option value='3'>3</option>\n";
  1108. echo " <option value='4'>4</option>\n";
  1109. echo " <option value='5'>5</option>\n";
  1110. echo " <option value='6'>6</option>\n";
  1111. echo " <option value='7'>7</option>\n";
  1112. echo " <option value='8'>8</option>\n";
  1113. echo " <option value='9'>9</option>\n";
  1114. echo " <option value='10'>10</option>\n";
  1115. echo " <option value='15'>15</option>\n";
  1116. echo " <option value='20'>20</option>\n";
  1117. echo " <option value='25'>25</option>\n";
  1118. echo " <option value='30'>30</option>\n";
  1119. echo " <option value='35'>35</option>\n";
  1120. echo " <option value='40'>40</option>\n";
  1121. echo " <option value='45'>45</option>\n";
  1122. echo " <option value='50'>50</option>\n";
  1123. echo " <option value='75'>75</option>\n";
  1124. echo " <option value='100'>100</option>\n";
  1125. echo " <option value='150'>150</option>\n";
  1126. echo " <option value='200'>200</option>\n";
  1127. echo " <option value='250'>250</option>\n";
  1128. echo " <option value='500'>500</option>\n";
  1129. echo " <option value='750'>750</option>\n";
  1130. echo " <option value='1000'>1000</option>\n";
  1131. echo " <option value='5000'>5000</option>\n";
  1132. echo " </select>\n";
  1133. echo "<br />\n";
  1134. echo $text['description-range']."<br />\n";
  1135. if ($_SESSION["user"]["unique"]["text"] != "global") {
  1136. echo "<input type=\"checkbox\" name=\"autogen_users\" value=\"true\"> ".$text['checkbox-range']."<br>\n";
  1137. }
  1138. echo "</td>\n";
  1139. echo "</tr>\n";
  1140. }
  1141.  
  1142. if ($action == "update") {
  1143. echo " <tr>";
  1144. echo " <td class='vncell' valign='top'>".$text['label-user_list']."</td>";
  1145. echo " <td class='vtable'>";
  1146. if (count($assigned_users) > 0) {
  1147. echo " <table width='30%'>\n";
  1148. foreach($assigned_users as $field) {
  1149. echo " <tr>\n";
  1150. echo " <td class='vtable'><a href='/core/users/usersupdate.php?id=".$field['user_uuid']."'>".$field['username']."</a></td>\n";
  1151. echo " <td>\n";
  1152. echo " <a href='#' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.getElementById('delete_type').value = 'user'; document.getElementById('delete_uuid').value = '".$field['user_uuid']."'; submit_form(); }\" alt='".$text['button-delete']."'>$v_link_label_delete</a>\n";
  1153. //echo " <a href='extension_edit.php?id=".$extension_uuid."&domain_uuid=".$_SESSION['domain_uuid']."&user_uuid=".$field['user_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
  1154. echo " </td>\n";
  1155. echo " </tr>\n";
  1156. }
  1157. echo " </table>\n";
  1158. echo " <br />\n";
  1159. }
  1160.  
  1161. echo " <select name='user_uuid' id='user_uuid' class='formfld' style='width: auto;'>\n";
  1162. echo " <option value=''></option>\n";
  1163. foreach($users as $field) {
  1164. echo " <option value='".$field['user_uuid']."'>".$field['username']."</option>\n";
  1165. }
  1166. echo " </select>";
  1167. echo " <input type='button' class='btn' value=\"".$text['button-add']."\" onclick='submit_form();'>\n";
  1168.  
  1169. echo " <br>\n";
  1170. echo " ".$text['description-user_list']."\n";
  1171. echo " <br />\n";
  1172. echo " </td>";
  1173. echo " </tr>";
  1174. }
  1175.  
  1176. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) {
  1177. echo "<tr>\n";
  1178. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1179. echo " ".$text['label-voicemail_password']."\n";
  1180. echo "</td>\n";
  1181. echo "<td class='vtable' align='left'>\n";
  1182. echo " <input class='formfld' type='text' name='voicemail_password' id='voicemail_password' autocomplete='off' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='255' value='$voicemail_password'>\n";
  1183. echo " <br />\n";
  1184. echo " ".$text['description-voicemail_password']."\n";
  1185. echo "</td>\n";
  1186. echo "</tr>\n";
  1187. }
  1188.  
  1189. if ($action == "update") {
  1190. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/devices')) {
  1191. echo "<tr>\n";
  1192. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1193. echo " ".$text['label-provisioning']."\n";
  1194. echo "</td>\n";
  1195. echo "<td class='vtable' align='left'>\n";
  1196. echo " <input type='hidden' name='device_line_uuid' id='device_line_uuid' value=''>";
  1197. echo " <table>\n";
  1198. echo " <tr>\n";
  1199. echo " <td class='vtable'>\n";
  1200. echo " ".$text['label-line']."&nbsp;\n";
  1201. echo " </td>\n";
  1202. echo " <td class='vtable'>\n";
  1203. echo " ".$text['label-device_mac_address']."&nbsp;\n";
  1204. echo " </td>\n";
  1205. echo " <td class='vtable'>\n";
  1206. echo " ".$text['label-device_template']."&nbsp;\n";
  1207. echo " </td>\n";
  1208.  
  1209. echo " <td>\n";
  1210. //if (permission_exists('device_edit')) {
  1211. // echo " <a href='device_line_edit.php?device_uuid=".$row['device_uuid']."&id=".$row['device_line_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
  1212. //}
  1213. //if (permission_exists('device_delete')) {
  1214. // echo " <a href='device_line_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_line_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
  1215. //}
  1216. echo " </td>\n";
  1217. echo " </tr>\n";
  1218. foreach($device_lines as $row) {
  1219. $device_mac_address = $row['device_mac_address'];
  1220. $device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2);
  1221. echo " <tr>\n";
  1222. echo " <td class='vtable'>".$row['line_number']."</td>\n";
  1223. echo " <td class='vtable'><a href='".PROJECT_PATH."/app/devices/device_edit.php?id=".$row['device_uuid']."'>".$device_mac_address."</a></td>\n";
  1224. echo " <td class='vtable'>".$row['device_template']."&nbsp;</td>\n";
  1225. //echo " <td class='vtable'>".$row['device_description']."&nbsp;</td>\n";
  1226. echo " <td>\n";
  1227. echo " <a href='#' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.getElementById('delete_type').value = 'device_line'; document.getElementById('delete_uuid').value = '".$row['device_line_uuid']."'; submit_form(); }\" alt='".$text['button-delete']."'>$v_link_label_delete</a>\n";
  1228. echo " </td>\n";
  1229. echo " </tr>\n";
  1230. }
  1231.  
  1232. echo " <tr>\n";
  1233. echo " <td class='vtable'>";
  1234. echo " <select id='line_number' name='line_number' class='formfld' style='width: auto;' onchange=\"$onchange\">\n";
  1235. echo " <option value=''></option>\n";
  1236. for ($n = 1; $n <=30; $n++) {
  1237. echo " <option value='".$n."'>".$n."</option>\n";
  1238. }
  1239. echo " </select>\n";
  1240. echo " </td>\n";
  1241.  
  1242. echo " <td class='vtable'>";
  1243. echo " <table border='0' cellpadding='1' cellspacing='0'>\n";
  1244. echo " <tr>\n";
  1245. echo " <td id=\"cell_device_mac_address_1\" nowrap='nowrap'>\n";
  1246. ?>
  1247. <script>
  1248. var Objs;
  1249. function changeToInput_device_mac_address(obj){
  1250. tb=document.createElement('INPUT');
  1251. tb.type='text';
  1252. tb.name=obj.name;
  1253. tb.className='formfld';
  1254. tb.setAttribute('id', 'device_mac_address');
  1255. tb.setAttribute('style', 'width: 80%;');
  1256. tb.setAttribute('pattern', '^([0-9A-Fa-f]{2}[:-]?){5}([0-9A-Fa-f]{2})$');
  1257. tb.value=obj.options[obj.selectedIndex].value;
  1258. document.getElementById('btn_select_to_input_device_mac_address').style.visibility = 'hidden';
  1259. tbb=document.createElement('INPUT');
  1260. tbb.setAttribute('class', 'btn');
  1261. tbb.setAttribute('style', 'margin-left: 4px;');
  1262. tbb.type='button';
  1263. tbb.value=$("<div />").html('&#9665;').text();
  1264. tbb.objs=[obj,tb,tbb];
  1265. tbb.onclick=function(){ replace_device_mac_address(this.objs); }
  1266. obj.parentNode.insertBefore(tb,obj);
  1267. obj.parentNode.insertBefore(tbb,obj);
  1268. obj.parentNode.removeChild(obj);
  1269. replace_device_mac_address(this.objs);
  1270. }
  1271.  
  1272. function replace_device_mac_address(obj){
  1273. obj[2].parentNode.insertBefore(obj[0],obj[2]);
  1274. obj[0].parentNode.removeChild(obj[1]);
  1275. obj[0].parentNode.removeChild(obj[2]);
  1276. document.getElementById('btn_select_to_input_device_mac_address').style.visibility = 'visible';
  1277. }
  1278. </script>
  1279. <?php
  1280. echo " <select id=\"device_mac_address\" name=\"device_mac_address\" class='formfld' style='width: 180px;' onchange='changeToInput_device_mac_address(this);this.style.visibility = \"hidden\";'>\n";
  1281. echo " <option value=''></option>\n";
  1282. if (count($devices) > 0) {
  1283. foreach($devices as $field) {
  1284. if (strlen($field["device_mac_address"]) > 0) {
  1285. if ($field_current_value == $field["device_mac_address"]) {
  1286. echo " <option value=\"".$field["device_mac_address"]."\" selected=\"selected\">".$field["device_mac_address"]."</option>\n";
  1287. }
  1288. else {
  1289. echo " <option value=\"".$field["device_mac_address"]."\">".$field["device_mac_address"]." ".$field['device_model']." ".$field['device_description']."</option>\n";
  1290. }
  1291. }
  1292. }
  1293. }
  1294. echo " </select>\n";
  1295. echo " <input type='button' id='btn_select_to_input_device_mac_address' class='btn' name='' alt='".$text['button-back']."' onclick='changeToInput_device_mac_address(document.getElementById(\"device_mac_address\"));this.style.visibility = \"hidden\";' value='&#9665;'>\n";
  1296. echo " </td>\n";
  1297. echo " </tr>\n";
  1298. echo " </table>\n";
  1299.  
  1300. echo " </td>\n";
  1301. echo " <td class='vtable'>";
  1302. $device = new device;
  1303. $template_dir = $device->get_template_dir();
  1304. echo "<select id='device_template' name='device_template' class='formfld'>\n";
  1305. echo "<option value=''></option>\n";
  1306. if (is_dir($template_dir)) {
  1307. $templates = scandir($template_dir);
  1308. foreach($templates as $dir) {
  1309. if($file != "." && $dir != ".." && $dir[0] != '.') {
  1310. if(is_dir($template_dir . "/" . $dir)) {
  1311. echo "<optgroup label='$dir'>";
  1312. $dh_sub=$template_dir . "/" . $dir;
  1313. if(is_dir($dh_sub)) {
  1314. $templates_sub = scandir($dh_sub);
  1315. foreach($templates_sub as $dir_sub) {
  1316. if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') {
  1317. if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) {
  1318. if ($device_template == $dir."/".$dir_sub) {
  1319. echo "<option value='".$dir."/".$dir_sub."' selected='selected'>".$dir."/".$dir_sub."</option>\n";
  1320. }
  1321. else {
  1322. echo "<option value='".$dir."/".$dir_sub."'>".$dir."/".$dir_sub."</option>\n";
  1323. }
  1324. }
  1325. }
  1326. }
  1327. }
  1328. echo "</optgroup>";
  1329. }
  1330. }
  1331. }
  1332. }
  1333. echo "</select>\n";
  1334. echo " </td>\n";
  1335. echo " <td>\n";
  1336. echo " <input type='button' class='btn' value=\"".$text['button-add']."\" onclick='submit_form();'>\n";
  1337. echo " </td>\n";
  1338. echo " </table>\n";
  1339. echo " <br />\n";
  1340. echo $text['description-provisioning']."\n";
  1341.  
  1342. echo "</td>\n";
  1343. echo "</tr>\n";
  1344. }
  1345. }
  1346.  
  1347. if (if_group("superadmin") || (if_group("admin") && $billing_app_exists)) {
  1348. echo "<tr>\n";
  1349. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1350. echo " ".$text['label-accountcode']."\n";
  1351. echo "</td>\n";
  1352. echo "<td class='vtable' align='left'>\n";
  1353. if ($billing_app_exists) {
  1354. $sql_accountcode = "SELECT type_value FROM v_billings WHERE domain_uuid = '".$domain_uuid."'";
  1355. echo "<select name='accountcode' id='accountcode' class='formfld'>\n";
  1356. $prep_statement_accountcode = $db->prepare(check_sql($sql_accountcode));
  1357. $prep_statement_accountcode->execute();
  1358. $result_accountcode = $prep_statement_accountcode->fetchAll(PDO::FETCH_NAMED);
  1359. foreach ($result_accountcode as &$row_accountcode) {
  1360. $selected = '';
  1361. if (($action == "add") && ($row_accountcode['type_value'] == $_SESSION['domain_name'])){
  1362. $selected='selected="selected"';
  1363. }
  1364. elseif ($row_accountcode['type_value'] == $accountcode){
  1365. $selected='selected="selected"';
  1366. }
  1367. echo "<option value=\"".$row_accountcode['type_value']."\" $selected>".$row_accountcode['type_value']."</option>\n";
  1368. }
  1369. unset($sql_accountcode, $prep_statement_accountcode, $result_accountcode);
  1370. echo "</select>";
  1371. }
  1372. else {
  1373. if ($action == "add") { $accountcode = $_SESSION['domain_name']; }
  1374. echo "<input class='formfld' type='text' name='accountcode' maxlength='255' value=\"".$accountcode."\">\n";
  1375. }
  1376. echo "<br />\n";
  1377. echo $text['description-accountcode']."\n";
  1378. echo "</td>\n";
  1379. echo "</tr>\n";
  1380. }
  1381.  
  1382. echo "<tr>\n";
  1383. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1384. echo " ".$text['label-effective_caller_id_name']."\n";
  1385. echo "</td>\n";
  1386. echo "<td class='vtable' align='left'>\n";
  1387. echo " <input class='formfld' type='text' name='effective_caller_id_name' maxlength='255' value=\"$effective_caller_id_name\">\n";
  1388. echo "<br />\n";
  1389. echo $text['description-effective_caller_id_name']."\n";
  1390. echo "</td>\n";
  1391. echo "</tr>\n";
  1392.  
  1393. echo "<tr>\n";
  1394. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1395. echo " ".$text['label-effective_caller_id_number']."\n";
  1396. echo "</td>\n";
  1397. echo "<td class='vtable' align='left'>\n";
  1398. echo " <input class='formfld' type='text' name='effective_caller_id_number' min='0' step='1' maxlength='255' value=\"$effective_caller_id_number\">\n";
  1399. echo "<br />\n";
  1400. echo $text['description-effective_caller_id_number']."\n";
  1401. echo "</td>\n";
  1402. echo "</tr>\n";
  1403.  
  1404. echo "<tr>\n";
  1405. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1406. echo " ".$text['label-outbound_caller_id_name']."\n";
  1407. echo "</td>\n";
  1408. echo "<td class='vtable' align='left'>\n";
  1409. if (permission_exists('outbound_caller_id_select')) {
  1410. if (count($destinations) > 0) {
  1411. echo " <select name='outbound_caller_id_name' id='outbound_caller_id_name' class='formfld'>\n";
  1412. echo " <option value=''></option>\n";
  1413. foreach ($destinations as &$row) {
  1414. $tmp = $row["destination_caller_id_name"];
  1415. if(strlen($tmp) == 0){
  1416. $tmp = $row["destination_description"];
  1417. }
  1418. if(strlen($tmp) > 0){
  1419. if ($outbound_caller_id_name == $tmp) {
  1420. echo " <option value='".$tmp."' selected='selected'>".$tmp."</option>\n";
  1421. }
  1422. else {
  1423. echo " <option value='".$tmp."'>".$tmp."</option>\n";
  1424. }
  1425. }
  1426. }
  1427. echo " </select>\n";
  1428. echo "<br />\n";
  1429. echo $text['description-outbound_caller_id_name-select']."\n";
  1430. }
  1431. else {
  1432. echo " <input type=\"button\" class=\"btn\" name=\"\" alt=\"".$text['button-add']."\" onclick=\"window.location='".PROJECT_PATH."/app/destinations/destinations.php'\" value='".$text['button-add']."'>\n";
  1433. }
  1434. }
  1435. else {
  1436. echo " <input class='formfld' type='text' name='outbound_caller_id_name' maxlength='255' value=\"$outbound_caller_id_name\">\n";
  1437. echo "<br />\n";
  1438. echo $text['description-outbound_caller_id_name-custom']."\n";
  1439. }
  1440. echo "</td>\n";
  1441. echo "</tr>\n";
  1442.  
  1443. echo "<tr>\n";
  1444. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1445. echo " ".$text['label-outbound_caller_id_number']."\n";
  1446. echo "</td>\n";
  1447. echo "<td class='vtable' align='left'>\n";
  1448. if (permission_exists('outbound_caller_id_select')) {
  1449. if (count($destinations) > 0) {
  1450. echo " <select name='outbound_caller_id_number' id='outbound_caller_id_number' class='formfld'>\n";
  1451. echo " <option value=''></option>\n";
  1452. foreach ($destinations as &$row) {
  1453. $tmp = $row["destination_caller_id_number"];
  1454. if(strlen($tmp) == 0){
  1455. $tmp = $row["destination_number"];
  1456. }
  1457. if(strlen($tmp) > 0){
  1458. if ($outbound_caller_id_number == $tmp) {
  1459. echo " <option value='".$tmp."' selected='selected'>".$tmp."</option>\n";
  1460. }
  1461. else {
  1462. echo " <option value='".$tmp."'>".$tmp."</option>\n";
  1463. }
  1464. }
  1465. }
  1466. echo " </select>\n";
  1467. echo "<br />\n";
  1468. echo $text['description-outbound_caller_id_number-select']."\n";
  1469. }
  1470. else {
  1471. echo " <input type=\"button\" class=\"btn\" name=\"\" alt=\"".$text['button-add']."\" onclick=\"window.location='".PROJECT_PATH."/app/destinations/destinations.php'\" value='".$text['button-add']."'>\n";
  1472. }
  1473. unset ($prep_statement);
  1474. }
  1475. else {
  1476. echo " <input class='formfld' type='text' name='outbound_caller_id_number' maxlength='255' min='0' step='1' value=\"$outbound_caller_id_number\">\n";
  1477. echo "<br />\n";
  1478. echo $text['description-outbound_caller_id_number-custom']."\n";
  1479. }
  1480. echo "</td>\n";
  1481. echo "</tr>\n";
  1482.  
  1483. echo "<tr>\n";
  1484. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1485. echo " ".$text['label-emergency_caller_id_name']."\n";
  1486. echo "</td>\n";
  1487. echo "<td class='vtable' align='left'>\n";
  1488. echo " <input class='formfld' type='text' name='emergency_caller_id_name' maxlength='255' value=\"$emergency_caller_id_name\">\n";
  1489. echo "<br />\n";
  1490. echo $text['description-emergency_caller_id_name']."\n";
  1491. echo "</td>\n";
  1492. echo "</tr>\n";
  1493.  
  1494. echo "<tr>\n";
  1495. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1496. echo " ".$text['label-emergency_caller_id_number']."\n";
  1497. echo "</td>\n";
  1498. echo "<td class='vtable' align='left'>\n";
  1499. echo " <input class='formfld' type='text' name='emergency_caller_id_number' maxlength='255' min='0' step='1' value=\"$emergency_caller_id_number\">\n";
  1500. echo "<br />\n";
  1501. echo $text['description-emergency_caller_id_number']."\n";
  1502. echo "</td>\n";
  1503. echo "</tr>\n";
  1504.  
  1505. echo "<tr>\n";
  1506. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1507. echo " ".$text['label-directory_full_name']."\n";
  1508. echo "</td>\n";
  1509. echo "<td class='vtable' align='left'>\n";
  1510. echo " <input class='formfld' type='text' name='directory_full_name' maxlength='255' value=\"$directory_full_name\">\n";
  1511. echo "<br />\n";
  1512. echo $text['description-directory_full_name']."\n";
  1513. echo "</td>\n";
  1514. echo "</tr>\n";
  1515.  
  1516. echo "<tr>\n";
  1517. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1518. echo " ".$text['label-directory_visible']."\n";
  1519. echo "</td>\n";
  1520. echo "<td class='vtable' align='left'>\n";
  1521. echo " <select class='formfld' name='directory_visible'>\n";
  1522. if ($directory_visible == "true") {
  1523. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  1524. }
  1525. else {
  1526. echo " <option value='true'>".$text['label-true']."</option>\n";
  1527. }
  1528. if ($directory_visible == "false") {
  1529. echo " <option value='false' selected >".$text['label-false']."</option>\n";
  1530. }
  1531. else {
  1532. echo " <option value='false'>".$text['label-false']."</option>\n";
  1533. }
  1534. echo " </select>\n";
  1535. echo "<br />\n";
  1536. echo "<br />\n";
  1537. echo $text['description-directory_visible']."\n";
  1538. echo "</td>\n";
  1539. echo "</tr>\n";
  1540.  
  1541. echo "<tr>\n";
  1542. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1543. echo " ".$text['label-directory_exten_visible']."\n";
  1544. echo "</td>\n";
  1545. echo "<td class='vtable' align='left'>\n";
  1546. echo " <select class='formfld' name='directory_exten_visible'>\n";
  1547. if ($directory_exten_visible == "true") {
  1548. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  1549. }
  1550. else {
  1551. echo " <option value='true'>".$text['label-true']."</option>\n";
  1552. }
  1553. if ($directory_exten_visible == "false") {
  1554. echo " <option value='false' selected >".$text['label-false']."</option>\n";
  1555. }
  1556. else {
  1557. echo " <option value='false'>".$text['label-false']."</option>\n";
  1558. }
  1559. echo " </select>\n";
  1560. echo "<br />\n";
  1561. echo "<br />\n";
  1562. echo $text['description-directory_exten_visible']."\n";
  1563. echo "</td>\n";
  1564. echo "</tr>\n";
  1565.  
  1566. echo "<tr>\n";
  1567. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1568. echo " ".$text['label-limit_max']."\n";
  1569. echo "</td>\n";
  1570. echo "<td class='vtable' align='left'>\n";
  1571. echo " <input class='formfld' type='text' name='limit_max' maxlength='255' value=\"$limit_max\">\n";
  1572. echo "<br />\n";
  1573. echo $text['description-limit_max']."\n";
  1574. echo "</td>\n";
  1575. echo "</tr>\n";
  1576.  
  1577. echo "<tr>\n";
  1578. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1579. echo " ".$text['label-limit_destination']."\n";
  1580. echo "</td>\n";
  1581. echo "<td class='vtable' align='left'>\n";
  1582. echo " <input class='formfld' type='text' name='limit_destination' maxlength='255' value=\"$limit_destination\">\n";
  1583. echo "<br />\n";
  1584. echo $text['description-limit_destination']."\n";
  1585. echo "</td>\n";
  1586. echo "</tr>\n";
  1587.  
  1588. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) {
  1589. echo "<tr>\n";
  1590. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1591. echo " ".$text['label-voicemail_enabled']."\n";
  1592. echo "</td>\n";
  1593. echo "<td class='vtable' align='left'>\n";
  1594. echo " <select class='formfld' name='voicemail_enabled'>\n";
  1595. if ($voicemail_enabled == "true") {
  1596. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  1597. }
  1598. else {
  1599. echo " <option value='true'>".$text['label-true']."</option>\n";
  1600. }
  1601. if ($voicemail_enabled == "false") {
  1602. echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
  1603. }
  1604. else {
  1605. echo " <option value='false'>".$text['label-false']."</option>\n";
  1606. }
  1607. echo " </select>\n";
  1608. echo "<br />\n";
  1609. echo $text['description-voicemail_enabled']."\n";
  1610. echo "</td>\n";
  1611. echo "</tr>\n";
  1612.  
  1613. echo "<tr>\n";
  1614. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1615. echo " ".$text['label-voicemail_mail_to']."\n";
  1616. echo "</td>\n";
  1617. echo "<td class='vtable' align='left'>\n";
  1618. echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='255' value=\"$voicemail_mail_to\">\n";
  1619. echo "<br />\n";
  1620. echo $text['description-voicemail_mail_to']."\n";
  1621. echo "</td>\n";
  1622. echo "</tr>\n";
  1623.  
  1624. echo "<tr>\n";
  1625. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1626. echo " ".$text['label-voicemail_file']."\n";
  1627. echo "</td>\n";
  1628. echo "<td class='vtable' align='left'>\n";
  1629. echo " <select class='formfld' name='voicemail_file' id='voicemail_file' onchange=\"if (this.selectedIndex != 2) { document.getElementById('voicemail_local_after_email').selectedIndex = 0; }\">\n";
  1630. echo " <option value='' ".(($voicemail_file == "listen") ? "selected='selected'" : null).">".$text['option-voicemail_file_listen']."</option>\n";
  1631. echo " <option value='link' ".(($voicemail_file == "link") ? "selected='selected'" : null).">".$text['option-voicemail_file_link']."</option>\n";
  1632. echo " <option value='attach' ".(($voicemail_file == "attach") ? "selected='selected'" : null).">".$text['option-voicemail_file_attach']."</option>\n";
  1633. echo " </select>\n";
  1634. echo "<br />\n";
  1635. echo $text['description-voicemail_file']."\n";
  1636. echo "</td>\n";
  1637. echo "</tr>\n";
  1638.  
  1639. echo "<tr>\n";
  1640. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1641. echo " ".$text['label-voicemail_local_after_email']."\n";
  1642. echo "</td>\n";
  1643. echo "<td class='vtable' align='left'>\n";
  1644. echo " <select class='formfld' name='voicemail_local_after_email' id='voicemail_local_after_email' onchange=\"if (this.selectedIndex == 1) { document.getElementById('voicemail_file').selectedIndex = 2; }\">\n";
  1645. echo " <option value='true' ".(($voicemail_local_after_email == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n";
  1646. echo " <option value='false' ".(($voicemail_local_after_email == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
  1647. echo " </select>\n";
  1648. echo "<br />\n";
  1649. echo $text['description-voicemail_local_after_email']."\n";
  1650. echo "</td>\n";
  1651. echo "</tr>\n";
  1652. }
  1653.  
  1654. if (permission_exists('extension_missed_call')) {
  1655. echo "<tr>\n";
  1656. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1657. echo " ".$text['label-missed_call']."\n";
  1658. echo "</td>\n";
  1659. echo "<td class='vtable' align='left'>\n";
  1660. echo " <select class='formfld' name='missed_call_app' id='missed_call_app' onchange=\"if (this.selectedIndex != 0) { document.getElementById('missed_call_data').style.display = ''; document.getElementById('missed_call_data').focus(); } else { document.getElementById('missed_call_data').style.display='none'; }\">\n";
  1661. echo " <option value=''></option>\n";
  1662. echo " <option value='email' ".(($missed_call_app == "email" && $missed_call_data != '') ? "selected='selected'" : null).">".$text['label-email']."</option>\n";
  1663. //echo " <option value='text' ".(($missed_call_app == "text" && $missed_call_data != '') ? "selected='selected'" : null).">".$text['label-text']."</option>\n";
  1664. //echo " <option value='url' ".(($missed_call_app == "url" && $missed_call_data != '') ? "selected='selected'" : null).">".$text['label-url']."</option>\n";
  1665. echo " </select>\n";
  1666. $missed_call_data = ($missed_call_app == 'text') ? format_phone($missed_call_data) : $missed_call_data;
  1667. echo " <input class='formfld' type='text' name='missed_call_data' id='missed_call_data' maxlength='255' value=\"$missed_call_data\" style='min-width: 200px; width: 200px; ".(($missed_call_app == '' || $missed_call_data == '') ? "display: none;" : null)."'>\n";
  1668. echo "<br />\n";
  1669. echo $text['description-missed_call']."\n";
  1670. echo "</td>\n";
  1671. echo "</tr>\n";
  1672. }
  1673.  
  1674. if (permission_exists('extension_toll')) {
  1675. echo "<tr>\n";
  1676. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1677. echo " ".$text['label-toll_allow']."\n";
  1678. echo "</td>\n";
  1679. echo "<td class='vtable' align='left'>\n";
  1680. if (is_array($_SESSION['toll allow']['name'])) {
  1681. echo " <select class='formfld' name='toll_allow'>\n";
  1682. echo " <option value=''></option>\n";
  1683. foreach ($_SESSION['toll allow']['name'] as $name) {
  1684. if ($_SESSION['call group']['name'] == $call_group) {
  1685. echo " <option value='$name' selected='selected'>$name</option>\n";
  1686. }
  1687. else {
  1688. echo " <option value='$name'>$name</option>\n";
  1689. }
  1690. }
  1691. echo " </select>\n";
  1692. }
  1693. else {
  1694. echo " <input class='formfld' type='text' name='toll_allow' maxlength='255' value=\"$toll_allow\">\n";
  1695. }
  1696. echo "<br />\n";
  1697. echo $text['description-toll_allow']."\n";
  1698. echo "</td>\n";
  1699. echo "</tr>\n";
  1700. }
  1701.  
  1702. echo "<tr>\n";
  1703. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1704. echo " ".$text['label-call_timeout']."\n";
  1705. echo "</td>\n";
  1706. echo "<td class='vtable' align='left'>\n";
  1707. echo " <input class='formfld' type='number' name='call_timeout' maxlength='255' min='1' step='1' value=\"$call_timeout\">\n";
  1708. echo "<br />\n";
  1709. echo $text['description-call_timeout']."\n";
  1710. echo "</td>\n";
  1711. echo "</tr>\n";
  1712.  
  1713. echo "<tr>\n";
  1714. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1715. echo " ".$text['label-call_group']."\n";
  1716. echo "</td>\n";
  1717. echo "<td class='vtable' align='left'>\n";
  1718. if (is_array($_SESSION['call group']['name'])) {
  1719. echo " <select class='formfld' name='call_group'>\n";
  1720. echo " <option value=''></option>\n";
  1721. foreach ($_SESSION['call group']['name'] as $name) {
  1722. if ($_SESSION['call group']['name'] == $call_group) {
  1723. echo " <option value='$name' selected='selected'>$name</option>\n";
  1724. }
  1725. else {
  1726. echo " <option value='$name'>$name</option>\n";
  1727. }
  1728. }
  1729. echo " </select>\n";
  1730. } else {
  1731. echo " <input class='formfld' type='text' name='call_group' maxlength='255' value=\"$call_group\">\n";
  1732. }
  1733. echo "<br />\n";
  1734. echo $text['description-call_group']."\n";
  1735. echo "</td>\n";
  1736. echo "</tr>\n";
  1737.  
  1738. if (permission_exists('extension_call_screen')) {
  1739. echo "<tr>\n";
  1740. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1741. echo " ".$text['label-call_screen_enabled']."\n";
  1742. echo "</td>\n";
  1743. echo "<td class='vtable' align='left'>\n";
  1744. echo " <select class='formfld' name='call_screen_enabled'>\n";
  1745. if ($call_screen_enabled == "true") {
  1746. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  1747. }
  1748. else {
  1749. echo " <option value='true'>".$text['label-true']."</option>\n";
  1750. }
  1751. if ($call_screen_enabled == "false") {
  1752. echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
  1753. }
  1754. else {
  1755. echo " <option value='false'>".$text['label-false']."</option>\n";
  1756. }
  1757. echo " </select>\n";
  1758. echo "<br />\n";
  1759. echo $text['description-call_screen_enabled']."\n";
  1760. echo "</td>\n";
  1761. echo "</tr>\n";
  1762. }
  1763.  
  1764. if (permission_exists('extension_user_record')) {
  1765. echo "<tr>\n";
  1766. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1767. echo " ".$text['label-user_record']."\n";
  1768. echo "</td>\n";
  1769. echo "<td class='vtable' align='left'>\n";
  1770. echo " <select class='formfld' name='user_record'>\n";
  1771. echo " <option value=''>".$text['label-user_record_none']."</option>\n";
  1772. if ($user_record == "all") {
  1773. echo " <option value='all' selected='selected'>".$text['label-user_record_all']."</option>\n";
  1774. }
  1775. else {
  1776. echo " <option value='all'>".$text['label-user_record_all']."</option>\n";
  1777. }
  1778. if ($user_record == "local") {
  1779. echo " <option value='local' selected='selected'>".$text['label-user_record_local']."</option>\n";
  1780. }
  1781. else {
  1782. echo " <option value='local'>".$text['label-user_record_local']."</option>\n";
  1783. }
  1784. if ($user_record == "inbound") {
  1785. echo " <option value='inbound' selected='selected'>".$text['label-user_record_inbound']."</option>\n";
  1786. }
  1787. else {
  1788. echo " <option value='inbound'>".$text['label-user_record_inbound']."</option>\n";
  1789. }
  1790. if ($user_record == "outbound") {
  1791. echo " <option value='outbound' selected='selected'>".$text['label-user_record_outbound']."</option>\n";
  1792. }
  1793. else {
  1794. echo " <option value='outbound'>".$text['label-user_record_outbound']."</option>\n";
  1795. }
  1796. echo " </select>\n";
  1797. echo "<br />\n";
  1798. echo $text['description-user_record']."\n";
  1799. echo "</td>\n";
  1800. echo "</tr>\n";
  1801. }
  1802.  
  1803. if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/music_on_hold')) {
  1804. echo "<tr>\n";
  1805. echo "<td width=\"30%\" class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1806. echo " ".$text['label-hold_music']."\n";
  1807. echo "</td>\n";
  1808. echo "<td width=\"70%\" class='vtable' align='left'>\n";
  1809. require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
  1810. $options = '';
  1811. $moh = new switch_music_on_hold;
  1812. echo $moh->select('hold_music', $hold_music, $options);
  1813. echo " <br />\n";
  1814. echo $text['description-hold_music']."\n";
  1815. echo "</td>\n";
  1816. echo "</tr>\n";
  1817. }
  1818.  
  1819. if (if_group("superadmin")) {
  1820. if (strlen($user_context) == 0) {
  1821. $user_context = $_SESSION['domain_name'];
  1822. }
  1823. echo "<tr>\n";
  1824. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  1825. echo " ".$text['label-user_context']."\n";
  1826. echo "</td>\n";
  1827. echo "<td class='vtable' align='left'>\n";
  1828. echo " <input class='formfld' type='text' name='user_context' maxlength='255' value=\"$user_context\" required='required'>\n";
  1829. echo "<br />\n";
  1830. echo $text['description-user_context']."\n";
  1831. echo "</td>\n";
  1832. echo "</tr>\n";
  1833. }
  1834.  
  1835. //--- begin: show_advanced -----------------------
  1836.  
  1837. echo "<tr>\n";
  1838. echo "<td style='padding: 0px;' colspan='2' class='' valign='top' align='left' nowrap>\n";
  1839.  
  1840. echo " <div id=\"show_advanced_box\">\n";
  1841. echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
  1842. echo " <tr>\n";
  1843. echo " <td width=\"30%\" valign=\"top\" class=\"vncell\">&nbsp;</td>\n";
  1844. echo " <td width=\"70%\" class=\"vtable\">\n";
  1845. echo " <input type=\"button\" class=\"btn\" onClick=\"show_advanced_config()\" value=\"".$text['button-advanced']."\"></input>\n";
  1846. echo " </td>\n";
  1847. echo " </tr>\n";
  1848. echo " </table>\n";
  1849. echo " </div>\n";
  1850.  
  1851. echo " <div id=\"show_advanced\" style=\"display:none\">\n";
  1852. echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
  1853.  
  1854. echo "<tr>\n";
  1855. echo "<td width=\"30%\" class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1856. echo " ".$text['label-auth_acl']."\n";
  1857. echo "</td>\n";
  1858. echo "<td width=\"70%\" class='vtable' align='left'>\n";
  1859. echo " <input class='formfld' type='text' name='auth_acl' maxlength='255' value=\"$auth_acl\">\n";
  1860. echo " <br />\n";
  1861. echo $text['description-auth_acl']."\n";
  1862. echo "</td>\n";
  1863. echo "</tr>\n";
  1864.  
  1865. echo "<tr>\n";
  1866. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1867. echo " ".$text['label-cidr']."\n";
  1868. echo "</td>\n";
  1869. echo "<td class='vtable' align='left'>\n";
  1870. echo " <input class='formfld' type='text' name='cidr' maxlength='255' value=\"$cidr\">\n";
  1871. echo "<br />\n";
  1872. echo $text['description-cidr']."\n";
  1873. echo "</td>\n";
  1874. echo "</tr>\n";
  1875.  
  1876. echo "<tr>\n";
  1877. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1878. echo " ".$text['label-sip_force_contact']."\n";
  1879. echo "</td>\n";
  1880. echo "<td class='vtable' align='left'>\n";
  1881. echo " <select class='formfld' name='sip_force_contact'>\n";
  1882. echo " <option value=''></option>\n";
  1883. switch ($sip_force_contact) {
  1884. case "NDLB-connectile-dysfunction" : $selected[1] = "selected='selected'"; break;
  1885. case "NDLB-connectile-dysfunction-2.0" : $selected[2] = "selected='selected'"; break;
  1886. case "NDLB-tls-connectile-dysfunction" : $selected[3] = "selected='selected'"; break;
  1887. }
  1888. echo " <option value='NDLB-connectile-dysfunction' ".$selected[1].">".$text['label-rewrite_contact_ip_and_port']."</option>\n";
  1889. echo " <option value='NDLB-connectile-dysfunction-2.0' ".$selected[2].">".$text['label-rewrite_contact_ip_and_port_2']."</option>\n";
  1890. echo " <option value='NDLB-tls-connectile-dysfunction' ".$selected[3].">".$text['label-rewrite_tls_contact_port']."</option>\n";
  1891. unset($selected);
  1892. echo " </select>\n";
  1893. echo "<br />\n";
  1894. echo $text['description-sip_force_contact']."\n";
  1895. echo "</td>\n";
  1896. echo "</tr>\n";
  1897.  
  1898. echo "<tr>\n";
  1899. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1900. echo " ".$text['label-sip_force_expires']."\n";
  1901. echo "</td>\n";
  1902. echo "<td class='vtable' align='left'>\n";
  1903. echo " <input class='formfld' type='number' name='sip_force_expires' maxlength='255' min='1' step='1' value=\"$sip_force_expires\">\n";
  1904. echo "<br />\n";
  1905. echo $text['description-sip_force_expires']."\n";
  1906. echo "</td>\n";
  1907. echo "</tr>\n";
  1908.  
  1909. if (if_group("superadmin")) {
  1910. echo "<tr>\n";
  1911. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1912. echo " ".$text['label-nibble_account']."\n";
  1913. echo "</td>\n";
  1914. echo "<td class='vtable' align='left'>\n";
  1915. echo " <input class='formfld' type='text' name='nibble_account' maxlength='255' value=\"$nibble_account\">\n";
  1916. echo "<br />\n";
  1917. echo $text['description-nibble_account']."\n";
  1918. echo "</td>\n";
  1919. echo "</tr>\n";
  1920. }
  1921.  
  1922. echo "<tr>\n";
  1923. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1924. echo " ".$text['label-mwi_account']."\n";
  1925. echo "</td>\n";
  1926. echo "<td class='vtable' align='left'>\n";
  1927. echo " <input class='formfld' type='text' name='mwi_account' maxlength='255' value=\"$mwi_account\">\n";
  1928. echo "<br />\n";
  1929. echo $text['description-mwi_account']."\n";
  1930. echo "</td>\n";
  1931. echo "</tr>\n";
  1932.  
  1933. echo "<tr>\n";
  1934. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1935. echo " ".$text['label-sip_bypass_media']."\n";
  1936. echo "</td>\n";
  1937. echo "<td class='vtable' align='left'>\n";
  1938. echo " <select class='formfld' name='sip_bypass_media'>\n";
  1939. echo " <option value=''></option>\n";
  1940. switch ($sip_bypass_media) {
  1941. case "bypass-media" : $selected[1] = "selected='selected'"; break;
  1942. case "bypass-media-after-bridge" : $selected[2] = "selected='selected'"; break;
  1943. case "proxy-media" : $selected[3] = "selected='selected'"; break;
  1944. }
  1945. echo " <option value='bypass-media' ".$selected[1].">".$text['label-bypass_media']."</option>\n";
  1946. echo " <option value='bypass-media-after-bridge'".$selected[2].">".$text['label-bypass_media_after_bridge']."</option>\n";
  1947. echo " <option value='proxy-media'".$selected[3].">".$text['label-proxy_media']."</option>\n";
  1948. unset($selected);
  1949. echo " </select>\n";
  1950. echo "<br />\n";
  1951. echo $text['description-sip_bypass_media']."\n";
  1952. echo "</td>\n";
  1953. echo "</tr>\n";
  1954.  
  1955. if (permission_exists('extension_absolute_codec_string')) {
  1956. echo "<tr>\n";
  1957. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1958. echo " ".$text['label-absolute_codec_string']."\n";
  1959. echo "</td>\n";
  1960. echo "<td class='vtable' align='left'>\n";
  1961. echo " <input class='formfld' type='text' name='absolute_codec_string' maxlength='255' value=\"$absolute_codec_string\">\n";
  1962. echo "<br />\n";
  1963. echo $text['description-absolute_codec_string']."\n";
  1964. echo "</td>\n";
  1965. echo "</tr>\n";
  1966. }
  1967.  
  1968. if (permission_exists('extension_force_ping')) {
  1969. echo "<tr>\n";
  1970. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  1971. echo " ".$text['label-force_ping']."\n";
  1972. echo "</td>\n";
  1973. echo "<td class='vtable' align='left'>\n";
  1974. echo " <select class='formfld' name='force_ping'>\n";
  1975. if ($force_ping == "") {
  1976. echo " <option value='' selected='selected'></option>\n";
  1977. }
  1978. else {
  1979. echo " <option value=''></option>\n";
  1980. }
  1981. if ($force_ping == "true") {
  1982. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  1983. }
  1984. else {
  1985. echo " <option value='true'>".$text['label-true']."</option>\n";
  1986. }
  1987. if ($force_ping == "false") {
  1988. echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
  1989. }
  1990. else {
  1991. echo " <option value='false'>".$text['label-false']."</option>\n";
  1992. }
  1993. echo " </select>\n";
  1994. echo "<br />\n";
  1995. echo $text['description-force_ping']."\n";
  1996. echo "</td>\n";
  1997. echo "</tr>\n";
  1998. }
  1999.  
  2000. if (permission_exists('extension_domain')) {
  2001. echo "<tr>\n";
  2002. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  2003. echo " ".$text['label-domain']."\n";
  2004. echo "</td>\n";
  2005. echo "<td class='vtable' align='left'>\n";
  2006. echo " <select class='formfld' name='domain_uuid'>\n";
  2007. foreach ($_SESSION['domains'] as $row) {
  2008. if ($row['domain_uuid'] == $domain_uuid) {
  2009. echo " <option value='".$row['domain_uuid']."' selected='selected'>".$row['domain_name']."</option>\n";
  2010. }
  2011. else {
  2012. echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
  2013. }
  2014. }
  2015. echo " </select>\n";
  2016. echo "<br />\n";
  2017. echo $text['description-domain_name']."\n";
  2018. echo "</td>\n";
  2019. echo "</tr>\n";
  2020. }
  2021.  
  2022. if (permission_exists('extension_dial_string')) {
  2023. echo "<tr>\n";
  2024. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  2025. echo " ".$text['label-dial_string']."\n";
  2026. echo "</td>\n";
  2027. echo "<td class='vtable' align='left'>\n";
  2028. echo " <input class='formfld' type='text' name='dial_string' maxlength='4096' value=\"$dial_string\">\n";
  2029. echo "<br />\n";
  2030. echo $text['description-dial_string']."\n";
  2031. echo "</td>\n";
  2032. echo "</tr>\n";
  2033. }
  2034.  
  2035. echo " </table>\n";
  2036. echo " </div>";
  2037.  
  2038. echo "</td>\n";
  2039. echo "</tr>\n";
  2040.  
  2041. //--- end: show_advanced -----------------------
  2042.  
  2043. if (permission_exists('extension_enabled')) {
  2044. echo "<tr>\n";
  2045. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  2046. echo " ".$text['label-enabled']."\n";
  2047. echo "</td>\n";
  2048. echo "<td class='vtable' align='left'>\n";
  2049. echo " <select class='formfld' name='enabled'>\n";
  2050. if ($enabled == "true") {
  2051. echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
  2052. }
  2053. else {
  2054. echo " <option value='true'>".$text['label-true']."</option>\n";
  2055. }
  2056. if ($enabled == "false") {
  2057. echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
  2058. }
  2059. else {
  2060. echo " <option value='false'>".$text['label-false']."</option>\n";
  2061. }
  2062. echo " </select>\n";
  2063. echo "<br />\n";
  2064. echo $text['description-enabled']."\n";
  2065. echo "</td>\n";
  2066. echo "</tr>\n";
  2067. }
  2068.  
  2069. echo "<tr>\n";
  2070. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  2071. echo " ".$text['label-description']."\n";
  2072. echo "</td>\n";
  2073. echo "<td class='vtable' align='left'>\n";
  2074. echo " <textarea class='formfld' name='description' rows='4'>$description</textarea>\n";
  2075. echo "<br />\n";
  2076. echo $text['description-description']."\n";
  2077. echo "</td>\n";
  2078. echo "</tr>\n";
  2079. echo " <tr>\n";
  2080. echo " <td colspan='2' align='right'>\n";
  2081. if ($action == "update") {
  2082. echo " <input type='hidden' name='extension_uuid' value='".$extension_uuid."'>\n";
  2083. echo " <input type='hidden' name='id' id='id' value='".$extension_uuid."'>";
  2084. if (!permission_exists('extension_domain')) {
  2085. echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value='".$_SESSION['domain_uuid']."'>";
  2086. }
  2087. echo " <input type='hidden' name='delete_type' id='delete_type' value=''>";
  2088. echo " <input type='hidden' name='delete_uuid' id='delete_uuid' value=''>";
  2089. }
  2090. echo " <br>";
  2091. echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
  2092. echo " </td>\n";
  2093. echo " </tr>";
  2094. echo "</table>";
  2095. echo "<br><br>";
  2096. echo "</form>";
  2097.  
  2098. echo "<script>\n";
  2099. //capture enter key to submit form
  2100. echo " $(window).keypress(function(event){\n";
  2101. echo " if (event.which == 13) { submit_form(); }\n";
  2102. echo " });\n";
  2103. // convert password fields to
  2104. echo " function submit_form() {\n";
  2105. echo " $('input:password').css('visibility','hidden');\n";
  2106. echo " $('input:password').attr({type:'text'});\n";
  2107. echo " $('form#frm').submit();\n";
  2108. echo " }\n";
  2109. echo "</script>\n";
  2110.  
  2111. //include the footer
  2112. require_once "resources/footer.php";
  2113.  
  2114. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement