function ordenRoute($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { global $arrPermission; $jsonObject = new PaloSantoJSON(); $seq = getParameter("seq"); $out_id = getParameter("out_id"); $domain = getParameter("organization"); if (!in_array('edit', $arrPermission)) { $jsonObject->set_error(_tr("You are not authorized to perform this action")); return $jsonObject->createJSON(); } if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pOutbound = new paloSantoOutbound($pDB, $domain); $pDB->beginTransaction(); $result = $pOutbound->reorderRoute($out_id, $seq); if ($result == false) { $pDB->rollBack(); $jsonObject->set_error(_tr($pOutbound->errMsg)); } else { $pDB->commit(); $pAstConf = new paloSantoASteriskConfig($pDB, new paloDB($arrConf['elastix_dsn']['elastix'])); $pAstConf->setReloadDialplan($domain, true); $content = reportOutbound($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); $jsonObject->set_message(array(_tr("Changes Applied"), $content)); } return $jsonObject->createJSON(); }
function faxAttachmentUpload($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { $jsonObject = new PaloSantoJSON(); $tmpfaxdocs = "/var/www/elastixdir/tmpfaxdocs/"; if (!file_exists($tmpfaxdocs)) { $jsonObject->set_error(_tr("Error uploading your file")); return $jsonObject->createJSON(); } foreach ($_FILES['faxFile']['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmpFileName = tempnam($tmpfaxdocs, ""); if ($tmpFileName == false) { $jsonObject->set_error(_tr("Error uploading your file")); return $jsonObject->createJSON(); } if (move_uploaded_file($_FILES['faxFile']['tmp_name'][$key], $tmpFileName) === false) { $jsonObject->set_error(_tr("Failed to move file")); return $jsonObject->createJSON(); } if (empty($_SESSION['faxFileAattached'])) { $_SESSION['faxFileAattached'] = $tmpFileName; } else { if (!empty($_SESSION['faxFileAattached'])) { unlink($_SESSION['faxFileAattached']); unset($_SESSION['faxFileAattached']); $_SESSION['faxFileAattached'] = $tmpFileName; } } $jsonObject->set_message($_SESSION['faxFileAattached']); } else { $jsonObject->set_error(_tr("Error uploading your file")); } } return $jsonObject->createJSON(); }
function KickCallers($smarty, &$pDB, $module_name, $credentials) { global $arrPermission; $id_conf = getParameter("id_conf"); $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $type_kick = getParameter("type"); $jsonObject = new PaloSantoJSON(); //permission $invite_part = in_array("admin_conference_participant", $arrPermission); if (!$invite_part) { $jsonObject->set_error(_tr("You are not authorized to perform this action")); } else { $pConf = new paloConference($pDB, $domain); $conference = $pConf->getConferenceById($id_conf); if ($conference == false) { $jsonObject->set_error(_tr($pConf->errMsg)); } else { $room = $conference["confno"]; $date = time(); if ($date >= strtotime($conference["startTime"]) && $date <= strtotime($conference["endtime"]) || $conference["startTime"] == "1900-01-01 12:00:00") { if ($type_kick == "all") { $result = $pConf->KickCaller($room, "all"); } else { $keys = array_keys($_POST); foreach ($keys as $value) { if (preg_match("/^kick_[0-9]+\$/", $value)) { $result = $pConf->KickCaller($room, $_POST[$value]); } } } $jsonObject->set_message(_tr("Changes has been applied") . print_r($result)); } else { $jsonObject->set_error(_tr("Conference out of Time")); } } } return $jsonObject->createJSON(); }
function getDevices($dsnAsterisk, $dsnSqlite) { $jsonObject = new PaloSantoJSON(); $paloEndPoint = new paloSantoEndPoint($dsnAsterisk, $dsnSqlite); $idModel = getParameter("id_model"); if ($idModel == "unselected") { $jsonObject->set_message(array("Unselected" => _tr("Unselected"))); } else { $iaxSupport = $paloEndPoint->modelSupportIAX($idModel); if ($iaxSupport === null) { $jsonObject->set_error("yes"); } else { if ($iaxSupport) { $jsonObject->set_message($paloEndPoint->getDeviceFreePBX(true)); } else { $jsonObject->set_message($paloEndPoint->getDeviceFreePBX()); } } } return $jsonObject->createJSON(); }
function handleJSON_saveNeoToggleTab($smarty, $module_name) { $jsonObject = new PaloSantoJSON(); $id_menu = getParameter("id_menu"); if (empty($id_menu)) { $jsonObject->set_status('false'); $jsonObject->set_error(_tr('Module not specified')); } else { $statusTab = getParameter("statusTab"); $output = saveNeoToggleTabByUser($id_menu, $statusTab); $jsonObject->set_status($output['status'] === TRUE ? 'true' : 'false'); $jsonObject->set_error($output['msg']); } return $jsonObject->createJSON(); }
function saveEditANI($pDB, $credentials) { $jsonObject = new PaloSantoJSON(); $ani_domain = getParameter("ani_domain"); $ani_trunkid = getParameter("ani_trunkid"); $ani_prefix = getParameter("ani_prefix"); $ani_prefix = trim($ani_prefix); if ($ani_prefix == "") { $ani_prefix = NULL; } if ($credentials['userlevel'] != 'superadmin') { $ani_domain = $credentials['domain']; } $pANI = new paloSantoANI($pDB, $ani_domain); $pDB->beginTransaction(); $success = $pANI->updateANI_Prefix($ani_trunkid, $ani_prefix); if ($success) { $pDB->commit(); $jsonObject->set_message(_tr("Prefix ANI was saved successfully.") . " [{$ani_prefix}] -> {$ani_domain}"); } else { $pDB->rollBack(); $error = $pANI->errMsg; $jsonObject->set_error($error); } return $jsonObject->createJSON(); }
function saveVacationSettings($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { global $arrCredentials; $objAntispam = new paloSantoAntispam($arrConf['path_postfix'], $arrConf['path_spamassassin'], $arrConf['file_master_cf'], $arrConf['file_local_cf']); $pVacations = new paloMyVacation($pDB, $arrCredentials['idUser']); $jsonObject = new PaloSantoJSON(); $myVacation['init_date'] = getParameter('intiDate'); $myVacation['end_date'] = getParameter('endDate'); $myVacation['email_subject'] = getParameter('emailSubject'); $myVacation['email_body'] = getParameter('emailBody'); $email = $_SESSION['elastix_user']; $subject = $myVacation['email_subject']; $body = $myVacation['email_body']; $ini_date = $myVacation['init_date']; $end_date = $myVacation['end_date']; $timestamp0 = mktime(0, 0, 0, date("m"), date("d"), date("Y")); $timestamp1 = mktime(0, 0, 0, date("m", strtotime($ini_date)), date("d", strtotime($ini_date)), date("Y", strtotime($ini_date))); $timeSince = $timestamp0 - $timestamp1; if ($timeSince >= 0) { $myVacation['vacation'] = "yes"; } else { $myVacation['vacation'] = "no"; } $scripts = $objAntispam->existScriptSieve($email, "scriptTest.sieve"); $spamCapture = false; // si CapturaSpam=OFF y Vacations=OFF if ($scripts['actived'] != "") { // hay un script activo if (preg_match("/scriptTest.sieve/", $scripts['actived'])) { // si CapturaSpam=ON y Vacations=OFF $spamCapture = true; } // si CapturaSpam=ON y Vacations=OFF } $pVacations->_DB->beginTransaction(); if (!$pVacations->editVacation($myVacation)) { $pVacations->_DB->rollBack(); $jsonObject->set_error($pVacations->getErrorMsg()); return $jsonObject->createJSON(); } else { //mandamos a actualizar el script del sieve if ($timeSince >= 0) { $body = str_replace("{END_DATE}", $end_date, $body); $result = $pVacations->uploadVacationScript($email, $subject, $body, $objAntispam, $spamCapture); } else { $result = true; } if ($result) { $pVacations->_DB->commit(); $jsonObject->set_message("Changes were saved succefully"); } else { $pVacations->_DB->rollBack(); $jsonObject->set_error($pVacations->getErrorMsg()); } return $jsonObject->createJSON(); } }
function getSelected(&$pDB, $userLevel1) { $jsonObject = new PaloSantoJSON(); $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrData = array(); if ($userLevel1 != "superadmin") { $jsonObject->set_error("You are not authorized to perform this action. "); } else { $idOrg = getParameter("idOrg"); //validamos que la organization exista $orgTmp = $pORGZ->getOrganization(array("id" => $idOrg)); //valido que al menos exista una organizacion creada if ($orgTmp === false) { $jsonObject->set_error(_tr($pORGZ->errMsg)); } elseif (count($orgTmp) <= 0) { $jsonObject->set_error(_tr("Organization doesn't exist")); } else { //obtengo los recursos asignados a la organizacion $arrResourceOrg = $pACL->getResourcesByOrg($idOrg); if ($arrResourceOrg === false) { $jsonObject->set_error(_tr($pACL->errMsg)); } else { foreach ($arrResourceOrg as $resource) { $arrData[] = $resource["id"]; } $jsonObject->set_message($arrData); } } } return $jsonObject->createJSON(); }
function getDataRegistration($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, &$pDBACL) { $pRegister = new paloSantoRegistration($pDB); $jsonObject = new PaloSantoJSON(); if (is_file("/etc/elastix.key")) { $_DATA = $pRegister->getDataServerRegistration(); if ($_DATA === null) { // no se puede conectar al web service o existe un problema de red $jsonObject->set_error(_tr("Impossible connect to Elastix Web services. Please check your internet connection.")); $jsonObject->set_status("error"); $jsonObject->set_message($_DATA); } elseif ($_DATA === "FALSE") { // su elastix no esta registrado, el idServer enviado no existe en la base de datos $_DATA = $pRegister->getDataRegister(); $jsonObject->set_error(_tr("Your Server ID is not valid. Please update your information to generate a new Server ID.")); $jsonObject->set_status("error-update"); $jsonObject->set_message($_DATA); } else { $jsonObject->set_message($_DATA); } } else { // elastix no registrado $jsonObject->set_error("no registrado"); $jsonObject->set_status("error"); $jsonObject->set_message("empty"); } return $jsonObject->createJSON(); }
function changeDIDfilter($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials) { $jsonObject = new PaloSantoJSON(); $pDID = new paloDidPBX($pDB); $prop["country"] = getParameter("country"); $prop["city"] = getParameter("city"); $listDID = $pDID->getDIDFree($prop); if ($listDID === false) { $jsonObject->set_error(_tr("An error has ocurred to retrieve DID data")); } else { $arrDID = array(); if (count($listDID) > 0) { //debemos quitar de la lista de did aquellos que ya han sido seleccionados $selectDID = getParameter("listDIDOrg"); if (!empty($selectDID)) { $listDIDOrg = explode(",", $selectDID); foreach ($listDID as $value) { if (!in_array($value['id'], $listDIDOrg)) { $arrDID[] = array('id' => $value['id'], 'did' => $value['did'], 'country_code' => $value['country_code'], 'area_code' => $value['area_code']); } } } else { foreach ($listDID as $value) { $arrDID[] = array('id' => $value['id'], 'did' => $value['did'], 'country_code' => $value['country_code'], 'area_code' => $value['area_code']); } } } $jsonObject->set_message($arrDID); } return $jsonObject->createJSON(); }
function actDesactTrunk($smarty, &$pDB) { $pTrunk = new paloSantoTrunk($pDB); $error = ""; $idTrunk = getParameter("id_trunk"); $action = getParameter("trunk_action"); $jsonObject = new PaloSantoJSON(); if (!preg_match('/^[[:digit:]]+$/', "{$idTrunk}")) { $error = _tr("Invalid Trunk Id"); } else { $pDB->beginTransaction(); $result = $pTrunk->actDesacTrunk($idTrunk, $action); if ($result == true) { $pDB->commit(); } else { $error = $pTrunk->errMsg(); $pDB->rollBack(); } } if ($error != "") { $jsonObject->set_error($error); } else { $state = $action == "on" ? "desactivated" : "activated"; $jsonObject->set_message(_tr("Trunk have been {$state} successfully")); } return $jsonObject->createJSON(); }
function hangup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $credentials) { $pRecording = new paloSantoRecordings($pDB); $jsonObject = new PaloSantoJSON(); $domain = null; if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials["domain"]; } else { $jsonObject->set_status("Error"); $jsonObject->set_error("Invalid Action"); return $jsonObject->createJSON(); } //obtenemos la extension del usuario que esta haciendo la grabacion $extension = $pRecording->Obtain_Extension_Current_User(); if (!$extension) { $jsonObject->set_status("Error"); $jsonObject->set_error("An erro has ocurred to obtain user extension"); return $jsonObject->createJSON(); } $pRecording = new paloSantoRecordings($pDB); $result = $pRecording->Obtain_Protocol_Current_User($domain, $extension); if ($result != FALSE) { $result = $pRecording->hangupPhone($dsn_agi_manager, $result['device'], $result['dial'], $result['exten']); } $msgResponse["record"] = $result; $jsonObject->set_status("OK"); $jsonObject->set_message($msgResponse); return $jsonObject->createJSON(); }
function viewBoxCalendar($arrConf, $arrLang, $pDB, $local_templates_dir, $smarty, $module_name) { $pCalendar = new paloSantoCalendar($pDB); $id = getParameter('id_event'); $action = getParameter('action'); $pDBACL = new paloDB($arrConf['dsn_conn_database1']); $pACL = new paloACL($pDBACL); $id_user = $pACL->getIdUser($_SESSION["elastix_user"]); $jsonObject = new PaloSantoJSON(); $data = $pCalendar->getEventById($id, $id_user); $val = false; if ($data == "" && !isset($data)) { $jsonObject->set_error(_tr("Don't exist the event")); return $jsonObject->createJSON(); } $data = $pCalendar->get_event_by_id($id); $type_event = $data['it_repeat']; $days_repeat = $data['days_repeat']; $data['it_repeat'] = returnEventToType($type_event, $arrLang); $data['visibility'] = "visibility: hidden;"; $data['visibility_repeat'] = "visibility: hidden;"; $data['notification_status'] = $data['notification']; $data['title'] = _tr("View Event"); $new_date_ini = $data['starttime']; $new_date_end = $data['endtime']; $data['date'] = date("d M Y H:i", strtotime($new_date_ini)); $data['to'] = date("d M Y H:i", strtotime($new_date_end)); $data['Contact'] = $arrLang['Contact']; $data['Email'] = $arrLang['Email']; if ($data['notification'] == "on") { $arrContacts = getEmailToTables($data['emails_notification']); $data['emails_notification'] = getEmails($data['emails_notification']); $data['visibility'] = "visibility: visible;"; $data = array_merge($data, $arrContacts); } else { $data['size_emails'] = 0; } if ($type_event == 5) { $data['visibility_repeat'] = "visibility: visible;"; } if ($type_event == 6) { $visibility_repeat = "visibility: visible;"; } if ($days_repeat != "") { $arr = getDaysByCheck($days_repeat, 2); $data = array_merge($data, $arr); } if ($data['call_to'] != "") { $visibility_alert = ""; } else { $visibility_alert = "display:none"; } $date_ini = getParameter("event_date"); if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $date_ini)) { $date_ini = date("M d Y"); } $dateServer = gmdate("D M d Y H:i:s TO (e)", strtotime($date_ini)); //Fri Nov 12 2010 00:00:00 GMT-0500 (ECT) $arrForm = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrForm); $smarty->assign("add_phone", $arrLang["Search in Address Book"]); $smarty->assign("SAVE", $arrLang["Save"]); $smarty->assign("EDIT", $arrLang["Edit"]); $smarty->assign("DELETE", $arrLang["Delete"]); $smarty->assign("CANCEL", $arrLang["Cancel"]); $smarty->assign("Start_date", $arrLang["Start_date"]); $smarty->assign("Notification_Alert", $arrLang["Notification_Alert"]); $smarty->assign("End_date", $arrLang["End_date"]); $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]); $smarty->assign("module_name", $module_name); $smarty->assign("notification_email", $arrLang["notification_email"]); $smarty->assign("id_event", $id); $smarty->assign("Call_alert", $arrLang["Call_alert"]); // $smarty->assign("visibility_emails",$visibility_emails); $smarty->assign("icon", "modules/{$module_name}/images/agenda_calendar.png"); $smarty->assign("visibility_alert", $visibility_alert); $smarty->assign("LBL_EDIT", $arrLang["Edit Event"]); $smarty->assign("LBL_LOADING", $arrLang["Loading"]); $smarty->assign("LBL_DELETING", $arrLang["Deleting"]); $smarty->assign("LBL_SENDING", $arrLang["Sending Request"]); $smarty->assign("START_TYPE", $arrLang["START_TYPE"]); $smarty->assign("DATE_SERVER", $dateServer); $smarty->assign("Color", $arrLang["Color"]); $smarty->assign("Listen", $arrLang["Listen"]); $smarty->assign("Listen_here", _tr("Click here to listen")); $htmlForm = $oForm->fetchForm("{$local_templates_dir}/evento.tpl", $arrLang["Calendar"], array()); $content = "<form method='POST' style='margin-bottom:0;' action='?menu={$module_name}' name='formNewEvent' id='formNewEvent' onsubmit='return sendNewEvent();'>" . $htmlForm . "</form>"; $data["html"] = $content; $jsonObject->set_message($data); return $jsonObject->createJSON(); }
function mostrar_menu() { global $arrLangModule; global $arrConf; $jsonObject = new PaloSantoJSON(); $respuesta = array(); $level = getParameter("level"); $parent_1_existing = getParameter("parent_1_existing"); $parent_2_existing = getParameter("parent_2_existing"); $id_parent = getParameter("id_parent"); //Nivel 2 if ($level == 0) { //Padre nivel 1 SI existe if ($parent_1_existing == 0) { $pDB_menu = new paloDB($arrConf['elastix_dsn']['menu']); if (!empty($pDB_menu->errMsg)) { $jsonObject->set_error("ERROR DE DB: {$pDB_menu->errMsg}"); return $jsonObject->createJSON(); } $pMenu = new paloMenu($pDB_menu); $arrMenuOptions = $pMenu->getRootMenus(); $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left'>"; $parent_Menu .= "<select name='parent_module' id='parent_module'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu .= "<option value='{$key}'>{$valor}</option>"; } $parent_Menu .= "</select>"; $parent_Menu .= "</td>"; } else { $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left' width='21%'><input type='text' name='parent_1_name' id='parent_1_name' value='' onkeyup='generateId(this,\"parent_1_id\")'></td>"; $parent_Menu .= "<td align='left' width='11%'><b>{$arrLangModule["Level 1 Parent Id"]}: </b></td>"; $parent_Menu .= "<td align='left'><i id='parent_1_id'></i></td>"; } $respuesta["parent_menu_1"] = $parent_Menu; $respuesta["level2_exist"] = ""; $respuesta["parent_menu_2"] = ""; $respuesta["label_level2"] = ""; } else { //Padre nivel 1 SI existe if ($parent_1_existing == 0) { //Padre nivel 2 SI existe if ($parent_2_existing == 0) { require_once 'libs/paloSantoNavigation.class.php'; $pMenu = new paloMenu($arrConf['elastix_dsn']['menu']); $arrMenu = $pMenu->cargar_menu(); $smarty = NULL; $pNav = new paloSantoNavigation($arrMenu, $smarty); $arrMenuOptions = $pNav->getArrSubMenu($id_parent); if (is_array($arrMenuOptions)) { $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td>"; $parent_Menu2 .= "<select name='parent_module_2' id='parent_module_2'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu2 .= "<option value='{$key}'>{$valor['Name']}</option>"; } $parent_Menu2 .= "</select>"; $parent_Menu2 .= "</td>"; $parent_Menu2 .= "<td></td><td></td><td></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } } else { if ($parent_2_existing == 1) { $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='21%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } else { $pDB_menu = new paloDB($arrConf['elastix_dsn']['menu']); if (!empty($pDB_menu->errMsg)) { $jsonObject->set_error("ERROR DE DB: {$pDB_menu->errMsg}"); return $jsonObject->createJSON(); } $pMenu = new paloMenu($pDB_menu); $arrMenuOptions = $pMenu->getRootMenus(); $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left'>"; $parent_Menu .= "<select name='parent_module' id='parent_module' onchange='mostrar_menu()'>"; foreach ($arrMenuOptions as $key => $valor) { $parent_Menu .= "<option value='{$key}'>{$valor}</option>"; } $parent_Menu .= "</select>"; $parent_Menu .= "</td>"; $parent_Menu .= "<td></td><td></td><td></td>"; $respuesta["parent_menu_1"] = $parent_Menu; //$respuesta->addAssign("parent_menu_1","innerHTML", ""); $parent_exist = "<b>{$arrLangModule["Level 2 Parent Exists"]}: <span class='required'>*</span></b>"; $respuesta["label_level2"] = $parent_exist; $parent_option = "<select id='parent_2_existing_option' name='parent_2_existing_option' onchange='mostrar_menu()'>"; $parent_option .= "<option value='{$arrLangModule["Yes"]}'>{$arrLangModule["Yes"]}</option>"; $parent_option .= "<option value='{$arrLangModule["No"]}' selected='selected'>{$arrLangModule["No"]}</option>"; $parent_option .= "</select>"; $respuesta["level2_exist"] = $parent_option; $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='22%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; } } } else { $parent_Menu = "<td align='left'><b>{$arrLangModule["Level 1 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu .= "<td align='left' width='22%'><input type='text' name='parent_1_name' id='parent_1_name' value='' onkeyup='generateId(this,\"parent_1_id\")'></td>"; $parent_Menu .= "<td align='left' width='11%'><b>{$arrLangModule["Level 1 Parent Id"]}: </b></td>"; $parent_Menu .= "<td align='left'><i id='parent_1_id'></i></td>"; $respuesta["parent_menu_1"] = $parent_Menu; $parent_Menu2 = "<td align='left'><b>{$arrLangModule["Level 2 Parent Name"]}: <span class='required'>*</span></b></td>"; $parent_Menu2 .= "<td align='left' width='22%'><input type='text' name='parent_2_name' id='parent_2_name' value='' onkeyup='generateId(this,\"parent_2_id\")'></td>"; $parent_Menu2 .= "<td align='left' width='11%'><b>{$arrLangModule["Level 2 Parent Id"]}: </b></td>"; $parent_Menu2 .= "<td align='left'><i id='parent_2_id'></i></td>"; $respuesta["parent_menu_2"] = $parent_Menu2; $respuesta["level2_exist"] = ""; $respuesta["label_level2"] = ""; } } $jsonObject->set_message($respuesta); return $jsonObject->createJSON(); }
function getGroups(&$pDB, $arrCredentiasls) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $jsonObject = new PaloSantoJSON(); $idOrgSel = getParameter("idOrganization"); $arrGrupos = array(); if ($idOrgSel == 0) { $arrGrupos = array(); } else { if ($arrCredentiasls['userlevel'] != 'superadmin') { if ($idOrgSel != $arrCredentiasls['id_organization']) { $jsonObject->set_error("Invalid Action"); $arrGrupos = array(); } } else { $arrGrupos[0] = array("country_code", $pORGZ->getOrganizationProp($idOrgSel, "country_code")); $arrGrupos[1] = array("area_code", $pORGZ->getOrganizationProp($idOrgSel, "area_code")); $arrGrupos[2] = array("email_quota", $pORGZ->getOrganizationProp($idOrgSel, "email_quota")); $temp = $pACL->getGroupsPaging(null, null, $idOrgSel); if ($temp === false) { $jsonObject->set_error(_tr($pACL->errMsg)); } else { $i = 3; foreach ($temp as $value) { $arrGrupos[$i] = array($value[0], $value[1]); $i++; } } } } $jsonObject->set_message($arrGrupos); return $jsonObject->createJSON(); }
function changeOtherPage($pDB, $module_name) { $jsonObject = new PaloSantoJSON(); $pRules = new paloSantoRules($pDB); $direction = getParameter("direction"); $actualrow = getParameter("actualrow"); $tmp = explode("_", $actualrow); $actual_id = $tmp[1]; $actual_order = $tmp[2]; $correct = false; if ($direction == "up") { if ($actual_order != 1) { $correct = true; $rule = $pRules->getPreviousRule($actual_order); } } else { $rule = $pRules->getNextRule($actual_order); if (count($rule) != 0) { $correct = true; } } if ($correct) { if (is_array($rule)) { $Exito1 = $pRules->updateOrder($actual_id, $rule["rule_order"]); $Exito2 = $pRules->updateOrder($rule["id"], $actual_order); $mensaje = _tr("You have made changes to the definition of firewall rules, for this to take effect in the system press the next button"); $mensaje2 = _tr("Save Changes"); if ($Exito1 && $Exito2) { $jsonObject->set_status(_tr("Successful Change") . ":{$mensaje}:{$mensaje2}:" . _tr("Dismiss") . ":" . _tr("MESSAGE")); $arrayResult["id"] = $rule["id"]; if ($rule['traffic'] == "INPUT") { $arrayResult["traffic"]["image"] = "modules/{$module_name}/images/fw_input.gif"; $arrayResult["traffic"]["title"] = _tr("INPUT"); $arrayResult["interface"] = _tr("IN") . ": {$rule['eth_in']}"; } elseif ($rule['traffic'] == "OUTPUT") { $arrayResult["traffic"]["image"] = "modules/{$module_name}/images/fw_output.gif"; $arrayResult["traffic"]["title"] = _tr("OUTPUT"); $arrayResult["interface"] = _tr("OUT") . ": {$rule['eth_out']}"; } else { $arrayResult["traffic"]["image"] = "modules/{$module_name}/images/fw_forward.gif"; $arrayResult["traffic"]["title"] = _tr("FORWARD"); $arrayResult["interface"] = _tr("IN") . ": {$rule['eth_in']}<br />" . _tr("OUT") . ": {$rule['eth_out']}"; } if ($rule['target'] == "ACCEPT") { $arrayResult["target"]["image"] = "modules/{$module_name}/images/target_accept.gif"; $arrayResult["target"]["title"] = _tr("ACCEPT"); } elseif ($rule['target'] == "DROP") { $arrayResult["target"]["image"] = "modules/{$module_name}/images/target_drop.gif"; $arrayResult["target"]["title"] = _tr("DROP"); } else { $arrayResult["target"]["image"] = "modules/{$module_name}/images/target_drop.gif"; $arrayResult["target"]["title"] = _tr("REJECT"); } $arrayResult["ipSource"] = $rule["ip_source"]; $arrayResult["ipDestiny"] = $rule["ip_destiny"]; $arrayResult["protocol"] = $rule["protocol"]; if ($rule['protocol'] == "ICMP") { $arrayResult["details"] = _tr("Type") . ": {$rule['icmp_type']}"; } else { if ($rule['protocol'] == "IP") { $arrayResult["details"] = _tr("Number Protocol IP") . ": {$rule['number_ip']}"; } else { if ($rule['protocol'] == "TCP" || $rule['protocol'] == "UDP") { if ($rule['sport'] != "" && $rule["sport"] != "ANY") { $sportName = $pRules->getProtocolName($rule["sport"]); } else { $sportName = $rule["sport"]; } if ($rule["dport"] != "" && $rule["dport"] != "ANY") { $dportName = $pRules->getProtocolName($rule["dport"]); } else { $dportName = $rule["dport"]; } $arrayResult["details"] = _tr("Source Port") . ": {$sportName}" . "<br />" . _tr("Destiny Port") . ": {$dportName}"; } else { if ($rule['protocol'] == "STATE") { $arrayResult["details"] = $rule['state']; } else { $arrayResult["details"] = ""; } } } } if ($rule['activated'] == 1) { $image = "modules/{$module_name}/images/foco_on.gif"; $activated = "Desactivate"; } else { $image = "modules/{$module_name}/images/foco_off.gif"; $activated = "Activate"; } $arrayResult["activate"] = "<a href='?menu={$module_name}&action=" . $activated . "&id=" . $rule['id'] . "'>" . "<img src='{$image}' border=0 title='" . _tr($activated) . "'</a>"; $arrayResult["edit"] = "<a href='?menu={$module_name}&action=edit&id=" . $rule['id'] . "'>" . "<img src='modules/{$module_name}/images/edit.gif' border=0 title='" . _tr('Edit') . "'</a>"; $jsonObject->set_message($arrayResult); } else { $jsonObject->set_error($pRules->errMsg); } } else { $jsonObject->set_error($pRules->errMsg); } } else { $jsonObject->set_status(_tr("Invalid Action")); } return $jsonObject->createJSON(); }
function handleJSON_changeImageProfile($smarty, $module_name) { global $arrConf; Header('Content-Type: application/json'); $arrCredentials = getUserCredentials($_SESSION['elastix_user']); $pDB = new paloDB($arrConf['elastix_dsn']["elastix"]); $pACL = new paloACL($pDB); $jsonObject = new PaloSantoJSON(); $idUser = $arrCredentials['idUser']; foreach ($_FILES['picture']['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $pictureUpload = $_FILES['picture']['name'][$key]; if (!preg_match("/^(\\w|-|\\.|\\(|\\)|\\s)+\\.(png|PNG|JPG|jpg|JPEG|jpeg)\$/", $pictureUpload)) { $jsonObject->set_error(_tr("Invalid file extension.- It must be png or jpg or jpeg")); return $jsonObject->createJSON(); } elseif (preg_match("/(\\.php)/", $pictureUpload)) { $jsonObject->set_error(_tr("Possible file upload attack.")); return $jsonObject->createJSON(); } else { if (is_uploaded_file($_FILES['picture']['tmp_name'][$key])) { $ancho = 159; $alto = 159; redimensionarImagen($_FILES['picture']['tmp_name'][$key], $_FILES['picture']['tmp_name'][$key], $ancho, $alto); $picture_type = $_FILES['picture']['type'][$key]; $picture_content = file_get_contents($_FILES['picture']['tmp_name'][$key]); $Exito = $pACL->setUserPicture($idUser, $picture_type, $picture_content); if ($Exito === false) { $jsonObject->set_error(_tr("Image couldn't be upload.")); return $jsonObject->createJSON(); } } else { $jsonObject->set_error(_tr("Possible file upload attack. Filename") . " : " . $pictureUpload); return $jsonObject->createJSON(); } } $url = "index.php?menu=_elastixutils&action=getImage&ID={$idUser}&rawmode=yes"; $jsonObject->set_message($url); return $jsonObject->createJSON(); } } return $jsonObject->createJSON(); }
function get_destination_category($smarty, $module_name, $pDB, $arrConf, $credentials) { $jsonObject = new PaloSantoJSON(); $categoria = getParameter("category"); $domain = getParameter("organization"); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pQueue = new paloQueuePBX($pDB, $domain); $arrDestine = $pQueue->getDefaultDestination($domain, $categoria); if ($arrDestine == FALSE) { $jsonObject->set_error(_tr($pQueue->errMsg)); } else { $jsonObject->set_message($arrDestine); } return $jsonObject->createJSON(); }
function transferCALL($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { global $arrCredentials; $jsonObject = new PaloSantoJSON(); $coreContact = new coreContact($pDB); $id_user = $arrCredentials['idUser']; $idContact = getParameter('idContact'); //obtener los parametros del filtro $filters['ftype_contacto'] = getParameter('ftype_contacto'); $validatedfilters = $coreContact->validatedFilters($filters); if (!empty($id_user)) { if ($validatedfilters['table'] == "internal") { $extension = $coreContact->sqlContact->getExtension($idContact); } else { $extension = $coreContact->sqlContact->getPhone($idContact); } if ($extension === false) { $smarty->assign("MSG_ERROR_FIELD", $coreContact->sqlContact->getErrorMsg()); $jsonObject->set_error($coreContact->sqlContact->getErrorMsg()); return $jsonObject->createJSON(); } $dataExt = $coreContact->sqlContact->Obtain_Protocol_from_Ext($id_user); if ($dataExt === FALSE) { $smarty->assign("MSG_ERROR_FIELD", $coreContact->sqlContact->getErrorMsg()); $jsonObject->set_error($coreContact->getErrorMsg()); return $jsonObject->createJSON(); } $result = $coreContact->TranferCall($extension, $dataExt['dial'], $dataExt['context'], $dataExt['code']); if (!$result) { $smarty->assign("MSG_ERROR_FIELD", _tr("The transfer couldn't be realized, maybe you don't have any conversation now.")); $jsonObject->set_error($coreContact->getErrorMsg()); return $jsonObject->createJSON(); } } else { $smarty->assign("MSG_ERROR_FIELD", $coreContact->getErrorMsg()); $jsonObject->set_error($coreContact->getErrorMsg()); return $jsonObject->createJSON(); } return $jsonObject->createJSON(); }
//$smarty->assign("HEADER_MODULES",$sModuleContent['JS_CSS_HEAD']); $smarty->assign("CONTENT", $sModuleContent['JS_CSS_HEAD'] . $sModuleContent['data']); } else { $smarty->assign("CONTENT", $sModuleContent['data']); } $smarty->assign('MENU', count($arrMenuFiltered) > 0 ? $smarty->fetch("_common/_menu.tpl") : _tr('No modules')); } $smarty->display("_common/index.tpl"); } } else { $rawmode = getParameter("rawmode"); if (isset($rawmode) && $rawmode == 'yes') { include_once "libs/paloSantoJSON.class.php"; $jsonObject = new PaloSantoJSON(); $jsonObject->set_status("ERROR_SESSION"); $jsonObject->set_error(_tr("Your session has expired. If you want to do a login please press the button 'Accept'.")); $jsonObject->set_message(null); Header('Content-Type: application/json'); echo $jsonObject->createJSON(); } else { $oPn = new paloSantoNavigation(array(), $smarty); $oPn->putHEAD_JQUERY_HTML(); $smarty->assign("THEMENAME", $arrConf['mainTheme']); $smarty->assign("WEBPATH", "web/"); $smarty->assign("WEBCOMMON", "../" . $arrConf['webCommon'] . "/"); $smarty->assign("currentyear", date("Y")); $smarty->assign("PAGE_NAME", _tr('Login page')); $smarty->assign("WELCOME", _tr('Welcome to Elastix')); $smarty->assign("ENTER_USER_PASSWORD", _tr('Please enter your username and password')); $smarty->assign("USERNAME", _tr('Username')); $smarty->assign("PASSWORD", _tr('Password'));
function saveExtensionSettings($smarty, $module_name, $local_templates_dir, $pDB, $arrConf) { $jsonObject = new PaloSantoJSON(); global $arrCredentials; $pMyExten = new paloMyExten($pDB, $arrCredentials['idUser']); $myExten['secret'] = getParameter('secretExtension'); $myExten['language'] = getParameter('language_vm'); $myExten['doNotDisturb'] = getParameter('doNotDisturb'); $myExten['callwaiting'] = getParameter('callWaiting'); $myExten['callForwardOpt'] = getParameter('callForwardOpt'); //n $myExten['callForwardUnavailableOpt'] = getParameter('callForwardUnavailableOpt'); //n $myExten['callForwardBusyOpt'] = getParameter('callForwardBusyOpt'); //n $myExten['callForwardInp'] = getParameter('callForwardInp'); //n $myExten['callForwardUnavailableInp'] = getParameter('callForwardUnavailableInp'); //n $myExten['callForwardBusyInp'] = getParameter('callForwardBusyInp'); //n $myExten['record_in'] = getParameter('recordIncoming'); $myExten['record_out'] = getParameter('recordOutgoing'); $myExten['create_vm'] = getParameter('status_vm'); $myExten['vmemail'] = getParameter('email_vm'); $myExten['vmpassword'] = getParameter('password_vm'); $myExten['vmattach'] = getParameter('emailAttachment_vm'); $myExten['vmsaycid'] = getParameter('playCid_vm'); $myExten['vmenvelope'] = getParameter('playEnvelope_vm'); $myExten['vmdelete'] = getParameter('deleteVmail'); $pMyExten = new paloMyExten($pDB, $arrCredentials['idUser']); $pMyExten->_DB->beginTransaction(); if (!$pMyExten->editExten($myExten)) { $pMyExten->_DB->rollBack(); $jsonObject->set_error($pMyExten->getErrorMsg()); //$jsonObject->set_error($myExten); } else { $pMyExten->_DB->commit(); //$jsonObject->set_message($myExten); $jsonObject->set_message("Changes were saved succefully"); } return $jsonObject->createJSON(); }
function checkmail($smarty, $module_name, $local_templates_dir, $arrConf, $pImap) { $jsonObject = new PaloSantoJSON(); $flag = false; //obtenemos la lista de mails y vemos si ahi algun cambio //obtenemos el mailbox que deseamos leer $mailbox = getParameter('folder'); $action = getParameter('action'); session_commit(); ini_set("session.use_cookies", "0"); //creamos la connección al mailbox $pImap->setMailbox($mailbox); $result = $pImap->login($_SESSION['elastix_user'], $_SESSION['elastix_pass2']); if ($result == false) { $jsonObject->set_status("ERROR"); $jsonObject->set_error($pImap->errMsg); $flag = true; } else { $result = $pImap->getRecentMessage(); if ($result === false) { $jsonObject->set_status("ERROR"); $jsonObject->set_error($pImap->errMsg); $flag = true; } else { if ($result == 0) { $jsonObject->set_status("NOCHANGED"); } else { $jsonObject->set_status("CHANGED"); $flag = true; } } } cleanAlertsImap(); $pImap->close_mail_connection(); return array('there_was_change' => $flag, 'data' => $jsonObject->createJSON()); }
function get_default_code($smarty, $module_name, &$pDB, $arrConf, $credentials) { $jsonObject = new PaloSantoJSON(); $feature = getParameter("fc_name"); if ($credentials['userlevel'] == 'superadmin') { $domain = getParameter('organization'); } else { $domain = $credentials['domain']; } $pFC = new paloFeatureCodePBX($pDB, $domain); if (!$pFC->validateFeatureCodePBX()) { $jsonObject->set_error(_tr("Invalid Organization")); } else { $arrFC = $pFC->getFeaturesCode($domain, $feature); if ($arrFC == FALSE) { $jsonObject->set_error(_tr($pFC->errMsg)); } else { $jsonObject->set_message($arrFC); } } return $jsonObject->createJSON(); }