Captcha : Randomize digit list for INTRUS
This commit is contained in:
parent
e5eed115a4
commit
f9bf266511
|
@ -32,29 +32,15 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
DECOUPE()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
MID=$((LENGTH / 2))
|
||||
|
||||
get_random
|
||||
R=$(($R % 2))
|
||||
|
||||
if [[ $R -eq 1 ]]; then
|
||||
echo "Tapez ${INPUT:0:$MID}\n suivi de ${INPUT:$MID:$MID}"
|
||||
else
|
||||
echo "Saisissez ${INPUT:0:$MID}\n puis ${INPUT:$MID:$MID}"
|
||||
fi
|
||||
}
|
||||
|
||||
INTRUS()
|
||||
{
|
||||
LENGTH=${#INPUT}
|
||||
NUMBERS=$(echo $INPUT | grep -o . | tr '\n' ' ')
|
||||
SORTED_UNIQ_NUM=$(echo "${NUMBERS[@]}" | sort -u | tr '\n' ' ')
|
||||
RANDOM_DIGITS=$(echo 123456789 | grep -o . | sort -R | tr '\n' ' ')
|
||||
INTRUS=-1
|
||||
|
||||
for i in 1 2 3 4 5 6 7 8 9
|
||||
for i in ${RANDOM_DIGITS[@]}
|
||||
do
|
||||
if [[ ! " ${SORTED_UNIQ_NUM[@]} " =~ " ${i} " ]]; then
|
||||
INTRUS=$i
|
||||
|
|
Loading…
Reference in New Issue