java/nekurak.net-web/web/kaptcha.jsp
author František Kučera <franta-hg@frantovo.cz>
Sun Jun 20 14:46:47 2010 +0200 (2010-06-20)
changeset 145 0efefbf5f8b6
parent 83 6767606d6342
permissions -rw-r--r--
Formátování kódu, důsledné používání tabulátorů, drobné úpravy, StringBuilder
franta-hg@83
     1
<?xml version="1.0" encoding="UTF-8"?>
franta-hg@83
     2
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
franta-hg@145
     3
		  xmlns:c="http://java.sun.com/jsp/jstl/core"
franta-hg@145
     4
		  xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
franta-hg@145
     5
		  xmlns:fn="http://java.sun.com/jsp/jstl/functions"
franta-hg@145
     6
		  xmlns:nk="urn:jsptagdir:/WEB-INF/tags/nekurak"
franta-hg@145
     7
		  version="2.0">
franta-hg@83
     8
franta-hg@145
     9
	<jsp:directive.page contentType="application/xhtml+xml"/>
franta-hg@83
    10
franta-hg@145
    11
	<!-- <lokalizace> -->
franta-hg@145
    12
	<c:if test="${param.jazyk != null}">
franta-hg@145
    13
		<fmt:setLocale value="${param.jazyk}" scope="session"/>
franta-hg@145
    14
	</c:if>
franta-hg@145
    15
	<fmt:setBundle basename="cz.frantovo.nekurak.preklady" scope="application"/>
franta-hg@145
    16
	<!-- </lokalizace> -->
franta-hg@83
    17
franta-hg@145
    18
	<nk:stranka titulek="Kaptcha">
franta-hg@83
    19
franta-hg@145
    20
		<h1><c:out value="Kaptcha – ukázka"/></h1>
franta-hg@83
    21
franta-hg@83
    22
		<c:choose>
franta-hg@145
    23
			<c:when test="${param.akce == 'odeslat'}">
franta-hg@145
    24
				<p>Odeslané údaje:</p>
franta-hg@145
    25
franta-hg@145
    26
				<p>Políčko 1: <c:out value="${param.policko1}"/></p>
franta-hg@145
    27
				<p>Políčko 2: <c:out value="${param.policko2}"/></p>
franta-hg@145
    28
				<p>Kaptcha: <c:out value="${param.kaptcha}"/></p>
franta-hg@145
    29
franta-hg@145
    30
				<p>Očekávaná hodnota: <c:out value="${sessionScope['KAPTCHA_SESSION_KEY']}"/></p>
franta-hg@145
    31
franta-hg@145
    32
				<c:choose>
franta-hg@145
    33
					<c:when test="${sessionScope['KAPTCHA_SESSION_KEY'] == param.kaptcha}">
franta-hg@145
    34
						<p class="informacniHlaska">Správně opsaný kód z obrázku.</p>
franta-hg@145
    35
					</c:when>
franta-hg@145
    36
					<c:otherwise>
franta-hg@145
    37
						<p class="chybovaHlaska">Špatně obsaný kód z obrázku.</p>
franta-hg@145
    38
					</c:otherwise>
franta-hg@145
    39
				</c:choose>
franta-hg@145
    40
franta-hg@145
    41
franta-hg@145
    42
franta-hg@145
    43
			</c:when>
franta-hg@145
    44
			<c:otherwise>
franta-hg@145
    45
				<!-- Zobrazíme uživateli registrační formulář. -->
franta-hg@145
    46
				<p>Nějaký formulář, který chceme ochránit proti spamu:</p>
franta-hg@145
    47
				<form method="post" action="kaptcha.jsp?akce=odeslat">
franta-hg@145
    48
					<fieldset>
franta-hg@145
    49
						<label>Políčko 1: <input type="text" name="policko1" maxlength="255"/></label><br/>
franta-hg@145
    50
						<label>Políčko 2: <input type="text" name="policko2" maxlength="255"/></label><br/>
franta-hg@145
    51
					</fieldset>
franta-hg@145
    52
					<fieldset>
franta-hg@145
    53
						<!-- Kaptcha -->
franta-hg@145
    54
						<img src="kaptcha.jpg" alt="ochrana proti spamu" id="kaptchaIMG" title="klikněte pro vygenerování nového obrázku"/><br/>
franta-hg@145
    55
						<script type="text/javascript">
franta-hg@145
    56
							$(function(){
franta-hg@145
    57
								$('#kaptchaIMG').click(function () { $(this).attr('src', 'kaptcha.jpg?' + Math.floor(Math.random()*100) ); })
franta-hg@145
    58
							});
franta-hg@145
    59
						</script>
franta-hg@145
    60
franta-hg@145
    61
						<label>Opište: <input type="text" name="kaptcha" maxlength="255"/></label><br/>
franta-hg@145
    62
					</fieldset>
franta-hg@145
    63
					<fieldset>
franta-hg@145
    64
						<button value="submit">Odeslat</button>
franta-hg@145
    65
					</fieldset>
franta-hg@145
    66
				</form>
franta-hg@145
    67
			</c:otherwise>
franta-hg@83
    68
		</c:choose>
franta-hg@83
    69
franta-hg@145
    70
	</nk:stranka>
franta-hg@83
    71
franta-hg@83
    72
</jsp:root>