Tuesday, November 28, 2006
Create CAPTCHA in PL/SQL
To create Captcha you must use dd_bmp package (package is using some functions from
http://www.adp-gmbh.ch/blog/2005/november/22.html).
To test Captcha you run program:
http://www.adp-gmbh.ch/blog/2005/november/22.html).
procedure Captcha (
name_array in owa.vc_arr,
value_array in owa.vc_arr
) is
pt raw(100);
l_lob blob;
vt varchar2(100);
FUNCTION namedParam(
p_searchVal in varchar2,
p_name_array in owa.vc_arr,
p_value_array in owa.vc_arr
) RETURN varchar2 IS
i integer;
BEGIN
FOR i IN 1..nvl(p_name_array.count,0) LOOP
if p_name_array(i)=p_searchVal then
return p_value_array(i);
end if;
END LOOP;
return null;
END;
begin
pt := namedParam(
'pt',
name_array ,
value_array
);
pt := utl_encode.base64_decode(pt);
vt := utl_raw.cast_to_varchar2(pt);
l_lob := dd_bmp.captcha(vt);
owa_util.mime_header( 'image/bmp', FALSE );
htp.p('Content-length: ' dbms_lob.getlength( l_lob ));
owa_util.http_header_close;
wpg_docload.download_file( l_lob );
end;
To test Captcha you run program:
procedure TestCaptcha (
name_array in owa.vc_arr,
value_array in owa.vc_arr
)
as
x raw(100);
vcapchapreveri raw(100);
vcapchavrednost raw(100);
v varchar2(100);
begin
for i__ in 1..nvl(name_array.count,0) loop
if name_array(i__) = 'capchavrednost' then vcapchavrednost := value_array(i__);
elsif name_array(i__) = 'capchapreveri' then vcapchapreveri := utl_raw.cast_to_raw(value_array(i__));
end if;
end loop;
begin
if utl_encode.base64_encode(vcapchapreveri) = vcapchavrednost then
htp.p ('OK<BR>');
else
htp.p ('NOT OK<BR>');
end if;
exception when others then null;
htp.p ('NOT OK<BR>');
end;
v := dd_random.rndchardd_random.rndchardd_random.rndchardd_random.rndchar;
x := utl_raw.cast_to_raw(v);
x := utl_encode.base64_encode(x);
htp.p('
<form method=post>
<img src="p_htmldokumenti.capcha?pt='x'">
<input type="text" name="capchapreveri" value="" size="4" maxlength="4">
<input type="hidden" name="capchavrednost" value="'x'">
<input type="submit" name="nnnn" value="Preveri">
</form>
');
exception when others then htp.p(sqlerrm);
end;
Comments:
<< Home
Hi Domen,
I was not able to find dd_bmp package. Do you still have it?If so, could you please share it with me?
I need it to use your code of a captcha implemented in pl/sql.
Thanks a lot!
Fernanda
I was not able to find dd_bmp package. Do you still have it?If so, could you please share it with me?
I need it to use your code of a captcha implemented in pl/sql.
Thanks a lot!
Fernanda
Libs are on new location
http://sourceforge.net/p/rasd/code-0/HEAD/tree/trunk/RASD_1.0/Documentation/plsqllib/
http://sourceforge.net/p/rasd/code-0/HEAD/tree/trunk/RASD_1.0/Documentation/plsqllib/
You can test TestCaptcha with the browser:
http://your server address: port/DAD name locating captcha procedure/!TestCaptcha
If you use PL/SQL Developer (http://www.allroundautomations.com/) you can test it from test window.
declare
begin
TestCaptcha;
end;
where output is in HTP Output tab.
If you still have problems please post.
http://your server address: port/DAD name locating captcha procedure/!TestCaptcha
If you use PL/SQL Developer (http://www.allroundautomations.com/) you can test it from test window.
declare
begin
TestCaptcha;
end;
where output is in HTP Output tab.
If you still have problems please post.
thanks Domen for reply!.
well i tested the test captcha and i had and error the page response with not ok
and i couldn“t see the image.
i create the following packages:
bmp
ddbmp
ddrandom
and the procedures
captcha
testcaptcha
well i tested the test captcha and i had and error the page response with not ok
and i couldn“t see the image.
i create the following packages:
bmp
ddbmp
ddrandom
and the procedures
captcha
testcaptcha
Hi Dome!
i tested the package dd_bmp and it worked fine i get the test.bmp,
so i think that my problem could be in the package when i call into the procedure CAPTCHA at : wpg_docload.download_file(l_lob);
Do you have any idea about it does not works for me??
thanks for your time friend!!
i tested the package dd_bmp and it worked fine i get the test.bmp,
so i think that my problem could be in the package when i call into the procedure CAPTCHA at : wpg_docload.download_file(l_lob);
Do you have any idea about it does not works for me??
thanks for your time friend!!
I found the problem:
It shoul be:
< img src="!Captcha?pt='||x||'" > -> look in published source
You must cal sample like:
http://ohs url :port/..DAD../!TestCaptcha
I posted latest version of all programs in lib location. http://sourceforge.net/p/rasd/code-0/HEAD/tree/trunk/RASD_1.0/Documentation/plsqllib/
All libs are now added to RASD enviorment http://sourceforge.net/projects/rasd/
Best regards Domen
It shoul be:
< img src="!Captcha?pt='||x||'" > -> look in published source
You must cal sample like:
http://ohs url :port/..DAD../!TestCaptcha
I posted latest version of all programs in lib location. http://sourceforge.net/p/rasd/code-0/HEAD/tree/trunk/RASD_1.0/Documentation/plsqllib/
All libs are now added to RASD enviorment http://sourceforge.net/projects/rasd/
Best regards Domen
Hi! I test the TestCaptcha with PL/SQL Developer (http://www.allroundautomations.com/) and run this:
declare
begin
TestCaptcha;
end;
But post this error: PLS-00306: wrong number or types or arguments in call to 'TESTCAPTCHA', the procedure have 2 parameters, but i don't understand what send it here.
Can you help me, please.
Tank you !!!
declare
begin
TestCaptcha;
end;
But post this error: PLS-00306: wrong number or types or arguments in call to 'TESTCAPTCHA', the procedure have 2 parameters, but i don't understand what send it here.
Can you help me, please.
Tank you !!!
You have
procedure TestCaptcha (
name_array in owa.vc_arr,
value_array in owa.vc_arr
)
these parameters are for runing over http server.
In one of development tool you can set values like:
declare
-- Non-scalar parameters require additional processing
name_array owa.vc_arr;
value_array owa.vc_arr;
begin
-- Call the procedure
name_array(1) := 'capchavrednost';
value_array(1) := '64474D7964513D3D'; --coded value of captcha value(base 64)
name_array(2) := 'vcapchapreveri';
value_array(2) := 'tc2u'; -- written value of captcha encode(tc2u) = 64474D7964513D3D
TestCaptcha(name_array => name_array,
value_array => value_array);
end;
For captcha image you have to set path to procedure - src="p_htmldokumenti.capcha?pt='x'">
Best regards Domen
Post a Comment
procedure TestCaptcha (
name_array in owa.vc_arr,
value_array in owa.vc_arr
)
these parameters are for runing over http server.
In one of development tool you can set values like:
declare
-- Non-scalar parameters require additional processing
name_array owa.vc_arr;
value_array owa.vc_arr;
begin
-- Call the procedure
name_array(1) := 'capchavrednost';
value_array(1) := '64474D7964513D3D'; --coded value of captcha value(base 64)
name_array(2) := 'vcapchapreveri';
value_array(2) := 'tc2u'; -- written value of captcha encode(tc2u) = 64474D7964513D3D
TestCaptcha(name_array => name_array,
value_array => value_array);
end;
For captcha image you have to set path to procedure - src="p_htmldokumenti.capcha?pt='x'">
Best regards Domen
<< Home

