Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Undefined Constant #1877

Open
MadTomT opened this issue Jan 26, 2023 · 3 comments
Open

Error Undefined Constant #1877

MadTomT opened this issue Jan 26, 2023 · 3 comments
Labels

Comments

@MadTomT
Copy link

MadTomT commented Jan 26, 2023

Hi,
I'm using an old version of phpseclib and it works fine for my requirements. However after an OS upgrade I've now started to get the following error:

"PHP Fatal error: Uncaught Error: Undefined constant "NET_SSH2_DISCONNECT_BY_APPLICATION""

Looking at old posts I can see this has been resolved, but my issue is I can't user composor to install the updated application.

I've read v2.0 will still allow manual installation, so I've copies the files to my server but then I get "PHP Fatal error: Uncaught Error: Class "Net_SSH2" not found"

The code I'm using to make the connection is $ssh = new Net_SSH2( $ipaddress );
Looking at Net/SSH/SSH2.php I can see the name has now changed to SSH2, so I changed my connection command to
$ssh = new SSH2( $ipaddress ); but that gives error "PHP Fatal error: Uncaught Error: Class "SSH2" not found"

This is the example I'm currently using.

include('/Net/SSH2.php');

$ssh = new SSH2( $ipaddress );
if ( !$ssh->login( $user, $password ) ) {
	exit('Login Failed<br/>');
}

Could some one help me get this working.
Thanks

@terrafrost
Copy link
Member

Apologies for the delay - I was out camping this weekend.

Looking at Net/SSH/SSH2.php I can see the name has now changed to SSH2, so I changed my connection command to
$ssh = new SSH2( $ipaddress ); but that gives error "PHP Fatal error: Uncaught Error: Class "SSH2" not found"

Sounds like you're trying to use the latest code in the master branch when you should be using the latest code in the 2.0 branch:

https://github.com/phpseclib/phpseclib/tree/2.0

@MadTomT
Copy link
Author

MadTomT commented Jan 30, 2023

Thanks, I am using 2.0.41 and that is what's showing the error.
Any idea how I can resolve this ?

@terrafrost
Copy link
Member

How did you install phpseclib? phpseclib 2.0 requires the use of an auto loader. Like you shouldn't be needing to do include() on any phpseclib files. I mean, you could do so but, most likely, you'd have to painstakingly load all the dependencies as well (eg Math/BigInteger.php, Crypt/Rijndael.php, Crypt/Base.php, etc). And even if you were going to go that route, most likely, the Net directory is not installed in the root directory as include('/Net/SSH2.php'); would imply but, rather, is installed in the current working directory. ie. if you were going to include a file you'd prob be better off doing include('./Net/SSH2.php');

@bantu bantu added the support label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants