function saveNewKey($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrAST, $arrAMP) { $arrFormNew = createFieldForm($pDB); $arrValues['id'] = getParameter("Extension"); $arrValues['key'] = getParameter("Current_Secret"); $arrValues['new_key'] = getParameter("New_Secret"); $confirmation = getParameter("Confirm_New_Secret"); $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']); $pACL = new paloACL($pDB2); $oForm = new paloForm($smarty, $arrFormNew); if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $pWeakKeys = new paloSantoWeakKeys($pDB); $device = $pWeakKeys->getWeakKeyById($arrValues['id']); if (!$pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) { if ($arrValues['key'] != $device['data']) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The Current Secret is invalid")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } } if ($arrValues['new_key'] != $confirmation) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("The New Secret does not match with the Confirmation Secret")); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $mensaje = getMensaje($arrValues['id'], $arrValues['new_key']); if ($mensaje != "OK") { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $mensaje); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } if (!$pWeakKeys->saveNewKey($arrValues, $device['tech'])) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pWeakKeys->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $data_connection = array('host' => $arrConf['AMI_HOST'], 'user' => $arrConf['AMI_USER'], 'password' => $arrConf['AMI_PASS']); $pLoadExtension = new paloSantoLoadExtension($pDB); if (!$pLoadExtension->do_reloadAll($data_connection, $arrAST, $arrAMP)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pLoadExtension->errMsg); return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']); } $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("Successful Secret Update")); return reportWeakKeys($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }
function backup_extensions($pDB) { $csv = ""; $pLoadExtension = new paloSantoLoadExtension($pDB); $r = $pLoadExtension->queryExtensions(); if (!is_array($r)) { print $pLoadExtension->errMsg; return; } $keyOrder = array('name' => 'Display Name', 'extension' => 'User Extension', 'directdid' => 'Direct DID', 'outboundcid' => 'Outbound CID', 'callwaiting' => 'Call Waiting', 'secret' => 'Secret', 'voicemail' => 'Voicemail Status', 'vm_secret' => 'Voicemail Password', 'email_address' => 'VM Email Address', 'pager_email_address' => 'VM Pager Email Address', 'vm_options' => 'VM Options', 'email_attachment' => 'VM Email Attachment', 'play_cid' => 'VM Play CID', 'play_envelope' => 'VM Play Envelope', 'delete_vmail' => 'VM Delete Vmail', 'context' => 'Context', 'tech' => 'Tech', 'callgroup' => 'Callgroup', 'pickupgroup' => 'Pickupgroup', 'disallow' => 'Disallow', 'allow' => 'Allow', 'deny' => 'Deny', 'permit' => 'Permit', 'record_in' => 'Record Incoming', 'record_out' => 'Record Outgoing'); print '"' . implode('","', $keyOrder) . "\"\n"; foreach ($r as $tupla) { $t = array(); foreach (array_keys($keyOrder) as $k) { switch ($k) { case 'name': $t[] = $tupla['name']; break; case 'extension': $t[] = $tupla['extension']; break; case 'directdid': $t[] = $tupla['directdid']; break; case 'outboundcid': $t[] = $tupla['outboundcid']; break; case 'callwaiting': $t[] = $tupla['callwaiting']; break; case 'voicemail': $t[] = $tupla['voicemail']; break; case 'vm_secret': $t[] = $tupla['vm_secret']; break; case 'email_address': $t[] = $tupla['email_address']; break; case 'pager_email_address': $t[] = $tupla['pager_email_address']; break; case 'vm_options': $t[] = $tupla['vm_options']; break; case 'email_attachment': $t[] = $tupla['email_attachment']; break; case 'play_cid': $t[] = $tupla['play_cid']; break; case 'play_envelope': $t[] = $tupla['play_envelope']; break; case 'delete_vmail': $t[] = $tupla['delete_vmail']; break; case 'tech': $t[] = $tupla['tech']; break; default: if (isset($tupla['parameters'][$k])) { if ($tupla['parameters'][$k] == "Adhoc") { $tupla['parameters'][$k] = "On Demand"; $t[] = $tupla['parameters'][$k]; } else { $t[] = $tupla['parameters'][$k]; } } else { $t[] = ''; } } } print '"' . implode('","', $t) . "\"\n"; } return $csv; }