[GH-ISSUE #44] Fatal error: Uncaught Error: Function name must be a string in /ajax.php:44 #28

Open
opened 2026-02-28 00:40:14 +03:00 by kerem · 9 comments
Owner

Originally created by @Smir on GitHub (Aug 15, 2017).
Original GitHub issue: https://github.com/telephone/LookingGlass/issues/44

Just installed and can't ping, traceroute or anything to do with that area.
Fatal error: Uncaught Error: Function name must be a string in /ajax.php:44 Stack trace: #0 {main} thrown in /ajax.php on line 44
Line 44 of ajax.php reads;
$output = $lg->$_GET['cmd']($_GET['host']);

Regards

Originally created by @Smir on GitHub (Aug 15, 2017). Original GitHub issue: https://github.com/telephone/LookingGlass/issues/44 Just installed and can't ping, traceroute or anything to do with that area. `Fatal error: Uncaught Error: Function name must be a string in /ajax.php:44 Stack trace: #0 {main} thrown in /ajax.php on line 44` Line 44 of ajax.php reads; ` $output = $lg->$_GET['cmd']($_GET['host']);` Regards
Author
Owner

@Volodya1234 commented on GitHub (Aug 16, 2017):

I will do this string for case:

	switch ($_GET['cmd']) {
		case "host":
			$output = $lg->host($_GET['host']);
			break;
		case "mtr":
			$output = $lg->mtr($_GET['host']);
			break;
		case "mtr6":
			$output = $lg->mtr6($_GET['host']);
			break;
		case "ping":
			$output = $lg->ping($_GET['host']);
			break;
		case "ping6":
			$output = $lg->ping6($_GET['host']);
			break;
		case "traceroute":
			$output = $lg->traceroute($_GET['host']);
			break;				
		case "traceroute6":
			$output = $lg->traceroute6($_GET['host']);
			break;
	}
<!-- gh-comment-id:322678159 --> @Volodya1234 commented on GitHub (Aug 16, 2017): I will do this string for case: switch ($_GET['cmd']) { case "host": $output = $lg->host($_GET['host']); break; case "mtr": $output = $lg->mtr($_GET['host']); break; case "mtr6": $output = $lg->mtr6($_GET['host']); break; case "ping": $output = $lg->ping($_GET['host']); break; case "ping6": $output = $lg->ping6($_GET['host']); break; case "traceroute": $output = $lg->traceroute($_GET['host']); break; case "traceroute6": $output = $lg->traceroute6($_GET['host']); break; }
Author
Owner

@Smir commented on GitHub (Aug 16, 2017):

Whats this for??

<!-- gh-comment-id:322910174 --> @Smir commented on GitHub (Aug 16, 2017): Whats this for??
Author
Owner

@Volodya1234 commented on GitHub (Aug 28, 2017):

  • Whats this for??
    This is fix.

Not all people are programmers and sometimes come to the github to find a solution to the problem and nothing more. I wrote a simple solution to this problem.

<!-- gh-comment-id:325375988 --> @Volodya1234 commented on GitHub (Aug 28, 2017): - Whats this for?? This is fix. Not all people are programmers and sometimes come to the github to find a solution to the problem and nothing more. I wrote a simple solution to this problem.
Author
Owner

@Smir commented on GitHub (Aug 28, 2017):

I have no idea what you posted?

do you mean overwrite line44 with what you posted?

<!-- gh-comment-id:325394868 --> @Smir commented on GitHub (Aug 28, 2017): I have no idea what you posted? do you mean overwrite line44 with what you posted?
Author
Owner

@Volodya1234 commented on GitHub (Aug 28, 2017):

  • do you mean overwrite line44 with what you posted?

Yes. It is necessary to rewrite this function in line44 to the code that I wrote above.

<!-- gh-comment-id:325396644 --> @Volodya1234 commented on GitHub (Aug 28, 2017): - do you mean overwrite line44 with what you posted? Yes. It is necessary to rewrite this function in line44 to the code that I wrote above.
Author
Owner

@Pulseeey commented on GitHub (Aug 30, 2017):

I just rewrote it to this, PHP 7 likes it now.
$output = $lg->{$_GET['cmd']}$_GET['host']);

<!-- gh-comment-id:325970694 --> @Pulseeey commented on GitHub (Aug 30, 2017): I just rewrote it to this, PHP 7 likes it now. `$output = $lg->{$_GET['cmd']}$_GET['host']);`
Author
Owner

@InsaneSplash commented on GitHub (Oct 1, 2017):

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

There is a missing ( in @Volodya1234 's code

<!-- gh-comment-id:333401402 --> @InsaneSplash commented on GitHub (Oct 1, 2017): $output = $lg->{$_GET['cmd']}($_GET['host']); There is a missing ( in @Volodya1234 's code
Author
Owner

@yavg commented on GitHub (Jan 26, 2021):

after i change $output = $lg->$_GET'cmd';
to $output = $lg->{$_GET['cmd']}($_GET['host']);
my lg is work now.

<!-- gh-comment-id:767590393 --> @yavg commented on GitHub (Jan 26, 2021): after i change $output = $lg->$_GET['cmd']($_GET['host']); to $output = $lg->{$_GET['cmd']}($_GET['host']); my lg is work now.
Author
Owner

@herzadigital commented on GitHub (Jan 19, 2025):

I will do this string for case:

	switch ($_GET['cmd']) {
		case "host":
			$output = $lg->host($_GET['host']);
			break;
		case "mtr":
			$output = $lg->mtr($_GET['host']);
			break;
		case "mtr6":
			$output = $lg->mtr6($_GET['host']);
			break;
		case "ping":
			$output = $lg->ping($_GET['host']);
			break;
		case "ping6":
			$output = $lg->ping6($_GET['host']);
			break;
		case "traceroute":
			$output = $lg->traceroute($_GET['host']);
			break;				
		case "traceroute6":
			$output = $lg->traceroute6($_GET['host']);
			break;
	}

Can you explain where to put this precisely?

<!-- gh-comment-id:2600796443 --> @herzadigital commented on GitHub (Jan 19, 2025): > I will do this string for case: > > ``` > switch ($_GET['cmd']) { > case "host": > $output = $lg->host($_GET['host']); > break; > case "mtr": > $output = $lg->mtr($_GET['host']); > break; > case "mtr6": > $output = $lg->mtr6($_GET['host']); > break; > case "ping": > $output = $lg->ping($_GET['host']); > break; > case "ping6": > $output = $lg->ping6($_GET['host']); > break; > case "traceroute": > $output = $lg->traceroute($_GET['host']); > break; > case "traceroute6": > $output = $lg->traceroute6($_GET['host']); > break; > } > ``` Can you explain where to put this precisely?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LookingGlass#28
No description provided.