blesta / module-pterodactyl

Blesta API integration with Pterodactyl
MIT License
12 stars 7 forks source link

Class Blesta\Core\Util\Validate\Server not found #16

Closed daemex closed 4 years ago

daemex commented 4 years ago

Hello, First of all, I don't know how I could thank you enough for this module. The only issue after installing is the following in the logs:

Fatal Error (E_ERROR): Class 'Blesta\Core\Util\Validate\Server' not found {"code":1,"message":"Class 'Blesta\Core\Util\Validate\Server' not found","file":"../pterodactyl.php"

I checked the core libraries for Blesta but there is no Blesta\Core\Util\Validate\Server? Any assistance is appreciated. Thank you!

JReissmueller commented 4 years ago

That is a dependency on Blesta 4.8(unreleased). To make it compatible with previous version you will need to make a couple changes.

First, remove the use statements for 'Blesta\Core\Util\Validate\Server' in pterodactyl.php and lib/prterodactyl_rule.php. Second update the lib/pterodctyl_rule.php lines 166-167 from

            $validator = new Server();
            return $validator->isUrl($value);

To

    if (strlen($value) > 255) {
        return false;
    }

    return $this->Input->matches(
        $value,
        "/^([a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])(\.([a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9]))+$/i"
    );

Finally, update pterodactyl.php lines 1109-1110 from

                    $validator = new Server();
                    return $validator->isDomain($host_name) || $validator->isIp($host_name);

To

    if (strlen($host_name) > 255) {
        return false;
    }

    return $this->Input->matches(
        $host_name,
        "/^([a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9])(\.([a-z0-9]|[a-z0-9][a-z0-9\-]{0,61}[a-z0-9]))+$/i"
    );
daemex commented 4 years ago

Hi @JReissmueller Thank you for the response! I have made the changes and now it appears I have one more error: Class 'Blesta\PterodactylSDK\PterodactylApi' not found {"code":1,"message":"Class 'Blesta\PterodactylSDK\PterodactylApi' not found","file":"../pterodactyl/pterodactyl.php","line":1087,"trace":null}

The method I used to install was simply copy source files, I did not use compose. Thanks!

JReissmueller commented 4 years ago

That would be why. You're gonna encounter a number of issues in that case. This module requires composer for autoloading files both internal (e.g. lib/pterodactyl_package.php) and external (the Pterodactyl SDK).

You probably have two options. 1. Run composer in the pterodactyl module. 2. add new include and use statements in all necessary files (sounds like a total pain).

daemex commented 4 years ago

Hi @JReissmueller

I have installed compose and ran it in the pterodactyl module directory. It installed everything successfully. However, I'm still getting an error that the class 'Blesta\PterodactylSDK\PterodactylApi' can't be found. It appears to be in a vendor folder under blesta/pterodactyl-sdk/PterodactlApi.php

Any ideas as to why? Thank you!

daemex commented 4 years ago

Aha! Ok I autoloaded on pterodactyl.php and it works but now it says it can't make a connection to the panel smh

Edit: Never mind, I got it now! Woop!

A question for you @JReissmueller, do you have a discord?

JReissmueller commented 4 years ago

Jono#9667