Author |
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: February 11 2007 at 15:59 | IP Logged
|
|
|
Hello. I'm wondering if there's any way to publish the global variables from Powerhome as a .csv that anyone can access, while still keeping the webserver secure.
Basically, I want to be able to have a .csv file of global variables that I can access from my real web server using PHP. To access it, the .csv could not be behind any kind of password protection. However, I don't want peope to be able to turn my lights on in the middle of the night, so I still want my Powerhome server to be password protected.
Any idea how I could go about doing this? If a .csv isn't possible, is there any way I could just make the global variables page accessable without a password, while leaving all the other server pages secure?
Thanks
Tom
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 11 2007 at 17:02 | IP Logged
|
|
|
Not sure if you want ALL your GV's public. Think about it for a bit first.
You can add extensions for files that don't need security in Setup. I have a few extensions set up that way.
You could then create a macro to export the CSV file using ph_writefile.
Edited by TonyNo - February 11 2007 at 17:04
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: February 15 2007 at 12:23 | IP Logged
|
|
|
Tom,
There are several different ways to set this up, but the easiest (if it works for you) would be to just save the global variables as a CSV file.
Below is the formula to do this (assuming the board doesnt screw up my syntax):
Code:
ph_sqlselect(1,"select * from global_variables") + ph_setvar_s(1,2,"") + ph_forloopwinc("ph_concatvar(1,2,ph_getdata(1,ph_getvar_n(1, 1),1) + '~t' + ph_getdata(1,ph_getvar_n(1,1),2) + '~r~n')",1,ph_getsqlrows(1),1,1) + ph_sqldestroy(1) + ph_writefile("globalvar.csv",1,ph_getvar_s(1,2))
|
|
|
It's not really a CSV file (but you could easily make it one if that's what you really want). The format I used was GV ID, tab character, GV Data, carriage return / line feed. It's fairly simple and easily modifiable if need be (if you need help though, don't hesitate to ask).
HTH,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 15 2007 at 13:57 | IP Logged
|
|
|
Well, that's way better than mine!
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: February 17 2007 at 16:47 | IP Logged
|
|
|
Awesome, that does exactly what I want in terms of exporting data. Thanks for setting that up.
Now that I have the csv file in the web directory, how do I make it accessable for anyone without un-securing the entire web server? I can't seem to find an option for that in the Web panel...
Tom
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 17 2007 at 19:44 | IP Logged
|
|
|
Ah. I was mistaken. All access needs to be behind a PW, except for white-listed IP's.
I don't suppose you're running another web server on that machine? If you were, you could just write the file to a shared folder.
I use a free, open-source, Java-based web server called Xerver.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: February 19 2007 at 15:10 | IP Logged
|
|
|
Tom,
If you're not already using PSP pages, you could set the "Access" in the web setup to "Any". You could then take the code above with simple modifications to return HTML directly in a table format.
If you're already using PSP, you could still do this, but you would have to add userid/password checking to every existing PSP file that you wish to still have credentials required. This can be as simple as adding the a single PSP line to the top of your PSP files as detailed in the example below:
Code:
<%ph_rtne(if(ph_getwebauth() <> 2,ph_setwebreturn(401),0))%>
<html>
<body>
TEST
</body>
</html>
|
|
|
Hope this helps,
Dave.
|
Back to Top |
|
|
|
|