telephone / LookingGlass

A user-friendly PHP Looking Glass
MIT License
1.25k stars 345 forks source link

run commands (mtr, ping , traceroute) not working #46

Open dkraklan opened 6 years ago

dkraklan commented 6 years ago

hello,

I've installed LookingGlass and installation went smooth, however when ever I input an IP and click run test it says loading for a half a second then goes back to run test and never provides any results.

I found an old issue suggesting to change to php 5.4 which i did. I've also tried php 7. I'm not sure what I'm missing any help would be greatly appreciated.

ghost commented 6 years ago

Refer to:
https://github.com/telephone/LookingGlass/issues/44#issuecomment-333401402

Edit ajax.php and replace:

$output = $lg->$_GET['cmd']($_GET['host']);

with

$output = $lg->{$_GET['cmd']}$_GET['host']);

This works on all new PHP builds for me.

dkraklan commented 6 years ago

Thank you! Are you able to explain what adding the curly braces does ?

andrew867 commented 6 years ago

http://php.net/manual/en/migration70.incompatible.php

Changes to the handling of indirect variables, properties, and methods Indirect access to variables, properties, and methods will now be evaluated strictly in left-to-right order, as opposed to the previous mix of special cases.

maxigentr commented 5 years ago

Refer to: #44 (comment)

Edit ajax.php and replace:

$output = $lg->$_GET['cmd']($_GET['host']);

with

$output = $lg->{$_GET['cmd']}$_GET['host']);

This works on all new PHP builds for me.

You have to correct the 44th line as follows.

$output = $lg->{$_GET['cmd']}($_GET['host']);

damianharouff commented 4 years ago

Putting this here for my future self, and likely for other people: if mtr returns an empty box, but ping, traceroute, etc work, it's likely because mtr is suid:

root@lg:/var/www/html# chsh -s /bin/bash www-data root@lg:/var/www/html# su www-data www-data@lg:/html$ mtr mtr: mtr should not run suid: No such file or directory www-data@lg:/html$

chmod u-s /usr/sbin/mtr fixed it.

kgrahul commented 3 years ago

I replaced that line but doesnt work

umiseaz commented 2 months ago

Refer to:
https://github.com/telephone/LookingGlass/issues/44#issuecomment-333401402

Edit ajax.php and replace:

$output = $lg->$_GET['cmd']($_GET['host']);

with

$output = $lg->{$_GET['cmd']}$_GET['host']);

This works on all new PHP builds for me.

Working on Ubuntu 20.04 and php7.4.3