Current time: 11-21-2019, 03:29 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using REST API to run server based script file
08-27-2014, 01:31 AM
Post: #1
Using REST API to run server based script file
I am wondering if the REST API can be used to load and run a script file hosted on the private instance?

I would like to be able to submit a request from an application of our and passing the script via a post is less than ideal (login info would need to be passed).

Thanks
Find all posts by this user
Quote this message in a reply
08-30-2014, 01:48 AM
Post: #2
RE: Using REST API to run server based script file
No, it can't pull pre-defined scripts (currently anyway).
Visit this user's website Find all posts by this user
Quote this message in a reply
08-30-2014, 04:40 AM
Post: #3
RE: Using REST API to run server based script file
(08-30-2014 01:48 AM)pmeenan Wrote:  No, it can't pull pre-defined scripts (currently anyway).

Thanks, good to know. Maybe if I have time I'll search the code see what is involved in do that (maybe hardcode path and just send filename to minimize security risk)
Find all posts by this user
Quote this message in a reply
08-30-2014, 04:54 AM
Post: #4
RE: Using REST API to run server based script file
Shouldn't be too hard. Somewhere around here: https://github.com/WPO-Foundation/webpag...st.php#L76

Add a new parameter that identifies pre-defined scripts (say "runscript") and if that parameter is set go load the script into $test['script']. It will get treated as if it was passed in from that point on (do it after $test['script'] is initially set or it will be overwritten). You need to be a bit careful about server attacks so don't pass in the actual file name unless you do some regex scrubbing.

Another option (maybe cleaner) would be to define script replacement strings and in ValidateScript ( https://github.com/WPO-Foundation/webpag....php#L1105 ) you could do the string replacement like we do for the built-in %URL% and %HOST% placeholders.
Visit this user's website Find all posts by this user
Quote this message in a reply
08-30-2014, 05:16 AM
Post: #5
RE: Using REST API to run server based script file
Ahh cool. Thanks for the info, the cleaner is a good idea.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)