function uninstallPaquete($arrConf) { $oPackages = new PaloSantoPackages($arrConf['ruta_yum']); $paquete = getParameter("paquete"); $resultado = $oPackages->uninstallPackage($paquete); $jsonObject = new PaloSantoJSON(); $jsonObject->set_status($resultado); 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()); }
//es necesario cargar los css y js que el modulo pone //$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'));
function getAllDataAction(&$pDB1, &$pDB2) { $jsonObject = new PaloSantoJSON(); $pControlPanel = new paloSantoControlPanel($pDB1, $pDB2); $message = $pControlPanel->getAllDevicesXML(); $arrPrev = array(); $data = array(); $session = getSession(); if (isset($session['operator_panel']['prev'])) { $arrPrev = $session['operator_panel']['prev']; } else { $session['operator_panel']['prev'] = $message; putSession($session); } $diff = $message; if (count($diff) > 0) { $i = 0; foreach ($diff as $key => $value) { foreach ($value as $key2 => $value2) { if ($key2 == "activity") { if (!isset($session['operator_panel'][$message[$key]["numconf"]])) { $data[$i]['Tipo'] = "conference"; $data[$i]['key'] = $message[$key]["numconf"]; $data[$i]['data'] = array($key2 => $value2); $i++; $session = getSession(); $session['operator_panel'][$message[$key]["numconf"]] = array(); putSession($session); } } elseif ($key2 == "parties") { $data[$i]['Tipo'] = "conference"; $data[$i]['key'] = $message[$key]["numconf"]; $data[$i]['data'] = array($key2 => $value2); $i++; } elseif ($key2 == "speak_time" && $value2 != " ") { if ($message[$key]["context"] == "macro-dialout-trunk" && $message[$key]["trunk"] != " ") { $data[$i]['Tipo'] = "trunk"; $data[$i]['key'] = $message[$key]["user"] . "_" . $message[$key]["trunk"]; $data[$i]['data'] = array($key2 => $value2); $i++; } elseif ($message[$key]["context"] != "macro-dialout-trunk") { $data[$i]['Tipo'] = "extension"; $data[$i]['key'] = $message[$key]["user"]; $data[$i]['data'] = array($key2 => $value2); $i++; } } elseif ($key2 == "waiting" || $key2 == "queueNumber") { $data[$i]['Tipo'] = "queue"; $data[$i]['key'] = $message[$key]["queueNumber"]; $data[$i]['data'] = array($key2 => $value2); $i++; } elseif ($key2 == "time") { $data[$i]['Tipo'] = "parkinglot"; $data[$i]['key'] = $message[$key]["lotNumber"]; $data[$i]['data'] = array($key2 => $value2); $i++; } elseif ($key2 == "extension" || $key2 == "lotNumber") { $data[$i]['Tipo'] = "parkinglot"; $data[$i]['key'] = $message[$key]["lotNumber"]; $data[$i]['data'] = array($key2 => $value2); $i++; } elseif ($key2 == "voicemail") { $data[$i]['Tipo'] = "extension"; $data[$i]['key'] = $message[$key]["user"]; $data[$i]['data'] = array($key2 => $value2 . "_" . $message[$key]["voicemail_cnt"]); $i++; } else { $data[$i]['Tipo'] = "extension"; $data[$i]['key'] = $message[$key]["user"]; $data[$i]['data'] = array($key2 => $value2); $i++; } } } if (count($data) > 0) { $jsonObject->set_status("CHANGED"); $jsonObject->set_message($data); } else { $jsonObject->set_message(array()); } } else { $jsonObject->set_message(array()); } // writeLOG("access.log", print_r($data,true)); 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_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 getFaxStatus($module_name, $local_templates_dir, &$pDB, $arrConf) { global $arrCredentials; $pMyFax = new paloMyFax($pDB, $arrCredentials['idUser']); $jsonObject = new PaloSantoJSON(); $my_fax = $pMyFax->getMyFaxExtension(); if ($my_fax == false) { $status = FALSE; } else { // 1 COMPARA EL VALOR DEVUELTO CON EL VALOR QUE ESTA EN SESION //SI HUBO UN CAMBIO // si hay cambio status true // poner el nuevo valor el seesion $session = getSession(); if ($session['faxlistStatus'] != $my_fax['STATUS']) { $msgResponse = $my_fax['STATUS']; $status = true; } else { $status = false; } if ($status) { //hubo un cambio $jsonObject->set_status("CHANGED"); $jsonObject->set_message($msgResponse); //el valor del status actual } else { $jsonObject->set_status("NOCHANGED"); } } $session['faxlistStatus'] = $my_fax['STATUS']; putSession($session); return array("there_was_change" => $status, "data" => $jsonObject->createJSON()); }
function save_module($smarty, $module_name, $local_templates_dir, $arrLangModule, &$pDB_acl, $arrConf) { $errMsg = ''; $error = FALSE; $jsonObject = new PaloSantoJSON(); $pNewMod = new paloSantoBuildModule($arrConf['elastix_dsn']['settings'], $arrConf['elastix_dsn']['menu'], $arrConf['elastix_dsn']['acl']); if (!empty($pNewMod->errMsg)) { $jsonObject->set_error("ERROR DE DB: {$pNewMod->errMsg} <br>"); return $jsonObject->createJSON(); } // Nivel al cual crear. Valores son 0 para nivel-2 y 1 para nivel-3 $iNivel = getParameter('module_level_options'); // Este arreglo representará la rama de módulos intermedios y finales $moduleBranch = array(); if (getParameter('parent_1_existing_option') == 0) { $moduleBranch[] = array('existing' => getParameter('parent_module')); } else { $parentName = getParameter('parent_1_name'); $level = array('create' => phpidentifier(strtolower($parentName)), 'name' => $parentName); if ($level['name'] == '') { $errMsg .= _tr('Level 1 Parent Name') . ', '; } if (trim($level['create']) == '') { $errMsg .= _tr('Level 1 Parent Id') . ' (' . _tr('Level 1 Parent Id is empty') . '), '; } $moduleBranch[] = $level; } if ($iNivel == 1) { if (getParameter('parent_2_existing_option') == 0) { $moduleBranch[] = array('existing' => getParameter('parent_module_2')); } else { $parentName = getParameter('parent_2_name'); $level = array('create' => phpidentifier(strtolower($parentName)), 'name' => $parentName); if ($level['name'] == '') { $errMsg .= _tr('Level 2 Parent Name') . ', '; } if (trim($level['create']) == '') { $errMsg .= _tr('Level 2 Parent Id') . ' (' . _tr('Level 2 Parent Id is empty') . '), '; } $moduleBranch[] = $level; } } $moduleName = getParameter('module_name'); $level = array('create' => phpidentifier(strtolower($moduleName)), 'name' => $moduleName); if ($level['name'] == '') { $errMsg .= _tr('Module Name') . ', '; } if (trim($level['create']) == '') { $errMsg .= _tr('Module Id') . ' (' . _tr('Module Id is empty') . '), '; } elseif (file_exists($arrConf['basePath'] . '/modules/' . $level['create'])) { $errMsg .= $level['create'] . ' (' . _tr('Folder already exists') . '),'; } $moduleBranch[] = $level; // Listado de IDs de grupos a autorizar para nuevo módulo $groupList = explode("\n", trim(getParameter('group_permissions'))); // Validación según tipo de módulo $sAutor = $sEmail = $sUrl = $fieldList = NULL; $sModuleType = getParameter('module_type'); if ($sModuleType == 'framed') { $sUrl = getParameter('valor_url'); if ($sUrl == '') { $errMsg .= _tr('URL is empty') . ', '; } } else { // form|grid $arr_form = explode("\n", trim(getParameter('arr_form'))); if (count($arr_form) <= 0) { $errMsg .= _tr('Module Description is empty') . ', '; } $sAutor = getParameter('your_name'); if ($sAutor == '') { $errMsg .= _tr('Your Name') . ', '; } $sEmail = getParameter('email_module'); if ($sEmail == '') { $errMsg .= _tr('Your e-mail') . ', '; } if ($sModuleType == 'form') { $fieldList = array(); foreach ($arr_form as $s) { $fieldList[] = explode('/', $s); } } else { $fieldList = $arr_form; } } if ($errMsg != '') { $errMsg = _tr('The following fields contain errors') . ': ' . $errMsg; $errTitle = _tr('Validation Error'); $error = TRUE; } else { $errTitle = _tr('ERROR'); $r = $sModuleType == 'framed' ? $pNewMod->createModuleURL($moduleBranch, $groupList, $sUrl) : $pNewMod->createModuleFormGrid($moduleBranch, $groupList, $sAutor, $sEmail, $sModuleType, $fieldList); if (!$r) { $error = TRUE; $errMsg = $pNewMod->errMsg; } } $response = array(); if ($error) { $jsonObject->set_status('ERROR'); $msgTitle = $errTitle; $message = $errMsg; } else { $new_id_module = $moduleBranch[count($moduleBranch) - 1]['create']; $response["moduleId"] = $new_id_module; $msgTitle = _tr('Message'); $message = _tr('The module was crated successfully') . '. ' . _tr('If you are not redirected to your new module in a few seconds, you can click') . " <a href=?menu={$new_id_module}>" . _tr('here') . "</a>."; } $htmlMessage = "<table width='99%' height='0px' border='0' cellspacing='0' cellpadding='0' align='center' class='message_board'>"; $htmlMessage .= "<tr>"; $htmlMessage .= "<td height='0px' valign='middle' id='mb_title' name='mb_title' class='mb_title'>" . $msgTitle . "</td>"; $htmlMessage .= "</tr>"; $htmlMessage .= "<tr>"; $htmlMessage .= "<td height='0px' valign='middle' id='mb_message' name='mb_message' class='mb_message'>" . $message . "</td>"; $htmlMessage .= "</tr>"; $htmlMessage .= "</table>"; $response["message"] = $htmlMessage; $jsonObject->set_message($response); return $jsonObject->createJSON(); }
function getChatContactsStatus($searchFilter) { $jsonObject = new PaloSantoJSON(); $dummy = NULL; $newListContacts = getNewListElastixAccounts($searchFilter, $dummy); if ($newListContacts === false) { $status = FALSE; } else { // 1 COMPARA EL VALOR DEVUELTO CON EL VALOR QUE ESTA EN SESION //SI HUBO UN CAMBIO // si hay cambio status true // poner el nuevo valor el seesion $session = getSession(); //var_dump($session['chatlistStatus']); //print_r("---------------------------------------------------------------------------------------"); //var_dump($newListContacts); //file_put_contents("/tmp/testchat",); if ($session['chatlistStatus'] != $newListContacts) { $msgResponse = $newListContacts; $status = true; } else { $status = false; } if ($status) { //hubo un cambio $jsonObject->set_status("CHANGED"); $jsonObject->set_message($msgResponse); //el valor del status actual } else { $jsonObject->set_status("NOCHANGED"); } } $session['chatlistStatus'] = $newListContacts; putSession($session); return array("there_was_change" => $status, "data" => $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 faxListStatus($smarty, $module_name, $local_templates_dir, $arrConf, $arrLang) { $oFax = new paloFax(); $arrFax = $oFax->getFaxList(); $status = TRUE; $end = count($arrFax); $arrFaxStatus = $oFax->getFaxStatus(); $arrData = array(); foreach ($arrFax as $fax) { $arrData[$fax['extension']] = $arrFaxStatus['modems']['ttyIAX' . $fax['dev_id']] . ' on ttyIAX' . $fax['dev_id']; } $statusArr = thereChanges($arrData); if (empty($statusArr)) { $status = FALSE; } $jsonObject = new PaloSantoJSON(); if ($status) { //este status es true solo cuando el tecnico acepto al customer (al hacer click) //sleep(2); //por si acaso se desincroniza en la tabla customer el campo attended y llenarse los datos de id_chat y id_chat_time $msgResponse["faxes"] = $statusArr; $jsonObject->set_status("CHANGED"); $jsonObject->set_message($msgResponse); } else { $jsonObject->set_status("NOCHANGED"); } return array("there_was_change" => $status, "data" => $jsonObject->createJSON()); }
function call_status($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $credentials) { session_commit(); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials["domain"]; } else { $jsonObject->set_status("HANGUP"); return array("there_was_change" => true, "data" => $jsonObject->createJSON()); } $status = true; $pRecording = new paloSantoRecordings($pDB, $domain); $extension = getParameter("extension"); $result = $pRecording->Obtain_Protocol_Current_User($domain, $extension); $state = $pRecording->callStatus($result['dial']); $jsonObject = new PaloSantoJSON(); if ($state == "hangup") { $status = FALSE; } if ($status) { $msgResponse["status"] = $state; $jsonObject->set_status("RECORDING"); $jsonObject->set_message($msgResponse); return array("there_was_change" => false, "data" => $jsonObject->createJSON()); } else { $jsonObject->set_status("HANGUP"); return array("there_was_change" => true, "data" => $jsonObject->createJSON()); } }
function updateShowCallers($smarty, &$pDB, $module_name, $credentials) { global $arrPermission; $id_conf = getParameter("id_conf"); $offset = getParameter("offset"); $limit = getParameter("limit"); $error = ""; $change = false; $id_conf = getParameter("id_conf"); $domain = getParameter('organization'); if ($credentials['userlevel'] != 'superadmin') { $domain = $credentials['domain']; } $pConf = new paloConference($pDB, $domain); $conference = $pConf->getConferenceById($id_conf); if ($conference == false) { $error = _tr($pConf->errMsg); } else { //permission $invite_part = in_array("admin_conference_participant", $arrPermission); $room = $conference["confno"]; $date = time(); if ($date >= strtotime($conference["startTime"]) && $date <= strtotime($conference["endtime"]) || $conference["startTime"] == "1900-01-01 12:00:00") { $total = $conference["members"]; $arrData = array(); $arrMemb = array(); $data = array(); if ($total != 0) { $arrMemb = $pConf->ObtainCallers($room); if ($arrMemb === false) { $error = _tr("Error getting conference data.") . $pConf->errMsg; } else { $membPagg = array_slice($arrMemb, $offset, $limit); foreach ($membPagg as $memb) { $arrTmp = array(); $arrTmp[0] = $memb['userId']; $arrTmp[1] = trim($memb['callerId']); $arrTmp[2] = $memb['duration']; $arrTmp[3] = empty($memb['mode']) ? "user" : "admin"; $status = strstr($memb['status'], "Muted"); //falso si no encuentra la palabra en el arreglo $checked = empty($status) ? "" : "checked"; if ($invite_part) { $arrTmp[4] = "<input type='checkbox' name=mute_{$memb['userId']} class='conf_mute' {$checked}>"; $arrTmp[5] = "<input type='checkbox' name=kick_{$memb['userId']} class='conf_kick'>"; } $arrData[] = $arrTmp; $data[$memb['userId']] = $memb['callerId']; } } } } else { $error = _tr("Conference out of Time"); } } $jsonObject = new PaloSantoJSON(); if ($error == "") { if (thereChangesShowCallers($data) == true) { $jsonObject->set_status("CHANGED"); $jsonObject->set_message($arrData); $change = true; } else { $jsonObject->set_status("NO CHANGED"); } } else { $jsonObject->set_error($error); $change = true; } return array('there_was_change' => $change, "data" => $jsonObject->createJSON()); }