Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
	$params = array(":idsesion" => $_SESSION["chatIdSession"]);
	$sql =
		"SELECT mc_enviadopor, mc_idarchivo, mc_mensaje, mc_tipomensaje
			 FROM web.wmc_mensajeschat
			WHERE mc_leidoporusuario = 'N'
				AND mc_idsesion = :idsesion
	 ORDER BY mc_id";
	$stmt = DBExecSql($conn, $sql, $params);
	while ($row = DBGetQuery($stmt)) {
		if ($row["MC_TIPOMENSAJE"] == "F")
			$chatFinalizado = true;
	?>
		mensajesNuevos = true;
		if (ventanaAbierta) {
			msg = '<?php 
echo getMensaje($row);
?>
';
			escribirMensaje(window.parent, msg);
		}
	<?	
	}

	// Marco los mensajes como leidos..
	$params = array(":idsesion" => $_SESSION["chatIdSession"]);
	$sql =
		"UPDATE web.wmc_mensajeschat
				SET mc_leidoporusuario = 'S'
			WHERE mc_idsesion = :idsesion";
	DBExecSql($conn, $sql, $params);
}