voicemail_msgs_password.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('voicemail_edit')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //add multi-lingual support
  32. $language = new text;
  33. $text = $language->get();
  34. //set the action as an add or update
  35. if (isset($_REQUEST["id"])) {
  36. $action = "update";
  37. $extension_uuid = check_str($_REQUEST["id"]);
  38. }
  39. //deny the user if not assigned to this mailboxes
  40. $sql = "";
  41. $sql .= " select * from v_extensions ";
  42. $sql .= "where domain_uuid = '$domain_uuid' ";
  43. $sql .= "and extension_uuid = '$extension_uuid'";
  44. if (!(if_group("admin") || if_group("superadmin"))) {
  45. if (count($_SESSION['user']['extension']) > 0) {
  46. $sql .= "and (";
  47. $x = 0;
  48. foreach($_SESSION['user']['extension'] as $row) {
  49. if ($x > 0) { $sql .= "or "; }
  50. $sql .= "extension = '".$row['user']."' ";
  51. $x++;
  52. }
  53. $sql .= ")";
  54. }
  55. else {
  56. //hide any results when a user has not been assigned an extension
  57. $sql .= "and extension = 'disabled' ";
  58. }
  59. }
  60. $prep_statement = $db->prepare(check_sql($sql));
  61. $prep_statement->execute();
  62. $v_mailboxes = '';
  63. $x = 0;
  64. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  65. foreach ($result as &$row) {
  66. $x++;
  67. }
  68. unset ($prep_statement);
  69. if ($x == 0) {
  70. //user has not been assigned to this account
  71. echo "access denied";
  72. exit;
  73. }
  74. //get the http post variables
  75. if (count($_POST)>0) {
  76. //$domain_uuid = check_str($_POST["domain_uuid"]);
  77. $extension = check_str($_POST["extension"]);
  78. $password = check_str($_POST["password"]);
  79. $mailbox = check_str($_POST["mailbox"]);
  80. $vm_password = check_str($_POST["vm_password"]);
  81. $accountcode = check_str($_POST["accountcode"]);
  82. $effective_caller_id_name = check_str($_POST["effective_caller_id_name"]);
  83. $effective_caller_id_number = check_str($_POST["effective_caller_id_number"]);
  84. $outbound_caller_id_name = check_str($_POST["outbound_caller_id_name"]);
  85. $outbound_caller_id_number = check_str($_POST["outbound_caller_id_number"]);
  86. $vm_enabled = check_str($_POST["vm_enabled"]);
  87. $vm_mailto = check_str($_POST["vm_mailto"]);
  88. $vm_attach_file = check_str($_POST["vm_attach_file"]);
  89. $vm_keep_local_after_email = check_str($_POST["vm_keep_local_after_email"]);
  90. $user_context = check_str($_POST["user_context"]);
  91. $call_group = check_str($_POST["call_group"]);
  92. $auth_acl = check_str($_POST["auth_acl"]);
  93. $cidr = check_str($_POST["cidr"]);
  94. $sip_force_contact = check_str($_POST["sip_force_contact"]);
  95. $enabled = check_str($_POST["enabled"]);
  96. $description = check_str($_POST["description"]);
  97. }
  98. if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
  99. $msg = '';
  100. if ($action == "update") {
  101. $extension_uuid = check_str($_POST["extension_uuid"]);
  102. }
  103. //check for all required data
  104. //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
  105. //if (strlen($extension) == 0) { $msg .= "Please provide: Extension<br>\n"; }
  106. //if (strlen($password) == 0) { $msg .= "Please provide: Password<br>\n"; }
  107. //if (strlen($mailbox) == 0) { $msg .= "Please provide: Mailbox<br>\n"; }
  108. if (strlen($vm_password) == 0) { $msg .= "".$text['confirm-password']."<br>\n"; }
  109. //if (strlen($accountcode) == 0) { $msg .= "Please provide: Account Code<br>\n"; }
  110. //if (strlen($effective_caller_id_name) == 0) { $msg .= "Please provide: Effective Caller ID Name<br>\n"; }
  111. //if (strlen($effective_caller_id_number) == 0) { $msg .= "Please provide: Effective Caller ID Number<br>\n"; }
  112. //if (strlen($outbound_caller_id_name) == 0) { $msg .= "Please provide: Outbound Caller ID Name<br>\n"; }
  113. //if (strlen($outbound_caller_id_number) == 0) { $msg .= "Please provide: Outbound Caller ID Number<br>\n"; }
  114. //if (strlen($vm_enabled) == 0) { $msg .= "Please provide: Voicemail Enabled<br>\n"; }
  115. //if (strlen($vm_mailto) == 0) { $msg .= "Please provide: Voicemail Mail To<br>\n"; }
  116. //if (strlen($vm_attach_file) == 0) { $msg .= "Please provide: Voicemail Attach File<br>\n"; }
  117. //if (strlen($vm_keep_local_after_email) == 0) { $msg .= "Please provide: VM Keep Local After Email<br>\n"; }
  118. //if (strlen($user_context) == 0) { $msg .= "Please provide: User Context<br>\n"; }
  119. //if (strlen($call_group) == 0) { $msg .= "Please provide: Call Group<br>\n"; }
  120. //if (strlen($auth_acl) == 0) { $msg .= "Please provide: Auth ACL<br>\n"; }
  121. //if (strlen($cidr) == 0) { $msg .= "Please provide: CIDR<br>\n"; }
  122. //if (strlen($sip_force_contact) == 0) { $msg .= "Please provide: SIP Force Contact<br>\n"; }
  123. //if (strlen($enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
  124. //if (strlen($description) == 0) { $msg .= "Please provide: Description<br>\n"; }
  125. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  126. require_once "resources/header.php";
  127. require_once "resources/persist_form_var.php";
  128. echo "<div align='center'>\n";
  129. echo "<table><tr><td>\n";
  130. echo $msg."<br />";
  131. echo "</td></tr></table>\n";
  132. persistformvar($_POST);
  133. echo "</div>\n";
  134. require_once "resources/footer.php";
  135. return;
  136. }
  137. //add or update the database
  138. if ($_POST["persistformvar"] != "true") {
  139. if ($action == "update") {
  140. $sql = "update v_extensions set ";
  141. //$sql .= "extension = '$extension', ";
  142. //$sql .= "password = '$password', ";
  143. //$sql .= "mailbox = '$mailbox', ";
  144. $sql .= "vm_password = '#$vm_password', ";
  145. //$sql .= "accountcode = '$accountcode', ";
  146. //$sql .= "effective_caller_id_name = '$effective_caller_id_name', ";
  147. //$sql .= "effective_caller_id_number = '$effective_caller_id_number', ";
  148. //$sql .= "outbound_caller_id_name = '$outbound_caller_id_name', ";
  149. //$sql .= "outbound_caller_id_number = '$outbound_caller_id_number', ";
  150. $sql .= "vm_enabled = '$vm_enabled', ";
  151. $sql .= "vm_mailto = '$vm_mailto', ";
  152. $sql .= "vm_attach_file = '$vm_attach_file', ";
  153. $sql .= "vm_keep_local_after_email = '$vm_keep_local_after_email' ";
  154. //$sql .= "user_context = '$user_context', ";
  155. //$sql .= "call_group = '$call_group', ";
  156. //$sql .= "auth_acl = '$auth_acl', ";
  157. //$sql .= "cidr = '$cidr', ";
  158. //$sql .= "sip_force_contact = '$sip_force_contact', ";
  159. //$sql .= "enabled = '$enabled', ";
  160. //$sql .= "description = '$description' ";
  161. $sql .= "where domain_uuid = '$domain_uuid' ";
  162. $sql .= "and extension_uuid = '$extension_uuid'";
  163. $db->exec(check_sql($sql));
  164. unset($sql);
  165. //syncrhonize configuration
  166. save_extension_xml();
  167. //apply settings reminder
  168. $_SESSION["reload_xml"] = true;
  169. //redirect the user
  170. require_once "resources/header.php";
  171. echo "<meta http-equiv=\"refresh\" content=\"2;url=voicemail_msgs.php\">\n";
  172. echo "<div align='center'>\n";
  173. echo "".$text['confirm-update']."\n";
  174. echo "</div>\n";
  175. require_once "resources/footer.php";
  176. return;
  177. } //if ($action == "update")
  178. } //if ($_POST["persistformvar"] != "true")
  179. } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
  180. //pre-populate the form
  181. if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
  182. $extension_uuid = $_GET["id"];
  183. $sql = "";
  184. $sql .= "select * from v_extensions ";
  185. $sql .= "where domain_uuid = '$domain_uuid' ";
  186. $sql .= "and extension_uuid = '$extension_uuid' ";
  187. $prep_statement = $db->prepare(check_sql($sql));
  188. $prep_statement->execute();
  189. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  190. foreach ($result as &$row) {
  191. $domain_uuid = $row["domain_uuid"];
  192. $extension = $row["extension"];
  193. $password = $row["password"];
  194. $mailbox = $row["mailbox"];
  195. $vm_password = $row["vm_password"];
  196. $vm_password = str_replace("#", "", $vm_password); //preserves leading zeros
  197. $accountcode = $row["accountcode"];
  198. $effective_caller_id_name = $row["effective_caller_id_name"];
  199. $effective_caller_id_number = $row["effective_caller_id_number"];
  200. $outbound_caller_id_name = $row["outbound_caller_id_name"];
  201. $outbound_caller_id_number = $row["outbound_caller_id_number"];
  202. $vm_enabled = $row["vm_enabled"];
  203. $vm_mailto = $row["vm_mailto"];
  204. $vm_attach_file = $row["vm_attach_file"];
  205. $vm_keep_local_after_email = $row["vm_keep_local_after_email"];
  206. $user_context = $row["user_context"];
  207. $call_group = $row["call_group"];
  208. $auth_acl = $row["auth_acl"];
  209. $cidr = $row["cidr"];
  210. $sip_force_contact = $row["sip_force_contact"];
  211. $enabled = $row["enabled"];
  212. $description = $row["description"];
  213. break; //limit to 1 row
  214. }
  215. unset ($prep_statement);
  216. }
  217. //show the header
  218. require_once "resources/header.php";
  219. //show the content
  220. echo "<script type=\"text/javascript\" language=\"JavaScript\">\n";
  221. echo "\n";
  222. echo "function enable_change(enable_over) {\n";
  223. echo " var endis;\n";
  224. echo " endis = !(document.iform.enable.checked || enable_over);\n";
  225. echo " document.iform.range_from.disabled = endis;\n";
  226. echo " document.iform.range_to.disabled = endis;\n";
  227. echo "}\n";
  228. echo "\n";
  229. echo "function show_advanced_config() {\n";
  230. echo " document.getElementById(\"show_advanced_box\").innerHTML='';\n";
  231. echo " aodiv = document.getElementById('show_advanced');\n";
  232. echo " aodiv.style.display = \"block\";\n";
  233. echo "}\n";
  234. echo "\n";
  235. echo "function hide_advanced_config() {\n";
  236. echo " document.getElementById(\"show_advanced_box\").innerHTML='';\n";
  237. echo " aodiv = document.getElementById('show_advanced');\n";
  238. echo " aodiv.style.display = \"block\";\n";
  239. echo "}\n";
  240. echo "</script>";
  241. echo "<div align='center'>";
  242. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  243. echo "<tr class=''>\n";
  244. echo " <td align=\"left\">\n";
  245. echo " <br>";
  246. echo "<form method='post' name='frm' action=''>\n";
  247. echo "<div align='center'>\n";
  248. echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  249. echo "<tr>\n";
  250. echo " <td width='30%' nowrap valign='top' align='left'><b>".$text['label-voicemail']." $extension</b></td>\n";
  251. echo " <td width='70%' align='right' valign='top'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='voicemail_msgs.php'\" value='".$text['button-back']."'><br /><br /></td>\n";
  252. echo "</tr>\n";
  253. echo "<tr>\n";
  254. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  255. echo " ".$text['label-password'].":\n";
  256. echo "</td>\n";
  257. echo "<td class='vtable' align='left'>\n";
  258. echo " <input class='formfld' type='password' name='vm_password' id='password' onfocus=\"document.getElementById('show_password').innerHTML = 'Password: '+document.getElementById('password').value;\" autocomplete='off' maxlength='50' value=\"$vm_password\">\n";
  259. echo "<br />\n";
  260. echo "<span onclick=\"document.getElementById('show_password').innerHTML = ''\">".$text['description-password']." </span><span id='show_password'></span>\n";
  261. echo "</td>\n";
  262. echo "</tr>\n";
  263. //echo "<tr>\n";
  264. //echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  265. //echo " Effective Caller ID Name:\n";
  266. //echo "</td>\n";
  267. //echo "<td class='vtable' align='left'>\n";
  268. //echo " <input class='formfld' type='text' name='effective_caller_id_name' maxlength='255' value=\"$effective_caller_id_name\">\n";
  269. //echo "<br />\n";
  270. //echo "Enter the effective caller id name here.\n";
  271. //echo "</td>\n";
  272. //echo "</tr>\n";
  273. //echo "<tr>\n";
  274. //echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  275. //echo " Effective Caller ID Number:\n";
  276. //echo "</td>\n";
  277. //echo "<td class='vtable' align='left'>\n";
  278. //echo " <input class='formfld' type='text' name='effective_caller_id_number' maxlength='255' value=\"$effective_caller_id_number\">\n";
  279. //echo "<br />\n";
  280. //echo "Enter the effective caller id number here.\n";
  281. //echo "</td>\n";
  282. //echo "</tr>\n";
  283. echo "<tr>\n";
  284. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  285. echo " ".$text['label-enabled'].":\n";
  286. echo "</td>\n";
  287. echo "<td class='vtable' align='left'>\n";
  288. echo " <select class='formfld' name='vm_enabled'>\n";
  289. echo " <option value=''></option>\n";
  290. if ($vm_enabled == "true") {
  291. echo " <option value='true' selected='selected'>true</option>\n";
  292. }
  293. else {
  294. echo " <option value='true'>true</option>\n";
  295. }
  296. if ($vm_enabled == "false") {
  297. echo " <option value='false' selected='selected'>false</option>\n";
  298. }
  299. else {
  300. echo " <option value='false'>false</option>\n";
  301. }
  302. echo " </select>\n";
  303. echo "<br />\n";
  304. echo " ".$text['description-voicemail-enable']."\n";
  305. echo "</td>\n";
  306. echo "</tr>\n";
  307. echo "<tr>\n";
  308. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  309. echo " ".$text['label-mail'].":\n";
  310. echo "</td>\n";
  311. echo "<td class='vtable' align='left'>\n";
  312. echo " <input class='formfld' type='text' name='vm_mailto' maxlength='255' value=\"$vm_mailto\">\n";
  313. echo "<br />\n";
  314. echo "".$text['description-email']."\n";
  315. echo "</td>\n";
  316. echo "</tr>\n";
  317. echo "<tr>\n";
  318. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  319. echo " ".$text['label-attach'].":\n";
  320. echo "</td>\n";
  321. echo "<td class='vtable' align='left'>\n";
  322. echo " <select class='formfld' name='vm_attach_file'>\n";
  323. echo " <option value=''></option>\n";
  324. if ($vm_attach_file == "true") {
  325. echo " <option value='true' selected='selected' >true</option>\n";
  326. }
  327. else {
  328. echo " <option value='true'>true</option>\n";
  329. }
  330. if ($vm_attach_file == "false") {
  331. echo " <option value='false' selected='selected' >false</option>\n";
  332. }
  333. else {
  334. echo " <option value='false'>false</option>\n";
  335. }
  336. echo " </select>\n";
  337. echo "<br />\n";
  338. echo "".$text['description-email-attachment']."\n";
  339. echo "</td>\n";
  340. echo "</tr>\n";
  341. echo "<tr>\n";
  342. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  343. echo " ".$text['label-vm'].":\n";
  344. echo "</td>\n";
  345. echo "<td class='vtable' align='left'>\n";
  346. echo " <select class='formfld' name='vm_keep_local_after_email'>\n";
  347. echo " <option value=''></option>\n";
  348. if ($vm_keep_local_after_email == "true") {
  349. echo " <option value='true' selected='selected' >true</option>\n";
  350. }
  351. else {
  352. echo " <option value='true'>true</option>\n";
  353. }
  354. if ($vm_keep_local_after_email == "false") {
  355. echo " <option value='false' selected='selected' >false</option>\n";
  356. }
  357. else {
  358. echo " <option value='false'>false</option>\n";
  359. }
  360. echo " </select>\n";
  361. echo "<br />\n";
  362. echo "".$text['description-keep-local']." \n";
  363. echo "</td>\n";
  364. echo "</tr>\n";
  365. //echo "<tr>\n";
  366. //echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  367. //echo " Description:\n";
  368. //echo "</td>\n";
  369. //echo "<td class='vtable' align='left'>\n";
  370. //echo " <textarea class='formfld' name='description' rows='4'>$description</textarea>\n";
  371. //echo "<br />\n";
  372. //echo "\n";
  373. //echo "</td>\n";
  374. //echo "</tr>\n";
  375. echo " <tr>\n";
  376. echo " <td colspan='2' align='right'>\n";
  377. if ($action == "update") {
  378. echo " <input type='hidden' name='extension_uuid' value='$extension_uuid'>\n";
  379. }
  380. echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
  381. echo " </td>\n";
  382. echo " </tr>";
  383. echo "</table>";
  384. echo "</form>";
  385. echo " </td>";
  386. echo " </tr>";
  387. echo "</table>";
  388. echo "</div>";
  389. //show the footer
  390. require_once "resources/footer.php";
  391. ?>