FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Cloudfare Login for App
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Cloudfare Login for App
Posted: Thu Jun 19, 2025 06:57 PM
hi,

i have a FW-App to read phpbb Forum, but it have stop working since Login have change to Cloudfare.
is there a Way to made my FW-App, login via Cloudfare, and read Message again ?
FUNCTION DownloadFromWWW( cURL, cFile, nThreadNo )
LOCAL oError, nTry, nStatus, nReadystate, cText, nPosi
LOCAL bOldError := ERRORBLOCK( { | e | BREAK( e ) } )
LOCAL oHttp     := Win_OleCreateObject( "MSXML2.ServerXMLHTTP" )
LOCAL aStatus   := HttpStatusArray()
LOCAL aArray, x1

   IF FILE( cFile )
      hb_FileDelete( cFile )
   ENDIF

   IF .NOT. "http" $ cUrl
      oHttp := NIL
      RETURN .F.
   ENDIF

   BEGIN SEQUENCE                                                     // WITH { | oError | BREAK( oError ) }
      oHttp:Open( "GET", cUrl, .F. )
      // oHttp:setRequestHeader( "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0" )
      oHttp:setRequestHeader( "Content-Type", "text/xml; charset=utf-8" )

      nTry := 0
      DO WHILE EMPTY( oHTTP:readyState )                              // = 0
         nTry ++
         millisec( 500 )
         DO Events
         IF nTry > 5
            BREAK
         ENDIF
      ENDDO

      // oHttp:setRequestHeader( "Content-Type", "text/xml; charset=utf-8")
      oHttp:Send()

      nReadystate := oHttp:readyState
      IF nReadystate <> 4
         BREAK
      ENDIF

      nStatus := oHttp:Status
      IF nStatus = 200
         StrFile( oHttp:ResponseBody(), cFile )

         //  x1 := hb_jsonDecode( oHttp:responseText, @aArray )
         x1 := hb_jsonDecode( oHttp:ResponseBody(), @aArray )
         ALTD()

      ELSEIF nStatus = 500
         lBreak := .T.
         cText := "Error Thread No. : " + VAR2CHAR( nThreadNo ) + CRLF + cText
         MessageBoxTimeout( cText, "nStatus =  " + VAR2CHAR( nStatus ), MB_ICONERROR, 3000 )
         lShowOnce := .F.
         BREAK

      ELSE
         Ondummy( oHttp:Status )
         nPosi := ASCAN( aStatus, { | x | x[ 1 ] = nStatus } )
         IF nPosi > 0
            cText := aStatus[ nPosi ] [ 2 ]
            Ondummy( TIME(), cText )
            //             lBreak := .T.
            //             lShowOnce := .T.
            //             BREAK
         ENDIF
      ENDIF

   RECOVER USING oError
      ERRORBLOCK( bOldError )

      IF EMPTY( nReadystate )
      ELSE
         lBreak := .T.
         lShowOnce := .T.
      ENDIF

      Ondummy( TIME(), oError:description, oError:operation, HB_VALTOSTR( oError:osCode ), "Error download " + cUrl )
      cText := hb_Translate( oError:Description, cTranslateCP + "WIN" )
      SayBarText( cText, "ICOERROR" )

      IF lBreak = .F.
         cText := "Error Thread No. : " + VAR2CHAR( nThreadNo ) + CRLF + cText
         MessageBoxTimeout( cText, "readyState " + VAR2CHAR( nReadystate ), MB_ICONERROR, 3000 )
         lShowOnce := .F.
      ENDIF

      IF lShowOnce = .T.
         lShowOnce := .F.
         MsgStop( "Error : " + cText, "readyState " + VAR2CHAR( nReadystate ) )
      ENDIF

      AADD( aError, { "Error Thread No. : " + VAR2CHAR( nThreadNo ), RECNO() } )

   END SEQUENCE

   ERRORBLOCK( bOldError )

   oHttp:Abort()
   oHttp := NIL

RETURN FILE( cFile )
i have include Google Translate to read Spanish Message of the Forum so i like to run my FW-App again.
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Cloudfare Login for App
Posted: Thu Jun 19, 2025 09:06 PM
Dear Jimmy,

Cloudflare specifically protects from those accesses so I don't think we can solve it.

We could provide you a MySQL dump of the forums from time to time to keep you updated :idea:
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion