Captcha : instructions are now italic
This commit is contained in:
parent
54f0711294
commit
8b042f7020
|
@ -37,10 +37,9 @@ INTRUS()
|
||||||
LENGTH=${#INPUT}
|
LENGTH=${#INPUT}
|
||||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||||
RANDOM_DIGITS=$(echo 123456789 | grep -o . | sort -R | tr '\n' ' ')
|
|
||||||
INTRUS=-1
|
INTRUS=-1
|
||||||
|
|
||||||
for i in ${RANDOM_DIGITS[@]}
|
for i in 1 2 3 4 5 6 7 8 9
|
||||||
do
|
do
|
||||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||||
INTRUS=$i
|
INTRUS=$i
|
||||||
|
@ -71,9 +70,9 @@ INTRUS()
|
||||||
R=$(($R % 100))
|
R=$(($R % 100))
|
||||||
|
|
||||||
if [[ $R -lt 50 ]]; then
|
if [[ $R -lt 50 ]]; then
|
||||||
echo "Tapez $NEWINPUT en\n supprimant les ${DIGIT[$INTRUS]}"
|
echo "Tapez | $NEWINPUT | en supprimant les ${DIGIT[$INTRUS]}"
|
||||||
else
|
else
|
||||||
echo "Saisissez $NEWINPUT en\n enlevant les ${DIGIT[$INTRUS]}"
|
echo "Saisissez | $NEWINPUT | en enlevant les ${DIGIT[$INTRUS]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,36 +95,45 @@ SOMME()
|
||||||
R=$(($R % 100))
|
R=$(($R % 100))
|
||||||
|
|
||||||
if [[ $R -lt 25 ]]; then
|
if [[ $R -lt 25 ]]; then
|
||||||
echo "Tapez le résultat\n de $A + $B"
|
echo "Tapez le résultat de | $A + $B"
|
||||||
elif [[ $R -lt 50 ]]; then
|
elif [[ $R -lt 50 ]]; then
|
||||||
echo "Sommez\n $A et $B"
|
echo "Sommez | $A et $B"
|
||||||
elif [[ $R -lt 75 ]]; then
|
elif [[ $R -lt 75 ]]; then
|
||||||
echo "Additionnez\n $A et $B"
|
echo "Additionnez | $A et $B"
|
||||||
else
|
else
|
||||||
echo "Saisissez le résultat\n de $A + $B"
|
echo "Saisissez le résultat de | $A + $B"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_random
|
|
||||||
RAND_ITALIC=$(($R % 25))
|
|
||||||
get_random
|
get_random
|
||||||
RAND_ANGLE=$(($R % 3))
|
RAND_ANGLE=$(($R % 3))
|
||||||
get_random
|
get_random
|
||||||
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
||||||
|
|
||||||
convert -size 300x60 xc:none -pointsize 20 \
|
INSTRUCTIONS=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 1)
|
||||||
|
INSTRUCTIONS2=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 3)
|
||||||
|
TEXT=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 2)
|
||||||
|
echo " $INSTRUCTIONS"
|
||||||
|
echo "$TEXT"
|
||||||
|
echo "$INSTRUCTIONS2"
|
||||||
|
|
||||||
|
convert -size 300x70 xc:none -pointsize 20 \
|
||||||
\( -clone 0 -fill black \
|
\( -clone 0 -fill black \
|
||||||
-stroke black -strokewidth 1 \
|
-stroke black -strokewidth 1 \
|
||||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
-annotate "${RAND_ANGLE}x25+0+0" "\n $INSTRUCTIONS" \
|
||||||
|
-annotate "${RAND_ANGLE}x0+0+20" "\n $TEXT" \
|
||||||
|
-annotate "${RAND_ANGLE}x25+0+40" "\n $INSTRUCTIONS2" \
|
||||||
-roll +$ROLL_X+0 \
|
-roll +$ROLL_X+0 \
|
||||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
||||||
-roll -$ROLL_X+0 \) \
|
-roll -$ROLL_X+0 \) \
|
||||||
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:"/var/lib/ejabberd/chapril_captchas/$(date "+%Y-%m-%d-%H%M%S")_${INPUT}.png"
|
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:"/var/lib/ejabberd/chapril_captchas/$(date "+%Y-%m-%d-%H%M%S")_${INPUT}.png"
|
||||||
|
|
||||||
convert -size 300x60 xc:none -pointsize 20 \
|
convert -size 300x70 xc:none -pointsize 20 \
|
||||||
\( -clone 0 -fill black \
|
\( -clone 0 -fill black \
|
||||||
-stroke black -strokewidth 1 \
|
-stroke black -strokewidth 1 \
|
||||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
-annotate "${RAND_ANGLE}x25+0+0" "\n $INSTRUCTIONS" \
|
||||||
|
-annotate "${RAND_ANGLE}x0+0+20" "\n $TEXT" \
|
||||||
|
-annotate "${RAND_ANGLE}x25+0+40" "\n $INSTRUCTIONS2" \
|
||||||
-roll +$ROLL_X+0 \
|
-roll +$ROLL_X+0 \
|
||||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
||||||
-roll -$ROLL_X+0 \) \
|
-roll -$ROLL_X+0 \) \
|
||||||
|
|
|
@ -70,9 +70,9 @@ INTRUS()
|
||||||
R=$(($R % 100))
|
R=$(($R % 100))
|
||||||
|
|
||||||
if [[ $R -lt 50 ]]; then
|
if [[ $R -lt 50 ]]; then
|
||||||
echo "Tapez $NEWINPUT en\n supprimant les ${DIGIT[$INTRUS]}"
|
echo "Tapez | $NEWINPUT | en supprimant les ${DIGIT[$INTRUS]}"
|
||||||
else
|
else
|
||||||
echo "Saisissez $NEWINPUT en\n enlevant les ${DIGIT[$INTRUS]}"
|
echo "Saisissez | $NEWINPUT | en enlevant les ${DIGIT[$INTRUS]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,37 +95,35 @@ SOMME()
|
||||||
R=$(($R % 100))
|
R=$(($R % 100))
|
||||||
|
|
||||||
if [[ $R -lt 25 ]]; then
|
if [[ $R -lt 25 ]]; then
|
||||||
echo "Tapez le résultat\n de $A + $B"
|
echo "Tapez le résultat de | $A + $B"
|
||||||
elif [[ $R -lt 50 ]]; then
|
elif [[ $R -lt 50 ]]; then
|
||||||
echo "Sommez\n $A et $B"
|
echo "Sommez | $A et $B"
|
||||||
elif [[ $R -lt 75 ]]; then
|
elif [[ $R -lt 75 ]]; then
|
||||||
echo "Additionnez\n $A et $B"
|
echo "Additionnez | $A et $B"
|
||||||
else
|
else
|
||||||
echo "Saisissez le résultat\n de $A + $B"
|
echo "Saisissez le résultat de | $A + $B"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_random
|
|
||||||
RAND_ITALIC=$(($R % 25))
|
|
||||||
get_random
|
get_random
|
||||||
RAND_ANGLE=$(($R % 3))
|
RAND_ANGLE=$(($R % 3))
|
||||||
get_random
|
get_random
|
||||||
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
||||||
|
|
||||||
convert -size 300x60 xc:none -pointsize 20 \
|
INSTRUCTIONS=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 1)
|
||||||
\( -clone 0 -fill black \
|
INSTRUCTIONS2=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 3)
|
||||||
-stroke black -strokewidth 1 \
|
TEXT=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 2)
|
||||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
echo " $INSTRUCTIONS"
|
||||||
-roll +$ROLL_X+0 \
|
echo "$TEXT"
|
||||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
echo "$INSTRUCTIONS2"
|
||||||
-roll -$ROLL_X+0 \) \
|
|
||||||
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:"/var/lib/ejabberd/chapril_captchas/EXPERIMENTAL_$(date "+%Y-%m-%d-%H%M%S")_{INPUT}.png"
|
|
||||||
|
|
||||||
convert -size 300x60 xc:none -pointsize 20 \
|
convert -size 300x70 xc:none -pointsize 20 \
|
||||||
\( -clone 0 -fill black \
|
\( -clone 0 -fill black \
|
||||||
-stroke black -strokewidth 1 \
|
-stroke black -strokewidth 1 \
|
||||||
-annotate "${RAND_ANGLE}x${RAND_ITALIC}+0+0" "\n $(${TRANSFORMATIONS[$RAND_INDEX]})" \
|
-annotate "${RAND_ANGLE}x25+0+0" "\n $INSTRUCTIONS" \
|
||||||
|
-annotate "${RAND_ANGLE}x0+0+20" "\n $TEXT" \
|
||||||
|
-annotate "${RAND_ANGLE}x25+0+40" "\n $INSTRUCTIONS2" \
|
||||||
-roll +$ROLL_X+0 \
|
-roll +$ROLL_X+0 \
|
||||||
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
|
||||||
-roll -$ROLL_X+0 \) \
|
-roll -$ROLL_X+0 \) \
|
||||||
-flatten -crop 300x60 +repage -quality 500 -depth 11 png:-
|
-flatten -crop 300x70 +repage -quality 500 -depth 11 png:"/var/lib/ejabberd/chapril_captchas/EXPERIMENTAL_$(date "+%Y-%m-%d-%H%M%S")_${INPUT}.png"
|
||||||
|
|
Loading…
Reference in New Issue