25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Change captcha.sh to not depend on bash (thanks to Konstantin Khomoutov)(EJAB-1105)

SVN Revision: 2750
This commit is contained in:
Badlop 2009-11-23 12:43:56 +00:00
parent 0838514c27
commit 4dcfde7737
3 changed files with 65 additions and 30 deletions

View File

@ -348,7 +348,7 @@ GNU Make
</LI><LI CLASS="li-itemize">Erlang mysql library. Optional. For MySQL authentication or storage. See section <A HREF="#compilemysql">3.2.1</A>. </LI><LI CLASS="li-itemize">Erlang mysql library. Optional. For MySQL authentication or storage. See section <A HREF="#compilemysql">3.2.1</A>.
</LI><LI CLASS="li-itemize">Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section <A HREF="#compilepgsql">3.2.3</A>. </LI><LI CLASS="li-itemize">Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section <A HREF="#compilepgsql">3.2.3</A>.
</LI><LI CLASS="li-itemize">PAM library. Optional. For Pluggable Authentication Modules (PAM). See section <A HREF="#pam">3.1.4</A>. </LI><LI CLASS="li-itemize">PAM library. Optional. For Pluggable Authentication Modules (PAM). See section <A HREF="#pam">3.1.4</A>.
</LI><LI CLASS="li-itemize">ImageMagick&#X2019;s Convert program, and Bash. Optional. For CAPTCHA challenges. See section <A HREF="#captcha">3.1.8</A>. </LI><LI CLASS="li-itemize">ImageMagick&#X2019;s Convert program. Optional. For CAPTCHA challenges. See section <A HREF="#captcha">3.1.8</A>.
</LI></UL><P> <A NAME="download"></A> </P><!--TOC subsection Download Source Code--> </LI></UL><P> <A NAME="download"></A> </P><!--TOC subsection Download Source Code-->
<H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc10">2.4.2</A>&#XA0;&#XA0;<A HREF="#download">Download Source Code</A></H3><!--SEC END --><P> <A NAME="download"></A> <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc10">2.4.2</A>&#XA0;&#XA0;<A HREF="#download">Download Source Code</A></H3><!--SEC END --><P> <A NAME="download"></A>
</P><P>Released versions of <TT>ejabberd</TT> are available in the ProcessOne <TT>ejabberd</TT> downloads page: </P><P>Released versions of <TT>ejabberd</TT> are available in the ProcessOne <TT>ejabberd</TT> downloads page:
@ -1233,7 +1233,7 @@ In order to take effect there must be a translation file
<H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc29">3.1.8</A>&#XA0;&#XA0;<A HREF="#captcha">CAPTCHA</A></H3><!--SEC END --><P> <A NAME="captcha"></A> <H3 CLASS="subsection"><!--SEC ANCHOR --><A NAME="htoc29">3.1.8</A>&#XA0;&#XA0;<A HREF="#captcha">CAPTCHA</A></H3><!--SEC END --><P> <A NAME="captcha"></A>
</P><P>Some <TT>ejabberd</TT> modules can be configured to require a CAPTCHA challenge on certain actions. </P><P>Some <TT>ejabberd</TT> modules can be configured to require a CAPTCHA challenge on certain actions.
If the client does not support CAPTCHA Forms (<A HREF="http://xmpp.org/extensions/xep-0158.html">XEP-0158</A>), If the client does not support CAPTCHA Forms (<A HREF="http://xmpp.org/extensions/xep-0158.html">XEP-0158</A>),
a web link is provided so the user can fill the challenge in a web browser.</P><P>An example Bash script is provided that generates the image a web link is provided so the user can fill the challenge in a web browser.</P><P>An example script is provided that generates the image
using ImageMagick&#X2019;s Convert program.</P><P>The configurable options are: using ImageMagick&#X2019;s Convert program.</P><P>The configurable options are:
</P><DL CLASS="description"><DT CLASS="dt-description"> </P><DL CLASS="description"><DT CLASS="dt-description">
<B><TT>{captcha_cmd, Path}</TT></B></DT><DD CLASS="dd-description"> <B><TT>{captcha_cmd, Path}</TT></B></DT><DD CLASS="dd-description">

View File

@ -312,7 +312,7 @@ To compile \ejabberd{} on a `Unix-like' operating system, you need:
\item Erlang mysql library. Optional. For MySQL authentication or storage. See section \ref{compilemysql}. \item Erlang mysql library. Optional. For MySQL authentication or storage. See section \ref{compilemysql}.
\item Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section \ref{compilepgsql}. \item Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section \ref{compilepgsql}.
\item PAM library. Optional. For Pluggable Authentication Modules (PAM). See section \ref{pam}. \item PAM library. Optional. For Pluggable Authentication Modules (PAM). See section \ref{pam}.
\item ImageMagick's Convert program, and Bash. Optional. For CAPTCHA challenges. See section \ref{captcha}. \item ImageMagick's Convert program. Optional. For CAPTCHA challenges. See section \ref{captcha}.
\end{itemize} \end{itemize}
\makesubsection{download}{Download Source Code} \makesubsection{download}{Download Source Code}
@ -1531,7 +1531,7 @@ Some \ejabberd{} modules can be configured to require a CAPTCHA challenge on cer
If the client does not support CAPTCHA Forms (\xepref{0158}), If the client does not support CAPTCHA Forms (\xepref{0158}),
a web link is provided so the user can fill the challenge in a web browser. a web link is provided so the user can fill the challenge in a web browser.
An example Bash script is provided that generates the image An example script is provided that generates the image
using ImageMagick's Convert program. using ImageMagick's Convert program.
The configurable options are: The configurable options are:

View File

@ -1,35 +1,70 @@
#!/bin/bash #!/bin/sh
INPUT=$1 INPUT=$1
WAVE1_AMPLITUDE=$((2 + $RANDOM % 5)) if test -n ${BASH_VERSION:-''} ; then
WAVE1_LENGTH=$((50 + $RANDOM % 25)) get_random ()
WAVE2_AMPLITUDE=$((2 + $RANDOM % 5)) {
WAVE2_LENGTH=$((50 + $RANDOM % 25)) R=$RANDOM
WAVE3_AMPLITUDE=$((2 + $RANDOM % 5)) }
WAVE3_LENGTH=$((50 + $RANDOM % 25)) else
W1_LINE_START_Y=$((10 + $RANDOM % 40)) for n in `od -A n -t u2 -N 48 /dev/urandom`; do RL="$RL$n "; done
W1_LINE_STOP_Y=$((10 + $RANDOM % 40)) get_random ()
W2_LINE_START_Y=$((10 + $RANDOM % 40)) {
W2_LINE_STOP_Y=$((10 + $RANDOM % 40)) R=${RL%% *}
W3_LINE_START_Y=$((10 + $RANDOM % 40)) RL=${RL#* }
W3_LINE_STOP_Y=$((10 + $RANDOM % 40)) }
fi
B1_LINE_START_Y=$(($RANDOM % 40)) get_random
B1_LINE_STOP_Y=$(($RANDOM % 40)) WAVE1_AMPLITUDE=$((2 + $R % 5))
B2_LINE_START_Y=$(($RANDOM % 40)) get_random
B2_LINE_STOP_Y=$(($RANDOM % 40)) WAVE1_LENGTH=$((50 + $R % 25))
#B3_LINE_START_Y=$(($RANDOM % 40)) get_random
#B3_LINE_STOP_Y=$(($RANDOM % 40)) WAVE2_AMPLITUDE=$((2 + $R % 5))
get_random
WAVE2_LENGTH=$((50 + $R % 25))
get_random
WAVE3_AMPLITUDE=$((2 + $R % 5))
get_random
WAVE3_LENGTH=$((50 + $R % 25))
get_random
W1_LINE_START_Y=$((10 + $R % 40))
get_random
W1_LINE_STOP_Y=$((10 + $R % 40))
get_random
W2_LINE_START_Y=$((10 + $R % 40))
get_random
W2_LINE_STOP_Y=$((10 + $R % 40))
get_random
W3_LINE_START_Y=$((10 + $R % 40))
get_random
W3_LINE_STOP_Y=$((10 + $R % 40))
B1_LINE_START_X=$(($RANDOM % 20)) get_random
B1_LINE_STOP_X=$((100 + $RANDOM % 40)) B1_LINE_START_Y=$(($R % 40))
B2_LINE_START_X=$(($RANDOM % 20)) get_random
B2_LINE_STOP_X=$((100 + $RANDOM % 40)) B1_LINE_STOP_Y=$(($R % 40))
#B3_LINE_START_X=$(($RANDOM % 20)) get_random
#B3_LINE_STOP_X=$((100 + $RANDOM % 40)) B2_LINE_START_Y=$(($R % 40))
get_random
B2_LINE_STOP_Y=$(($R % 40))
#B3_LINE_START_Y=$(($R % 40))
#B3_LINE_STOP_Y=$(($R % 40))
ROLL_X=$(($RANDOM % 40)) get_random
B1_LINE_START_X=$(($R % 20))
get_random
B1_LINE_STOP_X=$((100 + $R % 40))
get_random
B2_LINE_START_X=$(($R % 20))
get_random
B2_LINE_STOP_X=$((100 + $R % 40))
#B3_LINE_START_X=$(($R % 20))
#B3_LINE_STOP_X=$((100 + $R % 40))
get_random
ROLL_X=$(($R % 40))
convert -size 180x60 xc:none -pointsize 40 \ convert -size 180x60 xc:none -pointsize 40 \
\( -clone 0 -fill white \ \( -clone 0 -fill white \