NetTalk Central

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - JohanR

Pages: [1] 2 3 ... 25
1


Hi Jari

Some suggestions , sure there are other ways too.

Seeing as you have it in a stringtheory object already, no reason to move to local text field, use the ST methods
Also possibly search for something a bit more specific eg.  data:image/png;base64,

I don't have enough knowledge of image formats ,encoding and you should be searching for,
but you might encounter a different image, with a different starting string, or a random comma, but it's not valid for what you need.
You can then expand on the search string, to other possibilities, if required

              tmp_st.fromblob(ALI:Photo)
              pos# = tmp_st.FindChars('data:image/png;base64,')
              if pos# = 0
                 message('not found')
              else
                 if pos# = 1
                    tmp_st.RemoveFromPosition(pos#,22)
                    tmp_st.Base64Decode()
                   
                    loc:filename = 'c:\tmp\' & random(11111,99999) & '.png'
                    tmp_st.savefile(loc:filename)
                    tmp_st.toblob(ALI:Photo)
                   
                    message('done and saved to:' & loc:filename)
                 else
                    message('possible other issue')
                 end
              end



2
Hi,

Have managed this, however am running into all sorts of other issues when the 2 sites are exchanging information.
Will report back if I make any progress and if the added complication justifies the end result.

cheers,

Johan





3
Hi Bruce

Sorry ,
The loading of the file into a ST object was to try the ST decode,
but I had some issues with saving the file into usbale format.
will check again later and and try to figure out why

Johan

4
Hi Bruce

Yes,

below first few chars from the file that was saved with this code in the desktop program.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAAX

Code in desktop program
loc:filename = 'c:\tmp\' & random(11111,99999) & '.jpg'
IF BLOBTOFILE(ALI:Photo,loc:filename)  !returns an ERRORCODE if copy fails
   MESSAGE('BLOB did not copy due to the following ERRORCODE: ' & ERRORCODE())
else
   tmp_st.loadfile(loc:filename)
   message('saved:') 
END
Copying that to decoding website produces an image file.

Think it needs a few more lines of code to sort it out to display on screen

regards

Johan





I

5
Hi Jari

From the BLOB help
If you need to save images to a BLOB, and later restore them to an output file, the type of image should also be saved in the database (JPG, GIF, BMP, etc.).
Using BLOBTOFILE to save to a different extension can produce unpredictable results.

Possible problem is that the original file is PNG, and when the Blob is saved to disk it's a base64 encoded png file.
so you probably need to do some decoding and converting the image to different format.


regards

Johan


6
Hi Jari

I would try to save the image to disk to validate it and debug that way

I did have a quick look, but got a compile error when I tried to add the blobtoimage function

Will have a look later when I have more time

Johan

 

7

Hi,

Embedding a NTWS (Form) in an Iframe on an external website is resulting in the the NTWS page being called continuously.
In checking in with ChatGPT, the proposed answer it seems is add some JS to the NTWS page, see below.

Is this the correct way?
I have not added any JS before,
where and how to add this if this is correct way to do this?

The NTWS will only be used for this embedding purpose.

thanks

Johan




1. JavaScript to Detect Recursive Loading
Add this JavaScript snippet to the managemember page:

javascript
Copy code
if (window.location !== window.parent.location) {
    // Check if the page is loaded within an iframe, then prevent recursive load
    if (window.location.href === window.parent.location.href) {
        window.location = 'about:blank'; // Redirect to blank to stop recursion
    }
}
This code verifies if the managemember page is loaded in an iframe and compares the URL of the iframe with its parent. If they match, it stops further recursive loading by redirecting the iframe to a blank page.

8
Hi,

Found the solution!
Thanks John and the clarionlive team!

What an incredible resource

https://www.youtube.com/watch?v=CVTOUqz1uQ4&t=654s

cheers,
johan


9
Hi,

I am looking to embed A NTWS page on an external website, in this case a WIX hosted site.

And with some help from my ChatGPT, it seems I need to set a CSP on the NTWS, to allow this.

The X-Frame is currently set to "sameorigin" but in order to allow this and the external website as well,
I need to add the external URL and this needs to be done via a CSP.

How and where to set in NTWS?

thanks

Johan







10
Hi Jane

Thank you again for your help and effort,

I used the code and all working fine, hope I have it correct and will test.

The new zipped app does not have any embed code in webhandler, perhaps just zipped the wrong app, unless I'm missing something.
My code and embed point I used.

thanks again,

Johan



p_web._SendFile PROCEDURE(string p_FileName,Long p_header=NET:SendHeader)
! Start of "NetTalk Method Data Section"
! [Priority 1500]
loc:parent  string(252)   ! should always be a lower-case string
loc:done        Long
loc:filename    string(252)
! [Priority 6500]
! End of "NetTalk Method Data Section"

  CODE
  ! Start of "NetTalk Method Executable Code Section"
  ! [Priority 1500]
 
    loc:parent = self.PlainText(Lower(self.GetValue('_parentProc_')))
    loc:filename = SELF.GetPageName(Lower(p_FileName))
 
  ! Start of "Before SendFiles in DLLs"
  ! [Priority 5000]

    !############################# 
          block# = false
          case loc:filename
          of 'nwp_wineshop'
             block# = true
          of 'aboutus'
             block# = true
          of 'nwp_aboutus'
             block# = true
          end !case   
          if block# = true
             p_web.trace('case triggered:' & loc:filename)
             p_web.SendError (404,'The page cannot be found', 'The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.')
             return
          end   
    !############################# 

         
 
  ! End of "Before SendFiles in DLLs"
    loc:done = NetWebDLL_avc_b_SendFile(p_web, loc:Filename, loc:Parent)
    If loc:Done then Return.
    loc:done = NetWebDLL_avcfunc_SendFile(p_web, loc:Filename, loc:Parent)
    If loc:Done then Return.
  ! [Priority 3040]
 
    do Remap:tvcweb
    do CaseStart:tvcweb





11
Hi Jane

thanks!

Unfortunately I'm still on C10, so could not open the example you so kindly created.
It was an idea I had to consider and pursue, and with your suggestion and example it seems like it's a good plan.

Any chance of posting the code and where to pop it in to the webhandler procedure.


thanks

Johan

12
Hi Ron,

Just to add,

There really are 3 situations,

Login required - Pops the login page
Only serve if true - This procedure or page might be embedded on another procedure/page , so if false, send the blank, however it is a valid procedure, but only if certain conditions are met.
Hide - Send "page not found"

Something I have not looked at,
is to add code to serve "page not found" HTML

regards

Johan


13
Hi Ron

Thanks for info and suggestions,
Deleting them not an option,
as some might be work in progress and will be in next release, or some have been taken out of production, but I still want to keep the code in the app.

Yes, chances are that the names won't be guessed, but they can be, especially if they were in production and now have been taken out.

Currently what I am seeing is a blank browser screen, so it looks like a valid URL but with no data.

Ideally would like to display an error msg , "page not found"
So even if the procedure is there, it's invalid and not available




thanks

Johan








14
Hi,

What is a way to make unused web procedures not visible?

My app is full of procedures that are not being used, so I don't want them to be visible.

I have "Login rqd" set to true as well as "Only serve if" = false

anything else to consider?

and I notice that "Login rqd" is available via a global list
anything similar available for "Serve only" ?

thanks

Johan







15
Web Server - Ask For Help / Re: Convert text to HTML text for display
« on: September 26, 2024, 06:32:07 AM »
Hi,

Thanks for your help,
but think I was barking up the wrong tree, something I do way too often nowadays!

Something else is breaking my HTML page

cheers,

Johan


 

Pages: [1] 2 3 ... 25