How-to Read / Set Gain from SkyView and Gmap

.

.

Set Gain Using A Drop-down List

Below is the revised code for file /usr/share/dump1090-fa/html/gain.php.

With this code, the map will have a drop-down list (instead of text entry) for selecting desired gain setting. The current gain is displayed in red above drop-down.


<html>
 <form id="myform" action="gain.php" method="post" />
 <div><font color=#ff0000 face="'Helvetica Neue', Helvetica, Arial, sans-serif">Current Gain: <?php system('/var/www/html/setgain/findgain.sh');?> </font></div>
 <select name="gain" id="gain">
   <option value=-10>-10</option>
   <option value=49.6>49.6</option>
   <option value=48.0>48.0</option>
   <option value=44.5>44.5</option>
   <option value=43.9>43.9</option>
   <option value=43.4>43.4</option>
   <option value=42.1>42.1</option>
   <option value=40.2>40.2</option>
   <option value=38.6>38.6</option>
   <option value=37.2>37.2</option>
   <option value=36.4>36.4</option>
   <option value=33.8>33.8</option>
   <option value=32.8>32.8</option>
   <option value=29.7>29.7</option>
   <option value=28.0>28.0</option>
   <option value=25.4>25.4</option>
   <option value=22.9>22.9</option>
   <option value=20.7>20.7</option>
   <option value=19.7>19.7</option>
   <option value=16.6>16.6</option>
 </select>
 <input type="submit" value="Set Gain" style="color:#ffffff;background-color:#00A0E2;border-color:#00B0F0;" />
 </form>
</html>

<?php
function setgain(){
$gain="{$_POST['gain']}";
system("/var/www/html/setgain/setgain.sh $gain >> /tmp/gain.log 2>&1");
header("Refresh:0");
}

if ("{$_POST['gain']}"){
setgain();
}

?>

.
.

CLICK ON THE IMAGE TO SEE LARGER SIZE

3 Likes

@abcd567 excellent ! point-drop-and-click !
(you can also limit items shown, say if more than 5, display the vertical scroll bar)

ED1 as using Akis’s page, how can I increase div size to avoid the vert scrollbar ?
also added -10 to gains being a … valid one :wink:

new_gain

Is this just a copy and paste into an existing gain.php file?

Do you need to restart Piaware, after every change, for it to take effect?

.
Yes, but first you have to delete ALL existing code in file gain.php.
Keep pressed (Ctrl+k) till all code is deleted and the file is blank. Now copy-paste the new code and save file. That is all. :slightly_smiling_face:

NOTE:
Full code is not directly visible in my post.
You have to scroll right to see some vey long lines.
You have to scroll down to see all line of code till you reach last line which is very short i.e. it is only ?>.
Dont miss any lines in copy-paste. Remember code’s first line is <html> and last line is ?>.

.
.

.
No, you dont have to restart piaware or dump1090 (fa or mut). Just select the gain value you want, click the “Set Gain” button, wait for few seconds, and that is all. :slightly_smiling_face:

When you click the “Set Gain” button, it does three things in this sequence:
(1) Changes gain to desired value.
(2) Restarts dump1090 (fa or mut), implementing new gain value.
(3) Reads the current gain and displays it in red.

.

Man…this sounds too good to be true. :smiley:

I’ll try it when I get home.

Any reason why FA does not incorporate this into the image?

I can only click like once, it deserves more.:wink:

Giving a webinterface control over the pi might not be a good idea on every network.

Making it an option they would need to change the html files when restarting piaware. It’s a bit messy.
It might be possible in an elegant way but i’m not sure how.

Thanks for pointing out. I simply forgot it, like I forget my wife’s birthday or our wedding anniversary. :wink:

Now I have edited my post and have added it. Thanks again

1 Like

I’m deleting this addition!:wink:

Signed: The -10 opponent.:rofl:

2 Likes

.
Dont ask me, ask @obj and @ericcarlson :slight_smile:

Currently there is nothing in the web interface that has the potential to change the Pi’s configuration.
As soon as something like that is added, there is a large pile of associated security issues to sort out.
That’s not something we want to tackle right now.

(hint: giving passwordless sudo to www-data, or exposing the password so it’s effectively passwordless, is a bad idea)

2 Likes

.

The file gain.php is existing ONLY if you have already added gain setting feature to SkyView/Gmap.

If you have not added this feature already, then the file gain.php will not exist. In this case go to FIRST post of the thread, click on the link matching your install, and follow instructions.

If you want a drop-down menu (instead of a text box), then dont copy-paste the code for gain.php in those posts. Instead copy-paste from my today’s post.

1 Like

@abcd567
WOW that is what I call first class service .
Thanks very much.

Glad I stopped by to read the latest posts, as I was about to start making the changes, and would likely be lost.:thinking:

I totally agree, but is it the case here? I know nothing about coding, this is why I ask.

I have a problem , I don’t know other people have it also
When I change the value of the gain , the proces to feed Planeplotter takes 100% CPU
(ppup1090)

Screenshot of top just very recent , but I saw it on graphs some hours a go something was different :
see also the rise in core temp, when I find out I did a reboot :

the Flightradar24’s web interface IP-OF-PI:8754/settings.html changes the Pi’s configuration.

I dont know the details how they do it, but they have been doing it since many years, and I never came across any mention or complaint about security issue caused by it.

CLICK ON IMAGE TO SEE LARGER SIZE

See this:

Now anyone with access to www-data (or read access to that script, for that matter) can trivially get root.

The other security-related thing is that you don’t want something like this wide open in a standard image, so there would need to be some mechanism for authenticating, which has a whole lot of infrastructure associated with it (at a minimum, a way to set/change passwords and a HTTPS certificate to secure it all…)

For a one-off thing you do yourself it’s probably not a big deal - it’s unlikely to be attacked, you can probably juggle the HTTPS and password changes by hand, it’s a calculated risk.

For something where there are 18000 installs that are mostly maintained by users who aren’t familiar with any of this, though, it’s a completely different question and we have to be much much more careful.

1 Like

Yep…I can see that. No need to know code.:wink: I was looking at the listing posted this afternoon. I did not see anything of the sort there, hence my question.

Something to keep in mind for sure. An individual user is free to do whatever he/she wants. I understand now why FA would not want to get into this.

Thanks, obj.

@obj
@Dxista

I agree that the code I have used is not secure enough for mass scale distribution by Flightaware.

However the Flightradar24’s Web interface Settings page is in mass use by ALL their feeders for last many years. This means that there is a way to do it in a secure way, and as I am not an IT professional, I am not aware of its details.

You could make it secure forcing to ask for password at every change of gain, instead of having it in plain text. Annoying but, if someone is security oriented… will do it.