NetTalk Central

Author Topic: servedocument from html  (Read 2982 times)

johncorry

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Email
servedocument from html
« on: May 27, 2013, 06:44:37 PM »
I am using html files for the index page body. In one of these I would like to be able to have a file selection for downloading. If I set a link within an html to the url 'servedocument' and have the file described there (eg p_web.SetValue('name','Forums.Tps') ) it works fine. So I could have a series of servedocument pages each with a different file identified. But is there some way to send a value within the url call that can be used within a case structure or something to serve the different files?

Thanks again
John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: servedocument from html
« Reply #1 on: May 27, 2013, 09:05:38 PM »
Hi John,

yes.
A URL contains the "Identifier" part, but it can also include parameters. Parameters are of the form name=value, are & separated, and the first parameter is separated from the identifier by a ?. For example;

http://www.whatever.com/servedocument
is the identifier part. but if you had
http://www.whatever.com/servedocument?name=forums.tps
then
p_web.GetValue('name')
returns
'forums.tps'

here's another one;
http://www.whatever.com/servedocument?name=forums.tps&type=tps&login=fred&password=notverysecure
in the above you use p_web.GetValue to retrieve the various parameter values.

cheers
Bruce

johncorry

  • Newbie
  • *
  • Posts: 27
    • View Profile
    • Email
Re: servedocument from html
« Reply #2 on: May 28, 2013, 01:42:45 PM »
Thanks again Bruce - that works nicely.
In order to make it more secure I am trying to limit which files and from which folder with the following code.

  loc:allow = 0
  IF p_web.GetValue('name') = 'Forums.Tps'|
    OR p_web.GetValue('name') = 'ForumUsers.Tps'
    loc:allow = 10
  END
  IF loc:allow = 10
    loc:filename = clip(p_web.site.apppath)& 'web\ozfile\' & p_web.GetValue('name') 
  ! you need to add code here to check that the name is valid, and is within the range
  ! of files you want to allow to be served. If this is not done then ANY file on the
  ! machine can be served using this procedure.

    p_web.HeaderDetails.ContentDisposition = 'attachment; filename="'&p_web.GetValue('name')&'"'
  END

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: servedocument from html
« Reply #3 on: May 28, 2013, 09:31:47 PM »
good.