Home > Default > Security Images (Recaptcha)

Security Images (Recaptcha)

November 30Hits:0
Advertisement
Hi All,
How to create a security images in APEX.
ex: When we are creating any web new account (gmail,yahoo) they are asking some security verification number to type in the text box.
Now i have to do the same in APEX 3.2 or APEX 4.
i am storing the images in my database as a BLOB content. How to reterieve and show it dynamically.?
IS it possible to do that????
Thanks in advance
Cheers,
Shan
Edited by: Shan on 25 Oct, 2010 7:36 PM

Answers

Hi Udo,
Am still facing the same error while implementing the Patrick Wolf's Recaptcha Process. Now, am experiencing the following error, No matter what i send in the challenge field, right now the return is this.
*'Input error: challenge: Error parsing captcha challenge value\n'*
I have modified the checkrecaptcha function with printing some values to understand the flow of the function
CREATE OR REPLACE
FUNCTION checkRecaptcha
  ( pPrivateKey IN VARCHAR2
  , pRemoteIP   IN VARCHAR2 := OWA_Util.get_cgi_env('REMOTE_ADDR')
  , pChallenge  IN VARCHAR2
  , pResponse   IN VARCHAR2
  RETURN VARCHAR2
IS
    vRequest      Utl_Http.req;
    vPostText     VARCHAR2(500);
    vResponse     Utl_Http.resp;
    vResponseText VARCHAR2(2000);
    vError        VARCHAR2(200);
BEGIN
    -- Build text for the post action.
    -- For a field description, see
    -- http://recaptcha.net/apidocs/captcha/
    vPostText :=
      'privatekey='||Utl_Url.escape(pPrivateKey, TRUE)||CHR(38)||
      'remoteip='  ||Utl_Url.escape(pRemoteIP,   TRUE)||CHR(38)||
      'challenge=' ||Utl_Url.escape(pChallenge,  TRUE)||CHR(38)||
      'response='  ||Utl_Url.escape(pResponse,   TRUE)||CHR(38)
    -- if you need to set a proxy, uncomment next line.
    -- Utl_Http.set_proxy('proxy.it.my-company.com', 'my-company.com');
    -- Send data to reCAPTCHA.
    dbms_output.put_line(vPostText);
    vRequest := Utl_Http.begin_request
                  ( url    => 'http://api-verify.recaptcha.net/verify'
                  , method => 'POST'
    BEGIN
    Utl_Http.set_header
      ( r     => vRequest
      , name  => 'Content-Type'
      , value => 'application/x-www-form-urlencoded'
    DBMS_OUTPUT.PUT_LINE('SET HEADER1 SUCCESS');
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('SET HEADER1 FAILED');
    END;
    BEGIN
    Utl_Http.set_header
      ( r     => vRequest
      , name  => 'Content-Length'
      , value => LENGTH(vPostText)
    DBMS_OUTPUT.PUT_LINE('SET HEADER2 SUCCESS');
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('SET HEADER2 FAILED');
    END;
    BEGIN
    Utl_Http.write_text
      ( r    => vRequest
      , data => vPostText
    DBMS_OUTPUT.PUT_LINE('WRITE TEXT SUCCESS');
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('WRITE TEXT FAILED');
    END;
    vResponse := Utl_Http.get_response(vRequest);
    DBMS_OUTPUT.PUT_LINE('vResponse status code'||'-'||vResponse.status_code);
    DBMS_OUTPUT.PUT_LINE('vResponse reason phrase'||'-'||vResponse.reason_phrase);
    DBMS_OUTPUT.PUT_LINE('vResponse  http version'||'-'||vResponse.http_version);
    IF vResponse.status_code = '200' -- the HTTP call was successful
    THEN
        dbms_output.put_line('Entering If'||'-'||vResponseText||'-'||'the HTTP call was successful'); 
        Utl_Http.read_text(vResponse, vResponseText);
        --Utl_Http.write_text(vResponse, vResponseText);
        dbms_output.put_line('After Read Text'||'-'||vResponseText);
        -- Has the user entered a correct solution?
        IF vResponseText LIKE 'false%'
        THEN
        dbms_output.put_line('Response Text is False');
            vError := SUBSTR(vResponseText, 7);
            --vError := vResponseText;
        END IF;
    ELSE
        dbms_output.put_line('Entering Else Part');
        vError := 'HTTP status: '||vResponse.status_code||'-'||vResponse.reason_phrase;
    END IF;
    Utl_Http.end_response(vResponse);
    RETURN vError;
EXCEPTION
  WHEN utl_http.request_failed THEN
    dbms_output.put_line('Request Failed: ' || utl_http.get_detailed_sqlerrm);
  WHEN utl_http.http_server_error THEN
    dbms_output.put_line('Server Error: ' || utl_http.get_detailed_sqlerrm);
  WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
END checkRecaptcha;After modifying the above function's coding by adding the exceptions and print statement, i tried executing the checkrecaptcha function from backend(sql commands).
DECLARE
P2_RECAPTCHA_ERROR VARCHAR2(4000);
BEGIN
    P2_RECAPTCHA_ERROR := checkRecaptcha
                             ( pPrivateKey => '6Ld3IcASAAAAAIh6U8eJ2g7QEpVCtP-oEGd5Jz-v',
                               pChallenge  => 'God Saves',
                               pResponse   => 'God Saves'
    dbms_output.put_line(P2_RECAPTCHA_ERROR);
END;even after doing this am getting the following error. Can you please guide me to proceed further from here.
privatekey=6Ld3IcASAAAAAIh6U8eJ2g7QEpVCtP-oEGd5Jz-v&remoteip=192.168.1.145&challenge=God%20Saves&response=God%20Saves&
SET HEADER1 SUCCESS
SET HEADER2 SUCCESS
WRITE TEXT SUCCESS
vResponse status code-200
vResponse reason phrase-OK
vResponse  http version-HTTP/1.1
Entering If--the HTTP call was successful
After Read Text-false
'Input error: challenge: Error parsing captcha challenge value\n'
Response Text is False
'Input error: challenge: Error parsing captcha challenge value\n'Thanks,
Sakthi.
Edited by: Sakthi on Jan 5, 2011 10:39 PM
Edited by: Sakthi on Jan 5, 2011 10:57 PM
Edited by: Sakthi on Jan 6, 2011 3:07 AM

Read other 6 answers

Tags:

Related Articles

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.764 s.