Page 1 of 1

How to access LUA variables in client plugins

Posted: Tue May 19, 2015 7:03 pm
by StenAaboHansen
How to ?

I want to control the visibility and access to a client plugin. If the user accessing the FTP server from within my local network (defined by IP range) the user must see and activate the menu item but if the usre come from the internet the user may not see it. If it is possible to access LUA server variables i would be possible to du this.

Can anyone tell me how to do it.

Re: How to access LUA variables in client plugins

Posted: Wed May 20, 2015 2:45 am
by FTP
Yes, you can get the client IP by the Lua global variable "_REMOTE_IP".

Re: How to access LUA variables in client plugins

Posted: Wed May 20, 2015 8:57 pm
by StenAaboHansen
Thanks, it works

To other, who need to create client menu entry. The code below control the IP number of the user, my WINGFTP server is behind a F5 proxy then all external users come from only one IP number. If they come from the Internet they do not have the menu entry. I they come from intranet they will see the menu entry.

<%
local tab1 = {}
if _REMOTE_IP == "xx.xx.xx.xx" then a=""; else
tab1.plugin_enabled = true
tab1.extbutton_name = "User manager"
tab1.extbutton_func = "show_mydiv1()"
tab1.extbutton_icon = "plugins/User_Adm_1/icon3.png"
tab1.need_selectfile = false
tab1.exthtml = [[ <div id="commandUser" style="position:absolute; border:0; z-index:50; top:75px;
left:500px; width:150px; height:10px; padding:1px; text-align:center;
background:#FFFFFF; display:none; onclick="hide_mydiv1()";>
<form action="http://my-server:8080/" method="get"><input type="image" src="plugins/User_Adm_1/icon3.png" alt="User Manager" ></form>
</div>
]]
tab1.extjs = [[
function show_mydiv1() { $("commandUser").style.display = "";}
function hide_mydiv1() { $("commandUser").style.display = "none";}
]]
register_plugin(tab1)
end
%>